window.CodeMirror=function(){function n(a,b){if(!(this instanceof n))return new n(a,b);this.options=b=b||{};for(var c in Kb)!b.hasOwnProperty(c)&&Kb.hasOwnProperty(c)&&(b[c]=Kb[c]);Lb(b);c=this.display=Hd(a,"string"==typeof b.value?0:b.value.first);c.wrapper.CodeMirror=this;Ac(this);b.autofocus&&!Mb&&I(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,draggingText:!1,highlight:new Nb};Bc(this);b.lineWrapping&&(this.display.wrapper.className+=
" CodeMirror-wrap");var d=b.value;"string"==typeof d&&(d=new J(b.value,b.mode));w(this,Cc)(this,d);B&&setTimeout(L(Z,this,!0),20);Id(this);var e;try{e=document.activeElement==c.input}catch(f){}e||b.autofocus&&!Mb?setTimeout(L(ca,this),20):Ob(this);w(this,function(){for(var a in la)if(la.propertyIsEnumerable(a))la[a](this,b[a],Dc);for(a=0;a<Pb.length;++a)Pb[a](this)})()}function Hd(a,b){var c={},d=c.input=r("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none; font-size: 4px;");
M?d.style.width="1000px":d.setAttribute("wrap","off");Ca&&(d.style.border="1px solid black");d.setAttribute("autocorrect","off");d.setAttribute("autocapitalize","off");c.inputDiv=r("div",[d],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");c.scrollbarH=r("div",[r("div",null,null,"height: 1px")],"CodeMirror-hscrollbar");c.scrollbarV=r("div",[r("div",null,null,"width: 1px")],"CodeMirror-vscrollbar");c.scrollbarFiller=r("div",null,"CodeMirror-scrollbar-filler");c.lineDiv=r("div");
c.selectionDiv=r("div",null,null,"position: relative; z-index: 1");c.cursor=r("div","\u00a0","CodeMirror-cursor");c.otherCursor=r("div","\u00a0","CodeMirror-cursor CodeMirror-secondarycursor");c.measure=r("div",null,"CodeMirror-measure");c.lineSpace=r("div",[c.measure,c.selectionDiv,c.lineDiv,c.cursor,c.otherCursor],null,"position: relative; outline: none");c.mover=r("div",[r("div",[c.lineSpace],"CodeMirror-lines")],null,"position: relative");c.sizer=r("div",[c.mover],"CodeMirror-sizer");c.heightForcer=
r("div",null,null,"position: absolute; height: "+Da+"px; width: 1px;");c.gutters=r("div",null,"CodeMirror-gutters");c.lineGutter=null;var e=r("div",[c.sizer,c.heightForcer,c.gutters],null,"position: relative; min-height: 100%");c.scroller=r("div",[e],"CodeMirror-scroll");c.scroller.setAttribute("tabIndex","-1");c.wrapper=r("div",[c.inputDiv,c.scrollbarH,c.scrollbarV,c.scrollbarFiller,c.scroller],"CodeMirror");ma&&(c.gutters.style.zIndex=-1,c.scroller.style.paddingRight=0);a.appendChild?a.appendChild(c.wrapper):
a(c.wrapper);Ca&&(d.style.width="0px");M||(c.scroller.draggable=!0);Qb?(c.inputDiv.style.height="1px",c.inputDiv.style.position="absolute"):ma&&(c.scrollbarH.style.minWidth=c.scrollbarV.style.minWidth="18px");c.viewOffset=c.lastSizeC=0;c.showingFrom=c.showingTo=b;c.lineNumWidth=c.lineNumInnerWidth=c.lineNumChars=null;c.prevInput="";c.alignWidgets=!1;c.pollingFast=!1;c.poll=new Nb;c.cachedCharWidth=c.cachedTextHeight=null;c.measureLineCache=[];c.measureLineCachePos=0;c.inaccurateSelection=!1;c.maxLine=
null;c.maxLineLength=0;c.maxLineChanged=!1;c.wheelDX=c.wheelDY=c.wheelStartX=c.wheelStartY=null;return c}function Ea(a){a.doc.mode=n.getMode(a.options,a.doc.modeOption);a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null);a.styles&&(a.styles=null)});a.doc.frontier=a.doc.first;bb(a,100);a.state.modeGen++;a.curOp&&A(a)}function Ec(a){var b=Fa(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/Fc(a.display)-3);return function(e){return da(a.doc,e)?0:c?(Math.ceil(e.text.length/
d)||1)*b:b}}function Gc(a){var b=a.doc,c=Ec(a);b.iter(function(a){var b=c(a);b!=a.height&&Q(a,b)})}function Bc(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-");na(a)}function Ga(a){Ac(a);A(a)}function Ac(a){var b=a.display.gutters,c=a.options.gutters;cb(b);for(var d=0;d<c.length;++d){var e=c[d],f=b.appendChild(r("div",null,"CodeMirror-gutter "+e));"CodeMirror-linenumbers"==e&&(a.display.lineGutter=f,f.style.width=
(a.display.lineNumWidth||1)+"px")}b.style.display=d?"":"none"}function db(a,b){if(0==b.height)return 0;for(var c=b.text.length,d,e=b;d=ea(e,-1);)d=d.find(),e=s(a,d.from.line),c+=d.from.ch-d.to.ch;for(e=b;d=Ha(e);)d=d.find(),c-=e.text.length-d.from.ch,e=s(a,d.to.line),c+=e.text.length-d.to.ch;return c}function Rb(a){var b=a.display,c=a.doc;b.maxLine=s(c,c.first);b.maxLineLength=db(c,b.maxLine);b.maxLineChanged=!0;c.iter(function(a){var e=db(c,a);e>b.maxLineLength&&(b.maxLineLength=e,b.maxLine=a)})}
function Lb(a){for(var b=!1,c=0;c<a.gutters.length;++c)"CodeMirror-linenumbers"==a.gutters[c]&&(a.lineNumbers?b=!0:a.gutters.splice(c--,1));!b&&a.lineNumbers&&a.gutters.push("CodeMirror-linenumbers")}function Hc(a,b){var c=b+(a.mover.offsetHeight-a.lineSpace.offsetHeight);a.sizer.style.minHeight=a.heightForcer.style.top=c+"px";var c=Math.max(c,a.scroller.scrollHeight),d=a.scroller.scrollWidth>a.scroller.clientWidth,e=c>a.scroller.clientHeight;e?(a.scrollbarV.style.display="block",a.scrollbarV.style.bottom=
d?eb(a.measure)+"px":"0",a.scrollbarV.firstChild.style.height=c-a.scroller.clientHeight+a.scrollbarV.clientHeight+"px"):a.scrollbarV.style.display="";d?(a.scrollbarH.style.display="block",a.scrollbarH.style.right=e?eb(a.measure)+"px":"0",a.scrollbarH.firstChild.style.width=a.scroller.scrollWidth-a.scroller.clientWidth+a.scrollbarH.clientWidth+"px"):a.scrollbarH.style.display="";d&&e?(a.scrollbarFiller.style.display="block",a.scrollbarFiller.style.height=a.scrollbarFiller.style.width=eb(a.measure)+
"px"):a.scrollbarFiller.style.display="";Jd&&0===eb(a.measure)&&(a.scrollbarV.style.minWidth=a.scrollbarH.style.minHeight=Kd?"18px":"12px")}function Sb(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:fb(b,d),to:fb(b,a)}}function Ic(a){var b=a.display;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var c=Tb(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<h.length;++g)h[g].style.left=e;a.options.fixedGutter&&(b.gutters.style.left=c+d+"px")}}function Ld(a){if(!a.options.lineNumbers)return!1;var b=a.doc,b=Ub(a.options,b.first+b.size-1);a=a.display;if(b.length!=a.lineNumChars){var c=a.measure.appendChild(r("div",[r("div",b)],"CodeMirror-linenumber CodeMirror-gutter-elt")),d=c.firstChild.offsetWidth,c=c.offsetWidth-d;a.lineGutter.style.width=
"";a.lineNumInnerWidth=Math.max(d,a.lineGutter.offsetWidth-c);a.lineNumWidth=a.lineNumInnerWidth+c;a.lineNumChars=a.lineNumInnerWidth?b.length:-1;a.lineGutter.style.width=a.lineNumWidth+"px";return!0}return!1}function Ub(a,b){return String(a.lineNumberFormatter(b+a.firstLineNumber))}function Tb(a){return C(a.scroller).left-C(a.sizer).left}function gb(a,b,c){for(var d=a.display.showingFrom,e=a.display.showingTo,f,g=Sb(a.display,a.doc,c);;){if(Md(a,b,g))f=!0,R(a,"update",a),a.display.showingFrom==d&&
a.display.showingTo==e||R(a,"viewportChange",a,a.display.showingFrom,a.display.showingTo);else break;Vb(a);Hc(a.display,a.doc.height);c&&(c=Math.min(a.display.scroller.scrollHeight-a.display.scroller.clientHeight,"number"==typeof c?c:c.top));g=Sb(a.display,a.doc,c);if(g.from>=a.display.showingFrom&&g.to<=a.display.showingTo)break;b=[]}return f}function Md(a,b,c){var d=a.display,e=a.doc;if(!d.wrapper.clientWidth)d.showingFrom=d.showingTo=e.first,d.viewOffset=0;else if(!(0==b.length&&c.from>d.showingFrom&&
c.to<d.showingTo)){Ld(a)&&(b=[{from:e.first,to:e.first+e.size}]);var f=d.sizer.style.marginLeft=d.gutters.offsetWidth+"px";d.scrollbarH.style.left=a.options.fixedGutter?f:"0";var g=Infinity;if(a.options.lineNumbers)for(f=0;f<b.length;++f)if(b[f].diff){g=b[f].from;break}var f=e.first+e.size,h=Math.max(c.from-a.options.viewportMargin,e.first);c=Math.min(f,c.to+a.options.viewportMargin);d.showingFrom<h&&20>h-d.showingFrom&&(h=Math.max(e.first,d.showingFrom));d.showingTo>c&&20>d.showingTo-c&&(c=Math.min(f,
d.showingTo));if(Ia)for(h=K(oa(e,s(e,h)));c<f&&da(e,s(e,c));)++c;var k=[{from:Math.max(d.showingFrom,e.first),to:Math.min(d.showingTo,f)}],k=k[0].from>=k[0].to?[]:Nd(k,b);if(Ia)for(f=0;f<k.length;++f){b=k[f];for(var l;l=Ha(s(e,b.to-1));)if(l=l.find().from.line,l>b.from)b.to=l;else{k.splice(f--,1);break}}for(f=e=0;f<k.length;++f)b=k[f],b.from<h&&(b.from=h),b.to>c&&(b.to=c),b.from>=b.to?k.splice(f--,1):e+=b.to-b.from;if(e==c-h&&h==d.showingFrom&&c==d.showingTo)Jc(a);else{k.sort(function(a,b){return a.from-
b.from});try{var m=document.activeElement}catch(p){}e<.7*(c-h)&&(d.lineDiv.style.display="none");Od(a,h,c,k,g);d.lineDiv.style.display="";m&&document.activeElement!=m&&m.offsetHeight&&m.focus();if(h!=d.showingFrom||c!=d.showingTo||d.lastSizeC!=d.wrapper.clientHeight)d.lastSizeC=d.wrapper.clientHeight;d.showingFrom=h;d.showingTo=c;bb(a,100);m=d.lineDiv.offsetTop;for(e=d.lineDiv.firstChild;e;e=e.nextSibling)if(e.lineObj&&(ma?(g=e.offsetTop+e.offsetHeight,f=g-m,m=g):(f=C(e),f=f.bottom-f.top),g=e.lineObj.height-
f,2>f&&(f=Fa(d)),.001<g||-.001>g)&&(Q(e.lineObj,f),g=e.lineObj.widgets))for(f=0;f<g.length;++f)g[f].height=g[f].node.offsetHeight;Jc(a);return!0}}}function Jc(a){var b=a.display.viewOffset=pa(a,s(a.doc,a.display.showingFrom));a.display.mover.style.top=b+"px"}function Nd(a,b){for(var c=0,d=b.length||0;c<d;++c){for(var e=b[c],f=[],g=e.diff||0,h=0,k=a.length;h<k;++h){var l=a[h];e.to<=l.from&&e.diff?f.push({from:l.from+g,to:l.to+g}):e.to<=l.from||e.from>=l.to?f.push(l):(e.from>l.from&&f.push({from:l.from,
to:e.from}),e.to<l.to&&f.push({from:e.to+g,to:l.to+g}))}a=f}return a}function Pd(a){for(var b=a.display,c={},d={},e=b.gutters.firstChild,f=0;e;e=e.nextSibling,++f)c[a.options.gutters[f]]=e.offsetLeft,d[a.options.gutters[f]]=e.offsetWidth;return{fixedPos:Tb(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function Od(a,b,c,d,e){function f(b){var c=b.nextSibling;M&&qa&&a.display.currentWheelTarget==b?(b.style.display="none",b.lineObj=null):b.parentNode.removeChild(b);
return c}var g=Pd(a),h=a.display,k=a.options.lineNumbers;d.length||M&&a.display.currentWheelTarget||cb(h.lineDiv);var l=h.lineDiv,m=l.firstChild,p=d.shift(),y=b;for(a.doc.iter(b,c,function(b){p&&p.to==y&&(p=d.shift());if(da(a.doc,b)){if(0!=b.height&&Q(b,0),b.widgets&&m.previousSibling)for(var c=0;c<b.widgets.length;++c)if(b.widgets[c].showIfHidden){var h=m.previousSibling;if(/pre/i.test(h.nodeName)){var n=r("div",null,null,"position: relative");h.parentNode.replaceChild(n,h);n.appendChild(h);h=n}n=
h.appendChild(r("div",[b.widgets[c].node],"CodeMirror-linewidget"));Wb(b.widgets[c],n,h,g)}}else if(p&&p.from<=y&&p.to>y){for(;m.lineObj!=b;)m=f(m);k&&e<=y&&m.lineNumber&&Kc(m.lineNumber,Ub(a.options,y));m=m.nextSibling}else{if(b.widgets)for(var q=0,s=m;s&&20>q;++q,s=s.nextSibling)if(s.lineObj==b&&/div/i.test(s.nodeName)){c=s;break}var t=y,s=c,q=Xb(a,b),N=b.gutterMarkers,w=a.display;if(a.options.lineNumbers||N||b.bgClass||b.wrapClass||b.widgets){if(s){s.alignable=null;for(var F=!0,v=0,u=s.firstChild,
x;u;u=x)if(x=u.nextSibling,/\bCodeMirror-linewidget\b/.test(u.className)){for(var z=0,C=!0;z<b.widgets.length;++z){var B=b.widgets[z],A=!1;B.above||(A=C,C=!1);if(B.node==u.firstChild){Wb(B,u,s,g);++v;A&&s.insertBefore(q,u);break}}if(z==b.widgets.length){F=!1;break}}else s.removeChild(u);F&&v==b.widgets.length&&(h=s,s.className=b.wrapClass||"")}h||(h=r("div",null,b.wrapClass,"position: relative"),h.appendChild(q));b.bgClass&&h.insertBefore(r("div",null,b.bgClass+" CodeMirror-linebackground"),h.firstChild);
if(a.options.lineNumbers||N)if(n=h.insertBefore(r("div",null,null,"position: absolute; left: "+(a.options.fixedGutter?g.fixedPos:-g.gutterTotalWidth)+"px"),h.firstChild),a.options.fixedGutter&&(h.alignable||(h.alignable=[])).push(n),!a.options.lineNumbers||N&&N["CodeMirror-linenumbers"]||(h.lineNumber=n.appendChild(r("div",Ub(a.options,t),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+g.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+w.lineNumInnerWidth+"px"))),N)for(z=0;z<a.options.gutters.length;++z)B=
a.options.gutters[z],(t=N.hasOwnProperty(B)&&N[B])&&n.appendChild(r("div",[t],"CodeMirror-gutter-elt","left: "+g.gutterLeft[B]+"px; width: "+g.gutterWidth[B]+"px"));ma&&(h.style.zIndex=2);if(b.widgets&&h!=s)for(z=0,s=b.widgets;z<s.length;++z)B=s[z],N=r("div",[B.node],"CodeMirror-linewidget"),Wb(B,N,h,g),B.above?h.insertBefore(N,a.options.lineNumbers&&0!=b.height?n:q):h.appendChild(N),R(B,"redraw")}else h=q;if(h!=c)l.insertBefore(h,m);else{for(;m!=c;)m=f(m);m=m.nextSibling}h.lineObj=b}++y});m;)m=f(m)}
function Wb(a,b,c,d){a.noHScroll&&((c.alignable||(c.alignable=[])).push(b),c=d.wrapperWidth,b.style.left=d.fixedPos+"px",a.coverGutter||(c-=d.gutterTotalWidth,b.style.paddingLeft=d.gutterTotalWidth+"px"),b.style.width=c+"px");a.coverGutter&&(b.style.zIndex=5,b.style.position="relative",a.noHScroll||(b.style.marginLeft=-d.gutterTotalWidth+"px"))}function Vb(a){var b=a.display,c=x(a.doc.sel.from,a.doc.sel.to);if(c||a.options.showCursorWhenSelecting){var d=a.display,e=S(a,a.doc.sel.head,"div");d.cursor.style.left=
e.left+"px";d.cursor.style.top=e.top+"px";d.cursor.style.height=Math.max(0,e.bottom-e.top)*a.options.cursorHeight+"px";d.cursor.style.display="";e.other?(d.otherCursor.style.display="",d.otherCursor.style.left=e.other.left+"px",d.otherCursor.style.top=e.other.top+"px",d.otherCursor.style.height=.85*(e.other.bottom-e.other.top)+"px"):d.otherCursor.style.display="none"}else b.cursor.style.display=b.otherCursor.style.display="none";c?b.selectionDiv.style.display="none":Qd(a);a.options.moveInputWithCursor&&
(a=S(a,a.doc.sel.head,"div"),c=C(b.wrapper),d=C(b.lineDiv),b.inputDiv.style.top=Math.max(0,Math.min(b.wrapper.clientHeight-10,a.top+d.top-c.top))+"px",b.inputDiv.style.left=Math.max(0,Math.min(b.wrapper.clientWidth-10,a.left+d.left-c.left))+"px")}function Qd(a){function b(a,b,c,d){0>b&&(b=0);g.appendChild(r("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 l=s(e,c),m=l.text.length,p=g?Infinity:
-Infinity;Rd(T(l),d||0,null==f?m:f,function(e,y,n){var s=ib(a,q(c,e),"div",l),r,t;e==y?(r=s,n=t=s.left):(r=ib(a,q(c,y-1),"div",l),"rtl"==n&&(n=s,s=r,r=n),n=s.left,t=r.right);3<r.top-s.top&&(b(n,s.top,null,s.bottom),n=k,s.bottom<r.top&&b(n,s.bottom,null,r.top));null==f&&y==m&&(t=h);null==d&&0==e&&(n=k);p=g?Math.min(r.top,p):Math.max(r.bottom,p);n<k+1&&(n=k);b(n,r.top,t-n,r.bottom)});return p}var d=a.display,e=a.doc,f=a.doc.sel,g=document.createDocumentFragment(),h=d.lineSpace.offsetWidth,k=U(a.display.measure,
r("pre",null,null,"text-align: left")).appendChild(r("span","x")).offsetLeft;if(f.from.line==f.to.line)c(f.from.line,f.from.ch,f.to.ch);else{for(var l=s(e,f.from.line),m=l,p=[f.from.line,f.from.ch],y;m=Ha(m);){m=m.find();p.push(m.from.ch,m.to.line,m.to.ch);if(m.to.line==f.to.line){p.push(f.to.ch);y=!0;break}m=s(e,m.to.line)}if(y)for(f=0;f<p.length;f+=3)c(p[f],p[f+1],p[f+2]);else p=s(e,f.to.line),l=f.from.ch?c(f.from.line,f.from.ch,null,!1):pa(a,l)-d.viewOffset,f=f.to.ch?c(f.to.line,ea(p,-1)?null:
0,f.to.ch,!0):pa(a,p)-d.viewOffset,l<f&&b(k,l,null,f)}U(d.selectionDiv,g);d.selectionDiv.style.display=""}function jb(a){if(a.state.focused){var b=a.display;clearInterval(b.blinker);var c=!0;b.cursor.style.visibility=b.otherCursor.style.visibility="";b.blinker=setInterval(function(){b.cursor.style.visibility=b.otherCursor.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate)}}function bb(a,b){a.doc.mode.startState&&a.doc.frontier<a.display.showingTo&&a.state.highlight.set(b,L(Sd,a))}function Sd(a){var b=
a.doc;b.frontier<b.first&&(b.frontier=b.first);if(!(b.frontier>=a.display.showingTo)){var c=+new Date+a.options.workTime,d=ra(b.mode,Ka(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=Mc(a,g,d);for(var k=!h||h.length!=g.styles.length,l=0;!k&&l<h.length;++l)k=h[l]!=g.styles[l];k&&(f&&f.end==b.frontier?f.end++:e.push(f={start:b.frontier,end:b.frontier+1}));g.stateAfter=ra(b.mode,d)}else Nc(a,
g,d),g.stateAfter=0==b.frontier%5?ra(b.mode,d):null;++b.frontier;if(+new Date>c)return bb(a,a.options.workDelay),!0});e.length&&w(a,function(){for(var a=0;a<e.length;++a)A(this,e[a].start,e[a].end)})()}}function Td(a,b){for(var c,d,e=a.doc,f=b,g=b-100;f>g;--f){if(f<=e.first)return e.first;var h=s(e,f-1);if(h.stateAfter)return f;h=sa(h.text,null,a.options.tabSize);if(null==d||c>h)d=f-1,c=h}return d}function Ka(a,b){var c=a.doc,d=a.display;if(!c.mode.startState)return!0;var e=Td(a,b),f=e>c.first&&s(c,
e-1).stateAfter,f=f?ra(c.mode,f):Oc(c.mode);c.iter(e,b,function(g){Nc(a,g,f);g.stateAfter=e==b-1||0==e%5||e>=d.showingFrom&&e<d.showingTo?ra(c.mode,f):null;++e});return f}function Yb(a,b,c,d){var e=-1;d=d||Zb(a,b);for(a=c;!(b=d[a]);a+=e)0>e&&0==a&&(e=1);return{left:a<c?b.right:b.left,right:a>c?b.left:b.right,top:b.top,bottom:b.bottom}}function Pc(a,b){for(var c=a.display.measureLineCache,d=0;d<c.length;++d){var e=c[d];if(e.text==b.text&&e.markedSpans==b.markedSpans&&a.display.scroller.clientWidth==
e.width&&e.classes==b.textClass+"|"+b.bgClass+"|"+b.wrapClass)return e.measure}}function Zb(a,b){var c=Pc(a,b);if(!c){var d=a.display,e=Qc(b.text.length),f=Xb(a,b,e);if(B&&!ma&&!a.options.lineWrapping&&100<f.childNodes.length){for(var g=document.createDocumentFragment(),h=f.childNodes.length,c=0,k=Math.ceil(h/10);c<k;++c){for(var l=r("div",null,null,"display: inline-block"),m=0;10>m&&h;++m)l.appendChild(f.firstChild),--h;g.appendChild(l)}f.appendChild(g)}U(d.measure,f);k=C(d.lineDiv);g=[];h=Qc(b.text.length);
l=f.offsetHeight;O&&d.measure.first!=f&&U(d.measure,f);for(c=0;c<e.length;++c)if(d=e[c]){for(var f=C(d),p=Math.max(0,f.top-k.top),y=Math.min(f.bottom-k.top,l),m=0;m<g.length;m+=2){var n=g[m],s=g[m+1];if(!(n>y||s<p)&&(n<=p&&s>=y||p<=n&&y>=s||Math.min(y,s)-Math.max(p,n)>=y-p>>1)){g[m]=Math.min(p,n);g[m+1]=Math.max(y,s);break}}m==g.length&&g.push(p,y);p=f.right;d.measureRight&&(p=C(d.measureRight).left);h[c]={left:f.left-k.left,right:p-k.left,top:m}}for(c=0;c<h.length;++c)if(d=h[c])e=d.top,d.top=g[e],
d.bottom=g[e+1];c=h;e=a.display.measureLineCache;m={text:b.text,width:a.display.scroller.clientWidth,markedSpans:b.markedSpans,measure:c,classes:b.textClass+"|"+b.bgClass+"|"+b.wrapClass};16==e.length?e[++a.display.measureLineCachePos%16]=m:e.push(m)}return c}function na(a){a.display.measureLineCache.length=a.display.measureLineCachePos=0;a.display.cachedCharWidth=a.display.cachedTextHeight=null;a.options.lineWrapping||(a.display.maxLineChanged=!0);a.display.lineNumChars=null}function Rc(a,b,c,d){if(b.widgets)for(var e=
0;e<b.widgets.length;++e)if(b.widgets[e].above){var f=kb(b.widgets[e]);c.top+=f;c.bottom+=f}if("line"==d)return c;d||(d="local");b=pa(a,b);"local"!=d&&(b-=a.display.viewOffset);"page"==d&&(a=C(a.display.lineSpace),b+=a.top+(window.pageYOffset||(document.documentElement||document.body).scrollTop),a=a.left+(window.pageXOffset||(document.documentElement||document.body).scrollLeft),c.left+=a,c.right+=a);c.top+=b;c.bottom+=b;return c}function ib(a,b,c,d){d||(d=s(a.doc,b.line));return Rc(a,d,Yb(a,d,b.ch),
c)}function S(a,b,c,d,e){function f(b,f){var g=Yb(a,d,b,e);f?g.left=g.right:g.right=g.left;return Rc(a,d,g,c)}d=d||s(a.doc,b.line);e||(e=Zb(a,d));var g=T(d);b=b.ch;if(!g)return f(b);for(var h,k,l=g[0].level,m=0;m<g.length;++m){var p=g[m],y=p.level%2,n;if(p.from<b&&p.to>b)return f(b,y);var r=y?p.from:p.to;(y?p.to:p.from)==b?(p=m&&p.level<(n=g[m-1]).level?f(n.level%2?n.from:n.to-1,!0):f(y&&p.from!=p.to?b-1:b),y==l?h=p:k=p):r==b&&(n=m<g.length-1&&g[m+1],y||!n||n.from!=n.to)&&(p=n&&p.level<n.level?f(n.level%
2?n.to-1:n.from):f(y?b:b-1,!0),y==l?h=p:k=p)}l&&!b&&(k=f(g[0].to-1));if(!h)return k;k&&(h.other=k);return h}function lb(a,b,c){a=new q(a,b);c&&(a.outside=!0);return a}function $b(a,b,c){var d=a.doc;c+=a.display.viewOffset;if(0>c)return lb(d.first,0,!0);var e=fb(d,c),f=d.first+d.size-1;if(e>f)return lb(d.first+d.size-1,s(d,f).text.length,!0);for(0>b&&(b=0);;){var f=s(d,e),e=Ud(a,f,e,b,c),g=(f=Ha(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=S(a,
q(c,d),"line",b,l);h=!0;if(g>d.bottom)return d.left-k;if(g<d.top)return d.left+k;h=!1;return d.left}var g=e-pa(a,b),h=!1,k=2*a.display.wrapper.clientWidth,l=Zb(a,b),m=T(b),p=b.text.length,y=mb(b),n=nb(b),s=f(y);e=h;var r=f(n),t=h;if(d>r)return lb(c,n,t);for(;;){if(m?n==y||n==ac(b,y,1):1>=n-y){for(y=(d=d-s<r-d)?y:n;bc.test(b.text.charAt(y));)++y;e=lb(c,y,d?e:t);e.after=d;return e}var u=Math.ceil(p/2),v=y+u;if(m)for(var v=y,w=0;w<u;++w)v=ac(b,v,1);w=f(v);if(w>d){n=v;r=w;if(t=h)r+=1E3;p=u}else y=v,s=
w,e=h,p-=u}}function Fa(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==fa){fa=r("pre");for(var b=0;49>b;++b)fa.appendChild(document.createTextNode("x")),fa.appendChild(r("br"));fa.appendChild(document.createTextNode("x"))}U(a.measure,fa);b=fa.offsetHeight/50;3<b&&(a.cachedTextHeight=b);cb(a.measure);return b||1}function Fc(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=r("span","x"),c=r("pre",[b]);U(a.measure,c);b=b.offsetWidth;2<b&&(a.cachedCharWidth=b);return b||
10}function ta(a){a.curOp={changes:[],updateInput:null,userSelChange:null,textChanged:null,selectionChanged:!1,cursorActivity:!1,updateMaxLine:!1,updateScrollPos:!1,id:++Vd};ob++||($=[])}function ua(a){var b=a.curOp,c=a.doc,d=a.display;a.curOp=null;b.updateMaxLine&&Rb(a);if(d.maxLineChanged&&!a.options.lineWrapping&&d.maxLine){var e;e=d.maxLine;var f=!1;if(e.markedSpans)for(var g=0;g<e.markedSpans;++g){var h=e.markedSpans[g];!h.collapsed||null!=h.to&&h.to!=e.text.length||(f=!0)}(f=!f&&Pc(a,e))?e=
Yb(a,e,e.text.length,f).right:(e=Xb(a,e),f=e.appendChild(pb(a.display.measure)),U(a.display.measure,e),e=C(f).right-C(a.display.lineDiv).left);d.sizer.style.minWidth=Math.max(0,e+3+Da)+"px";d.maxLineChanged=!1;e=Math.max(0,d.sizer.offsetLeft+d.sizer.offsetWidth-d.scroller.clientWidth);e<c.scrollLeft&&!b.updateScrollPos&&va(a,Math.min(d.scroller.scrollLeft,e),!0)}var k,l;b.updateScrollPos?k=b.updateScrollPos:b.selectionChanged&&d.scroller.clientHeight&&(k=S(a,c.sel.head),k=qb(a,k.left,k.top,k.left,
k.bottom));if(b.changes.length||k&&null!=k.scrollTop)l=gb(a,b.changes,k&&k.scrollTop),a.display.scroller.offsetHeight&&(a.doc.scrollTop=a.display.scroller.scrollTop);!l&&b.selectionChanged&&Vb(a);if(b.updateScrollPos)d.scroller.scrollTop=d.scrollbarV.scrollTop=c.scrollTop=k.scrollTop,d.scroller.scrollLeft=d.scrollbarH.scrollLeft=c.scrollLeft=k.scrollLeft,Ic(a),b.scrollToPos&&Sc(a,t(a.doc,b.scrollToPos),b.scrollToPosMargin);else if(k&&(c=Sc(a,a.doc.sel.head),a.state.focused&&(d=a.display,k=C(d.sizer),
l=null,e=a.display.lineSpace.offsetTop,0>c.top+e+k.top?l=!0:c.bottom+e+k.top>(window.innerHeight||document.documentElement.clientHeight)&&(l=!1),null!=l&&!Wd))){if(k="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(l);k&&(d.cursor.style.display="none")}b.selectionChanged&&jb(a);a.state.focused&&b.updateInput&&Z(a,b.userSelChange);c=b.maybeHiddenMarkers;d=b.maybeUnhiddenMarkers;if(c)for(l=0;l<
c.length;++l)c[l].lines.length||G(c[l],"hide");if(d)for(l=0;l<d.length;++l)d[l].lines.length&&G(d[l],"unhide");var m;--ob||(m=$,$=null);b.textChanged&&G(a,"change",a,b.textChanged);b.cursorActivity&&G(a,"cursorActivity",a);if(m)for(l=0;l<m.length;++l)m[l]()}function w(a,b){return function(){var c=a||this,d=!c.curOp;d&&ta(c);try{var e=b.apply(c,arguments)}finally{d&&ua(c)}return e}}function La(a){return function(){var b=this.cm&&!this.cm.curOp,c;b&&ta(this.cm);try{c=a.apply(this,arguments)}finally{b&&
ua(this.cm)}return c}}function Tc(a,b){var c=!a.curOp,d;c&&ta(a);try{d=b()}finally{c&&ua(a)}return d}function A(a,b,c,d){null==b&&(b=a.doc.first);null==c&&(c=a.doc.first+a.doc.size);a.curOp.changes.push({from:b,to:c,diff:d})}function rb(a){a.display.pollingFast||a.display.poll.set(a.options.pollInterval,function(){cc(a);a.state.focused&&rb(a)})}function Ma(a){function b(){cc(a)||c?(a.display.pollingFast=!1,rb(a)):(c=!0,a.display.poll.set(60,b))}var c=!1;a.display.pollingFast=!0;a.display.poll.set(20,
b)}function cc(a){var b=a.display.input,c=a.display.prevInput,d=a.doc,e=d.sel;if(!a.state.focused||Xd(b)||Na(a))return!1;var f=b.value;if(f==c&&x(e.from,e.to))return!1;if(B&&!O&&a.display.inputHasSelection===f)return Z(a,!0),!1;var g=!a.curOp;g&&ta(a);e.shift=!1;for(var h=0,k=Math.min(c.length,f.length);h<k&&c.charCodeAt(h)==f.charCodeAt(h);)++h;k=e.from;e=e.to;h<c.length?k=q(k.line,k.ch-(c.length-h)):a.state.overwrite&&x(k,e)&&!a.state.pasteIncoming&&(e=q(e.line,Math.min(s(d,e.line).text.length,
e.ch+(f.length-h))));c=a.curOp.updateInput;wa(a.doc,{from:k,to:e,text:ga(f.slice(h)),origin:a.state.pasteIncoming?"paste":"+input"},"end");a.curOp.updateInput=c;1E3<f.length||-1<f.indexOf("\n")?b.value=a.display.prevInput="":a.display.prevInput=f;g&&ua(a);a.state.pasteIncoming=!1;return!0}function Z(a,b){var c,d,e=a.doc;x(e.sel.from,e.sel.to)?b&&(a.display.prevInput=a.display.input.value="",B&&!O&&(a.display.inputHasSelection=null)):(a.display.prevInput="",d=(c=Uc&&(100<e.sel.to.line-e.sel.from.line||
1E3<(d=a.getSelection()).length))?"-":d||a.getSelection(),a.display.input.value=d,a.state.focused&&Vc(a.display.input),B&&!O&&(a.display.inputHasSelection=d));a.display.inaccurateSelection=c}function I(a){"nocursor"==a.options.readOnly||Mb&&document.activeElement==a.display.input||a.display.input.focus()}function Na(a){return a.options.readOnly||a.doc.cantEdit}function Id(a){function b(){a.state.focused&&setTimeout(L(I,a),0)}function c(){g.cachedCharWidth=g.cachedTextHeight=null;na(a);Tc(a,L(A,a))}
function d(){for(var a=g.wrapper.parentNode;a&&a!=document.body;a=a.parentNode);a?setTimeout(d,5E3):W(window,"resize",c)}function e(b){a.options.onDragEvent&&a.options.onDragEvent(a,Oa(b))||Pa(b)}function f(){g.inaccurateSelection&&(g.prevInput="",g.inaccurateSelection=!1,g.input.value=a.getSelection(),Vc(g.input))}var g=a.display;v(g.scroller,"mousedown",w(a,Yd));B?v(g.scroller,"dblclick",w(a,function(b){var c=xa(a,b);!c||Wc(a,b)||ha(a.display,b)||(D(b),b=dc(s(a.doc,c.line).text,c),E(a.doc,b.from,
b.to))})):v(g.scroller,"dblclick",D);v(g.lineSpace,"selectstart",function(a){ha(g,a)||D(a)});ec||v(g.scroller,"contextmenu",function(b){Xc(a,b)});v(g.scroller,"scroll",function(){g.scroller.clientHeight&&(Qa(a,g.scroller.scrollTop),va(a,g.scroller.scrollLeft,!0),G(a,"scroll",a))});v(g.scrollbarV,"scroll",function(){g.scroller.clientHeight&&Qa(a,g.scrollbarV.scrollTop)});v(g.scrollbarH,"scroll",function(){g.scroller.clientHeight&&va(a,g.scrollbarH.scrollLeft)});v(g.scroller,"mousewheel",function(b){Yc(a,
b)});v(g.scroller,"DOMMouseScroll",function(b){Yc(a,b)});v(g.scrollbarH,"mousedown",b);v(g.scrollbarV,"mousedown",b);v(g.wrapper,"scroll",function(){g.wrapper.scrollTop=g.wrapper.scrollLeft=0});v(window,"resize",c);setTimeout(d,5E3);v(g.input,"keyup",w(a,function(b){a.options.onKeyEvent&&a.options.onKeyEvent(a,Oa(b))||16!=b.keyCode||(a.doc.sel.shift=!1)}));v(g.input,"input",L(Ma,a));v(g.input,"keydown",w(a,Zc));v(g.input,"keypress",w(a,Zd));v(g.input,"focus",L(ca,a));v(g.input,"blur",L(Ob,a));a.options.dragDrop&&
(v(g.scroller,"dragstart",function(b){if(B&&!a.state.draggingText)Pa(b);else if(!ha(a.display,b)){var c=a.getSelection();b.dataTransfer.setData("Text",c);b.dataTransfer.setDragImage&&(c=r("img",null,null,"position: fixed; left: 0; top: 0;"),V&&(c.width=c.height=1,a.display.wrapper.appendChild(c),c._top=c.offsetTop),fc&&(a.display.dragImg?c=a.display.dragImg:(a.display.dragImg=c,c.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",a.display.wrapper.appendChild(c))),b.dataTransfer.setDragImage(c,
0,0),V&&c.parentNode.removeChild(c))}}),v(g.scroller,"dragenter",e),v(g.scroller,"dragover",e),v(g.scroller,"drop",w(a,$d)));v(g.scroller,"paste",function(b){ha(g,b)||(I(a),Ma(a))});v(g.input,"paste",function(){a.state.pasteIncoming=!0;Ma(a)});v(g.input,"cut",f);v(g.input,"copy",f);Qb&&v(g.sizer,"mouseup",function(){document.activeElement==g.input&&g.input.blur();I(a)})}function ha(a,b){for(var c=b.target||b.srcElement;c!=a.wrapper;c=c.parentNode)if(!c||/\bCodeMirror-(?:line)?widget\b/.test(c.className)||
c.parentNode==a.sizer&&c!=a.mover)return!0}function xa(a,b,c){var d=a.display;if(!c&&(c=b.target||b.srcElement,c==d.scrollbarH||c==d.scrollbarH.firstChild||c==d.scrollbarV||c==d.scrollbarV.firstChild||c==d.scrollbarFiller))return null;var e,f,d=C(d.lineSpace);try{e=b.clientX,f=b.clientY}catch(g){return null}return $b(a,e-d.left,f-d.top)}function Yd(a){function b(a){if(!x(u,a))if(u=a,"single"==m)E(e.doc,t(g,k),a);else if(n=t(g,n),r=t(g,r),"double"==m){var b=dc(s(g,a.line).text,a);z(a,n)?E(e.doc,b.from,
r):E(e.doc,n,b.to)}else"triple"==m&&(z(a,n)?E(e.doc,r,t(g,q(a.line,0))):E(e.doc,n,t(g,q(a.line+1,0))))}function c(a){var d=++hb,h=xa(e,a,!0);if(h)if(x(h,p)){var k=a.clientY<A.top?-20:a.clientY>A.bottom?20:0;k&&setTimeout(w(e,function(){hb==d&&(f.scroller.scrollTop+=k,c(a))}),50)}else{e.state.focused||ca(e);p=h;b(h);var l=Sb(f,g);(h.line>=l.to||h.line<l.from)&&setTimeout(w(e,function(){hb==d&&c(a)}),150)}}function d(a){hb=Infinity;var c=xa(e,a);c&&b(c);D(a);I(e);W(document,"mousemove",Lc);W(document,
"mouseup",G)}var e=this,f=e.display,g=e.doc,h=g.sel;h.shift=a.shiftKey;if(ha(f,a))M||(f.scroller.draggable=!1,setTimeout(function(){f.scroller.draggable=!0},100));else if(!Wc(e,a)){var k=xa(e,a);switch($c(a)){case 3:ec&&Xc.call(e,e,a);return;case 2:k&&E(e.doc,k);setTimeout(L(I,e),20);D(a);return}if(k){e.state.focused||ca(e);var l=+new Date,m="single";sb&&sb.time>l-400&&x(sb.pos,k)?(m="triple",D(a),setTimeout(L(I,e),20),ae(e,k.line)):tb&&tb.time>l-400&&x(tb.pos,k)?(m="double",sb={time:l,pos:k},D(a),
l=dc(s(g,k.line).text,k),E(e.doc,l.from,l.to)):tb={time:l,pos:k};var p=k;if(!e.options.dragDrop||!be||Na(e)||x(h.from,h.to)||z(k,h.from)||z(h.to,k)||"single"!=m){D(a);"single"==m&&E(e.doc,t(g,k));var n=h.from,r=h.to,u=k,A=C(f.wrapper),hb=0,Lc=w(e,function(a){B||$c(a)?c(a):d(a)}),G=w(e,d);v(document,"mousemove",Lc);v(document,"mouseup",G)}else{var Ja=w(e,function(b){M&&(f.scroller.draggable=!1);e.state.draggingText=!1;W(document,"mouseup",Ja);W(f.scroller,"drop",Ja);10>Math.abs(a.clientX-b.clientX)+
Math.abs(a.clientY-b.clientY)&&(D(b),E(e.doc,k),I(e))});M&&(f.scroller.draggable=!0);e.state.draggingText=Ja;f.scroller.dragDrop&&f.scroller.dragDrop();v(document,"mouseup",Ja);v(f.scroller,"drop",Ja)}}else(a.target||a.srcElement)==f.scroller&&D(a)}}function $d(a){var b=this;if(!(ha(b.display,a)||b.options.onDragEvent&&b.options.onDragEvent(b,Oa(a)))){D(a);var c=xa(b,a,!0),d=a.dataTransfer.files;if(c&&!Na(b))if(d&&d.length&&window.FileReader&&window.File){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=t(b.doc,c),wa(b.doc,{from:c,to:c,text:ga(f.join("\n")),origin:"paste"},"around"))};h.readAsText(a)};for(var h=0;h<e;++h)a(d[h],h)}else if(!b.state.draggingText||z(c,b.doc.sel.from)||z(b.doc.sel.to,c))try{if(f=a.dataTransfer.getData("Text")){var h=b.doc.sel.from,k=b.doc.sel.to;aa(b.doc,c,c);b.state.draggingText&&ba(b.doc,"",h,k,"paste");b.replaceSelection(f,null,"paste");I(b);ca(b)}}catch(l){}else b.state.draggingText(a),setTimeout(L(I,
b),20)}}function Wc(a,b){var c=a.display;try{var d=b.clientX,e=b.clientY}catch(f){return!1}if(d>=Math.floor(C(c.gutters).right))return!1;D(b);if(!ya(a,"gutterClick"))return!0;var g=C(c.lineDiv);if(e>g.bottom)return!0;e-=g.top-c.viewOffset;for(g=0;g<a.options.gutters.length;++g){var h=c.gutters.childNodes[g];if(h&&C(h).right>=d){c=fb(a.doc,e);R(a,"gutterClick",a,c,a.options.gutters[g],b);break}}return!0}function Qa(a,b){2>Math.abs(a.doc.scrollTop-b)||(a.doc.scrollTop=b,za||gb(a,[],b),a.display.scroller.scrollTop!=
b&&(a.display.scroller.scrollTop=b),a.display.scrollbarV.scrollTop!=b&&(a.display.scrollbarV.scrollTop=b),za&&gb(a,[]))}function va(a,b,c){(c?b==a.doc.scrollLeft:2>Math.abs(a.doc.scrollLeft-b))||(b=Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth),a.doc.scrollLeft=b,Ic(a),a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b),a.display.scrollbarH.scrollLeft!=b&&(a.display.scrollbarH.scrollLeft=b))}function Yc(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&&qa&&M)for(var g=b.target;g!=f;g=g.parentNode)if(g.lineObj){a.display.currentWheelTarget=g;break}if(!c||za||V||null==P){if(d&&null!=P){var g=d*P,h=a.doc.scrollTop,k=h+e.wrapper.clientHeight;0>g?h=Math.max(0,h+g-50):k=Math.min(a.doc.height,k+g+50);gb(a,[],{top:h,bottom:k})}20>ub&&
(null==e.wheelStartX?(e.wheelStartX=f.scrollLeft,e.wheelStartY=f.scrollTop,e.wheelDX=c,e.wheelDY=d,setTimeout(function(){if(null!=e.wheelStartX){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;a&&(P=(P*ub+a)/(ub+1),++ub)}},200)):(e.wheelDX+=c,e.wheelDY+=d))}else d&&Qa(a,Math.max(0,Math.min(f.scrollTop+d*P,f.scrollHeight-f.clientHeight))),va(a,Math.max(0,Math.min(f.scrollLeft+c*P,f.scrollWidth-f.clientWidth))),
D(b),e.wheelStartX=null}}function vb(a,b,c){if("string"==typeof b&&(b=gc[b],!b))return!1;a.display.pollingFast&&cc(a)&&(a.display.pollingFast=!1);var d=a.doc,e=d.sel.shift,f=!1;try{Na(a)&&(a.state.suppressEdits=!0),c&&(d.sel.shift=!1),f=b(a)!=ad}finally{d.sel.shift=e,a.state.suppressEdits=!1}return f}function bd(a){var b=a.state.keyMaps.slice(0);a.options.extraKeys&&b.push(a.options.extraKeys);b.push(a.options.keyMap);return b}function cd(a,b){var c=hc(a.options.keyMap),d=c.auto;clearTimeout(dd);
d&&!ed(b)&&(dd=setTimeout(function(){hc(a.options.keyMap)==c&&(a.options.keyMap=d.call?d.call(null,a):d)},50));var e=fd(b,!0),f=!1;if(!e)return!1;f=bd(a);f=b.shiftKey?Ra("Shift-"+e,f,function(b){return vb(a,b,!0)})||Ra(e,f,function(b){if("string"==typeof b&&/^go[A-Z]/.test(b))return vb(a,b)}):Ra(e,f,function(b){return vb(a,b)});"stop"==f&&(f=!1);f&&(D(b),jb(a),O&&(b.oldKeyCode=b.keyCode,b.keyCode=0));return f}function ce(a,b,c){if(c=Ra("'"+c+"'",bd(a),function(b){return vb(a,b,!0)}))D(b),jb(a);return c}
function Zc(a){this.state.focused||ca(this);B&&27==a.keyCode&&(a.returnValue=!1);if(!this.options.onKeyEvent||!this.options.onKeyEvent(this,Oa(a))){var b=a.keyCode;this.doc.sel.shift=16==b||a.shiftKey;var c=cd(this,a);V&&(ic=c?b:null,!c&&88==b&&!Uc&&(qa?a.metaKey:a.ctrlKey)&&this.replaceSelection(""))}}function Zd(a){var b=this;if(!b.options.onKeyEvent||!b.options.onKeyEvent(b,Oa(a))){var c=a.keyCode,d=a.charCode;V&&c==ic?(ic=null,D(a)):(V&&(!a.which||10>a.which)||Qb)&&cd(b,a)||(c=String.fromCharCode(null==
d?c:d),this.options.electricChars&&this.doc.mode.electricChars&&this.options.smartIndent&&!Na(this)&&-1<this.doc.mode.electricChars.indexOf(c)&&setTimeout(w(b,function(){wb(b,b.doc.sel.to.line,"smart")}),75),ce(b,a,c)||(B&&!O&&(b.display.inputHasSelection=null),Ma(b)))}}function ca(a){"nocursor"!=a.options.readOnly&&(a.state.focused||(G(a,"focus",a),a.state.focused=!0,-1==a.display.wrapper.className.search(/\bCodeMirror-focused\b/)&&(a.display.wrapper.className+=" CodeMirror-focused"),Z(a,!0)),rb(a),
jb(a))}function Ob(a){a.state.focused&&(G(a,"blur",a),a.state.focused=!1,a.display.wrapper.className=a.display.wrapper.className.replace(" CodeMirror-focused",""));clearInterval(a.display.blinker);setTimeout(function(){a.state.focused||(a.doc.sel.shift=!1)},150)}function Xc(a,b){function c(){d.inputDiv.style.position="relative";d.input.style.cssText=h;O&&(d.scrollbarV.scrollTop=d.scroller.scrollTop=g);rb(a);if(null!=d.input.selectionStart&&(!B||O)){clearTimeout(jc);var b=d.input.value=" "+(x(e.from,
e.to)?"":d.input.value),c=0;d.prevInput=" ";d.input.selectionStart=1;d.input.selectionEnd=b.length;var f=function(){" "==d.prevInput&&0==d.input.selectionStart?w(a,gc.selectAll)(a):10>c++?jc=setTimeout(f,500):Z(a)};jc=setTimeout(f,200)}}var d=a.display,e=a.doc.sel;if(!ha(d,b)){var f=xa(a,b),g=d.scroller.scrollTop;if(f&&!V){(x(e.from,e.to)||z(f,e.from)||!z(f,e.to))&&w(a,aa)(a.doc,f,f);var h=d.input.style.cssText;d.inputDiv.style.position="absolute";d.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+
(b.clientY-5)+"px; left: "+(b.clientX-5)+"px; z-index: 1000; background: white; outline: none;border-width: 0; outline: none; overflow: hidden; opacity: .05; -ms-opacity: .05; filter: alpha(opacity=5);";I(a);Z(a,!0);x(e.from,e.to)&&(d.input.value=d.prevInput=" ");if(ec){Pa(b);var k=function(){W(window,"mouseup",k);setTimeout(c,20)};v(window,"mouseup",k)}else setTimeout(c,50)}}}function kc(a){return a.text?q(a.from.line+a.text.length-1,H(a.text).length+(1==a.text.length?a.from.ch:0)):a.to}function gd(a,
b,c){if(!z(b.from,c))return t(a,c);var d=b.text.length-1-(b.to.line-b.from.line);if(c.line>b.to.line+d)return b=c.line-d,d=a.first+a.size-1,b>d?q(d,s(a,d).text.length):xb(c,s(a,b).text.length);if(c.line==b.to.line+d)return xb(c,H(b.text).length+(1==b.text.length?b.from.ch:0)+s(a,b.to.line).text.length-b.to.ch);a=c.line-b.from.line;return xb(c,b.text[a].length+(a?0:b.from.ch))}function lc(a,b,c){if(c&&"object"==typeof c)return{anchor:gd(a,b,c.anchor),head:gd(a,b,c.head)};if("start"==c)return{anchor:b.from,
head:b.from};var d=kc(b);if("around"==c)return{anchor:b.from,head:d};if("end"==c)return{anchor:d,head:d};c=function(a){if(z(a,b.from))return a;if(!z(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 q(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=t(a,b));c&&(this.to=t(a,c));f&&(this.text=f);void 0!==
g&&(this.origin=g)},cancel:function(){this.canceled=!0}};G(a,"beforeChange",a,c);a.cm&&G(a.cm,"beforeChange",a.cm,c);return c.canceled?null:{from:c.from,to:c.to,text:c.text,origin:c.origin}}function wa(a,b,c,d){if(a.cm){if(!a.cm.curOp)return w(a.cm,wa)(a,b,c,d);if(a.cm.state.suppressEdits)return}if(ya(a,"beforeChange")||a.cm&&ya(a.cm,"beforeChange"))if(b=de(a,b),!b)return;if(d=hd&&!d&&ee(a,b.from,b.to)){for(var e=d.length-1;1<=e;--e)mc(a,{from:d[e].from,to:d[e].to,text:[""]});d.length&&mc(a,{from:d[0].from,
to:d[0].to,text:b.text},c)}else mc(a,b,c)}function mc(a,b,c){c=lc(a,b,c);id(a,b,c,a.cm?a.cm.curOp.id:NaN);Sa(a,b,c,nc(a,b));var d=[];Aa(a,function(a,c){c||-1!=X(d,a.history)||(jd(a.history,b),d.push(a.history));Sa(a,b,null,nc(a,b))})}function kd(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(oc(a,f));var g=c?lc(a,f,null):{anchor:d.anchorBefore,head:d.headBefore};Sa(a,f,g,ld(a,f));var h=[];Aa(a,function(a,b){b||-1!=X(h,a.history)||(jd(a.history,f),h.push(a.history));Sa(a,f,null,ld(a,f))})}}}}function md(a,b){function c(a){return q(a.line+b,a.ch)}a.first+=b;a.cm&&A(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 Sa(a,b,c,d){if(a.cm&&!a.cm.curOp)return w(a.cm,Sa)(a,b,c,d);if(b.to.line<a.first)md(a,b.text.length-1-(b.to.line-b.from.line));else if(!(b.from.line>a.lastLine())){if(b.from.line<a.first){var e=b.text.length-1-(a.first-b.from.line);md(a,e);b={from:q(a.first,0),to:q(b.to.line+e,b.to.ch),text:[H(b.text)],origin:b.origin}}e=a.lastLine();b.to.line>e&&(b={from:b.from,to:q(e,s(a,e).text.length),text:[b.text[0]],origin:b.origin});b.removed=pc(a,b.from,b.to);c||(c=lc(a,b,null));a.cm?fe(a.cm,b,d,
c):qc(a,b,d,c)}}function fe(a,b,c,d){var e=a.doc,f=a.display,g=b.from,h=b.to,k=!1,l=g.line;a.options.lineWrapping||(l=K(oa(e,s(e,g.line))),e.iter(l,h.line+1,function(a){if(a==f.maxLine)return k=!0}));z(e.sel.head,b.from)||z(b.to,e.sel.head)||(a.curOp.cursorActivity=!0);qc(e,b,c,d,Ec(a));a.options.lineWrapping||(e.iter(l,g.line+b.text.length,function(a){var b=db(e,a);b>f.maxLineLength&&(f.maxLine=a,f.maxLineLength=b,f.maxLineChanged=!0,k=!1)}),k&&(a.curOp.updateMaxLine=!0));e.frontier=Math.min(e.frontier,
g.line);bb(a,400);A(a,g.line,h.line+1,b.text.length-(h.line-g.line)-1);if(ya(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 ba(a,b,c,d,e){d||(d=c);if(z(d,c)){var f=d;d=c;c=f}"string"==typeof b&&(b=ga(b));wa(a,{from:c,to:d,text:b,origin:e},null)}function q(a,b){if(!(this instanceof q))return new q(a,b);this.line=a;this.ch=b}function x(a,b){return a.line==b.line&&
a.ch==b.ch}function z(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch}function ia(a){return q(a.line,a.ch)}function t(a,b){if(b.line<a.first)return q(a.first,0);var c=a.first+a.size-1;return b.line>c?q(c,s(a,c).text.length):xb(b,s(a,b.line).text.length)}function xb(a,b){var c=a.ch;return null==c||c>b?q(a.line,b):0>c?q(a.line,0):a}function Ba(a,b){return b>=a.first&&b<a.first+a.size}function E(a,b,c,d){if(a.sel.shift||a.sel.extend){var e=a.sel.anchor;if(c){var f=z(b,e);f!=z(c,e)?(e=b,b=c):f!=
z(b,c)&&(b=c)}aa(a,e,b,d)}else aa(a,b,c||b,d);a.cm&&(a.cm.curOp.userSelChange=!0)}function aa(a,b,c,d,e){if(!e&&ya(a,"beforeSelectionChange")||a.cm&&ya(a.cm,"beforeSelectionChange"))b={anchor:b,head:c},G(a,"beforeSelectionChange",a,b),a.cm&&G(a.cm,"beforeSelectionChange",a.cm,b),b.anchor=t(a,b.anchor),b.head=t(a,b.head),c=b.head,b=b.anchor;var f=a.sel;f.goalColumn=null;if(e||!x(b,f.anchor))b=yb(a,b,d,"push"!=e);if(e||!x(c,f.head))c=yb(a,c,d,"push"!=e);x(f.anchor,b)&&x(f.head,c)||(f.anchor=b,f.head=
c,d=z(c,b),f.from=d?c:b,f.to=d?b:c,a.cm&&(a.cm.curOp.updateInput=a.cm.curOp.selectionChanged=a.cm.curOp.cursorActivity=!0),R(a,"cursorActivity",a))}function nd(a){aa(a.doc,a.doc.sel.from,a.doc.sel.to,null,"push")}function yb(a,b,c,d){var e=!1,f=b,g=c||1;a.cantEdit=!1;a:for(;;){var h=s(a,f.line);if(h.markedSpans)for(var k=0;k<h.markedSpans.length;++k){var l=h.markedSpans[k],m=l.marker;if((null==l.from||(m.inclusiveLeft?l.from<=f.ch:l.from<f.ch))&&(null==l.to||(m.inclusiveRight?l.to>=f.ch:l.to>f.ch))){if(d&&
(G(m,"beforeCursorEnter"),m.explicitlyCleared))if(h.markedSpans){--k;continue}else break;if(m.atomic){k=m.find()[0>g?"from":"to"];if(x(k,f)&&(k.ch+=g,0>k.ch?k=k.line>a.first?t(a,q(k.line-1)):null:k.ch>h.text.length&&(k=k.line<a.first+a.size-1?q(k.line+1,0):null),!k)){if(e){if(!d)return yb(a,b,c,!0);a.cantEdit=!0;return q(a.first,0)}e=!0;k=b;g=-g}f=k;continue a}}}return f}}function Sc(a,b,c){for(null==c&&(c=0);;){var d=!1,e=S(a,b),f=qb(a,e.left,e.top-c,e.left,e.bottom+c),g=a.doc.scrollTop,h=a.doc.scrollLeft;
null!=f.scrollTop&&(Qa(a,f.scrollTop),1<Math.abs(a.doc.scrollTop-g)&&(d=!0));null!=f.scrollLeft&&(va(a,f.scrollLeft),1<Math.abs(a.doc.scrollLeft-h)&&(d=!0));if(!d)return e}}function qb(a,b,c,d,e){var f=a.display,g=f.lineSpace.offsetTop;c+=g;e+=g;0>c&&(c=0);var h=f.scroller.clientHeight-Da,k=f.scroller.scrollTop,l={};a=a.doc.height+(f.mover.offsetHeight-f.lineSpace.offsetHeight);var m=c<g+10,g=e+g>a-10;c<k?l.scrollTop=m?0:c:e>k+h&&(c=Math.min(c,(g?a:e)-h),c!=k&&(l.scrollTop=c));k=f.scroller.clientWidth-
Da;c=f.scroller.scrollLeft;b+=f.gutters.offsetWidth;d+=f.gutters.offsetWidth;f=f.gutters.offsetWidth;e=b<f+10;b<c+f||e?(e&&(b=0),l.scrollLeft=Math.max(0,b-10-f)):d>k+c-3&&(l.scrollLeft=d+10-k);return l}function zb(a,b,c){a.curOp.updateScrollPos={scrollLeft:null==b?a.doc.scrollLeft:b,scrollTop:null==c?a.doc.scrollTop:c}}function od(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 wb(a,b,c,d){var e=a.doc;c||(c="add");if("smart"==c)if(a.doc.mode.indent)var f=Ka(a,b);else c="prev";var g=a.options.tabSize,h=s(e,b),k=sa(h.text,null,g),l=h.text.match(/^\s*/)[0],m;if("smart"==c&&(m=a.doc.mode.indent(f,h.text.slice(l.length),h.text),m==ad)){if(!d)return;c="prev"}"prev"==c?m=b>e.first?sa(s(e,b-1).text,null,g):0:"add"==c?m=k+a.options.indentUnit:"subtract"==c&&(m=k-
a.options.indentUnit);m=Math.max(0,m);c="";d=0;if(a.options.indentWithTabs)for(e=Math.floor(m/g);e;--e)d+=g,c+="\t";d<m&&(c+=pd(m-d));c!=l&&ba(a.doc,c,q(b,0),q(b,l.length),"+input");h.stateAfter=null}function Ab(a,b,c){var d=b,e=b,f=a.doc;"number"==typeof b?e=s(f,Math.max(f.first,Math.min(b,f.first+f.size-1))):d=K(b);if(null!=d&&c(e,d))A(a,d,d+1);else return null;return e}function rc(a,b,c,d,e){function f(b){var d=(e?ac:qd)(k,h,c,!0);if(null==d){if(b=!b)b=g+c,b<a.first||b>=a.first+a.size?b=l=!1:(g=
b,b=k=s(a,b));if(b)h=e?(0>c?nb:mb)(k):0>c?k.text.length:0;else return l=!1}else h=d;return!0}var g=b.line,h=b.ch,k=s(a,g),l=!0;if("char"==d)f();else if("column"==d)f(!0);else if("word"==d||"group"==d){b=null;d="group"==d;for(var m=!0;!(0>c)||f(!m);m=!1){var p=k.text.charAt(h)||"\n",p=Bb(p)?"w":d?/\s/.test(p)?null:"p":null;if(b&&b!=p){0>c&&(c=1,f());break}p&&(b=p);if(0<c&&!f(!m))break}}b=yb(a,q(g,h),c,!0);l||(b.hitSide=!0);return b}function rd(a,b,c,d){var e=a.doc,f=b.left,g;"page"==d?(g=Math.min(a.display.wrapper.clientHeight,
window.innerHeight||document.documentElement.clientHeight),g=b.top+c*(g-(0>c?1.5:.5)*Fa(a.display))):"line"==d&&(g=0<c?b.bottom+3:b.top-3);for(;;){b=$b(a,f,g);if(!b.outside)break;if(0>c?0>=g:g>=e.height){b.hitSide=!0;break}g+=5*c}return b}function dc(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=Bb(e)?Bb:/\s/.test(e)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!Bb(a)};0<c&&e(a.charAt(c-1));)--c;for(;d<a.length&&e(a.charAt(d));)++d}return{from:q(b.line,
c),to:q(b.line,d)}}function ae(a,b){E(a.doc,q(b,0),t(a.doc,q(b+1,0)))}function u(a,b,c,d){n.defaults[a]=b;c&&(la[a]=d?function(a,b,d){d!=Dc&&c(a,b,d)}:c)}function ra(a,b){if(!0===b)return b;if(a.copyState)return a.copyState(b);var c={},d;for(d in b){var e=b[d];e instanceof Array&&(e=e.concat([]));c[d]=e}return c}function Oc(a,b,c){return a.startState?a.startState(b,c):!0}function hc(a){return"string"==typeof a?Y[a]:a}function Ra(a,b,c){function d(b){b=hc(b);var e=b[a];if(!1===e)return"stop";if(null!=
e&&c(e))return!0;if(b.nofallthrough)return"stop";b=b.fallthrough;if(null==b)return!1;if("[object Array]"!=Object.prototype.toString.call(b))return d(b);for(var e=0,f=b.length;e<f;++e){var l=d(b[e]);if(l)return l}return!1}for(var e=0;e<b.length;++e){var f=d(b[e]);if(f)return f}}function ed(a){a=ja[a.keyCode];return"Ctrl"==a||"Alt"==a||"Shift"==a||"Mod"==a}function fd(a,b){if(V&&34==a.keyCode&&a["char"])return!1;var c=ja[a.keyCode];if(null==c||a.altGraphKey)return!1;a.altKey&&(c="Alt-"+c);if(sd?a.metaKey:
a.ctrlKey)c="Ctrl-"+c;if(sd?a.ctrlKey:a.metaKey)c="Cmd-"+c;!b&&a.shiftKey&&(c="Shift-"+c);return c}function Ta(a,b){this.pos=this.start=0;this.string=a;this.tabSize=b||8;this.lastColumnPos=this.lastColumnValue=0}function ka(a,b){this.lines=[];this.type=b;this.doc=a}function Ua(a,b,c,d,e){if(d&&d.shared)return ge(a,b,c,d,e);if(a.cm&&!a.cm.curOp)return w(a.cm,Ua)(a,b,c,d,e);var f=new ka(a,e);if("range"==e&&!z(b,c))return f;d&&Cb(d,f);f.replacedWith&&(f.collapsed=!0,f.replacedWith=r("span",[f.replacedWith],
"CodeMirror-widget"));f.collapsed&&(Ia=!0);f.addToHistory&&id(a,{from:b,to:c,origin:"markText"},{head:a.sel.head,anchor:a.sel.anchor},NaN);var g=b.line,h=0,k,l,m=a.cm,p;a.iter(g,c.line+1,function(d){m&&f.collapsed&&!m.options.lineWrapping&&oa(a,d)==m.display.maxLine&&(p=!0);var e={from:null,to:null,marker:f};h+=d.text.length;g==b.line&&(e.from=b.ch,h-=b.ch);g==c.line&&(e.to=c.ch,h-=d.text.length-c.ch);f.collapsed&&(g==c.line&&(l=ea(d,c.ch)),g==b.line?k=ea(d,b.ch):Q(d,0));d.markedSpans=d.markedSpans?
d.markedSpans.concat([e]):[e];e.marker.attachLine(d);++g});f.collapsed&&a.iter(b.line,c.line+1,function(b){da(a,b)&&Q(b,0)});f.clearOnEnter&&v(f,"beforeCursorEnter",function(){f.clear()});f.readOnly&&(hd=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory());if(f.collapsed){if(k!=l)throw Error("Inserting collapsed marker overlapping an existing one");f.size=h;f.atomic=!0}m&&(p&&(m.curOp.updateMaxLine=!0),(f.className||f.startStyle||f.endStyle||f.collapsed)&&A(m,b.line,c.line+1),f.atomic&&
nd(m));return f}function Va(a,b){this.markers=a;this.primary=b;for(var c=0,d=this;c<a.length;++c)a[c].parent=this,v(a[c],"clear",function(){d.clear()})}function ge(a,b,c,d,e){d=Cb(d);d.shared=!1;var f=[Ua(a,b,c,d,e)],g=f[0],h=d.replacedWith;Aa(a,function(a){h&&(d.replacedWith=h.cloneNode(!0));f.push(Ua(a,t(a,b),t(a,c),d,e));for(var l=0;l<a.linked.length;++l)if(a.linked[l].isParent)return;g=H(f)});return new Va(f,g)}function Wa(a,b){if(a)for(var c=0;c<a.length;++c){var d=a[c];if(d.marker==b)return d}}
function nc(a,b){var c=Ba(a,b.from.line)&&s(a,b.from.line).markedSpans,d=Ba(a,b.to.line)&&s(a,b.to.line).markedSpans;if(!c&&!d)return null;var e=b.from.ch,f=b.to.ch,g=x(b.from,b.to);if(c)for(var h=0,k;h<c.length;++h){var l=c[h],m=l.marker;if(null==l.from||(m.inclusiveLeft?l.from<=e:l.from<e)||!("bookmark"!=m.type||l.from!=e||g&&l.marker.insertLeft)){var p=null==l.to||(m.inclusiveRight?l.to>=e:l.to>e);(k||(k=[])).push({from:l.from,to:p?null:l.to,marker:m})}}c=k;if(d)for(var h=0,n;h<d.length;++h)if(k=
d[h],l=k.marker,null==k.to||(l.inclusiveRight?k.to>=f:k.to>f)||"bookmark"==l.type&&k.from==f&&(!g||k.marker.insertLeft))m=null==k.from||(l.inclusiveLeft?k.from<=f:k.from<f),(n||(n=[])).push({from:m?null:k.from-f,to:null==k.to?null:k.to-f,marker:l});d=n;g=1==b.text.length;n=H(b.text).length+(g?e:0);if(c)for(f=0;f<c.length;++f)if(h=c[f],null==h.to)(k=Wa(d,h.marker),k)?g&&(h.to=null==k.to?null:k.to+n):h.to=e;if(d)for(f=0;f<d.length;++f)h=d[f],null!=h.to&&(h.to+=n),null==h.from?(k=Wa(c,h.marker),k||(h.from=
n,g&&(c||(c=[])).push(h))):(h.from+=n,g&&(c||(c=[])).push(h));e=[c];if(!g){var g=b.text.length-2,r;if(0<g&&c)for(f=0;f<c.length;++f)null==c[f].to&&(r||(r=[])).push({from:null,to:null,marker:c[f].marker});for(f=0;f<g;++f)e.push(r);e.push(d)}return e}function ld(a,b){var c;if(c=b["spans_"+a.id]){for(var d=0,e=[];d<b.text.length;++d)e.push(he(c[d]));c=e}else c=null;d=nc(a,b);if(!c)return d;if(!d)return c;for(e=0;e<c.length;++e){var f=c[e],g=d[e];if(f&&g){var h=0;a:for(;h<g.length;++h){for(var k=g[h],
l=0;l<f.length;++l)if(f[l].marker==k.marker)continue a;f.push(k)}}else g&&(c[e]=g)}return c}function ee(a,b,c){var d=null;a.iter(b.line,c.line+1,function(a){if(a.markedSpans)for(var b=0;b<a.markedSpans.length;++b){var c=a.markedSpans[b].marker;!c.readOnly||d&&-1!=X(d,c)||(d||(d=[])).push(c)}});if(!d)return null;a=[{from:b,to:c}];for(b=0;b<d.length;++b){c=d[b];for(var e=c.find(),f=0;f<a.length;++f){var g=a[f];if(!z(g.to,e.from)&&!z(e.to,g.from)){var h=[f,1];(z(g.from,e.from)||!c.inclusiveLeft&&x(g.from,
e.from))&&h.push({from:g.from,to:e.from});(z(e.to,g.to)||!c.inclusiveRight&&x(g.to,e.to))&&h.push({from:e.to,to:g.to});a.splice.apply(a,h);f+=h.length-1}}}return a}function ea(a,b){var c=Ia&&a.markedSpans,d;if(c)for(var e,f=0;f<c.length;++f)e=c[f],e.marker.collapsed&&(null==e.from||e.from<b)&&(null==e.to||e.to>b)&&(!d||d.width<e.marker.width)&&(d=e.marker);return d}function Ha(a){return ea(a,a.text.length+1)}function oa(a,b){for(var c;c=ea(b,-1);)b=s(a,c.find().from.line);return b}function da(a,b){var c=
Ia&&b.markedSpans;if(c)for(var d,e=0;e<c.length;++e)if(d=c[e],d.marker.collapsed&&(null==d.from||0==d.from&&d.marker.inclusiveLeft&&sc(a,b,d)))return!0}function sc(a,b,c){if(null==c.to)return b=c.marker.find().to,b=s(a,b.line),sc(a,b,Wa(b.markedSpans,c.marker));if(c.marker.inclusiveRight&&c.to==b.text.length)return!0;for(var d,e=0;e<b.markedSpans.length;++e)if(d=b.markedSpans[e],d.marker.collapsed&&d.from==c.to&&(d.marker.inclusiveLeft||c.marker.inclusiveRight)&&sc(a,b,d))return!0}function td(a){var b=
a.markedSpans;if(b){for(var c=0;c<b.length;++c)b[c].marker.detachLine(a);a.markedSpans=null}}function ud(a,b){if(b){for(var c=0;c<b.length;++c)b[c].marker.attachLine(a);a.markedSpans=b}}function vd(a){return function(){var b=!this.cm.curOp;b&&ta(this.cm);try{var c=a.apply(this,arguments)}finally{b&&ua(this.cm)}return c}}function kb(a){if(null!=a.height)return a.height;a.node.parentNode&&1==a.node.parentNode.nodeType||U(a.cm.display.measure,r("div",[a.node],null,"position: relative"));return a.height=
a.node.offsetHeight}function ie(a,b,c,d){var e=new tc(a,c,d);e.noHScroll&&(a.display.alignWidgets=!0);Ab(a,b,function(b){(b.widgets||(b.widgets=[])).push(e);e.line=b;if(!da(a.doc,b)||e.showIfHidden){var c=pa(a,b)<a.display.scroller.scrollTop;Q(b,b.height+kb(e));c&&od(a,0,e.height)}return!0});return e}function Xa(a,b,c){a={text:a};ud(a,b);a.height=c?c(a):1;return a}function wd(a,b,c,d,e){var f=c.flattenSpans;null==f&&(f=a.options.flattenSpans);var g="",h=null,k=new Ta(b,a.options.tabSize),l;for(""==
b&&c.blankLine&&c.blankLine(d);!k.eol();){k.pos>a.options.maxHighlightLength?(f=!1,k.pos=Math.min(b.length,k.start+5E4),l=null):l=c.token(k,d);var m=k.current();k.start=k.pos;f&&h==l?g+=m:(g&&e(g,h),g=m,h=l)}g&&e(g,h)}function Mc(a,b,c){var d=[a.state.modeGen];wd(a,b.text,a.doc.mode,c,function(a,b){d.push(a,b)});for(c=0;c<a.state.overlays.length;++c){var e=a.state.overlays[c],f=1;wd(a,b.text,e.mode,!0,function(a,b){for(var c=f,l=a.length;l;){var m=d[f],p=m.length;p<=l?l-=p:(d.splice(f,1,m.slice(0,
l),d[f+1],m.slice(l)),l=0);f+=2}if(b)if(e.opaque)d.splice(c,f-c,a,b),f=c+2;else for(;c<f;c+=2)m=d[c+1],d[c+1]=m?m+" "+b:b})}return d}function Nc(a,b,c){var d=a.doc.mode,e=new Ta(b.text,a.options.tabSize);for(""==b.text&&d.blankLine&&d.blankLine(c);!e.eol()&&e.pos<=a.options.maxHighlightLength;)d.token(e,c),e.start=e.pos}function xd(a){return a?yd[a]||(yd[a]="cm-"+a.replace(/ +/g," cm-")):null}function Xb(a,b,c){for(var d,e=b,f,g,h=!0;d=ea(e,-1);)h=!1,e=s(a.doc,d.find().from.line),f||(f=e);d={pre:r("pre"),
col:0,pos:0,display:!c,measure:null,addedOne:!1,cm:a};e.textClass&&(d.pre.className=e.textClass);do{d.measure=e==b&&c;d.pos=0;d.addToken=d.measure?je:zd;(B||M)&&a.getOption("lineWrapping")&&(d.addToken=ke(d.addToken));c&&g&&e!=b&&!d.addedOne&&(c[0]=d.pre.appendChild(pb(a.display.measure)),d.addedOne=!0);var k=g=e;k.styles&&k.styles[0]==a.state.modeGen||(k.styles=Mc(a,k,k.stateAfter=Ka(a,K(k))));a:{var l=g;g=d;var k=k.styles,m=l.markedSpans;if(m)for(var l=l.text.length,p=0,n=1,q="",t=void 0,u=0,v=
void 0,w=void 0,z=void 0,x=void 0;;){if(u==p){for(var v=w=z="",x=null,u=Infinity,A=null,C=0;C<m.length;++C){var F=m[C],D=F.marker;F.from<=p&&(null==F.to||F.to>p)?(null!=F.to&&u>F.to&&(u=F.to,w=""),D.className&&(v+=" "+D.className),D.startStyle&&F.from==p&&(z+=" "+D.startStyle),D.endStyle&&F.to==u&&(w+=" "+D.endStyle),D.collapsed&&(!x||x.marker.width<D.width)&&(x=F)):F.from>p&&u>F.from&&(u=F.from);"bookmark"==D.type&&F.from==p&&D.replacedWith&&(A=D.replacedWith)}if(x&&(x.from||0)==p&&(Ad(g,(null==
x.to?l:x.to)-p,null!=x.from&&x.marker.replacedWith),null==x.to)){k=x.marker.find();break a}A&&!x&&Ad(g,0,A)}if(p>=l)break;for(A=Math.min(l,u);;){if(q){C=p+q.length;x||(F=C>A?q.slice(0,A-p):q,g.addToken(g,F,t?t+v:v,z,p+F.length==u?w:""));if(C>=A){q=q.slice(A-p);p=A;break}p=C;z=""}q=k[n++];t=xd(k[n++])}}else for(var n=1;n<k.length;n+=2)g.addToken(g,k[n],xd(k[n+1]));k=void 0}g=e==f;k&&(e=s(a.doc,k.to.line),h=!1)}while(k);c&&!d.addedOne&&(c[0]=d.pre.appendChild(h?r("span","\u00a0"):pb(a.display.measure)));
d.pre.firstChild||da(a.doc,b)||d.pre.appendChild(document.createTextNode("\u00a0"));var E;c&&B&&(E=T(e))&&(f=E.length-1,E[f].from==E[f].to&&--f,e=E[f],E=E[f-1],e.from+1==e.to&&E&&e.level<E.level&&(c=c[d.pos-1])&&c.parentNode.insertBefore(c.measureRight=pb(a.display.measure),c.nextSibling));G(a,"renderLine",a,b,d.pre);return d.pre}function zd(a,b,c,d,e){if(b){if(uc.test(b))for(var f=document.createDocumentFragment(),g=0;;){uc.lastIndex=g;var h=uc.exec(b),k=h?h.index-g:b.length-g;k&&(f.appendChild(document.createTextNode(b.slice(g,
g+k))),a.col+=k);if(!h)break;g+=k+1;"\t"==h[0]?(h=a.cm.options.tabSize,h-=a.col%h,f.appendChild(r("span",pd(h),"cm-tab")),a.col+=h):(k=r("span","\u2022","cm-invalidchar"),k.title="\\u"+h[0].charCodeAt(0).toString(16),f.appendChild(k),a.col+=1)}else{a.col+=b.length;var f=document.createTextNode(b)}if(c||d||e||a.measure)return b=c||"",d&&(b+=d),e&&(b+=e),a.pre.appendChild(r("span",[f],b));a.pre.appendChild(f)}}function je(a,b,c,d,e){for(var f=a.cm.options.lineWrapping,g=0;g<b.length;++g){var h=b.charAt(g),
k=0==g;"\ud800"<=h&&"\udbff">h&&g<b.length-1?(h=b.slice(g,g+2),++g):g&&f&&Db.test(b.slice(g-1,g+1))&&a.pre.appendChild(r("wbr"));k=a.measure[a.pos]=zd(a,h,c,k&&d,g==b.length-1&&e);B&&f&&" "==h&&g&&!/\s/.test(b.charAt(g-1))&&g<b.length-1&&!/\s/.test(b.charAt(g+1))&&(k.style.whiteSpace="normal");a.pos+=h.length}b.length&&(a.addedOne=!0)}function ke(a){function b(a){for(var b=" ",e=0;e<a.length-2;++e)b+=e%2?" ":"\u00a0";return b+" "}return function(c,d,e,f,g){return a(c,d.replace(/ {3,}/,b),e,f,g)}}
function Ad(a,b,c){c&&(a.display||(c=c.cloneNode(!0)),a.pre.appendChild(c),a.measure&&b&&(a.measure[a.pos]=c,a.addedOne=!0));a.pos+=b}function qc(a,b,c,d,e){function f(a,c,d){a.text=c;a.stateAfter&&(a.stateAfter=null);a.styles&&(a.styles=null);null!=a.order&&(a.order=null);td(a);ud(a,d);c=e?e(a):1;c!=a.height&&Q(a,c);R(a,"change",a,b)}var g=b.from,h=b.to,k=b.text,l=s(a,g.line),m=s(a,h.line),p=H(k),n=c?c[k.length-1]:null,r=h.line-g.line;if(0==g.ch&&0==h.ch&&""==p){for(var q=0,u=k.length-1,t=[];q<u;++q)t.push(Xa(k[q],
c?c[q]:null,e));f(m,m.text,n);r&&a.remove(g.line,r);t.length&&a.insert(g.line,t)}else if(l==m)if(1==k.length)f(l,l.text.slice(0,g.ch)+p+l.text.slice(h.ch),n);else{t=[];q=1;for(u=k.length-1;q<u;++q)t.push(Xa(k[q],c?c[q]:null,e));t.push(Xa(p+l.text.slice(h.ch),n,e));f(l,l.text.slice(0,g.ch)+k[0],c?c[0]:null);a.insert(g.line+1,t)}else if(1==k.length)f(l,l.text.slice(0,g.ch)+k[0]+m.text.slice(h.ch),c?c[0]:null),a.remove(g.line+1,r);else{f(l,l.text.slice(0,g.ch)+k[0],c?c[0]:null);f(m,p+m.text.slice(h.ch),
n);q=1;u=k.length-1;for(t=[];q<u;++q)t.push(Xa(k[q],c?c[q]:null,e));1<r&&a.remove(g.line+1,r-1);a.insert(g.line+1,t)}R(a,"change",a,b);aa(a,d.anchor,d.head,null,!0)}function Eb(a){this.lines=a;this.parent=null;for(var b=0,c=a.length,d=0;b<c;++b)a[b].parent=this,d+=a[b].height;this.height=d}function Ya(a){this.children=a;for(var b=0,c=0,d=0,e=a.length;d<e;++d){var f=a[d],b=b+f.chunkSize(),c=c+f.height;f.parent=this}this.size=b;this.height=c;this.parent=null}function Aa(a,b,c){function d(a,f,g){if(a.linked)for(var h=
0;h<a.linked.length;++h){var k=a.linked[h];if(k.doc!=f){var l=g&&k.sharedHist;if(!c||l)b(k.doc,l),d(k.doc,a,l)}}}d(a,null,!0)}function Cc(a,b){if(b.cm)throw Error("This document is already in use.");a.doc=b;b.cm=a;Gc(a);Ea(a);a.options.lineWrapping||Rb(a);a.options.mode=b.modeOption;A(a)}function s(a,b){for(b-=a.first;!a.lines;)for(var c=0;;++c){var d=a.children[c],e=d.chunkSize();if(b<e){a=d;break}b-=e}return a.lines[b]}function pc(a,b,c){var d=[],e=b.line;a.iter(b.line,c.line+1,function(a){a=a.text;
e==c.line&&(a=a.slice(0,c.ch));e==b.line&&(a=a.slice(b.ch));d.push(a);++e});return d}function vc(a,b,c){var d=[];a.iter(b,c,function(a){d.push(a.text)});return d}function Q(a,b){for(var c=b-a.height,d=a;d;d=d.parent)d.height+=c}function K(a){if(null==a.parent)return null;var b=a.parent;a=X(b.lines,a);for(var c=b.parent;c;b=c,c=c.parent)for(var d=0;c.children[d]!=b;++d)a+=c.children[d].chunkSize();return a+b.first}function fb(a,b){var c=a.first;a:do{for(var d=0,e=a.children.length;d<e;++d){var f=a.children[d],
g=f.height;if(b<g){a=f;continue a}b-=g;c+=f.chunkSize()}return c}while(!a.lines);d=0;for(e=a.lines.length;d<e;++d){f=a.lines[d].height;if(b<f)break;b-=f}return c+d}function pa(a,b){b=oa(a.doc,b);for(var c=0,d=b.parent,e=0;e<d.lines.length;++e){var f=d.lines[e];if(f==b)break;else c+=f.height}for(f=d.parent;f;d=f,f=d.parent)for(e=0;e<f.children.length;++e){var g=f.children[e];if(g==d)break;else c+=g.height}return c}function T(a){var b=a.order;null==b&&(b=a.order=le(a.text));return b}function Fb(){return{done:[],
undone:[],undoDepth:Infinity,lastTime:0,lastOp:null,lastOrigin:null,dirtyCounter:0}}function Bd(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,c),Math.min(a.first+a.size,d),function(c){c.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans);++f})}function oc(a,b){var c={from:b.from,to:kc(b),text:pc(a,b.from,b.to)};Bd(a,c,b.from.line,b.to.line+1);Aa(a,function(a){Bd(a,c,b.from.line,b.to.line+1)},!0);return c}function id(a,b,c,d){var e=a.history;e.undone.length=0;var f=+new Date,
g=H(e.done);if(g&&(e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&e.lastTime>f-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))){var h=H(g.changes);x(b.from,b.to)&&x(b.from,h.to)?h.to=kc(b):g.changes.push(oc(a,b));g.anchorAfter=c.anchor;g.headAfter=c.head}else{g={changes:[oc(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<a.length;++b)a[b].marker.explicitlyCleared?c||(c=a.slice(0,b)):c&&c.push(a[b]);return c?c.length?c:null:a}function Gb(a,b){for(var c=0,d=[];c<a.length;++c){var e=a[c],f=e.changes,g=[];d.push({changes:g,anchorBefore:e.anchorBefore,headBefore:e.headBefore,anchorAfter:e.anchorAfter,headAfter:e.headAfter});for(e=0;e<f.length;++e){var h=f[e],k;g.push({from:h.from,to:h.to,text:h.text});if(b)for(var l in h)(k=
l.match(/^spans_(\d+)$/))&&-1<X(b,Number(k[1]))&&(H(g)[l]=h[l],delete h[l])}}return d}function Hb(a,b,c,d){c<a.line?a.line+=d:b<a.line&&(a.line=b,a.ch=0)}function Cd(a,b,c,d){for(var e=0;e<a.length;++e){for(var f=a[e],g=!0,h=0;h<f.changes.length;++h){var k=f.changes[h];f.copied||(k.from=ia(k.from),k.to=ia(k.to));if(c<k.from.line)k.from.line+=d,k.to.line+=d;else if(b<=k.to.line){g=!1;break}}f.copied||(f.anchorBefore=ia(f.anchorBefore),f.headBefore=ia(f.headBefore),f.anchorAfter=ia(f.anchorAfter),f.readAfter=
ia(f.headAfter),f.copied=!0);g?(Hb(f.anchorBefore),Hb(f.headBefore),Hb(f.anchorAfter),Hb(f.headAfter)):(a.splice(0,e+1),e=0)}}function jd(a,b){var c=b.from.line,d=b.to.line,e=b.text.length-(d-c)-1;Cd(a.done,c,d,e);Cd(a.undone,c,d,e)}function me(){Pa(this)}function Oa(a){a.stop||(a.stop=me);return a}function D(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function Dd(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}function Pa(a){D(a);Dd(a)}function $c(a){var b=a.which;null==b&&
(a.button&1?b=1:a.button&2?b=3:a.button&4&&(b=2));qa&&a.ctrlKey&&1==b&&(b=3);return b}function v(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):(a=a._handlers||(a._handlers={}),(a[b]||(a[b]=[])).push(c))}function W(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,!1);else if(a.detachEvent)a.detachEvent("on"+b,c);else if(a=a._handlers&&a._handlers[b])for(b=0;b<a.length;++b)if(a[b]==c){a.splice(b,1);break}}function G(a,b){var c=a._handlers&&a._handlers[b];
if(c)for(var d=Array.prototype.slice.call(arguments,2),e=0;e<c.length;++e)c[e].apply(null,d)}function R(a,b){function c(a){return function(){a.apply(null,e)}}var d=a._handlers&&a._handlers[b];if(d){var e=Array.prototype.slice.call(arguments,2);$||(++ob,$=[],setTimeout(ne,0));for(var f=0;f<d.length;++f)$.push(c(d[f]))}}function ne(){--ob;var a=$;$=null;for(var b=0;b<a.length;++b)a[b]()}function ya(a,b){var c=a._handlers&&a._handlers[b];return c&&0<c.length}function Nb(){this.id=null}function sa(a,
b,c,d,e){null==b&&(b=a.search(/[^\s\u00a0]/),-1==b&&(b=a.length));d=d||0;for(e=e||0;d<b;++d)"\t"==a.charAt(d)?e+=c-e%c:++e;return e}function pd(a){for(;Ib.length<=a;)Ib.push(H(Ib)+" ");return Ib[a]}function H(a){return a[a.length-1]}function Vc(a){Ca?(a.selectionStart=0,a.selectionEnd=a.value.length):a.select()}function X(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;c<d;++c)if(a[c]==b)return c;return-1}function Cb(a,b){b||(b={});for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}
function Qc(a){for(var b=[],c=0;c<a;++c)b.push(void 0);return b}function L(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(null,b)}}function Bb(a){return/\w/.test(a)||"\u0080"<a&&(a.toUpperCase()!=a.toLowerCase()||oe.test(a))}function Ed(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function r(a,b,c,d){a=document.createElement(a);c&&(a.className=c);d&&(a.style.cssText=d);if("string"==typeof b)Kc(a,b);else if(b)for(c=0;c<b.length;++c)a.appendChild(b[c]);
return a}function cb(a){for(var b=a.childNodes.length;0<b;--b)a.removeChild(a.firstChild);return a}function U(a,b){return cb(a).appendChild(b)}function Kc(a,b){O?(a.innerHTML="",a.appendChild(document.createTextNode(b))):a.textContent=b}function C(a){return a.getBoundingClientRect()}function eb(a){if(null!=Jb)return Jb;var b=r("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");U(a,b);b.offsetWidth&&(Jb=b.offsetHeight-b.clientHeight);return Jb||0}function pb(a){if(null==wc){var b=r("span",
"\u200b");U(a,r("span",[b,document.createTextNode("x")]));0!=a.firstChild.offsetHeight&&(wc=1>=b.offsetWidth&&2<b.offsetHeight&&!ma)}return wc?r("span","\u200b"):r("span","\u00a0",null,"display: inline-block; width: 1px; margin-right: -1px")}function Rd(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=0;e<a.length;++e){var f=a[e];(f.from<c&&f.to>b||b==c&&f.to==b)&&d(Math.max(f.from,b),Math.min(f.to,c),1==f.level?"rtl":"ltr")}}function xc(a){return a.level%2?a.to:a.from}function yc(a){return a.level%2?
a.from:a.to}function mb(a){return(a=T(a))?xc(a[0]):0}function nb(a){var b=T(a);return b?yc(H(b)):a.text.length}function Fd(a,b){var c=s(a.doc,b),d=oa(a.doc,c);d!=c&&(b=K(d));d=(c=T(d))?c[0].level%2?nb(d):mb(d):0;return q(b,d)}function pe(a,b){for(var c,d;c=Ha(d=s(a.doc,b));)b=c.find().to.line;d=(c=T(d))?c[0].level%2?mb(d):nb(d):d.text.length;return q(b,d)}function ac(a,b,c,d){var e=T(a);if(!e)return qd(a,b,c,d);d=d?function(b,c){do b+=c;while(0<b&&bc.test(a.text.charAt(b)));return b}:function(a,b){return a+
b};for(var f=e[0].level,g=0;g<e.length;++g){var h=e[g],k=h.level%2==f;if(h.from<b&&h.to>b||k&&(h.from==b||h.to==b))break}for(b=d(b,h.level%2?-c:c);null!=b;)if(h.level%2==f)if(b<h.from||b>h.to)b=(h=e[g+=c])&&(0<c==h.level%2?d(h.to,-1):d(h.from,1));else break;else if(b==xc(h))b=(h=e[--g])&&yc(h);else if(b==yc(h))b=(h=e[++g])&&xc(h);else break;return 0>b||b>a.text.length?null:b}function qd(a,b,c,d){b+=c;if(d)for(;0<b&&bc.test(a.text.charAt(b));)b+=c;return 0>b||b>a.text.length?null:b}var za=/gecko\/\d/i.test(navigator.userAgent),
B=/MSIE \d/.test(navigator.userAgent),ma=B&&(null==document.documentMode||8>document.documentMode),O=B&&(null==document.documentMode||9>document.documentMode),M=/WebKit\//.test(navigator.userAgent),qe=M&&/Qt\/\d+\.\d+/.test(navigator.userAgent),re=/Chrome\//.test(navigator.userAgent),V=/Opera\//.test(navigator.userAgent),fc=/Apple Computer/.test(navigator.vendor),Qb=/KHTML\//.test(navigator.userAgent),Jd=/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent),Kd=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),
Wd=/PhantomJS/.test(navigator.userAgent),Ca=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),Mb=Ca||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),qa=Ca||/Mac/.test(navigator.platform),se=/windows/i.test(navigator.platform),Za=V&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);Za&&(Za=Number(Za[1]));var sd=qa&&(qe||V&&(null==Za||12.11>Za)),ec=za||B&&!O,hd=!1,Ia=!1,fa,Vd=0,tb,sb,ub=0,P=null;B?P=-.53:za?P=15:re?P=-.7:fc&&(P=-1/3);
var dd,ic=null,jc;n.Pos=q;n.prototype={focus:function(){window.focus();I(this);ca(this);Ma(this)},setOption:function(a,b){var c=this.options,d=c[a];if(c[a]!=b||"mode"==a)c[a]=b,la.hasOwnProperty(a)&&w(this,la[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;c<b.length;++c)if(("string"==typeof a?b[c].name:b[c])==a)return b.splice(c,
1),!0},addOverlay:w(null,function(a,b){var c=a.token?a:n.getMode(this.options,a);if(c.startState)throw Error("Overlays may not be stateful.");this.state.overlays.push({mode:c,modeSpec:a,opaque:b&&b.opaque});this.state.modeGen++;A(this)}),removeOverlay:w(null,function(a){for(var b=this.state.overlays,c=0;c<b.length;++c)if(b[c].modeSpec==a){b.splice(c,1);this.state.modeGen++;A(this);break}}),indentLine:w(null,function(a,b,c){"string"!=typeof b&&(b=null==b?this.options.smartIndent?"smart":"prev":b?"add":
"subtract");Ba(this.doc,a)&&wb(this,a,b,c)}),indentSelection:w(null,function(a){var b=this.doc.sel;if(x(b.from,b.to))return wb(this,b.from.line,a);for(var c=b.to.line-(b.to.ch?0:1),b=b.from.line;b<=c;++b)wb(this,b,a)}),getTokenAt:function(a){var b=this.doc;a=t(b,a);for(var c=Ka(this,a.line),d=this.doc.mode,b=s(b,a.line),b=new Ta(b.text,this.options.tabSize);b.pos<a.ch&&!b.eol();){b.start=b.pos;var e=d.token(b,c)}return{start:b.start,end:b.pos,string:b.current(),className:e||null,type:e||null,state:c}},
getStateAfter:function(a){var b=this.doc;a=Math.max(b.first,Math.min(null==a?b.first+b.size-1:a,b.first+b.size-1));return Ka(this,a+1)},cursorCoords:function(a,b){var c;c=this.doc.sel;c=null==a?c.head:"object"==typeof a?t(this.doc,a):a?c.from:c.to;return S(this,c,b||"page")},charCoords:function(a,b){return ib(this,t(this.doc,a),b||"page")},coordsChar:function(a,b){var c=b||"page";if("div"!=c){var d=a.left,e=a.top;"page"==c&&(d-=window.pageXOffset||(document.documentElement||document.body).scrollLeft,
e-=window.pageYOffset||(document.documentElement||document.body).scrollTop);var f=C(this.display.lineSpace),d=d-f.left,e=e-f.top;"local"!=c&&c||(c=C(this.display.wrapper),d+=c.left,e+=c.top);a={left:d,top:e}}return $b(this,a.left,a.top)},defaultTextHeight:function(){return Fa(this.display)},defaultCharWidth:function(){return Fc(this.display)},setGutterMarker:w(null,function(a,b,c){return Ab(this,a,function(a){var e=a.gutterMarkers||(a.gutterMarkers={});e[b]=c;!c&&Ed(e)&&(a.gutterMarkers=null);return!0})}),
clearGutter:w(null,function(a){var b=this,c=b.doc,d=c.first;c.iter(function(c){c.gutterMarkers&&c.gutterMarkers[a]&&(c.gutterMarkers[a]=null,A(b,d,d+1),Ed(c.gutterMarkers)&&(c.gutterMarkers=null));++d})}),addLineClass:w(null,function(a,b,c){return Ab(this,a,function(a){var e="text"==b?"textClass":"background"==b?"bgClass":"wrapClass";if(a[e]){if((new RegExp("\\b"+c+"\\b")).test(a[e]))return!1;a[e]+=" "+c}else a[e]=c;return!0})}),removeLineClass:w(null,function(a,b,c){return Ab(this,a,function(a){var e=
"text"==b?"textClass":"background"==b?"bgClass":"wrapClass",f=a[e];if(f)if(null==c)a[e]=null;else{var g=f.replace(new RegExp("^"+c+"\\b\\s*|\\s*\\b"+c+"\\b"),"");if(g==f)return!1;a[e]=g||null}else return!1;return!0})}),addLineWidget:w(null,function(a,b,c){return ie(this,a,b,c)}),removeLineWidget:function(a){a.clear()},lineInfo:function(a){if("number"==typeof a){if(!Ba(this.doc,a))return null;var b=a;a=s(this.doc,a);if(!a)return null}else if(b=K(a),null==b)return null;return{line:b,handle:a,text:a.text,
gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},getViewport:function(){return{from:this.display.showingFrom,to:this.display.showingTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=S(this,t(this.doc,a));var g=a.bottom,h=a.left;b.style.position="absolute";f.sizer.appendChild(b);if("over"==d)g=a.top;else if("above"==d||"near"==d){var k=Math.max(f.wrapper.clientHeight,this.doc.height),l=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);
("above"==d||a.bottom+b.offsetHeight>k)&&a.top>b.offsetHeight?g=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=k&&(g=a.bottom);h+b.offsetWidth>l&&(h=l-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=qb(this,h,g,h+b.offsetWidth,g+b.offsetHeight),null!=a.scrollTop&&Qa(this,a.scrollTop),null!=a.scrollLeft&&
va(this,a.scrollLeft))},triggerOnKeyDown:w(null,Zc),execCommand:function(a){return gc[a](this)},findPosH:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);var f=0;for(a=t(this.doc,a);f<b&&(a=rc(this.doc,a,e,c,d),!a.hitSide);++f);return a},moveH:w(null,function(a,b){var c=this.doc.sel,c=c.shift||c.extend||x(c.from,c.to)?rc(this.doc,c.head,a,b,this.options.rtlMoveVisually):0>a?c.from:c.to;E(this.doc,c,c,a)}),deleteH:w(null,function(a,b){var c=this.doc.sel;x(c.from,c.to)?ba(this.doc,"",c.from,rc(this.doc,c.head,
a,b,!1),"+delete"):ba(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);var f=0;for(a=t(this.doc,a);f<b&&(a=S(this,a,"div"),null==d?d=a.left:a.left=d,a=rd(this,a,e,c),!a.hitSide);++f);return a},moveV:w(null,function(a,b){var c=this.doc.sel,d=S(this,c.head,"div");null!=c.goalColumn&&(d.left=c.goalColumn);var e=rd(this,d,a,b);"page"==b&&od(this,0,ib(this,e,"div").top-d.top);E(this.doc,e,e,a);c.goalColumn=d.left}),toggleOverwrite:function(){(this.state.overwrite=
!this.state.overwrite)?this.display.cursor.className+=" CodeMirror-overwrite":this.display.cursor.className=this.display.cursor.className.replace(" CodeMirror-overwrite","")},hasFocus:function(){return this.state.focused},scrollTo:w(null,function(a,b){zb(this,a,b)}),getScrollInfo:function(){var a=this.display.scroller,b=Da;return{left:a.scrollLeft,top:a.scrollTop,height:a.scrollHeight-b,width:a.scrollWidth-b,clientHeight:a.clientHeight-b,clientWidth:a.clientWidth-b}},scrollIntoView:w(null,function(a,
b){"number"==typeof a&&(a=q(a,0));b||(b=0);var c=a;a&&null==a.line||(this.curOp.scrollToPos=a?t(this.doc,a):this.doc.sel.head,this.curOp.scrollToPosMargin=b,c=S(this,this.curOp.scrollToPos));c=qb(this,c.left,c.top-b,c.right,c.bottom+b);zb(this,c.scrollLeft,c.scrollTop)}),setSize:function(a,b){function c(a){return"number"==typeof a||/^\d+$/.test(String(a))?a+"px":a}null!=a&&(this.display.wrapper.style.width=c(a));null!=b&&(this.display.wrapper.style.height=c(b));this.refresh()},on:function(a,b){v(this,
a,b)},off:function(a,b){W(this,a,b)},operation:function(a){return Tc(this,a)},refresh:w(null,function(){na(this);zb(this,this.doc.scrollLeft,this.doc.scrollTop);A(this)}),swapDoc:w(null,function(a){var b=this.doc;b.cm=null;Cc(this,a);na(this);Z(this,!0);zb(this,a.scrollLeft,a.scrollTop);return b}),getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};
var la=n.optionHandlers={},Kb=n.defaults={},Dc=n.Init={toString:function(){return"CodeMirror.Init"}};u("value","",function(a,b){a.setValue(b)},!0);u("mode",null,function(a,b){a.doc.modeOption=b;Ea(a)},!0);u("indentUnit",2,Ea,!0);u("indentWithTabs",!1);u("smartIndent",!0);u("tabSize",4,function(a){Ea(a);na(a);A(a)},!0);u("electricChars",!0);u("rtlMoveVisually",!se);u("theme","default",function(a){Bc(a);Ga(a)},!0);u("keyMap","default",function(a){var b=Y[a.options.keyMap].style;a.display.wrapper.className=
a.display.wrapper.className.replace(/\s*cm-keymap-\S+/g,"")+(b?" cm-keymap-"+b:"")});u("extraKeys",null);u("onKeyEvent",null);u("onDragEvent",null);u("lineWrapping",!1,function(a){a.options.lineWrapping?(a.display.wrapper.className+=" CodeMirror-wrap",a.display.sizer.style.minWidth=""):(a.display.wrapper.className=a.display.wrapper.className.replace(" CodeMirror-wrap",""),Rb(a));Gc(a);A(a);na(a);setTimeout(function(){Hc(a.display,a.doc.height)},100)},!0);u("gutters",[],function(a){Lb(a.options);Ga(a)},
!0);u("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?Tb(a.display)+"px":"0";a.refresh()},!0);u("lineNumbers",!1,function(a){Lb(a.options);Ga(a)},!0);u("firstLineNumber",1,Ga,!0);u("lineNumberFormatter",function(a){return a},Ga,!0);u("showCursorWhenSelecting",!1,Vb,!0);u("readOnly",!1,function(a,b){"nocursor"==b?(Ob(a),a.display.input.blur()):b||Z(a,!0)});u("dragDrop",!0);u("cursorBlinkRate",530);u("cursorHeight",1);u("workTime",100);u("workDelay",100);u("flattenSpans",!0);u("pollInterval",
100);u("undoDepth",40,function(a,b){a.doc.history.undoDepth=b});u("historyEventDelay",500);u("viewportMargin",10,function(a){a.refresh()},!0);u("maxHighlightLength",1E4,function(a){Ea(a);a.refresh()},!0);u("moveInputWithCursor",!0,function(a,b){b||(a.display.inputDiv.style.top=a.display.inputDiv.style.left=0)});u("tabindex",null,function(a,b){a.display.input.tabIndex=b||""});u("autofocus",null);var Gd=n.modes={},zc=n.mimeModes={};n.defineMode=function(a,b){n.defaults.mode||"null"==a||(n.defaults.mode=
a);if(2<arguments.length){b.dependencies=[];for(var c=2;c<arguments.length;++c)b.dependencies.push(arguments[c])}Gd[a]=b};n.defineMIME=function(a,b){zc[a]=b};n.resolveMode=function(a){if("string"==typeof a&&zc.hasOwnProperty(a))a=zc[a];else if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return n.resolveMode("application/xml");return"string"==typeof a?{name:a}:a||{name:"null"}};n.getMode=function(a,b){b=n.resolveMode(b);var c=Gd[b.name];if(!c)return n.getMode(a,"text/plain");c=c(a,b);if($a.hasOwnProperty(b.name)){var d=
$a[b.name],e;for(e in d)d.hasOwnProperty(e)&&(c.hasOwnProperty(e)&&(c["_"+e]=c[e]),c[e]=d[e])}c.name=b.name;return c};n.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}});n.defineMIME("text/plain","null");var $a=n.modeExtensions={};n.extendMode=function(a,b){var c=$a.hasOwnProperty(a)?$a[a]:$a[a]={};Cb(b,c)};n.defineExtension=function(a,b){n.prototype[a]=b};n.defineDocExtension=function(a,b){J.prototype[a]=b};n.defineOption=u;var Pb=[];n.defineInitHook=function(a){Pb.push(a)};
n.copyState=ra;n.startState=Oc;n.innerMode=function(a,b){for(;a.innerMode;){var c=a.innerMode(b);b=c.state;a=c.mode}return c||{mode:a,state:b}};var gc=n.commands={selectAll:function(a){a.setSelection(q(a.firstLine(),0),q(a.lastLine()))},killLine:function(a){var b=a.getCursor(!0),c=a.getCursor(!1),d=!x(b,c);d||a.getLine(b.line).length!=b.ch?a.replaceRange("",b,d?c:q(b.line),"+delete"):a.replaceRange("",b,q(b.line+1,0),"+delete")},deleteLine:function(a){var b=a.getCursor().line;a.replaceRange("",q(b,
0),q(b),"+delete")},undo:function(a){a.undo()},redo:function(a){a.redo()},goDocStart:function(a){a.extendSelection(q(a.firstLine(),0))},goDocEnd:function(a){a.extendSelection(q(a.lastLine()))},goLineStart:function(a){a.extendSelection(Fd(a,a.getCursor().line))},goLineStartSmart:function(a){var b=a.getCursor(),c=Fd(a,b.line),d=a.getLineHandle(c.line),e=T(d);e&&0!=e[0].level?a.extendSelection(c):(d=Math.max(0,d.text.search(/\S/)),a.extendSelection(q(c.line,b.line==c.line&&b.ch<=d&&b.ch?0:d)))},goLineEnd:function(a){a.extendSelection(pe(a,
a.getCursor().line))},goLineRight:function(a){var b=a.charCoords(a.getCursor(),"div").top+5;a.extendSelection(a.coordsChar({left:a.display.lineDiv.offsetWidth+100,top:b},"div"))},goLineLeft:function(a){var b=a.charCoords(a.getCursor(),"div").top+5;a.extendSelection(a.coordsChar({left:0,top:b},"div"))},goLineUp:function(a){a.moveV(-1,"line")},goLineDown:function(a){a.moveV(1,"line")},goPageUp:function(a){a.moveV(-1,"page")},goPageDown:function(a){a.moveV(1,"page")},goCharLeft:function(a){a.moveH(-1,
"char")},goCharRight:function(a){a.moveH(1,"char")},goColumnLeft:function(a){a.moveH(-1,"column")},goColumnRight:function(a){a.moveH(1,"column")},goWordLeft:function(a){a.moveH(-1,"word")},goGroupRight:function(a){a.moveH(1,"group")},goGroupLeft:function(a){a.moveH(-1,"group")},goWordRight:function(a){a.moveH(1,"word")},delCharBefore:function(a){a.deleteH(-1,"char")},delCharAfter:function(a){a.deleteH(1,"char")},delWordBefore:function(a){a.deleteH(-1,"word")},delWordAfter:function(a){a.deleteH(1,
"word")},delGroupBefore:function(a){a.deleteH(-1,"group")},delGroupAfter:function(a){a.deleteH(1,"group")},indentAuto:function(a){a.indentSelection("smart")},indentMore:function(a){a.indentSelection("add")},indentLess:function(a){a.indentSelection("subtract")},insertTab:function(a){a.replaceSelection("\t","end","+input")},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):a.replaceSelection("\t","end","+input")},transposeChars:function(a){var b=a.getCursor(),c=a.getLine(b.line);
0<b.ch&&b.ch<c.length-1&&a.replaceRange(c.charAt(b.ch)+c.charAt(b.ch-1),q(b.line,b.ch-1),q(b.line,b.ch+1))},newlineAndIndent:function(a){w(a,function(){a.replaceSelection("\n","end","+input");a.indentLine(a.getCursor().line,null,!0)})()},toggleOverwrite:function(a){a.toggleOverwrite()}},Y=n.keyMap={};Y.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore",
Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite"};Y.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Alt-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext",
"Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore",fallthrough:"basic"};Y.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter",
"Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore",fallthrough:["basic","emacsy"]};Y["default"]=qa?Y.macDefault:Y.pcDefault;Y.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore",
"Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"};n.lookupKey=Ra;n.isModifierKey=ed;n.keyName=fd;n.fromTextArea=function(a,b){function c(){a.value=l.getValue()}b||(b={});b.value=a.value;!b.tabindex&&a.tabindex&&(b.tabindex=a.tabindex);!b.placeholder&&a.placeholder&&(b.placeholder=a.placeholder);if(null==b.autofocus){var d=document.body;try{d=document.activeElement}catch(e){}b.autofocus=d==a||null!=a.getAttribute("autofocus")&&d==document.body}if(a.form&&
(v(a.form,"submit",c),!b.leaveSubmitMethodAlone)){var f=a.form,g=f.submit;try{var h=f.submit=function(){c();f.submit=g;f.submit();f.submit=h}}catch(k){}}a.style.display="none";var l=n(function(b){a.parentNode.insertBefore(b,a.nextSibling)},b);l.save=c;l.getTextArea=function(){return a};l.toTextArea=function(){c();a.parentNode.removeChild(l.getWrapperElement());a.style.display="";a.form&&(W(a.form,"submit",c),"function"==typeof a.form.submit&&(a.form.submit=g))};return l};Ta.prototype={eol:function(){return this.pos>=
this.string.length},sol:function(){return 0==this.pos},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(a){var b=this.string.charAt(this.pos);if("string"==typeof a?b==a:b&&(a.test?a.test(b):a(b)))return++this.pos,b},eatWhile:function(a){for(var b=this.pos;this.eat(a););return this.pos>b},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(-1<a)return this.pos=a,!0},backUp:function(a){this.pos-=a},column:function(){this.lastColumnPos<this.start&&(this.lastColumnValue=sa(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start);return this.lastColumnValue},indentation:function(){return sa(this.string,null,this.tabSize)},match:function(a,b,c){if("string"==typeof a){var d=function(a){return c?
a.toLowerCase():a},e=this.string.substr(this.pos,a.length);if(d(e)==d(a))return!1!==b&&(this.pos+=a.length),!0}else{if((a=this.string.slice(this.pos).match(a))&&0<a.index)return null;a&&!1!==b&&(this.pos+=a[0].length);return a}},current:function(){return this.string.slice(this.start,this.pos)}};n.StringStream=Ta;n.TextMarker=ka;ka.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;b&&ta(a);for(var c=null,d=null,e=0;e<this.lines.length;++e){var f=this.lines[e],g=
Wa(f.markedSpans,this);null!=g.to&&(d=K(f));for(var h=f,k=f.markedSpans,l=g,m=void 0,p=0;p<k.length;++p)k[p]!=l&&(m||(m=[])).push(k[p]);h.markedSpans=m;null!=g.from?c=K(f):this.collapsed&&!da(this.doc,f)&&a&&Q(f,Fa(a.display))}if(a&&this.collapsed&&!a.options.lineWrapping)for(e=0;e<this.lines.length;++e)f=oa(a.doc,this.lines[e]),g=db(a.doc,f),g>a.display.maxLineLength&&(a.display.maxLine=f,a.display.maxLineLength=g,a.display.maxLineChanged=!0);null!=c&&a&&A(a,c,d+1);this.lines.length=0;this.explicitlyCleared=
!0;this.collapsed&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&nd(a));b&&ua(a);R(this,"clear")}};ka.prototype.find=function(){for(var a,b,c=0;c<this.lines.length;++c){var d=this.lines[c],e=Wa(d.markedSpans,this);if(null!=e.from||null!=e.to)d=K(d),null!=e.from&&(a=q(d,e.from)),null!=e.to&&(b=q(d,e.to))}return"bookmark"==this.type?a:a&&{from:a,to:b}};ka.prototype.getOptions=function(a){var b=this.replacedWith;return{className:this.className,inclusiveLeft:this.inclusiveLeft,inclusiveRight:this.inclusiveRight,
atomic:this.atomic,collapsed:this.collapsed,replacedWith:a?b&&b.cloneNode(!0):b,readOnly:this.readOnly,startStyle:this.startStyle,endStyle:this.endStyle}};ka.prototype.attachLine=function(a){if(!this.lines.length&&this.doc.cm){var b=this.doc.cm.curOp;b.maybeHiddenMarkers&&-1!=X(b.maybeHiddenMarkers,this)||(b.maybeUnhiddenMarkers||(b.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(a)};ka.prototype.detachLine=function(a){this.lines.splice(X(this.lines,a),1);!this.lines.length&&this.doc.cm&&(a=
this.doc.cm.curOp,(a.maybeHiddenMarkers||(a.maybeHiddenMarkers=[])).push(this))};n.SharedTextMarker=Va;Va.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var a=0;a<this.markers.length;++a)this.markers[a].clear();R(this,"clear")}};Va.prototype.find=function(){return this.primary.find()};Va.prototype.getOptions=function(a){a=this.primary.getOptions(a);a.shared=!0;return a};var tc=n.LineWidget=function(a,b,c){for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.cm=
a;this.node=b};tc.prototype.clear=vd(function(){var a=this.line.widgets,b=K(this.line);if(null!=b&&a){for(var c=0;c<a.length;++c)a[c]==this&&a.splice(c--,1);a.length||(this.line.widgets=null);Q(this.line,Math.max(0,this.line.height-kb(this)));A(this.cm,b,b+1)}});tc.prototype.changed=vd(function(){var a=this.height;this.height=null;if(a=kb(this)-a)Q(this.line,this.line.height+a),a=K(this.line),A(this.cm,a,a+1)});var yd={},uc=/[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\uFEFF]/g;Eb.prototype={chunkSize:function(){return this.lines.length},
removeInner:function(a,b){for(var c=a,d=a+b;c<d;++c){var e=this.lines[c];this.height-=e.height;var f=e;f.parent=null;td(f);R(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.splice.apply(a,[a.length,0].concat(this.lines))},insertInner:function(a,b,c){this.height+=c;this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));a=0;for(c=b.length;a<c;++a)b[a].parent=this},iterN:function(a,b,c){for(b=a+b;a<b;++a)if(c(this.lines[a]))return!0}};Ya.prototype={chunkSize:function(){return this.size},
removeInner:function(a,b){this.size-=b;for(var c=0;c<this.children.length;++c){var d=this.children[c],e=d.chunkSize();if(a<e){var f=Math.min(b,e-a),g=d.height;d.removeInner(a,f);this.height-=g-d.height;e==f&&(this.children.splice(c--,1),d.parent=null);if(0==(b-=f))break;a=0}else a-=e}25>this.size-b&&(c=[],this.collapse(c),this.children=[new Eb(c)],this.children[0].parent=this)},collapse:function(a){for(var b=0,c=this.children.length;b<c;++b)this.children[b].collapse(a)},insertInner:function(a,b,c){this.size+=
b.length;this.height+=c;for(var d=0,e=this.children.length;d<e;++d){var f=this.children[d],g=f.chunkSize();if(a<=g){f.insertInner(a,b,c);if(f.lines&&50<f.lines.length){for(;50<f.lines.length;)a=f.lines.splice(f.lines.length-25,25),a=new Eb(a),f.height-=a.height,this.children.splice(d+1,0,a),a.parent=this;this.maybeSpill()}break}a-=g}},maybeSpill:function(){if(!(10>=this.children.length)){var a=this;do{var b=a.children.splice(a.children.length-5,5),b=new Ya(b);if(a.parent){a.size-=b.size;a.height-=
b.height;var c=X(a.parent.children,a);a.parent.children.splice(c+1,0,b)}else c=new Ya(a.children),c.parent=a,a.children=[c,b],a=c;b.parent=a.parent}while(10<a.children.length);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=0,e=this.children.length;d<e;++d){var f=this.children[d],g=f.chunkSize();if(a<g){g=Math.min(b,g-a);if(f.iterN(a,g,c))return!0;if(0==(b-=g))break;a=0}else a-=g}}};var te=0,J=n.Doc=function(a,b,c){if(!(this instanceof J))return new J(a,b,c);null==c&&(c=0);Ya.call(this,[new Eb([Xa("",
null)])]);this.first=c;this.scrollTop=this.scrollLeft=0;this.cantEdit=!1;this.history=Fb();this.frontier=c;c=q(c,0);this.sel={from:c,to:c,head:c,anchor:c,shift:!1,extend:!1,goalColumn:null};this.id=++te;this.modeOption=b;"string"==typeof a&&(a=ga(a));qc(this,{from:c,to:c,text:a},null,{head:c,anchor:c})};J.prototype=function(a,b){function c(){}c.prototype=a;var d=new c;b&&Cb(b,d);return d}(Ya.prototype,{iter:function(a,b,c){c?this.iterN(a-this.first,b-a,c):this.iterN(this.first,this.first+this.size,
a)},insert:function(a,b){for(var c=0,d=0,e=b.length;d<e;++d)c+=b[d].height;this.insertInner(a-this.first,b,c)},remove:function(a,b){this.removeInner(a-this.first,b)},getValue:function(a){var b=vc(this,this.first,this.first+this.size);return!1===a?b:b.join(a||"\n")},setValue:function(a){var b=q(this.first,0),c=this.first+this.size-1;wa(this,{from:b,to:q(c,s(this,c).text.length),text:ga(a),origin:"setValue"},{head:b,anchor:b},!0)},replaceRange:function(a,b,c,d){b=t(this,b);c=c?t(this,c):b;ba(this,a,
b,c,d)},getRange:function(a,b,c){a=pc(this,t(this,a),t(this,b));return!1===c?a:a.join(c||"\n")},getLine:function(a){return(a=this.getLineHandle(a))&&a.text},setLine:function(a,b){Ba(this,a)&&ba(this,b,q(a,0),t(this,q(a)))},removeLine:function(a){a?ba(this,"",t(this,q(a-1)),t(this,q(a))):ba(this,"",q(0,0),t(this,q(1,0)))},getLineHandle:function(a){if(Ba(this,a))return s(this,a)},getLineNumber:function(a){return K(a)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+
this.size-1},clipPos:function(a){return t(this,a)},getCursor:function(a){var b=this.sel;return ia(null==a||"head"==a?b.head:"anchor"==a?b.anchor:"end"==a||!1===a?b.to:b.from)},somethingSelected:function(){return!x(this.sel.head,this.sel.anchor)},setCursor:La(function(a,b,c){a=t(this,"number"==typeof a?q(a,b||0):a);c?E(this,a):aa(this,a,a)}),setSelection:La(function(a,b){aa(this,t(this,a),t(this,b||a))}),extendSelection:La(function(a,b){E(this,t(this,a),b&&t(this,b))}),getSelection:function(a){return this.getRange(this.sel.from,
this.sel.to,a)},replaceSelection:function(a,b,c){wa(this,{from:this.sel.from,to:this.sel.to,text:ga(a),origin:c},b||"around")},undo:La(function(){kd(this,"undo")}),redo:La(function(){kd(this,"redo")}),setExtending:function(a){this.sel.extend=a},historySize:function(){var a=this.history;return{undo:a.done.length,redo:a.undone.length}},clearHistory:function(){this.history=Fb()},markClean:function(){this.history.dirtyCounter=0;this.history.lastOp=this.history.lastOrigin=null},isClean:function(){return 0==
this.history.dirtyCounter},getHistory:function(){return{done:Gb(this.history.done),undone:Gb(this.history.undone)}},setHistory:function(a){var b=this.history=Fb();b.done=a.done.slice(0);b.undone=a.undone.slice(0)},markText:function(a,b,c){return Ua(this,t(this,a),t(this,b),c,"range")},setBookmark:function(a,b){var c={replacedWith:b&&(null==b.nodeType?b.widget:b),insertLeft:b&&b.insertLeft};a=t(this,a);return Ua(this,a,a,c,"bookmark")},findMarksAt:function(a){a=t(this,a);var b=[],c=s(this,a.line).markedSpans;
if(c)for(var d=0;d<c.length;++d){var e=c[d];(null==e.from||e.from<=a.ch)&&(null==e.to||e.to>=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;c<b.length;++c)null!=b[c].from&&a.push(b[c].marker)});return a},posFromIndex:function(a){var b,c=this.first;this.iter(function(d){d=d.text.length+1;if(d>a)return b=a,!0;a-=d;++c});return t(this,q(c,b))},indexFromPos:function(a){a=t(this,a);var b=a.ch;if(a.line<this.first||
0>a.ch)return 0;this.iter(this.first,a.line,function(a){b+=a.text.length+1});return b},copy:function(a){var b=new J(vc(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.to<c&&(c=a.to);b=new J(vc(this,b,c),a.mode||this.modeOption,b);a.sharedHist&&(b.history=this.history);(this.linked||(this.linked=[])).push({doc:b,sharedHist:a.sharedHist});b.linked=[{doc:this,isParent:!0,sharedHist:a.sharedHist}];return b},unlinkDoc:function(a){a instanceof n&&(a=a.doc);if(this.linked)for(var b=0;b<this.linked.length;++b)if(this.linked[b].doc==a){this.linked.splice(b,1);a.unlinkDoc(this);
break}if(a.history==this.history){var c=[a.id];Aa(a,function(a){c.push(a.id)},!0);a.history=Fb();a.history.done=Gb(this.history.done,c);a.history.undone=Gb(this.history.undone,c)}},iterLinkedDocs:function(a){Aa(this,a)},getMode:function(){return this.mode},getEditor:function(){return this.cm}});J.prototype.eachLine=J.prototype.iter;var ue=["iter","insert","remove","copy","getEditor"],ab;for(ab in J.prototype)J.prototype.hasOwnProperty(ab)&&0>X(ue,ab)&&(n.prototype[ab]=function(a){return function(){return a.apply(this.doc,
arguments)}}(J.prototype[ab]));n.e_stop=Pa;n.e_preventDefault=D;n.e_stopPropagation=Dd;var $,ob=0;n.on=v;n.off=W;n.signal=G;var Da=30,ad=n.Pass={toString:function(){return"CodeMirror.Pass"}};Nb.prototype={set:function(a,b){clearTimeout(this.id);this.id=setTimeout(b,a)}};n.countColumn=sa;var Ib=[""],oe=/[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc]/,bc=/[\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]/;
n.replaceGetRect=function(a){C=a};var be=function(){if(O)return!1;var a=r("div");return"draggable"in a||"dragDrop"in a}(),Db=/^$/;za?Db=/$'/:fc&&!/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent)?Db=/\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/:M&&(Db=/[~!#%&*)=+}\]|\"\.>,:;][({[<]|-[^\-?\.]|\?[\w~`@#$%\^&*(_=+{[|><]/);var Jb,wc,ga=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/)};n.splitLines=ga;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?0!=b.compareEndPoints("StartToEnd",b):!1},Uc=function(){var a=r("div");if("oncopy"in a)return!0;a.setAttribute("oncopy","return;");return"function"==typeof a.oncopy}(),ja={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"};n.keyNames=ja;(function(){for(var a=0;10>a;a++)ja[a+48]=String(a);for(a=65;90>=a;a++)ja[a]=String.fromCharCode(a);for(a=1;12>=a;a++)ja[a+111]=ja[a+63235]="F"+a})();var le=function(){function a(a){return 255>=a?"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL".charAt(a):1424<=
a&&1524>=a?"R":1536<=a&&1791>=a?"rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr".charAt(a-1536):1792<=a&&2220>=a?"r":"L"}var b=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,c=/[stwN]/,d=/[LRr]/,e=/[Lb1n]/,f=/[1n]/;return function(g){if(!b.test(g))return!1;for(var h=g.length,k=[],l=0,m;l<h;++l)k.push(a(g.charCodeAt(l)));
for(var l=0,p="L";l<h;++l)m=k[l],"m"==m?k[l]=p:p=m;l=0;for(p="L";l<h;++l)m=k[l],"1"==m&&"r"==p?k[l]="n":d.test(m)&&(p=m,"r"==m&&(k[l]="R"));l=1;for(p=k[0];l<h-1;++l)m=k[l],"+"==m&&"1"==p&&"1"==k[l+1]?k[l]="1":","!=m||p!=k[l+1]||"1"!=p&&"n"!=p||(k[l]=p),p=m;for(l=0;l<h;++l)if(m=k[l],","==m)k[l]="N";else if("%"==m){for(p=l+1;p<h&&"%"==k[p];++p);var n=l&&"!"==k[l-1]||p<h-1&&"1"==k[p]?"1":"N";for(m=l;m<p;++m)k[m]=n;l=p-1}l=0;for(p="L";l<h;++l)m=k[l],"L"==p&&"1"==m?k[l]="L":d.test(m)&&(p=m);for(l=0;l<
h;++l)if(c.test(k[l])){for(p=l+1;p<h&&c.test(k[p]);++p);m="L"==(p<h-1?k[p]:"L");n="L"==(l?k[l-1]:"L")||m?"L":"R";for(m=l;m<p;++m)k[m]=n;l=p-1}for(var p=[],r,l=0;l<h;)if(e.test(k[l])){m=l;for(++l;l<h&&e.test(k[l]);++l);p.push({from:m,to:l,level:0})}else{var q=l,n=p.length;for(++l;l<h&&"L"!=k[l];++l);for(m=q;m<l;)if(f.test(k[m])){q<m&&p.splice(n,0,{from:q,to:m,level:1});q=m;for(++m;m<l&&f.test(k[m]);++m);p.splice(n,0,{from:q,to:m,level:2});q=m}else++m;q<l&&p.splice(n,0,{from:q,to:l,level:1})}1==p[0].level&&
(r=g.match(/^\s+/))&&(p[0].from=r[0].length,p.unshift({from:0,to:r[0].length,level:0}));1==H(p).level&&(r=g.match(/\s+$/))&&(H(p).to-=r[0].length,p.push({from:h-r[0].length,to:h,level:0}));p[0].level!=H(p).level&&p.push({from:h,to:h,level:p[0].level});return p}}();n.version="3.12";return n}();
