(function(f){if("object"==typeof exports&&"object"==typeof module)module.exports=f();else{if("function"==typeof define&&define.amd)return define([],f);this.CodeMirror=f()}})(function(){function f(a,b){if(!(this instanceof f))return new f(a,b);this.options=b=b?db(b):{};db(of,b,!1);Z(b);var c=b.value;"string"==typeof c&&(c=new sa(c,b.mode));this.doc=c;var d=this.display=new Q(a,c);d.wrapper.CodeMirror=this;P(this);D(this);b.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");b.autofocus&&
!td&&wa(this);r(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,draggingText:!1,highlight:new Fc,keySeq:null};O&&11>V&&setTimeout(Oa(Da,this,!0),20);pf(this);ae||(qf(),ae=!0);tb(this);this.curOp.forceUpdate=!0;be(this,c);b.autofocus&&!td||eb()==d.input?setTimeout(Oa(ud,this),20):Gc(this);for(var e in Kb)if(Kb.hasOwnProperty(e))Kb[e](this,b[e],ce);ub(this);for(c=0;c<vd.length;++c)vd[c](this);vb(this)}function Q(a,b){var c=
this.input=F("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none");ia?c.style.width="1000px":c.setAttribute("wrap","off");dc&&(c.style.border="1px solid black");c.setAttribute("autocorrect","off");c.setAttribute("autocapitalize","off");c.setAttribute("spellcheck","false");this.inputDiv=F("div",[c],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");this.scrollbarFiller=F("div",null,"CodeMirror-scrollbar-filler");this.scrollbarFiller.setAttribute("not-content",
"true");this.gutterFiller=F("div",null,"CodeMirror-gutter-filler");this.gutterFiller.setAttribute("not-content","true");this.lineDiv=F("div",null,"CodeMirror-code");this.selectionDiv=F("div",null,null,"position: relative; z-index: 1");this.cursorDiv=F("div",null,"CodeMirror-cursors");this.measure=F("div",null,"CodeMirror-measure");this.lineMeasure=F("div",null,"CodeMirror-measure");this.lineSpace=F("div",[this.measure,this.lineMeasure,this.selectionDiv,this.cursorDiv,this.lineDiv],null,"position: relative; outline: none");
this.mover=F("div",[F("div",[this.lineSpace],"CodeMirror-lines")],null,"position: relative");this.sizer=F("div",[this.mover],"CodeMirror-sizer");this.sizerWidth=null;this.heightForcer=F("div",null,null,"position: absolute; height: "+de+"px; width: 1px;");this.gutters=F("div",null,"CodeMirror-gutters");this.lineGutter=null;this.scroller=F("div",[this.sizer,this.heightForcer,this.gutters],"CodeMirror-scroll");this.scroller.setAttribute("tabIndex","-1");this.wrapper=F("div",[this.inputDiv,this.scrollbarFiller,
this.gutterFiller,this.scroller],"CodeMirror");O&&8>V&&(this.gutters.style.zIndex=-1,this.scroller.style.paddingRight=0);dc&&(c.style.width="0px");ia||(this.scroller.draggable=!0);wd&&(this.inputDiv.style.height="1px",this.inputDiv.style.position="absolute");a&&(a.appendChild?a.appendChild(this.wrapper):a(this.wrapper));this.reportedViewFrom=this.reportedViewTo=this.viewFrom=this.viewTo=b.first;this.view=[];this.externalMeasured=this.renderedView=null;this.lastWrapHeight=this.lastWrapWidth=this.viewOffset=
0;this.updateLineNumbers=null;this.nativeBarWidth=this.barHeight=this.barWidth=0;this.scrollbarsClipped=!1;this.lineNumWidth=this.lineNumInnerWidth=this.lineNumChars=null;this.prevInput="";this.pollingFast=this.alignWidgets=!1;this.poll=new Fc;this.cachedCharWidth=this.cachedTextHeight=this.cachedPaddingH=null;this.inaccurateSelection=!1;this.maxLine=null;this.maxLineLength=0;this.maxLineChanged=!1;this.wheelDX=this.wheelDY=this.wheelStartX=this.wheelStartY=null;this.shift=!1;this.selForContextMenu=
null}function I(a){a.doc.mode=f.getMode(a.options,a.doc.modeOption);v(a)}function v(a){a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null);a.styles&&(a.styles=null)});a.doc.frontier=a.doc.first;Pa(a,100);a.state.modeGen++;a.curOp&&za(a)}function z(a){var b=wb(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/ec(a.display)-3);return function(e){if(xb(a.doc,e))return 0;var g=0;if(e.widgets)for(var m=0;m<e.widgets.length;m++)e.widgets[m].height&&(g+=e.widgets[m].height);
return c?g+(Math.ceil(e.text.length/d)||1)*b:g+b}}function y(a){var b=a.doc,c=z(a);b.iter(function(a){var b=c(a);b!=a.height&&Qa(a,b)})}function D(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-");Ea(a)}function A(a){P(a);za(a);setTimeout(function(){ja(a)},20)}function P(a){var b=a.display.gutters,c=a.options.gutters;yb(b);for(var d=0;d<c.length;++d){var e=c[d],g=b.appendChild(F("div",null,"CodeMirror-gutter "+e));
"CodeMirror-linenumbers"==e&&(a.display.lineGutter=g,g.style.width=(a.display.lineNumWidth||1)+"px")}b.style.display=d?"":"none";K(a)}function K(a){a.display.sizer.style.marginLeft=a.display.gutters.offsetWidth+"px"}function w(a){if(0==a.height)return 0;for(var b=a.text.length,c,d=a;c=zb(d,!0);)c=c.find(0,!0),d=c.from.line,b+=c.from.ch-c.to.ch;for(d=a;c=zb(d,!1);)c=c.find(0,!0),b-=d.text.length-c.from.ch,d=c.to.line,b+=d.text.length-c.to.ch;return b}function h(a){var b=a.display;a=a.doc;b.maxLine=
G(a,a.first);b.maxLineLength=w(b.maxLine);b.maxLineChanged=!0;a.iter(function(a){var d=w(a);d>b.maxLineLength&&(b.maxLineLength=d,b.maxLine=a)})}function Z(a){var b=ka(a.gutters,"CodeMirror-linenumbers");-1==b&&a.lineNumbers?a.gutters=a.gutters.concat(["CodeMirror-linenumbers"]):-1<b&&!a.lineNumbers&&(a.gutters=a.gutters.slice(0),a.gutters.splice(b,1))}function l(a){var b=a.display,c=b.gutters.offsetWidth,d=Math.round(a.doc.height+Lb(a.display));return{clientHeight:b.scroller.clientHeight,viewHeight:b.wrapper.clientHeight,
scrollWidth:b.scroller.scrollWidth,clientWidth:b.scroller.clientWidth,viewWidth:b.wrapper.clientWidth,barLeft:a.options.fixedGutter?c:0,docHeight:d,scrollHeight:d+Aa(a)+b.barHeight,nativeBarWidth:b.nativeBarWidth,gutterWidth:c}}function T(a,b,c){this.cm=c;var d=this.vert=F("div",[F("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),e=this.horiz=F("div",[F("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");a(d);a(e);M(d,"scroll",function(){d.clientHeight&&b(d.scrollTop,
"vertical")});M(e,"scroll",function(){e.clientWidth&&b(e.scrollLeft,"horizontal")});this.checkedOverlay=!1;O&&8>V&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function n(){}function r(a){a.display.scrollbars&&(a.display.scrollbars.clear(),a.display.scrollbars.addClass&&fc(a.display.wrapper,a.display.scrollbars.addClass));a.display.scrollbars=new f.scrollbarModel[a.options.scrollbarStyle](function(b){a.display.wrapper.insertBefore(b,a.display.scrollbarFiller);M(b,"mousedown",function(){a.state.focused&&
setTimeout(Oa(wa,a),0)});b.setAttribute("not-content","true")},function(b,c){"horizontal"==c?Mb(a,b):gc(a,b)},a);a.display.scrollbars.addClass&&hc(a.display.wrapper,a.display.scrollbars.addClass)}function C(a,b){b||(b=l(a));var c=a.display.barWidth,d=a.display.barHeight;ea(a,b);for(var e=0;4>e&&c!=a.display.barWidth||d!=a.display.barHeight;e++)c!=a.display.barWidth&&a.options.lineWrapping&&da(a),ea(a,l(a)),c=a.display.barWidth,d=a.display.barHeight}function ea(a,b){var c=a.display,d=c.scrollbars.update(b);
c.sizer.style.paddingRight=(c.barWidth=d.right)+"px";c.sizer.style.paddingBottom=(c.barHeight=d.bottom)+"px";d.right&&d.bottom?(c.scrollbarFiller.style.display="block",c.scrollbarFiller.style.height=d.bottom+"px",c.scrollbarFiller.style.width=d.right+"px"):c.scrollbarFiller.style.display="";d.bottom&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(c.gutterFiller.style.display="block",c.gutterFiller.style.height=d.bottom+"px",c.gutterFiller.style.width=b.gutterWidth+"px"):c.gutterFiller.style.display=
""}function R(a,b,c){var d=c&&null!=c.top?Math.max(0,c.top):a.scroller.scrollTop,d=Math.floor(d-a.lineSpace.offsetTop),e=c&&null!=c.bottom?c.bottom:d+a.wrapper.clientHeight,d=Ab(b,d),e=Ab(b,e);if(c&&c.ensure){var g=c.ensure.from.line;c=c.ensure.to.line;g<d?(d=g,e=Ab(b,Ra(G(b,g))+a.wrapper.clientHeight)):Math.min(c,b.lastLine())>=e&&(d=Ab(b,Ra(G(b,c))-a.wrapper.clientHeight),e=c)}return{from:d,to:Math.max(e,d+1)}}function ja(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=
oa(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,g=d+"px",m=0;m<c.length;m++)if(!c[m].hidden){a.options.fixedGutter&&c[m].gutter&&(c[m].gutter.style.left=g);var p=c[m].alignable;if(p)for(var t=0;t<p.length;t++)p[t].style.left=g}a.options.fixedGutter&&(b.gutters.style.left=d+e+"px")}}function ub(a){if(!a.options.lineNumbers)return!1;var b=a.doc,b=Fa(a.options,b.first+b.size-1),c=a.display;if(b.length!=c.lineNumChars){var d=c.measure.appendChild(F("div",[F("div",b)],"CodeMirror-linenumber CodeMirror-gutter-elt")),
e=d.firstChild.offsetWidth,d=d.offsetWidth-e;c.lineGutter.style.width="";c.lineNumInnerWidth=Math.max(e,c.lineGutter.offsetWidth-d);c.lineNumWidth=c.lineNumInnerWidth+d;c.lineNumChars=c.lineNumInnerWidth?b.length:-1;c.lineGutter.style.width=c.lineNumWidth+"px";K(a);return!0}return!1}function Fa(a,b){return String(a.lineNumberFormatter(b+a.firstLineNumber))}function oa(a){return a.scroller.getBoundingClientRect().left-a.sizer.getBoundingClientRect().left}function Za(a,b,c){var d=a.display;this.viewport=
b;this.visible=R(d,a.doc,b);this.editorIsHidden=!d.wrapper.offsetWidth;this.wrapperHeight=d.wrapper.clientHeight;this.wrapperWidth=d.wrapper.clientWidth;this.oldDisplayWidth=ta(a);this.force=c;this.dims=ic(a)}function ua(a,b){var c=a.display,d=a.doc;if(b.editorIsHidden)return fb(a),!1;if(!b.force&&b.visible.from>=c.viewFrom&&b.visible.to<=c.viewTo&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo)&&c.renderedView==c.view&&0==ee(a))return!1;ub(a)&&(fb(a),b.dims=ic(a));var e=d.first+d.size,
g=Math.max(b.visible.from-a.options.viewportMargin,d.first),m=Math.min(e,b.visible.to+a.options.viewportMargin);c.viewFrom<g&&20>g-c.viewFrom&&(g=Math.max(d.first,c.viewFrom));c.viewTo>m&&20>c.viewTo-m&&(m=Math.min(e,c.viewTo));gb&&(g=xd(a.doc,g),m=fe(a.doc,m));d=g!=c.viewFrom||m!=c.viewTo||c.lastWrapHeight!=b.wrapperHeight||c.lastWrapWidth!=b.wrapperWidth;e=a.display;0==e.view.length||g>=e.viewTo||m<=e.viewFrom?(e.view=Hc(a,g,m),e.viewFrom=g):(e.viewFrom>g?e.view=Hc(a,g,e.viewFrom).concat(e.view):
e.viewFrom<g&&(e.view=e.view.slice(jc(a,g))),e.viewFrom=g,e.viewTo<m?e.view=e.view.concat(Hc(a,e.viewTo,m)):e.viewTo>m&&(e.view=e.view.slice(0,jc(a,m))));e.viewTo=m;c.viewOffset=Ra(G(a.doc,c.viewFrom));a.display.mover.style.top=c.viewOffset+"px";m=ee(a);if(!d&&0==m&&!b.force&&c.renderedView==c.view&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo))return!1;g=eb();4<m&&(c.lineDiv.style.display="none");yd(a,c.updateLineNumbers,b.dims);4<m&&(c.lineDiv.style.display="");c.renderedView=c.view;
g&&eb()!=g&&g.offsetHeight&&g.focus();yb(c.cursorDiv);yb(c.selectionDiv);c.heightForcer.style.top=c.gutters.style.height=0;d&&(c.lastWrapHeight=b.wrapperHeight,c.lastWrapWidth=b.wrapperWidth,Pa(a,400));c.updateLineNumbers=null;return!0}function aa(a,b){for(var c=b.viewport,d=!0;;d=!1){if(!d||!a.options.lineWrapping||b.oldDisplayWidth==ta(a))if(c&&null!=c.top&&(c={top:Math.min(a.doc.height+Lb(a.display)-hb(a),c.top)}),b.visible=R(a.display,a.doc,c),b.visible.from>=a.display.viewFrom&&b.visible.to<=
a.display.viewTo)break;if(!ua(a,b))break;da(a);d=l(a);Sa(a);Nb(a,d);C(a,d)}la(a,"update",a);if(a.display.viewFrom!=a.display.reportedViewFrom||a.display.viewTo!=a.display.reportedViewTo)la(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo),a.display.reportedViewFrom=a.display.viewFrom,a.display.reportedViewTo=a.display.viewTo}function Ga(a,b){var c=new Za(a,b);ua(a,c)&&(da(a),aa(a,c),c=l(a),Sa(a),Nb(a,c),C(a,c))}function Nb(a,b){a.display.sizer.style.minHeight=b.docHeight+"px";var c=b.docHeight+
Aa(a);a.display.heightForcer.style.top=c+"px";a.display.gutters.style.height=Math.max(c,b.clientHeight)+"px"}function da(a){a=a.display;for(var b=a.lineDiv.offsetTop,c=0;c<a.view.length;c++){var d=a.view[c],e;if(!d.hidden){if(O&&8>V){var g=d.node.offsetTop+d.node.offsetHeight;e=g-b;b=g}else e=d.node.getBoundingClientRect(),e=e.bottom-e.top;g=d.line.height-e;2>e&&(e=wb(a));if(.001<g||-.001>g)if(Qa(d.line,e),Ic(d.line),d.rest)for(e=0;e<d.rest.length;e++)Ic(d.rest[e])}}}function Ic(a){if(a.widgets)for(var b=
0;b<a.widgets.length;++b)a.widgets[b].height=a.widgets[b].node.offsetHeight}function ic(a){for(var b=a.display,c={},d={},e=b.gutters.clientLeft,g=b.gutters.firstChild,m=0;g;g=g.nextSibling,++m)c[a.options.gutters[m]]=g.offsetLeft+g.clientLeft+e,d[a.options.gutters[m]]=g.clientWidth;return{fixedPos:oa(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function yd(a,b,c){function d(b){var c=b.nextSibling;ia&&Ha&&a.display.currentWheelTarget==b?b.style.display=
"none":b.parentNode.removeChild(b);return c}for(var e=a.display,g=a.options.lineNumbers,m=e.lineDiv,p=m.firstChild,t=e.view,e=e.viewFrom,U=0;U<t.length;U++){var x=t[U];if(!x.hidden)if(x.node){for(;p!=x.node;)p=d(p);p=g&&null!=b&&b<=e&&x.lineNumber;x.changes&&(-1<ka(x.changes,"gutter")&&(p=!1),Ob(a,x,e,c));p&&(yb(x.lineNumber),x.lineNumber.appendChild(document.createTextNode(Fa(a.options,e))));p=x.node.nextSibling}else{var k=ib(a,x,e,c);m.insertBefore(k,p)}e+=x.size}for(;p;)p=d(p)}function Ob(a,b,
c,d){for(var e=0;e<b.changes.length;e++){var g=b.changes[e];if("text"==g){var g=b,m=g.text.className,p=Ta(a,g);g.text==g.node&&(g.node=p.pre);g.text.parentNode.replaceChild(p.pre,g.text);g.text=p.pre;p.bgClass!=g.bgClass||p.textClass!=g.textClass?(g.bgClass=p.bgClass,g.textClass=p.textClass,Ia(g)):m&&(g.text.className=m)}else if("gutter"==g)Ba(a,b,c,d);else if("class"==g)Ia(b);else if("widget"==g){g=b;m=d;g.alignable&&(g.alignable=null);for(var p=g.node.firstChild,t=void 0;p;p=t)t=p.nextSibling,"CodeMirror-linewidget"==
p.className&&g.node.removeChild(p);W(g,m)}}b.changes=null}function Ca(a){a.node==a.text&&(a.node=F("div",null,null,"position: relative"),a.text.parentNode&&a.text.parentNode.replaceChild(a.node,a.text),a.node.appendChild(a.text),O&&8>V&&(a.node.style.zIndex=2));return a.node}function Ta(a,b){var c=a.display.externalMeasured;return c&&c.line==b.line?(a.display.externalMeasured=null,b.measure=c.measure,c.built):ge(a,b)}function Ia(a){var b=a.bgClass?a.bgClass+" "+(a.line.bgClass||""):a.line.bgClass;
b&&(b+=" CodeMirror-linebackground");if(a.background)b?a.background.className=b:(a.background.parentNode.removeChild(a.background),a.background=null);else if(b){var c=Ca(a);a.background=c.insertBefore(F("div",null,b),c.firstChild)}a.line.wrapClass?Ca(a).className=a.line.wrapClass:a.node!=a.text&&(a.node.className="");a.text.className=(a.textClass?a.textClass+" "+(a.line.textClass||""):a.line.textClass)||""}function Ba(a,b,c,d){b.gutter&&(b.node.removeChild(b.gutter),b.gutter=null);var e=b.line.gutterMarkers;
if(a.options.lineNumbers||e){var g=Ca(b),g=b.gutter=g.insertBefore(F("div",null,"CodeMirror-gutter-wrapper","left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px; width: "+d.gutterTotalWidth+"px"),b.text);b.line.gutterClass&&(g.className+=" "+b.line.gutterClass);!a.options.lineNumbers||e&&e["CodeMirror-linenumbers"]||(b.lineNumber=g.appendChild(F("div",Fa(a.options,c),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+d.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+a.display.lineNumInnerWidth+
"px")));if(e)for(b=0;b<a.options.gutters.length;++b){c=a.options.gutters[b];var m=e.hasOwnProperty(c)&&e[c];m&&g.appendChild(F("div",[m],"CodeMirror-gutter-elt","left: "+d.gutterLeft[c]+"px; width: "+d.gutterWidth[c]+"px"))}}}function ib(a,b,c,d){var e=Ta(a,b);b.text=b.node=e.pre;e.bgClass&&(b.bgClass=e.bgClass);e.textClass&&(b.textClass=e.textClass);Ia(b);Ba(a,b,c,d);W(b,d);return b.node}function W(a,b){pa(a.line,a,b,!0);if(a.rest)for(var c=0;c<a.rest.length;c++)pa(a.rest[c],a,b,!1)}function pa(a,
b,c,d){if(a.widgets){var e=Ca(b),g=0;for(a=a.widgets;g<a.length;++g){var m=a[g],p=F("div",[m.node],"CodeMirror-linewidget");m.handleMouseEvents||p.setAttribute("cm-ignore-events","true");var t=m,U=p,x=c;if(t.noHScroll){(b.alignable||(b.alignable=[])).push(U);var k=x.wrapperWidth;U.style.left=x.fixedPos+"px";t.coverGutter||(k-=x.gutterTotalWidth,U.style.paddingLeft=x.gutterTotalWidth+"px");U.style.width=k+"px"}t.coverGutter&&(U.style.zIndex=5,U.style.position="relative",t.noHScroll||(U.style.marginLeft=
-x.gutterTotalWidth+"px"));d&&m.above?e.insertBefore(p,b.gutter||b.text):e.appendChild(p);la(m,"redraw")}}}function q(a){return B(a.line,a.ch)}function ma(a,b){return 0>N(a,b)?b:a}function u(a,b){return 0>N(a,b)?a:b}function Ja(a,b){this.ranges=a;this.primIndex=b}function S(a,b){this.anchor=a;this.head=b}function va(a,b){var c=a[b];a.sort(function(a,b){return N(a.from(),b.from())});b=ka(a,c);for(c=1;c<a.length;c++){var d=a[c],e=a[c-1];if(0<=N(e.to(),d.from())){var g=u(e.from(),d.from()),m=ma(e.to(),
d.to()),d=e.empty()?d.from()==d.head:e.from()==e.head;c<=b&&--b;a.splice(--c,2,new S(d?m:g,d?g:m))}}return new Ja(a,b)}function Ua(a,b){return new Ja([new S(a,b||a)],0)}function J(a,b){if(b.line<a.first)return B(a.first,0);var c=a.first+a.size-1;if(b.line>c)return B(c,G(a,c).text.length);var c=G(a,b.line).text.length,d=b.ch,c=null==d||d>c?B(b.line,c):0>d?B(b.line,0):b;return c}function Va(a,b){return b>=a.first&&b<a.first+a.size}function jb(a,b,c,d){return a.cm&&a.cm.display.shift||a.extend?(a=b.anchor,
d&&(b=0>N(c,a),b!=0>N(d,a)?(a=c,c=d):b!=0>N(c,d)&&(c=d)),new S(a,c)):new S(d||c,c)}function xa(a,b,c,d){fa(a,new Ja([jb(a,a.sel.primary(),b,c)],0),d)}function Pb(a,b,c){for(var d=[],e=0;e<a.sel.ranges.length;e++)d[e]=jb(a,a.sel.ranges[e],b[e],null);b=va(d,a.sel.primIndex);fa(a,b,c)}function kc(a,b,c,d){var e=a.sel.ranges.slice(0);e[b]=c;fa(a,va(e,a.sel.primIndex),d)}function Jc(a,b){var c={ranges:b.ranges,update:function(b){this.ranges=[];for(var c=0;c<b.length;c++)this.ranges[c]=new S(J(a,b[c].anchor),
J(a,b[c].head))}};ga(a,"beforeSelectionChange",a,c);a.cm&&ga(a.cm,"beforeSelectionChange",a.cm,c);return c.ranges!=b.ranges?va(c.ranges,c.ranges.length-1):b}function kb(a,b,c){var d=a.history.done,e=X(d);e&&e.ranges?(d[d.length-1]=b,Qb(a,b,c)):fa(a,b,c)}function fa(a,b,c){Qb(a,b,c);b=a.sel;var d=a.cm?a.cm.curOp.id:NaN,e=a.history,g=c&&c.origin,m;if(!(m=d==e.lastSelOp)&&(m=g&&e.lastSelOrigin==g)&&!(m=e.lastModTime==e.lastSelTime&&e.lastOrigin==g)){m=X(e.done);var p=g.charAt(0);m="*"==p||"+"==p&&m.ranges.length==
b.ranges.length&&m.somethingSelected()==b.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}m?e.done[e.done.length-1]=b:Kc(b,e.done);e.lastSelTime=+new Date;e.lastSelOrigin=g;e.lastSelOp=d;c&&!1!==c.clearRedo&&he(e.undone)}function Qb(a,b,c){if(Ka(a,"beforeSelectionChange")||a.cm&&Ka(a.cm,"beforeSelectionChange"))b=Jc(a,b);var d=c&&c.bias||(0>N(b.primary().head,a.sel.primary().head)?-1:1);Lc(a,lc(a,b,d,!0));c&&!1===c.scroll||!a.cm||Rb(a.cm)}function Lc(a,
b){b.equals(a.sel)||(a.sel=b,a.cm&&(a.cm.curOp.updateInput=a.cm.curOp.selectionChanged=!0,ie(a.cm)),la(a,"cursorActivity",a))}function Mc(a){Lc(a,lc(a,a.sel,null,!1),lb)}function lc(a,b,c,d){for(var e,g=0;g<b.ranges.length;g++){var m=b.ranges[g],p=mb(a,m.anchor,c,d),t=mb(a,m.head,c,d);if(e||p!=m.anchor||t!=m.head)e||(e=b.ranges.slice(0,g)),e[g]=new S(p,t)}return e?va(e,b.primIndex):b}function mb(a,b,c,d){var e=!1,g=b,m=c||1;a.cantEdit=!1;a:for(;;){var p=G(a,g.line);if(p.markedSpans)for(var t=0;t<
p.markedSpans.length;++t){var U=p.markedSpans[t],x=U.marker;if((null==U.from||(x.inclusiveLeft?U.from<=g.ch:U.from<g.ch))&&(null==U.to||(x.inclusiveRight?U.to>=g.ch:U.to>g.ch))){if(d&&(ga(x,"beforeCursorEnter"),x.explicitlyCleared))if(p.markedSpans){--t;continue}else break;if(x.atomic){t=x.find(0>m?-1:1);if(0==N(t,g)&&(t.ch+=m,0>t.ch?t=t.line>a.first?J(a,B(t.line-1)):null:t.ch>p.text.length&&(t=t.line<a.first+a.size-1?B(t.line+1,0):null),!t)){if(e){if(!d)return mb(a,b,c,!0);a.cantEdit=!0;return B(a.first,
0)}e=!0;t=b;m=-m}g=t;continue a}}}return g}}function Nc(a){for(var b=a.display,c=a.doc,d={},e=d.cursors=document.createDocumentFragment(),g=d.selection=document.createDocumentFragment(),m=0;m<c.sel.ranges.length;m++){var p=c.sel.ranges[m],t=p.empty();if(t||a.options.showCursorWhenSelecting){var U=a,x=e,k=$a(U,p.head,"div",null,null,!U.options.singleCursorHeightPerLine),ba=x.appendChild(F("div","\u00a0","CodeMirror-cursor"));ba.style.left=k.left+"px";ba.style.top=k.top+"px";ba.style.height=Math.max(0,
k.bottom-k.top)*U.options.cursorHeight+"px";k.other&&(U=x.appendChild(F("div","\u00a0","CodeMirror-cursor CodeMirror-secondarycursor")),U.style.display="",U.style.left=k.other.left+"px",U.style.top=k.other.top+"px",U.style.height=.85*(k.other.bottom-k.other.top)+"px")}t||nb(a,p,g)}a.options.moveInputWithCursor&&(a=$a(a,c.sel.primary().head,"div"),c=b.wrapper.getBoundingClientRect(),e=b.lineDiv.getBoundingClientRect(),d.teTop=Math.max(0,Math.min(b.wrapper.clientHeight-10,a.top+e.top-c.top)),d.teLeft=
Math.max(0,Math.min(b.wrapper.clientWidth-10,a.left+e.left-c.left)));return d}function Oc(a,b){Wa(a.display.cursorDiv,b.cursors);Wa(a.display.selectionDiv,b.selection);null!=b.teTop&&(a.display.inputDiv.style.top=b.teTop+"px",a.display.inputDiv.style.left=b.teLeft+"px")}function Sa(a){Oc(a,Nc(a))}function nb(a,b,c){function d(a,b,c,d){0>b&&(b=0);b=Math.round(b);d=Math.round(d);p.appendChild(F("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?x-a:
c)+"px; height: "+(d-b)+"px"))}function e(b,c,e){var g=G(m,b),p=g.text.length,t,f;rf(Xa(g),c||0,null==e?p:e,function(m,zd,l){var q=Pc(a,B(b,m),"div",g,"left"),h,n;m==zd?(h=q,l=n=q.left):(h=Pc(a,B(b,zd-1),"div",g,"right"),"rtl"==l&&(l=q,q=h,h=l),l=q.left,n=h.right);null==c&&0==m&&(l=k);3<h.top-q.top&&(d(l,q.top,null,q.bottom),l=k,q.bottom<h.top&&d(l,q.bottom,null,h.top));null==e&&zd==p&&(n=x);if(!t||q.top<t.top||q.top==t.top&&q.left<t.left)t=q;if(!f||h.bottom>f.bottom||h.bottom==f.bottom&&h.right>
f.right)f=h;l<k+1&&(l=k);d(l,h.top,n-l,h.bottom)});return{start:t,end:f}}var g=a.display,m=a.doc,p=document.createDocumentFragment(),t=Sb(a.display),k=t.left,x=Math.max(g.sizerWidth,ta(a)-g.sizer.offsetLeft)-t.right,g=b.from();b=b.to();if(g.line==b.line)e(g.line,g.ch,b.ch);else{var f=G(m,g.line),t=G(m,b.line),t=Ya(f)==Ya(t),g=e(g.line,g.ch,t?f.text.length+1:null).end;b=e(b.line,t?0:null,b.ch).start;t&&(g.top<b.top-2?(d(g.right,g.top,null,g.bottom),d(k,b.top,b.left,b.bottom)):d(g.right,g.top,b.left-
g.right,g.bottom));g.bottom<b.top&&d(k,g.bottom,null,b.top)}c.appendChild(p)}function Tb(a){if(a.state.focused){var b=a.display;clearInterval(b.blinker);var c=!0;b.cursorDiv.style.visibility="";0<a.options.cursorBlinkRate?b.blinker=setInterval(function(){b.cursorDiv.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate):0>a.options.cursorBlinkRate&&(b.cursorDiv.style.visibility="hidden")}}function Pa(a,b){a.doc.mode.startState&&a.doc.frontier<a.display.viewTo&&a.state.highlight.set(b,Oa(ob,
a))}function ob(a){var b=a.doc;b.frontier<b.first&&(b.frontier=b.first);if(!(b.frontier>=a.display.viewTo)){var c=+new Date+a.options.workTime,d=Ub(b.mode,ab(a,b.frontier)),e=[];b.iter(b.frontier,Math.min(b.first+b.size,a.display.viewTo+500),function(g){if(b.frontier>=a.display.viewFrom){var m=g.styles,p=je(a,g,d,!0);g.styles=p.styles;var t=g.styleClasses;(p=p.classes)?g.styleClasses=p:t&&(g.styleClasses=null);t=!m||m.length!=g.styles.length||t!=p&&(!t||!p||t.bgClass!=p.bgClass||t.textClass!=p.textClass);
for(p=0;!t&&p<m.length;++p)t=m[p]!=g.styles[p];t&&e.push(b.frontier);g.stateAfter=Ub(b.mode,d)}else Ad(a,g.text,d),g.stateAfter=0==b.frontier%5?Ub(b.mode,d):null;++b.frontier;if(+new Date>c)return Pa(a,a.options.workDelay),!0});e.length&&pb(a,function(){for(var b=0;b<e.length;b++)bb(a,e[b],"text")})}}function Qc(a,b,c){for(var d,e,g=a.doc,m=c?-1:b-(a.doc.mode.innerMode?1E3:100);b>m;--b){if(b<=g.first)return g.first;var p=G(g,b-1);if(p.stateAfter&&(!c||b<=g.frontier))return b;p=La(p.text,null,a.options.tabSize);
if(null==e||d>p)e=b-1,d=p}return e}function ab(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return!0;var g=Qc(a,b,c),m=g>d.first&&G(d,g-1).stateAfter,m=m?Ub(d.mode,m):sf(d.mode);d.iter(g,b,function(c){Ad(a,c.text,m);c.stateAfter=g==b-1||0==g%5||g>=e.viewFrom&&g<e.viewTo?Ub(d.mode,m):null;++g});c&&(d.frontier=g);return m}function Lb(a){return a.mover.offsetHeight-a.lineSpace.offsetHeight}function Sb(a){if(a.cachedPaddingH)return a.cachedPaddingH;var b=Wa(a.measure,F("pre","x")),b=window.getComputedStyle?
window.getComputedStyle(b):b.currentStyle,b={left:parseInt(b.paddingLeft),right:parseInt(b.paddingRight)};isNaN(b.left)||isNaN(b.right)||(a.cachedPaddingH=b);return b}function Aa(a){return de-a.display.nativeBarWidth}function ta(a){return a.display.scroller.clientWidth-Aa(a)-a.display.barWidth}function hb(a){return a.display.scroller.clientHeight-Aa(a)-a.display.barHeight}function Rc(a,b){if(b>=a.display.viewFrom&&b<a.display.viewTo)return a.display.view[jc(a,b)];var c=a.display.externalMeasured;
if(c&&b>=c.lineN&&b<c.lineN+c.size)return c}function E(a,b){var c=ca(b),d=Rc(a,c);d&&!d.text?d=null:d&&d.changes&&Ob(a,d,c,ic(a));if(!d){var e;e=Ya(b);d=ca(e);e=a.display.externalMeasured=new ke(a.doc,e,d);e.lineN=d;d=e.built=ge(a,e);e.text=d.pre;Wa(a.display.lineMeasure,d.pre);d=e}a:if(e=d,e.line==b)c={map:e.measure.map,cache:e.measure.cache};else{for(var g=0;g<e.rest.length;g++)if(e.rest[g]==b){c={map:e.measure.maps[g],cache:e.measure.caches[g]};break a}for(g=0;g<e.rest.length;g++)if(ca(e.rest[g])>
c){c={map:e.measure.maps[g],cache:e.measure.caches[g],before:!0};break a}c=void 0}return{line:b,view:d,rect:null,map:c.map,cache:c.cache,before:c.before,hasHeights:!1}}function mc(a,b,c,d,e){b.before&&(c=-1);var g=c+(d||"");if(b.cache.hasOwnProperty(g))a=b.cache[g];else{b.rect||(b.rect=b.view.text.getBoundingClientRect());if(!b.hasHeights){var m=b.view,p=b.rect,t=a.options.lineWrapping,k=t&&ta(a);if(!m.measure.heights||t&&m.measure.width!=k){var x=m.measure.heights=[];if(t)for(m.measure.width=k,m=
m.text.firstChild.getClientRects(),t=0;t<m.length-1;t++){var k=m[t],f=m[t+1];2<Math.abs(k.bottom-f.bottom)&&x.push((k.bottom+f.top)/2-p.top)}x.push(p.bottom-p.top)}b.hasHeights=!0}var p=d,x=b.map,ba,l,q,h;for(d=0;d<x.length;d+=3){var n=x[d],H=x[d+1];if(c<n)l=0,q=1,h="left";else if(c<H)l=c-n,q=l+1;else if(d==x.length-3||c==H&&x[d+3]>c)q=H-n,l=q-1,c>=H&&(h="right");if(null!=l){ba=x[d+2];n==H&&p==(ba.insertLeft?"left":"right")&&(h=p);if("left"==p&&0==l)for(;d&&x[d-2]==x[d-3]&&x[d-1].insertLeft;)ba=x[(d-=
3)+2],h="left";if("right"==p&&l==H-n)for(;d<x.length-3&&x[d+3]==x[d+4]&&!x[d+5].insertLeft;)ba=x[(d+=3)+2],h="right";break}}var u;if(3==ba.nodeType){for(d=0;4>d;d++){for(;l&&nc(b.line.text.charAt(n+l));)--l;for(;n+q<H&&nc(b.line.text.charAt(n+q));)++q;if(O&&9>V&&0==l&&q==H-n)u=ba.parentNode.getBoundingClientRect();else if(O&&a.options.lineWrapping){var r=Vb(ba,l,q).getClientRects();u=r.length?r["right"==p?r.length-1:0]:Bd}else u=Vb(ba,l,q).getBoundingClientRect()||Bd;if(u.left||u.right||0==l)break;
q=l;--l;h="right"}O&&11>V&&((c=!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI)||(null!=Cd?c=Cd:(q=Wa(a.display.measure,F("span","x")),c=q.getBoundingClientRect(),q=Vb(q,0,1).getBoundingClientRect(),c=Cd=1<Math.abs(c.left-q.left)),c=!c),c||(c=screen.logicalXDPI/screen.deviceXDPI,q=screen.logicalYDPI/screen.deviceYDPI,u={left:u.left*c,right:u.right*c,top:u.top*q,bottom:u.bottom*q}))}else 0<l&&(h=p="right"),u=a.options.lineWrapping&&1<(r=ba.getClientRects()).length?r["right"==
p?r.length-1:0]:ba.getBoundingClientRect();!(O&&9>V)||l||u&&(u.left||u.right)||(u=(ba=ba.parentNode.getClientRects()[0])?{left:ba.left,right:ba.left+ec(a.display),top:ba.top,bottom:ba.bottom}:Bd);ba=u.top-b.rect.top;l=u.bottom-b.rect.top;c=(ba+l)/2;q=b.view.measure.heights;for(d=0;d<q.length-1&&!(c<q[d]);d++);h={left:("right"==h?u.right:u.left)-b.rect.left,right:("left"==h?u.left:u.right)-b.rect.left,top:d?q[d-1]:0,bottom:q[d]};u.left||u.right||(h.bogus=!0);a.options.singleCursorHeightPerLine||(h.rtop=
ba,h.rbottom=l);a=h;a.bogus||(b.cache[g]=a)}return{left:a.left,right:a.right,top:e?a.rtop:a.top,bottom:e?a.rbottom:a.bottom}}function k(a){if(a.measure&&(a.measure.cache={},a.measure.heights=null,a.rest))for(var b=0;b<a.rest.length;b++)a.measure.caches[b]={}}function H(a){a.display.externalMeasure=null;yb(a.display.lineMeasure);for(var b=0;b<a.display.view.length;b++)k(a.display.view[b])}function Ea(a){H(a);a.display.cachedCharWidth=a.display.cachedTextHeight=a.display.cachedPaddingH=null;a.options.lineWrapping||
(a.display.maxLineChanged=!0);a.display.lineNumChars=null}function Y(a,b,c,d){if(b.widgets)for(var e=0;e<b.widgets.length;++e)if(b.widgets[e].above){var g=oc(b.widgets[e]);c.top+=g;c.bottom+=g}if("line"==d)return c;d||(d="local");b=Ra(b);b="local"==d?b+a.display.lineSpace.offsetTop:b-a.display.viewOffset;if("page"==d||"window"==d)a=a.display.lineSpace.getBoundingClientRect(),b+=a.top+("window"==d?0:window.pageYOffset||(document.documentElement||document.body).scrollTop),d=a.left+("window"==d?0:window.pageXOffset||
(document.documentElement||document.body).scrollLeft),c.left+=d,c.right+=d;c.top+=b;c.bottom+=b;return c}function le(a,b,c){if("div"==c)return b;var d=b.left;b=b.top;"page"==c?(d-=window.pageXOffset||(document.documentElement||document.body).scrollLeft,b-=window.pageYOffset||(document.documentElement||document.body).scrollTop):"local"!=c&&c||(c=a.display.sizer.getBoundingClientRect(),d+=c.left,b+=c.top);a=a.display.lineSpace.getBoundingClientRect();return{left:d-a.left,top:b-a.top}}function Pc(a,
b,c,d,e){d||(d=G(a.doc,b.line));var g=d;b=b.ch;d=mc(a,E(a,d),b,e);return Y(a,g,d,c)}function $a(a,b,c,d,e,g){function m(b,m){var p=mc(a,e,b,m?"right":"left",g);m?p.left=p.right:p.right=p.left;return Y(a,d,p,c)}function p(a,b){var c=t[b],d=c.level%2;a==Dd(c)&&b&&c.level<t[b-1].level?(c=t[--b],a=Ed(c)-(c.level%2?0:1),d=!0):a==Ed(c)&&b<t.length-1&&c.level<t[b+1].level&&(c=t[++b],a=Dd(c)-c.level%2,d=!1);return d&&a==c.to&&a>c.from?m(a-1):m(a,d)}d=d||G(a.doc,b.line);e||(e=E(a,d));var t=Xa(d);b=b.ch;if(!t)return m(b);
var k=Fd(t,b),k=p(b,k);null!=pc&&(k.other=p(b,pc));return k}function me(a,b){var c=0;b=J(a.doc,b);a.options.lineWrapping||(c=ec(a.display)*b.ch);var d=G(a.doc,b.line),e=Ra(d)+a.display.lineSpace.offsetTop;return{left:c,right:c,top:e,bottom:e+d.height}}function Sc(a,b,c,d){a=B(a,b);a.xRel=d;c&&(a.outside=!0);return a}function Gd(a,b,c){var d=a.doc;c+=a.display.viewOffset;if(0>c)return Sc(d.first,0,!0,-1);var e=Ab(d,c),g=d.first+d.size-1;if(e>g)return Sc(d.first+d.size-1,G(d,g).text.length,!0,1);0>
b&&(b=0);for(d=G(d,e);;)if(e=tf(a,d,e,b,c),g=(d=zb(d,!1))&&d.find(0,!0),d&&(e.ch>g.from.ch||e.ch==g.from.ch&&0<e.xRel))e=ca(d=g.to.line);else return e}function tf(a,b,c,d,e){function g(d){d=$a(a,B(c,d),"line",b,k);p=!0;if(m>d.bottom)return d.left-t;if(m<d.top)return d.left+t;p=!1;return d.left}var m=e-Ra(b),p=!1,t=2*a.display.wrapper.clientWidth,k=E(a,b),x=Xa(b),l=b.text.length;e=Tc(b);var f=Uc(b),q=g(e),h=p,u=g(f),n=p;if(d>u)return Sc(c,f,n,1);for(;;){if(x?f==e||f==Hd(b,e,1):1>=f-e){x=d<q||d-q<=
u-d?e:f;for(d-=x==e?q:u;nc(b.text.charAt(x));)++x;return Sc(c,x,x==e?h:n,-1>d?-1:1<d?1:0)}var H=Math.ceil(l/2),r=e+H;if(x)for(var r=e,Y=0;Y<H;++Y)r=Hd(b,r,1);Y=g(r);if(Y>d){f=r;u=Y;if(n=p)u+=1E3;l=H}else e=r,q=Y,h=p,l-=H}}function wb(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==Bb){Bb=F("pre");for(var b=0;49>b;++b)Bb.appendChild(document.createTextNode("x")),Bb.appendChild(F("br"));Bb.appendChild(document.createTextNode("x"))}Wa(a.measure,Bb);b=Bb.offsetHeight/50;3<b&&(a.cachedTextHeight=
b);yb(a.measure);return b||1}function ec(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=F("span","xxxxxxxxxx"),c=F("pre",[b]);Wa(a.measure,c);b=b.getBoundingClientRect();b=(b.right-b.left)/10;2<b&&(a.cachedCharWidth=b);return b||10}function tb(a){a.curOp={cm:a,viewChanged:!1,startHeight:a.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,
id:++uf};Wb?Wb.ops.push(a.curOp):a.curOp.ownsGroup=Wb={ops:[a.curOp],delayedCallbacks:[]}}function vb(a){if(a=a.curOp.ownsGroup)try{var b=a.delayedCallbacks,c=0;do{for(;c<b.length;c++)b[c]();for(var d=0;d<a.ops.length;d++){var e=a.ops[d];if(e.cursorActivityHandlers)for(;e.cursorActivityCalled<e.cursorActivityHandlers.length;)e.cursorActivityHandlers[e.cursorActivityCalled++](e.cm)}}while(c<b.length)}finally{Wb=null;for(b=0;b<a.ops.length;b++)a.ops[b].cm.curOp=null;a=a.ops;for(b=0;b<a.length;b++){var e=
a[b],c=e.cm,g=d=c.display;!g.scrollbarsClipped&&g.scroller.offsetWidth&&(g.nativeBarWidth=g.scroller.offsetWidth-g.scroller.clientWidth,g.heightForcer.style.height=Aa(c)+"px",g.sizer.style.marginBottom=-g.nativeBarWidth+"px",g.sizer.style.borderRightWidth=Aa(c)+"px",g.scrollbarsClipped=!0);e.updateMaxLine&&h(c);e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<d.viewFrom||e.scrollToPos.to.line>=d.viewTo)||d.maxLineChanged&&c.options.lineWrapping;
e.update=e.mustUpdate&&new Za(c,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}for(b=0;b<a.length;b++)e=a[b],e.updatedDisplay=e.mustUpdate&&ua(e.cm,e.update);for(b=0;b<a.length;b++)if(e=a[b],c=e.cm,d=c.display,e.updatedDisplay&&da(c),e.barMeasure=l(c),d.maxLineChanged&&!c.options.lineWrapping&&(g=void 0,g=d.maxLine.text.length,g=mc(c,E(c,d.maxLine),g,void 0),e.adjustWidthTo=g.left+3,c.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(d.scroller.clientWidth,
d.sizer.offsetLeft+e.adjustWidthTo+Aa(c)+c.display.barWidth),e.maxScrollLeft=Math.max(0,d.sizer.offsetLeft+e.adjustWidthTo-ta(c))),e.updatedDisplay||e.selectionChanged)e.newSelectionNodes=Nc(c);for(b=0;b<a.length;b++)e=a[b],c=e.cm,null!=e.adjustWidthTo&&(c.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<c.doc.scrollLeft&&Mb(c,Math.min(c.display.scroller.scrollLeft,e.maxScrollLeft),!0),c.display.maxLineChanged=!1),e.newSelectionNodes&&Oc(c,e.newSelectionNodes),e.updatedDisplay&&Nb(c,
e.barMeasure),(e.updatedDisplay||e.startHeight!=c.doc.height)&&C(c,e.barMeasure),e.selectionChanged&&Tb(c),c.state.focused&&e.updateInput&&Da(c,e.typing);for(b=0;b<a.length;b++){e=a[b];c=e.cm;d=c.display;g=c.doc;e.updatedDisplay&&aa(c,e.update);null==d.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(d.wheelStartX=d.wheelStartY=null);null==e.scrollTop||d.scroller.scrollTop==e.scrollTop&&!e.forceScroll||(g.scrollTop=Math.max(0,Math.min(d.scroller.scrollHeight-d.scroller.clientHeight,
e.scrollTop)),d.scrollbars.setScrollTop(g.scrollTop),d.scroller.scrollTop=g.scrollTop);null==e.scrollLeft||d.scroller.scrollLeft==e.scrollLeft&&!e.forceScroll||(g.scrollLeft=Math.max(0,Math.min(d.scroller.scrollWidth-ta(c),e.scrollLeft)),d.scrollbars.setScrollLeft(g.scrollLeft),d.scroller.scrollLeft=g.scrollLeft,ja(c));if(e.scrollToPos){var m=void 0,p=J(g,e.scrollToPos.from),m=J(g,e.scrollToPos.to),t=e.scrollToPos.margin;null==t&&(t=0);for(var k=0;5>k;k++){var x=!1,f=$a(c,p),q=m&&m!=p?$a(c,m):f,q=
Vc(c,Math.min(f.left,q.left),Math.min(f.top,q.top)-t,Math.max(f.left,q.left),Math.max(f.bottom,q.bottom)+t),u=c.doc.scrollTop,n=c.doc.scrollLeft;null!=q.scrollTop&&(gc(c,q.scrollTop),1<Math.abs(c.doc.scrollTop-u)&&(x=!0));null!=q.scrollLeft&&(Mb(c,q.scrollLeft),1<Math.abs(c.doc.scrollLeft-n)&&(x=!0));if(!x)break}m=f;e.scrollToPos.isCursor&&c.state.focused&&(Ma(c,"scrollCursorIntoView")||(t=c.display,k=t.sizer.getBoundingClientRect(),p=null,0>m.top+k.top?p=!0:m.bottom+k.top>(window.innerHeight||document.documentElement.clientHeight)&&
(p=!1),null==p||vf||(m=F("div","\u200b",null,"position: absolute; top: "+(m.top-t.viewOffset-c.display.lineSpace.offsetTop)+"px; height: "+(m.bottom-m.top+Aa(c)+t.barHeight)+"px; left: "+m.left+"px; width: 2px;"),c.display.lineSpace.appendChild(m),m.scrollIntoView(p),c.display.lineSpace.removeChild(m))))}p=e.maybeHiddenMarkers;m=e.maybeUnhiddenMarkers;if(p)for(t=0;t<p.length;++t)p[t].lines.length||ga(p[t],"hide");if(m)for(t=0;t<m.length;++t)m[t].lines.length&&ga(m[t],"unhide");d.wrapper.offsetHeight&&
(g.scrollTop=c.display.scroller.scrollTop);e.changeObjs&&ga(c,"changes",c,e.changeObjs)}}}function pb(a,b){if(a.curOp)return b();tb(a);try{return b()}finally{vb(a)}}function ha(a,b){return function(){if(a.curOp)return b.apply(a,arguments);tb(a);try{return b.apply(a,arguments)}finally{vb(a)}}}function na(a){return function(){if(this.curOp)return a.apply(this,arguments);tb(this);try{return a.apply(this,arguments)}finally{vb(this)}}}function qa(a){return function(){var b=this.cm;if(!b||b.curOp)return a.apply(this,
arguments);tb(b);try{return a.apply(this,arguments)}finally{vb(b)}}}function ke(a,b,c){for(var d=this.line=b,e;d=zb(d,!1);)d=d.find(1,!0).line,(e||(e=[])).push(d);this.size=(this.rest=e)?ca(X(this.rest))-c+1:1;this.node=this.text=null;this.hidden=xb(a,b)}function Hc(a,b,c){var d=[],e;for(e=b;e<c;)b=new ke(a.doc,G(a.doc,e),e),e+=b.size,d.push(b);return d}function za(a,b,c,d){null==b&&(b=a.doc.first);null==c&&(c=a.doc.first+a.doc.size);d||(d=0);var e=a.display;d&&c<e.viewTo&&(null==e.updateLineNumbers||
e.updateLineNumbers>b)&&(e.updateLineNumbers=b);a.curOp.viewChanged=!0;if(b>=e.viewTo)gb&&xd(a.doc,b)<e.viewTo&&fb(a);else if(c<=e.viewFrom)gb&&fe(a.doc,c+d)>e.viewFrom?fb(a):(e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&c>=e.viewTo)fb(a);else if(b<=e.viewFrom){var g=Wc(a,c,c+d,1);g?(e.view=e.view.slice(g.index),e.viewFrom=g.lineN,e.viewTo+=d):fb(a)}else if(c>=e.viewTo)(g=Wc(a,b,b,-1))?(e.view=e.view.slice(0,g.index),e.viewTo=g.lineN):fb(a);else{var g=Wc(a,b,b,-1),m=Wc(a,c,c+d,1);g&&m?(e.view=
e.view.slice(0,g.index).concat(Hc(a,g.lineN,m.lineN)).concat(e.view.slice(m.index)),e.viewTo+=d):fb(a)}if(a=e.externalMeasured)c<a.lineN?a.lineN+=d:b<a.lineN+a.size&&(e.externalMeasured=null)}function bb(a,b,c){a.curOp.viewChanged=!0;var d=a.display,e=a.display.externalMeasured;e&&b>=e.lineN&&b<e.lineN+e.size&&(d.externalMeasured=null);b<d.viewFrom||b>=d.viewTo||(a=d.view[jc(a,b)],null!=a.node&&(a=a.changes||(a.changes=[]),-1==ka(a,c)&&a.push(c)))}function fb(a){a.display.viewFrom=a.display.viewTo=
a.doc.first;a.display.view=[];a.display.viewOffset=0}function jc(a,b){if(b>=a.display.viewTo)return null;b-=a.display.viewFrom;if(0>b)return null;for(var c=a.display.view,d=0;d<c.length;d++)if(b-=c[d].size,0>b)return d}function Wc(a,b,c,d){var e=jc(a,b),g=a.display.view;if(!gb||c==a.doc.first+a.doc.size)return{index:e,lineN:c};for(var m=0,p=a.display.viewFrom;m<e;m++)p+=g[m].size;if(p!=b){if(0<d){if(e==g.length-1)return null;b=p+g[e].size-b;e++}else b=p-b;c+=b}for(;xd(a.doc,c)!=c;){if(e==(0>d?0:g.length-
1))return null;c+=d*g[e-(0>d?1:0)].size;e+=d}return{index:e,lineN:c}}function ee(a){a=a.display.view;for(var b=0,c=0;c<a.length;c++){var d=a[c];d.hidden||d.node&&!d.changes||++b}return b}function Xc(a){a.display.pollingFast||a.display.poll.set(a.options.pollInterval,function(){Yc(a);a.state.focused&&Xc(a)})}function Zc(a){function b(){Yc(a)||c?(a.display.pollingFast=!1,Xc(a)):(c=!0,a.display.poll.set(60,b))}var c=!1;a.display.pollingFast=!0;a.display.poll.set(20,b)}function Yc(a){var b=a.display.input,
c=a.display.prevInput,d=a.doc;if(!a.state.focused||wf(b)&&!c||$c(a)||a.options.disableInput||a.state.keySeq)return!1;a.state.pasteIncoming&&a.state.fakedLastChar&&(b.value=b.value.substring(0,b.value.length-1),a.state.fakedLastChar=!1);var e=b.value;if(e==c&&!a.somethingSelected())return!1;if(O&&9<=V&&a.display.inputHasSelection===e||Ha&&/[\uf700-\uf7ff]/.test(e))return Da(a),!1;var g=!a.curOp;g&&tb(a);a.display.shift=!1;8203!=e.charCodeAt(0)||d.sel!=a.display.selForContextMenu||c||(c="\u200b");for(var m=
0,p=Math.min(c.length,e.length);m<p&&c.charCodeAt(m)==e.charCodeAt(m);)++m;var p=e.slice(m),t=Cb(p),k=null;a.state.pasteIncoming&&1<d.sel.ranges.length&&(Db&&Db.join("\n")==p?k=0==d.sel.ranges.length%Db.length&&Xb(Db,Cb):t.length==d.sel.ranges.length&&(k=Xb(t,function(a){return[a]})));for(var x=d.sel.ranges.length-1;0<=x;x--){var f=d.sel.ranges[x],l=f.from(),q=f.to();m<c.length?l=B(l.line,l.ch-(c.length-m)):a.state.overwrite&&f.empty()&&!a.state.pasteIncoming&&(q=B(q.line,Math.min(G(d,q.line).text.length,
q.ch+X(t).length)));var h=a.curOp.updateInput,l={from:l,to:q,text:k?k[x%k.length]:t,origin:a.state.pasteIncoming?"paste":a.state.cutIncoming?"cut":"+input"};Yb(a.doc,l);la(a,"inputRead",a,l);if(p&&!a.state.pasteIncoming&&a.options.electricChars&&a.options.smartIndent&&100>f.head.ch&&(!x||d.sel.ranges[x-1].head.line!=f.head.line))if(f=a.getModeAt(f.head),l=qb(l),f.electricChars)for(q=0;q<f.electricChars.length;q++){if(-1<p.indexOf(f.electricChars.charAt(q))){qc(a,l.line,"smart");break}}else f.electricInput&&
f.electricInput.test(G(d,l.line).text.slice(0,l.ch))&&qc(a,l.line,"smart")}Rb(a);a.curOp.updateInput=h;a.curOp.typing=!0;1E3<e.length||-1<e.indexOf("\n")?b.value=a.display.prevInput="":a.display.prevInput=e;g&&vb(a);a.state.pasteIncoming=a.state.cutIncoming=!1;return!0}function Da(a,b){if(!a.display.contextMenuPending){var c,d,e=a.doc;a.somethingSelected()?(a.display.prevInput="",c=e.sel.primary(),d=(c=ne&&(100<c.to().line-c.from().line||1E3<(d=a.getSelection()).length))?"-":d||a.getSelection(),a.display.input.value=
d,a.state.focused&&rc(a.display.input),O&&9<=V&&(a.display.inputHasSelection=d)):b||(a.display.prevInput=a.display.input.value="",O&&9<=V&&(a.display.inputHasSelection=null));a.display.inaccurateSelection=c}}function wa(a){"nocursor"==a.options.readOnly||td&&eb()==a.display.input||a.display.input.focus()}function Id(a){a.state.focused||(wa(a),ud(a))}function $c(a){return a.options.readOnly||a.doc.cantEdit}function pf(a){function b(b){Ma(a,b)||Jd(b)}function c(b){if(a.somethingSelected())Db=a.getSelections(),
d.inaccurateSelection&&(d.prevInput="",d.inaccurateSelection=!1,d.input.value=Db.join("\n"),rc(d.input));else{for(var c=[],m=[],p=0;p<a.doc.sel.ranges.length;p++){var t=a.doc.sel.ranges[p].head.line,t={anchor:B(t,0),head:B(t+1,0)};m.push(t);c.push(a.getRange(t.anchor,t.head))}"cut"==b.type?a.setSelections(m,null,lb):(d.prevInput="",d.input.value=c.join("\n"),rc(d.input));Db=c}"cut"==b.type&&(a.state.cutIncoming=!0)}var d=a.display;M(d.scroller,"mousedown",ha(a,oe));O&&11>V?M(d.scroller,"dblclick",
ha(a,function(b){if(!Ma(a,b)){var c=Zb(a,b);!c||Kd(a,b,"gutterClick",!0,la)||Eb(a.display,b)||(ra(b),b=a.findWordAt(c),xa(a.doc,b.anchor,b.head))}})):M(d.scroller,"dblclick",function(b){Ma(a,b)||ra(b)});M(d.lineSpace,"selectstart",function(a){Eb(d,a)||ra(a)});Ld||M(d.scroller,"contextmenu",function(b){pe(a,b)});M(d.scroller,"scroll",function(){d.scroller.clientHeight&&(gc(a,d.scroller.scrollTop),Mb(a,d.scroller.scrollLeft,!0),ga(a,"scroll",a))});M(d.scroller,"mousewheel",function(b){qe(a,b)});M(d.scroller,
"DOMMouseScroll",function(b){qe(a,b)});M(d.wrapper,"scroll",function(){d.wrapper.scrollTop=d.wrapper.scrollLeft=0});M(d.input,"keyup",function(b){re.call(a,b)});M(d.input,"input",function(){O&&9<=V&&a.display.inputHasSelection&&(a.display.inputHasSelection=null);Yc(a)});M(d.input,"keydown",ha(a,se));M(d.input,"keypress",ha(a,te));M(d.input,"focus",Oa(ud,a));M(d.input,"blur",Oa(Gc,a));a.options.dragDrop&&(M(d.scroller,"dragstart",function(b){if(O&&(!a.state.draggingText||100>+new Date-ue))Jd(b);else if(!Ma(a,
b)&&!Eb(a.display,b)&&(b.dataTransfer.setData("Text",a.getSelection()),b.dataTransfer.setDragImage&&!ve)){var c=F("img",null,null,"position: fixed; left: 0; top: 0;");c.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";Na&&(c.width=c.height=1,a.display.wrapper.appendChild(c),c._top=c.offsetTop);b.dataTransfer.setDragImage(c,0,0);Na&&c.parentNode.removeChild(c)}}),M(d.scroller,"dragenter",b),M(d.scroller,"dragover",b),M(d.scroller,"drop",ha(a,xf)));M(d.scroller,"paste",
function(b){Eb(d,b)||(a.state.pasteIncoming=!0,wa(a),Zc(a))});M(d.input,"paste",function(){if(ia&&!a.state.fakedLastChar&&!(200>new Date-a.state.lastMiddleDown)){var b=d.input.selectionStart,c=d.input.selectionEnd;d.input.value+="$";d.input.selectionEnd=c;d.input.selectionStart=b;a.state.fakedLastChar=!0}a.state.pasteIncoming=!0;Zc(a)});M(d.input,"cut",c);M(d.input,"copy",c);wd&&M(d.sizer,"mouseup",function(){eb()==d.input&&d.input.blur();wa(a)})}function yf(a){var b=a.display;if(b.lastWrapHeight!=
b.wrapper.clientHeight||b.lastWrapWidth!=b.wrapper.clientWidth)b.cachedCharWidth=b.cachedTextHeight=b.cachedPaddingH=null,b.scrollbarsClipped=!1,a.setSize()}function Eb(a,b){for(var c=b.target||b.srcElement;c!=a.wrapper;c=c.parentNode)if(!c||"true"==c.getAttribute("cm-ignore-events")||c.parentNode==a.sizer&&c!=a.mover)return!0}function Zb(a,b,c,d){var e=a.display;if(!c&&"true"==(b.target||b.srcElement).getAttribute("not-content"))return null;var g,m;c=e.lineSpace.getBoundingClientRect();try{g=b.clientX-
c.left,m=b.clientY-c.top}catch(p){return null}b=Gd(a,g,m);var t;d&&1==b.xRel&&(t=G(a.doc,b.line).text).length==b.ch&&(d=La(t,t.length,a.options.tabSize)-t.length,b=B(b.line,Math.max(0,Math.round((g-Sb(a.display).left)/ec(a.display))-d)));return b}function oe(a){if(!Ma(this,a)){var b=this.display;b.shift=a.shiftKey;if(Eb(b,a))ia||(b.scroller.draggable=!1,setTimeout(function(){b.scroller.draggable=!0},100));else if(!Kd(this,a,"gutterClick",!0,la)){var c=Zb(this,a);window.focus();switch(we(a)){case 1:c?
zf(this,a,c):(a.target||a.srcElement)==b.scroller&&ra(a);break;case 2:ia&&(this.state.lastMiddleDown=+new Date);c&&xa(this.doc,c);setTimeout(Oa(wa,this),20);ra(a);break;case 3:Ld&&pe(this,a)}}}}function zf(a,b,c){setTimeout(Oa(Id,a),0);var d=+new Date,e;ad&&ad.time>d-400&&0==N(ad.pos,c)?e="triple":bd&&bd.time>d-400&&0==N(bd.pos,c)?(e="double",ad={time:d,pos:c}):(e="single",bd={time:d,pos:c});var d=a.doc.sel,g=Ha?b.metaKey:b.ctrlKey,m;a.options.dragDrop&&Af&&!$c(a)&&"single"==e&&-1<(m=d.contains(c))&&
!d.ranges[m].empty()?Bf(a,b,c,g):Cf(a,b,c,e,g)}function Bf(a,b,c,d){var e=a.display,g=ha(a,function(m){ia&&(e.scroller.draggable=!1);a.state.draggingText=!1;cb(document,"mouseup",g);cb(e.scroller,"drop",g);10>Math.abs(b.clientX-m.clientX)+Math.abs(b.clientY-m.clientY)&&(ra(m),d||xa(a.doc,c),wa(a),O&&9==V&&setTimeout(function(){document.body.focus();wa(a)},20))});ia&&(e.scroller.draggable=!0);a.state.draggingText=g;e.scroller.dragDrop&&e.scroller.dragDrop();M(document,"mouseup",g);M(e.scroller,"drop",
g)}function Cf(a,b,c,d,e){function g(b){if(0!=N(h,b))if(h=b,"rect"==d){for(var e=[],g=a.options.tabSize,m=La(G(k,c.line).text,c.ch,g),p=La(G(k,b.line).text,b.ch,g),t=Math.min(m,p),m=Math.max(m,p),p=Math.min(c.line,b.line),q=Math.min(a.lastLine(),Math.max(c.line,b.line));p<=q;p++){var n=G(k,p).text,H=xe(n,t,g);t==m?e.push(new S(B(p,H),B(p,H))):n.length>H&&e.push(new S(B(p,H),B(p,xe(n,m,g))))}e.length||e.push(new S(c,c));fa(k,va(l.ranges.slice(0,f).concat(e),f),{origin:"*mouse",scroll:!1});a.scrollIntoView(b)}else e=
x,g=e.anchor,t=b,"single"!=d&&(b="double"==d?a.findWordAt(b):new S(B(b.line,0),J(k,B(b.line+1,0))),0<N(b.anchor,g)?(t=b.head,g=u(e.from(),b.anchor)):(t=b.anchor,g=ma(e.to(),b.head))),e=l.ranges.slice(0),e[f]=new S(J(k,g),t),fa(k,va(e,f),Md)}function m(b){var c=++H,e=Zb(a,b,!0,"rect"==d);if(e)if(0!=N(e,h)){Id(a);g(e);var p=R(t,k);(e.line>=p.to||e.line<p.from)&&setTimeout(ha(a,function(){H==c&&m(b)}),150)}else{var x=b.clientY<n.top?-20:b.clientY>n.bottom?20:0;x&&setTimeout(ha(a,function(){H==c&&(t.scroller.scrollTop+=
x,m(b))}),50)}}function p(b){H=Infinity;ra(b);wa(a);cb(document,"mousemove",r);cb(document,"mouseup",Y);k.history.lastSelOrigin=null}var t=a.display,k=a.doc;ra(b);var x,f,l=k.sel,q=l.ranges;e&&!b.shiftKey?(f=k.sel.contains(c),x=-1<f?q[f]:new S(c,c)):x=k.sel.primary();b.altKey?(d="rect",e||(x=new S(c,c)),c=Zb(a,b,!0,!0),f=-1):"double"==d?(b=a.findWordAt(c),x=a.display.shift||k.extend?jb(k,x,b.anchor,b.head):b):"triple"==d?(b=new S(B(c.line,0),J(k,B(c.line+1,0))),x=a.display.shift||k.extend?jb(k,x,
b.anchor,b.head):b):x=jb(k,x,c);e?-1==f?(f=q.length,fa(k,va(q.concat([x]),f),{scroll:!1,origin:"*mouse"})):1<q.length&&q[f].empty()&&"single"==d?(fa(k,va(q.slice(0,f).concat(q.slice(f+1)),0)),l=k.sel):kc(k,f,x,Md):(f=0,fa(k,new Ja([x],0),Md),l=k.sel);var h=c,n=t.wrapper.getBoundingClientRect(),H=0,r=ha(a,function(a){we(a)?m(a):p(a)}),Y=ha(a,p);M(document,"mousemove",r);M(document,"mouseup",Y)}function Kd(a,b,c,d,e){try{var g=b.clientX,m=b.clientY}catch(p){return!1}if(g>=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;
d&&ra(b);d=a.display;var t=d.lineDiv.getBoundingClientRect();if(m>t.bottom||!Ka(a,c))return Nd(b);m-=t.top-d.viewOffset;for(t=0;t<a.options.gutters.length;++t){var k=d.gutters.childNodes[t];if(k&&k.getBoundingClientRect().right>=g)return g=Ab(a.doc,m),e(a,c,a,g,a.options.gutters[t],b),Nd(b)}}function xf(a){var b=this;if(!Ma(b,a)&&!Eb(b.display,a)){ra(a);O&&(ue=+new Date);var c=Zb(b,a,!0),d=a.dataTransfer.files;if(c&&!$c(b))if(d&&d.length&&window.FileReader&&window.File){var e=d.length,g=Array(e),
m=0;a=function(a,d){var p=new FileReader;p.onload=ha(b,function(){g[d]=p.result;if(++m==e){c=J(b.doc,c);var a={from:c,to:c,text:Cb(g.join("\n")),origin:"paste"};Yb(b.doc,a);kb(b.doc,Ua(c,qb(a)))}});p.readAsText(a)};for(var p=0;p<e;++p)a(d[p],p)}else if(b.state.draggingText&&-1<b.doc.sel.contains(c))b.state.draggingText(a),setTimeout(Oa(wa,b),20);else try{if(g=a.dataTransfer.getData("Text")){if(b.state.draggingText&&(Ha?!a.metaKey:!a.ctrlKey))var t=b.listSelections();Qb(b.doc,Ua(c,c));if(t)for(p=0;p<
t.length;++p)cd(b.doc,"",t[p].anchor,t[p].head,"drag");b.replaceSelection(g,"around","paste");wa(b)}}catch(k){}}}function gc(a,b){2>Math.abs(a.doc.scrollTop-b)||(a.doc.scrollTop=b,sc||Ga(a,{top:b}),a.display.scroller.scrollTop!=b&&(a.display.scroller.scrollTop=b),a.display.scrollbars.setScrollTop(b),sc&&Ga(a),Pa(a,100))}function Mb(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,ja(a),a.display.scroller.scrollLeft!=
b&&(a.display.scroller.scrollLeft=b),a.display.scrollbars.setScrollLeft(b))}function qe(a,b){var c=ye(b),d=c.x,c=c.y,e=a.display,g=e.scroller;if(d&&g.scrollWidth>g.clientWidth||c&&g.scrollHeight>g.clientHeight){if(c&&Ha&&ia){var m=b.target,p=e.view;a:for(;m!=g;m=m.parentNode)for(var t=0;t<p.length;t++)if(p[t].node==m){a.display.currentWheelTarget=m;break a}}!d||sc||Na||null==ya?(c&&null!=ya&&(m=c*ya,p=a.doc.scrollTop,t=p+e.wrapper.clientHeight,0>m?p=Math.max(0,p+m-50):t=Math.min(a.doc.height,t+m+
50),Ga(a,{top:p,bottom:t})),20>dd&&(null==e.wheelStartX?(e.wheelStartX=g.scrollLeft,e.wheelStartY=g.scrollTop,e.wheelDX=d,e.wheelDY=c,setTimeout(function(){if(null!=e.wheelStartX){var a=g.scrollLeft-e.wheelStartX,b=g.scrollTop-e.wheelStartY,a=b&&e.wheelDY&&b/e.wheelDY||a&&e.wheelDX&&a/e.wheelDX;e.wheelStartX=e.wheelStartY=null;a&&(ya=(ya*dd+a)/(dd+1),++dd)}},200)):(e.wheelDX+=d,e.wheelDY+=c))):(c&&gc(a,Math.max(0,Math.min(g.scrollTop+c*ya,g.scrollHeight-g.clientHeight))),Mb(a,Math.max(0,Math.min(g.scrollLeft+
d*ya,g.scrollWidth-g.clientWidth))),ra(b),e.wheelStartX=null)}}function ed(a,b,c){if("string"==typeof b&&(b=fd[b],!b))return!1;a.display.pollingFast&&Yc(a)&&(a.display.pollingFast=!1);var d=a.display.shift,e=!1;try{$c(a)&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=ze}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function Df(a,b,c){for(var d=0;d<a.state.keyMaps.length;d++){var e=tc(b,a.state.keyMaps[d],c,a);if(e)return e}return a.options.extraKeys&&tc(b,a.options.extraKeys,
c,a)||tc(b,a.options.keyMap,c,a)}function gd(a,b,c,d){var e=a.state.keySeq;if(e){if(Ef(b))return"handled";Ff.set(50,function(){a.state.keySeq==e&&(a.state.keySeq=null,Da(a))});b=e+" "+b}d=Df(a,b,d);"multi"==d&&(a.state.keySeq=b);"handled"==d&&la(a,"keyHandled",a,b,c);if("handled"==d||"multi"==d)ra(c),Tb(a);return e&&!d&&/\'$/.test(b)?(ra(c),!0):!!d}function Ae(a,b){var c=Gf(b,!0);return c?b.shiftKey&&!a.state.keySeq?gd(a,"Shift-"+c,b,function(b){return ed(a,b,!0)})||gd(a,c,b,function(b){if("string"==
typeof b?/^go[A-Z]/.test(b):b.motion)return ed(a,b)}):gd(a,c,b,function(b){return ed(a,b)}):!1}function Hf(a,b,c){return gd(a,"'"+c+"'",b,function(b){return ed(a,b,!0)})}function se(a){Id(this);if(!Ma(this,a)){O&&11>V&&27==a.keyCode&&(a.returnValue=!1);var b=a.keyCode;this.display.shift=16==b||a.shiftKey;var c=Ae(this,a);Na&&(Od=c?b:null,!c&&88==b&&!ne&&(Ha?a.metaKey:a.ctrlKey)&&this.replaceSelection("",null,"cut"));18!=b||/\bCodeMirror-crosshair\b/.test(this.display.lineDiv.className)||If(this)}}
function If(a){function b(a){18!=a.keyCode&&a.altKey||(fc(c,"CodeMirror-crosshair"),cb(document,"keyup",b),cb(document,"mouseover",b))}var c=a.display.lineDiv;hc(c,"CodeMirror-crosshair");M(document,"keyup",b);M(document,"mouseover",b)}function re(a){16==a.keyCode&&(this.doc.sel.shift=!1);Ma(this,a)}function te(a){if(!(Ma(this,a)||a.ctrlKey&&!a.altKey||Ha&&a.metaKey)){var b=a.keyCode,c=a.charCode;Na&&b==Od?(Od=null,ra(a)):(Na&&(!a.which||10>a.which)||wd)&&Ae(this,a)||(b=String.fromCharCode(null==
c?b:c),Hf(this,a,b)||(O&&9<=V&&(this.display.inputHasSelection=null),Zc(this)))}}function ud(a){"nocursor"!=a.options.readOnly&&(a.state.focused||(ga(a,"focus",a),a.state.focused=!0,hc(a.display.wrapper,"CodeMirror-focused"),a.curOp||a.display.selForContextMenu==a.doc.sel||(Da(a),ia&&setTimeout(Oa(Da,a,!0),0))),Xc(a),Tb(a))}function Gc(a){a.state.focused&&(ga(a,"blur",a),a.state.focused=!1,fc(a.display.wrapper,"CodeMirror-focused"));clearInterval(a.display.blinker);setTimeout(function(){a.state.focused||
(a.display.shift=!1)},150)}function pe(a,b){function c(){if(null!=e.input.selectionStart){var b=a.somethingSelected(),c=e.input.value="\u200b"+(b?e.input.value:"");e.prevInput=b?"":"\u200b";e.input.selectionStart=1;e.input.selectionEnd=c.length;e.selForContextMenu=a.doc.sel}}function d(){e.contextMenuPending=!1;e.inputDiv.style.position="relative";e.input.style.cssText=p;O&&9>V&&e.scrollbars.setScrollTop(e.scroller.scrollTop=m);Xc(a);if(null!=e.input.selectionStart){(!O||O&&9>V)&&c();var b=0,d=function(){e.selForContextMenu==
a.doc.sel&&0==e.input.selectionStart?ha(a,fd.selectAll)(a):10>b++?e.detectingSelectAll=setTimeout(d,500):Da(a)};e.detectingSelectAll=setTimeout(d,200)}}if(!Ma(a,b,"contextmenu")){var e=a.display;if(!Eb(e,b)&&!Jf(a,b)){var g=Zb(a,b),m=e.scroller.scrollTop;if(g&&!Na){a.options.resetSelectionOnContextMenu&&-1==a.doc.sel.contains(g)&&ha(a,fa)(a.doc,Ua(g),lb);var p=e.input.style.cssText;e.inputDiv.style.position="absolute";e.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(b.clientY-
5)+"px; left: "+(b.clientX-5)+"px; z-index: 1000; background: "+(O?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";if(ia)var t=window.scrollY;wa(a);ia&&window.scrollTo(null,t);Da(a);a.somethingSelected()||(e.input.value=e.prevInput=" ");e.contextMenuPending=!0;e.selForContextMenu=a.doc.sel;clearTimeout(e.detectingSelectAll);O&&9<=V&&c();if(Ld){Jd(b);var k=function(){cb(window,"mouseup",k);setTimeout(d,
20)};M(window,"mouseup",k)}else setTimeout(d,50)}}}}function Jf(a,b){return Ka(a,"gutterContextMenu")?Kd(a,b,"gutterContextMenu",!1,ga):!1}function Be(a,b){if(0>N(a,b.from))return a;if(0>=N(a,b.to))return qb(b);var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;a.line==b.to.line&&(d+=qb(b).ch-b.to.ch);return B(c,d)}function Pd(a,b){for(var c=[],d=0;d<a.sel.ranges.length;d++){var e=a.sel.ranges[d];c.push(new S(Be(e.anchor,b),Be(e.head,b)))}return va(c,a.sel.primIndex)}function Ce(a,b,c){return a.line==
b.line?B(c.line,a.ch-b.ch+c.ch):B(c.line+(a.line-b.line),a.ch)}function De(a,b,c){b={canceled:!1,from:b.from,to:b.to,text:b.text,origin:b.origin,cancel:function(){this.canceled=!0}};c&&(b.update=function(b,c,g,m){b&&(this.from=J(a,b));c&&(this.to=J(a,c));g&&(this.text=g);void 0!==m&&(this.origin=m)});ga(a,"beforeChange",a,b);a.cm&&ga(a.cm,"beforeChange",a.cm,b);return b.canceled?null:{from:b.from,to:b.to,text:b.text,origin:b.origin}}function Yb(a,b,c){if(a.cm){if(!a.cm.curOp)return ha(a.cm,Yb)(a,
b,c);if(a.cm.state.suppressEdits)return}if(Ka(a,"beforeChange")||a.cm&&Ka(a.cm,"beforeChange"))if(b=De(a,b,!0),!b)return;if(c=Ee&&!c&&Kf(a,b.from,b.to))for(var d=c.length-1;0<=d;--d)Fe(a,{from:c[d].from,to:c[d].to,text:d?[""]:b.text});else Fe(a,b)}function Fe(a,b){if(1!=b.text.length||""!=b.text[0]||0!=N(b.from,b.to)){var c=Pd(a,b);Ge(a,b,c,a.cm?a.cm.curOp.id:NaN);uc(a,b,c,Qd(a,b));var d=[];Fb(a,function(a,c){c||-1!=ka(d,a.history)||(He(a.history,b),d.push(a.history));uc(a,b,null,Qd(a,b))})}}function hd(a,
b,c){if(!a.cm||!a.cm.state.suppressEdits){for(var d=a.history,e,g=a.sel,m="undo"==b?d.done:d.undone,p="undo"==b?d.undone:d.done,t=0;t<m.length&&(e=m[t],c?!e.ranges||e.equals(a.sel):e.ranges);t++);if(t!=m.length){for(d.lastOrigin=d.lastSelOrigin=null;;)if(e=m.pop(),e.ranges){Kc(e,p);if(c&&!e.equals(a.sel)){fa(a,e,{clearRedo:!1});return}g=e}else break;c=[];Kc(g,p);p.push({changes:c,generation:d.generation});d.generation=e.generation||++d.maxGeneration;d=Ka(a,"beforeChange")||a.cm&&Ka(a.cm,"beforeChange");
for(t=e.changes.length-1;0<=t;--t){var k=e.changes[t];k.origin=b;if(d&&!De(a,k,!1)){m.length=0;break}c.push(Rd(a,k));g=t?Pd(a,k):X(m);uc(a,k,g,Ie(a,k));!t&&a.cm&&a.cm.scrollIntoView({from:k.from,to:qb(k)});var x=[];Fb(a,function(a,b){b||-1!=ka(x,a.history)||(He(a.history,k),x.push(a.history));uc(a,k,null,Ie(a,k))})}}}}function Je(a,b){if(0!=b&&(a.first+=b,a.sel=new Ja(Xb(a.sel.ranges,function(a){return new S(B(a.anchor.line+b,a.anchor.ch),B(a.head.line+b,a.head.ch))}),a.sel.primIndex),a.cm)){za(a.cm,
a.first,a.first-b,b);for(var c=a.cm.display,d=c.viewFrom;d<c.viewTo;d++)bb(a.cm,d,"gutter")}}function uc(a,b,c,d){if(a.cm&&!a.cm.curOp)return ha(a.cm,uc)(a,b,c,d);if(b.to.line<a.first)Je(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);Je(a,e);b={from:B(a.first,0),to:B(b.to.line+e,b.to.ch),text:[X(b.text)],origin:b.origin}}e=a.lastLine();b.to.line>e&&(b={from:b.from,to:B(e,G(a,e).text.length),text:[b.text[0]],
origin:b.origin});b.removed=vc(a,b.from,b.to);c||(c=Pd(a,b));a.cm?Lf(a.cm,b,d):Sd(a,b,d);Qb(a,c,lb)}}function Lf(a,b,c){var d=a.doc,e=a.display,g=b.from,m=b.to,p=!1,k=g.line;a.options.lineWrapping||(k=ca(Ya(G(d,g.line))),d.iter(k,m.line+1,function(a){if(a==e.maxLine)return p=!0}));-1<d.sel.contains(b.from,b.to)&&ie(a);Sd(d,b,c,z(a));a.options.lineWrapping||(d.iter(k,g.line+b.text.length,function(a){var b=w(a);b>e.maxLineLength&&(e.maxLine=a,e.maxLineLength=b,e.maxLineChanged=!0,p=!1)}),p&&(a.curOp.updateMaxLine=
!0));d.frontier=Math.min(d.frontier,g.line);Pa(a,400);c=b.text.length-(m.line-g.line)-1;g.line!=m.line||1!=b.text.length||Ke(a.doc,b)?za(a,g.line,m.line+1,c):bb(a,g.line,"text");c=Ka(a,"changes");if((d=Ka(a,"change"))||c)b={from:g,to:m,text:b.text,removed:b.removed,origin:b.origin},d&&la(a,"change",a,b),c&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(b);a.display.selForContextMenu=null}function cd(a,b,c,d,e){d||(d=c);if(0>N(d,c)){var g=d;d=c;c=g}"string"==typeof b&&(b=Cb(b));Yb(a,{from:c,to:d,
text:b,origin:e})}function Vc(a,b,c,d,e){var g=a.display,m=wb(a.display);0>c&&(c=0);var p=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:g.scroller.scrollTop,k=hb(a),f={};e-c>k&&(e=c+k);var x=a.doc.height+Lb(g),l=c<m,m=e>x-m;c<p?f.scrollTop=l?0:c:e>p+k&&(c=Math.min(c,(m?x:e)-k),c!=p&&(f.scrollTop=c));p=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:g.scroller.scrollLeft;a=ta(a)-(a.options.fixedGutter?g.gutters.offsetWidth:0);(g=d-b>a)&&(d=b+a);10>b?f.scrollLeft=0:b<p?f.scrollLeft=Math.max(0,
b-(g?0:10)):d>a+p-3&&(f.scrollLeft=d+(g?0:10)-a);return f}function id(a,b,c){null==b&&null==c||jd(a);null!=b&&(a.curOp.scrollLeft=(null==a.curOp.scrollLeft?a.doc.scrollLeft:a.curOp.scrollLeft)+b);null!=c&&(a.curOp.scrollTop=(null==a.curOp.scrollTop?a.doc.scrollTop:a.curOp.scrollTop)+c)}function Rb(a){jd(a);var b=a.getCursor(),c=b,d=b;a.options.lineWrapping||(c=b.ch?B(b.line,b.ch-1):b,d=B(b.line,b.ch+1));a.curOp.scrollToPos={from:c,to:d,margin:a.options.cursorScrollMargin,isCursor:!0}}function jd(a){var b=
a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=me(a,b.from),d=me(a,b.to),b=Vc(a,Math.min(c.left,d.left),Math.min(c.top,d.top)-b.margin,Math.max(c.right,d.right),Math.max(c.bottom,d.bottom)+b.margin);a.scrollTo(b.scrollLeft,b.scrollTop)}}function qc(a,b,c,d){var e=a.doc,g;null==c&&(c="add");"smart"==c&&(e.mode.indent?g=ab(a,b):c="prev");var m=a.options.tabSize,p=G(e,b),k=La(p.text,null,m);p.stateAfter&&(p.stateAfter=null);var f=p.text.match(/^\s*/)[0],x;if(!d&&!/\S/.test(p.text))x=0,c="not";
else if("smart"==c&&(x=e.mode.indent(g,p.text.slice(f.length),p.text),x==ze||150<x)){if(!d)return;c="prev"}"prev"==c?x=b>e.first?La(G(e,b-1).text,null,m):0:"add"==c?x=k+a.options.indentUnit:"subtract"==c?x=k-a.options.indentUnit:"number"==typeof c&&(x=k+c);x=Math.max(0,x);c="";d=0;if(a.options.indentWithTabs)for(a=Math.floor(x/m);a;--a)d+=m,c+="\t";d<x&&(c+=Le(x-d));if(c!=f)cd(e,c,B(b,0),B(b,f.length),"+input");else for(a=0;a<e.sel.ranges.length;a++)if(m=e.sel.ranges[a],m.head.line==b&&m.head.ch<
f.length){d=B(b,f.length);kc(e,a,new S(d,d));break}p.stateAfter=null}function kd(a,b,c,d){var e=b,g=b;"number"==typeof b?g=G(a,Math.max(a.first,Math.min(b,a.first+a.size-1))):e=ca(b);if(null==e)return null;d(g,e)&&a.cm&&bb(a.cm,e,c);return g}function $b(a,b){for(var c=a.doc.sel.ranges,d=[],e=0;e<c.length;e++){for(var g=b(c[e]);d.length&&0>=N(g.from,X(d).to);){var m=d.pop();if(0>N(m.from,g.from)){g.from=m.from;break}}d.push(g)}pb(a,function(){for(var b=d.length-1;0<=b;b--)cd(a.doc,"",d[b].from,d[b].to,
"+delete");Rb(a)})}function Td(a,b,c,d,e){function g(b){var d=(e?Hd:Me)(f,p,c,!0);if(null==d){if(b=!b)b=m+c,b<a.first||b>=a.first+a.size?b=x=!1:(m=b,b=f=G(a,b));if(b)p=e?(0>c?Uc:Tc)(f):0>c?f.text.length:0;else return x=!1}else p=d;return!0}var m=b.line,p=b.ch,k=c,f=G(a,m),x=!0;if("char"==d)g();else if("column"==d)g(!0);else if("word"==d||"group"==d){var l=null;d="group"==d;b=a.cm&&a.cm.getHelper(b,"wordChars");for(var q=!0;!(0>c)||g(!q);q=!1){var h=f.text.charAt(p)||"\n",h=ld(h,b)?"w":d&&"\n"==h?
"n":!d||/\s/.test(h)?null:"p";!d||q||h||(h="s");if(l&&l!=h){0>c&&(c=1,g());break}h&&(l=h);if(0<c&&!g(!q))break}}k=mb(a,B(m,p),k,!0);x||(k.hitSide=!0);return k}function Ne(a,b,c,d){var e=a.doc,g=b.left,m;"page"==d?(m=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),m=b.top+c*(m-(0>c?1.5:.5)*wb(a.display))):"line"==d&&(m=0<c?b.bottom+3:b.top-3);for(;;){b=Gd(a,g,m);if(!b.outside)break;if(0>c?0>=m:m>=e.height){b.hitSide=!0;break}m+=5*c}return b}function L(a,
b,c,d){f.defaults[a]=b;c&&(Kb[a]=d?function(a,b,d){d!=ce&&c(a,b,d)}:c)}function Mf(a){var b=a.split(/-(?!$)/);a=b[b.length-1];for(var c,d,e,g,m=0;m<b.length-1;m++){var p=b[m];if(/^(cmd|meta|m)$/i.test(p))g=!0;else if(/^a(lt)?$/i.test(p))c=!0;else if(/^(c|ctrl|control)$/i.test(p))d=!0;else if(/^s(hift)$/i.test(p))e=!0;else throw Error("Unrecognized modifier name: "+p);}c&&(a="Alt-"+a);d&&(a="Ctrl-"+a);g&&(a="Cmd-"+a);e&&(a="Shift-"+a);return a}function md(a){return"string"==typeof a?rb[a]:a}function ac(a,
b,c,d,e){if(d&&d.shared)return Nf(a,b,c,d,e);if(a.cm&&!a.cm.curOp)return ha(a.cm,ac)(a,b,c,d,e);var g=new Gb(a,e);e=N(b,c);d&&db(d,g,!1);if(0<e||0==e&&!1!==g.clearWhenEmpty)return g;g.replacedWith&&(g.collapsed=!0,g.widgetNode=F("span",[g.replacedWith],"CodeMirror-widget"),d.handleMouseEvents||g.widgetNode.setAttribute("cm-ignore-events","true"),d.insertLeft&&(g.widgetNode.insertLeft=!0));if(g.collapsed){if(Oe(a,b.line,b,c,g)||b.line!=c.line&&Oe(a,c.line,b,c,g))throw Error("Inserting collapsed marker partially overlapping an existing one");
gb=!0}g.addToHistory&&Ge(a,{from:b,to:c,origin:"markText"},a.sel,NaN);var m=b.line,p=a.cm,k;a.iter(m,c.line+1,function(a){p&&g.collapsed&&!p.options.lineWrapping&&Ya(a)==p.display.maxLine&&(k=!0);g.collapsed&&m!=b.line&&Qa(a,0);var d=new nd(g,m==b.line?b.ch:null,m==c.line?c.ch:null);a.markedSpans=a.markedSpans?a.markedSpans.concat([d]):[d];d.marker.attachLine(a);++m});g.collapsed&&a.iter(b.line,c.line+1,function(b){xb(a,b)&&Qa(b,0)});g.clearOnEnter&&M(g,"beforeCursorEnter",function(){g.clear()});
g.readOnly&&(Ee=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory());g.collapsed&&(g.id=++Of,g.atomic=!0);if(p){k&&(p.curOp.updateMaxLine=!0);if(g.collapsed)za(p,b.line,c.line+1);else if(g.className||g.title||g.startStyle||g.endStyle||g.css)for(d=b.line;d<=c.line;d++)bb(p,d,"text");g.atomic&&Mc(p.doc);la(p,"markerAdded",p,g)}return g}function Nf(a,b,c,d,e){d=db(d);d.shared=!1;var g=[ac(a,b,c,d,e)],m=g[0],p=d.widgetNode;Fb(a,function(a){p&&(d.widgetNode=p.cloneNode(!0));g.push(ac(a,
J(a,b),J(a,c),d,e));for(var k=0;k<a.linked.length;++k)if(a.linked[k].isParent)return;m=X(g)});return new od(g,m)}function Pe(a){return a.findMarks(B(a.first,0),a.clipPos(B(a.lastLine())),function(a){return a.parent})}function Pf(a){for(var b=0;b<a.length;b++){var c=a[b],d=[c.primary.doc];Fb(c.primary.doc,function(a){d.push(a)});for(var e=0;e<c.markers.length;e++){var g=c.markers[e];-1==ka(d,g.doc)&&(g.parent=null,c.markers.splice(e--,1))}}}function nd(a,b,c){this.marker=a;this.from=b;this.to=c}function wc(a,
b){if(a)for(var c=0;c<a.length;++c){var d=a[c];if(d.marker==b)return d}}function Qd(a,b){var c=Va(a,b.from.line)&&G(a,b.from.line).markedSpans,d=Va(a,b.to.line)&&G(a,b.to.line).markedSpans;if(!c&&!d)return null;var e=b.from.ch,g=b.to.ch,m=0==N(b.from,b.to);if(c)for(var p=0,k;p<c.length;++p){var f=c[p],x=f.marker;if(null==f.from||(x.inclusiveLeft?f.from<=e:f.from<e)||!(f.from!=e||"bookmark"!=x.type||m&&f.marker.insertLeft)){var l=null==f.to||(x.inclusiveRight?f.to>=e:f.to>e);(k||(k=[])).push(new nd(x,
f.from,l?null:f.to))}}c=k;if(d)for(var p=0,q;p<d.length;++p)if(k=d[p],f=k.marker,null==k.to||(f.inclusiveRight?k.to>=g:k.to>g)||k.from==g&&"bookmark"==f.type&&(!m||k.marker.insertLeft))x=null==k.from||(f.inclusiveLeft?k.from<=g:k.from<g),(q||(q=[])).push(new nd(f,x?null:k.from-g,null==k.to?null:k.to-g));d=q;m=1==b.text.length;q=X(b.text).length+(m?e:0);if(c)for(g=0;g<c.length;++g)if(p=c[g],null==p.to)(k=wc(d,p.marker),k)?m&&(p.to=null==k.to?null:k.to+q):p.to=e;if(d)for(g=0;g<d.length;++g)p=d[g],null!=
p.to&&(p.to+=q),null==p.from?(k=wc(c,p.marker),k||(p.from=q,m&&(c||(c=[])).push(p))):(p.from+=q,m&&(c||(c=[])).push(p));c&&(c=Qe(c));d&&d!=c&&(d=Qe(d));e=[c];if(!m){var m=b.text.length-2,h;if(0<m&&c)for(g=0;g<c.length;++g)null==c[g].to&&(h||(h=[])).push(new nd(c[g].marker,null,null));for(g=0;g<m;++g)e.push(h);e.push(d)}return e}function Qe(a){for(var b=0;b<a.length;++b){var c=a[b];null!=c.from&&c.from==c.to&&!1!==c.marker.clearWhenEmpty&&a.splice(b--,1)}return a.length?a:null}function Ie(a,b){var c;
if(c=b["spans_"+a.id]){for(var d=0,e=[];d<b.text.length;++d)e.push(Qf(c[d]));c=e}else c=null;d=Qd(a,b);if(!c)return d;if(!d)return c;for(e=0;e<c.length;++e){var g=c[e],m=d[e];if(g&&m){var p=0;a:for(;p<m.length;++p){for(var k=m[p],f=0;f<g.length;++f)if(g[f].marker==k.marker)continue a;g.push(k)}}else m&&(c[e]=m)}return c}function Kf(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!=ka(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(0),g=0;g<a.length;++g){var m=a[g];if(!(0>N(m.to,e.from)||0<N(m.from,e.to))){var p=[g,1],k=N(m.from,e.from),f=N(m.to,e.to);(0>k||!c.inclusiveLeft&&!k)&&p.push({from:m.from,to:e.from});(0<f||!c.inclusiveRight&&!f)&&p.push({from:e.to,to:m.to});a.splice.apply(a,p);g+=p.length-1}}}return a}function Re(a){var b=a.markedSpans;if(b){for(var c=0;c<b.length;++c)b[c].marker.detachLine(a);a.markedSpans=
null}}function Se(a,b){if(b){for(var c=0;c<b.length;++c)b[c].marker.attachLine(a);a.markedSpans=b}}function Te(a,b){var c=a.lines.length-b.lines.length;if(0!=c)return c;var c=a.find(),d=b.find(),e=N(c.from,d.from)||(a.inclusiveLeft?-1:0)-(b.inclusiveLeft?-1:0);return e?-e:(c=N(c.to,d.to)||(a.inclusiveRight?1:0)-(b.inclusiveRight?1:0))?c:b.id-a.id}function zb(a,b){var c=gb&&a.markedSpans,d;if(c)for(var e,g=0;g<c.length;++g)e=c[g],e.marker.collapsed&&null==(b?e.from:e.to)&&(!d||0>Te(d,e.marker))&&(d=
e.marker);return d}function Oe(a,b,c,d,e){a=G(a,b);if(a=gb&&a.markedSpans)for(b=0;b<a.length;++b){var g=a[b];if(g.marker.collapsed){var m=g.marker.find(0),p=N(m.from,c)||(g.marker.inclusiveLeft?-1:0)-(e.inclusiveLeft?-1:0),k=N(m.to,d)||(g.marker.inclusiveRight?1:0)-(e.inclusiveRight?1:0);if(!(0<=p&&0>=k||0>=p&&0<=k)&&(0>=p&&(0<N(m.to,c)||g.marker.inclusiveRight&&e.inclusiveLeft)||0<=p&&(0>N(m.from,d)||g.marker.inclusiveLeft&&e.inclusiveRight)))return!0}}}function Ya(a){for(var b;b=zb(a,!0);)a=b.find(-1,
!0).line;return a}function xd(a,b){var c=G(a,b),d=Ya(c);return c==d?b:ca(d)}function fe(a,b){if(b>a.lastLine())return b;var c=G(a,b),d;if(!xb(a,c))return b;for(;d=zb(c,!1);)c=d.find(1,!0).line;return ca(c)+1}function xb(a,b){var c=gb&&b.markedSpans;if(c)for(var d,e=0;e<c.length;++e)if(d=c[e],d.marker.collapsed&&(null==d.from||!d.marker.widgetNode&&0==d.from&&d.marker.inclusiveLeft&&Ud(a,b,d)))return!0}function Ud(a,b,c){if(null==c.to)return b=c.marker.find(1,!0),Ud(a,b.line,wc(b.line.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.marker.widgetNode&&d.from==c.to&&(null==d.to||d.to!=c.from)&&(d.marker.inclusiveLeft||c.marker.inclusiveRight)&&Ud(a,b,d))return!0}function oc(a){if(null!=a.height)return a.height;var b;a:{b=document.body;var c=a.node;if(b.contains)b=b.contains(c);else{for(;c=c.parentNode;)if(c==b){b=!0;break a}b=void 0}}b||(b="position: relative;",a.coverGutter&&
(b+="margin-left: -"+a.cm.getGutterElement().offsetWidth+"px;"),Wa(a.cm.display.measure,F("div",[a.node],null,b)));return a.height=a.node.offsetHeight}function Rf(a,b,c,d){var e=new pd(a,c,d);e.noHScroll&&(a.display.alignWidgets=!0);kd(a.doc,b,"widget",function(b){var c=b.widgets||(b.widgets=[]);null==e.insertAt?c.push(e):c.splice(Math.min(c.length-1,Math.max(0,e.insertAt)),0,e);e.line=b;xb(a.doc,b)||(c=Ra(b)<a.doc.scrollTop,Qa(b,b.height+oc(e)),c&&id(a,null,e.height),a.curOp.forceUpdate=!0);return!0});
return e}function Ue(a,b){if(a)for(;;){var c=a.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!c)break;a=a.slice(0,c.index)+a.slice(c.index+c[0].length);var d=c[1]?"bgClass":"textClass";null==b[d]?b[d]=c[2]:(new RegExp("(?:^|s)"+c[2]+"(?:$|s)")).test(b[d])||(b[d]+=" "+c[2])}return a}function Ve(a,b){if(a.blankLine)return a.blankLine(b);if(a.innerMode){var c=f.innerMode(a,b);if(c.mode.blankLine)return c.mode.blankLine(c.state)}}function Vd(a,b,c,d){for(var e=0;10>e;e++){d&&(d[0]=f.innerMode(a,c).mode);
var g=a.token(b,c);if(b.pos>b.start)return g}throw Error("Mode "+a.name+" failed to advance stream.");}function We(a,b,c,d){function e(a){return{start:q.start,end:q.pos,string:q.current(),type:p||null,state:a?Ub(g.mode,f):f}}var g=a.doc,m=g.mode,p;b=J(g,b);var k=G(g,b.line),f=ab(a,b.line,c),q=new qd(k.text,a.options.tabSize),l;for(d&&(l=[]);(d||q.pos<b.ch)&&!q.eol();)q.start=q.pos,p=Vd(m,q,f),d&&l.push(e(!0));return d?l:e()}function Xe(a,b,c,d,e,g,m){var p=c.flattenSpans;null==p&&(p=a.options.flattenSpans);
var k=0,f=null,q=new qd(b,a.options.tabSize),l,h=a.options.addModeClass&&[null];for(""==b&&Ue(Ve(c,d),g);!q.eol();){q.pos>a.options.maxHighlightLength?(p=!1,m&&Ad(a,b,d,q.pos),q.pos=b.length,l=null):l=Ue(Vd(c,q,d,h),g);if(h){var n=h[0].name;n&&(l="m-"+(l?n+" "+l:n))}if(!p||f!=l){for(;k<q.start;)k=Math.min(q.start,k+5E4),e(k,f);f=l}q.start=q.pos}for(;k<q.pos;)a=Math.min(q.pos,k+5E4),e(a,f),k=a}function je(a,b,c,d){var e=[a.state.modeGen],g={};Xe(a,b.text,a.doc.mode,c,function(a,b){e.push(a,b)},g,d);
for(c=0;c<a.state.overlays.length;++c){var m=a.state.overlays[c],p=1,k=0;Xe(a,b.text,m.mode,!0,function(a,b){for(var c=p;k<a;){var d=e[p];d>a&&e.splice(p,1,a,e[p+1],d);p+=2;k=Math.min(a,d)}if(b)if(m.opaque)e.splice(c,p-c,a,"cm-overlay "+b),p=c+2;else for(;c<p;c+=2)d=e[c+1],e[c+1]=(d?d+" ":"")+"cm-overlay "+b},g)}return{styles:e,classes:g.bgClass||g.textClass?g:null}}function Ye(a,b,c){if(!b.styles||b.styles[0]!=a.state.modeGen){var d=je(a,b,b.stateAfter=ab(a,ca(b)));b.styles=d.styles;d.classes?b.styleClasses=
d.classes:b.styleClasses&&(b.styleClasses=null);c===a.doc.frontier&&a.doc.frontier++}return b.styles}function Ad(a,b,c,d){var e=a.doc.mode,g=new qd(b,a.options.tabSize);g.start=g.pos=d||0;for(""==b&&Ve(e,c);!g.eol()&&g.pos<=a.options.maxHighlightLength;)Vd(e,g,c),g.start=g.pos}function Ze(a,b){if(!a||/^\s*$/.test(a))return null;var c=b.addModeClass?Sf:Tf;return c[a]||(c[a]=a.replace(/\S+/g,"cm-$&"))}function ge(a,b){var c=F("span",null,null,ia?"padding-right: .1px":null),c={pre:F("pre",[c]),content:c,
col:0,pos:0,cm:a};b.measure={};for(var d=0;d<=(b.rest?b.rest.length:0);d++){var e=d?b.rest[d-1]:b.line,g;c.pos=0;c.addToken=Uf;(O||ia)&&a.getOption("lineWrapping")&&(c.addToken=Vf(c.addToken));var m;if(null!=Wd)m=Wd;else{m=Wa(a.display.measure,document.createTextNode("A\u062eA"));var k=Vb(m,0,1).getBoundingClientRect();m=k&&k.left!=k.right?Wd=3>Vb(m,1,2).getBoundingClientRect().right-k.right:!1}m&&(g=Xa(e))&&(c.addToken=Wf(c.addToken,g));c.map=[];k=b!=a.display.externalMeasured&&ca(e);a:{m=c;var k=
Ye(a,e,k),f=e.markedSpans,q=e.text,l=0;if(f)for(var h=q.length,n=0,u=1,H="",r=void 0,Y=void 0,C=0,Ga=void 0,Ea=void 0,T=void 0,y=void 0,da=void 0;;){if(C==n){for(var Ga=Ea=T=y=Y="",da=null,C=Infinity,v=[],ma=0;ma<f.length;++ma){var z=f[ma],w=z.marker;z.from<=n&&(null==z.to||z.to>n)?(null!=z.to&&C>z.to&&(C=z.to,Ea=""),w.className&&(Ga+=" "+w.className),w.css&&(Y=w.css),w.startStyle&&z.from==n&&(T+=" "+w.startStyle),w.endStyle&&z.to==C&&(Ea+=" "+w.endStyle),w.title&&!y&&(y=w.title),w.collapsed&&(!da||
0>Te(da.marker,w))&&(da=z)):z.from>n&&C>z.from&&(C=z.from);"bookmark"==w.type&&z.from==n&&w.widgetNode&&v.push(w)}if(da&&(da.from||0)==n&&($e(m,(null==da.to?h+1:da.to)-n,da.marker,null==da.from),null==da.to))break a;if(!da&&v.length)for(ma=0;ma<v.length;++ma)$e(m,0,v[ma])}if(n>=h)break;for(v=Math.min(h,C);;){if(H){ma=n+H.length;da||(z=ma>v?H.slice(0,v-n):H,m.addToken(m,z,r?r+Ga:Ga,T,n+z.length==C?Ea:"",y,Y));if(ma>=v){H=H.slice(v-n);n=v;break}n=ma;T=""}H=q.slice(l,l=k[u++]);r=Ze(k[u++],m.cm.options)}}else for(var u=
1;u<k.length;u+=2)m.addToken(m,q.slice(l,l=k[u]),Ze(k[u+1],m.cm.options))}e.styleClasses&&(e.styleClasses.bgClass&&(c.bgClass=Xd(e.styleClasses.bgClass,c.bgClass||"")),e.styleClasses.textClass&&(c.textClass=Xd(e.styleClasses.textClass,c.textClass||"")));0==c.map.length&&c.map.push(0,0,c.content.appendChild(Xf(a.display.measure)));0==d?(b.measure.map=c.map,b.measure.cache={}):((b.measure.maps||(b.measure.maps=[])).push(c.map),(b.measure.caches||(b.measure.caches=[])).push({}))}ia&&/\bcm-tab\b/.test(c.content.lastChild.className)&&
(c.content.className="cm-tab-wrap-hack");ga(a,"renderLine",a,b.line,c.pre);c.pre.className&&(c.textClass=Xd(c.pre.className,c.textClass||""));return c}function Uf(a,b,c,d,e,g,m){if(b){var k=a.cm.options.specialChars,f=!1;if(k.test(b))for(var q=document.createDocumentFragment(),l=0;;){k.lastIndex=l;var h=k.exec(b),n=h?h.index-l:b.length-l;if(n){var u=document.createTextNode(b.slice(l,l+n));O&&9>V?q.appendChild(F("span",[u])):q.appendChild(u);a.map.push(a.pos,a.pos+n,u);a.col+=n;a.pos+=n}if(!h)break;
l+=n+1;"\t"==h[0]?(u=a.cm.options.tabSize,h=u-a.col%u,u=q.appendChild(F("span",Le(h),"cm-tab")),a.col+=h):(u=a.cm.options.specialCharPlaceholder(h[0]),O&&9>V?q.appendChild(F("span",[u])):q.appendChild(u),a.col+=1);a.map.push(a.pos,a.pos+1,u);a.pos++}else{a.col+=b.length;var q=document.createTextNode(b);a.map.push(a.pos,a.pos+b.length,q);O&&9>V&&(f=!0);a.pos+=b.length}if(c||d||e||f||m)return b=c||"",d&&(b+=d),e&&(b+=e),d=F("span",[q],b,m),g&&(d.title=g),a.content.appendChild(d);a.content.appendChild(q)}}
function Vf(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,g,m,k){a(c,d.replace(/ {3,}/g,b),e,g,m,k)}}function Wf(a,b){return function(c,d,e,g,m,k){e=e?e+" cm-force-border":"cm-force-border";for(var f=c.pos,q=f+d.length;;){for(var l=0;l<b.length;l++){var h=b[l];if(h.to>f&&h.from<=f)break}if(h.to>=q)return a(c,d,e,g,m,k);a(c,d.slice(0,h.to-f),e,g,null,k);g=null;d=d.slice(h.to-f);f=h.to}}}function $e(a,b,c,d){if(c=!d&&c.widgetNode)a.map.push(a.pos,
a.pos+b,c),a.content.appendChild(c);a.pos+=b}function Ke(a,b){return 0==b.from.ch&&0==b.to.ch&&""==X(b.text)&&(!a.cm||a.cm.options.wholeLineUpdateBefore)}function Sd(a,b,c,d){function e(a,c,e){a.text=c;a.stateAfter&&(a.stateAfter=null);a.styles&&(a.styles=null);null!=a.order&&(a.order=null);Re(a);Se(a,e);c=d?d(a):1;c!=a.height&&Qa(a,c);la(a,"change",a,b)}var g=b.from,m=b.to,k=b.text,f=G(a,g.line),q=G(a,m.line),l=X(k),h=c?c[k.length-1]:null,n=m.line-g.line;if(Ke(a,b)){for(var u=0,H=[];u<k.length-1;++u)H.push(new Hb(k[u],
c?c[u]:null,d));e(q,q.text,h);n&&a.remove(g.line,n);H.length&&a.insert(g.line,H)}else if(f==q)if(1==k.length)e(f,f.text.slice(0,g.ch)+l+f.text.slice(m.ch),h);else{H=[];for(u=1;u<k.length-1;++u)H.push(new Hb(k[u],c?c[u]:null,d));H.push(new Hb(l+f.text.slice(m.ch),h,d));e(f,f.text.slice(0,g.ch)+k[0],c?c[0]:null);a.insert(g.line+1,H)}else if(1==k.length)e(f,f.text.slice(0,g.ch)+k[0]+q.text.slice(m.ch),c?c[0]:null),a.remove(g.line+1,n);else{e(f,f.text.slice(0,g.ch)+k[0],c?c[0]:null);e(q,l+q.text.slice(m.ch),
h);u=1;for(H=[];u<k.length-1;++u)H.push(new Hb(k[u],c?c[u]:null,d));1<n&&a.remove(g.line+1,n-1);a.insert(g.line+1,H)}la(a,"change",a,b)}function xc(a){this.lines=a;this.parent=null;for(var b=0,c=0;b<a.length;++b)a[b].parent=this,c+=a[b].height;this.height=c}function yc(a){this.children=a;for(var b=0,c=0,d=0;d<a.length;++d){var e=a[d],b=b+e.chunkSize(),c=c+e.height;e.parent=this}this.size=b;this.height=c;this.parent=null}function Fb(a,b,c){function d(a,g,m){if(a.linked)for(var k=0;k<a.linked.length;++k){var f=
a.linked[k];if(f.doc!=g){var q=m&&f.sharedHist;if(!c||q)b(f.doc,q),d(f.doc,a,q)}}}d(a,null,!0)}function be(a,b){if(b.cm)throw Error("This document is already in use.");a.doc=b;b.cm=a;y(a);I(a);a.options.lineWrapping||h(a);a.options.mode=b.modeOption;za(a)}function G(a,b){b-=a.first;if(0>b||b>=a.size)throw Error("There is no line "+(b+a.first)+" in the document.");for(var c=a;!c.lines;)for(var d=0;;++d){var e=c.children[d],g=e.chunkSize();if(b<g){c=e;break}b-=g}return c.lines[b]}function vc(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 Yd(a,b,c){var d=[];a.iter(b,c,function(a){d.push(a.text)});return d}function Qa(a,b){var c=b-a.height;if(c)for(var d=a;d;d=d.parent)d.height+=c}function ca(a){if(null==a.parent)return null;var b=a.parent;a=ka(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 Ab(a,b){var c=
a.first;a:do{for(var d=0;d<a.children.length;++d){var e=a.children[d],g=e.height;if(b<g){a=e;continue a}b-=g;c+=e.chunkSize()}return c}while(!a.lines);for(d=0;d<a.lines.length;++d){e=a.lines[d].height;if(b<e)break;b-=e}return c+d}function Ra(a){a=Ya(a);for(var b=0,c=a.parent,d=0;d<c.lines.length;++d){var e=c.lines[d];if(e==a)break;else b+=e.height}for(a=c.parent;a;c=a,a=c.parent)for(d=0;d<a.children.length&&(e=a.children[d],e!=c);++d)b+=e.height;return b}function Xa(a){var b=a.order;null==b&&(b=a.order=
Yf(a.text));return b}function rd(a){this.done=[];this.undone=[];this.undoDepth=Infinity;this.lastModTime=this.lastSelTime=0;this.lastOrigin=this.lastSelOrigin=this.lastOp=this.lastSelOp=null;this.generation=this.maxGeneration=a||1}function Rd(a,b){var c={from:q(b.from),to:qb(b),text:vc(a,b.from,b.to)};af(a,c,b.from.line,b.to.line+1);Fb(a,function(a){af(a,c,b.from.line,b.to.line+1)},!0);return c}function he(a){for(;a.length;)if(X(a).ranges)a.pop();else break}function Ge(a,b,c,d){var e=a.history;e.undone.length=
0;var g=+new Date,m,k;if(k=e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&e.lastModTime>g-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))e.lastOp==d?(he(e.done),m=X(e.done)):e.done.length&&!X(e.done).ranges?m=X(e.done):1<e.done.length&&!e.done[e.done.length-2].ranges?(e.done.pop(),m=X(e.done)):m=void 0,k=m;if(k){var f=X(m.changes);0==N(b.from,b.to)&&0==N(b.from,f.to)?f.to=qb(b):m.changes.push(Rd(a,b))}else for((m=X(e.done))&&m.ranges||Kc(a.sel,e.done),m={changes:[Rd(a,
b)],generation:e.generation},e.done.push(m);e.done.length>e.undoDepth;)e.done.shift(),e.done[0].ranges||e.done.shift();e.done.push(c);e.generation=++e.maxGeneration;e.lastModTime=e.lastSelTime=g;e.lastOp=e.lastSelOp=d;e.lastOrigin=e.lastSelOrigin=b.origin;f||ga(a,"historyAdded")}function Kc(a,b){var c=X(b);c&&c.ranges&&c.equals(a)||b.push(a)}function af(a,b,c,d){var e=b["spans_"+a.id],g=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]={}))[g]=
c.markedSpans);++g})}function Qf(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 bc(a,b,c){for(var d=0,e=[];d<a.length;++d){var g=a[d];if(g.ranges)e.push(c?Ja.prototype.deepCopy.call(g):g);else{var g=g.changes,m=[];e.push({changes:m});for(var k=0;k<g.length;++k){var f=g[k],q;m.push({from:f.from,to:f.to,text:f.text});if(b)for(var l in f)(q=l.match(/^spans_(\d+)$/))&&-1<ka(b,Number(q[1]))&&(X(m)[l]=
f[l],delete f[l])}}}return e}function bf(a,b,c,d){c<a.line?a.line+=d:b<a.line&&(a.line=b,a.ch=0)}function cf(a,b,c,d){for(var e=0;e<a.length;++e){var g=a[e],m=!0;if(g.ranges){g.copied||(g=a[e]=g.deepCopy(),g.copied=!0);for(var k=0;k<g.ranges.length;k++)bf(g.ranges[k].anchor,b,c,d),bf(g.ranges[k].head,b,c,d)}else{for(k=0;k<g.changes.length;++k){var f=g.changes[k];if(c<f.from.line)f.from=B(f.from.line+d,f.from.ch),f.to=B(f.to.line+d,f.to.ch);else if(b<=f.to.line){m=!1;break}}m||(a.splice(0,e+1),e=0)}}}
function He(a,b){var c=b.from.line,d=b.to.line,e=b.text.length-(d-c)-1;cf(a.done,c,d,e);cf(a.undone,c,d,e)}function Nd(a){return null!=a.defaultPrevented?a.defaultPrevented:0==a.returnValue}function we(a){var b=a.which;null==b&&(a.button&1?b=1:a.button&2?b=3:a.button&4&&(b=2));Ha&&a.ctrlKey&&1==b&&(b=3);return b}function la(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),g;Wb?g=Wb.delayedCallbacks:zc?g=zc:
(g=zc=[],setTimeout(Zf,0));for(var k=0;k<d.length;++k)g.push(c(d[k]))}}function Zf(){var a=zc;zc=null;for(var b=0;b<a.length;++b)a[b]()}function Ma(a,b,c){"string"==typeof b&&(b={type:b,preventDefault:function(){this.defaultPrevented=!0}});ga(a,c||b.type,a,b);return Nd(b)||b.codemirrorIgnore}function ie(a){var b=a._handlers&&a._handlers.cursorActivity;if(b){a=a.curOp.cursorActivityHandlers||(a.curOp.cursorActivityHandlers=[]);for(var c=0;c<b.length;++c)-1==ka(a,b[c])&&a.push(b[c])}}function Ka(a,
b){var c=a._handlers&&a._handlers[b];return c&&0<c.length}function cc(a){a.prototype.on=function(a,c){M(this,a,c)};a.prototype.off=function(a,c){cb(this,a,c)}}function Fc(){this.id=null}function xe(a,b,c){for(var d=0,e=0;;){var g=a.indexOf("\t",d);-1==g&&(g=a.length);var k=g-d;if(g==a.length||e+k>=b)return d+Math.min(k,b-e);e+=g-d;e+=c-e%c;d=g+1;if(e>=b)return d}}function Le(a){for(;sd.length<=a;)sd.push(X(sd)+" ");return sd[a]}function X(a){return a[a.length-1]}function ka(a,b){for(var c=0;c<a.length;++c)if(a[c]==
b)return c;return-1}function Xb(a,b){for(var c=[],d=0;d<a.length;d++)c[d]=b(a[d],d);return c}function df(a,b){var c;Object.create?c=Object.create(a):(c=function(){},c.prototype=a,c=new c);b&&db(b,c);return c}function db(a,b,c){b||(b={});for(var d in a)!a.hasOwnProperty(d)||!1===c&&b.hasOwnProperty(d)||(b[d]=a[d]);return b}function Oa(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(null,b)}}function ld(a,b){return b?-1<b.source.indexOf("\\w")&&ef(a)?!0:b.test(a):ef(a)}
function ff(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function nc(a){return 768<=a.charCodeAt(0)&&$f.test(a)}function F(a,b,c,d){a=document.createElement(a);c&&(a.className=c);d&&(a.style.cssText=d);if("string"==typeof b)a.appendChild(document.createTextNode(b));else if(b)for(c=0;c<b.length;++c)a.appendChild(b[c]);return a}function yb(a){for(var b=a.childNodes.length;0<b;--b)a.removeChild(a.firstChild);return a}function Wa(a,b){return yb(a).appendChild(b)}function eb(){return document.activeElement}
function Ac(a){return new RegExp("(^|\\s)"+a+"(?:$|\\s)\\s*")}function Xd(a,b){for(var c=a.split(" "),d=0;d<c.length;d++)c[d]&&!Ac(c[d]).test(b)&&(b+=" "+c[d]);return b}function gf(a){if(document.body.getElementsByClassName)for(var b=document.body.getElementsByClassName("CodeMirror"),c=0;c<b.length;c++){var d=b[c].CodeMirror;d&&a(d)}}function qf(){var a;M(window,"resize",function(){null==a&&(a=setTimeout(function(){a=null;gf(yf)},100))});M(window,"blur",function(){gf(Gc)})}function Xf(a){if(null==
Zd){var b=F("span","\u200b");Wa(a,F("span",[b,document.createTextNode("x")]));0!=a.firstChild.offsetHeight&&(Zd=1>=b.offsetWidth&&2<b.offsetHeight&&!(O&&8>V))}return Zd?F("span","\u200b"):F("span","\u00a0",null,"display: inline-block; width: 1px; margin-right: -1px")}function rf(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=!1,g=0;g<a.length;++g){var k=a[g];if(k.from<c&&k.to>b||b==c&&k.to==b)d(Math.max(k.from,b),Math.min(k.to,c),1==k.level?"rtl":"ltr"),e=!0}e||d(b,c,"ltr")}function Dd(a){return a.level%
2?a.to:a.from}function Ed(a){return a.level%2?a.from:a.to}function Tc(a){return(a=Xa(a))?Dd(a[0]):0}function Uc(a){var b=Xa(a);return b?Ed(X(b)):a.text.length}function hf(a,b){var c=G(a.doc,b),d=Ya(c);d!=c&&(b=ca(d));d=(c=Xa(d))?c[0].level%2?Uc(d):Tc(d):0;return B(b,d)}function jf(a,b){var c=hf(a,b.line),d=G(a.doc,c.line),e=Xa(d);return e&&0!=e[0].level?c:(d=Math.max(0,d.text.search(/\S/)),B(c.line,b.line==c.line&&b.ch<=d&&b.ch?0:d))}function Fd(a,b){pc=null;for(var c=0,d;c<a.length;++c){var e=a[c];
if(e.from<b&&e.to>b)return c;if(e.from==b||e.to==b)if(null==d)d=c;else{var g;g=e.level;var k=a[d].level,p=a[0].level;g=g==p?!0:k==p?!1:g<k;if(g)return e.from!=e.to&&(pc=d),c;e.from!=e.to&&(pc=c);break}}return d}function $d(a,b,c,d){if(!d)return b+c;do b+=c;while(0<b&&nc(a.text.charAt(b)));return b}function Hd(a,b,c,d){var e=Xa(a);if(!e)return Me(a,b,c,d);var g=Fd(e,b),k=e[g];for(b=$d(a,b,k.level%2?-c:c,d);;){if(b>k.from&&b<k.to)return b;if(b==k.from||b==k.to){if(Fd(e,b)==g)return b;k=e[g+c];return 0<
c==k.level%2?k.to:k.from}k=e[g+=c];if(!k)return null;b=0<c==k.level%2?$d(a,k.to,-1,d):$d(a,k.from,1,d)}}function Me(a,b,c,d){b+=c;if(d)for(;0<b&&nc(a.text.charAt(b));)b+=c;return 0>b||b>a.text.length?null:b}var sc=/gecko\/\d/i.test(navigator.userAgent),kf=/MSIE \d/.test(navigator.userAgent),lf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),O=kf||lf,V=O&&(kf?document.documentMode||6:lf[1]),ia=/WebKit\//.test(navigator.userAgent),ag=ia&&/Qt\/\d+\.\d+/.test(navigator.userAgent),bg=
/Chrome\//.test(navigator.userAgent),Na=/Opera\//.test(navigator.userAgent),ve=/Apple Computer/.test(navigator.vendor),wd=/KHTML\//.test(navigator.userAgent),cg=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),vf=/PhantomJS/.test(navigator.userAgent),dc=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),td=dc||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),Ha=dc||/Mac/.test(navigator.platform),dg=/win/i.test(navigator.platform),
Ib=Na&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);Ib&&(Ib=Number(Ib[1]));Ib&&15<=Ib&&(Na=!1,ia=!0);var mf=Ha&&(ag||Na&&(null==Ib||12.11>Ib)),Ld=sc||O&&9<=V,Ee=!1,gb=!1;T.prototype=db({update:function(a){var b=a.scrollWidth>a.clientWidth+1,c=a.scrollHeight>a.clientHeight+1,d=a.nativeBarWidth;c?(this.vert.style.display="block",this.vert.style.bottom=b?d+"px":"0",this.vert.firstChild.style.height=Math.max(0,a.scrollHeight-a.clientHeight+(a.viewHeight-(b?d:0)))+"px"):(this.vert.style.display="",
this.vert.firstChild.style.height="0");b?(this.horiz.style.display="block",this.horiz.style.right=c?d+"px":"0",this.horiz.style.left=a.barLeft+"px",this.horiz.firstChild.style.width=a.scrollWidth-a.clientWidth+(a.viewWidth-a.barLeft-(c?d:0))+"px"):(this.horiz.style.display="",this.horiz.firstChild.style.width="0");!this.checkedOverlay&&0<a.clientHeight&&(0==d&&this.overlayHack(),this.checkedOverlay=!0);return{right:c?d:0,bottom:b?d:0}},setScrollLeft:function(a){this.horiz.scrollLeft!=a&&(this.horiz.scrollLeft=
a)},setScrollTop:function(a){this.vert.scrollTop!=a&&(this.vert.scrollTop=a)},overlayHack:function(){this.horiz.style.minHeight=this.vert.style.minWidth=Ha&&!cg?"12px":"18px";var a=this,b=function(b){(b.target||b.srcElement)!=a.vert&&(b.target||b.srcElement)!=a.horiz&&ha(a.cm,oe)(b)};M(this.vert,"mousedown",b);M(this.horiz,"mousedown",b)},clear:function(){var a=this.horiz.parentNode;a.removeChild(this.horiz);a.removeChild(this.vert)}},T.prototype);n.prototype=db({update:function(){return{bottom:0,
right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},n.prototype);f.scrollbarModel={"native":T,"null":n};var B=f.Pos=function(a,b){if(!(this instanceof B))return new B(a,b);this.line=a;this.ch=b},N=f.cmpPos=function(a,b){return a.line-b.line||a.ch-b.ch};Ja.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(a){if(a==this)return!0;if(a.primIndex!=this.primIndex||a.ranges.length!=this.ranges.length)return!1;for(var b=0;b<this.ranges.length;b++){var c=
this.ranges[b],d=a.ranges[b];if(0!=N(c.anchor,d.anchor)||0!=N(c.head,d.head))return!1}return!0},deepCopy:function(){for(var a=[],b=0;b<this.ranges.length;b++)a[b]=new S(q(this.ranges[b].anchor),q(this.ranges[b].head));return new Ja(a,this.primIndex)},somethingSelected:function(){for(var a=0;a<this.ranges.length;a++)if(!this.ranges[a].empty())return!0;return!1},contains:function(a,b){b||(b=a);for(var c=0;c<this.ranges.length;c++){var d=this.ranges[c];if(0<=N(b,d.from())&&0>=N(a,d.to()))return c}return-1}};
S.prototype={from:function(){return u(this.anchor,this.head)},to:function(){return ma(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var Bd={left:0,right:0,top:0,bottom:0},Bb,Wb=null,uf=0,Db=null,bd,ad,ue=0,dd=0,ya=null;O?ya=-.53:sc?ya=15:bg?ya=-.7:ve&&(ya=-1/3);var ye=function(a){var b=a.wheelDeltaX,c=a.wheelDeltaY;null==b&&a.detail&&a.axis==a.HORIZONTAL_AXIS&&(b=a.detail);null==c&&a.detail&&a.axis==a.VERTICAL_AXIS?c=a.detail:null==
c&&(c=a.wheelDelta);return{x:b,y:c}};f.wheelEventPixels=function(a){a=ye(a);a.x*=ya;a.y*=ya;return a};var Ff=new Fc,Od=null,qb=f.changeEnd=function(a){return a.text?B(a.from.line+a.text.length-1,X(a.text).length+(1==a.text.length?a.from.ch:0)):a.to};f.prototype={constructor:f,focus:function(){window.focus();wa(this);Zc(this)},setOption:function(a,b){var c=this.options,d=c[a];if(c[a]!=b||"mode"==a)c[a]=b,Kb.hasOwnProperty(a)&&ha(this,Kb[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"](md(a))},removeKeyMap:function(a){for(var b=this.state.keyMaps,c=0;c<b.length;++c)if(b[c]==a||b[c].name==a)return b.splice(c,1),!0},addOverlay:na(function(a,b){var c=a.token?a:f.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++;za(this)}),removeOverlay:na(function(a){for(var b=this.state.overlays,
c=0;c<b.length;++c){var d=b[c].modeSpec;if(d==a||"string"==typeof a&&d.name==a){b.splice(c,1);this.state.modeGen++;za(this);break}}}),indentLine:na(function(a,b,c){"string"!=typeof b&&"number"!=typeof b&&(b=null==b?this.options.smartIndent?"smart":"prev":b?"add":"subtract");Va(this.doc,a)&&qc(this,a,b,c)}),indentSelection:na(function(a){for(var b=this.doc.sel.ranges,c=-1,d=0;d<b.length;d++){var e=b[d];if(e.empty())e.head.line>c&&(qc(this,e.head.line,a,!0),c=e.head.line,d==this.doc.sel.primIndex&&
Rb(this));else{for(var g=e.from(),e=e.to(),k=Math.max(c,g.line),c=Math.min(this.lastLine(),e.line-(e.ch?0:1))+1,e=k;e<c;++e)qc(this,e,a);e=this.doc.sel.ranges;0==g.ch&&b.length==e.length&&0<e[d].from().ch&&kc(this.doc,d,new S(g,e[d].to()),lb)}}}),getTokenAt:function(a,b){return We(this,a,b)},getLineTokens:function(a,b){return We(this,B(a),b,!0)},getTokenTypeAt:function(a){a=J(this.doc,a);var b=Ye(this,G(this.doc,a.line)),c=0,d=(b.length-1)/2;a=a.ch;if(0==a)b=b[2];else for(;;){var e=c+d>>1;if((e?b[2*
e-1]:0)>=a)d=e;else if(b[2*e+1]<a)c=e+1;else{b=b[2*e+2];break}}c=b?b.indexOf("cm-overlay "):-1;return 0>c?b:0==c?null:b.slice(0,c-1)},getModeAt:function(a){var b=this.doc.mode;return b.innerMode?f.innerMode(b,this.getTokenAt(a).state).mode:b},getHelper:function(a,b){return this.getHelpers(a,b)[0]},getHelpers:function(a,b){var c=[];if(!Jb.hasOwnProperty(b))return Jb;var d=Jb[b],e=this.getModeAt(a);if("string"==typeof e[b])d[e[b]]&&c.push(d[e[b]]);else if(e[b])for(var g=0;g<e[b].length;g++){var k=d[e[b][g]];
k&&c.push(k)}else e.helperType&&d[e.helperType]?c.push(d[e.helperType]):d[e.name]&&c.push(d[e.name]);for(g=0;g<d._global.length;g++)k=d._global[g],k.pred(e,this)&&-1==ka(c,k.val)&&c.push(k.val);return c},getStateAfter:function(a,b){var c=this.doc;a=Math.max(c.first,Math.min(null==a?c.first+c.size-1:a,c.first+c.size-1));return ab(this,a+1,b)},cursorCoords:function(a,b){var c;c=this.doc.sel.primary();c=null==a?c.head:"object"==typeof a?J(this.doc,a):a?c.from():c.to();return $a(this,c,b||"page")},charCoords:function(a,
b){return Pc(this,J(this.doc,a),b||"page")},coordsChar:function(a,b){a=le(this,a,b||"page");return Gd(this,a.left,a.top)},lineAtHeight:function(a,b){a=le(this,{top:a,left:0},b||"page").top;return Ab(this.doc,a+this.display.viewOffset)},heightAtLine:function(a,b){var c=!1,d=this.doc.first+this.doc.size-1;a<this.doc.first?a=this.doc.first:a>d&&(a=d,c=!0);d=G(this.doc,a);return Y(this,d,{top:0,left:0},b||"page").top+(c?this.doc.height-Ra(d):0)},defaultTextHeight:function(){return wb(this.display)},defaultCharWidth:function(){return ec(this.display)},
setGutterMarker:na(function(a,b,c){return kd(this.doc,a,"gutter",function(a){var e=a.gutterMarkers||(a.gutterMarkers={});e[b]=c;!c&&ff(e)&&(a.gutterMarkers=null);return!0})}),clearGutter:na(function(a){var b=this,c=b.doc,d=c.first;c.iter(function(c){c.gutterMarkers&&c.gutterMarkers[a]&&(c.gutterMarkers[a]=null,bb(b,d,"gutter"),ff(c.gutterMarkers)&&(c.gutterMarkers=null));++d})}),addLineWidget:na(function(a,b,c){return Rf(this,a,b,c)}),removeLineWidget:function(a){a.clear()},lineInfo:function(a){if("number"==
typeof a){if(!Va(this.doc,a))return null;var b=a;a=G(this.doc,a);if(!a)return null}else if(b=ca(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.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,c,d,e){var g=this.display;a=$a(this,J(this.doc,a));var k=a.bottom,p=a.left;b.style.position="absolute";b.setAttribute("cm-ignore-events",
"true");g.sizer.appendChild(b);if("over"==d)k=a.top;else if("above"==d||"near"==d){var f=Math.max(g.wrapper.clientHeight,this.doc.height),q=Math.max(g.sizer.clientWidth,g.lineSpace.clientWidth);("above"==d||a.bottom+b.offsetHeight>f)&&a.top>b.offsetHeight?k=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=f&&(k=a.bottom);p+b.offsetWidth>q&&(p=q-b.offsetWidth)}b.style.top=k+"px";b.style.left=b.style.right="";"right"==e?(p=g.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?p=0:"middle"==
e&&(p=(g.sizer.clientWidth-b.offsetWidth)/2),b.style.left=p+"px");c&&(a=Vc(this,p,k,p+b.offsetWidth,k+b.offsetHeight),null!=a.scrollTop&&gc(this,a.scrollTop),null!=a.scrollLeft&&Mb(this,a.scrollLeft))},triggerOnKeyDown:na(se),triggerOnKeyPress:na(te),triggerOnKeyUp:re,execCommand:function(a){if(fd.hasOwnProperty(a))return fd[a](this)},findPosH:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);var g=0;for(a=J(this.doc,a);g<b&&(a=Td(this.doc,a,e,c,d),!a.hitSide);++g);return a},moveH:na(function(a,b){var c=
this;c.extendSelectionsBy(function(d){return c.display.shift||c.doc.extend||d.empty()?Td(c.doc,d.head,a,b,c.options.rtlMoveVisually):0>a?d.from():d.to()},Bc)}),deleteH:na(function(a,b){var c=this.doc;this.doc.sel.somethingSelected()?c.replaceSelection("",null,"+delete"):$b(this,function(d){var e=Td(c,d.head,a,b,!1);return 0>a?{from:e,to:d.head}:{from:d.head,to:e}})}),findPosV:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);var g=0;for(a=J(this.doc,a);g<b&&(a=$a(this,a,"div"),null==d?d=a.left:a.left=d,
a=Ne(this,a,e,c),!a.hitSide);++g);return a},moveV:na(function(a,b){var c=this,d=this.doc,e=[],g=!c.display.shift&&!d.extend&&d.sel.somethingSelected();d.extendSelectionsBy(function(k){if(g)return 0>a?k.from():k.to();var m=$a(c,k.head,"div");null!=k.goalColumn&&(m.left=k.goalColumn);e.push(m.left);var f=Ne(c,m,a,b);"page"==b&&k==d.sel.primary()&&id(c,null,Pc(c,f,"div").top-m.top);return f},Bc);if(e.length)for(var k=0;k<d.sel.ranges.length;k++)d.sel.ranges[k].goalColumn=e[k]}),findWordAt:function(a){var b=
G(this.doc,a.line).text,c=a.ch,d=a.ch;if(b){var e=this.getHelper(a,"wordChars");(0>a.xRel||d==b.length)&&c?--c:++d;for(var g=b.charAt(c),g=ld(g,e)?function(a){return ld(a,e)}:/\s/.test(g)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!ld(a)};0<c&&g(b.charAt(c-1));)--c;for(;d<b.length&&g(b.charAt(d));)++d}return new S(B(a.line,c),B(a.line,d))},toggleOverwrite:function(a){if(null==a||a!=this.state.overwrite)(this.state.overwrite=!this.state.overwrite)?hc(this.display.cursorDiv,"CodeMirror-overwrite"):
fc(this.display.cursorDiv,"CodeMirror-overwrite"),ga(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return eb()==this.display.input},scrollTo:na(function(a,b){null==a&&null==b||jd(this);null!=a&&(this.curOp.scrollLeft=a);null!=b&&(this.curOp.scrollTop=b)}),getScrollInfo:function(){var a=this.display.scroller;return{left:a.scrollLeft,top:a.scrollTop,height:a.scrollHeight-Aa(this)-this.display.barHeight,width:a.scrollWidth-Aa(this)-this.display.barWidth,clientHeight:hb(this),
clientWidth:ta(this)}},scrollIntoView:na(function(a,b){null==a?(a={from:this.doc.sel.primary().head,to:null},null==b&&(b=this.options.cursorScrollMargin)):"number"==typeof a?a={from:B(a,0),to:null}:null==a.from&&(a={from:a,to:null});a.to||(a.to=a.from);a.margin=b||0;if(null!=a.from.line)jd(this),this.curOp.scrollToPos=a;else{var c=Vc(this,Math.min(a.from.left,a.to.left),Math.min(a.from.top,a.to.top)-a.margin,Math.max(a.from.right,a.to.right),Math.max(a.from.bottom,a.to.bottom)+a.margin);this.scrollTo(c.scrollLeft,
c.scrollTop)}}),setSize:na(function(a,b){function c(a){return"number"==typeof a||/^\d+$/.test(String(a))?a+"px":a}var d=this;null!=a&&(d.display.wrapper.style.width=c(a));null!=b&&(d.display.wrapper.style.height=c(b));d.options.lineWrapping&&H(this);var e=d.display.viewFrom;d.doc.iter(e,d.display.viewTo,function(a){if(a.widgets)for(var b=0;b<a.widgets.length;b++)if(a.widgets[b].noHScroll){bb(d,e,"widget");break}++e});d.curOp.forceUpdate=!0;ga(d,"refresh",this)}),operation:function(a){return pb(this,
a)},refresh:na(function(){var a=this.display.cachedTextHeight;za(this);this.curOp.forceUpdate=!0;Ea(this);this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop);K(this);(null==a||.5<Math.abs(a-wb(this.display)))&&y(this);ga(this,"refresh",this)}),swapDoc:na(function(a){var b=this.doc;b.cm=null;be(this,a);Ea(this);Da(this);this.scrollTo(a.scrollLeft,a.scrollTop);this.curOp.forceScroll=!0;la(this,"swapDoc",this,b);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}};cc(f);var of=f.defaults={},Kb=f.optionHandlers={},ce=f.Init={toString:function(){return"CodeMirror.Init"}};L("value","",function(a,b){a.setValue(b)},!0);L("mode",null,function(a,b){a.doc.modeOption=b;I(a)},!0);L("indentUnit",2,I,!0);L("indentWithTabs",!1);L("smartIndent",!0);L("tabSize",4,function(a){v(a);Ea(a);za(a)},!0);L("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,
function(a,b){a.options.specialChars=new RegExp(b.source+(b.test("\t")?"":"|\t"),"g");a.refresh()},!0);L("specialCharPlaceholder",function(a){var b=F("span","\u2022","cm-invalidchar");b.title="\\u"+a.charCodeAt(0).toString(16);return b},function(a){a.refresh()},!0);L("electricChars",!0);L("rtlMoveVisually",!dg);L("wholeLineUpdateBefore",!0);L("theme","default",function(a){D(a);A(a)},!0);L("keyMap","default",function(a,b,c){b=md(b);(c=c!=f.Init&&md(c))&&c.detach&&c.detach(a,b);b.attach&&b.attach(a,
c||null)});L("extraKeys",null);L("lineWrapping",!1,function(a){a.options.lineWrapping?(hc(a.display.wrapper,"CodeMirror-wrap"),a.display.sizer.style.minWidth="",a.display.sizerWidth=null):(fc(a.display.wrapper,"CodeMirror-wrap"),h(a));y(a);za(a);Ea(a);setTimeout(function(){C(a)},100)},!0);L("gutters",[],function(a){Z(a.options);A(a)},!0);L("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?oa(a.display)+"px":"0";a.refresh()},!0);L("coverGutterNextToScrollbar",!1,function(a){C(a)},!0);L("scrollbarStyle",
"native",function(a){r(a);C(a);a.display.scrollbars.setScrollTop(a.doc.scrollTop);a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)},!0);L("lineNumbers",!1,function(a){Z(a.options);A(a)},!0);L("firstLineNumber",1,A,!0);L("lineNumberFormatter",function(a){return a},A,!0);L("showCursorWhenSelecting",!1,Sa,!0);L("resetSelectionOnContextMenu",!0);L("readOnly",!1,function(a,b){"nocursor"==b?(Gc(a),a.display.input.blur(),a.display.disabled=!0):(a.display.disabled=!1,b||Da(a))});L("disableInput",!1,function(a,
b){b||Da(a)},!0);L("dragDrop",!0);L("cursorBlinkRate",530);L("cursorScrollMargin",0);L("cursorHeight",1,Sa,!0);L("singleCursorHeightPerLine",!0,Sa,!0);L("workTime",100);L("workDelay",100);L("flattenSpans",!0,v,!0);L("addModeClass",!1,v,!0);L("pollInterval",100);L("undoDepth",200,function(a,b){a.doc.history.undoDepth=b});L("historyEventDelay",1250);L("viewportMargin",10,function(a){a.refresh()},!0);L("maxHighlightLength",1E4,v,!0);L("moveInputWithCursor",!0,function(a,b){b||(a.display.inputDiv.style.top=
a.display.inputDiv.style.left=0)});L("tabindex",null,function(a,b){a.display.input.tabIndex=b||""});L("autofocus",null);var nf=f.modes={},Cc=f.mimeModes={};f.defineMode=function(a,b){f.defaults.mode||"null"==a||(f.defaults.mode=a);2<arguments.length&&(b.dependencies=Array.prototype.slice.call(arguments,2));nf[a]=b};f.defineMIME=function(a,b){Cc[a]=b};f.resolveMode=function(a){if("string"==typeof a&&Cc.hasOwnProperty(a))a=Cc[a];else if(a&&"string"==typeof a.name&&Cc.hasOwnProperty(a.name)){var b=Cc[a.name];
"string"==typeof b&&(b={name:b});a=df(b,a);a.name=b.name}else if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return f.resolveMode("application/xml");return"string"==typeof a?{name:a}:a||{name:"null"}};f.getMode=function(a,b){b=f.resolveMode(b);var c=nf[b.name];if(!c)return f.getMode(a,"text/plain");c=c(a,b);if(Dc.hasOwnProperty(b.name)){var d=Dc[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;b.helperType&&(c.helperType=b.helperType);
if(b.modeProps)for(e in b.modeProps)c[e]=b.modeProps[e];return c};f.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}});f.defineMIME("text/plain","null");var Dc=f.modeExtensions={};f.extendMode=function(a,b){var c=Dc.hasOwnProperty(a)?Dc[a]:Dc[a]={};db(b,c)};f.defineExtension=function(a,b){f.prototype[a]=b};f.defineDocExtension=function(a,b){sa.prototype[a]=b};f.defineOption=L;var vd=[];f.defineInitHook=function(a){vd.push(a)};var Jb=f.helpers={};f.registerHelper=function(a,b,
c){Jb.hasOwnProperty(a)||(Jb[a]=f[a]={_global:[]});Jb[a][b]=c};f.registerGlobalHelper=function(a,b,c,d){f.registerHelper(a,b,d);Jb[a]._global.push({pred:c,val:d})};var Ub=f.copyState=function(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},sf=f.startState=function(a,b,c){return a.startState?a.startState(b,c):!0};f.innerMode=function(a,b){for(;a.innerMode;){var c=a.innerMode(b);if(!c||c.mode==a)break;
b=c.state;a=c.mode}return c||{mode:a,state:b}};var fd=f.commands={selectAll:function(a){a.setSelection(B(a.firstLine(),0),B(a.lastLine()),lb)},singleSelection:function(a){a.setSelection(a.getCursor("anchor"),a.getCursor("head"),lb)},killLine:function(a){$b(a,function(b){if(b.empty()){var c=G(a.doc,b.head.line).text.length;return b.head.ch==c&&b.head.line<a.lastLine()?{from:b.head,to:B(b.head.line+1,0)}:{from:b.head,to:B(b.head.line,c)}}return{from:b.from(),to:b.to()}})},deleteLine:function(a){$b(a,
function(b){return{from:B(b.from().line,0),to:J(a.doc,B(b.to().line+1,0))}})},delLineLeft:function(a){$b(a,function(a){return{from:B(a.from().line,0),to:a.from()}})},delWrappedLineLeft:function(a){$b(a,function(b){var c=a.charCoords(b.head,"div").top+5;return{from:a.coordsChar({left:0,top:c},"div"),to:b.from()}})},delWrappedLineRight:function(a){$b(a,function(b){var c=a.charCoords(b.head,"div").top+5,c=a.coordsChar({left:a.display.lineDiv.offsetWidth+100,top:c},"div");return{from:b.from(),to:c}})},
undo:function(a){a.undo()},redo:function(a){a.redo()},undoSelection:function(a){a.undoSelection()},redoSelection:function(a){a.redoSelection()},goDocStart:function(a){a.extendSelection(B(a.firstLine(),0))},goDocEnd:function(a){a.extendSelection(B(a.lastLine()))},goLineStart:function(a){a.extendSelectionsBy(function(b){return hf(a,b.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(a){a.extendSelectionsBy(function(b){return jf(a,b.head)},{origin:"+move",bias:1})},goLineEnd:function(a){a.extendSelectionsBy(function(b){b=
b.head.line;for(var c,d=G(a.doc,b);c=zb(d,!1);)d=c.find(1,!0).line,b=null;c=(c=Xa(d))?c[0].level%2?Tc(d):Uc(d):d.text.length;return B(null==b?ca(d):b,c)},{origin:"+move",bias:-1})},goLineRight:function(a){a.extendSelectionsBy(function(b){b=a.charCoords(b.head,"div").top+5;return a.coordsChar({left:a.display.lineDiv.offsetWidth+100,top:b},"div")},Bc)},goLineLeft:function(a){a.extendSelectionsBy(function(b){b=a.charCoords(b.head,"div").top+5;return a.coordsChar({left:0,top:b},"div")},Bc)},goLineLeftSmart:function(a){a.extendSelectionsBy(function(b){var c=
a.charCoords(b.head,"div").top+5,c=a.coordsChar({left:0,top:c},"div");return c.ch<a.getLine(c.line).search(/\S/)?jf(a,b.head):c},Bc)},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")},insertSoftTab:function(a){for(var b=[],c=a.listSelections(),d=a.options.tabSize,e=0;e<c.length;e++){var g=c[e].from(),g=La(a.getLine(g.line),g.ch,d);b.push(Array(d-g%d+1).join(" "))}a.replaceSelections(b)},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):a.execCommand("insertTab")},transposeChars:function(a){pb(a,function(){for(var b=a.listSelections(),c=[],d=0;d<b.length;d++){var e=
b[d].head,g=G(a.doc,e.line).text;if(g)if(e.ch==g.length&&(e=new B(e.line,e.ch-1)),0<e.ch)e=new B(e.line,e.ch+1),a.replaceRange(g.charAt(e.ch-1)+g.charAt(e.ch-2),B(e.line,e.ch-2),e,"+transpose");else if(e.line>a.doc.first){var k=G(a.doc,e.line-1).text;k&&a.replaceRange(g.charAt(0)+"\n"+k.charAt(k.length-1),B(e.line-1,k.length-1),B(e.line,1),"+transpose")}c.push(new S(e,e))}a.setSelections(c)})},newlineAndIndent:function(a){pb(a,function(){for(var b=a.listSelections().length,c=0;c<b;c++){var d=a.listSelections()[c];
a.replaceRange("\n",d.anchor,d.head,"+input");a.indentLine(d.from().line+1,null,!0);Rb(a)}})},toggleOverwrite:function(a){a.toggleOverwrite()}},rb=f.keyMap={};rb.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"};
rb.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","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","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"};rb.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"};rb.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","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","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]};rb["default"]=Ha?rb.macDefault:rb.pcDefault;f.normalizeKeyMap=function(a){var b={},c;for(c in a)if(a.hasOwnProperty(c)){var d=a[c];if(!/^(name|fallthrough|(de|at)tach)$/.test(c)){if("..."!=d)for(var e=Xb(c.split(" "),Mf),g=0;g<
e.length;g++){var k,f;g==e.length-1?(f=c,k=d):(f=e.slice(0,g+1).join(" "),k="...");var q=b[f];if(!q)b[f]=k;else if(q!=k)throw Error("Inconsistent bindings for "+f);}delete a[c]}}for(var l in b)a[l]=b[l];return a};var tc=f.lookupKey=function(a,b,c,d){b=md(b);var e=b.call?b.call(a,d):b[a];if(!1===e)return"nothing";if("..."===e)return"multi";if(null!=e&&c(e))return"handled";if(b.fallthrough){if("[object Array]"!=Object.prototype.toString.call(b.fallthrough))return tc(a,b.fallthrough,c,d);for(e=0;e<b.fallthrough.length;e++){var g=
tc(a,b.fallthrough[e],c,d);if(g)return g}}},Ef=f.isModifierKey=function(a){a="string"==typeof a?a:sb[a.keyCode];return"Ctrl"==a||"Alt"==a||"Shift"==a||"Mod"==a},Gf=f.keyName=function(a,b){if(Na&&34==a.keyCode&&a["char"])return!1;var c=sb[a.keyCode],d=c;if(null==d||a.altGraphKey)return!1;a.altKey&&"Alt"!=c&&(d="Alt-"+d);(mf?a.metaKey:a.ctrlKey)&&"Ctrl"!=c&&(d="Ctrl-"+d);(mf?a.ctrlKey:a.metaKey)&&"Cmd"!=c&&(d="Cmd-"+d);!b&&a.shiftKey&&"Shift"!=c&&(d="Shift-"+d);return d};f.fromTextArea=function(a,b){function c(){a.value=
q.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=eb();b.autofocus=d==a||null!=a.getAttribute("autofocus")&&d==document.body}if(a.form&&(M(a.form,"submit",c),!b.leaveSubmitMethodAlone)){var e=a.form,g=e.submit;try{var k=e.submit=function(){c();e.submit=g;e.submit();e.submit=k}}catch(p){}}a.style.display="none";var q=f(function(b){a.parentNode.insertBefore(b,a.nextSibling)},
b);q.save=c;q.getTextArea=function(){return a};q.toTextArea=function(){q.toTextArea=isNaN;c();a.parentNode.removeChild(q.getWrapperElement());a.style.display="";a.form&&(cb(a.form,"submit",c),"function"==typeof a.form.submit&&(a.form.submit=g))};return q};var qd=f.StringStream=function(a,b){this.pos=this.start=0;this.string=a;this.tabSize=b||8;this.lineStart=this.lastColumnPos=this.lastColumnValue=0};qd.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==
this.lineStart},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=La(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start);return this.lastColumnValue-(this.lineStart?La(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return La(this.string,null,this.tabSize)-(this.lineStart?La(this.string,
this.lineStart,this.tabSize):0)},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)},hideFirstChars:function(a,b){this.lineStart+=a;try{return b()}finally{this.lineStart-=a}}};var Gb=f.TextMarker=
function(a,b){this.lines=[];this.type=b;this.doc=a};cc(Gb);Gb.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;b&&tb(a);if(Ka(this,"clear")){var c=this.find();c&&la(this,"clear",c.from,c.to)}for(var d=c=null,e=0;e<this.lines.length;++e){var g=this.lines[e],k=wc(g.markedSpans,this);a&&!this.collapsed?bb(a,ca(g),"text"):a&&(null!=k.to&&(d=ca(g)),null!=k.from&&(c=ca(g)));for(var f=g,q=g.markedSpans,l=k,h=void 0,u=0;u<q.length;++u)q[u]!=l&&(h||(h=[])).push(q[u]);
f.markedSpans=h;null==k.from&&this.collapsed&&!xb(this.doc,g)&&a&&Qa(g,wb(a.display))}if(a&&this.collapsed&&!a.options.lineWrapping)for(e=0;e<this.lines.length;++e)g=Ya(this.lines[e]),k=w(g),k>a.display.maxLineLength&&(a.display.maxLine=g,a.display.maxLineLength=k,a.display.maxLineChanged=!0);null!=c&&a&&this.collapsed&&za(a,c,d+1);this.lines.length=0;this.explicitlyCleared=!0;this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&Mc(a.doc));a&&la(a,"markerCleared",a,this);b&&vb(a);this.parent&&
this.parent.clear()}};Gb.prototype.find=function(a,b){null==a&&"bookmark"==this.type&&(a=1);for(var c,d,e=0;e<this.lines.length;++e){var g=this.lines[e],k=wc(g.markedSpans,this);if(null!=k.from&&(c=B(b?g:ca(g),k.from),-1==a))return c;if(null!=k.to&&(d=B(b?g:ca(g),k.to),1==a))return d}return c&&{from:c,to:d}};Gb.prototype.changed=function(){var a=this.find(-1,!0),b=this,c=this.doc.cm;a&&c&&pb(c,function(){var d=a.line,e=ca(a.line);if(e=Rc(c,e))k(e),c.curOp.selectionChanged=c.curOp.forceUpdate=!0;c.curOp.updateMaxLine=
!0;xb(b.doc,d)||null==b.height||(e=b.height,b.height=null,(e=oc(b)-e)&&Qa(d,d.height+e))})};Gb.prototype.attachLine=function(a){if(!this.lines.length&&this.doc.cm){var b=this.doc.cm.curOp;b.maybeHiddenMarkers&&-1!=ka(b.maybeHiddenMarkers,this)||(b.maybeUnhiddenMarkers||(b.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(a)};Gb.prototype.detachLine=function(a){this.lines.splice(ka(this.lines,a),1);!this.lines.length&&this.doc.cm&&(a=this.doc.cm.curOp,(a.maybeHiddenMarkers||(a.maybeHiddenMarkers=
[])).push(this))};var Of=0,od=f.SharedTextMarker=function(a,b){this.markers=a;this.primary=b;for(var c=0;c<a.length;++c)a[c].parent=this};cc(od);od.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var a=0;a<this.markers.length;++a)this.markers[a].clear();la(this,"clear")}};od.prototype.find=function(a,b){return this.primary.find(a,b)};var pd=f.LineWidget=function(a,b,c){if(c)for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.cm=a;this.node=b};cc(pd);pd.prototype.clear=
function(){var a=this.cm,b=this.line.widgets,c=this.line,d=ca(c);if(null!=d&&b){for(var e=0;e<b.length;++e)b[e]==this&&b.splice(e--,1);b.length||(c.widgets=null);var g=oc(this);pb(a,function(){var b=-g;Ra(c)<(a.curOp&&a.curOp.scrollTop||a.doc.scrollTop)&&id(a,null,b);bb(a,d,"widget");Qa(c,Math.max(0,c.height-g))})}};pd.prototype.changed=function(){var a=this.height,b=this.cm,c=this.line;this.height=null;var d=oc(this)-a;d&&pb(b,function(){b.curOp.forceUpdate=!0;Ra(c)<(b.curOp&&b.curOp.scrollTop||
b.doc.scrollTop)&&id(b,null,d);Qa(c,c.height+d)})};var Hb=f.Line=function(a,b,c){this.text=a;Se(this,b);this.height=c?c(this):1};cc(Hb);Hb.prototype.lineNo=function(){return ca(this)};var Tf={},Sf={};xc.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 g=e;g.parent=null;Re(g);la(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.push.apply(a,this.lines)},insertInner:function(a,b,c){this.height+=
c;this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(a=0;a<b.length;++a)b[a].parent=this},iterN:function(a,b,c){for(b=a+b;a<b;++a)if(c(this.lines[a]))return!0}};yc.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 g=Math.min(b,e-a),k=d.height;d.removeInner(a,g);this.height-=k-d.height;e==g&&(this.children.splice(c--,1),d.parent=null);if(0==(b-=g))break;
a=0}else a-=e}25>this.size-b&&(1<this.children.length||!(this.children[0]instanceof xc))&&(c=[],this.collapse(c),this.children=[new xc(c)],this.children[0].parent=this)},collapse:function(a){for(var b=0;b<this.children.length;++b)this.children[b].collapse(a)},insertInner:function(a,b,c){this.size+=b.length;this.height+=c;for(var d=0;d<this.children.length;++d){var e=this.children[d],g=e.chunkSize();if(a<=g){e.insertInner(a,b,c);if(e.lines&&50<e.lines.length){for(;50<e.lines.length;)a=e.lines.splice(e.lines.length-
25,25),a=new xc(a),e.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 yc(b);if(a.parent){a.size-=b.size;a.height-=b.height;var c=ka(a.parent.children,a);a.parent.children.splice(c+1,0,b)}else c=new yc(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;d<this.children.length;++d){var e=this.children[d],g=e.chunkSize();if(a<g){g=Math.min(b,g-a);if(e.iterN(a,g,c))return!0;if(0==(b-=g))break;a=0}else a-=g}}};var eg=0,sa=f.Doc=function(a,b,c){if(!(this instanceof sa))return new sa(a,b,c);null==c&&(c=0);yc.call(this,[new xc([new Hb("",null)])]);this.first=c;this.scrollTop=this.scrollLeft=0;this.cantEdit=!1;this.cleanGeneration=1;this.frontier=c;c=B(c,0);this.sel=Ua(c);this.history=new rd(null);this.id=++eg;this.modeOption=b;"string"==typeof a&&(a=
Cb(a));Sd(this,{from:c,to:c,text:a});fa(this,Ua(c),lb)};sa.prototype=df(yc.prototype,{constructor:sa,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;d<b.length;++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=Yd(this,this.first,this.first+this.size);return!1===a?b:b.join(a||"\n")},setValue:qa(function(a){var b=B(this.first,
0),c=this.first+this.size-1;Yb(this,{from:b,to:B(c,G(this,c).text.length),text:Cb(a),origin:"setValue"},!0);fa(this,Ua(b))}),replaceRange:function(a,b,c,d){b=J(this,b);c=c?J(this,c):b;cd(this,a,b,c,d)},getRange:function(a,b,c){a=vc(this,J(this,a),J(this,b));return!1===c?a:a.join(c||"\n")},getLine:function(a){return(a=this.getLineHandle(a))&&a.text},getLineHandle:function(a){if(Va(this,a))return G(this,a)},getLineNumber:function(a){return ca(a)},getLineHandleVisualStart:function(a){"number"==typeof a&&
(a=G(this,a));return Ya(a)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(a){return J(this,a)},getCursor:function(a){var b=this.sel.primary();return null==a||"head"==a?b.head:"anchor"==a?b.anchor:"end"==a||"to"==a||!1===a?b.to():b.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:qa(function(a,b,c){a=J(this,"number"==
typeof a?B(a,b||0):a);fa(this,Ua(a,null),c)}),setSelection:qa(function(a,b,c){var d=J(this,a);a=J(this,b||a);fa(this,Ua(d,a),c)}),extendSelection:qa(function(a,b,c){xa(this,J(this,a),b&&J(this,b),c)}),extendSelections:qa(function(a,b){for(var c=[],d=0;d<a.length;d++)c[d]=J(this,a[d]);Pb(this,c)}),extendSelectionsBy:qa(function(a,b){Pb(this,Xb(this.sel.ranges,a),b)}),setSelections:qa(function(a,b,c){if(a.length){for(var d=0,e=[];d<a.length;d++)e[d]=new S(J(this,a[d].anchor),J(this,a[d].head));null==
b&&(b=Math.min(a.length-1,this.sel.primIndex));fa(this,va(e,b),c)}}),addSelection:qa(function(a,b,c){var d=this.sel.ranges.slice(0);d.push(new S(J(this,a),J(this,b||a)));fa(this,va(d,d.length-1),c)}),getSelection:function(a){for(var b=this.sel.ranges,c,d=0;d<b.length;d++){var e=vc(this,b[d].from(),b[d].to());c=c?c.concat(e):e}return!1===a?c:c.join(a||"\n")},getSelections:function(a){for(var b=[],c=this.sel.ranges,d=0;d<c.length;d++){var e=vc(this,c[d].from(),c[d].to());!1!==a&&(e=e.join(a||"\n"));
b[d]=e}return b},replaceSelection:function(a,b,c){for(var d=[],e=0;e<this.sel.ranges.length;e++)d[e]=a;this.replaceSelections(d,b,c||"+input")},replaceSelections:qa(function(a,b,c){for(var d=[],e=this.sel,g=0;g<e.ranges.length;g++){var k=e.ranges[g];d[g]={from:k.from(),to:k.to(),text:Cb(a[g]),origin:c}}if(g=b&&"end"!=b){g=[];c=a=B(this.first,0);for(e=0;e<d.length;e++){var f=d[e],k=Ce(f.from,a,c),q=Ce(qb(f),a,c);a=f.to;c=q;"around"==b?(f=this.sel.ranges[e],f=0>N(f.head,f.anchor),g[e]=new S(f?q:k,f?
k:q)):g[e]=new S(k,k)}g=new Ja(g,this.sel.primIndex)}b=g;for(g=d.length-1;0<=g;g--)Yb(this,d[g]);b?kb(this,b):this.cm&&Rb(this.cm)}),undo:qa(function(){hd(this,"undo")}),redo:qa(function(){hd(this,"redo")}),undoSelection:qa(function(){hd(this,"undo",!0)}),redoSelection:qa(function(){hd(this,"redo",!0)}),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){for(var a=this.history,b=0,c=0,d=0;d<a.done.length;d++)a.done[d].ranges||++b;for(d=0;d<a.undone.length;d++)a.undone[d].ranges||
++c;return{undo:b,redo:c}},clearHistory:function(){this.history=new rd(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(a){a&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null);return this.history.generation},isClean:function(a){return this.history.generation==(a||this.cleanGeneration)},getHistory:function(){return{done:bc(this.history.done),undone:bc(this.history.undone)}},setHistory:function(a){var b=
this.history=new rd(this.history.maxGeneration);b.done=bc(a.done.slice(0),null,!0);b.undone=bc(a.undone.slice(0),null,!0)},addLineClass:qa(function(a,b,c){return kd(this,a,"gutter"==b?"gutter":"class",function(a){var e="text"==b?"textClass":"background"==b?"bgClass":"gutter"==b?"gutterClass":"wrapClass";if(a[e]){if(Ac(c).test(a[e]))return!1;a[e]+=" "+c}else a[e]=c;return!0})}),removeLineClass:qa(function(a,b,c){return kd(this,a,"gutter"==b?"gutter":"class",function(a){var e="text"==b?"textClass":
"background"==b?"bgClass":"gutter"==b?"gutterClass":"wrapClass",g=a[e];if(g)if(null==c)a[e]=null;else{var k=g.match(Ac(c));if(!k)return!1;var f=k.index+k[0].length;a[e]=g.slice(0,k.index)+(k.index&&f!=g.length?" ":"")+g.slice(f)||null}else return!1;return!0})}),markText:function(a,b,c){return ac(this,J(this,a),J(this,b),c,"range")},setBookmark:function(a,b){var c={replacedWith:b&&(null==b.nodeType?b.widget:b),insertLeft:b&&b.insertLeft,clearWhenEmpty:!1,shared:b&&b.shared};a=J(this,a);return ac(this,
a,a,c,"bookmark")},findMarksAt:function(a){a=J(this,a);var b=[],c=G(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},findMarks:function(a,b,c){a=J(this,a);b=J(this,b);var d=[],e=a.line;this.iter(a.line,b.line+1,function(g){if(g=g.markedSpans)for(var k=0;k<g.length;k++){var f=g[k];e==a.line&&a.ch>f.to||null==f.from&&e!=a.line||e==b.line&&f.from>b.ch||c&&!c(f.marker)||d.push(f.marker.parent||
f.marker)}++e});return d},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 J(this,B(c,b))},indexFromPos:function(a){a=J(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 sa(Yd(this,
this.first,this.first+this.size),this.modeOption,this.first);b.scrollTop=this.scrollTop;b.scrollLeft=this.scrollLeft;b.sel=this.sel;b.extend=!1;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 sa(Yd(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}];a=Pe(this);for(c=0;c<a.length;c++){var d=a[c],e=d.find(),g=b.clipPos(e.from),e=b.clipPos(e.to);N(g,e)&&(g=ac(b,g,e,d.primary,d.primary.type),d.markers.push(g),g.parent=d)}return b},unlinkDoc:function(a){a instanceof f&&(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);Pf(Pe(this));break}if(a.history==this.history){var c=[a.id];Fb(a,function(a){c.push(a.id)},
!0);a.history=new rd(null);a.history.done=bc(this.history.done,c);a.history.undone=bc(this.history.undone,c)}},iterLinkedDocs:function(a){Fb(this,a)},getMode:function(){return this.mode},getEditor:function(){return this.cm}});sa.prototype.eachLine=sa.prototype.iter;var fg=["iter","insert","remove","copy","getEditor"],Ec;for(Ec in sa.prototype)sa.prototype.hasOwnProperty(Ec)&&0>ka(fg,Ec)&&(f.prototype[Ec]=function(a){return function(){return a.apply(this.doc,arguments)}}(sa.prototype[Ec]));cc(sa);
var ra=f.e_preventDefault=function(a){a.preventDefault?a.preventDefault():a.returnValue=!1},gg=f.e_stopPropagation=function(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0},Jd=f.e_stop=function(a){ra(a);gg(a)},M=f.on=function(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))},cb=f.off=function(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}},ga=f.signal=function(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)},zc=null,de=30,ze=f.Pass={toString:function(){return"CodeMirror.Pass"}},lb={scroll:!1},Md={origin:"*mouse"},Bc={origin:"+move"};Fc.prototype.set=function(a,b){clearTimeout(this.id);this.id=setTimeout(b,a)};var La=f.countColumn=function(a,b,c,d,e){null==
b&&(b=a.search(/[^\s\u00a0]/),-1==b&&(b=a.length));d=d||0;for(e=e||0;;){var g=a.indexOf("\t",d);if(0>g||g>=b)return e+(b-d);e+=g-d;e+=c-e%c;d=g+1}},sd=[""],rc=function(a){a.select()};dc?rc=function(a){a.selectionStart=0;a.selectionEnd=a.value.length}:O&&(rc=function(a){try{a.select()}catch(b){}});[].indexOf&&(ka=function(a,b){return a.indexOf(b)});[].map&&(Xb=function(a,b){return a.map(b)});var hg=/[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,
ef=f.isWordChar=function(a){return/\w/.test(a)||"\u0080"<a&&(a.toUpperCase()!=a.toLowerCase()||hg.test(a))},$f=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/,
Vb;Vb=document.createRange?function(a,b,c){var d=document.createRange();d.setEnd(a,c);d.setStart(a,b);return d}:function(a,b,c){var d=document.body.createTextRange();try{d.moveToElementText(a.parentNode)}catch(e){return d}d.collapse(!0);d.moveEnd("character",c);d.moveStart("character",b);return d};O&&11>V&&(eb=function(){try{return document.activeElement}catch(a){return document.body}});var fc=f.rmClass=function(a,b){var c=a.className,d=Ac(b).exec(c);if(d){var e=c.slice(d.index+d[0].length);a.className=
c.slice(0,d.index)+(e?d[1]+e:"")}},hc=f.addClass=function(a,b){var c=a.className;Ac(b).test(c)||(a.className+=(c?" ":"")+b)},ae=!1,Af=function(){if(O&&9>V)return!1;var a=F("div");return"draggable"in a||"dragDrop"in a}(),Zd,Wd,Cb=f.splitLines=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 g=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),k=g.indexOf("\r");-1!=k?(c.push(g.slice(0,k)),b+=k+1):(c.push(g),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)},
wf=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},ne=function(){var a=F("div");if("oncopy"in a)return!0;a.setAttribute("oncopy","return;");return"function"==typeof a.oncopy}(),Cd=null,sb={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:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};f.keyNames=sb;(function(){for(var a=0;10>a;a++)sb[a+48]=sb[a+96]=String(a);for(a=65;90>=
a;a++)sb[a]=String.fromCharCode(a);for(a=1;12>=a;a++)sb[a+111]=sb[a+63235]="F"+a})();var pc,Yf=function(){function a(a){return 247>=a?"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(a):1424<=a&&1524>=a?"R":1536<=a&&1773>=a?"rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm".charAt(a-
1536):1774<=a&&2220>=a?"r":8192<=a&&8203>=a?"w":8204==a?"b":"L"}function b(a,b,c){this.level=a;this.from=b;this.to=c}var c=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,d=/[stwN]/,e=/[LRr]/,g=/[Lb1n]/,k=/[1n]/;return function(f){if(!c.test(f))return!1;for(var q=f.length,l=[],h=0,u;h<q;++h)l.push(a(f.charCodeAt(h)));for(var h=0,n="L";h<q;++h)u=l[h],"m"==u?l[h]=n:n=u;h=0;for(n="L";h<q;++h)u=l[h],"1"==u&&"r"==n?l[h]="n":e.test(u)&&(n=u,"r"==u&&(l[h]="R"));h=1;for(n=l[0];h<q-1;++h)u=l[h],"+"==u&&"1"==n&&
"1"==l[h+1]?l[h]="1":","!=u||n!=l[h+1]||"1"!=n&&"n"!=n||(l[h]=n),n=u;for(h=0;h<q;++h)if(u=l[h],","==u)l[h]="N";else if("%"==u){for(n=h+1;n<q&&"%"==l[n];++n);var H=h&&"!"==l[h-1]||n<q&&"1"==l[n]?"1":"N";for(u=h;u<n;++u)l[u]=H;h=n-1}h=0;for(n="L";h<q;++h)u=l[h],"L"==n&&"1"==u?l[h]="L":e.test(u)&&(n=u);for(h=0;h<q;++h)if(d.test(l[h])){for(n=h+1;n<q&&d.test(l[n]);++n);u="L"==(n<q?l[n]:"L");H="L"==(h?l[h-1]:"L")||u?"L":"R";for(u=h;u<n;++u)l[u]=H;h=n-1}for(var n=[],r,h=0;h<q;)if(g.test(l[h])){u=h;for(++h;h<
q&&g.test(l[h]);++h);n.push(new b(0,u,h))}else{var Y=h,H=n.length;for(++h;h<q&&"L"!=l[h];++h);for(u=Y;u<h;)if(k.test(l[u])){Y<u&&n.splice(H,0,new b(1,Y,u));Y=u;for(++u;u<h&&k.test(l[u]);++u);n.splice(H,0,new b(2,Y,u));Y=u}else++u;Y<h&&n.splice(H,0,new b(1,Y,h))}1==n[0].level&&(r=f.match(/^\s+/))&&(n[0].from=r[0].length,n.unshift(new b(0,0,r[0].length)));1==X(n).level&&(r=f.match(/\s+$/))&&(X(n).to-=r[0].length,n.push(new b(0,q-r[0].length,q)));n[0].level!=X(n).level&&n.push(new b(n[0].level,q,q));
return n}}();f.version="4.10.0";return f});
(function(f){"object"==typeof exports&&"object"==typeof module?f(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],f):f(CodeMirror)})(function(f){f.defineMode("xml",function(Q,I){function v(f,l){function h(n){l.tokenize=n;return n(f,l)}var n=f.next();if("<"==n){if(f.eat("!"))return f.eat("[")?f.match("CDATA[")?h(D("atom","]]\x3e")):null:f.match("--")?h(D("comment","--\x3e")):f.match("DOCTYPE",!0,!0)?(f.eatWhile(/[\w\._\-]/),h(A(1))):null;if(f.eat("?"))return f.eatWhile(/[\w\._\-]/),
l.tokenize=D("meta","?>"),"meta";ua=f.eat("/")?"closeTag":"openTag";l.tokenize=z;return"tag bracket"}if("&"==n)return(f.eat("#")?f.eat("x")?f.eatWhile(/[a-fA-F\d]/)&&f.eat(";"):f.eatWhile(/[\d]/)&&f.eat(";"):f.eatWhile(/[\w\.\-:]/)&&f.eat(";"))?"atom":"error";f.eatWhile(/[^&<]/);return null}function z(f,l){var n=f.next();if(">"==n||"/"==n&&f.eat(">"))return l.tokenize=v,ua=">"==n?"endTag":"selfcloseTag","tag bracket";if("="==n)return ua="equals",null;if("<"==n)return l.tokenize=v,l.state=h,l.tagName=
l.tagStart=null,(n=l.tokenize(f,l))?n+" tag error":"tag error";if(/[\'\"]/.test(n))return l.tokenize=y(n),l.stringStartCol=f.column(),l.tokenize(f,l);f.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);return"word"}function y(f){var l=function(l,h){for(;!l.eol();)if(l.next()==f){h.tokenize=z;break}return"string"};l.isInAttribute=!0;return l}function D(f,l){return function(h,n){for(;!h.eol();){if(h.match(l)){n.tokenize=v;break}h.next()}return f}}function A(f){return function(l,h){for(var n;null!=(n=
l.next());){if("<"==n)return h.tokenize=A(f+1),h.tokenize(l,h);if(">"==n)if(1==f){h.tokenize=v;break}else return h.tokenize=A(f-1),h.tokenize(l,h)}return"meta"}}function P(f,l,h){this.prev=f.context;this.tagName=l;this.indent=f.indented;this.startOfLine=h;if(oa.doNotIndent.hasOwnProperty(l)||f.context&&f.context.noIndent)this.noIndent=!0}function K(f){f.context&&(f.context=f.context.prev)}function w(f,l){for(var h;f.context;){h=f.context.tagName;if(!oa.contextGrabbers.hasOwnProperty(h)||!oa.contextGrabbers[h].hasOwnProperty(l))break;
K(f)}}function h(f,n,r){return"openTag"==f?(r.tagStart=n.column(),Z):"closeTag"==f?l:h}function Z(f,l,h){if("word"==f)return h.tagName=l.current(),aa="tag",r;aa="error";return Z}function l(f,l,h){if("word"==f){f=l.current();h.context&&h.context.tagName!=f&&oa.implicitlyClosed.hasOwnProperty(h.context.tagName)&&K(h);if(h.context&&h.context.tagName==f)return aa="tag",T;aa="tag error";return n}aa="error";return n}function T(f,l,n){if("endTag"!=f)return aa="error",T;K(n);return h}function n(f,l,h){aa=
"error";return T(f,l,h)}function r(f,l,n){if("word"==f)return aa="attribute",C;if("endTag"==f||"selfcloseTag"==f){l=n.tagName;var T=n.tagStart;n.tagName=n.tagStart=null;"selfcloseTag"==f||oa.autoSelfClosers.hasOwnProperty(l)?w(n,l):(w(n,l),n.context=new P(n,l,T==n.indented));return h}aa="error";return r}function C(f,l,h){if("equals"==f)return ea;oa.allowMissing||(aa="error");return r(f,l,h)}function ea(f,l,h){if("string"==f)return R;if("word"==f&&oa.allowUnquoted)return aa="string",r;aa="error";return r(f,
l,h)}function R(f,l,h){return"string"==f?R:r(f,l,h)}var ja=Q.indentUnit,ub=I.multilineTagIndentFactor||1,Fa=I.multilineTagIndentPastTag;null==Fa&&(Fa=!0);var oa=I.htmlMode?{autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},
li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0}:
{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1},Za=I.alignCDATA,ua,aa;return{startState:function(){return{tokenize:v,state:h,indented:0,tagName:null,tagStart:null,context:null}},token:function(f,l){!l.tagName&&f.sol()&&(l.indented=f.indentation());if(f.eatSpace())return null;ua=null;var h=l.tokenize(f,l);(h||ua)&&"comment"!=h&&(aa=null,l.state=l.state(ua||h,f,l),aa&&(h="error"==aa?h+" error":aa));return h},indent:function(l,h,
n){var r=l.context;if(l.tokenize.isInAttribute)return l.tagStart==l.indented?l.stringStartCol+1:l.indented+ja;if(r&&r.noIndent)return f.Pass;if(l.tokenize!=z&&l.tokenize!=v)return n?n.match(/^(\s*)/)[0].length:0;if(l.tagName)return Fa?l.tagStart+l.tagName.length+2:l.tagStart+ja*ub;if(Za&&/<!\[CDATA\[/.test(h))return 0;if((l=h&&/^<(\/)?([\w_:\.-]*)/.exec(h))&&l[1])for(;r;)if(r.tagName==l[2]){r=r.prev;break}else if(oa.implicitlyClosed.hasOwnProperty(r.tagName))r=r.prev;else break;else if(l)for(;r;)if((h=
oa.contextGrabbers[r.tagName])&&h.hasOwnProperty(l[2]))r=r.prev;else break;for(;r&&!r.startOfLine;)r=r.prev;return r?r.indent+ja:0},electricInput:/<\/[\s\w:]+>$/,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",configuration:I.htmlMode?"html":"xml",helperType:I.htmlMode?"html":"xml"}});f.defineMIME("text/xml","xml");f.defineMIME("application/xml","xml");f.mimeModes.hasOwnProperty("text/html")||f.defineMIME("text/html",{name:"xml",htmlMode:!0})});
(function(f){"object"==typeof exports&&"object"==typeof module?f(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],f):f(CodeMirror)})(function(f){f.defineMode("javascript",function(Q,I){function v(k,f,l){ta=k;hb=l;return f}function z(k,f){var l=k.next();if('"'==l||"'"==l)return f.tokenize=y(l),f.tokenize(k,f);if("."==l&&k.match(/^\d+(?:[eE][+\-]?\d+)?/))return v("number","number");if("."==l&&k.match(".."))return v("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(l))return v(l);
if("="==l&&k.eat(">"))return v("=>","operator");if("0"==l&&k.eat(/x/i))return k.eatWhile(/[\da-f]/i),v("number","number");if(/\d/.test(l))return k.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),v("number","number");if("/"==l){if(k.eat("*"))return f.tokenize=D,D(k,f);if(k.eat("/"))return k.skipToEnd(),v("comment","comment");if("operator"==f.lastType||"keyword c"==f.lastType||"sof"==f.lastType||/^[\[{}\(,;:]$/.test(f.lastType)){a:for(var l=!1,h,q=!1;null!=(h=k.next());){if(!l){if("/"==h&&!q)break a;"["==
h?q=!0:q&&"]"==h&&(q=!1)}l=!l&&"\\"==h}k.eatWhile(/[gimy]/);return v("regexp","string-2")}k.eatWhile(Sb);return v("operator","operator",k.current())}if("`"==l)return f.tokenize=A,A(k,f);if("#"==l)return k.skipToEnd(),v("error","error");if(Sb.test(l))return k.eatWhile(Sb),v("operator","operator",k.current());if(ab.test(l))return k.eatWhile(ab),l=k.current(),(h=Lb.propertyIsEnumerable(l)&&Lb[l])&&"."!=f.lastType?v(h.type,h.style,l):v("variable","variable",l)}function y(k){return function(f,l){var h=
!1,q;if(Pa&&"@"==f.peek()&&f.match(Aa))return l.tokenize=z,v("jsonld-keyword","meta");for(;null!=(q=f.next())&&(q!=k||h);)h=!h&&"\\"==q;h||(l.tokenize=z);return v("string","string")}}function D(k,f){for(var l=!1,h;h=k.next();){if("/"==h&&l){f.tokenize=z;break}l="*"==h}return v("comment","comment")}function A(k,f){for(var l=!1,h;null!=(h=k.next());){if(!l&&("`"==h||"$"==h&&k.eat("{"))){f.tokenize=z;break}l=!l&&"\\"==h}return v("quasi","string-2",k.current())}function P(k,f){f.fatArrowAt&&(f.fatArrowAt=
null);var l=k.string.indexOf("=>",k.start);if(!(0>l)){for(var h=0,q=!1,l=l-1;0<=l;--l){var n=k.string.charAt(l),u="([{}])".indexOf(n);if(0<=u&&3>u){if(!h){++l;break}if(0==--h)break}else if(3<=u&&6>u)++h;else if(ab.test(n))q=!0;else{if(/["'\/]/.test(n))return;if(q&&!h){++l;break}}}q&&!h&&(f.fatArrowAt=l)}}function K(k,f,l,h,q,n){this.indented=k;this.column=f;this.type=l;this.prev=q;this.info=n;null!=h&&(this.align=h)}function w(){for(var k=arguments.length-1;0<=k;k--)E.cc.push(arguments[k])}function h(){w.apply(null,
arguments);return!0}function Z(k){function f(l){for(;l;l=l.next)if(l.name==k)return!0;return!1}var l=E.state;l.context?(E.marked="def",f(l.localVars)||(l.localVars={name:k,next:l.localVars})):!f(l.globalVars)&&I.globalVars&&(l.globalVars={name:k,next:l.globalVars})}function l(){E.state.context={prev:E.state.context,vars:E.state.localVars};E.state.localVars=mc}function T(){E.state.localVars=E.state.context.vars;E.state.context=E.state.context.prev}function n(k,f){var l=function(){var l=E.state,h=l.indented;
if("stat"==l.lexical.type)h=l.lexical.indented;else for(var q=l.lexical;q&&")"==q.type&&q.align;q=q.prev)h=q.indented;l.lexical=new K(h,E.stream.column(),k,null,l.lexical,f)};l.lex=!0;return l}function r(){var k=E.state;k.lexical.prev&&(")"==k.lexical.type&&(k.indented=k.lexical.indented),k.lexical=k.lexical.prev)}function C(k){function f(l){return l==k?h():";"==k?w():h(f)}return f}function ea(k,f){return"var"==k?h(n("vardef",f.length),pa,C(";"),r):"keyword a"==k?h(n("form"),R,ea,r):"keyword b"==
k?h(n("form"),ea,r):"{"==k?h(n("}"),Ba,r):";"==k?h():"if"==k?("else"==E.state.lexical.info&&E.state.cc[E.state.cc.length-1]==r&&E.state.cc.pop()(),h(n("form"),R,ea,r,S)):"function"==k?h(xa):"for"==k?h(n("form"),va,ea,r):"variable"==k?h(n("stat"),Ic):"switch"==k?h(n("form"),R,n("}","switch"),C("{"),Ba,r,r):"case"==k?h(R,C(":")):"default"==k?h(C(":")):"catch"==k?h(n("form"),l,C("("),Pb,C(")"),ea,r,T):"module"==k?h(n("form"),l,Qb,T,r):"class"==k?h(n("form"),kc,r):"export"==k?h(n("form"),Lc,r):"import"==
k?h(n("form"),Mc,r):w(n("stat"),R,C(";"),r)}function R(k){return ub(k,!1)}function ja(k){return ub(k,!0)}function ub(k,f){if(E.state.fatArrowAt==E.stream.start){var u=f?da:Nb;if("("==k)return h(l,n(")"),Ta(q,")"),r,C("=>"),u,T);if("variable"==k)return w(l,q,C("=>"),u,T)}u=f?ua:Za;return Rc.hasOwnProperty(k)?h(u):"function"==k?h(xa,u):"keyword c"==k?h(f?oa:Fa):"("==k?h(n(")"),Fa,Sa,C(")"),r,u):"operator"==k||"spread"==k?h(f?ja:R):"["==k?h(n("]"),Nc,r,u):"{"==k?Ia(yd,"}",null,u):"quasi"==k?w(aa,u):
h()}function Fa(k){return k.match(/[;\}\)\],]/)?w():w(R)}function oa(k){return k.match(/[;\}\)\],]/)?w():w(ja)}function Za(k,f){return","==k?h(R):ua(k,f,!1)}function ua(k,f,q){var u=0==q?Za:ua,z=0==q?R:ja;if("=>"==k)return h(l,q?da:Nb,T);if("operator"==k)return/\+\+|--/.test(f)?h(u):"?"==f?h(R,C(":"),z):h(z);if("quasi"==k)return w(aa,u);if(";"!=k){if("("==k)return Ia(ja,")","call",u);if("."==k)return h(ic,u);if("["==k)return h(n("]"),Fa,C("]"),r,u)}}function aa(k,f){return"quasi"!=k?w():"${"!=f.slice(f.length-
2)?h(aa):h(R,Ga)}function Ga(k){if("}"==k)return E.marked="string-2",E.state.tokenize=A,h(aa)}function Nb(k){P(E.stream,E.state);return w("{"==k?ea:R)}function da(k){P(E.stream,E.state);return w("{"==k?ea:ja)}function Ic(k){return":"==k?h(r,ea):w(Za,C(";"),r)}function ic(k){if("variable"==k)return E.marked="property",h()}function yd(k,f){if("variable"==k||"keyword"==E.style)return E.marked="property","get"==f||"set"==f?h(Ob):h(Ca);if("number"==k||"string"==k)return E.marked=Pa?"property":E.style+
" property",h(Ca);if("jsonld-keyword"==k)return h(Ca);if("["==k)return h(R,C("]"),Ca)}function Ob(k){if("variable"!=k)return w(Ca);E.marked="property";return h(xa)}function Ca(k){if(":"==k)return h(ja);if("("==k)return w(xa)}function Ta(k,f){function l(q){return","==q?(q=E.state.lexical,"call"==q.info&&(q.pos=(q.pos||0)+1),h(k,l)):q==f?h():h(C(f))}return function(q){return q==f?h():w(k,l)}}function Ia(k,f,l){for(var q=3;q<arguments.length;q++)E.cc.push(arguments[q]);return h(n(f,l),Ta(k,f),r)}function Ba(k){return"}"==
k?h():w(ea,Ba)}function ib(k){if(Qc&&":"==k)return h(W)}function W(k){if("variable"==k)return E.marked="variable-3",h()}function pa(){return w(q,ib,u,Ja)}function q(k,f){if("variable"==k)return Z(f),h();if("["==k)return Ia(q,"]");if("{"==k)return Ia(ma,"}")}function ma(k,f){if("variable"==k&&!E.stream.match(/^\s*:/,!1))return Z(f),h(u);"variable"==k&&(E.marked="property");return h(C(":"),q,u)}function u(k,f){if("="==f)return h(ja)}function Ja(k){if(","==k)return h(pa)}function S(k,f){if("keyword b"==
k&&"else"==f)return h(n("form","else"),ea,r)}function va(k){if("("==k)return h(n(")"),Ua,C(")"),r)}function Ua(k){return"var"==k?h(pa,C(";"),Va):";"==k?h(Va):"variable"==k?h(J):w(R,C(";"),Va)}function J(k,f){return"in"==f||"of"==f?(E.marked="keyword",h(R)):h(Za,Va)}function Va(k,f){return";"==k?h(jb):"in"==f||"of"==f?(E.marked="keyword",h(R)):w(R,C(";"),jb)}function jb(k){")"!=k&&h(R)}function xa(k,f){if("*"==f)return E.marked="keyword",h(xa);if("variable"==k)return Z(f),h(xa);if("("==k)return h(l,
n(")"),Ta(Pb,")"),r,ea,T)}function Pb(k){return"spread"==k?h(Pb):w(q,ib)}function kc(k,f){if("variable"==k)return Z(f),h(Jc)}function Jc(k,f){if("extends"==f)return h(R,Jc);if("{"==k)return h(n("}"),kb,r)}function kb(k,f){if("variable"==k||"keyword"==E.style)return E.marked="property","get"==f||"set"==f?h(fa,xa,kb):h(xa,kb);if("*"==f)return E.marked="keyword",h(kb);if(";"==k)return h(kb);if("}"==k)return h()}function fa(k){if("variable"!=k)return w();E.marked="property";return h()}function Qb(k,f){if("string"==
k)return h(ea);if("variable"==k)return Z(f),h(mb)}function Lc(k,f){return"*"==f?(E.marked="keyword",h(mb,C(";"))):"default"==f?(E.marked="keyword",h(R,C(";"))):w(ea)}function Mc(k){return"string"==k?h():w(lc,mb)}function lc(k,f){if("{"==k)return Ia(lc,"}");"variable"==k&&Z(f);return h()}function mb(k,f){if("from"==f)return E.marked="keyword",h(R)}function Nc(k){return"]"==k?h():w(ja,Oc)}function Oc(k){return"for"==k?w(Sa,C("]")):","==k?h(Ta(oa,"]")):w(Ta(ja,"]"))}function Sa(k){if("for"==k)return h(va,
Sa);if("if"==k)return h(R,Sa)}var nb=Q.indentUnit,Tb=I.statementIndent,Pa=I.jsonld,ob=I.json||Pa,Qc=I.typescript,ab=I.wordCharacters||/[\w$\xa1-\uffff]/,Lb=function(){function k(k){return{type:k,style:"keyword"}}var f=k("keyword a"),l=k("keyword b"),h=k("keyword c"),q=k("operator"),n={type:"atom",style:"atom"},f={"if":k("if"),"while":f,"with":f,"else":l,"do":l,"try":l,"finally":l,"return":h,"break":h,"continue":h,"new":h,"delete":h,"throw":h,"debugger":h,"var":k("var"),"const":k("var"),let:k("var"),
"function":k("function"),"catch":k("catch"),"for":k("for"),"switch":k("switch"),"case":k("case"),"default":k("default"),"in":q,"typeof":q,"instanceof":q,"true":n,"false":n,"null":n,undefined:n,NaN:n,Infinity:n,"this":k("this"),module:k("module"),"class":k("class"),"super":k("atom"),yield:h,"export":k("export"),"import":k("import"),"extends":h};if(Qc){var l={type:"variable",style:"variable-3"},l={"interface":k("interface"),"extends":k("extends"),constructor:k("constructor"),"public":k("public"),"private":k("private"),
"protected":k("protected"),"static":k("static"),string:l,number:l,bool:l,any:l},u;for(u in l)f[u]=l[u]}return f}(),Sb=/[+\-*&%=<>!?|~^]/,Aa=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,ta,hb,Rc={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},E={state:null,column:null,marked:null,cc:null},mc={name:"this",next:{name:"arguments"}};r.lex=!0;return{startState:function(k){k={tokenize:z,lastType:"sof",cc:[],lexical:new K((k||0)-
nb,0,"block",!1),localVars:I.localVars,context:I.localVars&&{vars:I.localVars},indented:0};I.globalVars&&"object"==typeof I.globalVars&&(k.globalVars=I.globalVars);return k},token:function(k,f){k.sol()&&(f.lexical.hasOwnProperty("align")||(f.lexical.align=!1),f.indented=k.indentation(),P(k,f));if(f.tokenize!=D&&k.eatSpace())return null;var l=f.tokenize(k,f);if("comment"==ta)return l;f.lastType="operator"!=ta||"++"!=hb&&"--"!=hb?ta:"incdec";a:{var h=ta,q=hb,n=f.cc;E.state=f;E.stream=k;E.marked=null;
E.cc=n;E.style=l;f.lexical.hasOwnProperty("align")||(f.lexical.align=!0);for(;;)if((n.length?n.pop():ob?R:ea)(h,q)){for(;n.length&&n[n.length-1].lex;)n.pop()();if(E.marked){l=E.marked;break a}if(h="variable"==h)b:{for(h=f.localVars;h;h=h.next)if(h.name==q){h=!0;break b}for(n=f.context;n;n=n.prev)for(h=n.vars;h;h=h.next)if(h.name==q){h=!0;break b}h=void 0}if(h){l="variable-2";break a}break a}}return l},indent:function(k,l){if(k.tokenize==D)return f.Pass;if(k.tokenize!=z)return 0;var h=l&&l.charAt(0),
q=k.lexical;if(!/^\s*else\b/.test(l))for(var n=k.cc.length-1;0<=n;--n){var u=k.cc[n];if(u==r)q=q.prev;else if(u!=S)break}"stat"==q.type&&"}"==h&&(q=q.prev);Tb&&")"==q.type&&"stat"==q.prev.type&&(q=q.prev);n=q.type;u=h==n;return"vardef"==n?q.indented+("operator"==k.lastType||","==k.lastType?q.info+1:0):"form"==n&&"{"==h?q.indented:"form"==n?q.indented+nb:"stat"==n?q.indented+("operator"==k.lastType||","==k.lastType?Tb||nb:0):"switch"!=q.info||u||0==I.doubleIndentSwitch?q.align?q.column+(u?0:1):q.indented+
(u?0:nb):q.indented+(/^(?:case|default)\b/.test(l)?nb:2*nb)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:ob?null:"/*",blockCommentEnd:ob?null:"*/",lineComment:ob?null:"//",fold:"brace",helperType:ob?"json":"javascript",jsonldMode:Pa,jsonMode:ob}});f.registerHelper("wordChars","javascript",/[\w$]/);f.defineMIME("text/javascript","javascript");f.defineMIME("text/ecmascript","javascript");f.defineMIME("application/javascript","javascript");f.defineMIME("application/x-javascript",
"javascript");f.defineMIME("application/ecmascript","javascript");f.defineMIME("application/json",{name:"javascript",json:!0});f.defineMIME("application/x-json",{name:"javascript",json:!0});f.defineMIME("application/ld+json",{name:"javascript",jsonld:!0});f.defineMIME("text/typescript",{name:"javascript",typescript:!0});f.defineMIME("application/typescript",{name:"javascript",typescript:!0})});
(function(f){"object"==typeof exports&&"object"==typeof module?f(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],f):f(CodeMirror)})(function(f){function Q(f){for(var l={},h=0;h<f.length;++h)l[f[h]]=!0;return l}function I(f,l){for(var h=!1,n;null!=(n=f.next());){if(h&&"/"==n){l.tokenize=null;break}h="*"==n}return["comment","comment"]}function v(f,l){f.skipTo("--\x3e")?(f.match("--\x3e"),l.tokenize=null):f.skipToEnd();return["comment","comment"]}
f.defineMode("css",function(l,h){function n(f,l){ib=l;return f}function r(f,l){var h=f.next();if(I[h]){var C=I[h](f,l);if(!1!==C)return C}if("@"==h)return f.eatWhile(/[\w\\\-]/),n("def",f.current());if("="==h||("~"==h||"|"==h)&&f.eat("="))return n(null,"compare");if('"'==h||"'"==h)return l.tokenize=T(h),l.tokenize(f,l);if("#"==h)return f.eatWhile(/[\w\\\-]/),n("atom","hash");if("!"==h)return f.match(/^\s*\w*/),n("keyword","important");if(/\d/.test(h)||"."==h&&f.eat(/\d/))return f.eatWhile(/[\w.%]/),
n("number","unit");if("-"===h){if(/[\d.]/.test(f.peek()))return f.eatWhile(/[\w.%]/),n("number","unit");if(f.match(/^\w+-/))return n("meta","meta")}else return/[,+>*\/]/.test(h)?n(null,"select-op"):"."==h&&f.match(/^-?[_a-z][_a-z0-9-]*/i)?n("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(h)?n(null,h):"u"==h&&f.match("rl(")?(f.backUp(1),l.tokenize=z,n("property","word")):/[\w\\\-]/.test(h)?(f.eatWhile(/[\w\\\-]/),n("property","word")):n(null,null)}function T(f){return function(l,h){for(var r=!1,C;null!=
(C=l.next());){if(C==f&&!r){")"==f&&l.backUp(1);break}r=!r&&"\\"==C}if(C==f||!r&&")"!=f)h.tokenize=null;return n("string","string")}}function z(f,l){f.next();f.match(/\s*[\"\')]/,!1)?l.tokenize=null:l.tokenize=T(")");return n(null,"(")}function w(f,l,h){this.type=f;this.indent=l;this.prev=h}function v(f,l,h){f.context=new w(h,l.indentation()+K,f.context);return h}function y(f){f.context=f.context.prev;return f.context.type}function A(f,l,h,n){for(n=n||1;0<n;n--)h.context=h.context.prev;return pa[h.context.type](f,
l,h)}function D(f){f=f.current().toLowerCase();W=Ta.hasOwnProperty(f)?"atom":Ca.hasOwnProperty(f)?"keyword":"variable"}h.propertyKeywords||(h=f.resolveMode("text/css"));var K=l.indentUnit,I=h.tokenHooks,Z=h.mediaTypes||{},P=h.mediaFeatures||{},Q=h.propertyKeywords||{},Ob=h.nonStandardPropertyKeywords||{},Ca=h.colorKeywords||{},Ta=h.valueKeywords||{},Ia=h.fontProperties||{},Ba=h.allowNested,ib,W,pa={top:function(f,l,h){if("{"==f)return v(h,l,"block");if("}"==f&&h.context.prev)return y(h);if("@media"==
f)return v(h,l,"media");if("@font-face"==f)return"font_face_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(f))return"keyframes";if(f&&"@"==f.charAt(0))return v(h,l,"at");if("hash"==f)W="builtin";else if("word"==f)W="tag";else{if("variable-definition"==f)return"maybeprop";if("interpolation"==f)return v(h,l,"interpolation");if(":"==f)return"pseudo";if(Ba&&"("==f)return v(h,l,"parens")}return h.context.type},block:function(f,l,h){if("word"==f){f=l.current().toLowerCase();if(Q.hasOwnProperty(f))return W=
"property","maybeprop";if(Ob.hasOwnProperty(f))return W="string-2","maybeprop";if(Ba)return W=l.match(/^\s*:(?:\s|$)/,!1)?"property":"tag","block";W+=" error";return"maybeprop"}if("meta"==f)return"block";if(Ba||"hash"!=f&&"qualifier"!=f)return pa.top(f,l,h);W="error";return"block"},maybeprop:function(f,l,h){return":"==f?v(h,l,"prop"):pa[h.context.type](f,l,h)},prop:function(f,l,h){if(";"==f)return y(h);if("{"==f&&Ba)return v(h,l,"propBlock");if("}"==f||"{"==f)return A(f,l,h);if("("==f)return v(h,
l,"parens");if("hash"==f&&!/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(l.current()))W+=" error";else if("word"==f)D(l);else if("interpolation"==f)return v(h,l,"interpolation");return"prop"},propBlock:function(f,l,h){return"}"==f?y(h):"word"==f?(W="property","maybeprop"):h.context.type},parens:function(f,l,h){if("{"==f||"}"==f)return A(f,l,h);if(")"==f)return y(h);if("("==f)return v(h,l,"parens");"word"==f&&D(l);return"parens"},pseudo:function(f,l,h){return"word"==f?(W="variable-3",h.context.type):pa[h.context.type](f,
l,h)},media:function(f,l,h){if("("==f)return v(h,l,"media_parens");if("}"==f)return A(f,l,h);if("{"==f)return y(h)&&v(h,l,Ba?"block":"top");"word"==f&&(f=l.current().toLowerCase(),W="only"==f||"not"==f||"and"==f?"keyword":Z.hasOwnProperty(f)?"attribute":P.hasOwnProperty(f)?"property":"error");return h.context.type},media_parens:function(f,l,h){return")"==f?y(h):"{"==f||"}"==f?A(f,l,h,2):pa.media(f,l,h)},font_face_before:function(f,l,h){return"{"==f?v(h,l,"font_face"):pa[h.context.type](f,l,h)},font_face:function(f,
l,h){return"}"==f?y(h):"word"==f?(W=Ia.hasOwnProperty(l.current().toLowerCase())?"property":"error","maybeprop"):"font_face"},keyframes:function(f,l,h){return"word"==f?(W="variable","keyframes"):"{"==f?v(h,l,"top"):pa[h.context.type](f,l,h)},at:function(f,l,h){if(";"==f)return y(h);if("{"==f||"}"==f)return A(f,l,h);"word"==f?W="tag":"hash"==f&&(W="builtin");return"at"},interpolation:function(f,l,h){if("}"==f)return y(h);if("{"==f||";"==f)return A(f,l,h);"variable"!=f&&(W="error");return"interpolation"}};
return{startState:function(f){return{tokenize:null,state:"top",context:new w("top",f||0,null)}},token:function(f,l){if(!l.tokenize&&f.eatSpace())return null;var h=(l.tokenize||r)(f,l);h&&"object"==typeof h&&(ib=h[1],h=h[0]);W=h;l.state=pa[l.state](ib,f,l);return W},indent:function(f,l){var h=f.context,n=l&&l.charAt(0),r=h.indent;"prop"!=h.type||"}"!=n&&")"!=n||(h=h.prev);!h.prev||("}"!=n||"block"!=h.type&&"top"!=h.type&&"interpolation"!=h.type&&"font_face"!=h.type)&&(")"!=n||"parens"!=h.type&&"media_parens"!=
h.type)&&("{"!=n||"at"!=h.type&&"media"!=h.type)||(r=h.indent-K);return r},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}});var z="all aural braille handheld print projection screen tty tv embossed".split(" "),y=Q(z),D="width min-width max-width height min-height max-height device-width min-device-width max-device-width device-height min-device-height max-device-height aspect-ratio min-aspect-ratio max-aspect-ratio device-aspect-ratio min-device-aspect-ratio max-device-aspect-ratio color min-color max-color color-index min-color-index max-color-index monochrome min-monochrome max-monochrome resolution min-resolution max-resolution scan grid".split(" "),
A=Q(D),P="align-content align-items align-self alignment-adjust alignment-baseline anchor-point animation animation-delay animation-direction animation-duration animation-fill-mode animation-iteration-count animation-name animation-play-state animation-timing-function appearance azimuth backface-visibility background background-attachment background-clip background-color background-image background-origin background-position background-repeat background-size baseline-shift binding bleed bookmark-label bookmark-level bookmark-state bookmark-target border border-bottom border-bottom-color border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width border-collapse border-color border-image border-image-outset border-image-repeat border-image-slice border-image-source border-image-width border-left border-left-color border-left-style border-left-width border-radius border-right border-right-color border-right-style border-right-width border-spacing border-style border-top border-top-color border-top-left-radius border-top-right-radius border-top-style border-top-width border-width bottom box-decoration-break box-shadow box-sizing break-after break-before break-inside caption-side clear clip color color-profile column-count column-fill column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-width columns content counter-increment counter-reset crop cue cue-after cue-before cursor direction display dominant-baseline drop-initial-after-adjust drop-initial-after-align drop-initial-before-adjust drop-initial-before-align drop-initial-size drop-initial-value elevation empty-cells fit fit-position flex flex-basis flex-direction flex-flow flex-grow flex-shrink flex-wrap float float-offset flow-from flow-into font font-feature-settings font-family font-kerning font-language-override font-size font-size-adjust font-stretch font-style font-synthesis font-variant font-variant-alternates font-variant-caps font-variant-east-asian font-variant-ligatures font-variant-numeric font-variant-position font-weight grid grid-area grid-auto-columns grid-auto-flow grid-auto-position grid-auto-rows grid-column grid-column-end grid-column-start grid-row grid-row-end grid-row-start grid-template grid-template-areas grid-template-columns grid-template-rows hanging-punctuation height hyphens icon image-orientation image-rendering image-resolution inline-box-align justify-content left letter-spacing line-break line-height line-stacking line-stacking-ruby line-stacking-shift line-stacking-strategy list-style list-style-image list-style-position list-style-type margin margin-bottom margin-left margin-right margin-top marker-offset marks marquee-direction marquee-loop marquee-play-count marquee-speed marquee-style max-height max-width min-height min-width move-to nav-down nav-index nav-left nav-right nav-up object-fit object-position opacity order orphans outline outline-color outline-offset outline-style outline-width overflow overflow-style overflow-wrap overflow-x overflow-y padding padding-bottom padding-left padding-right padding-top page page-break-after page-break-before page-break-inside page-policy pause pause-after pause-before perspective perspective-origin pitch pitch-range play-during position presentation-level punctuation-trim quotes region-break-after region-break-before region-break-inside region-fragment rendering-intent resize rest rest-after rest-before richness right rotation rotation-point ruby-align ruby-overhang ruby-position ruby-span shape-image-threshold shape-inside shape-margin shape-outside size speak speak-as speak-header speak-numeral speak-punctuation speech-rate stress string-set tab-size table-layout target target-name target-new target-position text-align text-align-last text-decoration text-decoration-color text-decoration-line text-decoration-skip text-decoration-style text-emphasis text-emphasis-color text-emphasis-position text-emphasis-style text-height text-indent text-justify text-outline text-overflow text-shadow text-size-adjust text-space-collapse text-transform text-underline-position text-wrap top transform transform-origin transform-style transition transition-delay transition-duration transition-property transition-timing-function unicode-bidi vertical-align visibility voice-balance voice-duration voice-family voice-pitch voice-range voice-rate voice-stress voice-volume volume white-space widows width word-break word-spacing word-wrap z-index clip-path clip-rule mask enable-background filter flood-color flood-opacity lighting-color stop-color stop-opacity pointer-events color-interpolation color-interpolation-filters color-rendering fill fill-opacity fill-rule image-rendering marker marker-end marker-mid marker-start shape-rendering stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-rendering baseline-shift dominant-baseline glyph-orientation-horizontal glyph-orientation-vertical text-anchor writing-mode".split(" "),
K=Q(P),w="scrollbar-arrow-color scrollbar-base-color scrollbar-dark-shadow-color scrollbar-face-color scrollbar-highlight-color scrollbar-shadow-color scrollbar-3d-light-color scrollbar-track-color shape-inside searchfield-cancel-button searchfield-decoration searchfield-results-button searchfield-results-decoration zoom".split(" "),h=Q(w),Z="aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkturquoise darkviolet deeppink deepskyblue dimgray dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray grey green greenyellow honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightpink lightsalmon lightseagreen lightskyblue lightslategray lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen".split(" "),
l=Q(Z),T="above absolute activeborder activecaption afar after-white-space ahead alias all all-scroll alternate always amharic amharic-abegede antialiased appworkspace arabic-indic armenian asterisks auto avoid avoid-column avoid-page avoid-region background backwards baseline below bidi-override binary bengali blink block block-axis bold bolder border border-box both bottom break break-all break-word button button-bevel buttonface buttonhighlight buttonshadow buttontext cambodian capitalize caps-lock-indicator caption captiontext caret cell center checkbox circle cjk-earthly-branch cjk-heavenly-stem cjk-ideographic clear clip close-quote col-resize collapse column compact condensed contain content content-box context-menu continuous copy cover crop cross crosshair currentcolor cursive dashed decimal decimal-leading-zero default default-button destination-atop destination-in destination-out destination-over devanagari disc discard document dot-dash dot-dot-dash dotted double down e-resize ease ease-in ease-in-out ease-out element ellipse ellipsis embed end ethiopic ethiopic-abegede ethiopic-abegede-am-et ethiopic-abegede-gez ethiopic-abegede-ti-er ethiopic-abegede-ti-et ethiopic-halehame-aa-er ethiopic-halehame-aa-et ethiopic-halehame-am-et ethiopic-halehame-gez ethiopic-halehame-om-et ethiopic-halehame-sid-et ethiopic-halehame-so-et ethiopic-halehame-ti-er ethiopic-halehame-ti-et ethiopic-halehame-tig ew-resize expanded extra-condensed extra-expanded fantasy fast fill fixed flat footnotes forwards from geometricPrecision georgian graytext groove gujarati gurmukhi hand hangul hangul-consonant hebrew help hidden hide higher highlight highlighttext hiragana hiragana-iroha horizontal hsl hsla icon ignore inactiveborder inactivecaption inactivecaptiontext infinite infobackground infotext inherit initial inline inline-axis inline-block inline-table inset inside intrinsic invert italic justify kannada katakana katakana-iroha keep-all khmer landscape lao large larger left level lighter line-through linear lines list-item listbox listitem local logical loud lower lower-alpha lower-armenian lower-greek lower-hexadecimal lower-latin lower-norwegian lower-roman lowercase ltr malayalam match media-controls-background media-current-time-display media-fullscreen-button media-mute-button media-play-button media-return-to-realtime-button media-rewind-button media-seek-back-button media-seek-forward-button media-slider media-sliderthumb media-time-remaining-display media-volume-slider media-volume-slider-container media-volume-sliderthumb medium menu menulist menulist-button menulist-text menulist-textfield menutext message-box middle min-intrinsic mix mongolian monospace move multiple myanmar n-resize narrower ne-resize nesw-resize no-close-quote no-drop no-open-quote no-repeat none normal not-allowed nowrap ns-resize nw-resize nwse-resize oblique octal open-quote optimizeLegibility optimizeSpeed oriya oromo outset outside outside-shape overlay overline padding padding-box painted page paused persian plus-darker plus-lighter pointer polygon portrait pre pre-line pre-wrap preserve-3d progress push-button radio read-only read-write read-write-plaintext-only rectangle region relative repeat repeat-x repeat-y reset reverse rgb rgba ridge right round row-resize rtl run-in running s-resize sans-serif scroll scrollbar se-resize searchfield searchfield-cancel-button searchfield-decoration searchfield-results-button searchfield-results-decoration semi-condensed semi-expanded separate serif show sidama single skip-white-space slide slider-horizontal slider-vertical sliderthumb-horizontal sliderthumb-vertical slow small small-caps small-caption smaller solid somali source-atop source-in source-out source-over space square square-button start static status-bar stretch stroke sub subpixel-antialiased super sw-resize table table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group telugu text text-bottom text-top textarea textfield thai thick thin threeddarkshadow threedface threedhighlight threedlightshadow threedshadow tibetan tigre tigrinya-er tigrinya-er-abegede tigrinya-et tigrinya-et-abegede to top transparent ultra-condensed ultra-expanded underline up upper-alpha upper-armenian upper-greek upper-hexadecimal upper-latin upper-norwegian upper-roman uppercase urdu url vertical vertical-text visible visibleFill visiblePainted visibleStroke visual w-resize wait wave wider window windowframe windowtext x-large x-small xor xx-large xx-small".split(" "),
n=Q(T),r=Q("font-family src unicode-range font-variant font-feature-settings font-stretch font-weight font-style".split(" ")),z=z.concat(D).concat(P).concat(w).concat(Z).concat(T);f.registerHelper("hintWords","css",z);f.defineMIME("text/css",{mediaTypes:y,mediaFeatures:A,propertyKeywords:K,nonStandardPropertyKeywords:h,colorKeywords:l,valueKeywords:n,fontProperties:r,tokenHooks:{"<":function(f,l){if(!f.match("!--"))return!1;l.tokenize=v;return v(f,l)},"/":function(f,l){if(!f.eat("*"))return!1;l.tokenize=
I;return I(f,l)}},name:"css"});f.defineMIME("text/x-scss",{mediaTypes:y,mediaFeatures:A,propertyKeywords:K,nonStandardPropertyKeywords:h,colorKeywords:l,valueKeywords:n,fontProperties:r,allowNested:!0,tokenHooks:{"/":function(f,l){return f.eat("/")?(f.skipToEnd(),["comment","comment"]):f.eat("*")?(l.tokenize=I,I(f,l)):["operator","operator"]},":":function(f){return f.match(/\s*\{/)?[null,"{"]:!1},$:function(f){f.match(/^[\w-]+/);return f.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2",
"variable"]},"#":function(f){return f.eat("{")?[null,"interpolation"]:!1}},name:"css",helperType:"scss"});f.defineMIME("text/x-less",{mediaTypes:y,mediaFeatures:A,propertyKeywords:K,nonStandardPropertyKeywords:h,colorKeywords:l,valueKeywords:n,fontProperties:r,allowNested:!0,tokenHooks:{"/":function(f,l){return f.eat("/")?(f.skipToEnd(),["comment","comment"]):f.eat("*")?(l.tokenize=I,I(f,l)):["operator","operator"]},"@":function(f){if(f.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,
!1))return!1;f.eatWhile(/[\w\\\-]/);return f.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"})});
(function(f){"object"==typeof exports&&"object"==typeof module?f(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],f):f(CodeMirror)})(function(f){f.defineMode("htmlmixed",function(Q,I){function v(f,h){var n=h.htmlState.tagName;n&&(n=n.toLowerCase());var r=A.token(f,h.htmlState);if("script"==n&&/\btag\b/.test(r)&&">"==
f.current()){(n=(n=f.string.slice(Math.max(0,f.pos-100),f.pos).match(/\btype\s*=\s*("[^"]+"|'[^']+'|\S+)[^<]*$/i))?n[1]:"")&&/[\"\']/.test(n.charAt(0))&&(n=n.slice(1,n.length-1));for(var v=0;v<K.length;++v){var z=K[v];if("string"==typeof z.matches?n==z.matches:z.matches.test(n)){z.mode&&(h.token=y,h.localMode=z.mode,h.localState=z.mode.startState&&z.mode.startState(A.indent(h.htmlState,"")));break}}}else"style"==n&&/\btag\b/.test(r)&&">"==f.current()&&(h.token=D,h.localMode=P,h.localState=P.startState(A.indent(h.htmlState,
"")));return r}function z(f,h,n){var r=f.current(),v=r.search(h);-1<v?f.backUp(r.length-v):r.match(/<\/?$/)&&(f.backUp(r.length),f.match(h,!1)||f.match(r));return n}function y(f,h){return f.match(/^<\/\s*script\s*>/i,!1)?(h.token=v,h.localState=h.localMode=null):z(f,/<\/\s*script\s*>/,h.localMode.token(f,h.localState))}function D(f,h){return f.match(/^<\/\s*style\s*>/i,!1)?(h.token=v,h.localState=h.localMode=null):z(f,/<\/\s*style\s*>/,P.token(f,h.localState))}var A=f.getMode(Q,{name:"xml",htmlMode:!0,
multilineTagIndentFactor:I.multilineTagIndentFactor,multilineTagIndentPastTag:I.multilineTagIndentPastTag}),P=f.getMode(Q,"css"),K=[],w=I&&I.scriptTypes;K.push({matches:/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,mode:f.getMode(Q,"javascript")});if(w)for(var h=0;h<w.length;++h){var Z=w[h];K.push({matches:Z.matches,mode:Z.mode&&f.getMode(Q,Z.mode)})}K.push({matches:/./,mode:f.getMode(Q,"text/plain")});return{startState:function(){var f=A.startState();return{token:v,localMode:null,localState:null,
htmlState:f}},copyState:function(h){if(h.localState)var v=f.copyState(h.localMode,h.localState);return{token:h.token,localMode:h.localMode,localState:v,htmlState:f.copyState(A,h.htmlState)}},token:function(f,h){return h.token(f,h)},indent:function(h,v){return!h.localMode||/^\s*<\//.test(v)?A.indent(h.htmlState,v):h.localMode.indent?h.localMode.indent(h.localState,v):f.Pass},innerMode:function(f){return{state:f.localState||f.htmlState,mode:f.localMode||A}}}},"xml","javascript","css");f.defineMIME("text/html",
"htmlmixed")});
(function(f){"object"==typeof exports&&"object"==typeof module?f(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],f):f(CodeMirror)})(function(f){function Q(f,z,y){f=f.getWrapperElement().appendChild(document.createElement("div"));f.className=y?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top";"string"==typeof z?f.innerHTML=z:f.appendChild(z);return f}function I(f,z){f.state.currentNotificationClose&&f.state.currentNotificationClose();
f.state.currentNotificationClose=z}f.defineExtension("openDialog",function(v,z,y){function D(f){if("string"==typeof f)w.value=f;else if(!P&&(P=!0,A.parentNode.removeChild(A),K.focus(),y.onClose))y.onClose(A)}y||(y={});I(this,null);var A=Q(this,v,y.bottom),P=!1,K=this,w=A.getElementsByTagName("input")[0];if(w){y.value&&(w.value=y.value,w.select());if(y.onInput)f.on(w,"input",function(f){y.onInput(f,w.value,D)});if(y.onKeyUp)f.on(w,"keyup",function(f){y.onKeyUp(f,w.value,D)});f.on(w,"keydown",function(h){if(!(y&&
y.onKeyDown&&y.onKeyDown(h,w.value,D))){if(27==h.keyCode||!1!==y.closeOnEnter&&13==h.keyCode)w.blur(),f.e_stop(h),D();13==h.keyCode&&z(w.value,h)}});if(!1!==y.closeOnBlur)f.on(w,"blur",D);w.focus()}else if(v=A.getElementsByTagName("button")[0]){f.on(v,"click",function(){D();K.focus()});if(!1!==y.closeOnBlur)f.on(v,"blur",D);v.focus()}return D});f.defineExtension("openConfirm",function(v,z,y){function D(){P||(P=!0,A.parentNode.removeChild(A),K.focus())}I(this,null);var A=Q(this,v,y&&y.bottom);v=A.getElementsByTagName("button");
var P=!1,K=this,w=1;v[0].focus();for(y=0;y<v.length;++y){var h=v[y];(function(z){f.on(h,"click",function(h){f.e_preventDefault(h);D();z&&z(K)})})(z[y]);f.on(h,"blur",function(){--w;setTimeout(function(){0>=w&&D()},200)});f.on(h,"focus",function(){++w})}});f.defineExtension("openNotification",function(v,z){function y(){A||(A=!0,clearTimeout(P),D.parentNode.removeChild(D))}I(this,y);var D=Q(this,v,z&&z.bottom),A=!1,P,K=z&&"undefined"!==typeof z.duration?z.duration:5E3;f.on(D,"click",function(z){f.e_preventDefault(z);
y()});K&&(P=setTimeout(y,K));return y})});
(function(f){"object"==typeof exports&&"object"==typeof module?f(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],f):f(CodeMirror)})(function(f){function Q(f,y,D,A){this.atOccurrence=!1;this.doc=f;null==A&&"string"==typeof y&&(A=!1);D=D?f.clipPos(D):v(0,0);this.pos={from:D,to:D};if("string"!=typeof y)y.global||(y=new RegExp(y.source,y.ignoreCase?"ig":"g")),this.matches=function(h,l){if(h){y.lastIndex=0;for(var w=f.getLine(l.line).slice(0,l.ch),
n=0,r,C;;){y.lastIndex=n;n=y.exec(w);if(!n)break;r=n;C=r.index;n=r.index+(r[0].length||1);if(n==w.length)break}(n=r&&r[0].length||0)||(0==C&&0==w.length?r=void 0:C!=f.getLine(l.line).length&&n++)}else y.lastIndex=l.ch,w=f.getLine(l.line),n=(r=y.exec(w))&&r[0].length||0,C=r&&r.index,C+n==w.length||n||(n=1);if(r&&n)return{from:v(l.line,C),to:v(l.line,C+n),match:r}};else{var P=y;A&&(y=y.toLowerCase());var K=A?function(f){return f.toLowerCase()}:function(f){return f},w=y.split("\n");if(1==w.length)this.matches=
y.length?function(h,l){if(h){var w=f.getLine(l.line).slice(0,l.ch),n=K(w),r=n.lastIndexOf(y);if(-1<r)return r=I(w,n,r),{from:v(l.line,r),to:v(l.line,r+P.length)}}else if(w=f.getLine(l.line).slice(l.ch),n=K(w),r=n.indexOf(y),-1<r)return r=I(w,n,r)+l.ch,{from:v(l.line,r),to:v(l.line,r+P.length)}}:function(){};else{var h=P.split("\n");this.matches=function(y,l){var A=w.length-1;if(y){if(!(l.line-(w.length-1)<f.firstLine())&&K(f.getLine(l.line).slice(0,h[A].length))==w[w.length-1]){for(var n=v(l.line,
h[A].length),r=l.line-1,C=A-1;1<=C;--C,--r)if(w[C]!=K(f.getLine(r)))return;var C=f.getLine(r),D=C.length-h[0].length;if(K(C.slice(D))==w[0])return{from:v(r,D),to:n}}}else if(!(l.line+(w.length-1)>f.lastLine())&&(C=f.getLine(l.line),D=C.length-h[0].length,K(C.slice(D))==w[0])){n=v(l.line,D);r=l.line+1;for(C=1;C<A;++C,++r)if(w[C]!=K(f.getLine(r)))return;if(K(f.getLine(r).slice(0,h[A].length))==w[A])return{from:n,to:v(r,h[A].length)}}}}}}function I(f,v,D){if(f.length==v.length)return D;for(v=Math.min(D,
f.length);;){var A=f.slice(0,v).toLowerCase().length;if(A<D)++v;else if(A>D)--v;else return v}}var v=f.Pos;Q.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(f){function y(f){f=v(f,0);D.pos={from:f,to:f};return D.atOccurrence=!1}for(var D=this,A=this.doc.clipPos(f?this.pos.from:this.pos.to);;){if(this.pos=this.matches(f,A))return this.atOccurrence=!0,this.pos.match||!0;if(f){if(!A.line)return y(0);A=v(A.line-1,this.doc.getLine(A.line-
1).length)}else{var I=this.doc.lineCount();if(A.line==I-1)return y(I);A=v(A.line+1,0)}}},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(z){this.atOccurrence&&(z=f.splitLines(z),this.doc.replaceRange(z,this.pos.from,this.pos.to),this.pos.to=v(this.pos.from.line+z.length-1,z[z.length-1].length+(1==z.length?this.pos.from.ch:0)))}};f.defineExtension("getSearchCursor",function(f,v,D){return new Q(this.doc,f,v,D)});f.defineDocExtension("getSearchCursor",
function(f,v,D){return new Q(this,f,v,D)});f.defineExtension("selectMatches",function(v,y){for(var D=[],A=this.getSearchCursor(v,this.getCursor("from"),y);A.findNext()&&!(0<f.cmpPos(A.to(),this.getCursor("to")));)D.push({anchor:A.from(),head:A.to()});D.length&&this.setSelections(D,0)})});
(function(f){"object"==typeof exports&&"object"==typeof module?f(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],f):f(CodeMirror)})(function(f){function Q(f,h){"string"==typeof f?f=new RegExp(f.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),h?"gi":"g"):f.global||(f=new RegExp(f.source,f.ignoreCase?"gi":"g"));return{token:function(h){f.lastIndex=h.pos;
var r=f.exec(h.string);if(r&&r.index==h.pos)return h.pos+=r[0].length,"searching";r?h.pos=r.index:h.skipToEnd()}}}function I(){this.overlay=this.posFrom=this.posTo=this.query=null}function v(f){return f.state.search||(f.state.search=new I)}function z(f){return"string"==typeof f&&f==f.toLowerCase()}function y(f,h,n){return f.getSearchCursor(h,n,z(h))}function D(f,h,n,r,v){f.openDialog?f.openDialog(h,v,{value:r}):v(prompt(n,r))}function A(f,h,n,r){if(f.openConfirm)f.openConfirm(h,r);else if(confirm(n))r[0]()}
function P(f){var h=f.match(/^\/(.*)\/([a-z]*)$/);if(h)try{f=new RegExp(h[1],-1==h[2].indexOf("i")?"":"i")}catch(n){}if("string"==typeof f?""==f:f.test(""))f=/x^/;return f}function K(f,h){var n=v(f);if(n.query)return w(f,h);D(f,'Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>',"Search for:",f.getSelection(),function(r){f.operation(function(){r&&!n.query&&(n.query=P(r),
f.removeOverlay(n.overlay,z(n.query)),n.overlay=Q(n.query,z(n.query)),f.addOverlay(n.overlay),f.showMatchesOnScrollbar&&(n.annotate&&(n.annotate.clear(),n.annotate=null),n.annotate=f.showMatchesOnScrollbar(n.query,z(n.query))),n.posFrom=n.posTo=f.getCursor(),w(f,h))})})}function w(h,w){h.operation(function(){var n=v(h),r=y(h,n.query,w?n.posFrom:n.posTo);if(!r.find(w)&&(r=y(h,n.query,w?f.Pos(h.lastLine()):f.Pos(h.firstLine(),0)),!r.find(w)))return;h.setSelection(r.from(),r.to());h.scrollIntoView({from:r.from(),
to:r.to()});n.posFrom=r.from();n.posTo=r.to()})}function h(f){f.operation(function(){var h=v(f);h.query&&(h.query=null,f.removeOverlay(h.overlay),h.annotate&&(h.annotate.clear(),h.annotate=null))})}function Z(f,v){f.getOption("readOnly")||D(f,'Replace: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>',"Replace:",f.getSelection(),function(n){n&&(n=P(n),D(f,'With: <input type="text" style="width: 10em" class="CodeMirror-search-field"/>',
"Replace with:","",function(r){if(v)f.operation(function(){for(var h=y(f,n);h.findNext();)if("string"!=typeof n){var v=f.getRange(h.from(),h.to()).match(n);h.replace(r.replace(/\$(\d)/g,function(f,h){return v[h]}))}else h.replace(r)});else{h(f);var w=y(f,n,f.getCursor()),z=function(){var h=w.from(),r;if(!(r=w.findNext())&&(w=y(f,n),!(r=w.findNext())||h&&w.from().line==h.line&&w.from().ch==h.ch))return;f.setSelection(w.from(),w.to());f.scrollIntoView({from:w.from(),to:w.to()});A(f,"Replace? <button>Yes</button> <button>No</button> <button>Stop</button>",
"Replace?",[function(){D(r)},z])},D=function(f){w.replace("string"==typeof n?r:r.replace(/\$(\d)/g,function(h,l){return f[l]}));z()};z()}}))})}f.commands.find=function(f){h(f);K(f)};f.commands.findNext=K;f.commands.findPrev=function(f){K(f,!0)};f.commands.clearSearch=h;f.commands.replace=Z;f.commands.replaceAll=function(f){Z(f,!0)}});