var CodeMirror=function(){function D(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;c=0&&d>=0;--c,--d)if(a.charAt(c)!=b.charAt(d))break;return d+1}function B(a){return a.replace(/[<>&]/g,function(a){return a=="&"?"&":a=="<"?"<":">"})}function A(a){return{line:a.line,ch:a.ch}}function z(a,b){return a.linea&&d.push(h.slice(a-f,Math.min(h.length,b-f)),c[e+1]),i>=a&&(g=1)):g==1&&(i>b?d.push(h.slice(0,b-f),c[e+1]):d.push(h,c[e+1])),f=i}}function g(a,b){this.styles=b||[a,null],this.stateAfter=null,this.text=a,this.marked=this.gutterMarker=this.className=null}function f(a){this.pos=this.start=0,this.string=a}function e(a,b,c){return a.startState?a.startState(b,c):!0}function d(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c}function a(b,c){function cL(a,b,c){this.atOccurrence=!1,c==null&&(c=typeof a=="string"&&a==a.toLowerCase()),b&&typeof b=="object"?b=ca(b):b={line:0,ch:0},this.pos={from:b,to:b};if(typeof a!="string")this.matches=function(b,c){if(b){var d=U[c.line].text.slice(0,c.ch),e=d.match(a),f=0;while(e){var g=d.indexOf(e[0]);f+=g,d=d.slice(g+1);var h=d.match(a);if(h)e=h;else break;f++}}else var d=U[c.line].text.slice(c.ch),e=d.match(a),f=e&&c.ch+d.indexOf(e[0]);if(e)return{from:{line:c.line,ch:f},to:{line:c.line,ch:f+e[0].length},match:e}};else{c&&(a=a.toLowerCase());var d=c?function(a){return a.toLowerCase()}:function(a){return a},e=a.split("\n");e.length==1?this.matches=function(b,c){var e=d(U[c.line].text),f=a.length,g;if(b?c.ch>=f&&(g=e.lastIndexOf(a,c.ch-f))!=-1:(g=e.indexOf(a,c.ch))!=-1)return{from:{line:c.line,ch:g},to:{line:c.line,ch:g+f}}}:this.matches=function(a,b){var c=b.line,f=a?e.length-1:0,g=e[f],h=d(U[c].text),i=a?h.indexOf(g)+g.length:h.lastIndexOf(g);if(!(a?i>=b.ch||i!=g.length:i<=b.ch||i!=h.length-g.length))for(;;){if(a?!c:c==U.length-1)return;h=d(U[c+=a?-1:1].text),g=e[a?--f:++f];if(f>0&&f=U.length)continue;b=!0;var g=cD(c),h=g&&U[g-1].stateAfter;h?h=d(T,h):h=e(T);var i=0;for(var j=g,k=U.length;ja){V.push(j),cG(f.workDelay),bb.push({from:c,to:j});return}var n=l.highlight(T,h);l.stateAfter=d(T,h);if(n||!m)i=0;else if(++i>3)break}bb.push({from:c,to:j})}b&&f.onHighlightComplete&&f.onHighlightComplete(bp)}function cE(a){var b=cD(a),c=b&&U[b-1].stateAfter;c?c=d(T,c):c=e(T);for(var f=b;fe;--d){if(d==0)return 0;var f=U[d-1];if(f.stateAfter)return d;var g=f.indentation();if(c==null||b>g)c=d,b=g}return c}function cC(a){function p(a,b,c){if(!!a.text){var d=a.styles,e=g?0:a.text.length-1,f;for(var i=g?0:d.length-2,j=g?d.length:-2;i!=j;i+=2*h){var k=d[i];if(d[i+1]!=null&&d[i+1]!=m){e+=h*k.length;continue}for(var l=g?0:k.length-1,p=g?k.length:-1;l!=p;l+=h,e+=h)if(e>=b&&e"==g)n.push(f);else{if(n.pop()!=q.charAt(0))return{pos:e,match:!1};if(!n.length)return{pos:e,match:!0}}}}}}var b=Y.inverted?Y.from:Y.to,c=U[b.line],d=b.ch-1,e=d>=0&&cB[c.text.charAt(d)]||cB[c.text.charAt(++d)];if(!!e){var f=e.charAt(0),g=e.charAt(1)==">",h=g?1:-1,i=c.styles;for(var j=d+1,k=0,l=i.length;kH.clientWidth||e-c.top>H.clientHeight))return null;var f=w(N,!0),g=bf+Math.floor((e-f.top)/cv());return ca({line:g,ch:cs(b_(g),d-f.left)})}function cx(){return N.offsetLeft}function cw(){return N.offsetTop}function cv(){var a=P.childNodes.length;if(a)return P.offsetHeight/a||1;J.innerHTML="
x
";return J.firstChild.offsetHeight||1}function cu(a){var b=ct(a,!0),c=w(N);return{x:c.left+b.x,y:c.top+b.y,yBot:c.top+b.yBot}}function ct(a,b){var c=cv(),d=a.line-(b?bf:0);return{x:cr(a.line,a.ch),y:d*c,yBot:(d+1)*c}}function cs(a,b){function e(a){J.innerHTML="
"+c.getHTML(null,null,!1,a)+"
";return J.firstChild.firstChild.offsetWidth}if(b<=0)return 0;var c=U[a],d=c.text,f=0,g=0,h=d.length,i,j=Math.min(h,Math.ceil(b/cq("x")));for(;;){var k=e(j);if(k<=b&&ji)return h;j=Math.floor(h*.8),k=e(j),kb-g?f:h;var l=Math.ceil((f+h)/2),m=e(l);m>b?(h=l,i=m):(f=l,g=m)}}function cr(a,b){if(b==0)return 0;J.innerHTML="
"+U[a].getHTML(null,null,!1,b)+"
";return J.firstChild.firstChild.offsetWidth}function cq(a){J.innerHTML="
x
",J.firstChild.firstChild.firstChild.nodeValue=a;return J.firstChild.firstChild.offsetWidth||10}function cp(a){if(typeof a=="number"){var b=a;a=U[a];if(!a)return null}else{var b=D(U,a);if(b==-1)return null}var c=a.gutterMarker;return{line:b,text:a.text,markerText:c&&c.text,markerClass:c&&c.style}}function co(a,b){if(typeof a=="number"){var c=a;a=U[b_(a)]}else{var c=D(U,a);if(c==-1)return null}a.className!=b&&(a.className=b,bb.push({from:c,to:c+1}));return a}function cn(a){typeof a=="number"&&(a=U[b_(a)]),a.gutterMarker=null,bW()}function cm(a,b,c){typeof a=="number"&&(a=U[b_(a)]),a.gutterMarker={text:b,style:c},bW();return a}function cl(a,b,c){function e(a,b,c,e){var a=U[a],f=a.addMark(b,c,e);f.line=a,d.push(f)}a=ca(a),b=ca(b);var d=[];if(a.line==b.line)e(a.line,a.ch,b.ch,c);else{e(a.line,a.ch,null,c);for(var f=a.line+1,g=b.line;f-1&&(a==null&&(a=f),b=f)}a!=null&&bb.push({from:a,to:b+1})}}function ck(){var a=f.gutter||f.lineNumbers;L.style.display=a?"":"none",a?bW():P.parentNode.style.marginLeft=0}function cj(){T=a.getMode(f,f.mode);for(var b=0,c=U.length;b0&&/\w/.test(b.charAt(c-1)))--c;while(d=U.length)return{line:U.length-1,ch:U[U.length-1].text.length};var b=a.ch,c=U[a.line].text.length;return b==null||b>c?{line:a.line,ch:c}:b<0?{line:a.line,ch:0}:a}function b_(a){return Math.max(0,Math.min(a,U.length-1))}function b$(a,b,c){var d=ca({line:a,ch:b||0});(c?bY:bZ)(d,d)}function bZ(a,b,c,d){if(!y(Y.from,a)||!y(Y.to,b)){if(z(b,a)){var e=b;b=a,a=e}var f=y(Y.to,b),g=y(Y.from,a);y(a,b)?Y.inverted=!1:f&&!g?Y.inverted=!0:g&&!f&&(Y.inverted=!1),c==null&&(c=Y.from.line,d=Y.to.line),y(a,b)?y(Y.from,Y.to)||bb.push({from:c,to:d+1}):y(Y.from,Y.to)?bb.push({from:a.line,to:b.line+1}):(y(a,Y.from)||(a.line':"
",g,"
")}L.style.display="none",M.innerHTML=c.join("");var h=String(U.length).length,i=M.firstChild,j=x(i),k="";while(j.length+k.length0;--k)P.removeChild(j?j.previousSibling:P.lastChild);else if(i){for(var k=Math.max(0,i);k>0;--k)P.insertBefore(l.createElement("pre"),j);for(var k=Math.max(0,-i);k>0;--k)P.removeChild(j?j.previousSibling:P.lastChild)}var m=P.childNodes[h.domStart+d],n=b=h.from;for(var k=h.from;kj.from&&f.push({from:j.from,to:e.from,domStart:j.domStart}),e.to=m)break;if(j.domStart>o||j.from>q)n.push({from:q,to:j.from,domSize:j.domStart-o,domStart:o}),r+=j.from-q;q=j.to,o=j.domStart+(j.to-j.from)}if(o!=p||q!=m)r+=Math.abs(m-q),n.push({from:q,to:m,domSize:p-o,domStart:o});if(!n.length)return;P.style.display="none",r>(k.to-k.from)*.3?bU(l=Math.max(k.from-10,0),m=Math.min(k.to+7,U.length)):bV(n),P.style.display="";var s=l!=bf||m!=bg||bh!=H.clientHeight;bf=l,bg=m,K.style.top=l*cv()+"px",s&&(bh=H.clientHeight,I.style.height=U.length*cv()+2*cw()+"px",bW());var t=cq(bl);N.style.width=t>H.clientWidth?t+"px":"";if(P.childNodes.length!=bg-bf)throw new Error("BAD PATCH! "+JSON.stringify(n)+" size="+(bg-bf)+" nodes="+P.childNodes.length);bX()}}function bS(){var a=cv(),b=H.scrollTop-cw();return{from:Math.min(U.length,Math.max(0,Math.floor(b/a))),to:Math.min(U.length,Math.ceil((b+H.clientHeight)/a))}}function bR(a,b,c,d){var e=cx(),g=cw(),h=cv();b+=g,d+=g,a+=e,c+=e;var i=H.clientHeight,j=H.scrollTop,k=!1,l=!0;bj+i&&(H.scrollTop=d+h-i,k=!0);var m=H.clientWidth,n=H.scrollLeft;am+n&&(H.scrollLeft=c+10-m,k=!0,c>I.clientWidth&&(l=!1)),k&&f.onScroll&&f.onScroll(bp);return l}function bQ(){var a=ct(Y.inverted?Y.from:Y.to);return bR(a.x,a.y,a.x,a.yBot)}function bP(){f.readOnly!="nocursor"&&B.focus()}function bO(){var a=[],b=Math.max(0,Y.from.line-1),c=Math.min(U.length,Y.to.line+2);for(var d=b;d=a)return{line:c,ch:a-d};++c,d=e+1}}if(!be){var a=!1,b=B.value,c=F(B);if(!c)return!1;var a=bj.text!=b,d=$,e=a||c.start!=bj.start||c.end!=(d?bj.start:bj.end);if(!e&&!d)return!1;if(a){Z=$=null;if(f.readOnly){ba=!0;return"changed"}}var h=g(c.start,bj.from),i=g(c.end,bj.from);if(d){h=c.start==d.anchor?i:h,i=Z?Y.to:c.start==d.anchor?h:i;if(!z(h,i)){$=null,Y.inverted=!1;var j=h;h=i,i=j}}h.line==i.line&&h.line==Y.from.line&&h.line==Y.to.line&&!Z&&(ba=!1);if(a){var k=0,l=b.length,m=Math.min(l,bj.text.length),n,o=bj.from,p=-1;while(k-1?k-p:k,r=bj.to-1,s=bj.text.length;for(;;){n=bj.text.charAt(s),n=="\n"&&r--;if(b.charAt(l)!=n){++l,++s;break}if(s<=k||l<=k)break;--l,--s}var p=bj.text.lastIndexOf("\n",s-1),t=p==-1?s:s-p-1;bA({line:o,ch:q},{line:r,ch:t},E(b.slice(k,l)),h,i);if(o!=r||h.line!=o)ba=!0}else bZ(h,i);bj.text=b,bj.start=c.start,bj.end=c.end;return a?"changed":e?"moved":!1}}function bM(a){function c(){cH();var d=bN();d=="moved"&&a&&(t[a]=!0),!d&&!b?(b=!0,Q.set(80,c)):(bK=!1,bL()),cI()}var b=!1;bK=!0,Q.set(20,c)}function bL(){bK||Q.set(2e3,function(){cH(),bN(),X&&bL(),cI()})}function bJ(){return bI(Y.from,Y.to)}function bI(a,b){var c=a.line,d=b.line;if(c==d)return U[c].text.slice(a.ch,b.ch);var e=[U[c].text.slice(a.ch)];for(var f=c+1;fh&&(bl=o,h=o.length,f=!1)}if(f){h=0;for(var i=0,n=U.length;ih&&(h=o.length,bl=o)}}var p=[],q=c.length-j-1;for(var i=0,o=V.length;ib.line&&p.push(r+q)}c.length&&p.push(a.line),V=p,cG(100),bb.push({from:a.line,to:b.line+1,diff:q}),bc={from:a,to:b,text:c},bZ(d,e,s(Y.from.line),s(Y.to.line)),I.style.height=U.length*cv()+2*cw()+"px"}function bD(){bB(W.undone,W.done)}function bC(){bB(W.done,W.undone)}function bB(a,b){var c=a.pop();if(c){var d=[],e=c.start+c.added;for(var f=c.start;ff.undoDepth)W.done.shift()}bE(a,b,c,d,e)}function bz(){X&&f.onBlur&&f.onBlur(bp),clearInterval(S),Z=null,X=!1,u.className=u.className.replace(" CodeMirror-focused","")}function by(){f.readOnly!="nocursor"&&(!X&&f.onFocus&&f.onFocus(bp),X=!0,bL(),u.className.search(/\bCodeMirror-focused\b/)==-1&&(u.className+=" CodeMirror-focused"),cA())}function bx(a){if(!f.onKeyEvent||!f.onKeyEvent(bp,k(a.e))){if(f.electricChars&&T.electricChars){var b=String.fromCharCode(a.e.charCode==null?a.e.keyCode:a.e.charCode);T.electricChars.indexOf(b)>-1&&setTimeout(cK(function(){ci(Y.to.line,"smart")}),50)}var c=a.e.keyCode;c==13?(f.readOnly||cg(),a.stop()):!a.e.ctrlKey&&!a.e.altKey&&!a.e.metaKey&&c==9&&f.tabMode!="default"?a.stop():bM(bi)}}function bw(a){if(!f.onKeyEvent||!f.onKeyEvent(bp,k(a.e)))$&&($=null,ba=!0),a.e.keyCode==16&&(Z=null)}function bv(a){X||by();var b=a.e.keyCode,c=(s?a.e.metaKey:a.e.ctrlKey)&&!a.e.altKey,d=a.e.ctrlKey||a.e.altKey||a.e.metaKey;b==16||a.e.shiftKey?Z=Z||(Y.inverted?Y.to:Y.from):Z=null;if(!f.onKeyEvent||!f.onKeyEvent(bp,k(a.e))){if(b==33||b==34){cb(b==34);return a.stop()}if(c&&(b==36||b==35||s&&(b==38||b==40))){cc(b==36||b==38);return a.stop()}if(c&&b==65){cd();return a.stop()}if(!f.readOnly){if(!d&&b==13)return;if(!d&&b==9&&ch(a.e.shiftKey))return a.stop();if(c&&b==90){bC();return a.stop()}if(c&&(a.e.shiftKey&&b==90||b==89)){bD();return a.stop()}}bi=(c?"c":"")+b;if(Y.inverted&&t.hasOwnProperty(bi)){var e=F(B);e&&($={anchor:e.start},G(B,e.start,e.start))}bM(bi)}}function bu(a){var b=cy(a,!0),c=a.e.dataTransfer.files;if(!!b&&!f.readOnly)if(c&&c.length&&window.FileReader&&window.File){var d=c.length,e=Array(d),g=0;for(var h=0;h=c.to||b.line=0&&a
 
',b.appendChild?b.appendChild(u):b(u);var v=u.firstChild,B=v.firstChild,H=u.lastChild,I=H.firstChild,J=I.firstChild,K=J.nextSibling,L=K.firstChild,M=L.firstChild,N=L.nextSibling.firstChild,O=N.firstChild,P=O.nextSibling;f.tabindex!=null&&(B.tabindex=f.tabindex),!f.gutter&&!f.lineNumbers&&(L.style.display="none");var Q=new n,R=new n,S,T,U=[new g("")],V,W=new i,X;cj();var Y={from:{line:0,ch:0},to:{line:0,ch:0},inverted:!1},Z,$,_,ba,bb,bc,bd,be,bf=0,bg=0,bh=0,bi=null,bj,bk,bl="";cK(function(){bq(f.value||""),ba=!1})(),setTimeout(bO,20),m(H,"mousedown",cK(bs)),p||m(H,"contextmenu",cK(cz)),m(I,"dblclick",cK(bt)),m(H,"scroll",function(){bT([]),f.onScroll&&f.onScroll(bp)}),m(window,"resize",function(){bT(!0)}),m(B,"keyup",cK(bw)),m(B,"keydown",cK(bv)),m(B,"keypress",cK(bx)),m(B,"focus",by),m(B,"blur",bz),m(H,"dragenter",function(a){a.stop()}),m(H,"dragover",function(a){a.stop()}),m(H,"drop",cK(bu)),m(H,"paste",function(){bP(),bM()}),m(B,"paste",function(){bM()}),m(B,"cut",function(){bM()});var bm;try{bm=l.activeElement==B}catch(bn){}bm?by():bz();var bp={getValue:br,setValue:cK(bq),getSelection:bJ,replaceSelection:cK(bG),focus:function(){bP(),by(),bM()},setOption:function(a,b){f[a]=b,a=="lineNumbers"||a=="gutter"?ck():a=="mode"||a=="indentUnit"?cj():a=="readOnly"&&b=="nocursor"&&B.blur()},getOption:function(a){return f[a]},undo:cK(bC),redo:cK(bD),indentLine:cK(function(a){bo(a)&&ci(a,"smart")}),historySize:function(){return{undo:W.done.length,redo:W.undone.length}},matchBrackets:cK(function(){cC(!0)}),getTokenAt:function(a){a=ca(a);return U[a.line].getTokenAt(T,cE(a.line),a.ch)},cursorCoords:function(a){a==null&&(a=Y.inverted);return cu(a?Y.from:Y.to)},charCoords:function(a){return cu(ca(a))},coordsChar:function(a){var b=w(N),c=b_(Math.min(U.length-1,bf+Math.floor((a.y-b.top)/cv())));return ca({line:c,ch:cs(b_(c),a.x-b.left)})},getSearchCursor:function(a,b,c){return new cL(a,b,c)},markText:cK(function(a,b,c){return cK(cl(a,b,c))}),setMarker:cm,clearMarker:cn,setLineClass:cK(co),lineInfo:cp,addWidget:function(a,b,c){var a=ct(ca(a),!0);b.style.top=bf*cv()+a.yBot+cw()+"px",b.style.left=a.x+cx()+"px",I.appendChild(b),c&&bR(a.x,a.yBot,a.x+b.offsetWidth,a.yBot+b.offsetHeight)},lineCount:function(){return U.length},getCursor:function(a){a==null&&(a=Y.inverted);return A(a?Y.from:Y.to)},somethingSelected:function(){return!y(Y.from,Y.to)},setCursor:cK(function(a,b){b==null&&typeof a.line=="number"?b$(a.line,a.ch):b$(a,b)}),setSelection:cK(function(a,b){bZ(ca(a),ca(b||a))}),getLine:function(a){if(bo(a))return U[a].text},setLine:cK(function(a,b){bo(a)&&bF(b,{line:a,ch:0},{line:a,ch:U[a].text.length})}),removeLine:cK(function(a){bo(a)&&bF("",{line:a,ch:0},ca({line:a+1,ch:0}))}),replaceRange:cK(bF),getRange:function(a,b){return bI(ca(a),ca(b))},operation:function(a){return cK(a)()},refresh:function(){bT(!0)},getInputField:function(){return B},getWrapperElement:function(){return u}},bK=!1,cB={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},cJ=0;cL.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(a){function d(a){var c={line:a,ch:0};b.pos={from:c,to:c},b.atOccurrence=!1;return!1}var b=this,c=ca(a?this.pos.from:this.pos.to);for(;;){if(this.pos=this.matches(a,c)){this.atOccurrence=!0;return this.pos.match||!0}if(a){if(!c.line)return d(0);c={line:c.line-1,ch:U[c.line-1].text.length}}else{if(c.line==U.length-1)return d(U.length);c={line:c.line+1,ch:0}}}},from:function(){if(this.atOccurrence)return A(this.pos.from)},to:function(){if(this.atOccurrence)return A(this.pos.to)}};return bp}a.defaults={value:"",mode:null,indentUnit:2,indentWithTabs:!1,tabMode:"classic",enterMode:"indent",electricChars:!0,onKeyEvent:null,lineNumbers:!1,gutter:!1,firstLineNumber:1,readOnly:!1,onChange:null,onCursorActivity:null,onGutterClick:null,onHighlightComplete:null,onFocus:null,onBlur:null,onScroll:null,matchBrackets:!1,workTime:100,workDelay:200,undoDepth:40,tabindex:null,document:window.document};var b={},c={};a.defineMode=function(c,d){!a.defaults.mode&&c!="null"&&(a.defaults.mode=c),b[c]=d},a.defineMIME=function(a,b){c[a]=b},a.getMode=function(d,e){typeof e=="string"&&c.hasOwnProperty(e)&&(e=c[e]);if(typeof e=="string")var f=e,g={};else if(e!=null)var f=e.name,g=e;var h=b[f];if(!h){window.console&&console.warn("No mode "+f+" found, falling back to plain text.");return a.getMode(d,"text/plain")}return h(d,g||{})},a.listModes=function(){var a=[];for(var c in b)b.propertyIsEnumerable(c)&&a.push(c);return a},a.listMIMEs=function(){var a=[];for(var b in c)c.propertyIsEnumerable(b)&&a.push(b);return a},a.fromTextArea=function(b,c){function d(){b.value=h.getValue()}c||(c={}),c.value=b.value,!c.tabindex&&b.tabindex&&(c.tabindex=b.tabindex);if(b.form){var e=m(b.form,"submit",d,!0);if(typeof b.form.submit=="function"){var f=b.form.submit;function g(){d(),b.form.submit=f,b.form.submit(),b.form.submit=g}b.form.submit=g}}b.style.display="none";var h=a(function(a){b.parentNode.insertBefore(a,b.nextSibling)},c);h.save=d,h.toTextArea=function(){d(),b.parentNode.removeChild(h.getWrapperElement()),b.style.display="",b.form&&(e(),typeof b.form.submit=="function"&&(b.form.submit=f))};return h},a.startState=e,a.copyState=d,f.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==0},peek:function(){return this.string.charAt(this.pos)},next:function(){if(this.posb},eatSpace:function(){var a=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){var b=this.string.indexOf(a,this.pos);if(b>-1){this.pos=b;return!0}},backUp:function(a){this.pos-=a},column:function(){return v(this.string,this.start)},indentation:function(){return v(this.string)},match:function(a,b,c){if(typeof a!="string"){var e=this.string.slice(this.pos).match(a);e&&b!==!1&&(this.pos+=e[0].length);return e}function d(a){return c?a.toLowerCase():a}if(d(this.string).indexOf(d(a),this.pos)==this.pos){b!==!1&&(this.pos+=a.length);return!0}},current:function(){return this.string.slice(this.start,this.pos)}},a.StringStream=f,g.prototype={replace:function(a,b,c){var d=[],e=this.marked;h(0,a,this.styles,d),c&&d.push(c,null),h(b,this.text.length,this.styles,d),this.styles=d,this.text=this.text.slice(0,a)+c+this.text.slice(b),this.stateAfter=null;if(e){var f=c.length-(b-a),g=this.text.length;function i(a){return a<=Math.min(b,b+f)?a:a+f}for(var j=0;j=g?l=!0:(k.from=i(k.from),k.to!=null&&(k.to=i(k.to)));if(l||k.from>=k.to)e.splice(j,1),j--}}},split:function(a,b){var c=[b,null];h(a,this.text.length,this.styles,c);return new g(b+this.text.slice(a),c)},addMark:function(a,b,c){var d=this.marked,e={from:a,to:b,style:c};this.marked==null&&(this.marked=[]),this.marked.push(e),this.marked.sort(function(a,b){return a.from-b.from});return e},removeMark:function(a){var b=this.marked;if(!!b)for(var c=0;c5e3){d[e++]=this.text.slice(c.pos),d[e++]=null;break}}d.length!=e&&(d.length=e,g=!0),e&&d[e-2]!=i&&(g=!0);return g||d.length<5&&this.text.length<10},getTokenAt:function(a,b,c){var d=this.text,e=new f(d);while(e.pos',B(a),""):e.push(B(a)))}var e=[];c&&e.push(this.className?'
':"
");var g=this.styles,h=this.text,i=this.marked;a==b&&(a=null);var j=h.length;d!=null&&(j=Math.min(d,j));if(!h&&d==null)f(" ",a!=null&&b==null?"CodeMirror-selected":null);else if(!i&&a==null)for(var k=0,l=0;lj&&(m=m.slice(0,j-l)),l+=n,f(m,g[k+1])}else{var o=0,k=0,p="",q,r=0,s=-1,t=null;function u(){i&&(s+=1,t=so)v=a;else if(b==null||b>o)w=" CodeMirror-selected",b!=null&&(v=Math.min(v,b));while(t&&t.to!=null&&t.to<=o)u();t&&(t.from>o?v=Math.min(v,t.from):(w+=" "+t.style,t.to!=null&&(v=Math.min(v,t.to))));for(;;){var x=o+p.length,y=q;w&&(y=q?q+w:w),f(x>v?p.slice(0,v-o):p,y);if(x>=v){p=p.slice(v-o),o=v;break}o=x,p=g[k++],q=g[k++]}}a!=null&&b==null&&f(" ","CodeMirror-selected")}c&&e.push("
");return e.join("")}},i.prototype={addChange:function(a,b,c){this.undone.length=0;var d=+(new Date),e=this.done[this.done.length-1];if(d-this.time>400||!e||e.start>a+b||e.start+e.added=0;--g)e.old.unshift(c[g]);e.added+=e.start-a,e.start=a}else e.start-1&&(q="\r\n")})();var r=8,s=/Mac/.test(navigator.platform),t={};for(var u=35;u<=40;++u)t[u]=t["c"+u]=!0;a.htmlEscape=B;if("\n\nb".split(/\n/).length!=3)var E=function(a){var b=0,c,d=[];while((c=a.indexOf("\n",b))>-1)d.push(a.slice(b,a.charAt(c-1)=="\r"?c-1:c)),b=c+1;d.push(a.slice(b));return d};else var E=function(a){return a.split(/\r?\n/)};a.splitLines=E;if(window.getSelection)var F=function(a){try{return{start:a.selectionStart,end:a.selectionEnd}}catch(b){return null}},G=function(a,b,c){try{a.setSelectionRange(b,c)}catch(d){}};else var F=function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){return null}if(!b||b.parentElement()!=a)return null;var d=a.value,e=d.length,f=a.createTextRange();f.moveToBookmark(b.getBookmark());var g=a.createTextRange();g.collapse(!1);if(f.compareEndPoints("StartToEnd",g)>-1)return{start:e,end:e};var h=-f.moveStart("character",-e);for(var i=d.indexOf("\r");i>-1&&i-1)return{start:h,end:e};var j=-f.moveEnd("character",-e);for(var i=d.indexOf("\r");i>-1&&i-1&&h-1&&h"):b?g.push(''+CodeMirror.htmlEscape(a)+""):g.push(CodeMirror.htmlEscape(a))}}var h=CodeMirror.splitLines(a),i=CodeMirror.startState(d);for(var j=0,k=h.length;j=0;a--)s.cc.push(arguments[a])}function r(a,b,c,e,f){var g=a.cc;s.state=a,s.stream=f,s.marked=null,s.cc=g,a.lexical.hasOwnProperty("align")||(a.lexical.align=!0);for(;;){var h=g.length?g.pop():d?D:C;if(h(c,e)){while(g.length&&g[g.length-1].lex)g.pop()();if(s.marked)return s.marked;if(c=="variable"&&q(a,e))return"js-localvariable";return b}}}function q(a,b){for(var c=a.localVars;c;c=c.next)if(c.name==b)return!0}function p(a,b,c,d,e,f){this.indented=a,this.column=b,this.type=c,this.prev=e,this.info=f,d!=null&&(this.align=d)}function n(a,b){var c=!1,d;while(d=a.next()){if(d=="/"&&c){b.tokenize=l;break}c=d=="*"}return k("comment","js-comment")}function m(a){return function(b,c){h(b,a)||(c.tokenize=l);return k("string","js-string")}}function l(a,b){var c=a.next();if(c=='"'||c=="'")return g(a,b,m(c));if(/[\[\]{}\(\),;\:\.]/.test(c))return k(c);if(c=="0"&&a.eat(/x/i)){a.eatWhile(/[\da-f]/i);return k("number","js-atom")}if(/\d/.test(c)){a.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);return k("number","js-atom")}if(c=="/"){if(a.eat("*"))return g(a,b,n);if(a.eat("/")){a.skipToEnd();return k("comment","js-comment")}if(b.reAllowed){h(a,"/"),a.eatWhile(/[gimy]/);return k("regexp","js-string")}a.eatWhile(f);return k("operator",null,a.current())}if(f.test(c)){a.eatWhile(f);return k("operator",null,a.current())}a.eatWhile(/[\w\$_]/);var d=a.current(),i=e.propertyIsEnumerable(d)&&e[d];return i?k(i.type,i.style,d):k("variable","js-variable",d)}function k(a,b,c){i=a,j=c;return b}function h(a,b){var c=!1,d;while((d=a.next())!=null){if(d==b&&!c)return!1;c=!c&&d=="\\"}return c}function g(a,b,c){b.tokenize=c;return c(a,b)}var c=a.indentUnit,d=b.json,e=function(){function a(a){return{type:a,style:"js-keyword"}}var b=a("keyword a"),c=a("keyword b"),d=a("keyword c"),e=a("operator"),f={type:"atom",style:"js-atom"};return{"if":b,"while":b,"with":b,"else":c,"do":c,"try":c,"finally":c,"return":d,"break":d,"continue":d,"new":d,"delete":d,"throw":d,"var":a("var"),"function":a("function"),"catch":a("catch"),"for":a("for"),"switch":a("switch"),"case":a("case"),"default":a("default"),"in":e,"typeof":e,"instanceof":e,"true":f,"false":f,"null":f,"undefined":f,NaN:f,Infinity:f}}(),f=/[+\-*&%=<>!?|]/,i,j,o={atom:!0,number:!0,variable:!0,string:!0,regexp:!0},s={state:null,column:null,marked:null,cc:null},w={name:"this",next:{name:"arguments"}};A.lex=!0;return{startState:function(a){return{tokenize:l,reAllowed:!0,cc:[],lexical:new p((a||0)-c,0,"block",!1),localVars:null,context:null,indented:0}},token:function(a,b){a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation());if(a.eatSpace())return null;var c=b.tokenize(a,b);if(i=="comment")return c;b.reAllowed=i=="operator"||i=="keyword c"||i.match(/^[\[{}\(,;:]$/);return r(b,c,i,j,a)},indent:function(a,b){if(a.tokenize!=l)return 0;var d=b&&b.charAt(0),e=a.lexical,f=e.type,g=d==f;return f=="vardef"?e.indented+4:f=="form"&&d=="{"?e.indented:f=="stat"||f=="form"?e.indented+c:e.info=="switch"&&!g?e.indented+(/^(?:case|default)\b/.test(b)?c:2*c):e.align?e.column+(g?0:1):e.indented+(g?0:c)},electricChars:":{}"}}),CodeMirror.defineMIME("text/javascript","javascript"),CodeMirror.defineMIME("application/json",{name:"javascript",json:!0}),CodeMirror.defineMode("xml",function(a,b){function v(a){if(a=="xml-word"&&d.allowUnquoted){m="xml-attribute";return o()}if(a=="xml-attribute")return o();return n()}function u(a){if(a=="xml-word"){m="xml-attname";return o(u)}if(a=="equals")return o(v,u);return n()}function t(a){if(a=="endTag")return o();return n()}function s(a){return function(b){if(b=="selfcloseTag"||b=="endTag"&&d.autoSelfClosers.hasOwnProperty(l.tagName.toLowerCase()))return o();if(b=="endTag"){p(l.tagName,a);return o()}return o()}}function r(a){if(a=="openTag"){l.tagName=f;return o(u,s(l.startOfLine))}if(a=="closeTag"){q();return o(t)}if(a=="xml-cdata"){(!l.context||l.context.name!="!cdata")&&p("!cdata"),l.tokenize==h&&q();return o()}return o()}function q(){l.context&&(l.context=l.context.prev)}function p(a,b){var c=d.doNotIndent.hasOwnProperty(a)||l.context&&l.context.noIndent;l.context={prev:l.context,tagName:a,indent:l.indented,startOfLine:b,noIndent:c}}function o(){n.apply(null,arguments);return!0}function n(){for(var a=arguments.length-1;a>=0;a--)l.cc.push(arguments[a])}function k(a,b){return function(c,d){while(!c.eol()){if(c.match(b)){d.tokenize=h;break}c.next()}return a}}function j(a){return function(b,c){while(!b.eol())if(b.next()==a){c.tokenize=i;break}return"xml-attribute"}}function i(a,b){var c=a.next();if(c==">"||c=="/"&&a.eat(">")){b.tokenize=h,g=c==">"?"endTag":"selfcloseTag";return"xml-tag"}if(c=="="){g="equals";return null}if(/[\'\"]/.test(c)){b.tokenize=j(c);return b.tokenize(a,b)}a.eatWhile(/[^\s\u00a0=<>\"\'\/?]/);return"xml-word"}function h(a,b){function c(c){b.tokenize=c;return c(a,b)}var d=a.next();if(d=="<"){if(a.eat("!")){if(a.eat("["))return a.match("CDATA[")?c(k("xml-cdata","]]>")):null;if(a.match("--"))return c(k("xml-comment","-->"));if(a.match("DOCTYPE")){a.eatWhile(/[\w\._\-]/);return c(k("xml-doctype",">"))}return null}if(a.eat("?")){a.eatWhile(/[\w\._\-]/),b.tokenize=k("xml-processing","?>");return"xml-processing"}g=a.eat("/")?"closeTag":"openTag",a.eatSpace(),f="";var e;while(e=a.eat(/[^\s\u00a0=<>\"\'\/?]/))f+=e;b.tokenize=i;return"xml-tag"}if(d=="&"){a.eatWhile(/[^;]/),a.eat(";");return"xml-entity"}a.eatWhile(/[^&<]/);return null}var c=a.indentUnit,d=b.htmlMode?{autoSelfClosers:{br:!0,img:!0,hr:!0,link:!0,input:!0,meta:!0,col:!0,frame:!0,base:!0,area:!0},doNotIndent:{pre:!0,"!cdata":!0},allowUnquoted:!0}:{autoSelfClosers:{},doNotIndent:{"!cdata":!0},allowUnquoted:!1},e=b.alignCDATA,f,g,l,m;return{startState:function(){return{tokenize:h,cc:[],indented:0,startOfLine:!0,tagName:null,context:null}},token:function(a,b){a.sol()&&(b.startOfLine=!0,b.indented=a.indentation());if(a.eatSpace())return null;m=g=f=null;var c=b.tokenize(a,b);if((c||g)&&c!="xml-comment"){l=b;for(;;){var d=b.cc.pop()||r;if(d(g||c))break}}b.startOfLine=!1;return m||c},indent:function(a,b){var d=a.context;if(d&&d.noIndent)return 0;if(e&&/=2&&f==">"){b.tokenize=e;break}c=f=="-"?c+1:0}return d("css-comment","comment")}function f(a,b){var c=!1,f;while((f=a.next())!=null){if(c&&f=="/"){b.tokenize=e;break}c=f=="*"}return d("css-comment","comment")}function e(a,b){var c=a.next();if(c=="@"){a.eatWhile(/\w/);return d("css-at",a.current())}if(c=="/"&&a.eat("*")){b.tokenize=f;return f(a,b)}if(c=="<"&&a.eat("!")){b.tokenize=g;return g(a,b)}if(c=="=")d(null,"compare");else{if(c!="~"&&c!="|"||!a.eat("=")){if(c=='"'||c=="'"){b.tokenize=h(c);return b.tokenize(a,b)}if(c=="#"){a.eatWhile(/\w/);return d("css-selector","hash")}if(c=="!"){a.match(/^\s*\w*/);return d("css-important","important")}if(/\d/.test(c)){a.eatWhile(/[\w.%]/);return d("css-unit","unit")}if(/[,.+>*\/]/.test(c))return d(null,"select-op");if(/[;{}:\[\]]/.test(c))return d(null,c);a.eatWhile(/[\w\\\-_]/);return d("css-identifier","identifier")}return d(null,"compare")}}function d(a,b){c=b;return a}var b=a.indentUnit,c;return{startState:function(a){return{tokenize:e,baseIndent:a||0,stack:[]}},token:function(a,b){if(a.eatSpace())return null;var d=b.tokenize(a,b),e=b.stack[b.stack.length-1];if(c=="hash"&&e=="rule")d="css-colorcode";else if(d=="css-identifier")if(e=="rule")d="css-value";else if(!e||e=="@media{")d="css-selector";e=="rule"&&/^[\{\};]$/.test(c)&&b.stack.pop(),c=="{"?e=="@media"?b.stack[b.stack.length-1]="@media{":b.stack.push("{"):c=="}"?b.stack.pop():c=="@media"?b.stack.push("@media"):e!="rule"&&e!="@media"&&c!="comment"&&b.stack.push("rule");return d},indent:function(a,c){var d=a.stack.length;/^\}/.test(c)&&(d-=a.stack[a.stack.length-1]=="rule"?2:1);return a.baseIndent+d*b},electricChars:"}"}}),CodeMirror.defineMIME("text/css","css"),CodeMirror.defineMode("htmlmixed",function(a,b){function i(a,b){if(a.match(/^<\/\s*style\s*>/i,!1)){b.token=f,b.localState=null;return f(a,b)}return g(a,/<\/\s*style\s*>/,e.token(a,b.localState))}function h(a,b){if(a.match(/^<\/\s*script\s*>/i,!1)){b.token=f,b.curState=null;return f(a,b)}return g(a,/<\/\s*script\s*>/,d.token(a,b.localState))}function g(a,b,c){var d=a.current(),e=d.search(b);e>-1&&a.backUp(d.length-e);return c}function f(a,b){var f=c.token(a,b.htmlState);f=="xml-tag"&&a.current()==">"&&b.htmlState.context&&(/^script$/i.test(b.htmlState.context.tagName)?(b.token=h,b.localState=d.startState(c.indent(b.htmlState,""))):/^style$/i.test(b.htmlState.context.tagName)&&(b.token=i,b.localState=e.startState(c.indent(b.htmlState,""))));return f}var c=CodeMirror.getMode(a,{name:"xml",htmlMode:!0}),d=CodeMirror.getMode(a,"javascript"),e=CodeMirror.getMode(a,"css");return{startState:function(){var a=c.startState();return{token:f,localState:null,htmlState:a}},copyState:function(a){if(a.localState)var b=CodeMirror.copyState(a.token==i?e:d,a.localState);return{token:a.token,localState:b,htmlState:CodeMirror.copyState(c,a.htmlState)}},token:function(a,b){return b.token(a,b)},indent:function(a,b){return a.token==f||/^\s*<\//.test(b)?c.indent(a.htmlState,b):a.token==h?d.indent(a.localState,b):e.indent(a.localState,b)},electricChars:"/{}:"}}),CodeMirror.defineMIME("text/html","htmlmixed")