(function(za,X){"object"===typeof exports&&"undefined"!==typeof module?module.exports=X():"function"===typeof define&&define.amd?define(X):za.CodeMirror=X()})(this,function(){function za(a){return new RegExp("(^|\\s)"+a+"(?:$|\\s)\\s*")}function X(a){for(var b=a.childNodes.length;0<b;--b)a.removeChild(a.firstChild);return a}function U(a,b){return X(a).appendChild(b)}function r(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 Tb(a,b){3==b.nodeType&&(b=b.parentNode);if(a.contains)return a.contains(b);do if(11==b.nodeType&&(b=b.host),b==a)return!0;while(b=b.parentNode)}function la(){var a;try{a=document.activeElement}catch(b){a=document.body||null}for(;a&&a.root&&a.root.activeElement;)a=a.root.activeElement;return a}function Ma(a,b){var c=a.className;za(b).test(c)||(a.className+=(c?" ":"")+b)}function Gc(a,b){for(var c=a.split(" "),d=0;d<c.length;d++)c[d]&&
!za(c[d]).test(b)&&(b+=" "+c[d]);return b}function Hc(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(null,b)}}function aa(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 Y(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 f=a.indexOf("\t",d);if(0>f||f>=b)return e+(b-d);e+=f-d;e+=c-e%c;d=f+1}}function Aa(){this.id=null}function H(a,b){for(var c=0;c<a.length;++c)if(a[c]==
b)return c;return-1}function Ic(a,b,c){for(var d=0,e=0;;){var f=a.indexOf("\t",d);-1==f&&(f=a.length);var g=f-d;if(f==a.length||e+g>=b)return d+Math.min(g,b-e);e+=f-d;e+=c-e%c;d=f+1;if(e>=b)return d}}function Jc(a){for(;Ub.length<=a;)Ub.push(y(Ub)+" ");return Ub[a]}function y(a){return a[a.length-1]}function Vb(a,b){for(var c=[],d=0;d<a.length;d++)c[d]=b(a[d],d);return c}function Of(a,b,c){for(var d=0,e=c(b);d<a.length&&c(a[d])<=e;)d++;a.splice(d,0,b)}function ib(){}function Pd(a,b){var c;Object.create?
c=Object.create(a):(ib.prototype=a,c=new ib);b&&aa(b,c);return c}function Kc(a){return/\w/.test(a)||""<a&&(a.toUpperCase()!=a.toLowerCase()||Pf.test(a))}function Wb(a,b){return b?-1<b.source.indexOf("\\w")&&Kc(a)?!0:b.test(a):Kc(a)}function Qd(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function jb(a){return 768<=a.charCodeAt(0)&&Qf.test(a)}function Rf(a,b,c){this.input=c;this.scrollbarFiller=r("div",null,"CodeMirror-scrollbar-filler");this.scrollbarFiller.setAttribute("cm-not-content",
"true");this.gutterFiller=r("div",null,"CodeMirror-gutter-filler");this.gutterFiller.setAttribute("cm-not-content","true");this.lineDiv=r("div",null,"CodeMirror-code");this.selectionDiv=r("div",null,null,"position: relative; z-index: 1");this.cursorDiv=r("div",null,"CodeMirror-cursors");this.measure=r("div",null,"CodeMirror-measure");this.lineMeasure=r("div",null,"CodeMirror-measure");this.lineSpace=r("div",[this.measure,this.lineMeasure,this.selectionDiv,this.cursorDiv,this.lineDiv],null,"position: relative; outline: none");
this.mover=r("div",[r("div",[this.lineSpace],"CodeMirror-lines")],null,"position: relative");this.sizer=r("div",[this.mover],"CodeMirror-sizer");this.sizerWidth=null;this.heightForcer=r("div",null,null,"position: absolute; height: 30px; width: 1px;");this.gutters=r("div",null,"CodeMirror-gutters");this.lineGutter=null;this.scroller=r("div",[this.sizer,this.heightForcer,this.gutters],"CodeMirror-scroll");this.scroller.setAttribute("tabIndex","-1");this.wrapper=r("div",[this.scrollbarFiller,this.gutterFiller,
this.scroller],"CodeMirror");B&&8>A&&(this.gutters.style.zIndex=-1,this.scroller.style.paddingRight=0);I||sa&&kb||(this.scroller.draggable=!0);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.alignWidgets=!1;this.maxLine=this.cachedCharWidth=this.cachedTextHeight=this.cachedPaddingH=null;this.maxLineLength=0;this.maxLineChanged=!1;this.wheelDX=this.wheelDY=this.wheelStartX=this.wheelStartY=null;this.shift=!1;this.activeTouch=this.selForContextMenu=null;c.init(this)}function u(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],f=e.chunkSize();if(b<f){c=e;break}b-=f}return c.lines[b]}function Ba(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 Lc(a,b,c){var d=[];a.iter(b,c,function(a){d.push(a.text)});return d}function ga(a,b){var c=b-a.height;if(c)for(var d=a;d;d=d.parent)d.height+=c}function C(a){if(null==a.parent)return null;var b=a.parent;a=H(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 Ca(a,b){var c=a.first;a:do{for(var d=0;d<a.children.length;++d){var e=a.children[d],f=e.height;if(b<f){a=e;continue a}b-=f;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 lb(a,b){return b>=a.first&&b<a.first+a.size}function Mc(a,b){return String(a.lineNumberFormatter(b+a.firstLineNumber))}function q(a,b){if(!(this instanceof q))return new q(a,
b);this.line=a;this.ch=b}function w(a,b){return a.line-b.line||a.ch-b.ch}function Nc(a){return q(a.line,a.ch)}function Xb(a,b){return 0>w(a,b)?b:a}function Yb(a,b){return 0>w(a,b)?a:b}function x(a,b){if(b.line<a.first)return q(a.first,0);var c=a.first+a.size-1;if(b.line>c)return q(c,u(a,c).text.length);var c=u(a,b.line).text.length,d=b.ch,c=null==d||d>c?q(b.line,c):0>d?q(b.line,0):b;return c}function Rd(a,b){for(var c=[],d=0;d<b.length;d++)c[d]=x(a,b[d]);return c}function Zb(a,b,c){this.marker=a;
this.from=b;this.to=c}function mb(a,b){if(a)for(var c=0;c<a.length;++c){var d=a[c];if(d.marker==b)return d}}function Oc(a,b){if(b.full)return null;var c=lb(a,b.from.line)&&u(a,b.from.line).markedSpans,d=lb(a,b.to.line)&&u(a,b.to.line).markedSpans;if(!c&&!d)return null;var e=b.from.ch,f=b.to.ch,g=0==w(b.from,b.to),h;if(c)for(var k=0;k<c.length;++k){var l=c[k],m=l.marker;if(null==l.from||(m.inclusiveLeft?l.from<=e:l.from<e)||!(l.from!=e||"bookmark"!=m.type||g&&l.marker.insertLeft)){var n=null==l.to||
(m.inclusiveRight?l.to>=e:l.to>e);(h||(h=[])).push(new Zb(m,l.from,n?null:l.to))}}var c=h,p;if(d)for(h=0;h<d.length;++h)if(k=d[h],l=k.marker,null==k.to||(l.inclusiveRight?k.to>=f:k.to>f)||k.from==f&&"bookmark"==l.type&&(!g||k.marker.insertLeft))m=null==k.from||(l.inclusiveLeft?k.from<=f:k.from<f),(p||(p=[])).push(new Zb(l,m?null:k.from-f,null==k.to?null:k.to-f));d=p;f=1==b.text.length;g=y(b.text).length+(f?e:0);if(c)for(p=0;p<c.length;++p)if(h=c[p],null==h.to)(k=mb(d,h.marker),k)?f&&(h.to=null==k.to?
null:k.to+g):h.to=e;if(d)for(e=0;e<d.length;++e)p=d[e],null!=p.to&&(p.to+=g),null==p.from?mb(c,p.marker)||(p.from=g,f&&(c||(c=[])).push(p)):(p.from+=g,f&&(c||(c=[])).push(p));c&&(c=Sd(c));d&&d!=c&&(d=Sd(d));e=[c];if(!f){var f=b.text.length-2,t;if(0<f&&c)for(g=0;g<c.length;++g)null==c[g].to&&(t||(t=[])).push(new Zb(c[g].marker,null,null));for(c=0;c<f;++c)e.push(t);e.push(d)}return e}function Sd(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 Sf(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!=H(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),f=0;f<a.length;++f){var g=a[f];if(!(0>w(g.to,e.from)||0<w(g.from,e.to))){var h=[f,1],k=w(g.from,e.from),l=w(g.to,e.to);(0>k||!c.inclusiveLeft&&!k)&&h.push({from:g.from,to:e.from});(0<l||
!c.inclusiveRight&&!l)&&h.push({from:e.to,to:g.to});a.splice.apply(a,h);f+=h.length-1}}}return a}function Td(a){var b=a.markedSpans;if(b){for(var c=0;c<b.length;++c)b[c].marker.detachLine(a);a.markedSpans=null}}function Ud(a,b){if(b){for(var c=0;c<b.length;++c)b[c].marker.attachLine(a);a.markedSpans=b}}function Vd(a,b){var c=a.lines.length-b.lines.length;if(0!=c)return c;var c=a.find(),d=b.find(),e=w(c.from,d.from)||(a.inclusiveLeft?-1:0)-(b.inclusiveLeft?-1:0);return e?-e:(c=w(c.to,d.to)||(a.inclusiveRight?
1:0)-(b.inclusiveRight?1:0))?c:b.id-a.id}function Da(a,b){var c=ta&&a.markedSpans,d;if(c)for(var e=void 0,f=0;f<c.length;++f)e=c[f],e.marker.collapsed&&null==(b?e.from:e.to)&&(!d||0>Vd(d,e.marker))&&(d=e.marker);return d}function Wd(a,b,c,d,e){a=u(a,b);if(a=ta&&a.markedSpans)for(b=0;b<a.length;++b){var f=a[b];if(f.marker.collapsed){var g=f.marker.find(0),h=w(g.from,c)||(f.marker.inclusiveLeft?-1:0)-(e.inclusiveLeft?-1:0),k=w(g.to,d)||(f.marker.inclusiveRight?1:0)-(e.inclusiveRight?1:0);if(!(0<=h&&
0>=k||0>=h&&0<=k)&&(0>=h&&(f.marker.inclusiveRight&&e.inclusiveLeft?0<=w(g.to,c):0<w(g.to,c))||0<=h&&(f.marker.inclusiveRight&&e.inclusiveLeft?0>=w(g.from,d):0>w(g.from,d))))return!0}}}function ha(a){for(var b;b=Da(a,!0);)a=b.find(-1,!0).line;return a}function Pc(a,b){var c=u(a,b),d=ha(c);return c==d?b:C(d)}function Xd(a,b){if(b>a.lastLine())return b;var c=u(a,b),d;if(!Ea(a,c))return b;for(;d=Da(c,!1);)c=d.find(1,!0).line;return C(c)+1}function Ea(a,b){var c=ta&&b.markedSpans;if(c)for(var d=void 0,
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&&Qc(a,b,d)))return!0}function Qc(a,b,c){if(null==c.to)return b=c.marker.find(1,!0),Qc(a,b.line,mb(b.line.markedSpans,c.marker));if(c.marker.inclusiveRight&&c.to==b.text.length)return!0;for(var d=void 0,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)&&
Qc(a,b,d))return!0}function ia(a){a=ha(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 $b(a){if(0==a.height)return 0;for(var b=a.text.length,c,d=a;c=Da(d,!0);)c=c.find(0,!0),d=c.from.line,b+=c.from.ch-c.to.ch;for(d=a;c=Da(d,!1);)a=c.find(0,!0),b-=d.text.length-a.from.ch,d=a.to.line,b+=d.text.length-a.to.ch;return b}function Rc(a){var b=
a.display;a=a.doc;b.maxLine=u(a,a.first);b.maxLineLength=$b(b.maxLine);b.maxLineChanged=!0;a.iter(function(a){var d=$b(a);d>b.maxLineLength&&(b.maxLineLength=d,b.maxLine=a)})}function Tf(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=!1,f=0;f<a.length;++f){var g=a[f];if(g.from<c&&g.to>b||b==c&&g.to==b)d(Math.max(g.from,b),Math.min(g.to,c),1==g.level?"rtl":"ltr"),e=!0}e||d(b,c,"ltr")}function Sc(a){return a.level%2?a.to:a.from}function Tc(a){return a.level%2?a.from:a.to}function ac(a){return(a=ba(a))?
Sc(a[0]):0}function bc(a){var b=ba(a);return b?Tc(y(b)):a.text.length}function cc(a,b){var c;nb=null;for(var d=0;d<a.length;++d){var e=a[d];if(e.from<b&&e.to>b)return d;if(e.from==b||e.to==b)if(null==c)c=d;else{var f;f=e.level;var g=a[c].level,h=a[0].level;f=f==h?!0:g==h?!1:f<g;if(f)return e.from!=e.to&&(nb=c),d;e.from!=e.to&&(nb=d);break}}return c}function Uc(a,b,c,d){if(!d)return b+c;do b+=c;while(0<b&&jb(a.text.charAt(b)));return b}function Vc(a,b,c,d){var e=ba(a);if(!e)return Yd(a,b,c,d);var f=
cc(e,b),g=e[f];for(b=Uc(a,b,g.level%2?-c:c,d);;){if(b>g.from&&b<g.to)return b;if(b==g.from||b==g.to){if(cc(e,b)==f)return b;g=e[f+c];return 0<c==g.level%2?g.to:g.from}g=e[f+=c];if(!g)return null;b=0<c==g.level%2?Uc(a,g.to,-1,d):Uc(a,g.from,1,d)}}function Yd(a,b,c,d){b+=c;if(d)for(;0<b&&jb(a.text.charAt(b));)b+=c;return 0>b||b>a.text.length?null:b}function ba(a){var b=a.order;null==b&&(b=a.order=Uf(a.text));return b}function ca(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,!1);else if(a.detachEvent)a.detachEvent("on"+
b,c);else{var d=(a=a._handlers)&&a[b];d&&(c=H(d,c),-1<c&&(a[b]=d.slice(0,c).concat(d.slice(c+1))))}}function E(a,b){var c=a._handlers&&a._handlers[b]||dc;if(c.length)for(var d=Array.prototype.slice.call(arguments,2),e=0;e<c.length;++e)c[e].apply(null,d)}function F(a,b,c){"string"==typeof b&&(b={type:b,preventDefault:function(){this.defaultPrevented=!0}});E(a,c||b.type,a,b);return Wc(b)||b.codemirrorIgnore}function Zd(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==H(a,b[c])&&a.push(b[c])}}function Z(a,b){return 0<(a._handlers&&a._handlers[b]||dc).length}function Na(a){a.prototype.on=function(a,c){v(this,a,c)};a.prototype.off=function(a,c){ca(this,a,c)}}function L(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function $d(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}function Wc(a){return null!=a.defaultPrevented?a.defaultPrevented:0==a.returnValue}function ob(a){L(a);$d(a)}
function ae(a){var b=a.which;null==b&&(a.button&1?b=1:a.button&2?b=3:a.button&4&&(b=2));da&&a.ctrlKey&&1==b&&(b=3);return b}function Vf(a){if(null==Xc){var b=r("span","​");U(a,r("span",[b,document.createTextNode("x")]));0!=a.firstChild.offsetHeight&&(Xc=1>=b.offsetWidth&&2<b.offsetHeight&&!(B&&8>A))}a=Xc?r("span","​"):r("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");a.setAttribute("cm-text","");return a}function Wf(a,b){2<arguments.length&&(b.dependencies=Array.prototype.slice.call(arguments,
2));Yc[a]=b}function ec(a){if("string"==typeof a&&Oa.hasOwnProperty(a))a=Oa[a];else if(a&&"string"==typeof a.name&&Oa.hasOwnProperty(a.name)){var b=Oa[a.name];"string"==typeof b&&(b={name:b});a=Pd(b,a);a.name=b.name}else{if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return ec("application/xml");if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+json$/.test(a))return ec("application/json")}return"string"==typeof a?{name:a}:a||{name:"null"}}function Zc(a,b){b=ec(b);var c=Yc[b.name];if(!c)return Zc(a,
"text/plain");c=c(a,b);if(Pa.hasOwnProperty(b.name)){var d=Pa[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(var f in b.modeProps)c[f]=b.modeProps[f];return c}function Xf(a,b){var c=Pa.hasOwnProperty(a)?Pa[a]:Pa[a]={};aa(b,c)}function ma(a,b){if(!0===b)return b;if(a.copyState)return a.copyState(b);var c={},d;for(d in b){var e=b[d];e instanceof Array&&(e=e.concat([]));c[d]=e}return c}
function $c(a,b){for(var c;a.innerMode;){c=a.innerMode(b);if(!c||c.mode==a)break;b=c.state;a=c.mode}return c||{mode:a,state:b}}function be(a,b,c){return a.startState?a.startState(b,c):!0}function ce(a,b,c,d){var e=[a.state.modeGen],f={};de(a,b.text,a.doc.mode,c,function(a,b){return e.push(a,b)},f,d);c=function(d){var c=a.state.overlays[d],k=1,l=0;de(a,b.text,c.mode,!0,function(a,b){for(var d=k;l<a;){var f=e[k];f>a&&e.splice(k,1,a,e[k+1],f);k+=2;l=Math.min(a,f)}if(b)if(c.opaque)e.splice(d,k-d,a,"overlay "+
b),k=d+2;else for(;d<k;d+=2)f=e[d+1],e[d+1]=(f?f+" ":"")+"overlay "+b},f)};for(d=0;d<a.state.overlays.length;++d)c(d);return{styles:e,classes:f.bgClass||f.textClass?f:null}}function ee(a,b,c){if(!b.styles||b.styles[0]!=a.state.modeGen){var d=pb(a,C(b)),e=ce(a,b,b.text.length>a.options.maxHighlightLength?ma(a.doc.mode,d):d);b.stateAfter=d;b.styles=e.styles;e.classes?b.styleClasses=e.classes:b.styleClasses&&(b.styleClasses=null);c===a.doc.frontier&&a.doc.frontier++}return b.styles}function pb(a,b,c){var d=
a.doc,e=a.display;if(!d.mode.startState)return!0;var f=Yf(a,b,c),g=f>d.first&&u(d,f-1).stateAfter,g=g?ma(d.mode,g):be(d.mode);d.iter(f,b,function(c){ad(a,c.text,g);c.stateAfter=f==b-1||0==f%5||f>=e.viewFrom&&f<e.viewTo?ma(d.mode,g):null;++f});c&&(d.frontier=f);return g}function ad(a,b,c,d){var e=a.doc.mode;a=new qb(b,a.options.tabSize);a.start=a.pos=d||0;for(""==b&&fe(e,c);!a.eol();)bd(e,a,c),a.start=a.pos}function fe(a,b){if(a.blankLine)return a.blankLine(b);if(a.innerMode){var c=$c(a,b);if(c.mode.blankLine)return c.mode.blankLine(c.state)}}
function bd(a,b,c,d){for(var e=0;10>e;e++){d&&(d[0]=$c(a,c).mode);var f=a.token(b,c);if(b.pos>b.start)return f}throw Error("Mode "+a.name+" failed to advance stream.");}function ge(a,b,c,d){var e=function(a){return{start:m.start,end:m.pos,string:m.current(),type:h||null,state:a?ma(f.mode,l):l}},f=a.doc,g=f.mode,h;b=x(f,b);var k=u(f,b.line),l=pb(a,b.line,c),m=new qb(k.text,a.options.tabSize),n;for(d&&(n=[]);(d||m.pos<b.ch)&&!m.eol();)m.start=m.pos,h=bd(g,m,l),d&&n.push(e(!0));return d?n:e()}function he(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 de(a,b,c,d,e,f,g){var h=c.flattenSpans;null==h&&(h=a.options.flattenSpans);var k=0,l=null,m=new qb(b,a.options.tabSize),n,p=a.options.addModeClass&&[null];for(""==b&&he(fe(c,d),f);!m.eol();){m.pos>a.options.maxHighlightLength?(h=!1,
g&&ad(a,b,d,m.pos),m.pos=b.length,n=null):n=he(bd(c,m,d,p),f);if(p){var t=p[0].name;t&&(n="m-"+(n?t+" "+n:t))}if(!h||l!=n){for(;k<m.start;)k=Math.min(m.start,k+5E3),e(k,l);l=n}m.start=m.pos}for(;k<m.pos;)a=Math.min(m.pos,k+5E3),e(a,l),k=a}function Yf(a,b,c){for(var d,e,f=a.doc,g=c?-1:b-(a.doc.mode.innerMode?1E3:100);b>g;--b){if(b<=f.first)return f.first;var h=u(f,b-1);if(h.stateAfter&&(!c||b<=f.frontier))return b;h=Y(h.text,null,a.options.tabSize);if(null==e||d>h)e=b-1,d=h}return e}function Qa(a,
b,c){this.text=a;Ud(this,b);this.height=c?c(this):1}function ie(a,b){if(!a||/^\s*$/.test(a))return null;var c=b.addModeClass?Zf:$f;return c[a]||(c[a]=a.replace(/\S+/g,"cm-$\x26"))}function je(a,b){var c=r("span",null,null,I?"padding-right: .1px":null),c={pre:r("pre",[c],"CodeMirror-line"),content:c,col:0,pos:0,cm:a,trailingSpace:!1,splitSpaces:(B||I)&&a.getOption("lineWrapping")};b.measure={};for(var d=0;d<=(b.rest?b.rest.length:0);d++){var e=d?b.rest[d-1]:b.line,f=void 0;c.pos=0;c.addToken=ag;var g;
g=a.display.measure;if(null!=cd)g=cd;else{var h=U(g,document.createTextNode("AخA")),k=Ra(h,0,1).getBoundingClientRect(),h=Ra(h,1,2).getBoundingClientRect();X(g);g=k&&k.left!=k.right?cd=3>h.right-k.right:!1}g&&(f=ba(e))&&(c.addToken=bg(c.addToken,f));c.map=[];g=b!=a.display.externalMeasured&&C(e);a:{f=c;g=ee(a,e,g);var l=e.markedSpans,k=e.text,h=0;if(l)for(var m=k.length,n=0,p=1,t="",q=void 0,sb=void 0,u=0,v=void 0,w=void 0,x=void 0,fc=void 0,M=void 0;;){if(u==n){for(var v=w=x=fc=sb="",M=null,u=Infinity,
na=[],Q=void 0,y=0;y<l.length;++y){var z=l[y],A=z.marker;"bookmark"==A.type&&z.from==n&&A.widgetNode?na.push(A):z.from<=n&&(null==z.to||z.to>n||A.collapsed&&z.to==n&&z.from==n)?(null!=z.to&&z.to!=n&&u>z.to&&(u=z.to,w=""),A.className&&(v+=" "+A.className),A.css&&(sb=(sb?sb+";":"")+A.css),A.startStyle&&z.from==n&&(x+=" "+A.startStyle),A.endStyle&&z.to==u&&(Q||(Q=[])).push(A.endStyle,z.to),A.title&&!fc&&(fc=A.title),A.collapsed&&(!M||0>Vd(M.marker,A))&&(M=z)):z.from>n&&u>z.from&&(u=z.from)}if(Q)for(y=
0;y<Q.length;y+=2)Q[y+1]==u&&(w+=" "+Q[y]);if(!M||M.from==n)for(Q=0;Q<na.length;++Q)ke(f,0,na[Q]);if(M&&(M.from||0)==n){ke(f,(null==M.to?m+1:M.to)-n,M.marker,null==M.from);if(null==M.to)break a;M.to==n&&(M=!1)}}if(n>=m)break;for(na=Math.min(m,u);;){if(t){Q=n+t.length;M||(y=Q>na?t.slice(0,na-n):t,f.addToken(f,y,q?q+v:v,x,n+y.length==u?w:"",fc,sb));if(Q>=na){t=t.slice(na-n);n=na;break}n=Q;x=""}t=k.slice(h,h=g[p++]);q=ie(g[p++],f.cm.options)}}else for(l=1;l<g.length;l+=2)f.addToken(f,k.slice(h,h=g[l]),
ie(g[l+1],f.cm.options))}e.styleClasses&&(e.styleClasses.bgClass&&(c.bgClass=Gc(e.styleClasses.bgClass,c.bgClass||"")),e.styleClasses.textClass&&(c.textClass=Gc(e.styleClasses.textClass,c.textClass||"")));0==c.map.length&&c.map.push(0,0,c.content.appendChild(Vf(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({}))}I&&(d=c.content.lastChild,/\bcm-tab\b/.test(d.className)||d.querySelector&&
d.querySelector(".cm-tab"))&&(c.content.className="cm-tab-wrap-hack");E(a,"renderLine",a,b.line,c.pre);c.pre.className&&(c.textClass=Gc(c.pre.className,c.textClass||""));return c}function cg(a){var b=r("span","•","cm-invalidchar");b.title="\\u"+a.charCodeAt(0).toString(16);b.setAttribute("aria-label",b.title);return b}function ag(a,b,c,d,e,f,g){if(b){var h;if(a.splitSpaces)if(h=a.trailingSpace,1<b.length&&!/  /.test(b))h=b;else{for(var k="",l=0;l<b.length;l++){var m=b.charAt(l);" "!=m||!h||l!=b.length-
1&&32!=b.charCodeAt(l+1)||(m=" ");k+=m;h=" "==m}h=k}else h=b;k=h;l=a.cm.state.specialChars;m=!1;if(l.test(b)){h=document.createDocumentFragment();for(var n=0;;){l.lastIndex=n;var p=l.exec(b),t=p?p.index-n:b.length-n;if(t){var q=document.createTextNode(k.slice(n,n+t));B&&9>A?h.appendChild(r("span",[q])):h.appendChild(q);a.map.push(a.pos,a.pos+t,q);a.col+=t;a.pos+=t}if(!p)break;n+=t+1;t=void 0;"\t"==p[0]?(p=a.cm.options.tabSize,p-=a.col%p,t=h.appendChild(r("span",Jc(p),"cm-tab")),t.setAttribute("role",
"presentation"),t.setAttribute("cm-text","\t"),a.col+=p):("\r"==p[0]||"\n"==p[0]?(t=h.appendChild(r("span","\r"==p[0]?"␍":"␤","cm-invalidchar")),t.setAttribute("cm-text",p[0])):(t=a.cm.options.specialCharPlaceholder(p[0]),t.setAttribute("cm-text",p[0]),B&&9>A?h.appendChild(r("span",[t])):h.appendChild(t)),a.col+=1);a.map.push(a.pos,a.pos+1,t);a.pos++}}else a.col+=b.length,h=document.createTextNode(k),a.map.push(a.pos,a.pos+b.length,h),B&&9>A&&(m=!0),a.pos+=b.length;a.trailingSpace=32==k.charCodeAt(b.length-
1);if(c||d||e||m||g)return b=c||"",d&&(b+=d),e&&(b+=e),d=r("span",[h],b,g),f&&(d.title=f),a.content.appendChild(d);a.content.appendChild(h)}}function bg(a,b){return function(c,d,e,f,g,h,k){e=e?e+" cm-force-border":"cm-force-border";for(var l=c.pos,m=l+d.length;;){for(var n=void 0,p=0;p<b.length&&!(n=b[p],n.to>l&&n.from<=l);p++);if(n.to>=m)return a(c,d,e,f,g,h,k);a(c,d.slice(0,n.to-l),e,f,null,h,k);f=null;d=d.slice(n.to-l);l=n.to}}}function ke(a,b,c,d){var e=!d&&c.widgetNode;e&&a.map.push(a.pos,a.pos+
b,e);!d&&a.cm.display.input.needsContentAttribute&&(e||(e=a.content.appendChild(document.createElement("span"))),e.setAttribute("cm-marker",c.id));e&&(a.cm.display.input.setUneditable(e),a.content.appendChild(e));a.pos+=b;a.trailingSpace=!1}function le(a,b,c){for(var d=this.line=b,e;d=Da(d,!1);)d=d.find(1,!0).line,(e||(e=[])).push(d);this.size=(this.rest=e)?C(y(this.rest))-c+1:1;this.node=this.text=null;this.hidden=Ea(a,b)}function gc(a,b,c){var d=[],e;for(e=b;e<c;)b=new le(a.doc,u(a.doc,e),e),e+=
b.size,d.push(b);return d}function dg(a,b){var c=a.ownsGroup;if(c)try{var d=c.delayedCallbacks,e=0;do{for(;e<d.length;e++)d[e].call(null);for(var f=0;f<c.ops.length;f++){var g=c.ops[f];if(g.cursorActivityHandlers)for(;g.cursorActivityCalled<g.cursorActivityHandlers.length;)g.cursorActivityHandlers[g.cursorActivityCalled++].call(null,g.cm)}}while(e<d.length)}finally{Sa=null,b(c)}}function R(a,b){var c=a._handlers&&a._handlers[b]||dc;if(c.length){var d=Array.prototype.slice.call(arguments,2),e;Sa?e=
Sa.delayedCallbacks:tb?e=tb:(e=tb=[],setTimeout(eg,0));for(var f=function(a){e.push(function(){return c[a].apply(null,d)})},g=0;g<c.length;++g)f(g)}}function eg(){var a=tb;tb=null;for(var b=0;b<a.length;++b)a[b]()}function me(a,b,c,d){for(var e=0;e<b.changes.length;e++){var f=b.changes[e];if("text"==f){var f=b,g=f.text.className,h=ne(a,f);f.text==f.node&&(f.node=h.pre);f.text.parentNode.replaceChild(h.pre,f.text);f.text=h.pre;h.bgClass!=f.bgClass||h.textClass!=f.textClass?(f.bgClass=h.bgClass,f.textClass=
h.textClass,dd(f)):g&&(f.text.className=g)}else if("gutter"==f)oe(a,b,c,d);else if("class"==f)dd(b);else if("widget"==f){f=a;g=b;h=d;g.alignable&&(g.alignable=null);for(var k=g.node.firstChild,l=void 0;k;k=l)l=k.nextSibling,"CodeMirror-linewidget"==k.className&&g.node.removeChild(k);pe(f,g,h)}}b.changes=null}function ub(a){a.node==a.text&&(a.node=r("div",null,null,"position: relative"),a.text.parentNode&&a.text.parentNode.replaceChild(a.node,a.text),a.node.appendChild(a.text),B&&8>A&&(a.node.style.zIndex=
2));return a.node}function ne(a,b){var c=a.display.externalMeasured;return c&&c.line==b.line?(a.display.externalMeasured=null,b.measure=c.measure,c.built):je(a,b)}function dd(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=ub(a);a.background=c.insertBefore(r("div",null,b),c.firstChild)}a.line.wrapClass?ub(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 oe(a,b,c,d){b.gutter&&(b.node.removeChild(b.gutter),b.gutter=null);b.gutterBackground&&(b.node.removeChild(b.gutterBackground),b.gutterBackground=null);if(b.line.gutterClass){var e=ub(b);b.gutterBackground=r("div",null,"CodeMirror-gutter-background "+b.line.gutterClass,"left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px; width: "+
d.gutterTotalWidth+"px");e.insertBefore(b.gutterBackground,b.text)}e=b.line.gutterMarkers;if(a.options.lineNumbers||e){var f=ub(b),g=b.gutter=r("div",null,"CodeMirror-gutter-wrapper","left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px");a.display.input.setUneditable(g);f.insertBefore(g,b.text);b.line.gutterClass&&(g.className+=" "+b.line.gutterClass);!a.options.lineNumbers||e&&e["CodeMirror-linenumbers"]||(b.lineNumber=g.appendChild(r("div",Mc(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],(f=e.hasOwnProperty(c)&&e[c])&&g.appendChild(r("div",[f],"CodeMirror-gutter-elt","left: "+d.gutterLeft[c]+"px; width: "+d.gutterWidth[c]+"px"))}}function fg(a,b,c,d){var e=ne(a,b);b.text=b.node=e.pre;e.bgClass&&(b.bgClass=e.bgClass);e.textClass&&(b.textClass=e.textClass);dd(b);oe(a,b,c,d);pe(a,b,d);return b.node}function pe(a,b,c){qe(a,
b.line,b,c,!0);if(b.rest)for(var d=0;d<b.rest.length;d++)qe(a,b.rest[d],b,c,!1)}function qe(a,b,c,d,e){if(b.widgets){var f=ub(c),g=0;for(b=b.widgets;g<b.length;++g){var h=b[g],k=r("div",[h.node],"CodeMirror-linewidget");h.handleMouseEvents||k.setAttribute("cm-ignore-events","true");var l=h,m=k,n=d;if(l.noHScroll){(c.alignable||(c.alignable=[])).push(m);var p=n.wrapperWidth;m.style.left=n.fixedPos+"px";l.coverGutter||(p-=n.gutterTotalWidth,m.style.paddingLeft=n.gutterTotalWidth+"px");m.style.width=
p+"px"}l.coverGutter&&(m.style.zIndex=5,m.style.position="relative",l.noHScroll||(m.style.marginLeft=-n.gutterTotalWidth+"px"));a.display.input.setUneditable(k);e&&h.above?f.insertBefore(k,c.gutter||c.text):f.appendChild(k);R(h,"redraw")}}}function vb(a){if(null!=a.height)return a.height;var b=a.doc.cm;if(!b)return 0;if(!Tb(document.body,a.node)){var c="position: relative;";a.coverGutter&&(c+="margin-left: -"+b.display.gutters.offsetWidth+"px;");a.noHScroll&&(c+="width: "+b.display.wrapper.clientWidth+
"px;");U(b.display.measure,r("div",[a.node],null,c))}return a.height=a.node.parentNode.offsetHeight}function oa(a,b){for(var c=b.target||b.srcElement;c!=a.wrapper;c=c.parentNode)if(!c||1==c.nodeType&&"true"==c.getAttribute("cm-ignore-events")||c.parentNode==a.sizer&&c!=a.mover)return!0}function ed(a){return a.mover.offsetHeight-a.lineSpace.offsetHeight}function re(a){if(a.cachedPaddingH)return a.cachedPaddingH;var b=U(a.measure,r("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 ja(a){return 30-a.display.nativeBarWidth}function Fa(a){return a.display.scroller.clientWidth-ja(a)-a.display.barWidth}function fd(a){return a.display.scroller.clientHeight-ja(a)-a.display.barHeight}function se(a,b,c){if(a.line==b)return{map:a.measure.map,cache:a.measure.cache};for(var d=0;d<a.rest.length;d++)if(a.rest[d]==b)return{map:a.measure.maps[d],cache:a.measure.caches[d]};
for(b=0;b<a.rest.length;b++)if(C(a.rest[b])>c)return{map:a.measure.maps[b],cache:a.measure.caches[b],before:!0}}function gd(a,b){if(b>=a.display.viewFrom&&b<a.display.viewTo)return a.display.view[Ga(a,b)];var c=a.display.externalMeasured;if(c&&b>=c.lineN&&b<c.lineN+c.size)return c}function hc(a,b){var c=C(b),d=gd(a,c);d&&!d.text?d=null:d&&d.changes&&(me(a,d,c,hd(a)),a.curOp.forceUpdate=!0);if(!d){var e;e=ha(b);d=C(e);e=a.display.externalMeasured=new le(a.doc,e,d);e.lineN=d;d=e.built=je(a,e);e.text=
d.pre;U(a.display.lineMeasure,d.pre);d=e}c=se(d,b,c);return{line:b,view:d,rect:null,map:c.map,cache:c.cache,before:c.before,hasHeights:!1}}function ic(a,b,c,d,e){b.before&&(c=-1);var f=c+(d||"");if(b.cache.hasOwnProperty(f))a=b.cache[f];else{b.rect||(b.rect=b.view.text.getBoundingClientRect());if(!b.hasHeights){var g=b.view,h=b.rect,k=a.options.lineWrapping,l=k&&Fa(a);if(!g.measure.heights||k&&g.measure.width!=l){var m=g.measure.heights=[];if(k)for(g.measure.width=l,g=g.text.firstChild.getClientRects(),
k=0;k<g.length-1;k++){var l=g[k],n=g[k+1];2<Math.abs(l.bottom-n.bottom)&&m.push((l.bottom+n.top)/2-h.top)}m.push(h.bottom-h.top)}b.hasHeights=!0}m=d;g=te(b.map,c,m);d=g.node;h=g.start;k=g.end;c=g.collapse;var p;if(3==d.nodeType){for(var t=0;4>t;t++){for(;h&&jb(b.line.text.charAt(g.coverStart+h));)--h;for(;g.coverStart+k<g.coverEnd&&jb(b.line.text.charAt(g.coverStart+k));)++k;if(B&&9>A&&0==h&&k==g.coverEnd-g.coverStart)p=d.parentNode.getBoundingClientRect();else{p=Ra(d,h,k).getClientRects();k=ue;if("left"==
m)for(l=0;l<p.length&&(k=p[l]).left==k.right;l++);else for(l=p.length-1;0<=l&&(k=p[l]).left==k.right;l--);p=k}if(p.left||p.right||0==h)break;k=h;--h;c="right"}B&&11>A&&((t=!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI)||(null!=id?t=id:(m=U(a.display.measure,r("span","x")),t=m.getBoundingClientRect(),m=Ra(m,0,1).getBoundingClientRect(),t=id=1<Math.abs(t.left-m.left)),t=!t),t||(t=screen.logicalXDPI/screen.deviceXDPI,m=screen.logicalYDPI/screen.deviceYDPI,p={left:p.left*
t,right:p.right*t,top:p.top*m,bottom:p.bottom*m}))}else 0<h&&(c=m="right"),p=a.options.lineWrapping&&1<(t=d.getClientRects()).length?t["right"==m?t.length-1:0]:d.getBoundingClientRect();!(B&&9>A)||h||p&&(p.left||p.right)||(p=(p=d.parentNode.getClientRects()[0])?{left:p.left,right:p.left+wb(a.display),top:p.top,bottom:p.bottom}:ue);d=p.top-b.rect.top;h=p.bottom-b.rect.top;t=(d+h)/2;m=b.view.measure.heights;for(g=0;g<m.length-1&&!(t<m[g]);g++);c={left:("right"==c?p.right:p.left)-b.rect.left,right:("left"==
c?p.left:p.right)-b.rect.left,top:g?m[g-1]:0,bottom:m[g]};p.left||p.right||(c.bogus=!0);a.options.singleCursorHeightPerLine||(c.rtop=d,c.rbottom=h);a=c;a.bogus||(b.cache[f]=a)}return{left:a.left,right:a.right,top:e?a.rtop:a.top,bottom:e?a.rbottom:a.bottom}}function te(a,b,c){for(var d,e,f,g,h,k,l=0;l<a.length;l+=3){h=a[l];k=a[l+1];if(b<h)e=0,f=1,g="left";else if(b<k)e=b-h,f=e+1;else if(l==a.length-3||b==k&&a[l+3]>b)f=k-h,e=f-1,b>=k&&(g="right");if(null!=e){d=a[l+2];h==k&&c==(d.insertLeft?"left":"right")&&
(g=c);if("left"==c&&0==e)for(;l&&a[l-2]==a[l-3]&&a[l-1].insertLeft;)d=a[(l-=3)+2],g="left";if("right"==c&&e==k-h)for(;l<a.length-3&&a[l+3]==a[l+4]&&!a[l+5].insertLeft;)d=a[(l+=3)+2],g="right";break}}return{node:d,start:e,end:f,collapse:g,coverStart:h,coverEnd:k}}function ve(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 we(a){a.display.externalMeasure=null;X(a.display.lineMeasure);for(var b=0;b<a.display.view.length;b++)ve(a.display.view[b])}
function xb(a){we(a);a.display.cachedCharWidth=a.display.cachedTextHeight=a.display.cachedPaddingH=null;a.options.lineWrapping||(a.display.maxLineChanged=!0);a.display.lineNumChars=null}function jd(a,b,c,d,e){if(!e&&b.widgets)for(e=0;e<b.widgets.length;++e)if(b.widgets[e].above){var f=vb(b.widgets[e]);c.top+=f;c.bottom+=f}if("line"==d)return c;d||(d="local");b=ia(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 xe(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 jc(a,b,c,d,e){d||(d=u(a.doc,b.line));var f=d;b=b.ch;d=ic(a,hc(a,d),b,e);return jd(a,f,d,c)}function pa(a,b,c,d,e,f){function g(b,g){var h=ic(a,e,b,g?"right":"left",f);g?h.left=h.right:h.right=h.left;return jd(a,d,h,c)}function h(a,b){var d=k[b],c=d.level%2;a==Sc(d)&&b&&d.level<k[b-1].level?(d=k[--b],a=Tc(d)-(d.level%2?0:1),c=!0):a==Tc(d)&&b<k.length-1&&d.level<k[b+1].level&&(d=k[++b],a=Sc(d)-
d.level%2,c=!1);return c&&a==d.to&&a>d.from?g(a-1):g(a,c)}d=d||u(a.doc,b.line);e||(e=hc(a,d));var k=ba(d);b=b.ch;if(!k)return g(b);var l=cc(k,b),l=h(b,l);null!=nb&&(l.other=h(b,nb));return l}function ye(a,b){var c=0;b=x(a.doc,b);a.options.lineWrapping||(c=wb(a.display)*b.ch);var d=u(a.doc,b.line),e=ia(d)+a.display.lineSpace.offsetTop;return{left:c,right:c,top:e,bottom:e+d.height}}function kc(a,b,c,d){a=q(a,b);a.xRel=d;c&&(a.outside=!0);return a}function kd(a,b,c){var d=a.doc;c+=a.display.viewOffset;
if(0>c)return kc(d.first,0,!0,-1);var e=Ca(d,c),f=d.first+d.size-1;if(e>f)return kc(d.first+d.size-1,u(d,f).text.length,!0,1);0>b&&(b=0);for(d=u(d,e);;)if(e=gg(a,d,e,b,c),f=(d=Da(d,!1))&&d.find(0,!0),d&&(e.ch>f.from.ch||e.ch==f.from.ch&&0<e.xRel))e=C(d=f.to.line);else return e}function gg(a,b,c,d,e){function f(d){d=pa(a,q(c,d),"line",b,l);h=!0;if(g>d.bottom)return d.left-k;if(g<d.top)return d.left+k;h=!1;return d.left}var g=e-ia(b),h=!1,k=2*a.display.wrapper.clientWidth,l=hc(a,b);e=ba(b);var m=b.text.length,
n=ac(b),p=bc(b),t=f(n),rb=h,u=f(p),r=h;if(d>u)return kc(c,p,r,1);for(;;){if(e?p==n||p==Vc(b,n,1):1>=p-n){m=d<t||d-t<=u-d?n:p;rb=m==n?rb:r;n=d-(m==n?t:u);r&&!e&&!/\s/.test(b.text.charAt(m))&&0<n&&m<b.text.length&&1<l.view.measure.heights.length&&(e=ic(a,l,m,"right"),g<=e.bottom&&g>=e.top&&Math.abs(d-e.right)<n&&(rb=!1,m++,n=d-e.right));for(;jb(b.text.charAt(m));)++m;return kc(c,m,rb,-1>n?-1:1<n?1:0)}var v=Math.ceil(m/2),w=n+v;if(e)for(var w=n,x=0;x<v;++x)w=Vc(b,w,1);x=f(w);if(x>d){p=w;u=x;if(r=h)u+=
1E3;m=v}else n=w,t=x,rb=h,m-=v}}function Ha(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==Ia){Ia=r("pre");for(var b=0;49>b;++b)Ia.appendChild(document.createTextNode("x")),Ia.appendChild(r("br"));Ia.appendChild(document.createTextNode("x"))}U(a.measure,Ia);b=Ia.offsetHeight/50;3<b&&(a.cachedTextHeight=b);X(a.measure);return b||1}function wb(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=r("span","xxxxxxxxxx"),c=r("pre",[b]);U(a.measure,c);b=b.getBoundingClientRect();
b=(b.right-b.left)/10;2<b&&(a.cachedCharWidth=b);return b||10}function hd(a){for(var b=a.display,c={},d={},e=b.gutters.clientLeft,f=b.gutters.firstChild,g=0;f;f=f.nextSibling,++g)c[a.options.gutters[g]]=f.offsetLeft+f.clientLeft+e,d[a.options.gutters[g]]=f.clientWidth;return{fixedPos:ld(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function ld(a){return a.scroller.getBoundingClientRect().left-a.sizer.getBoundingClientRect().left}function ze(a){var b=
Ha(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/wb(a.display)-3);return function(e){if(Ea(a.doc,e))return 0;var f=0;if(e.widgets)for(var g=0;g<e.widgets.length;g++)e.widgets[g].height&&(f+=e.widgets[g].height);return c?f+(Math.ceil(e.text.length/d)||1)*b:f+b}}function md(a){var b=a.doc,c=ze(a);b.iter(function(a){var b=c(a);b!=a.height&&ga(a,b)})}function Ja(a,b,c,d){var e=a.display;if(!c&&"true"==(b.target||b.srcElement).getAttribute("cm-not-content"))return null;
var f,g;c=e.lineSpace.getBoundingClientRect();try{f=b.clientX-c.left,g=b.clientY-c.top}catch(h){return null}b=kd(a,f,g);var k;d&&1==b.xRel&&(k=u(a.doc,b.line).text).length==b.ch&&(d=Y(k,k.length,a.options.tabSize)-k.length,b=q(b.line,Math.max(0,Math.round((f-re(a.display).left)/wb(a.display))-d)));return b}function Ga(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 yb(a){a.display.input.showSelection(a.display.input.prepareSelection())}
function Ae(a,b){for(var c=a.doc,d={},e=d.cursors=document.createDocumentFragment(),f=d.selection=document.createDocumentFragment(),g=0;g<c.sel.ranges.length;g++)if(!1!==b||g!=c.sel.primIndex){var h=c.sel.ranges[g];if(!(h.from().line>=a.display.viewTo||h.to().line<a.display.viewFrom)){var k=h.empty();(k||a.options.showCursorWhenSelecting)&&Be(a,h.head,e);k||hg(a,h,f)}}return d}function Be(a,b,c){b=pa(a,b,"div",null,null,!a.options.singleCursorHeightPerLine);var d=c.appendChild(r("div"," ","CodeMirror-cursor"));
d.style.left=b.left+"px";d.style.top=b.top+"px";d.style.height=Math.max(0,b.bottom-b.top)*a.options.cursorHeight+"px";b.other&&(a=c.appendChild(r("div"," ","CodeMirror-cursor CodeMirror-secondarycursor")),a.style.display="",a.style.left=b.other.left+"px",a.style.top=b.other.top+"px",a.style.height=.85*(b.other.bottom-b.other.top)+"px")}function hg(a,b,c){function d(a,b,d,c){0>b&&(b=0);b=Math.round(b);c=Math.round(c);h.appendChild(r("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px;\n                             top: "+
b+"px; width: "+(null==d?m-a:d)+"px;\n                             height: "+(c-b)+"px"))}function e(b,c,e){var f=u(g,b),h=f.text.length,k,n;Tf(ba(f),c||0,null==e?h:e,function(g,u,r){var w=jc(a,q(b,g),"div",f,"left"),v,x;g==u?(v=w,r=x=w.left):(v=jc(a,q(b,u-1),"div",f,"right"),"rtl"==r&&(r=w,w=v,v=r),r=w.left,x=v.right);null==c&&0==g&&(r=l);3<v.top-w.top&&(d(r,w.top,null,w.bottom),r=l,w.bottom<v.top&&d(r,w.bottom,null,v.top));null==e&&u==h&&(x=m);if(!k||w.top<k.top||w.top==k.top&&w.left<k.left)k=w;
if(!n||v.bottom>n.bottom||v.bottom==n.bottom&&v.right>n.right)n=v;r<l+1&&(r=l);d(r,v.top,x-r,v.bottom)});return{start:k,end:n}}var f=a.display,g=a.doc,h=document.createDocumentFragment(),k=re(a.display),l=k.left,m=Math.max(f.sizerWidth,Fa(a)-f.sizer.offsetLeft)-k.right,f=b.from();b=b.to();if(f.line==b.line)e(f.line,f.ch,b.ch);else{var n=u(g,f.line),k=u(g,b.line),k=ha(n)==ha(k),f=e(f.line,f.ch,k?n.text.length+1:null).end;b=e(b.line,k?0:null,b.ch).start;k&&(f.top<b.top-2?(d(f.right,f.top,null,f.bottom),
d(l,b.top,b.left,b.bottom)):d(f.right,f.top,b.left-f.right,f.bottom));f.bottom<b.top&&d(l,f.bottom,null,b.top)}c.appendChild(h)}function nd(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(){return b.cursorDiv.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate):0>a.options.cursorBlinkRate&&(b.cursorDiv.style.visibility="hidden")}}function Ce(a){a.state.focused||(a.display.input.focus(),
od(a))}function ig(a){a.state.delayingBlurEvent=!0;setTimeout(function(){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1,zb(a))},100)}function od(a,b){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1);"nocursor"!=a.options.readOnly&&(a.state.focused||(E(a,"focus",a,b),a.state.focused=!0,Ma(a.display.wrapper,"CodeMirror-focused"),a.curOp||a.display.selForContextMenu==a.doc.sel||(a.display.input.reset(),I&&setTimeout(function(){return a.display.input.reset(!0)},20)),a.display.input.receivedFocus()),
nd(a))}function zb(a,b){a.state.delayingBlurEvent||(a.state.focused&&(E(a,"blur",a,b),a.state.focused=!1,Ta(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout(function(){a.state.focused||(a.display.shift=!1)},150))}function pd(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=ld(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,f=d+"px",g=0;g<c.length;g++)if(!c[g].hidden){a.options.fixedGutter&&(c[g].gutter&&
(c[g].gutter.style.left=f),c[g].gutterBackground&&(c[g].gutterBackground.style.left=f));var h=c[g].alignable;if(h)for(var k=0;k<h.length;k++)h[k].style.left=f}a.options.fixedGutter&&(b.gutters.style.left=d+e+"px")}}function De(a){if(!a.options.lineNumbers)return!1;var b=a.doc,b=Mc(a.options,b.first+b.size-1),c=a.display;if(b.length!=c.lineNumChars){var d=c.measure.appendChild(r("div",[r("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)+1;c.lineNumWidth=c.lineNumInnerWidth+d;c.lineNumChars=c.lineNumInnerWidth?b.length:-1;c.lineGutter.style.width=c.lineNumWidth+"px";qd(a);return!0}return!1}function lc(a){a=a.display;for(var b=a.lineDiv.offsetTop,c=0;c<a.view.length;c++){var d=a.view[c],e=void 0;if(!d.hidden){if(B&&8>A)var f=d.node.offsetTop+d.node.offsetHeight,e=f-b,b=f;else e=d.node.getBoundingClientRect(),e=e.bottom-e.top;f=d.line.height-e;2>e&&(e=Ha(a));if(.001<f||-.001>
f)if(ga(d.line,e),Ee(d.line),d.rest)for(e=0;e<d.rest.length;e++)Ee(d.rest[e])}}}function Ee(a){if(a.widgets)for(var b=0;b<a.widgets.length;++b)a.widgets[b].height=a.widgets[b].node.parentNode.offsetHeight}function rd(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=Ca(b,d),e=Ca(b,e);if(c&&c.ensure){var f=c.ensure.from.line;c=c.ensure.to.line;f<d?(d=f,e=Ca(b,ia(u(b,f))+a.wrapper.clientHeight)):
Math.min(c,b.lastLine())>=e&&(d=Ca(b,ia(u(b,c))-a.wrapper.clientHeight),e=c)}return{from:d,to:Math.max(e,d+1)}}function Ab(a,b){2>Math.abs(a.doc.scrollTop-b)||(a.doc.scrollTop=b,sa||sd(a,{top:b}),a.display.scroller.scrollTop!=b&&(a.display.scroller.scrollTop=b),a.display.scrollbars.setScrollTop(b),sa&&sd(a),Bb(a,100))}function Ua(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,pd(a),a.display.scroller.scrollLeft!=
b&&(a.display.scroller.scrollLeft=b),a.display.scrollbars.setScrollLeft(b))}function Fe(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}}function jg(a){a=Fe(a);a.x*=V;a.y*=V;return a}function Ge(a,b){var c=Fe(b),d=c.x,c=c.y,e=a.display,f=e.scroller,g=f.scrollWidth>f.clientWidth,h=f.scrollHeight>f.clientHeight;if(d&&g||c&&h){if(c&&da&&I){var g=b.target,k=
e.view;a:for(;g!=f;g=g.parentNode)for(var l=0;l<k.length;l++)if(k[l].node==g){a.display.currentWheelTarget=g;break a}}!d||sa||ea||null==V?(c&&null!=V&&(h=c*V,g=a.doc.scrollTop,k=g+e.wrapper.clientHeight,0>h?g=Math.max(0,g+h-50):k=Math.min(a.doc.height,k+h+50),sd(a,{top:g,bottom:k})),20>mc&&(null==e.wheelStartX?(e.wheelStartX=f.scrollLeft,e.wheelStartY=f.scrollTop,e.wheelDX=d,e.wheelDY=c,setTimeout(function(){if(null!=e.wheelStartX){var a=f.scrollLeft-e.wheelStartX,b=f.scrollTop-e.wheelStartY,a=b&&
e.wheelDY&&b/e.wheelDY||a&&e.wheelDX&&a/e.wheelDX;e.wheelStartX=e.wheelStartY=null;a&&(V=(V*mc+a)/(mc+1),++mc)}},200)):(e.wheelDX+=d,e.wheelDY+=c))):(c&&h&&Ab(a,Math.max(0,Math.min(f.scrollTop+c*V,f.scrollHeight-f.clientHeight))),Ua(a,Math.max(0,Math.min(f.scrollLeft+d*V,f.scrollWidth-f.clientWidth))),(!c||c&&h)&&L(b),e.wheelStartX=null)}}function Cb(a){var b=a.display,c=b.gutters.offsetWidth,d=Math.round(a.doc.height+ed(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+ja(a)+b.barHeight,nativeBarWidth:b.nativeBarWidth,gutterWidth:c}}function td(a,b,c){this.cm=c;var d=this.vert=r("div",[r("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),e=this.horiz=r("div",[r("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");a(d);a(e);v(d,"scroll",function(){d.clientHeight&&b(d.scrollTop,
"vertical")});v(e,"scroll",function(){e.clientWidth&&b(e.scrollLeft,"horizontal")});this.checkedZeroWidth=!1;B&&8>A&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function ud(){}function Va(a,b){b||(b=Cb(a));var c=a.display.barWidth,d=a.display.barHeight;He(a,b);for(var e=0;4>e&&c!=a.display.barWidth||d!=a.display.barHeight;e++)c!=a.display.barWidth&&a.options.lineWrapping&&lc(a),He(a,Cb(a)),c=a.display.barWidth,d=a.display.barHeight}function He(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";c.heightForcer.style.borderBottom=d.bottom+"px solid transparent";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 Ie(a){a.display.scrollbars&&(a.display.scrollbars.clear(),a.display.scrollbars.addClass&&Ta(a.display.wrapper,a.display.scrollbars.addClass));a.display.scrollbars=new Je[a.options.scrollbarStyle](function(b){a.display.wrapper.insertBefore(b,a.display.scrollbarFiller);v(b,"mousedown",function(){a.state.focused&&setTimeout(function(){return a.display.input.focus()},0)});b.setAttribute("cm-not-content","true")},
function(b,c){"horizontal"==c?Ua(a,b):Ab(a,b)},a);a.display.scrollbars.addClass&&Ma(a.display.wrapper,a.display.scrollbars.addClass)}function nc(a,b,c,d,e){var f=a.display,g=Ha(a.display);0>c&&(c=0);var h=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:f.scroller.scrollTop,k=fd(a),l={};e-c>k&&(e=c+k);var m=a.doc.height+ed(f),n=c<g,g=e>m-g;c<h?l.scrollTop=n?0:c:e>h+k&&(c=Math.min(c,(g?m:e)-k),c!=h&&(l.scrollTop=c));h=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft:f.scroller.scrollLeft;a=Fa(a)-
(a.options.fixedGutter?f.gutters.offsetWidth:0);(f=d-b>a)&&(d=b+a);10>b?l.scrollLeft=0:b<h?l.scrollLeft=Math.max(0,b-(f?0:10)):d>a+h-3&&(l.scrollLeft=d+(f?0:10)-a);return l}function oc(a,b,c){null==b&&null==c||pc(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 Wa(a){pc(a);var b=a.getCursor(),c=b,d=b;a.options.lineWrapping||(c=b.ch?q(b.line,b.ch-1):b,
d=q(b.line,b.ch+1));a.curOp.scrollToPos={from:c,to:d,margin:a.options.cursorScrollMargin,isCursor:!0}}function pc(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=ye(a,b.from),d=ye(a,b.to),b=nc(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 Xa(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,focus:!1,id:++kg};a=a.curOp;Sa?Sa.ops.push(a):a.ownsGroup=Sa={ops:[a],delayedCallbacks:[]}}function Ya(a){dg(a.curOp,function(a){for(var c=0;c<a.ops.length;c++)a.ops[c].cm.curOp=null;a=a.ops;for(c=0;c<a.length;c++){var d=a[c],e=d.cm,f=e.display,g=e.display;!g.scrollbarsClipped&&g.scroller.offsetWidth&&(g.nativeBarWidth=g.scroller.offsetWidth-g.scroller.clientWidth,g.heightForcer.style.height=
ja(e)+"px",g.sizer.style.marginBottom=-g.nativeBarWidth+"px",g.sizer.style.borderRightWidth=ja(e)+"px",g.scrollbarsClipped=!0);d.updateMaxLine&&Rc(e);d.mustUpdate=d.viewChanged||d.forceUpdate||null!=d.scrollTop||d.scrollToPos&&(d.scrollToPos.from.line<f.viewFrom||d.scrollToPos.to.line>=f.viewTo)||f.maxLineChanged&&e.options.lineWrapping;d.update=d.mustUpdate&&new qc(e,d.mustUpdate&&{top:d.scrollTop,ensure:d.scrollToPos},d.forceUpdate)}for(c=0;c<a.length;c++)d=a[c],d.updatedDisplay=d.mustUpdate&&vd(d.cm,
d.update);for(c=0;c<a.length;c++)if(d=a[c],e=d.cm,f=e.display,d.updatedDisplay&&lc(e),d.barMeasure=Cb(e),f.maxLineChanged&&!e.options.lineWrapping&&(g=void 0,g=f.maxLine.text.length,g=ic(e,hc(e,f.maxLine),g,void 0),d.adjustWidthTo=g.left+3,e.display.sizerWidth=d.adjustWidthTo,d.barMeasure.scrollWidth=Math.max(f.scroller.clientWidth,f.sizer.offsetLeft+d.adjustWidthTo+ja(e)+e.display.barWidth),d.maxScrollLeft=Math.max(0,f.sizer.offsetLeft+d.adjustWidthTo-Fa(e))),d.updatedDisplay||d.selectionChanged)d.preparedSelection=
f.input.prepareSelection(d.focus);for(c=0;c<a.length;c++)d=a[c],e=d.cm,null!=d.adjustWidthTo&&(e.display.sizer.style.minWidth=d.adjustWidthTo+"px",d.maxScrollLeft<e.doc.scrollLeft&&Ua(e,Math.min(e.display.scroller.scrollLeft,d.maxScrollLeft),!0),e.display.maxLineChanged=!1),f=d.focus&&d.focus==la()&&(!document.hasFocus||document.hasFocus()),d.preparedSelection&&e.display.input.showSelection(d.preparedSelection,f),(d.updatedDisplay||d.startHeight!=e.doc.height)&&Va(e,d.barMeasure),d.updatedDisplay&&
wd(e,d.barMeasure),d.selectionChanged&&nd(e),e.state.focused&&d.updateInput&&e.display.input.reset(d.typing),f&&Ce(d.cm);for(c=0;c<a.length;c++){d=a[c];e=d.cm;f=e.display;g=e.doc;d.updatedDisplay&&Ke(e,d.update);null==f.wheelStartX||null==d.scrollTop&&null==d.scrollLeft&&!d.scrollToPos||(f.wheelStartX=f.wheelStartY=null);null==d.scrollTop||f.scroller.scrollTop==d.scrollTop&&!d.forceScroll||(g.scrollTop=Math.max(0,Math.min(f.scroller.scrollHeight-f.scroller.clientHeight,d.scrollTop)),f.scrollbars.setScrollTop(g.scrollTop),
f.scroller.scrollTop=g.scrollTop);null==d.scrollLeft||f.scroller.scrollLeft==d.scrollLeft&&!d.forceScroll||(g.scrollLeft=Math.max(0,Math.min(f.scroller.scrollWidth-f.scroller.clientWidth,d.scrollLeft)),f.scrollbars.setScrollLeft(g.scrollLeft),f.scroller.scrollLeft=g.scrollLeft,pd(e));if(d.scrollToPos){var h=void 0,k=x(g,d.scrollToPos.from),h=x(g,d.scrollToPos.to),l=d.scrollToPos.margin;null==l&&(l=0);for(var m=void 0,n=0;5>n;n++){var p=!1,m=pa(e,k),t=h&&h!=k?pa(e,h):m,t=nc(e,Math.min(m.left,t.left),
Math.min(m.top,t.top)-l,Math.max(m.left,t.left),Math.max(m.bottom,t.bottom)+l),q=e.doc.scrollTop,u=e.doc.scrollLeft;null!=t.scrollTop&&(Ab(e,t.scrollTop),1<Math.abs(e.doc.scrollTop-q)&&(p=!0));null!=t.scrollLeft&&(Ua(e,t.scrollLeft),1<Math.abs(e.doc.scrollLeft-u)&&(p=!0));if(!p)break}h=m;d.scrollToPos.isCursor&&e.state.focused&&(F(e,"scrollCursorIntoView")||(l=e.display,m=l.sizer.getBoundingClientRect(),k=null,0>h.top+m.top?k=!0:h.bottom+m.top>(window.innerHeight||document.documentElement.clientHeight)&&
(k=!1),null==k||lg||(h=r("div","​",null,"position: absolute;\n                         top: "+(h.top-l.viewOffset-e.display.lineSpace.offsetTop)+"px;\n                         height: "+(h.bottom-h.top+ja(e)+l.barHeight)+"px;\n                         left: "+h.left+"px; width: 2px;"),e.display.lineSpace.appendChild(h),h.scrollIntoView(k),e.display.lineSpace.removeChild(h))))}h=d.maybeHiddenMarkers;k=d.maybeUnhiddenMarkers;if(h)for(l=0;l<h.length;++l)h[l].lines.length||E(h[l],"hide");if(k)for(h=0;h<
k.length;++h)k[h].lines.length&&E(k[h],"unhide");f.wrapper.offsetHeight&&(g.scrollTop=e.display.scroller.scrollTop);d.changeObjs&&E(e,"changes",e,d.changeObjs);d.update&&d.update.finish()}})}function W(a,b){if(a.curOp)return b();Xa(a);try{return b()}finally{Ya(a)}}function G(a,b){return function(){if(a.curOp)return b.apply(a,arguments);Xa(a);try{return b.apply(a,arguments)}finally{Ya(a)}}}function O(a){return function(){if(this.curOp)return a.apply(this,arguments);Xa(this);try{return a.apply(this,
arguments)}finally{Ya(this)}}}function J(a){return function(){var b=this.cm;if(!b||b.curOp)return a.apply(this,arguments);Xa(b);try{return a.apply(this,arguments)}finally{Ya(b)}}}function N(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)ta&&Pc(a.doc,b)<e.viewTo&&ua(a);else if(c<=e.viewFrom)ta&&Xd(a.doc,c+d)>e.viewFrom?ua(a):
(e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&c>=e.viewTo)ua(a);else if(b<=e.viewFrom){var f=rc(a,c,c+d,1);f?(e.view=e.view.slice(f.index),e.viewFrom=f.lineN,e.viewTo+=d):ua(a)}else if(c>=e.viewTo)(f=rc(a,b,b,-1))?(e.view=e.view.slice(0,f.index),e.viewTo=f.lineN):ua(a);else{var f=rc(a,b,b,-1),g=rc(a,c,c+d,1);f&&g?(e.view=e.view.slice(0,f.index).concat(gc(a,f.lineN,g.lineN)).concat(e.view.slice(g.index)),e.viewTo+=d):ua(a)}if(a=e.externalMeasured)c<a.lineN?a.lineN+=d:b<a.lineN+a.size&&(e.externalMeasured=
null)}function va(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[Ga(a,b)],null!=a.node&&(a=a.changes||(a.changes=[]),-1==H(a,c)&&a.push(c)))}function ua(a){a.display.viewFrom=a.display.viewTo=a.doc.first;a.display.view=[];a.display.viewOffset=0}function rc(a,b,c,d){var e=Ga(a,b),f=a.display.view;if(!ta||c==a.doc.first+a.doc.size)return{index:e,lineN:c};for(var g=a.display.viewFrom,
h=0;h<e;h++)g+=f[h].size;if(g!=b){if(0<d){if(e==f.length-1)return null;b=g+f[e].size-b;e++}else b=g-b;c+=b}for(;Pc(a.doc,c)!=c;){if(e==(0>d?0:f.length-1))return null;c+=d*f[e-(0>d?1:0)].size;e+=d}return{index:e,lineN:c}}function Le(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 Bb(a,b){a.doc.mode.startState&&a.doc.frontier<a.display.viewTo&&a.state.highlight.set(b,Hc(mg,a))}function mg(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=ma(b.mode,pb(a,b.frontier)),e=[];b.iter(b.frontier,Math.min(b.first+b.size,a.display.viewTo+500),function(f){if(b.frontier>=a.display.viewFrom){var g=f.styles,h=f.text.length>a.options.maxHighlightLength,k=ce(a,f,h?ma(b.mode,d):d,!0);f.styles=k.styles;var l=f.styleClasses;(k=k.classes)?f.styleClasses=k:l&&(f.styleClasses=null);l=!g||g.length!=f.styles.length||l!=k&&(!l||!k||l.bgClass!=k.bgClass||l.textClass!=k.textClass);
for(k=0;!l&&k<g.length;++k)l=g[k]!=f.styles[k];l&&e.push(b.frontier);f.stateAfter=h?d:ma(b.mode,d)}else f.text.length<=a.options.maxHighlightLength&&ad(a,f.text,d),f.stateAfter=0==b.frontier%5?ma(b.mode,d):null;++b.frontier;if(+new Date>c)return Bb(a,a.options.workDelay),!0});e.length&&W(a,function(){for(var b=0;b<e.length;b++)va(a,e[b],"text")})}}function qc(a,b,c){var d=a.display;this.viewport=b;this.visible=rd(d,a.doc,b);this.editorIsHidden=!d.wrapper.offsetWidth;this.wrapperHeight=d.wrapper.clientHeight;
this.wrapperWidth=d.wrapper.clientWidth;this.oldDisplayWidth=Fa(a);this.force=c;this.dims=hd(a);this.events=[]}function vd(a,b){var c=a.display,d=a.doc;if(b.editorIsHidden)return ua(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==Le(a))return!1;De(a)&&(ua(a),b.dims=hd(a));var e=d.first+d.size,f=Math.max(b.visible.from-a.options.viewportMargin,d.first),g=Math.min(e,b.visible.to+a.options.viewportMargin);
c.viewFrom<f&&20>f-c.viewFrom&&(f=Math.max(d.first,c.viewFrom));c.viewTo>g&&20>c.viewTo-g&&(g=Math.min(e,c.viewTo));ta&&(f=Pc(a.doc,f),g=Xd(a.doc,g));d=f!=c.viewFrom||g!=c.viewTo||c.lastWrapHeight!=b.wrapperHeight||c.lastWrapWidth!=b.wrapperWidth;e=a.display;0==e.view.length||f>=e.viewTo||g<=e.viewFrom?(e.view=gc(a,f,g),e.viewFrom=f):(e.viewFrom>f?e.view=gc(a,f,e.viewFrom).concat(e.view):e.viewFrom<f&&(e.view=e.view.slice(Ga(a,f))),e.viewFrom=f,e.viewTo<g?e.view=e.view.concat(gc(a,e.viewTo,g)):e.viewTo>
g&&(e.view=e.view.slice(0,Ga(a,g))));e.viewTo=g;c.viewOffset=ia(u(a.doc,c.viewFrom));a.display.mover.style.top=c.viewOffset+"px";g=Le(a);if(!d&&0==g&&!b.force&&c.renderedView==c.view&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo))return!1;f=la();4<g&&(c.lineDiv.style.display="none");ng(a,c.updateLineNumbers,b.dims);4<g&&(c.lineDiv.style.display="");c.renderedView=c.view;f&&la()!=f&&f.offsetHeight&&f.focus();X(c.cursorDiv);X(c.selectionDiv);c.gutters.style.height=c.sizer.style.minHeight=
0;d&&(c.lastWrapHeight=b.wrapperHeight,c.lastWrapWidth=b.wrapperWidth,Bb(a,400));c.updateLineNumbers=null;return!0}function Ke(a,b){for(var c=b.viewport,d=!0;;d=!1){if(!d||!a.options.lineWrapping||b.oldDisplayWidth==Fa(a))if(c&&null!=c.top&&(c={top:Math.min(a.doc.height+ed(a.display)-fd(a),c.top)}),b.visible=rd(a.display,a.doc,c),b.visible.from>=a.display.viewFrom&&b.visible.to<=a.display.viewTo)break;if(!vd(a,b))break;lc(a);d=Cb(a);yb(a);Va(a,d);wd(a,d)}b.signal(a,"update",a);if(a.display.viewFrom!=
a.display.reportedViewFrom||a.display.viewTo!=a.display.reportedViewTo)b.signal(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo),a.display.reportedViewFrom=a.display.viewFrom,a.display.reportedViewTo=a.display.viewTo}function sd(a,b){var c=new qc(a,b);if(vd(a,c)){lc(a);Ke(a,c);var d=Cb(a);yb(a);Va(a,d);wd(a,d);c.finish()}}function ng(a,b,c){function d(b){var d=b.nextSibling;I&&da&&a.display.currentWheelTarget==b?b.style.display="none":b.parentNode.removeChild(b);return d}for(var e=a.display,
f=a.options.lineNumbers,g=e.lineDiv,h=g.firstChild,k=e.view,e=e.viewFrom,l=0;l<k.length;l++){var m=k[l];if(!m.hidden)if(m.node&&m.node.parentNode==g){for(;h!=m.node;)h=d(h);h=f&&null!=b&&b<=e&&m.lineNumber;m.changes&&(-1<H(m.changes,"gutter")&&(h=!1),me(a,m,e,c));h&&(X(m.lineNumber),m.lineNumber.appendChild(document.createTextNode(Mc(a.options,e))));h=m.node.nextSibling}else{var n=fg(a,m,e,c);g.insertBefore(n,h)}e+=m.size}for(;h;)h=d(h)}function qd(a){a.display.sizer.style.marginLeft=a.display.gutters.offsetWidth+
"px"}function wd(a,b){a.display.sizer.style.minHeight=b.docHeight+"px";a.display.heightForcer.style.top=b.docHeight+"px";a.display.gutters.style.height=b.docHeight+a.display.barHeight+ja(a)+"px"}function Me(a){var b=a.display.gutters,c=a.options.gutters;X(b);for(var d=0;d<c.length;++d){var e=c[d],f=b.appendChild(r("div",null,"CodeMirror-gutter "+e));"CodeMirror-linenumbers"==e&&(a.display.lineGutter=f,f.style.width=(a.display.lineNumWidth||1)+"px")}b.style.display=d?"":"none";qd(a)}function xd(a){var b=
H(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 qa(a,b){this.ranges=a;this.primIndex=b}function z(a,b){this.anchor=a;this.head=b}function fa(a,b){var c=a[b];a.sort(function(a,b){return w(a.from(),b.from())});b=H(a,c);for(c=1;c<a.length;c++){var d=a[c],e=a[c-1];if(0<=w(e.to(),d.from())){var f=Yb(e.from(),d.from()),g=Xb(e.to(),d.to()),d=e.empty()?d.from()==
d.head:e.from()==e.head;c<=b&&--b;a.splice(--c,2,new z(d?g:f,d?f:g))}}return new qa(a,b)}function ra(a,b){return new qa([new z(a,b||a)],0)}function wa(a){return a.text?q(a.from.line+a.text.length-1,y(a.text).length+(1==a.text.length?a.from.ch:0)):a.to}function Ne(a,b){if(0>w(a,b.from))return a;if(0>=w(a,b.to))return wa(b);var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;a.line==b.to.line&&(d+=wa(b).ch-b.to.ch);return q(c,d)}function yd(a,b){for(var c=[],d=0;d<a.sel.ranges.length;d++){var e=
a.sel.ranges[d];c.push(new z(Ne(e.anchor,b),Ne(e.head,b)))}return fa(c,a.sel.primIndex)}function Oe(a,b,c){return a.line==b.line?q(c.line,a.ch-b.ch+c.ch):q(c.line+(a.line-b.line),a.ch)}function zd(a){a.doc.mode=Zc(a.options,a.doc.modeOption);Db(a)}function Db(a){a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null);a.styles&&(a.styles=null)});a.doc.frontier=a.doc.first;Bb(a,100);a.state.modeGen++;a.curOp&&N(a)}function Pe(a,b){return 0==b.from.ch&&0==b.to.ch&&""==y(b.text)&&(!a.cm||a.cm.options.wholeLineUpdateBefore)}
function Ad(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);Td(a);Ud(a,e);c=d?d(a):1;c!=a.height&&ga(a,c);R(a,"change",a,b)}function f(a,b){for(var e=[],f=a;f<b;++f)e.push(new Qa(k[f],c?c[f]:null,d));return e}var g=b.from,h=b.to,k=b.text,l=u(a,g.line),m=u(a,h.line),n=y(k),p=c?c[k.length-1]:null,t=h.line-g.line;b.full?(a.insert(0,f(0,k.length)),a.remove(k.length,a.size-k.length)):Pe(a,b)?(h=f(0,k.length-1),e(m,m.text,p),
t&&a.remove(g.line,t),h.length&&a.insert(g.line,h)):l==m?1==k.length?e(l,l.text.slice(0,g.ch)+n+l.text.slice(h.ch),p):(t=f(1,k.length-1),t.push(new Qa(n+l.text.slice(h.ch),p,d)),e(l,l.text.slice(0,g.ch)+k[0],c?c[0]:null),a.insert(g.line+1,t)):1==k.length?(e(l,l.text.slice(0,g.ch)+k[0]+m.text.slice(h.ch),c?c[0]:null),a.remove(g.line+1,t)):(e(l,l.text.slice(0,g.ch)+k[0],c?c[0]:null),e(m,n+m.text.slice(h.ch),p),p=f(1,k.length-1),1<t&&a.remove(g.line+1,t-1),a.insert(g.line+1,p));R(a,"change",a,b)}function Ka(a,
b,c){function d(a,f,g){if(a.linked)for(var h=0;h<a.linked.length;++h){var k=a.linked[h];if(k.doc!=f){var l=g&&k.sharedHist;if(!c||l)b(k.doc,l),d(k.doc,a,l)}}}d(a,null,!0)}function Qe(a,b){if(b.cm)throw Error("This document is already in use.");a.doc=b;b.cm=a;md(a);zd(a);a.options.lineWrapping||Rc(a);a.options.mode=b.modeOption;N(a)}function sc(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 Bd(a,b){var c={from:Nc(b.from),to:wa(b),text:Ba(a,b.from,b.to)};Re(a,c,b.from.line,b.to.line+1);Ka(a,function(a){return Re(a,c,b.from.line,b.to.line+1)},!0);return c}function Se(a){for(;a.length;)if(y(a).ranges)a.pop();else break}function Te(a,b,c,d){var e=a.history;e.undone.length=0;var f=+new Date,g,h,k;if(k=e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&e.lastModTime>f-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))e.lastOp==
d?(Se(e.done),g=y(e.done)):e.done.length&&!y(e.done).ranges?g=y(e.done):1<e.done.length&&!e.done[e.done.length-2].ranges?(e.done.pop(),g=y(e.done)):g=void 0,k=g;if(k)h=y(g.changes),0==w(b.from,b.to)&&0==w(b.from,h.to)?h.to=wa(b):g.changes.push(Bd(a,b));else for((g=y(e.done))&&g.ranges||tc(a.sel,e.done),g={changes:[Bd(a,b)],generation:e.generation},e.done.push(g);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=
f;e.lastOp=e.lastSelOp=d;e.lastOrigin=e.lastSelOrigin=b.origin;h||E(a,"historyAdded")}function tc(a,b){var c=y(b);c&&c.ranges&&c.equals(a)||b.push(a)}function Re(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,c),Math.min(a.first+a.size,d),function(d){d.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]=d.markedSpans);++f})}function og(a){if(!a)return null;for(var b,c=0;c<a.length;++c)a[c].marker.explicitlyCleared?b||(b=a.slice(0,c)):b&&b.push(a[c]);return b?b.length?b:null:a}function Ue(a,
b){var c;if(c=b["spans_"+a.id]){for(var d=[],e=0;e<b.text.length;++e)d.push(og(c[e]));c=d}else c=null;d=Oc(a,b);if(!c)return d;if(!d)return c;for(e=0;e<c.length;++e){var f=c[e],g=d[e];if(f&&g){var h=0;a:for(;h<g.length;++h){for(var k=g[h],l=0;l<f.length;++l)if(f[l].marker==k.marker)continue a;f.push(k)}}else g&&(c[e]=g)}return c}function Za(a,b,c){for(var d=[],e=0;e<a.length;++e){var f=a[e];if(f.ranges)d.push(c?qa.prototype.deepCopy.call(f):f);else{var f=f.changes,g=[];d.push({changes:g});for(var h=
0;h<f.length;++h){var k=f[h],l=void 0;g.push({from:k.from,to:k.to,text:k.text});if(b)for(var m in k)(l=m.match(/^spans_(\d+)$/))&&-1<H(b,Number(l[1]))&&(y(g)[m]=k[m],delete k[m])}}}return d}function Eb(a,b,c,d){return a.cm&&a.cm.display.shift||a.extend?(a=b.anchor,d&&(b=0>w(c,a),b!=0>w(d,a)?(a=c,c=d):b!=0>w(c,d)&&(c=d)),new z(a,c)):new z(d||c,c)}function uc(a,b,c,d){K(a,new qa([Eb(a,a.sel.primary(),b,c)],0),d)}function Ve(a,b,c){for(var d=[],e=0;e<a.sel.ranges.length;e++)d[e]=Eb(a,a.sel.ranges[e],
b[e],null);b=fa(d,a.sel.primIndex);K(a,b,c)}function Cd(a,b,c,d){var e=a.sel.ranges.slice(0);e[b]=c;K(a,fa(e,a.sel.primIndex),d)}function pg(a,b,c){c={ranges:b.ranges,update:function(b){this.ranges=[];for(var c=0;c<b.length;c++)this.ranges[c]=new z(x(a,b[c].anchor),x(a,b[c].head))},origin:c&&c.origin};E(a,"beforeSelectionChange",a,c);a.cm&&E(a.cm,"beforeSelectionChange",a.cm,c);return c.ranges!=b.ranges?fa(c.ranges,c.ranges.length-1):b}function We(a,b,c){var d=a.history.done,e=y(d);e&&e.ranges?(d[d.length-
1]=b,vc(a,b,c)):K(a,b,c)}function K(a,b,c){vc(a,b,c);b=a.sel;var d=a.cm?a.cm.curOp.id:NaN,e=a.history,f=c&&c.origin,g;if(!(g=d==e.lastSelOp)&&(g=f&&e.lastSelOrigin==f)&&!(g=e.lastModTime==e.lastSelTime&&e.lastOrigin==f)){g=y(e.done);var h=f.charAt(0);g="*"==h||"+"==h&&g.ranges.length==b.ranges.length&&g.somethingSelected()==b.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}g?e.done[e.done.length-1]=b:tc(b,e.done);e.lastSelTime=+new Date;e.lastSelOrigin=
f;e.lastSelOp=d;c&&!1!==c.clearRedo&&Se(e.undone)}function vc(a,b,c){if(Z(a,"beforeSelectionChange")||a.cm&&Z(a.cm,"beforeSelectionChange"))b=pg(a,b,c);var d=c&&c.bias||(0>w(b.primary().head,a.sel.primary().head)?-1:1);Xe(a,Ye(a,b,d,!0));c&&!1===c.scroll||!a.cm||Wa(a.cm)}function Xe(a,b){b.equals(a.sel)||(a.sel=b,a.cm&&(a.cm.curOp.updateInput=a.cm.curOp.selectionChanged=!0,Zd(a.cm)),R(a,"cursorActivity",a))}function Ze(a){Xe(a,Ye(a,a.sel,null,!1),ka)}function Ye(a,b,c,d){for(var e,f=0;f<b.ranges.length;f++){var g=
b.ranges[f],h=b.ranges.length==a.sel.ranges.length&&a.sel.ranges[f],k=Dd(a,g.anchor,h&&h.anchor,c,d),h=Dd(a,g.head,h&&h.head,c,d);if(e||k!=g.anchor||h!=g.head)e||(e=b.ranges.slice(0,f)),e[f]=new z(k,h)}return e?fa(e,b.primIndex):b}function $a(a,b,c,d,e){var f=u(a,b.line);if(f.markedSpans)for(var g=0;g<f.markedSpans.length;++g){var h=f.markedSpans[g],k=h.marker;if((null==h.from||(k.inclusiveLeft?h.from<=b.ch:h.from<b.ch))&&(null==h.to||(k.inclusiveRight?h.to>=b.ch:h.to>b.ch))){if(e&&(E(k,"beforeCursorEnter"),
k.explicitlyCleared))if(f.markedSpans){--g;continue}else break;if(k.atomic){if(c){g=k.find(0>d?1:-1);h=void 0;if(0>d?k.inclusiveRight:k.inclusiveLeft)g=$e(a,g,-d,g&&g.line==b.line?f:null);if(g&&g.line==b.line&&(h=w(g,c))&&(0>d?0>h:0<h))return $a(a,g,b,d,e)}c=k.find(0>d?-1:1);if(0>d?k.inclusiveLeft:k.inclusiveRight)c=$e(a,c,d,c.line==b.line?f:null);return c?$a(a,c,b,d,e):null}}}return b}function Dd(a,b,c,d,e){d=d||1;b=$a(a,b,c,d,e)||!e&&$a(a,b,c,d,!0)||$a(a,b,c,-d,e)||!e&&$a(a,b,c,-d,!0);return b?
b:(a.cantEdit=!0,q(a.first,0))}function $e(a,b,c,d){return 0>c&&0==b.ch?b.line>a.first?x(a,q(b.line-1)):null:0<c&&b.ch==(d||u(a,b.line)).text.length?b.line<a.first+a.size-1?q(b.line+1,0):null:new q(b.line,b.ch+c)}function af(a){a.setSelection(q(a.firstLine(),0),q(a.lastLine()),ka)}function bf(a,b,c){var d={canceled:!1,from:b.from,to:b.to,text:b.text,origin:b.origin,cancel:function(){return d.canceled=!0}};c&&(d.update=function(b,c,g,h){b&&(d.from=x(a,b));c&&(d.to=x(a,c));g&&(d.text=g);void 0!==h&&
(d.origin=h)});E(a,"beforeChange",a,d);a.cm&&E(a.cm,"beforeChange",a.cm,d);return d.canceled?null:{from:d.from,to:d.to,text:d.text,origin:d.origin}}function ab(a,b,c){if(a.cm){if(!a.cm.curOp)return G(a.cm,ab)(a,b,c);if(a.cm.state.suppressEdits)return}if(Z(a,"beforeChange")||a.cm&&Z(a.cm,"beforeChange"))if(b=bf(a,b,!0),!b)return;if(c=cf&&!c&&Sf(a,b.from,b.to))for(var d=c.length-1;0<=d;--d)df(a,{from:c[d].from,to:c[d].to,text:d?[""]:b.text});else df(a,b)}function df(a,b){if(1!=b.text.length||""!=b.text[0]||
0!=w(b.from,b.to)){var c=yd(a,b);Te(a,b,c,a.cm?a.cm.curOp.id:NaN);Fb(a,b,c,Oc(a,b));var d=[];Ka(a,function(a,c){c||-1!=H(d,a.history)||(ef(a.history,b),d.push(a.history));Fb(a,b,null,Oc(a,b))})}}function wc(a,b,c){if(!a.cm||!a.cm.state.suppressEdits||c){for(var d=a.history,e,f=a.sel,g="undo"==b?d.done:d.undone,h="undo"==b?d.undone:d.done,k=0;k<g.length&&(e=g[k],c?!e.ranges||e.equals(a.sel):e.ranges);k++);if(k!=g.length){for(d.lastOrigin=d.lastSelOrigin=null;;)if(e=g.pop(),e.ranges){tc(e,h);if(c&&
!e.equals(a.sel)){K(a,e,{clearRedo:!1});return}f=e}else break;var l=[];tc(f,h);h.push({changes:l,generation:d.generation});d.generation=e.generation||++d.maxGeneration;var m=Z(a,"beforeChange")||a.cm&&Z(a.cm,"beforeChange");c=function(d){var c=e.changes[d];c.origin=b;if(m&&!bf(a,c,!1))return g.length=0,{};l.push(Bd(a,c));var f=d?yd(a,c):y(g);Fb(a,c,f,Ue(a,c));!d&&a.cm&&a.cm.scrollIntoView({from:c.from,to:wa(c)});var h=[];Ka(a,function(a,b){b||-1!=H(h,a.history)||(ef(a.history,c),h.push(a.history));
Fb(a,c,null,Ue(a,c))})};for(d=e.changes.length-1;0<=d;--d)if(f=c(d))return f.v}}}function ff(a,b){if(0!=b&&(a.first+=b,a.sel=new qa(Vb(a.sel.ranges,function(a){return new z(q(a.anchor.line+b,a.anchor.ch),q(a.head.line+b,a.head.ch))}),a.sel.primIndex),a.cm)){N(a.cm,a.first,a.first-b,b);for(var c=a.cm.display,d=c.viewFrom;d<c.viewTo;d++)va(a.cm,d,"gutter")}}function Fb(a,b,c,d){if(a.cm&&!a.cm.curOp)return G(a.cm,Fb)(a,b,c,d);if(b.to.line<a.first)ff(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);ff(a,e);b={from:q(a.first,0),to:q(b.to.line+e,b.to.ch),text:[y(b.text)],origin:b.origin}}e=a.lastLine();b.to.line>e&&(b={from:b.from,to:q(e,u(a,e).text.length),text:[b.text[0]],origin:b.origin});b.removed=Ba(a,b.from,b.to);c||(c=yd(a,b));a.cm?qg(a.cm,b,d):Ad(a,b,d);vc(a,c,ka)}}function qg(a,b,c){var d=a.doc,e=a.display,f=b.from,g=b.to,h=!1,k=f.line;a.options.lineWrapping||(k=C(ha(u(d,f.line))),d.iter(k,g.line+1,function(a){if(a==
e.maxLine)return h=!0}));-1<d.sel.contains(b.from,b.to)&&Zd(a);Ad(d,b,c,ze(a));a.options.lineWrapping||(d.iter(k,f.line+b.text.length,function(a){var b=$b(a);b>e.maxLineLength&&(e.maxLine=a,e.maxLineLength=b,e.maxLineChanged=!0,h=!1)}),h&&(a.curOp.updateMaxLine=!0));d.frontier=Math.min(d.frontier,f.line);Bb(a,400);c=b.text.length-(g.line-f.line)-1;b.full?N(a):f.line!=g.line||1!=b.text.length||Pe(a.doc,b)?N(a,f.line,g.line+1,c):va(a,f.line,"text");c=Z(a,"changes");if((d=Z(a,"change"))||c)b={from:f,
to:g,text:b.text,removed:b.removed,origin:b.origin},d&&R(a,"change",a,b),c&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(b);a.display.selForContextMenu=null}function bb(a,b,c,d,e){d||(d=c);if(0>w(d,c)){var f=d;d=c;c=f}"string"==typeof b&&(b=a.splitLines(b));ab(a,{from:c,to:d,text:b,origin:e})}function gf(a,b,c,d){c<a.line?a.line+=d:b<a.line&&(a.line=b,a.ch=0)}function hf(a,b,c,d){for(var e=0;e<a.length;++e){var f=a[e],g=!0;if(f.ranges)for(f.copied||(f=a[e]=f.deepCopy(),f.copied=!0),g=0;g<f.ranges.length;g++)gf(f.ranges[g].anchor,
b,c,d),gf(f.ranges[g].head,b,c,d);else{for(var h=0;h<f.changes.length;++h){var k=f.changes[h];if(c<k.from.line)k.from=q(k.from.line+d,k.from.ch),k.to=q(k.to.line+d,k.to.ch);else if(b<=k.to.line){g=!1;break}}g||(a.splice(0,e+1),e=0)}}}function ef(a,b){var c=b.from.line,d=b.to.line,e=b.text.length-(d-c)-1;hf(a.done,c,d,e);hf(a.undone,c,d,e)}function Gb(a,b,c,d){var e=b,f=b;"number"==typeof b?f=u(a,Math.max(a.first,Math.min(b,a.first+a.size-1))):e=C(b);if(null==e)return null;d(f,e)&&a.cm&&va(a.cm,e,
c);return f}function Hb(a){this.lines=a;this.parent=null;for(var b=0,c=0;c<a.length;++c)a[c].parent=this,b+=a[c].height;this.height=b}function Ib(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 Jb(a,b,c){if(c)for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.doc=a;this.node=b}function rg(a,b,c,d){var e=new Jb(a,c,d),f=a.cm;f&&e.noHScroll&&(f.display.alignWidgets=!0);Gb(a,b,"widget",
function(b){var d=b.widgets||(b.widgets=[]);null==e.insertAt?d.push(e):d.splice(Math.min(d.length-1,Math.max(0,e.insertAt)),0,e);e.line=b;f&&!Ea(a,b)&&(d=ia(b)<a.scrollTop,ga(b,b.height+vb(e)),d&&oc(f,null,e.height),f.curOp.forceUpdate=!0);return!0});return e}function xa(a,b){this.lines=[];this.type=b;this.doc=a;this.id=++jf}function cb(a,b,c,d,e){if(d&&d.shared)return sg(a,b,c,d,e);if(a.cm&&!a.cm.curOp)return G(a.cm,cb)(a,b,c,d,e);var f=new xa(a,e);e=w(b,c);d&&aa(d,f,!1);if(0<e||0==e&&!1!==f.clearWhenEmpty)return f;
f.replacedWith&&(f.collapsed=!0,f.widgetNode=r("span",[f.replacedWith],"CodeMirror-widget"),d.handleMouseEvents||f.widgetNode.setAttribute("cm-ignore-events","true"),d.insertLeft&&(f.widgetNode.insertLeft=!0));if(f.collapsed){if(Wd(a,b.line,b,c,f)||b.line!=c.line&&Wd(a,c.line,b,c,f))throw Error("Inserting collapsed marker partially overlapping an existing one");ta=!0}f.addToHistory&&Te(a,{from:b,to:c,origin:"markText"},a.sel,NaN);var g=b.line,h=a.cm,k;a.iter(g,c.line+1,function(a){h&&f.collapsed&&
!h.options.lineWrapping&&ha(a)==h.display.maxLine&&(k=!0);f.collapsed&&g!=b.line&&ga(a,0);var d=new Zb(f,g==b.line?b.ch:null,g==c.line?c.ch:null);a.markedSpans=a.markedSpans?a.markedSpans.concat([d]):[d];d.marker.attachLine(a);++g});f.collapsed&&a.iter(b.line,c.line+1,function(b){Ea(a,b)&&ga(b,0)});f.clearOnEnter&&v(f,"beforeCursorEnter",function(){return f.clear()});f.readOnly&&(cf=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory());f.collapsed&&(f.id=++jf,f.atomic=!0);if(h){k&&
(h.curOp.updateMaxLine=!0);if(f.collapsed)N(h,b.line,c.line+1);else if(f.className||f.title||f.startStyle||f.endStyle||f.css)for(d=b.line;d<=c.line;d++)va(h,d,"text");f.atomic&&Ze(h.doc);R(h,"markerAdded",h,f)}return f}function Kb(a,b){this.markers=a;this.primary=b;for(var c=0;c<a.length;++c)a[c].parent=this}function sg(a,b,c,d,e){d=aa(d);d.shared=!1;var f=[cb(a,b,c,d,e)],g=f[0],h=d.widgetNode;Ka(a,function(a){h&&(d.widgetNode=h.cloneNode(!0));f.push(cb(a,x(a,b),x(a,c),d,e));for(var l=0;l<a.linked.length;++l)if(a.linked[l].isParent)return;
g=y(f)});return new Kb(f,g)}function kf(a){return a.findMarks(q(a.first,0),a.clipPos(q(a.lastLine())),function(a){return a.parent})}function tg(a){for(var b=function(b){b=a[b];var c=[b.primary.doc];Ka(b.primary.doc,function(a){return c.push(a)});for(var f=0;f<b.markers.length;f++){var g=b.markers[f];-1==H(c,g.doc)&&(g.parent=null,b.markers.splice(f--,1))}},c=0;c<a.length;c++)b(c)}function ug(a){var b=this;lf(b);if(!F(b,a)&&!oa(b.display,a)){L(a);B&&(mf=+new Date);var c=Ja(b,a,!0),d=a.dataTransfer.files;
if(c&&!b.isReadOnly())if(d&&d.length&&window.FileReader&&window.File)for(var e=d.length,f=Array(e),g=0,h=function(a,d){if(!b.options.allowDropFileTypes||-1!=H(b.options.allowDropFileTypes,a.type)){var h=new FileReader;h.onload=G(b,function(){var a=h.result;/[\x00-\x08\x0e-\x1f]{2}/.test(a)&&(a="");f[d]=a;++g==e&&(c=x(b.doc,c),a={from:c,to:c,text:b.doc.splitLines(f.join(b.doc.lineSeparator())),origin:"paste"},ab(b.doc,a),We(b.doc,ra(c,wa(a))))});h.readAsText(a)}},k=0;k<e;++k)h(d[k],k);else if(b.state.draggingText&&
-1<b.doc.sel.contains(c))b.state.draggingText(a),setTimeout(function(){return b.display.input.focus()},20);else try{if(h=a.dataTransfer.getData("Text")){b.state.draggingText&&!b.state.draggingText.copy&&(k=b.listSelections());vc(b.doc,ra(c,c));if(k)for(d=0;d<k.length;++d)bb(b.doc,"",k[d].anchor,k[d].head,"drag");b.replaceSelection(h,"around","paste");b.display.input.focus()}}catch(l){}}}function lf(a){a.display.dragCursor&&(a.display.lineSpace.removeChild(a.display.dragCursor),a.display.dragCursor=
null)}function nf(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 vg(){var a;v(window,"resize",function(){null==a&&(a=setTimeout(function(){a=null;nf(wg)},100))});v(window,"blur",function(){return nf(zb)})}function wg(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 xg(a){var b=a.split(/-(?!$)/);a=b[b.length-1];for(var c,d,e,f,g=0;g<b.length-1;g++){var h=b[g];if(/^(cmd|meta|m)$/i.test(h))f=!0;else if(/^a(lt)?$/i.test(h))c=!0;else if(/^(c|ctrl|control)$/i.test(h))d=!0;else if(/^s(hift)?$/i.test(h))e=!0;else throw Error("Unrecognized modifier name: "+h);}c&&(a="Alt-"+a);d&&(a="Ctrl-"+a);f&&(a="Cmd-"+a);e&&(a="Shift-"+a);return a}function yg(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=Vb(c.split(" "),xg),f=0;f<e.length;f++){var g=void 0,h=void 0;f==e.length-1?(h=e.join(" "),g=d):(h=e.slice(0,f+1).join(" "),g="...");var k=b[h];if(!k)b[h]=g;else if(k!=g)throw Error("Inconsistent bindings for "+h);}delete a[c]}}for(var l in b)a[l]=b[l];return a}function db(a,b,c,d){b=xc(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 db(a,
b.fallthrough,c,d);for(e=0;e<b.fallthrough.length;e++){var f=db(a,b.fallthrough[e],c,d);if(f)return f}}}function of(a){a="string"==typeof a?a:ya[a.keyCode];return"Ctrl"==a||"Alt"==a||"Shift"==a||"Mod"==a}function pf(a,b){if(ea&&34==a.keyCode&&a["char"])return!1;var c=ya[a.keyCode],d=c;if(null==d||a.altGraphKey)return!1;a.altKey&&"Alt"!=c&&(d="Alt-"+d);(qf?a.metaKey:a.ctrlKey)&&"Ctrl"!=c&&(d="Ctrl-"+d);(qf?a.ctrlKey:a.metaKey)&&"Cmd"!=c&&(d="Cmd-"+d);!b&&a.shiftKey&&"Shift"!=c&&(d="Shift-"+d);return d}
function xc(a){return"string"==typeof a?Lb[a]:a}function eb(a,b){for(var c=a.doc.sel.ranges,d=[],e=0;e<c.length;e++){for(var f=b(c[e]);d.length&&0>=w(f.from,y(d).to);){var g=d.pop();if(0>w(g.from,f.from)){f.from=g.from;break}}d.push(f)}W(a,function(){for(var b=d.length-1;0<=b;b--)bb(a.doc,"",d[b].from,d[b].to,"+delete");Wa(a)})}function rf(a,b){var c=u(a.doc,b),d=ha(c);d!=c&&(b=C(d));d=(c=ba(d))?c[0].level%2?bc(d):ac(d):0;return q(b,d)}function sf(a,b){var c=rf(a,b.line),d=u(a.doc,c.line),e=ba(d);
return e&&0!=e[0].level?c:(d=Math.max(0,d.text.search(/\S/)),q(c.line,b.line==c.line&&b.ch<=d&&b.ch?0:d))}function yc(a,b,c){if("string"==typeof b&&(b=zc[b],!b))return!1;a.display.input.ensurePolled();var d=a.display.shift,e=!1;try{a.isReadOnly()&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=Ed}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function zg(a,b,c){for(var d=0;d<a.state.keyMaps.length;d++){var e=db(b,a.state.keyMaps[d],c,a);if(e)return e}return a.options.extraKeys&&
db(b,a.options.extraKeys,c,a)||db(b,a.options.keyMap,c,a)}function Ac(a,b,c,d){var e=a.state.keySeq;if(e){if(of(b))return"handled";Ag.set(50,function(){a.state.keySeq==e&&(a.state.keySeq=null,a.display.input.reset())});b=e+" "+b}d=zg(a,b,d);"multi"==d&&(a.state.keySeq=b);"handled"==d&&R(a,"keyHandled",a,b,c);if("handled"==d||"multi"==d)L(c),nd(a);return e&&!d&&/\'$/.test(b)?(L(c),!0):!!d}function tf(a,b){var c=pf(b,!0);return c?b.shiftKey&&!a.state.keySeq?Ac(a,"Shift-"+c,b,function(b){return yc(a,
b,!0)})||Ac(a,c,b,function(b){if("string"==typeof b?/^go[A-Z]/.test(b):b.motion)return yc(a,b)}):Ac(a,c,b,function(b){return yc(a,b)}):!1}function Bg(a,b,c){return Ac(a,"'"+c+"'",b,function(b){return yc(a,b,!0)})}function uf(a){this.curOp.focus=la();if(!F(this,a)){B&&11>A&&27==a.keyCode&&(a.returnValue=!1);var b=a.keyCode;this.display.shift=16==b||a.shiftKey;var c=tf(this,a);ea&&(Fd=c?b:null,!c&&88==b&&!vf&&(da?a.metaKey:a.ctrlKey)&&this.replaceSelection("",null,"cut"));18!=b||/\bCodeMirror-crosshair\b/.test(this.display.lineDiv.className)||
Cg(this)}}function Cg(a){function b(a){18!=a.keyCode&&a.altKey||(Ta(c,"CodeMirror-crosshair"),ca(document,"keyup",b),ca(document,"mouseover",b))}var c=a.display.lineDiv;Ma(c,"CodeMirror-crosshair");v(document,"keyup",b);v(document,"mouseover",b)}function wf(a){16==a.keyCode&&(this.doc.sel.shift=!1);F(this,a)}function xf(a){if(!(oa(this.display,a)||F(this,a)||a.ctrlKey&&!a.altKey||da&&a.metaKey)){var b=a.keyCode,c=a.charCode;if(ea&&b==Fd)Fd=null,L(a);else if(!ea||a.which&&!(10>a.which)||!tf(this,a))if(b=
String.fromCharCode(null==c?b:c),"\b"!=b&&!Bg(this,a,b))this.display.input.onKeyPress(a)}}function Dg(a){var b=this.display;if(!(F(this,a)||b.activeTouch&&b.input.supportsTouch()))if(b.input.ensurePolled(),b.shift=a.shiftKey,oa(b,a))I||(b.scroller.draggable=!1,setTimeout(function(){return b.scroller.draggable=!0},100));else if(!Gd(this,a,"gutterClick",!0)){var c=Ja(this,a);window.focus();switch(ae(a)){case 1:this.state.selectingText?this.state.selectingText(a):c?Eg(this,a,c):(a.target||a.srcElement)==
b.scroller&&L(a);break;case 2:I&&(this.state.lastMiddleDown=+new Date);c&&uc(this.doc,c);setTimeout(function(){return b.input.focus()},20);L(a);break;case 3:Hd?yf(this,a):ig(this)}}}function Eg(a,b,c){B?setTimeout(Hc(Ce,a),0):a.curOp.focus=la();var d=+new Date,e;Bc&&Bc.time>d-400&&0==w(Bc.pos,c)?e="triple":Cc&&Cc.time>d-400&&0==w(Cc.pos,c)?(e="double",Bc={time:d,pos:c}):(e="single",Cc={time:d,pos:c});var d=a.doc.sel,f=da?b.metaKey:b.ctrlKey,g;a.options.dragDrop&&Fg&&!a.isReadOnly()&&"single"==e&&
-1<(g=d.contains(c))&&(0>w((g=d.ranges[g]).from(),c)||0<c.xRel)&&(0<w(g.to(),c)||0>c.xRel)?Gg(a,b,c,f):Hg(a,b,c,e,f)}function Gg(a,b,c,d){var e=a.display,f=+new Date,g=G(a,function(h){I&&(e.scroller.draggable=!1);a.state.draggingText=!1;ca(document,"mouseup",g);ca(e.scroller,"drop",g);10>Math.abs(b.clientX-h.clientX)+Math.abs(b.clientY-h.clientY)&&(L(h),!d&&+new Date-200<f&&uc(a.doc,c),I||B&&9==A?setTimeout(function(){document.body.focus();e.input.focus()},20):e.input.focus())});I&&(e.scroller.draggable=
!0);a.state.draggingText=g;g.copy=da?b.altKey:b.ctrlKey;e.scroller.dragDrop&&e.scroller.dragDrop();v(document,"mouseup",g);v(e.scroller,"drop",g)}function Hg(a,b,c,d,e){function f(b){if(0!=w(y,b))if(y=b,"rect"==d){for(var e=[],f=a.options.tabSize,g=Y(u(l,c.line).text,c.ch,f),h=Y(u(l,b.line).text,b.ch,f),k=Math.min(g,h),g=Math.max(g,h),h=Math.min(c.line,b.line),t=Math.min(a.lastLine(),Math.max(c.line,b.line));h<=t;h++){var r=u(l,h).text,v=Ic(r,k,f);k==g?e.push(new z(q(h,v),q(h,v))):r.length>v&&e.push(new z(q(h,
v),q(h,Ic(r,g,f))))}e.length||e.push(new z(c,c));K(l,fa(p.ranges.slice(0,n).concat(e),n),{origin:"*mouse",scroll:!1});a.scrollIntoView(b)}else k=m,e=k.anchor,f=b,"single"!=d&&(b="double"==d?a.findWordAt(b):new z(q(b.line,0),x(l,q(b.line+1,0))),0<w(b.anchor,e)?(f=b.head,e=Yb(k.from(),b.anchor)):(f=b.anchor,e=Xb(k.to(),b.head))),b=p.ranges.slice(0),b[n]=new z(x(l,e),f),K(l,fa(b,n),Id)}function g(b){var c=++B,e=Ja(a,b,!0,"rect"==d);if(e)if(0!=w(e,y)){a.curOp.focus=la();f(e);var h=rd(k,l);(e.line>=h.to||
e.line<h.from)&&setTimeout(G(a,function(){B==c&&g(b)}),150)}else{var m=b.clientY<A.top?-20:b.clientY>A.bottom?20:0;m&&setTimeout(G(a,function(){B==c&&(k.scroller.scrollTop+=m,g(b))}),50)}}function h(b){a.state.selectingText=!1;B=Infinity;L(b);k.input.focus();ca(document,"mousemove",C);ca(document,"mouseup",D);l.history.lastSelOrigin=null}var k=a.display,l=a.doc;L(b);var m,n,p=l.sel,t=p.ranges;e&&!b.shiftKey?(n=l.sel.contains(c),m=-1<n?t[n]:new z(c,c)):(m=l.sel.primary(),n=l.sel.primIndex);if(Ig?b.shiftKey&&
b.metaKey:b.altKey)d="rect",e||(m=new z(c,c)),c=Ja(a,b,!0,!0),n=-1;else if("double"==d){var r=a.findWordAt(c);m=a.display.shift||l.extend?Eb(l,m,r.anchor,r.head):r}else"triple"==d?(r=new z(q(c.line,0),x(l,q(c.line+1,0))),m=a.display.shift||l.extend?Eb(l,m,r.anchor,r.head):r):m=Eb(l,m,c);e?-1==n?(n=t.length,K(l,fa(t.concat([m]),n),{scroll:!1,origin:"*mouse"})):1<t.length&&t[n].empty()&&"single"==d&&!b.shiftKey?(K(l,fa(t.slice(0,n).concat(t.slice(n+1)),0),{scroll:!1,origin:"*mouse"}),p=l.sel):Cd(l,
n,m,Id):(n=0,K(l,new qa([m],0),Id),p=l.sel);var y=c,A=k.wrapper.getBoundingClientRect(),B=0,C=G(a,function(a){ae(a)?g(a):h(a)}),D=G(a,h);a.state.selectingText=D;v(document,"mousemove",C);v(document,"mouseup",D)}function Gd(a,b,c,d){var e,f;try{e=b.clientX,f=b.clientY}catch(g){return!1}if(e>=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;d&&L(b);d=a.display;var h=d.lineDiv.getBoundingClientRect();if(f>h.bottom||!Z(a,c))return Wc(b);f-=h.top-d.viewOffset;for(h=0;h<a.options.gutters.length;++h){var k=
d.gutters.childNodes[h];if(k&&k.getBoundingClientRect().right>=e)return e=Ca(a.doc,f),E(a,c,a,e,a.options.gutters[h],b),Wc(b)}}function yf(a,b){var c;(c=oa(a.display,b))||(c=Z(a,"gutterContextMenu")?Gd(a,b,"gutterContextMenu",!1):!1);if(!c&&!F(a,b,"contextmenu"))a.display.input.onContextMenu(b)}function zf(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-");xb(a)}function Mb(a){Me(a);N(a);setTimeout(function(){return pd(a)},
20)}function Jg(a,b,c){!b!=!(c&&c!=fb)&&(c=a.display.dragFunctions,b=b?v:ca,b(a.display.scroller,"dragstart",c.start),b(a.display.scroller,"dragenter",c.enter),b(a.display.scroller,"dragover",c.over),b(a.display.scroller,"dragleave",c.leave),b(a.display.scroller,"drop",c.drop))}function Kg(a){a.options.lineWrapping?(Ma(a.display.wrapper,"CodeMirror-wrap"),a.display.sizer.style.minWidth="",a.display.sizerWidth=null):(Ta(a.display.wrapper,"CodeMirror-wrap"),Rc(a));md(a);N(a);xb(a);setTimeout(function(){return Va(a)},
100)}function D(a,b){var c=this;if(!(this instanceof D))return new D(a,b);this.options=b=b?aa(b):{};aa(Af,b,!1);xd(b);var d=b.value;"string"==typeof d&&(d=new P(d,b.mode,null,b.lineSeparator));this.doc=d;var e=new D.inputStyles[b.inputStyle](this),e=this.display=new Rf(a,d,e);e.wrapper.CodeMirror=this;Me(this);zf(this);b.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");b.autofocus&&!kb&&e.input.focus();Ie(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,
focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Aa,keySeq:null,specialChars:null};B&&11>A&&setTimeout(function(){return c.display.input.reset(!0)},20);Lg(this);Bf||(vg(),Bf=!0);Xa(this);this.curOp.forceUpdate=!0;Qe(this,d);b.autofocus&&!kb||this.hasFocus()?setTimeout(Hc(od,this),20):zb(this);for(var f in Dc)if(Dc.hasOwnProperty(f))Dc[f](c,b[f],fb);De(this);b.finishInit&&b.finishInit(this);for(d=0;d<Jd.length;++d)Jd[d](c);Ya(this);I&&b.lineWrapping&&
"optimizelegibility"==getComputedStyle(e.lineDiv).textRendering&&(e.lineDiv.style.textRendering="auto")}function Lg(a){function b(){d.activeTouch&&(e=setTimeout(function(){return d.activeTouch=null},1E3),f=d.activeTouch,f.end=+new Date)}function c(a,b){if(null==b.left)return!0;var d=b.left-a.left,c=b.top-a.top;return 400<d*d+c*c}var d=a.display;v(d.scroller,"mousedown",G(a,Dg));B&&11>A?v(d.scroller,"dblclick",G(a,function(b){if(!F(a,b)){var d=Ja(a,b);!d||Gd(a,b,"gutterClick",!0)||oa(a.display,b)||
(L(b),b=a.findWordAt(d),uc(a.doc,b.anchor,b.head))}})):v(d.scroller,"dblclick",function(b){return F(a,b)||L(b)});Hd||v(d.scroller,"contextmenu",function(b){return yf(a,b)});var e,f={end:0};v(d.scroller,"touchstart",function(b){var c;if(c=!F(a,b))1!=b.touches.length?c=!1:(c=b.touches[0],c=1>=c.radiusX&&1>=c.radiusY),c=!c;c&&(d.input.ensurePolled(),clearTimeout(e),c=+new Date,d.activeTouch={start:c,moved:!1,prev:300>=c-f.end?f:null},1==b.touches.length&&(d.activeTouch.left=b.touches[0].pageX,d.activeTouch.top=
b.touches[0].pageY))});v(d.scroller,"touchmove",function(){d.activeTouch&&(d.activeTouch.moved=!0)});v(d.scroller,"touchend",function(e){var f=d.activeTouch;if(f&&!oa(d,e)&&null!=f.left&&!f.moved&&300>new Date-f.start){var g=a.coordsChar(d.activeTouch,"page"),f=!f.prev||c(f,f.prev)?new z(g,g):!f.prev.prev||c(f,f.prev.prev)?a.findWordAt(g):new z(q(g.line,0),x(a.doc,q(g.line+1,0)));a.setSelection(f.anchor,f.head);a.focus();L(e)}b()});v(d.scroller,"touchcancel",b);v(d.scroller,"scroll",function(){d.scroller.clientHeight&&
(Ab(a,d.scroller.scrollTop),Ua(a,d.scroller.scrollLeft,!0),E(a,"scroll",a))});v(d.scroller,"mousewheel",function(b){return Ge(a,b)});v(d.scroller,"DOMMouseScroll",function(b){return Ge(a,b)});v(d.wrapper,"scroll",function(){return d.wrapper.scrollTop=d.wrapper.scrollLeft=0});d.dragFunctions={enter:function(b){F(a,b)||ob(b)},over:function(b){if(!F(a,b)){var d=Ja(a,b);if(d){var c=document.createDocumentFragment();Be(a,d,c);a.display.dragCursor||(a.display.dragCursor=r("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),
a.display.lineSpace.insertBefore(a.display.dragCursor,a.display.cursorDiv));U(a.display.dragCursor,c)}ob(b)}},start:function(b){if(B&&(!a.state.draggingText||100>+new Date-mf))ob(b);else if(!F(a,b)&&!oa(a.display,b)&&(b.dataTransfer.setData("Text",a.getSelection()),b.dataTransfer.effectAllowed="copyMove",b.dataTransfer.setDragImage&&!Cf)){var d=r("img",null,null,"position: fixed; left: 0; top: 0;");d.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw\x3d\x3d";ea&&(d.width=
d.height=1,a.display.wrapper.appendChild(d),d._top=d.offsetTop);b.dataTransfer.setDragImage(d,0,0);ea&&d.parentNode.removeChild(d)}},drop:G(a,ug),leave:function(b){F(a,b)||lf(a)}};var g=d.input.getField();v(g,"keyup",function(b){return wf.call(a,b)});v(g,"keydown",G(a,uf));v(g,"keypress",G(a,xf));v(g,"focus",function(b){return od(a,b)});v(g,"blur",function(b){return zb(a,b)})}function Nb(a,b,c,d){var e=a.doc,f;null==c&&(c="add");"smart"==c&&(e.mode.indent?f=pb(a,b):c="prev");var g=a.options.tabSize,
h=u(e,b),k=Y(h.text,null,g);h.stateAfter&&(h.stateAfter=null);var l=h.text.match(/^\s*/)[0],m;if(!d&&!/\S/.test(h.text))m=0,c="not";else if("smart"==c&&(m=e.mode.indent(f,h.text.slice(l.length),h.text),m==Ed||150<m)){if(!d)return;c="prev"}"prev"==c?m=b>e.first?Y(u(e,b-1).text,null,g):0:"add"==c?m=k+a.options.indentUnit:"subtract"==c?m=k-a.options.indentUnit:"number"==typeof c&&(m=k+c);m=Math.max(0,m);c="";d=0;if(a.options.indentWithTabs)for(a=Math.floor(m/g);a;--a)d+=g,c+="\t";d<m&&(c+=Jc(m-d));if(c!=
l)return bb(e,c,q(b,0),q(b,l.length),"+input"),h.stateAfter=null,!0;for(g=0;g<e.sel.ranges.length;g++)if(h=e.sel.ranges[g],h.head.line==b&&h.head.ch<l.length){b=q(b,l.length);Cd(e,g,new z(b,b));break}}function Df(a){S=a}function Kd(a,b,c,d,e){var f=a.doc;a.display.shift=!1;d||(d=f.sel);var g=a.state.pasteIncoming||"paste"==e,h=Ld(b),k=null;if(g&&1<d.ranges.length)if(S&&S.text.join("\n")==b){if(0==d.ranges.length%S.text.length)for(var k=[],l=0;l<S.text.length;l++)k.push(f.splitLines(S.text[l]))}else h.length==
d.ranges.length&&(k=Vb(h,function(a){return[a]}));for(var m,l=d.ranges.length-1;0<=l;l--){m=d.ranges[l];var n=m.from(),p=m.to();m.empty()&&(c&&0<c?n=q(n.line,n.ch-c):a.state.overwrite&&!g?p=q(p.line,Math.min(u(f,p.line).text.length,p.ch+y(h).length)):S&&S.lineWise&&S.text.join("\n")==b&&(n=p=q(n.line,0)));m=a.curOp.updateInput;n={from:n,to:p,text:k?k[l%k.length]:h,origin:e||(g?"paste":a.state.cutIncoming?"cut":"+input")};ab(a.doc,n);R(a,"inputRead",a,n)}b&&!g&&Ef(a,b);Wa(a);a.curOp.updateInput=m;
a.curOp.typing=!0;a.state.pasteIncoming=a.state.cutIncoming=!1}function Ff(a,b){var c=a.clipboardData&&a.clipboardData.getData("Text");if(c)return a.preventDefault(),b.isReadOnly()||b.options.disableInput||W(b,function(){return Kd(b,c,0,null,"paste")}),!0}function Ef(a,b){if(a.options.electricChars&&a.options.smartIndent)for(var c=a.doc.sel,d=c.ranges.length-1;0<=d;d--){var e=c.ranges[d];if(!(100<e.head.ch||d&&c.ranges[d-1].head.line==e.head.line)){var f=a.getModeAt(e.head),g=!1;if(f.electricChars)for(var h=
0;h<f.electricChars.length;h++){if(-1<b.indexOf(f.electricChars.charAt(h))){g=Nb(a,e.head.line,"smart");break}}else f.electricInput&&f.electricInput.test(u(a.doc,e.head.line).text.slice(0,e.head.ch))&&(g=Nb(a,e.head.line,"smart"));g&&R(a,"electricInput",a,e.head.line)}}}function Gf(a){for(var b=[],c=[],d=0;d<a.doc.sel.ranges.length;d++){var e=a.doc.sel.ranges[d].head.line,e={anchor:q(e,0),head:q(e+1,0)};c.push(e);b.push(a.getRange(e.anchor,e.head))}return{text:b,ranges:c}}function Hf(a,b){a.setAttribute("autocorrect",
"off");a.setAttribute("autocapitalize","off");a.setAttribute("spellcheck",!!b)}function If(){var a=r("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),b=r("div",[a],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");I?a.style.width="1000px":a.setAttribute("wrap","off");Ob&&(a.style.border="1px solid black");Hf(a);return b}function Md(a,b,c,d,e){function f(b){var d=(e?Vc:Yd)(l,h,c,!0);if(null==d){if(b=!b)b=g+c,b<a.first||
b>=a.first+a.size?b=!1:(g=b,b=l=u(a,b));if(b)h=e?(0>c?bc:ac)(l):0>c?l.text.length:0;else return!1}else h=d;return!0}var g=b.line,h=b.ch,k=c,l=u(a,g);if("char"==d)f();else if("column"==d)f(!0);else if("word"==d||"group"==d){var m=null;d="group"==d;for(var n=a.cm&&a.cm.getHelper(b,"wordChars"),p=!0;!(0>c)||f(!p);p=!1){var t=l.text.charAt(h)||"\n",t=Wb(t,n)?"w":d&&"\n"==t?"n":!d||/\s/.test(t)?null:"p";!d||p||t||(t="s");if(m&&m!=t){0>c&&(c=1,f());break}t&&(m=t);if(0<c&&!f(!p))break}}k=Dd(a,q(g,h),b,k,
!0);w(b,k)||(k.hitSide=!0);return k}function Jf(a,b,c,d){var e=a.doc,f=b.left,g;"page"==d?(g=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),g=Math.max(g-.5*Ha(a.display),3),g=(0<c?b.bottom:b.top)+c*g):"line"==d&&(g=0<c?b.bottom+3:b.top-3);for(;;){b=kd(a,f,g);if(!b.outside)break;if(0>c?0>=g:g>=e.height){b.hitSide=!0;break}g+=5*c}return b}function Nd(a){this.cm=a;this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null;
this.polling=new Aa;this.composing=null;this.gracePeriod=!1;this.readDOMTimeout=null}function Kf(a,b){var c=gd(a,b.line);if(!c||c.hidden)return null;var d=u(a.doc,b.line),c=se(c,d,b.line),d=ba(d),e="left";d&&(e=cc(d,b.ch)%2?"right":"left");c=te(c.map,b.ch,e);c.offset="right"==c.collapse?c.end:c.start;return c}function gb(a,b){b&&(a.bad=!0);return a}function Mg(a,b,c,d,e){function f(a){return function(b){return b.id==a}}function g(b){if(1==b.nodeType){var c=b.getAttribute("cm-text");if(null!=c)h=""==
c?h+b.textContent.replace(/\u200b/g,""):h+c;else{var c=b.getAttribute("cm-marker"),p;if(c)b=a.findMarks(q(d,0),q(e+1,0),f(+c)),b.length&&(p=b[0].find())&&(h+=Ba(a.doc,p.from,p.to).join(l));else if("false"!=b.getAttribute("contenteditable")){for(p=0;p<b.childNodes.length;p++)g(b.childNodes[p]);/^(pre|div|p)$/i.test(b.nodeName)&&(k=!0)}}}else 3==b.nodeType&&(b=b.nodeValue)&&(k&&(h+=l,k=!1),h+=b)}for(var h="",k=!1,l=a.doc.lineSeparator();;){g(b);if(b==c)break;b=b.nextSibling}return h}function Ec(a,b,
c){var d;if(b==a.display.lineDiv){d=a.display.lineDiv.childNodes[c];if(!d)return gb(a.clipPos(q(a.display.viewTo-1)),!0);b=null;c=0}else for(d=b;;d=d.parentNode){if(!d||d==a.display.lineDiv)return null;if(d.parentNode&&d.parentNode==a.display.lineDiv)break}for(var e=0;e<a.display.view.length;e++){var f=a.display.view[e];if(f.node==d)return Ng(f,b,c)}}function Ng(a,b,c){function d(b,d,c){for(var e=-1;e<(l?l.length:0);e++)for(var f=0>e?k.map:l[e],g=0;g<f.length;g+=3){var h=f[g+2];if(h==b||h==d){d=C(0>
e?a.line:a.rest[e]);e=f[g]+c;if(0>c||h!=b)e=f[g+(c?1:0)];return q(d,e)}}}var e=a.text.firstChild,f=!1;if(!b||!Tb(e,b))return gb(q(C(a.line),0),!0);if(b==e&&(f=!0,b=e.childNodes[c],c=0,!b))return c=a.rest?y(a.rest):a.line,gb(q(C(c),c.text.length),f);var g=3==b.nodeType?b:null,h=b;g||1!=b.childNodes.length||3!=b.firstChild.nodeType||(g=b.firstChild,c&&(c=g.nodeValue.length));for(;h.parentNode!=e;)h=h.parentNode;var k=a.measure,l=k.maps;if(b=d(g,h,c))return gb(b,f);e=h.nextSibling;for(g=g?g.nodeValue.length-
c:0;e;e=e.nextSibling){if(b=d(e,e.firstChild,0))return gb(q(b.line,b.ch-g),f);g+=e.textContent.length}for(h=h.previousSibling;h;h=h.previousSibling){if(b=d(h,h.firstChild,-1))return gb(q(b.line,b.ch+c),f);c+=h.textContent.length}}function Od(a){this.cm=a;this.prevInput="";this.pollingFast=!1;this.polling=new Aa;this.hasSelection=this.inaccurateSelection=!1;this.composing=null}var T=navigator.userAgent,Lf=navigator.platform,sa=/gecko\/\d/i.test(T),Mf=/MSIE \d/.test(T),Nf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(T),
B=Mf||Nf,A=B&&(Mf?document.documentMode||6:Nf[1]),I=/WebKit\//.test(T),Og=I&&/Qt\/\d+\.\d+/.test(T),Pg=/Chrome\//.test(T),ea=/Opera\//.test(T),Cf=/Apple Computer/.test(navigator.vendor),Qg=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(T),lg=/PhantomJS/.test(T),Ob=/AppleWebKit/.test(T)&&/Mobile\/\w+/.test(T),kb=Ob||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(T),da=Ob||/Mac/.test(Lf),Ig=/\bCrOS\b/.test(T),Rg=/win/i.test(Lf),La=ea&&T.match(/Version\/(\d*\.\d*)/);La&&(La=Number(La[1]));La&&
15<=La&&(ea=!1,I=!0);var qf=da&&(Og||ea&&(null==La||12.11>La)),Hd=sa||B&&9<=A,Ta=function(a,b){var c=a.className,d=za(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:"")}},Ra;Ra=document.createRange?function(a,b,c,d){var e=document.createRange();e.setEnd(d||a,c);e.setStart(a,b);return e}: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};var hb=function(a){a.select()};Ob?hb=function(a){a.selectionStart=0;a.selectionEnd=a.value.length}:B&&(hb=function(a){try{a.select()}catch(b){}});Aa.prototype.set=function(a,b){clearTimeout(this.id);this.id=setTimeout(b,a)};var Ed={toString:function(){return"CodeMirror.Pass"}},ka={scroll:!1},Id={origin:"*mouse"},Pb={origin:"+move"},Ub=[""],Pf=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Qf=/[\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]/,
cf=!1,ta=!1,nb=null,Uf=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,d){this.level=a;this.from=b;this.to=d}var c=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,d=/[stwN]/,e=/[LRr]/,f=/[Lb1n]/,g=/[1n]/;return function(h){if(!c.test(h))return!1;for(var k=h.length,l=[],m=0;m<k;++m)l.push(a(h.charCodeAt(m)));for(var m=0,n="L";m<k;++m){var p=l[m];"m"==p?l[m]=n:n=p}m=0;for(n="L";m<k;++m)p=l[m],"1"==p&&"r"==n?l[m]="n":e.test(p)&&(n=p,"r"==p&&(l[m]="R"));m=1;for(n=l[0];m<k-1;++m)p=l[m],"+"==p&&"1"==
n&&"1"==l[m+1]?l[m]="1":","!=p||n!=l[m+1]||"1"!=n&&"n"!=n||(l[m]=n),n=p;for(m=0;m<k;++m)if(n=l[m],","==n)l[m]="N";else if("%"==n){n=void 0;for(n=m+1;n<k&&"%"==l[n];++n);for(p=m&&"!"==l[m-1]||n<k&&"1"==l[n]?"1":"N";m<n;++m)l[m]=p;m=n-1}m=0;for(n="L";m<k;++m)p=l[m],"L"==n&&"1"==p?l[m]="L":e.test(p)&&(n=p);for(n=0;n<k;++n)if(d.test(l[n])){m=void 0;for(m=n+1;m<k&&d.test(l[m]);++m);p="L"==(m<k?l[m]:"L");for(p="L"==(n?l[n-1]:"L")||p?"L":"R";n<m;++n)l[n]=p;n=m-1}for(var m=[],t,n=0;n<k;)if(f.test(l[n])){p=
n;for(++n;n<k&&f.test(l[n]);++n);m.push(new b(0,p,n))}else{var q=n,p=m.length;for(++n;n<k&&"L"!=l[n];++n);for(var r=q;r<n;)if(g.test(l[r])){q<r&&m.splice(p,0,new b(1,q,r));q=r;for(++r;r<n&&g.test(l[r]);++r);m.splice(p,0,new b(2,q,r));q=r}else++r;q<n&&m.splice(p,0,new b(1,q,n))}1==m[0].level&&(t=h.match(/^\s+/))&&(m[0].from=t[0].length,m.unshift(new b(0,0,t[0].length)));1==y(m).level&&(t=h.match(/\s+$/))&&(y(m).to-=t[0].length,m.push(new b(0,k-t[0].length,k)));2==m[0].level&&m.unshift(new b(1,m[0].to,
m[0].to));m[0].level!=y(m).level&&m.push(new b(m[0].level,k,k));return m}}(),dc=[],v=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]||dc).concat(c))},Fg=function(){if(B&&9>A)return!1;var a=r("div");return"draggable"in a||"dragDrop"in a}(),Xc,cd,Ld=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;b<=d;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?
e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)},Sg=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){var b;try{b=a.ownerDocument.selection.createRange()}catch(c){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},vf=function(){var a=r("div");if("oncopy"in a)return!0;a.setAttribute("oncopy","return;");return"function"==typeof a.oncopy}(),
id=null,Yc={},Oa={},Pa={},qb=function(a,b){this.pos=this.start=0;this.string=a;this.tabSize=b||8;this.lineStart=this.lastColumnPos=this.lastColumnValue=0};qb.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=Y(this.string,this.start,this.tabSize,
this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start);return this.lastColumnValue-(this.lineStart?Y(this.string,this.lineStart,this.tabSize):0)},indentation:function(){return Y(this.string,null,this.tabSize)-(this.lineStart?Y(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}}};Na(Qa);Qa.prototype.lineNo=function(){return C(this)};var $f={},Zf={},Sa=null,tb=null,ue={left:0,right:0,top:0,bottom:0},Ia,mc=0,V=null;B?V=-.53:sa?V=15:Pg?V=-.7:Cf&&(V=-1/3);td.prototype=aa({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.checkedZeroWidth&&0<a.clientHeight&&(0==d&&this.zeroWidthHack(),this.checkedZeroWidth=!0);return{right:c?d:0,bottom:b?d:0}},setScrollLeft:function(a){this.horiz.scrollLeft!=a&&(this.horiz.scrollLeft=a);this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},setScrollTop:function(a){this.vert.scrollTop!=a&&(this.vert.scrollTop=a);this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert)},zeroWidthHack:function(){this.horiz.style.height=
this.vert.style.width=da&&!Qg?"12px":"18px";this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none";this.disableHoriz=new Aa;this.disableVert=new Aa},enableZeroWidthBar:function(a,b){function c(){var d=a.getBoundingClientRect();document.elementFromPoint(d.left+1,d.bottom-1)!=a?a.style.pointerEvents="none":b.set(1E3,c)}a.style.pointerEvents="auto";b.set(1E3,c)},clear:function(){var a=this.horiz.parentNode;a.removeChild(this.horiz);a.removeChild(this.vert)}},td.prototype);ud.prototype=aa({update:function(){return{bottom:0,
right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},ud.prototype);var Je={"native":td,"null":ud},kg=0;qc.prototype.signal=function(a,b){Z(a,b)&&this.events.push(arguments)};qc.prototype.finish=function(){for(var a=0;a<this.events.length;a++)E.apply(null,this.events[a])};qa.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!=w(c.anchor,d.anchor)||0!=w(c.head,d.head))return!1}return!0},deepCopy:function(){for(var a=[],b=0;b<this.ranges.length;b++)a[b]=new z(Nc(this.ranges[b].anchor),Nc(this.ranges[b].head));return new qa(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<=w(b,d.from())&&
0>=w(a,d.to()))return c}return-1}};z.prototype={from:function(){return Yb(this.anchor,this.head)},to:function(){return Xb(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};Hb.prototype={chunkSize:function(){return this.lines.length},removeInner:function(a,b){for(var c=a,d=a+b;c<d;++c){var e=this.lines[c];this.height-=e.height;var f=e;f.parent=null;Td(f);R(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.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}};Ib.prototype={chunkSize:function(){return this.size},removeInner:function(a,b){this.size-=b;for(var c=0;c<this.children.length;++c){var d=this.children[c],e=d.chunkSize();if(a<e){var f=Math.min(b,e-a),g=d.height;d.removeInner(a,f);this.height-=g-d.height;e==f&&(this.children.splice(c--,
1),d.parent=null);if(0==(b-=f))break;a=0}else a-=e}25>this.size-b&&(1<this.children.length||!(this.children[0]instanceof Hb))&&(c=[],this.collapse(c),this.children=[new Hb(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],f=e.chunkSize();if(a<=f){e.insertInner(a,b,c);if(e.lines&&50<e.lines.length){for(b=
a=e.lines.length%25+25;b<e.lines.length;)c=new Hb(e.lines.slice(b,b+=25)),e.height-=c.height,this.children.splice(++d,0,c),c.parent=this;e.lines=e.lines.slice(0,a);this.maybeSpill()}break}a-=f}},maybeSpill:function(){if(!(10>=this.children.length)){var a=this;do{var b=a.children.splice(a.children.length-5,5),b=new Ib(b);if(a.parent){a.size-=b.size;a.height-=b.height;var c=H(a.parent.children,a);a.parent.children.splice(c+1,0,b)}else c=new Ib(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],f=e.chunkSize();if(a<f){f=Math.min(b,f-a);if(e.iterN(a,f,c))return!0;if(0==(b-=f))break;a=0}else a-=f}}};Na(Jb);Jb.prototype.clear=function(){var a=this.doc.cm,b=this.line.widgets,c=this.line,d=C(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 f=vb(this);ga(c,Math.max(0,c.height-f));a&&W(a,function(){var b=-f;ia(c)<
(a.curOp&&a.curOp.scrollTop||a.doc.scrollTop)&&oc(a,null,b);va(a,d,"widget")})}};Jb.prototype.changed=function(){var a=this.height,b=this.doc.cm,c=this.line;this.height=null;var d=vb(this)-a;d&&(ga(c,c.height+d),b&&W(b,function(){b.curOp.forceUpdate=!0;ia(c)<(b.curOp&&b.curOp.scrollTop||b.doc.scrollTop)&&oc(b,null,d)}))};var jf=0;Na(xa);xa.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;b&&Xa(a);if(Z(this,"clear")){var c=this.find();c&&R(this,"clear",c.from,
c.to)}for(var d=c=null,e=0;e<this.lines.length;++e){var f=this.lines[e],g=mb(f.markedSpans,this);a&&!this.collapsed?va(a,C(f),"text"):a&&(null!=g.to&&(d=C(f)),null!=g.from&&(c=C(f)));for(var h=f,k=f.markedSpans,l=g,m=void 0,n=0;n<k.length;++n)k[n]!=l&&(m||(m=[])).push(k[n]);h.markedSpans=m;null==g.from&&this.collapsed&&!Ea(this.doc,f)&&a&&ga(f,Ha(a.display))}if(a&&this.collapsed&&!a.options.lineWrapping)for(e=0;e<this.lines.length;++e)f=ha(this.lines[e]),g=$b(f),g>a.display.maxLineLength&&(a.display.maxLine=
f,a.display.maxLineLength=g,a.display.maxLineChanged=!0);null!=c&&a&&this.collapsed&&N(a,c,d+1);this.lines.length=0;this.explicitlyCleared=!0;this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&Ze(a.doc));a&&R(a,"markerCleared",a,this);b&&Ya(a);this.parent&&this.parent.clear()}};xa.prototype.find=function(a,b){null==a&&"bookmark"==this.type&&(a=1);for(var c,d,e=0;e<this.lines.length;++e){var f=this.lines[e],g=mb(f.markedSpans,this);if(null!=g.from&&(c=q(b?f:C(f),g.from),-1==a))return c;if(null!=
g.to&&(d=q(b?f:C(f),g.to),1==a))return d}return c&&{from:c,to:d}};xa.prototype.changed=function(){var a=this.find(-1,!0),b=this,c=this.doc.cm;a&&c&&W(c,function(){var d=a.line,e=C(a.line);if(e=gd(c,e))ve(e),c.curOp.selectionChanged=c.curOp.forceUpdate=!0;c.curOp.updateMaxLine=!0;Ea(b.doc,d)||null==b.height||(e=b.height,b.height=null,(e=vb(b)-e)&&ga(d,d.height+e))})};xa.prototype.attachLine=function(a){if(!this.lines.length&&this.doc.cm){var b=this.doc.cm.curOp;b.maybeHiddenMarkers&&-1!=H(b.maybeHiddenMarkers,
this)||(b.maybeUnhiddenMarkers||(b.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(a)};xa.prototype.detachLine=function(a){this.lines.splice(H(this.lines,a),1);!this.lines.length&&this.doc.cm&&(a=this.doc.cm.curOp,(a.maybeHiddenMarkers||(a.maybeHiddenMarkers=[])).push(this))};Na(Kb);Kb.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var a=0;a<this.markers.length;++a)this.markers[a].clear();R(this,"clear")}};Kb.prototype.find=function(a,b){return this.primary.find(a,
b)};var Tg=0,P=function(a,b,c,d){if(!(this instanceof P))return new P(a,b,c,d);null==c&&(c=0);Ib.call(this,[new Hb([new Qa("",null)])]);this.first=c;this.scrollTop=this.scrollLeft=0;this.cantEdit=!1;this.cleanGeneration=1;this.frontier=c;c=q(c,0);this.sel=ra(c);this.history=new sc(null);this.id=++Tg;this.modeOption=b;this.lineSep=d;this.extend=!1;"string"==typeof a&&(a=this.splitLines(a));Ad(this,{from:c,to:c,text:a});K(this,ra(c),ka)};P.prototype=Pd(Ib.prototype,{constructor:P,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=Lc(this,this.first,this.first+this.size);return!1===a?b:b.join(a||this.lineSeparator())},setValue:J(function(a){var b=q(this.first,0),c=this.first+this.size-1;ab(this,{from:b,to:q(c,u(this,c).text.length),text:this.splitLines(a),origin:"setValue",
full:!0},!0);K(this,ra(b))}),replaceRange:function(a,b,c,d){b=x(this,b);c=c?x(this,c):b;bb(this,a,b,c,d)},getRange:function(a,b,c){a=Ba(this,x(this,a),x(this,b));return!1===c?a:a.join(c||this.lineSeparator())},getLine:function(a){return(a=this.getLineHandle(a))&&a.text},getLineHandle:function(a){if(lb(this,a))return u(this,a)},getLineNumber:function(a){return C(a)},getLineHandleVisualStart:function(a){"number"==typeof a&&(a=u(this,a));return ha(a)},lineCount:function(){return this.size},firstLine:function(){return this.first},
lastLine:function(){return this.first+this.size-1},clipPos:function(a){return x(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:J(function(a,b,c){a=x(this,"number"==typeof a?q(a,b||0):a);K(this,ra(a,null),c)}),setSelection:J(function(a,b,c){var d=x(this,a);a=x(this,b||a);
K(this,ra(d,a),c)}),extendSelection:J(function(a,b,c){uc(this,x(this,a),b&&x(this,b),c)}),extendSelections:J(function(a,b){Ve(this,Rd(this,a),b)}),extendSelectionsBy:J(function(a,b){var c=Vb(this.sel.ranges,a);Ve(this,Rd(this,c),b)}),setSelections:J(function(a,b,c){if(a.length){for(var d=[],e=0;e<a.length;e++)d[e]=new z(x(this,a[e].anchor),x(this,a[e].head));null==b&&(b=Math.min(a.length-1,this.sel.primIndex));K(this,fa(d,b),c)}}),addSelection:J(function(a,b,c){var d=this.sel.ranges.slice(0);d.push(new z(x(this,
a),x(this,b||a)));K(this,fa(d,d.length-1),c)}),getSelection:function(a){for(var b=this.sel.ranges,c,d=0;d<b.length;d++){var e=Ba(this,b[d].from(),b[d].to());c=c?c.concat(e):e}return!1===a?c:c.join(a||this.lineSeparator())},getSelections:function(a){for(var b=[],c=this.sel.ranges,d=0;d<c.length;d++){var e=Ba(this,c[d].from(),c[d].to());!1!==a&&(e=e.join(a||this.lineSeparator()));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:J(function(a,b,c){for(var d=[],e=this.sel,f=0;f<e.ranges.length;f++){var g=e.ranges[f];d[f]={from:g.from(),to:g.to(),text:this.splitLines(a[f]),origin:c}}if(a=b&&"end"!=b){a=[];e=c=q(this.first,0);for(f=0;f<d.length;f++){var h=d[f],g=Oe(h.from,c,e),k=Oe(wa(h),c,e);c=h.to;e=k;"around"==b?(h=this.sel.ranges[f],h=0>w(h.head,h.anchor),a[f]=new z(h?k:g,h?g:k)):a[f]=new z(g,g)}a=new qa(a,this.sel.primIndex)}b=a;for(a=d.length-1;0<=a;a--)ab(this,d[a]);b?We(this,b):this.cm&&
Wa(this.cm)}),undo:J(function(){wc(this,"undo")}),redo:J(function(){wc(this,"redo")}),undoSelection:J(function(){wc(this,"undo",!0)}),redoSelection:J(function(){wc(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 sc(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:Za(this.history.done),undone:Za(this.history.undone)}},setHistory:function(a){var b=this.history=new sc(this.history.maxGeneration);b.done=Za(a.done.slice(0),null,!0);b.undone=Za(a.undone.slice(0),
null,!0)},setGutterMarker:J(function(a,b,c){return Gb(this,a,"gutter",function(a){var e=a.gutterMarkers||(a.gutterMarkers={});e[b]=c;!c&&Qd(e)&&(a.gutterMarkers=null);return!0})}),clearGutter:J(function(a){var b=this,c=this.first;this.iter(function(d){d.gutterMarkers&&d.gutterMarkers[a]&&Gb(b,d,"gutter",function(){d.gutterMarkers[a]=null;Qd(d.gutterMarkers)&&(d.gutterMarkers=null);return!0});++c})}),lineInfo:function(a){var b;if("number"==typeof a){if(!lb(this,a))return null;b=a;a=u(this,a);if(!a)return null}else if(b=
C(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}},addLineClass:J(function(a,b,c){return Gb(this,a,"gutter"==b?"gutter":"class",function(a){var e="text"==b?"textClass":"background"==b?"bgClass":"gutter"==b?"gutterClass":"wrapClass";if(a[e]){if(za(c).test(a[e]))return!1;a[e]+=" "+c}else a[e]=c;return!0})}),removeLineClass:J(function(a,b,c){return Gb(this,a,"gutter"==b?"gutter":"class",
function(a){var e="text"==b?"textClass":"background"==b?"bgClass":"gutter"==b?"gutterClass":"wrapClass",f=a[e];if(f)if(null==c)a[e]=null;else{var g=f.match(za(c));if(!g)return!1;var h=g.index+g[0].length;a[e]=f.slice(0,g.index)+(g.index&&h!=f.length?" ":"")+f.slice(h)||null}else return!1;return!0})}),addLineWidget:J(function(a,b,c){return rg(this,a,b,c)}),removeLineWidget:function(a){a.clear()},markText:function(a,b,c){return cb(this,x(this,a),x(this,b),c,c&&c.type||"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,handleMouseEvents:b&&b.handleMouseEvents};a=x(this,a);return cb(this,a,a,c,"bookmark")},findMarksAt:function(a){a=x(this,a);var b=[],c=u(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=x(this,a);b=x(this,b);var d=[],e=a.line;this.iter(a.line,
b.line+1,function(f){if(f=f.markedSpans)for(var g=0;g<f.length;g++){var h=f[g];null!=h.to&&e==a.line&&a.ch>=h.to||null==h.from&&e!=a.line||null!=h.from&&e==b.line&&h.from>=b.ch||c&&!c(h.marker)||d.push(h.marker.parent||h.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,d=this.lineSeparator().length;this.iter(function(e){e=e.text.length+
d;if(e>a)return b=a,!0;a-=e;++c});return x(this,q(c,b))},indexFromPos:function(a){a=x(this,a);var b=a.ch;if(a.line<this.first||0>a.ch)return 0;var c=this.lineSeparator().length;this.iter(this.first,a.line,function(a){b+=a.text.length+c});return b},copy:function(a){var b=new P(Lc(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep);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 P(Lc(this,b,c),a.mode||this.modeOption,b,this.lineSep);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=kf(this);for(c=0;c<a.length;c++){var d=a[c],e=d.find(),f=b.clipPos(e.from),e=b.clipPos(e.to);w(f,e)&&(f=cb(b,f,e,d.primary,d.primary.type),
d.markers.push(f),f.parent=d)}return b},unlinkDoc:function(a){a instanceof D&&(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);tg(kf(this));break}if(a.history==this.history){var c=[a.id];Ka(a,function(a){return c.push(a.id)},!0);a.history=new sc(null);a.history.done=Za(this.history.done,c);a.history.undone=Za(this.history.undone,c)}},iterLinkedDocs:function(a){Ka(this,a)},getMode:function(){return this.mode},getEditor:function(){return this.cm},
splitLines:function(a){return this.lineSep?a.split(this.lineSep):Ld(a)},lineSeparator:function(){return this.lineSep||"\n"}});P.prototype.eachLine=P.prototype.iter;for(var mf=0,Bf=!1,ya={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:"\x3d",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"\x3d",109:"-",110:".",
111:"/",127:"Delete",173:"-",186:";",187:"\x3d",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"},Qb=0;10>Qb;Qb++)ya[Qb+48]=ya[Qb+96]=String(Qb);for(var Fc=65;90>=Fc;Fc++)ya[Fc]=String.fromCharCode(Fc);for(var Rb=1;12>=Rb;Rb++)ya[Rb+111]=ya[Rb+63235]="F"+Rb;var Lb={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"},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"},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","Ctrl-O":"openLine"},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"]}};Lb["default"]=da?Lb.macDefault:Lb.pcDefault;var zc={selectAll:af,singleSelection:function(a){return a.setSelection(a.getCursor("anchor"),a.getCursor("head"),ka)},killLine:function(a){return eb(a,function(b){if(b.empty()){var c=u(a.doc,b.head.line).text.length;return b.head.ch==c&&b.head.line<a.lastLine()?{from:b.head,to:q(b.head.line+1,0)}:{from:b.head,to:q(b.head.line,c)}}return{from:b.from(),to:b.to()}})},deleteLine:function(a){return eb(a,function(b){return{from:q(b.from().line,
0),to:x(a.doc,q(b.to().line+1,0))}})},delLineLeft:function(a){return eb(a,function(a){return{from:q(a.from().line,0),to:a.from()}})},delWrappedLineLeft:function(a){return eb(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){return eb(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){return a.undo()},
redo:function(a){return a.redo()},undoSelection:function(a){return a.undoSelection()},redoSelection:function(a){return a.redoSelection()},goDocStart:function(a){return a.extendSelection(q(a.firstLine(),0))},goDocEnd:function(a){return a.extendSelection(q(a.lastLine()))},goLineStart:function(a){return a.extendSelectionsBy(function(b){return rf(a,b.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(a){return a.extendSelectionsBy(function(b){return sf(a,b.head)},{origin:"+move",bias:1})},
goLineEnd:function(a){return a.extendSelectionsBy(function(b){b=b.head.line;for(var c,d=u(a.doc,b);c=Da(d,!1);)d=c.find(1,!0).line,b=null;c=(c=ba(d))?c[0].level%2?ac(d):bc(d):d.text.length;return q(null==b?C(d):b,c)},{origin:"+move",bias:-1})},goLineRight:function(a){return a.extendSelectionsBy(function(b){b=a.charCoords(b.head,"div").top+5;return a.coordsChar({left:a.display.lineDiv.offsetWidth+100,top:b},"div")},Pb)},goLineLeft:function(a){return a.extendSelectionsBy(function(b){b=a.charCoords(b.head,
"div").top+5;return a.coordsChar({left:0,top:b},"div")},Pb)},goLineLeftSmart:function(a){return 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/)?sf(a,b.head):c},Pb)},goLineUp:function(a){return a.moveV(-1,"line")},goLineDown:function(a){return a.moveV(1,"line")},goPageUp:function(a){return a.moveV(-1,"page")},goPageDown:function(a){return a.moveV(1,"page")},goCharLeft:function(a){return a.moveH(-1,
"char")},goCharRight:function(a){return a.moveH(1,"char")},goColumnLeft:function(a){return a.moveH(-1,"column")},goColumnRight:function(a){return a.moveH(1,"column")},goWordLeft:function(a){return a.moveH(-1,"word")},goGroupRight:function(a){return a.moveH(1,"group")},goGroupLeft:function(a){return a.moveH(-1,"group")},goWordRight:function(a){return a.moveH(1,"word")},delCharBefore:function(a){return a.deleteH(-1,"char")},delCharAfter:function(a){return a.deleteH(1,"char")},delWordBefore:function(a){return a.deleteH(-1,
"word")},delWordAfter:function(a){return a.deleteH(1,"word")},delGroupBefore:function(a){return a.deleteH(-1,"group")},delGroupAfter:function(a){return a.deleteH(1,"group")},indentAuto:function(a){return a.indentSelection("smart")},indentMore:function(a){return a.indentSelection("add")},indentLess:function(a){return a.indentSelection("subtract")},insertTab:function(a){return a.replaceSelection("\t")},insertSoftTab:function(a){for(var b=[],c=a.listSelections(),d=a.options.tabSize,e=0;e<c.length;e++){var f=
c[e].from(),f=Y(a.getLine(f.line),f.ch,d);b.push(Jc(d-f%d))}a.replaceSelections(b)},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):a.execCommand("insertTab")},transposeChars:function(a){return W(a,function(){for(var b=a.listSelections(),c=[],d=0;d<b.length;d++)if(b[d].empty()){var e=b[d].head,f=u(a.doc,e.line).text;if(f)if(e.ch==f.length&&(e=new q(e.line,e.ch-1)),0<e.ch)e=new q(e.line,e.ch+1),a.replaceRange(f.charAt(e.ch-1)+f.charAt(e.ch-2),q(e.line,e.ch-2),e,"+transpose");
else if(e.line>a.doc.first){var g=u(a.doc,e.line-1).text;g&&(e=new q(e.line,1),a.replaceRange(f.charAt(0)+a.doc.lineSeparator()+g.charAt(g.length-1),q(e.line-1,g.length-1),e,"+transpose"))}c.push(new z(e,e))}a.setSelections(c)})},newlineAndIndent:function(a){return W(a,function(){for(var b=a.listSelections(),c=b.length-1;0<=c;c--)a.replaceRange(a.doc.lineSeparator(),b[c].anchor,b[c].head,"+input");b=a.listSelections();for(c=0;c<b.length;c++)a.indentLine(b[c].from().line,null,!0);Wa(a)})},openLine:function(a){return a.replaceSelection("\n",
"start")},toggleOverwrite:function(a){return a.toggleOverwrite()}},Ag=new Aa,Fd=null,Cc,Bc,fb={toString:function(){return"CodeMirror.Init"}},Af={},Dc={};D.defaults=Af;D.optionHandlers=Dc;var Jd=[];D.defineInitHook=function(a){return Jd.push(a)};var S=null;Nd.prototype=aa({init:function(a){function b(a){if(!F(e,a)){if(e.somethingSelected())Df({lineWise:!1,text:e.getSelections()}),"cut"==a.type&&e.replaceSelection("",null,"cut");else if(e.options.lineWiseCopyCut){var b=Gf(e);Df({lineWise:!0,text:b.text});
"cut"==a.type&&e.operation(function(){e.setSelections(b.ranges,0,ka);e.replaceSelection("",null,"cut")})}else return;if(a.clipboardData){a.clipboardData.clearData();var c=S.text.join("\n");a.clipboardData.setData("Text",c);if(a.clipboardData.getData("Text")==c){a.preventDefault();return}}var l=If();a=l.firstChild;e.display.lineSpace.insertBefore(l,e.display.lineSpace.firstChild);a.value=S.text.join("\n");var m=document.activeElement;hb(a);setTimeout(function(){e.display.lineSpace.removeChild(l);m.focus();
m==f&&d.showPrimarySelection()},50)}}var c=this,d=this,e=d.cm,f=d.div=a.lineDiv;Hf(f,e.options.spellcheck);v(f,"paste",function(a){F(e,a)||Ff(a,e)||11>=A&&setTimeout(G(e,function(){d.pollContent()||N(e)}),20)});v(f,"compositionstart",function(a){c.composing={data:a.data}});v(f,"compositionupdate",function(a){c.composing||(c.composing={data:a.data})});v(f,"compositionend",function(a){c.composing&&(a.data!=c.composing.data&&c.readFromDOMSoon(),c.composing=null)});v(f,"touchstart",function(){return d.forceCompositionEnd()});
v(f,"input",function(){c.composing||c.readFromDOMSoon()});v(f,"copy",b);v(f,"cut",b)},prepareSelection:function(){var a=Ae(this.cm,!1);a.focus=this.cm.state.focused;return a},showSelection:function(a,b){a&&this.cm.display.view.length&&((a.focus||b)&&this.showPrimarySelection(),this.showMultipleSelections(a))},showPrimarySelection:function(){var a=window.getSelection(),b=this.cm.doc.sel.primary(),c=Ec(this.cm,a.anchorNode,a.anchorOffset),d=Ec(this.cm,a.focusNode,a.focusOffset);if(!c||c.bad||!d||d.bad||
0!=w(Yb(c,d),b.from())||0!=w(Xb(c,d),b.to()))if(c=Kf(this.cm,b.from()),d=Kf(this.cm,b.to()),c||d){var e=this.cm.display.view,b=a.rangeCount&&a.getRangeAt(0);c?d||(d=e[e.length-1].measure,d=d.maps?d.maps[d.maps.length-1]:d.map,d={node:d[d.length-1],offset:d[d.length-2]-d[d.length-3]}):c={node:e[0].measure.map[2],offset:0};var f;try{f=Ra(c.node,c.offset,d.offset,d.node)}catch(g){}f&&(!sa&&this.cm.state.focused?(a.collapse(c.node,c.offset),f.collapsed||(a.removeAllRanges(),a.addRange(f))):(a.removeAllRanges(),
a.addRange(f)),b&&null==a.anchorNode?a.addRange(b):sa&&this.startGracePeriod());this.rememberSelection()}},startGracePeriod:function(){var a=this;clearTimeout(this.gracePeriod);this.gracePeriod=setTimeout(function(){a.gracePeriod=!1;a.selectionChanged()&&a.cm.operation(function(){return a.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(a){U(this.cm.display.cursorDiv,a.cursors);U(this.cm.display.selectionDiv,a.selection)},rememberSelection:function(){var a=window.getSelection();
this.lastAnchorNode=a.anchorNode;this.lastAnchorOffset=a.anchorOffset;this.lastFocusNode=a.focusNode;this.lastFocusOffset=a.focusOffset},selectionInEditor:function(){var a=window.getSelection();if(!a.rangeCount)return!1;a=a.getRangeAt(0).commonAncestorContainer;return Tb(this.div,a)},focus:function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()||this.showSelection(this.prepareSelection(),!0),this.div.focus())},blur:function(){this.div.blur()},getField:function(){return this.div},
supportsTouch:function(){return!0},receivedFocus:function(){function a(){b.cm.state.focused&&(b.pollSelection(),b.polling.set(b.cm.options.pollInterval,a))}var b=this;this.selectionInEditor()?this.pollSelection():W(this.cm,function(){return b.cm.curOp.selectionChanged=!0});this.polling.set(this.cm.options.pollInterval,a)},selectionChanged:function(){var a=window.getSelection();return a.anchorNode!=this.lastAnchorNode||a.anchorOffset!=this.lastAnchorOffset||a.focusNode!=this.lastFocusNode||a.focusOffset!=
this.lastFocusOffset},pollSelection:function(){if(!this.composing&&null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var a=window.getSelection(),b=this.cm;this.rememberSelection();var c=Ec(b,a.anchorNode,a.anchorOffset),d=Ec(b,a.focusNode,a.focusOffset);c&&d&&W(b,function(){K(b.doc,ra(c,d),ka);if(c.bad||d.bad)b.curOp.selectionChanged=!0})}},pollContent:function(){null!=this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var a=this.cm,b=a.display,
c=a.doc.sel.primary(),d=c.from(),c=c.to();0==d.ch&&d.line>a.firstLine()&&(d=q(d.line-1,u(a.doc,d.line-1).length));c.ch==u(a.doc,c.line).text.length&&c.line<a.lastLine()&&(c=q(c.line+1,0));if(d.line<b.viewFrom||c.line>b.viewTo-1)return!1;var e;d.line==b.viewFrom||0==(e=Ga(a,d.line))?(d=C(b.view[0].line),e=b.view[0].node):(d=C(b.view[e].line),e=b.view[e-1].node.nextSibling);var f=Ga(a,c.line);f==b.view.length-1?(c=b.viewTo-1,b=b.lineDiv.lastChild):(c=C(b.view[f+1].line)-1,b=b.view[f+1].node.previousSibling);
if(!e)return!1;b=a.doc.splitLines(Mg(a,e,b,d,c));for(e=Ba(a.doc,q(d,0),q(c,u(a.doc,c).text.length));1<b.length&&1<e.length;)if(y(b)==y(e))b.pop(),e.pop(),c--;else if(b[0]==e[0])b.shift(),e.shift(),d++;else break;for(var g=0,f=0,h=b[0],k=e[0],l=Math.min(h.length,k.length);g<l&&h.charCodeAt(g)==k.charCodeAt(g);)++g;h=y(b);k=y(e);for(l=Math.min(h.length-(1==b.length?g:0),k.length-(1==e.length?g:0));f<l&&h.charCodeAt(h.length-f-1)==k.charCodeAt(k.length-f-1);)++f;b[b.length-1]=h.slice(0,h.length-f).replace(/^\u200b+/,
"");b[0]=b[0].slice(g).replace(/\u200b+$/,"");d=q(d,g);c=q(c,e.length?y(e).length-f:0);if(1<b.length||b[0]||w(d,c))return bb(a.doc,b,d,c,"+input"),!0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&(this.composing=null,this.pollContent()||N(this.cm),this.div.blur(),this.div.focus())},readFromDOMSoon:function(){var a=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){a.readDOMTimeout=
null;a.composing||!a.cm.isReadOnly()&&a.pollContent()||W(a.cm,function(){return N(a.cm)})},80))},setUneditable:function(a){a.contentEditable="false"},onKeyPress:function(a){a.preventDefault();this.cm.isReadOnly()||G(this.cm,Kd)(this.cm,String.fromCharCode(null==a.charCode?a.keyCode:a.charCode),0)},readOnlyChanged:function(a){this.div.contentEditable=String("nocursor"!=a)},onContextMenu:ib,resetPosition:ib,needsContentAttribute:!0},Nd.prototype);Od.prototype=aa({init:function(a){function b(a){if(!F(e,
a)){if(e.somethingSelected())S={lineWise:!1,text:e.getSelections()},d.inaccurateSelection&&(d.prevInput="",d.inaccurateSelection=!1,g.value=S.text.join("\n"),hb(g));else if(e.options.lineWiseCopyCut){var b=Gf(e);S={lineWise:!0,text:b.text};"cut"==a.type?e.setSelections(b.ranges,null,ka):(d.prevInput="",g.value=b.text.join("\n"),hb(g))}else return;"cut"==a.type&&(e.state.cutIncoming=!0)}}var c=this,d=this,e=this.cm,f=this.wrapper=If(),g=this.textarea=f.firstChild;a.wrapper.insertBefore(f,a.wrapper.firstChild);
Ob&&(g.style.width="0px");v(g,"input",function(){B&&9<=A&&c.hasSelection&&(c.hasSelection=null);d.poll()});v(g,"paste",function(a){F(e,a)||Ff(a,e)||(e.state.pasteIncoming=!0,d.fastPoll())});v(g,"cut",b);v(g,"copy",b);v(a.scroller,"paste",function(b){oa(a,b)||F(e,b)||(e.state.pasteIncoming=!0,d.focus())});v(a.lineSpace,"selectstart",function(b){oa(a,b)||L(b)});v(g,"compositionstart",function(){var a=e.getCursor("from");d.composing&&d.composing.range.clear();d.composing={start:a,range:e.markText(a,
e.getCursor("to"),{className:"CodeMirror-composing"})}});v(g,"compositionend",function(){d.composing&&(d.poll(),d.composing.range.clear(),d.composing=null)})},prepareSelection:function(){var a=this.cm,b=a.display,c=a.doc,d=Ae(a);if(a.options.moveInputWithCursor){var a=pa(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},showSelection:function(a){var b=this.cm.display;U(b.cursorDiv,a.cursors);U(b.selectionDiv,a.selection);null!=a.teTop&&(this.wrapper.style.top=a.teTop+"px",this.wrapper.style.left=a.teLeft+"px")},reset:function(a){if(!this.contextMenuPending){var b,c,d=this.cm,e=d.doc;d.somethingSelected()?(this.prevInput="",b=e.sel.primary(),c=(b=vf&&(100<b.to().line-b.from().line||1E3<(c=d.getSelection()).length))?"-":c||d.getSelection(),this.textarea.value=c,d.state.focused&&hb(this.textarea),
B&&9<=A&&(this.hasSelection=c)):a||(this.prevInput=this.textarea.value="",B&&9<=A&&(this.hasSelection=null));this.inaccurateSelection=b}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!kb||la()!=this.textarea))try{this.textarea.focus()}catch(a){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var a=
this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){a.poll();a.cm.state.focused&&a.slowPoll()})},fastPoll:function(){function a(){c.poll()||b?(c.pollingFast=!1,c.slowPoll()):(b=!0,c.polling.set(60,a))}var b=!1,c=this;c.pollingFast=!0;c.polling.set(20,a)},poll:function(){var a=this,b=this.cm,c=this.textarea,d=this.prevInput;if(this.contextMenuPending||!b.state.focused||Sg(c)&&!d&&!this.composing||b.isReadOnly()||b.options.disableInput||b.state.keySeq)return!1;var e=c.value;
if(e==d&&!b.somethingSelected())return!1;if(B&&9<=A&&this.hasSelection===e||da&&/[\uf700-\uf7ff]/.test(e))return b.display.input.reset(),!1;if(b.doc.sel==b.display.selForContextMenu){var f=e.charCodeAt(0);8203!=f||d||(d="​");if(8666==f)return this.reset(),this.cm.execCommand("undo")}for(var g=0,f=Math.min(d.length,e.length);g<f&&d.charCodeAt(g)==e.charCodeAt(g);)++g;W(b,function(){Kd(b,e.slice(g),d.length-g,null,a.composing?"*compose":null);1E3<e.length||-1<e.indexOf("\n")?c.value=a.prevInput="":
a.prevInput=e;a.composing&&(a.composing.range.clear(),a.composing.range=b.markText(a.composing.start,b.getCursor("to"),{className:"CodeMirror-composing"}))});return!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){B&&9<=A&&(this.hasSelection=null);this.fastPoll()},onContextMenu:function(a){function b(){if(null!=g.selectionStart){var a=e.somethingSelected(),b="​"+(a?g.value:"");g.value="⇚";g.value=b;d.prevInput=a?"":"​";g.selectionStart=1;g.selectionEnd=
b.length;f.selForContextMenu=e.doc.sel}}function c(){d.contextMenuPending=!1;d.wrapper.style.cssText=m;g.style.cssText=l;B&&9>A&&f.scrollbars.setScrollTop(f.scroller.scrollTop=k);if(null!=g.selectionStart){(!B||B&&9>A)&&b();var a=0,c=function(){f.selForContextMenu==e.doc.sel&&0==g.selectionStart&&0<g.selectionEnd&&"​"==d.prevInput?G(e,af)(e):10>a++?f.detectingSelectAll=setTimeout(c,500):f.input.reset()};f.detectingSelectAll=setTimeout(c,200)}}var d=this,e=d.cm,f=e.display,g=d.textarea,h=Ja(e,a),k=
f.scroller.scrollTop;if(h&&!ea){e.options.resetSelectionOnContextMenu&&-1==e.doc.sel.contains(h)&&G(e,K)(e.doc,ra(h),ka);var l=g.style.cssText,m=d.wrapper.style.cssText;d.wrapper.style.cssText="position: absolute";h=d.wrapper.getBoundingClientRect();g.style.cssText="position: absolute; width: 30px; height: 30px;\n      top: "+(a.clientY-h.top-5)+"px; left: "+(a.clientX-h.left-5)+"px;\n      z-index: 1000; background: "+(B?"rgba(255, 255, 255, .05)":"transparent")+";\n      outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity\x3d5);";
var n;I&&(n=window.scrollY);f.input.focus();I&&window.scrollTo(null,n);f.input.reset();e.somethingSelected()||(g.value=d.prevInput=" ");d.contextMenuPending=!0;f.selForContextMenu=e.doc.sel;clearTimeout(f.detectingSelectAll);B&&9<=A&&b();if(Hd){ob(a);var p=function(){ca(window,"mouseup",p);setTimeout(c,20)};v(window,"mouseup",p)}else setTimeout(c,50)}},readOnlyChanged:function(a){a||this.reset()},setUneditable:ib,needsContentAttribute:!1},Od.prototype);(function(a){function b(b,e,f,g){a.defaults[b]=
e;f&&(c[b]=g?function(a,b,d){d!=fb&&f(a,b,d)}:f)}var c=a.optionHandlers;a.defineOption=b;a.Init=fb;b("value","",function(a,b){return a.setValue(b)},!0);b("mode",null,function(a,b){a.doc.modeOption=b;zd(a)},!0);b("indentUnit",2,zd,!0);b("indentWithTabs",!1);b("smartIndent",!0);b("tabSize",4,function(a){Db(a);xb(a);N(a)},!0);b("lineSeparator",null,function(a,b){if(a.doc.lineSep=b){var c=[],g=a.doc.first;a.doc.iter(function(a){for(var d=0;;){var h=a.text.indexOf(b,d);if(-1==h)break;d=h+b.length;c.push(q(g,
h))}g++});for(var h=c.length-1;0<=h;h--)bb(a.doc,b,c[h],q(c[h].line,c[h].ch+b.length))}});b("specialChars",/[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(a,b,c){a.state.specialChars=new RegExp(b.source+(b.test("\t")?"":"|\t"),"g");c!=fb&&a.refresh()});b("specialCharPlaceholder",cg,function(a){return a.refresh()},!0);b("electricChars",!0);b("inputStyle",kb?"contenteditable":"textarea",function(){throw Error("inputStyle can not (yet) be changed in a running editor");},!0);b("spellcheck",
!1,function(a,b){return a.getInputField().spellcheck=b},!0);b("rtlMoveVisually",!Rg);b("wholeLineUpdateBefore",!0);b("theme","default",function(a){zf(a);Mb(a)},!0);b("keyMap","default",function(a,b,c){b=xc(b);(c=c!=fb&&xc(c))&&c.detach&&c.detach(a,b);b.attach&&b.attach(a,c||null)});b("extraKeys",null);b("lineWrapping",!1,Kg,!0);b("gutters",[],function(a){xd(a.options);Mb(a)},!0);b("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?ld(a.display)+"px":"0";a.refresh()},!0);b("coverGutterNextToScrollbar",
!1,function(a){return Va(a)},!0);b("scrollbarStyle","native",function(a){Ie(a);Va(a);a.display.scrollbars.setScrollTop(a.doc.scrollTop);a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)},!0);b("lineNumbers",!1,function(a){xd(a.options);Mb(a)},!0);b("firstLineNumber",1,Mb,!0);b("lineNumberFormatter",function(a){return a},Mb,!0);b("showCursorWhenSelecting",!1,yb,!0);b("resetSelectionOnContextMenu",!0);b("lineWiseCopyCut",!0);b("readOnly",!1,function(a,b){"nocursor"==b?(zb(a),a.display.input.blur(),
a.display.disabled=!0):a.display.disabled=!1;a.display.input.readOnlyChanged(b)});b("disableInput",!1,function(a,b){b||a.display.input.reset()},!0);b("dragDrop",!0,Jg);b("allowDropFileTypes",null);b("cursorBlinkRate",530);b("cursorScrollMargin",0);b("cursorHeight",1,yb,!0);b("singleCursorHeightPerLine",!0,yb,!0);b("workTime",100);b("workDelay",100);b("flattenSpans",!0,Db,!0);b("addModeClass",!1,Db,!0);b("pollInterval",100);b("undoDepth",200,function(a,b){return a.doc.history.undoDepth=b});b("historyEventDelay",
1250);b("viewportMargin",10,function(a){return a.refresh()},!0);b("maxHighlightLength",1E4,Db,!0);b("moveInputWithCursor",!0,function(a,b){b||a.display.input.resetPosition()});b("tabindex",null,function(a,b){return a.display.input.getField().tabIndex=b||""});b("autofocus",null)})(D);(function(a){var b=a.optionHandlers,c=a.helpers={};a.prototype={constructor:a,focus:function(){window.focus();this.display.input.focus()},setOption:function(a,c){var f=this.options,g=f[a];if(f[a]!=c||"mode"==a)f[a]=c,
b.hasOwnProperty(a)&&G(this,b[a])(this,c,g)},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](xc(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:O(function(b,c){var f=b.token?b:a.getMode(this.options,b);if(f.startState)throw Error("Overlays may not be stateful.");Of(this.state.overlays,{mode:f,modeSpec:b,opaque:c&&
c.opaque,priority:c&&c.priority||0},function(a){return a.priority});this.state.modeGen++;N(this)}),removeOverlay:O(function(a){for(var b=this.state.overlays,c=0;c<b.length;++c){var g=b[c].modeSpec;if(g==a||"string"==typeof a&&g.name==a){b.splice(c,1);this.state.modeGen++;N(this);break}}}),indentLine:O(function(a,b,c){"string"!=typeof b&&"number"!=typeof b&&(b=null==b?this.options.smartIndent?"smart":"prev":b?"add":"subtract");lb(this.doc,a)&&Nb(this,a,b,c)}),indentSelection:O(function(a){for(var b=
this.doc.sel.ranges,c=-1,g=0;g<b.length;g++){var h=b[g];if(h.empty())h.head.line>c&&(Nb(this,h.head.line,a,!0),c=h.head.line,g==this.doc.sel.primIndex&&Wa(this));else{for(var k=h.from(),h=h.to(),l=Math.max(c,k.line),c=Math.min(this.lastLine(),h.line-(h.ch?0:1))+1,h=l;h<c;++h)Nb(this,h,a);h=this.doc.sel.ranges;0==k.ch&&b.length==h.length&&0<h[g].from().ch&&Cd(this.doc,g,new z(k,h[g].to()),ka)}}}),getTokenAt:function(a,b){return ge(this,a,b)},getLineTokens:function(a,b){return ge(this,q(a),b,!0)},getTokenTypeAt:function(a){a=
x(this.doc,a);var b=ee(this,u(this.doc,a.line)),c=0,g=(b.length-1)/2;a=a.ch;if(0==a)b=b[2];else for(;;){var h=c+g>>1;if((h?b[2*h-1]:0)>=a)g=h;else if(b[2*h+1]<a)c=h+1;else{b=b[2*h+2];break}}c=b?b.indexOf("overlay "):-1;return 0>c?b:0==c?null:b.slice(0,c-1)},getModeAt:function(b){var c=this.doc.mode;return c.innerMode?a.innerMode(c,this.getTokenAt(b).state).mode:c},getHelper:function(a,b){return this.getHelpers(a,b)[0]},getHelpers:function(a,b){var f=[];if(!c.hasOwnProperty(b))return f;var g=c[b],
h=this.getModeAt(a);if("string"==typeof h[b])g[h[b]]&&f.push(g[h[b]]);else if(h[b])for(var k=0;k<h[b].length;k++){var l=g[h[b][k]];l&&f.push(l)}else h.helperType&&g[h.helperType]?f.push(g[h.helperType]):g[h.name]&&f.push(g[h.name]);for(k=0;k<g._global.length;k++)l=g._global[k],l.pred(h,this)&&-1==H(f,l.val)&&f.push(l.val);return f},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 pb(this,a+1,b)},cursorCoords:function(a,b){var c;
c=this.doc.sel.primary();c=null==a?c.head:"object"==typeof a?x(this.doc,a):a?c.from():c.to();return pa(this,c,b||"page")},charCoords:function(a,b){return jc(this,x(this.doc,a),b||"page")},coordsChar:function(a,b){a=xe(this,a,b||"page");return kd(this,a.left,a.top)},lineAtHeight:function(a,b){a=xe(this,{top:a,left:0},b||"page").top;return Ca(this.doc,a+this.display.viewOffset)},heightAtLine:function(a,b,c){var g=!1;if("number"==typeof a){var h=this.doc.first+this.doc.size-1;a<this.doc.first?a=this.doc.first:
a>h&&(a=h,g=!0);a=u(this.doc,a)}return jd(this,a,{top:0,left:0},b||"page",c).top+(g?this.doc.height-ia(a):0)},defaultTextHeight:function(){return Ha(this.display)},defaultCharWidth:function(){return wb(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,c,g,h){var k=this.display;a=pa(this,x(this.doc,a));var l=a.bottom,m=a.left;b.style.position="absolute";b.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(b);
k.sizer.appendChild(b);if("over"==g)l=a.top;else if("above"==g||"near"==g){var n=Math.max(k.wrapper.clientHeight,this.doc.height),p=Math.max(k.sizer.clientWidth,k.lineSpace.clientWidth);("above"==g||a.bottom+b.offsetHeight>n)&&a.top>b.offsetHeight?l=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=n&&(l=a.bottom);m+b.offsetWidth>p&&(m=p-b.offsetWidth)}b.style.top=l+"px";b.style.left=b.style.right="";"right"==h?(m=k.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==h?m=0:"middle"==h&&(m=(k.sizer.clientWidth-
b.offsetWidth)/2),b.style.left=m+"px");c&&(a=nc(this,m,l,m+b.offsetWidth,l+b.offsetHeight),null!=a.scrollTop&&Ab(this,a.scrollTop),null!=a.scrollLeft&&Ua(this,a.scrollLeft))},triggerOnKeyDown:O(uf),triggerOnKeyPress:O(xf),triggerOnKeyUp:wf,execCommand:function(a){if(zc.hasOwnProperty(a))return zc[a].call(null,this)},triggerElectric:O(function(a){Ef(this,a)}),findPosH:function(a,b,c,g){var h=1;0>b&&(h=-1,b=-b);a=x(this.doc,a);for(var k=0;k<b&&(a=Md(this.doc,a,h,c,g),!a.hitSide);++k);return a},moveH:O(function(a,
b){var c=this;this.extendSelectionsBy(function(g){return c.display.shift||c.doc.extend||g.empty()?Md(c.doc,g.head,a,b,c.options.rtlMoveVisually):0>a?g.from():g.to()},Pb)}),deleteH:O(function(a,b){var c=this.doc;this.doc.sel.somethingSelected()?c.replaceSelection("",null,"+delete"):eb(this,function(g){var h=Md(c,g.head,a,b,!1);return 0>a?{from:h,to:g.head}:{from:g.head,to:h}})}),findPosV:function(a,b,c,g){var h=1;0>b&&(h=-1,b=-b);var k=x(this.doc,a);for(a=0;a<b&&(k=pa(this,k,"div"),null==g?g=k.left:
k.left=g,k=Jf(this,k,h,c),!k.hitSide);++a);return k},moveV:O(function(a,b){var c=this,g=this.doc,h=[],k=!this.display.shift&&!g.extend&&g.sel.somethingSelected();g.extendSelectionsBy(function(l){if(k)return 0>a?l.from():l.to();var n=pa(c,l.head,"div");null!=l.goalColumn&&(n.left=l.goalColumn);h.push(n.left);var p=Jf(c,n,a,b);"page"==b&&l==g.sel.primary()&&oc(c,null,jc(c,p,"div").top-n.top);return p},Pb);if(h.length)for(var l=0;l<g.sel.ranges.length;l++)g.sel.ranges[l].goalColumn=h[l]}),findWordAt:function(a){var b=
u(this.doc,a.line).text,c=a.ch,g=a.ch;if(b){var h=this.getHelper(a,"wordChars");(0>a.xRel||g==b.length)&&c?--c:++g;for(var k=b.charAt(c),k=Wb(k,h)?function(a){return Wb(a,h)}:/\s/.test(k)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!Wb(a)};0<c&&k(b.charAt(c-1));)--c;for(;g<b.length&&k(b.charAt(g));)++g}return new z(q(a.line,c),q(a.line,g))},toggleOverwrite:function(a){if(null==a||a!=this.state.overwrite)(this.state.overwrite=!this.state.overwrite)?Ma(this.display.cursorDiv,"CodeMirror-overwrite"):
Ta(this.display.cursorDiv,"CodeMirror-overwrite"),E(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function(){return this.display.input.getField()==la()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:O(function(a,b){null==a&&null==b||pc(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-ja(this)-this.display.barHeight,
width:a.scrollWidth-ja(this)-this.display.barWidth,clientHeight:fd(this),clientWidth:Fa(this)}},scrollIntoView:O(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:q(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)pc(this),this.curOp.scrollToPos=a;else{var c=nc(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:O(function(a,b){var c=this,g=function(a){return"number"==typeof a||/^\d+$/.test(String(a))?a+"px":a};null!=a&&(this.display.wrapper.style.width=g(a));null!=b&&(this.display.wrapper.style.height=g(b));this.options.lineWrapping&&we(this);var h=this.display.viewFrom;this.doc.iter(h,this.display.viewTo,function(a){if(a.widgets)for(var b=0;b<a.widgets.length;b++)if(a.widgets[b].noHScroll){va(c,
h,"widget");break}++h});this.curOp.forceUpdate=!0;E(this,"refresh",this)}),operation:function(a){return W(this,a)},refresh:O(function(){var a=this.display.cachedTextHeight;N(this);this.curOp.forceUpdate=!0;xb(this);this.scrollTo(this.doc.scrollLeft,this.doc.scrollTop);qd(this);(null==a||.5<Math.abs(a-Ha(this.display)))&&md(this);E(this,"refresh",this)}),swapDoc:O(function(a){var b=this.doc;b.cm=null;Qe(this,a);xb(this);this.display.input.reset();this.scrollTo(a.scrollLeft,a.scrollTop);this.curOp.forceScroll=
!0;R(this,"swapDoc",this,b);return b}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};Na(a);a.registerHelper=function(b,e,f){c.hasOwnProperty(b)||(c[b]=a[b]={_global:[]});c[b][e]=f};a.registerGlobalHelper=function(b,e,f,g){a.registerHelper(b,e,g);c[b]._global.push({pred:f,val:g})}})(D);var Ug="iter insert remove copy getEditor constructor".split(" "),
Sb;for(Sb in P.prototype)P.prototype.hasOwnProperty(Sb)&&0>H(Ug,Sb)&&(D.prototype[Sb]=function(a){return function(){return a.apply(this.doc,arguments)}}(P.prototype[Sb]));Na(P);D.inputStyles={textarea:Od,contenteditable:Nd};D.defineMode=function(a){D.defaults.mode||"null"==a||(D.defaults.mode=a);Wf.apply(this,arguments)};D.defineMIME=function(a,b){Oa[a]=b};D.defineMode("null",function(){return{token:function(a){return a.skipToEnd()}}});D.defineMIME("text/plain","null");D.defineExtension=function(a,
b){D.prototype[a]=b};D.defineDocExtension=function(a,b){P.prototype[a]=b};D.fromTextArea=function(a,b){function c(){a.value=k.getValue()}b=b?aa(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=la();b.autofocus=d==a||null!=a.getAttribute("autofocus")&&d==document.body}var e;if(a.form&&(v(a.form,"submit",c),!b.leaveSubmitMethodAlone)){var f=a.form;e=f.submit;try{var g=f.submit=function(){c();
f.submit=e;f.submit();f.submit=g}}catch(h){}}b.finishInit=function(b){b.save=c;b.getTextArea=function(){return a};b.toTextArea=function(){b.toTextArea=isNaN;c();a.parentNode.removeChild(b.getWrapperElement());a.style.display="";a.form&&(ca(a.form,"submit",c),"function"==typeof a.form.submit&&(a.form.submit=e))}};a.style.display="none";var k=D(function(b){return a.parentNode.insertBefore(b,a.nextSibling)},b);return k};(function(a){a.off=ca;a.on=v;a.wheelEventPixels=jg;a.Doc=P;a.splitLines=Ld;a.countColumn=
Y;a.findColumn=Ic;a.isWordChar=Kc;a.Pass=Ed;a.signal=E;a.Line=Qa;a.changeEnd=wa;a.scrollbarModel=Je;a.Pos=q;a.cmpPos=w;a.modes=Yc;a.mimeModes=Oa;a.resolveMode=ec;a.getMode=Zc;a.modeExtensions=Pa;a.extendMode=Xf;a.copyState=ma;a.startState=be;a.innerMode=$c;a.commands=zc;a.keyMap=Lb;a.keyName=pf;a.isModifierKey=of;a.lookupKey=db;a.normalizeKeyMap=yg;a.StringStream=qb;a.SharedTextMarker=Kb;a.TextMarker=xa;a.LineWidget=Jb;a.e_preventDefault=L;a.e_stopPropagation=$d;a.e_stop=ob;a.addClass=Ma;a.contains=
Tb;a.rmClass=Ta;a.keyNames=ya})(D);D.version="5.21.0";return D});