mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
1 line
No EOL
48 KiB
JavaScript
1 line
No EOL
48 KiB
JavaScript
var CodeMirror=function(){function O(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;c<d;++c)if(a[c]==b)return c;return-1}function N(a,b){if(!b)return a?a.length:0;if(!a)return b.length;for(var c=a.length,d=b.length;c>=0&&d>=0;--c,--d)if(a.charAt(c)!=b.charAt(d))break;return d+1}function M(a){L.innerText=L.textContent=a;return L.innerHTML}function K(a){return{line:a.line,ch:a.ch}}function J(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch}function I(a,b){return a.line==b.line&&a.ch==b.ch}function H(a){return a.textContent||a.innerText||a.nodeValue||""}function G(a,b){var c=a.ownerDocument.body,d=0,e=0,f=!1;for(var g=a;g;g=g.offsetParent)d+=g.offsetLeft,e+=g.offsetTop,b&&F(g).position=="fixed"&&(f=!0);var h=b&&!f?null:c;for(var g=a.parentNode;g!=h;g=g.parentNode)g.scrollLeft!=null&&(d-=g.scrollLeft,e-=g.scrollTop);return{left:d,top:e}}function F(a){if(a.currentStyle)return a.currentStyle;return window.getComputedStyle(a,null)}function E(a,b){b==null&&(b=a.search(/[^\s\u00a0]/),b==-1&&(b=a.length));for(var c=0,d=0;c<b;++c)a.charAt(c)=="\t"?d+=A-d%A:++d;return d}function u(){this.id=null}function t(a,b,c,d){function e(a){c(a||window.event)}if(typeof a.addEventListener=="function"){a.addEventListener(b,e,!1);if(d)return function(){a.removeEventListener(b,e,!1)}}else{a.attachEvent("on"+b,e);if(d)return function(){a.detachEvent("on"+b,e)}}}function s(a){if(a.pageY!=null)return a.pageY;var b=p(a).ownerDocument;return a.clientY+b.body.scrollTop+b.documentElement.scrollTop}function r(a){if(a.pageX!=null)return a.pageX;var b=p(a).ownerDocument;return a.clientX+b.body.scrollLeft+b.documentElement.scrollLeft}function q(a){if(a.which)return a.which;if(a.button&1)return 1;if(a.button&2)return 3;if(a.button&4)return 2}function p(a){return a.target||a.srcElement}function o(a){m(a),n(a)}function n(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}function m(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function l(a){a.stop||(a.stop=k);return a}function k(){o(this)}function j(){this.time=0,this.done=[],this.undone=[]}function i(a,b,c,d){for(var e=0,f=0,g=0;f<b;e+=2){var h=c[e],i=f+h.length;g==0?(i>a&&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 h(a,b){this.styles=b||[a,null],this.stateAfter=null,this.text=a,this.marked=this.gutterMarker=this.className=null}function g(a){this.pos=this.start=0,this.string=a}function f(a,b,c){return a.startState?a.startState(b,c):!0}function e(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 cV(a,b,c){this.atOccurrence=!1,c==null&&(c=typeof a=="string"&&a==a.toLowerCase()),b&&typeof b=="object"?b=cj(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=ba[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=ba[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(ba[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(ba[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==ba.length-1)return;h=d(ba[c+=a?-1:1].text),g=e[a?--f:++f];if(f>0&&f<e.length-1){if(h!=g)return;continue}var j=a?h.lastIndexOf(g):h.indexOf(g)+g.length;if(a?j!=h.length-g.length:j!=g.length)return;var k={line:b.line,ch:i},l={line:c,ch:j};return{from:a?l:k,to:a?k:l}}}}}function cU(a){return function(){cT++||cR();try{var b=a.apply(this,arguments)}finally{--cT||cS()}return b}}function cS(){var a=!1;bl&&(a=!bZ()),bj.length?ca(bj):bl&&ce(),a&&bZ(),bl&&cJ(),bd&&!bm&&(bi===!0||bi!==!1&&bl)&&bX(),bl&&g.matchBrackets&&setTimeout(cU(function(){bs&&(bs(),bs=null),cL(!1)}),20);var b=bk;bl&&g.onCursorActivity&&g.onCursorActivity(by),b&&g.onChange&&by&&g.onChange(by,b)}function cR(){bi=null,bj=[],bk=bl=!1}function cQ(a){!bb.length||Z.set(a,cU(cP))}function cP(){var a=+(new Date)+g.workTime,b=bb.length;while(bb.length){if(!ba[bn].stateAfter)var c=bn;else var c=bb.pop();if(c>=ba.length)continue;var d=cM(c),h=d&&ba[d-1].stateAfter;h?h=e(_,h):h=f(_);var i=0,j=_.compareStates;for(var k=d,l=ba.length;k<l;++k){var m=ba[k],n=m.stateAfter;if(+(new Date)>a){bb.push(k),cQ(g.workDelay),bj.push({from:c,to:k+1});return}var o=m.highlight(_,h);m.stateAfter=e(_,h);if(j){if(n&&j(n,h))break}else if(o||!n)i=0;else if(++i>3)break}bj.push({from:c,to:k+1})}b&&g.onHighlightComplete&&g.onHighlightComplete(by)}function cO(a,b){var c=cN(a);for(var d=a;d<b;++d){var f=ba[d];f.highlight(_,c),f.stateAfter=e(_,c)}}function cN(a){var b=cM(a),c=b&&ba[b-1].stateAfter;c?c=e(_,c):c=f(_);for(var d=b;d<a;++d){var g=ba[d];g.highlight(_,c),g.stateAfter=e(_,c)}a<ba.length&&!ba[a].stateAfter&&bb.push(a);return c}function cM(a){var b,c;for(var d=a,e=a-40;d>e;--d){if(d==0)return 0;var f=ba[d-1];if(f.stateAfter)return d;var g=f.indentation();if(c==null||b>g)c=d,b=g}return c}function cL(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<c&&o.test(f=k.charAt(l))){var q=cK[f];if(q.charAt(1)==">"==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=be.inverted?be.from:be.to,c=ba[b.line],d=b.ch-1,e=d>=0&&cK[c.text.charAt(d)]||cK[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;k<l;k+=2)if((j-=i[k].length)<=0){var m=i[k+1];break}var n=[c.text.charAt(d)],o=/[(){}[\]]/;for(var k=b.line,l=g?Math.min(k+100,ba.length):Math.max(-1,k-100);k!=l;k+=h){var c=ba[k],q=k==b.line,r=p(c,q&&g?d+1:0,q&&!g?d:c.text.length);if(r)break}r||(r={pos:null,match:!1});var m=r.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket",s=cu({line:b.line,ch:d},{line:b.line,ch:d+1},m),t=r.pos!=null?cu({line:k,ch:r.pos},{line:k,ch:r.pos+1},m):function(){},u=cU(function(){s(),t()});a?setTimeout(u,800):bs=u}}function cJ(){clearInterval($);var a=!0;W.style.visibility="",$=setInterval(function(){W.style.visibility=(a=!a)?"":"hidden"},650)}function cI(a){function e(){var a=P(E.value).join("\n");a!=d&&cU(bP)(a,"end"),D.style.position="relative",E.style.cssText=c,bm=!1,bX(),bU()}var b=cH(a);if(!!b&&!window.opera){(I(be.from,be.to)||J(b,be.from)||!J(b,be.to))&&cU(ch)(b.line,b.ch);var c=E.style.cssText;D.style.position="absolute",E.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(s(a)-1)+"px; left: "+(r(a)-1)+"px; z-index: 1000; background: white; "+"border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",bm=!0;var d=E.value=bS();bY(),R(E,0,E.value.length);if(w){o(a);var f=t(window,"mouseup",function(){f(),setTimeout(e,20)},!0)}else setTimeout(e,50)}}function cH(a,b){var c=G(F,!0),d,e;try{d=a.clientX,e=a.clientY}catch(a){return null}if(!b&&(d-c.left>F.clientWidth||e-c.top>F.clientHeight))return null;var f=G(V,!0),g=bn+Math.floor((e-f.top)/cE());return cj({line:g,ch:cB(ci(g),d-f.left)})}function cG(){return V.offsetLeft}function cF(){return V.offsetTop}function cE(){var a=X.childNodes.length;if(a)return X.offsetHeight/a||1;M.innerHTML="<pre>x</pre>";return M.firstChild.offsetHeight||1}function cD(a){var b=cC(a,!0),c=G(V);return{x:c.left+b.x,y:c.top+b.y,yBot:c.top+b.yBot}}function cC(a,b){var c=cE(),d=a.line-(b?bn:0);return{x:cA(a.line,a.ch),y:d*c,yBot:(d+1)*c}}function cB(a,b){function e(a){M.innerHTML="<pre><span>"+c.getHTML(null,null,!1,a)+"</span></pre>";return M.firstChild.firstChild.offsetWidth}if(b<=0)return 0;var c=ba[a],d=c.text,f=0,g=0,h=d.length,i,j=Math.min(h,Math.ceil(b/cz("x")));for(;;){var k=e(j);if(k<=b&&j<h)j=Math.min(h,Math.ceil(j*1.2));else{i=k,h=j;break}}if(b>i)return h;j=Math.floor(h*.8),k=e(j),k<b&&(f=j,g=k);for(;;){if(h-f<=1)return i-b>b-g?f:h;var l=Math.ceil((f+h)/2),m=e(l);m>b?(h=l,i=m):(f=l,g=m)}}function cA(a,b){if(b==0)return 0;M.innerHTML="<pre><span>"+ba[a].getHTML(null,null,!1,b)+"</span></pre>";return M.firstChild.firstChild.offsetWidth}function cz(a){M.innerHTML="<pre><span>x</span></pre>",M.firstChild.firstChild.firstChild.nodeValue=a;return M.firstChild.firstChild.offsetWidth||10}function cy(a){if(typeof a=="number"){var b=a;a=ba[a];if(!a)return null}else{var b=O(ba,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 cx(a,b){if(typeof a=="number"){var c=a;a=ba[ci(a)]}else{var c=O(ba,a);if(c==-1)return null}a.className!=b&&(a.className=b,bj.push({from:c,to:c+1}));return a}function cw(a){typeof a=="number"&&(a=ba[ci(a)]),a.gutterMarker=null,cd()}function cv(a,b,c){typeof a=="number"&&(a=ba[ci(a)]),a.gutterMarker={text:b,style:c},cd();return a}function cu(a,b,c){function e(a,b,c,e){var a=ba[a],f=a.addMark(b,c,e);f.line=a,d.push(f)}a=cj(a),b=cj(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<g;++f)e(f,0,null,c);e(b.line,0,b.ch,c)}bj.push({from:a.line,to:b.line+1});return function(){var a,b;for(var c=0;c<d.length;++c){var e=d[c],f=O(ba,e.line);e.line.removeMark(e),f>-1&&(a==null&&(a=f),b=f)}a!=null&&bj.push({from:a,to:b+1})}}function ct(){var a=g.gutter||g.lineNumbers;T.style.display=a?"":"none",a?cd():X.parentNode.style.marginLeft=0}function cs(){_=a.getMode(g,g.mode);for(var b=0,c=ba.length;b<c;++b)ba[b].stateAfter=null;bb=[0],cQ()}function cr(a,b){if(b=="smart")if(!_.indent)b="prev";else var c=cN(a);var d=ba[a],e=d.indentation(),f=d.text.match(/^\s*/)[0],h;b=="prev"?a?h=ba[a-1].indentation():h=0:b=="smart"?h=_.indent(c,d.text.slice(f.length)):b=="add"?h=e+g.indentUnit:b=="subtract"&&(h=e-g.indentUnit),h=Math.max(0,h);var i=h-e;if(!i){if(be.from.line!=a&&be.to.line!=a)return;var j=f}else{var j="",k=0;if(g.indentWithTabs)for(var l=Math.floor(h/A);l;--l)k+=A,j+="\t";while(k<h)++k,j+=" "}bO(j,{line:a,ch:0},{line:a,ch:f.length})}function cq(a){function b(a){if(I(be.from,be.to))return cr(be.from.line,a);var b=be.to.line-(be.to.ch?0:1);for(var c=be.from.line;c<=b;++c)cr(c,a)}bf=null;switch(g.tabMode){case"default":return!1;case"indent":b("smart");break;case"classic":if(I(be.from,be.to)){a?cr(be.from.line,"smart"):bP("\t","end");break};case"shift":b(a?"subtract":"add")}return!0}function cp(){bP("\n","end"),g.enterMode!="flat"&&cr(be.from.line,g.enterMode=="keep"?"prev":"smart")}function co(a){cf({line:a,ch:0},{line:a,ch:ba[a].text.length})}function cn(a){var b=ba[a.line].text,c=a.ch,d=a.ch;while(c>0&&/\w/.test(b.charAt(c-1)))--c;while(d<b.length&&/\w/.test(b.charAt(d)))++d;cf({line:a.line,ch:c},{line:a.line,ch:d})}function cm(){var a=ba.length-1;cg({line:0,ch:0},{line:a,ch:ba[a].text.length})}function cl(a){var b=a?{line:0,ch:0}:{line:ba.length-1,ch:ba[ba.length-1].text.length};cf(b,b)}function ck(a){var b=Math.floor(F.clientHeight/cE()),c=be.inverted?be.from:be.to;ch(c.line+Math.max(b-1,1)*(a?1:-1),c.ch,!0)}function cj(a){if(a.line<0)return{line:0,ch:0};if(a.line>=ba.length)return{line:ba.length-1,ch:ba[ba.length-1].text.length};var b=a.ch,c=ba[a.line].text.length;return b==null||b>c?{line:a.line,ch:c}:b<0?{line:a.line,ch:0}:a}function ci(a){return Math.max(0,Math.min(a,ba.length-1))}function ch(a,b,c){var d=cj({line:a,ch:b||0});(c?cf:cg)(d,d)}function cg(a,b,c,d){if(!I(be.from,a)||!I(be.to,b)){if(J(b,a)){var e=b;b=a,a=e}I(a,b)?be.inverted=!1:I(a,be.to)?be.inverted=!1:I(b,be.from)&&(be.inverted=!0),c==null&&(c=be.from.line,d=be.to.line),I(a,b)?I(be.from,be.to)||bj.push({from:c,to:d+1}):I(be.from,be.to)?bj.push({from:a.line,to:b.line+1}):(I(a,be.from)||(a.line<c?bj.push({from:a.line,to:Math.min(b.line,c)+1}):bj.push({from:c,to:Math.min(d,a.line)+1})),I(b,be.to)||(b.line<d?bj.push({from:Math.max(c,a.line),to:d+1}):bj.push({from:Math.max(a.line,d),to:b.line+1}))),be.from=a,be.to=b,bl=!0}}function cf(a,b){var c=bf&&cj(bf);c&&(J(c,a)?a=c:J(b,c)&&(b=c)),cg(a,b)}function ce(){var a=be.inverted?be.from:be.to,b=cE(),c=cA(a.line,a.ch)+"px",d=(a.line-bn)*b+"px";D.style.top=a.line*b-F.scrollTop+"px",I(be.from,be.to)?(W.style.top=d,W.style.left=c,W.style.display=""):W.style.display="none"}function cd(){if(!!g.gutter||!!g.lineNumbers){var a=S.offsetHeight,b=F.clientHeight;T.style.height=(a-b<2?b:a)+"px";var c=[];for(var d=bn;d<Math.max(bo,bn+1);++d){var e=ba[d].gutterMarker,f=g.lineNumbers?d+g.firstLineNumber:null;e&&e.text?f=e.text.replace("%N%",f!=null?f:""):f==null&&(f="\u00a0"),c.push(e&&e.style?'<pre class="'+e.style+'">':"<pre>",f,"</pre>")}T.style.display="none",U.innerHTML=c.join("");var h=String(ba.length).length,i=U.firstChild,j=H(i),k="";while(j.length+k.length<h)k+="\u00a0";k&&i.insertBefore(n.createTextNode(k),i.firstChild),T.style.display="",V.style.marginLeft=T.offsetWidth+"px"}}function cc(a){var b=be.from.line,c=be.to.line,d=0,e=v&&n.createElement("div");for(var f=0,g=a.length;f<g;++f){var h=a[f],i=h.to-h.from-h.domSize,j=X.childNodes[h.domStart+h.domSize+d]||null;if(v)for(var k=Math.max(-i,h.domSize);k>0;--k)X.removeChild(j?j.previousSibling:X.lastChild);else if(i){for(var k=Math.max(0,i);k>0;--k)X.insertBefore(n.createElement("pre"),j);for(var k=Math.max(0,-i);k>0;--k)X.removeChild(j?j.previousSibling:X.lastChild)}var l=X.childNodes[h.domStart+d],m=b<h.from&&c>=h.from;for(var k=h.from;k<h.to;++k){var o=null,p=null;m?(o=0,c==k&&(m=!1,p=be.to.ch)):b==k&&(c==k?(o=be.from.ch,p=be.to.ch):(m=!0,o=be.from.ch)),v?(e.innerHTML=ba[k].getHTML(o,p,!0),X.insertBefore(e.firstChild,j)):(l.innerHTML=ba[k].getHTML(o,p,!1),l.className=ba[k].className||"",l=l.nextSibling)}d+=i}}function cb(a,b){var c=[],d={line:a,ch:0},e=J(be.from,d)&&!J(be.to,d);for(var f=a;f<b;++f){var g=null,h=null;e?(g=0,be.to.line==f&&(e=!1,h=be.to.ch)):be.from.line==f&&(be.to.line==f?(g=be.from.ch,h=be.to.ch):(e=!0,g=be.from.ch)),c.push(ba[f].getHTML(g,h,!0))}X.innerHTML=c.join("")}function ca(a){if(!F.clientWidth)bn=bo=0;else{var b=a===!0?[]:[{from:bn,to:bo,domStart:0}];for(var c=0,d=a.length||0;c<d;++c){var e=a[c],f=[],g=e.diff||0;for(var h=0,i=b.length;h<i;++h){var j=b[h];e.to<=j.from?f.push({from:j.from+g,to:j.to+g,domStart:j.domStart}):j.to<=e.from?f.push(j):(e.from>j.from&&f.push({from:j.from,to:e.from,domStart:j.domStart}),e.to<j.to&&f.push({from:e.to+g,to:j.to+g,domStart:j.domStart+(e.to-j.from)}))}b=f}var k=b_(),l=Math.min(bn,Math.max(k.from-3,0)),m=Math.min(ba.length,Math.max(bo,k.to+3)),n=[],o=0,p=bo-bn,q=l,r=0;for(var c=0,d=b.length;c<d;++c){var j=b[c];if(j.to<=l)continue;if(j.from>=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;X.style.display="none",r>(k.to-k.from)*.3?cb(l=Math.max(k.from-10,0),m=Math.min(k.to+7,ba.length)):cc(n),X.style.display="";var s=l!=bn||m!=bo||bp!=F.clientHeight;bn=l,bo=m,S.style.top=l*cE()+"px",s&&(bp=F.clientHeight,L.style.height=ba.length*cE()+2*cF()+"px",cd()),bu==null&&(bu=cz(bt)),bu>F.clientWidth?(V.style.width=bu+"px",L.style.width="",L.style.width=F.scrollWidth+"px"):V.style.width=L.style.width="";if(X.childNodes.length!=bo-bn)throw new Error("BAD PATCH! "+JSON.stringify(n)+" size="+(bo-bn)+" nodes="+X.childNodes.length);ce()}}function b_(){var a=cE(),b=F.scrollTop-cF();return{from:Math.min(ba.length,Math.max(0,Math.floor(b/a))),to:Math.min(ba.length,Math.ceil((b+F.clientHeight)/a))}}function b$(a,b,c,d){var e=cG(),f=cF(),h=cE();b+=f,d+=f,a+=e,c+=e;var i=F.clientHeight,j=F.scrollTop,k=!1,l=!0;b<j?(F.scrollTop=Math.max(0,b-2*h),k=!0):d>j+i&&(F.scrollTop=d+h-i,k=!0);var m=F.clientWidth,n=F.scrollLeft;a<n?(a<50&&(a=0),F.scrollLeft=Math.max(0,a-10),k=!0):c>m+n&&(F.scrollLeft=c+10-m,k=!0,c>L.clientWidth&&(l=!1)),k&&g.onScroll&&g.onScroll(by);return l}function bZ(){var a=cC(be.inverted?be.from:be.to);return b$(a.x,a.y,a.x,a.yBot)}function bY(){g.readOnly!="nocursor"&&E.focus()}function bX(){var a=[],b=Math.max(0,be.from.line-1),c=Math.min(ba.length,be.to.line+2);for(var d=b;d<c;++d)a.push(ba[d].text);a=E.value=a.join(z);var e=be.from.ch,f=be.to.ch;for(var d=b;d<be.from.line;++d)e+=z.length+ba[d].text.length;for(var d=b;d<be.to.line;++d)f+=z.length+ba[d].text.length;br={text:a,from:b,to:c,start:e,end:f},R(E,e,bg?e:f)}function bW(){function f(a,c){var d=0;for(;;){var e=b.indexOf("\n",d);if(e==-1||(b.charAt(e-1)=="\r"?e-1:e)>=a)return{line:c,ch:a-d};++c,d=e+1}}if(!bm&&!!bd){var a=!1,b=E.value,c=Q(E);if(!c)return!1;var a=br.text!=b,d=bg,e=a||c.start!=br.start||c.end!=(d?br.start:br.end);if(!e&&!d)return!1;if(a){bf=bg=null;if(g.readOnly){bi=!0;return"changed"}}var h=f(c.start,br.from),i=f(c.end,br.from);if(d){var j=c.start==d.anchor?i:h,k=bf?be.to:c.start==d.anchor?h:i;(be.inverted=J(j,k))?(h=j,i=k):(bg=null,h=k,i=j)}h.line==i.line&&h.line==be.from.line&&h.line==be.to.line&&!bf&&(bi=!1);if(a){var l=0,m=b.length,n=Math.min(m,br.text.length),o,p=br.from,q=-1;while(l<n&&(o=b.charAt(l))==br.text.charAt(l))++l,o=="\n"&&(p++,q=l);var r=q>-1?l-q:l,s=br.to-1,t=br.text.length;for(;;){o=br.text.charAt(t);if(b.charAt(m)!=o){++m,++t;break}o=="\n"&&s--;if(t<=l||m<=l)break;--m,--t}var q=br.text.lastIndexOf("\n",t-1),u=q==-1?t:t-q-1;bJ({line:p,ch:r},{line:s,ch:u},P(b.slice(l,m)),h,i);if(p!=s||h.line!=p)bi=!0}else cg(h,i);br.text=b,br.start=c.start,br.end=c.end;return a?"changed":e?"moved":!1}}function bV(a){function c(){cR();var d=bW();d=="moved"&&a&&(C[a]=!0),!d&&!b?(b=!0,Y.set(80,c)):(bT=!1,bU()),cS()}var b=!1;bT=!0,Y.set(20,c)}function bU(){bT||Y.set(2e3,function(){cR(),bW(),bd&&bU(),cS()})}function bS(){return bR(be.from,be.to)}function bR(a,b){var c=a.line,d=b.line;if(c==d)return ba[c].text.slice(a.ch,b.ch);var e=[ba[c].text.slice(a.ch)];for(var f=c+1;f<d;++f)e.push(ba[f].text);e.push(ba[d].text.slice(0,b.ch));return e.join("\n")}function bQ(a,b,c,d){var e=a.length==1?a[0].length+b.ch:a[a.length-1].length,f=d({line:b.line+a.length-1,ch:e});bJ(b,c,a,f.from,f.to)}function bP(a,b){bQ(P(a),be.from,be.to,function(a){return b=="end"?{from:a,to:a}:b=="start"?{from:be.from,to:be.from}:{from:be.from,to:a}})}function bO(a,b,c){function d(d){if(J(d,b))return d;if(!J(c,d))return e;var f=d.line+a.length-(c.line-b.line)-1,g=d.ch;d.line==c.line&&(g+=a[a.length-1].length-(c.ch-(c.line==b.line?b.ch:0)));return{line:f,ch:g}}b=cj(b),c?c=cj(c):c=b,a=P(a);var e;bQ(a,b,c,function(a){e=a;return{from:d(be.from),to:d(be.to)}});return e}function bN(a,b,c,d,e){function s(a){return a<=Math.min(b.line,b.line+q)?a:a+q}var f=!1,g=bt.length;for(var i=a.line;i<=b.line;++i)if(ba[i].text.length==g){f=!0;break}var j=b.line-a.line,k=ba[a.line],l=ba[b.line];if(k==l)if(c.length==1)k.replace(a.ch,b.ch,c[0]);else{l=k.split(b.ch,c[c.length-1]);var m=[a.line+1,j];k.replace(a.ch,k.text.length,c[0]);for(var i=1,n=c.length-1;i<n;++i)m.push(new h(c[i]));m.push(l),ba.splice.apply(ba,m)}else if(c.length==1)k.replace(a.ch,k.text.length,c[0]+l.text.slice(b.ch)),ba.splice(a.line+1,j);else{var m=[a.line+1,j-1];k.replace(a.ch,k.text.length,c[0]),l.replace(0,b.ch,c[c.length-1]);for(var i=1,n=c.length-1;i<n;++i)m.push(new h(c[i]));ba.splice.apply(ba,m)}for(var i=a.line,n=i+c.length;i<n;++i){var o=ba[i].text;o.length>g&&(bt=o,g=o.length,bu=null,f=!1)}if(f){g=0,bt="",bu=null;for(var i=0,n=ba.length;i<n;++i){var o=ba[i].text;o.length>g&&(g=o.length,bt=o)}}var p=[],q=c.length-j-1;for(var i=0,o=bb.length;i<o;++i){var r=bb[i];r<a.line?p.push(r):r>b.line&&p.push(r+q)}c.length<5?(cO(a.line,a.line+c.length),p.push(a.line+c.length)):p.push(a.line),bb=p,cQ(100),bj.push({from:a.line,to:b.line+1,diff:q}),bk={from:a,to:b,text:c},cg(d,e,s(be.from.line),s(be.to.line)),L.style.height=ba.length*cE()+2*cF()+"px"}function bM(){bK(bc.undone,bc.done)}function bL(){bK(bc.done,bc.undone)}function bK(a,b){var c=a.pop();if(c){var d=[],e=c.start+c.added;for(var f=c.start;f<e;++f)d.push(ba[f].text);b.push({start:c.start,added:c.old.length,old:d});var g=cj({line:c.start+c.old.length-1,ch:N(d[d.length-1],c.old[c.old.length-1])});bN({line:c.start,ch:0},{line:e-1,ch:ba[e-1].text.length},c.old,g,g),bi=!0}}function bJ(a,b,c,d,e){if(bc){var f=[];for(var h=a.line,i=b.line+1;h<i;++h)f.push(ba[h].text);bc.addChange(a.line,c.length,f);while(bc.done.length>g.undoDepth)bc.done.shift()}bN(a,b,c,d,e)}function bI(){bd&&(g.onBlur&&g.onBlur(by),bd=!1,y.className=y.className.replace(" CodeMirror-focused","")),clearInterval($),setTimeout(function(){bd||(bf=null)},150)}function bH(){g.readOnly!="nocursor"&&(bd||(g.onFocus&&g.onFocus(by),bd=!0,y.className.search(/\bCodeMirror-focused\b/)==-1&&(y.className+=" CodeMirror-focused"),bm||bX()),bU(),cJ())}function bG(a){if(!g.onKeyEvent||!g.onKeyEvent(by,l(a))){if(g.electricChars&&_.electricChars){var b=String.fromCharCode(a.charCode==null?a.keyCode:a.charCode);_.electricChars.indexOf(b)>-1&&setTimeout(cU(function(){cr(be.to.line,"smart")}),50)}var c=a.keyCode;c==13?(g.readOnly||cp(),m(a)):!a.ctrlKey&&!a.altKey&&!a.metaKey&&c==9&&g.tabMode!="default"?m(a):bV(bq)}}function bF(a){if(!g.onKeyEvent||!g.onKeyEvent(by,l(a)))bg&&(bg=null,bi=!0),a.keyCode==16&&(bf=null)}function bE(a){bd||bH();var b=a.keyCode;x&&b==27&&(a.returnValue=!1);var c=(B?a.metaKey:a.ctrlKey)&&!a.altKey,d=a.ctrlKey||a.altKey||a.metaKey;b==16||a.shiftKey?bf=bf||(be.inverted?be.to:be.from):bf=null;if(!g.onKeyEvent||!g.onKeyEvent(by,l(a))){if(b==33||b==34){ck(b==34);return m(a)}if(c&&(b==36||b==35||B&&(b==38||b==40))){cl(b==36||b==38);return m(a)}if(c&&b==65){cm();return m(a)}if(!g.readOnly){if(!d&&b==13)return;if(!d&&b==9&&cq(a.shiftKey))return m(a);if(c&&b==90){bL();return m(a)}if(c&&(a.shiftKey&&b==90||b==89)){bM();return m(a)}}bq=(c?"c":"")+b;if(be.inverted&&C.hasOwnProperty(bq)){var e=Q(E);e&&(bg={anchor:e.start},R(E,e.start,e.start))}bV(bq)}}function bD(a){a.preventDefault();var b=cH(a,!0),c=a.dataTransfer.files;if(!!b&&!g.readOnly)if(c&&c.length&&window.FileReader&&window.File){function d(a,c){var d=new FileReader;d.onload=function(){f[c]=d.result,++h==e&&bO(f.join(""),cj(b),cj(b))},d.readAsText(a)}var e=c.length,f=Array(e),h=0;for(var i=0;i<e;++i)d(c[i],i)}else try{var f=a.dataTransfer.getData("Text");f&&bO(f,b,b)}catch(a){}}function bC(a){var b=cH(a);!b||(cn(b),m(a),bh=+(new Date))}function bB(a){function i(a){var b=cH(a,!0);if(b&&!I(b,e)){bd||bH(),e=b,cf(d,b),bi=!1;var c=b_();if(b.line>=c.to||b.line<c.from)f=setTimeout(cU(function(){i(a)}),150)}}function h(){bY(),bi=!0,j(),k()}for(var b=p(a);b!=y;b=b.parentNode)if(b.parentNode==L&&b!=S)return;var c=bh;bh=null;for(var b=p(a);b!=y;b=b.parentNode)if(b.parentNode==U){g.onGutterClick&&g.onGutterClick(by,O(U.childNodes,b)+bn);return m(a)}var d=cH(a);switch(q(a)){case 3:w&&!B&&cI(a);return;case 2:d&&ch(d.line,d.ch,!0);return}if(!d)p(a)==F&&m(a);else{bd||bH(),m(a);if(c&&+(new Date)-c<400)return co(d.line);ch(d.line,d.ch,!0);var e=d,f,j=t(n,"mousemove",cU(function(a){clearTimeout(f),m(a),i(a)}),!0),k=t(n,"mouseup",cU(function(a){clearTimeout(f);var b=cH(a);b&&cf(d,b),m(a),h()}),!0)}}function bA(a){var b=[];for(var c=0,d=ba.length;c<d;++c)b.push(ba[c].text);return b.join("\n")}function bz(a){bc=null;var b={line:0,ch:0};bJ(b,{line:ba.length-1,ch:ba[ba.length-1].text.length},P(a),b,b),bc=new j}function bx(a){return a>=0&&a<ba.length}var g={},i=a.defaults;for(var k in i)i.hasOwnProperty(k)&&(g[k]=(c&&c.hasOwnProperty(k)?c:i)[k]);var n=g.document,y=n.createElement("div");y.className="CodeMirror",y.innerHTML='<div style="overflow: hidden; position: relative; width: 1px; height: 0px;"><textarea style="position: absolute; width: 2px;" wrap="off"></textarea></div><div class="CodeMirror-scroll cm-s-'+g.theme+'">'+'<div style="position: relative">'+'<div style="position: absolute; height: 0; width: 0; overflow: hidden;"></div>'+'<div style="position: relative">'+'<div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div>'+'<div class="CodeMirror-lines"><div style="position: relative">'+'<pre class="CodeMirror-cursor"> </pre>'+"<div></div>"+"</div></div></div></div></div>",b.appendChild?b.appendChild(y):b(y);var D=y.firstChild,E=D.firstChild,F=y.lastChild,L=F.firstChild,M=L.firstChild,S=M.nextSibling,T=S.firstChild,U=T.firstChild,V=T.nextSibling.firstChild,W=V.firstChild,X=W.nextSibling;g.tabindex!=null&&(E.tabindex=g.tabindex),!g.gutter&&!g.lineNumbers&&(T.style.display="none");var Y=new u,Z=new u,$,_,ba=[new h("")],bb,bc=new j,bd;cs();var be={from:{line:0,ch:0},to:{line:0,ch:0},inverted:!1},bf,bg,bh,bi,bj,bk,bl,bm,bn=0,bo=0,bp=0,bq=null,br,bs,bt="",bu;cU(function(){bz(g.value||""),bi=!1})(),t(F,"mousedown",cU(bB)),w||t(F,"contextmenu",cI),t(L,"dblclick",cU(bC)),t(F,"scroll",function(){ca([]),g.onScroll&&g.onScroll(by)}),t(window,"resize",function(){ca(!0)}),t(E,"keyup",cU(bF)),t(E,"keydown",cU(bE)),t(E,"keypress",cU(bG)),t(E,"focus",bH),t(E,"blur",bI),t(F,"dragenter",o),t(F,"dragover",o),t(F,"drop",cU(bD)),t(F,"paste",function(){bY(),bV()}),t(E,"paste",function(){bV()}),t(E,"cut",function(){bV()});var bv;try{bv=n.activeElement==E}catch(bw){}bv?setTimeout(bH,20):bI();var by={getValue:bA,setValue:cU(bz),getSelection:bS,replaceSelection:cU(bP),focus:function(){bY(),bH(),bV()},setOption:function(a,b){g[a]=b,a=="lineNumbers"||a=="gutter"?ct():a=="mode"||a=="indentUnit"?cs():a=="readOnly"&&b=="nocursor"?E.blur():a=="theme"&&(F.className=F.className.replace(/cm-s-\w+/,"cm-s-"+b))},getOption:function(a){return g[a]},undo:cU(bL),redo:cU(bM),indentLine:cU(function(a,b){bx(a)&&cr(a,b==null?"smart":b?"add":"subtract")}),historySize:function(){return{undo:bc.done.length,redo:bc.undone.length}},matchBrackets:cU(function(){cL(!0)}),getTokenAt:function(a){a=cj(a);return ba[a.line].getTokenAt(_,cN(a.line),a.ch)},getStateAfter:function(a){a=ci(a==null?ba.length-1:a);return cN(a+1)},cursorCoords:function(a){a==null&&(a=be.inverted);return cD(a?be.from:be.to)},charCoords:function(a){return cD(cj(a))},coordsChar:function(a){var b=G(V),c=ci(Math.min(ba.length-1,bn+Math.floor((a.y-b.top)/cE())));return cj({line:c,ch:cB(ci(c),a.x-b.left)})},getSearchCursor:function(a,b,c){return new cV(a,b,c)},markText:cU(function(a,b,c){return cU(cu(a,b,c))}),setMarker:cv,clearMarker:cw,setLineClass:cU(cx),lineInfo:cy,addWidget:function(a,b,c,d){a=cC(cj(a));var e=a.yBot,f=a.x;b.style.position="absolute",L.appendChild(b),b.style.left=f+"px";if(d=="over")e=a.y;else if(d=="near"){var g=Math.max(F.offsetHeight,ba.length*cE()),h=Math.max(L.clientWidth,V.clientWidth)-cG();a.yBot+b.offsetHeight>g&&a.y>b.offsetHeight&&(e=a.y-b.offsetHeight),f+b.offsetWidth>h&&(f=h-b.offsetWidth)}b.style.top=e+cF()+"px",b.style.left=f+cG()+"px",c&&b$(f,e,f+b.offsetWidth,e+b.offsetHeight)},lineCount:function(){return ba.length},getCursor:function(a){a==null&&(a=be.inverted);return K(a?be.from:be.to)},somethingSelected:function(){return!I(be.from,be.to)},setCursor:cU(function(a,b){b==null&&typeof a.line=="number"?ch(a.line,a.ch):ch(a,b)}),setSelection:cU(function(a,b){cg(cj(a),cj(b||a))}),getLine:function(a){if(bx(a))return ba[a].text},setLine:cU(function(a,b){bx(a)&&bO(b,{line:a,ch:0},{line:a,ch:ba[a].text.length})}),removeLine:cU(function(a){bx(a)&&bO("",{line:a,ch:0},cj({line:a+1,ch:0}))}),replaceRange:cU(bO),getRange:function(a,b){return bR(cj(a),cj(b))},operation:function(a){return cU(a)()},refresh:function(){ca(!0)},getInputField:function(){return E},getWrapperElement:function(){return y},getScrollerElement:function(){return F},getGutterElement:function(){return T}},bT=!1,cK={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},cT=0;cV.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=cj(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:ba[c.line-1].text.length}}else{if(c.line==ba.length-1)return d(ba.length);c={line:c.line+1,ch:0}}}},from:function(){if(this.atOccurrence)return K(this.pos.from)},to:function(){if(this.atOccurrence)return K(this.pos.to)},replace:function(a){var b=this;this.atOccurrence&&cU(function(){b.pos.to=bO(a,b.pos.from,b.pos.to)})()}};for(var cW in d)d.propertyIsEnumerable(cW)&&!by.propertyIsEnumerable(cW)&&(by[cW]=d[cW]);return by}a.defaults={value:"",mode:null,theme:"default",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};var d={};a.defineExtension=function(a,b){d[a]=b},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=t(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=f,a.copyState=e,g.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.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(a){var b=this.string.charAt(this.pos);if(typeof a=="string")var c=b==a;else var c=b&&(a.test?a.test(b):a(b));if(c){++this.pos;return b}},eatWhile:function(a){var b=this.start;while(this.eat(a));return this.pos>b},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 E(this.string,this.start)},indentation:function(){return E(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=g,h.prototype={replace:function(a,b,c){var d=[],e=this.marked;i(0,a,this.styles,d),c&&d.push(c,null),i(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 h(a){return a<=Math.min(b,b+f)?a:a+f}for(var j=0;j<e.length;++j){var k=e[j],l=!1;k.from>=g?l=!0:(k.from=h(k.from),k.to!=null&&(k.to=h(k.to)));if(l||k.from>=k.to)e.splice(j,1),j--}}},split:function(a,b){var c=[b,null];i(a,this.text.length,this.styles,c);return new h(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;c<b.length;++c)if(b[c]==a){b.splice(c,1);break}},highlight:function(a,b){var c=new g(this.text),d=this.styles,e=0,f=!1,h=d[0],i;this.text==""&&a.blankLine&&a.blankLine(b);while(!c.eol()){var j=a.token(c,b),k=this.text.slice(c.start,c.pos);c.start=c.pos,e&&d[e-1]==j?d[e-2]+=k:k&&(!f&&(d[e+1]!=j||e&&d[e-2]!=i)&&(f=!0),d[e++]=k,d[e++]=j,i=h,h=d[e]);if(c.pos>5e3){d[e++]=this.text.slice(c.pos),d[e++]=null;break}}d.length!=e&&(d.length=e,f=!0),e&&d[e-2]!=i&&(f=!0);return f||d.length<5&&this.text.length<10},getTokenAt:function(a,b,c){var d=this.text,e=new g(d);while(e.pos<c&&!e.eol()){e.start=e.pos;var f=a.token(e,b)}return{start:e.start,end:e.pos,string:e.current(),className:f||null,state:b}},indentation:function(){return E(this.text)},getHTML:function(a,b,c,d){function f(a,b){!a||(b?e.push('<span class="',b,'">',M(a),"</span>"):e.push(M(a)))}var e=[];c&&e.push(this.className?'<pre class="'+this.className+'">':"<pre>");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;l<j;k+=2){var m=g[k],n=m.length;l+n>j&&(m=m.slice(0,j-l)),l+=n,f(m,"cm-"+g[k+1])}else{var o=0,k=0,p="",q,r=0,s=-1,t=null;function u(){i&&(s+=1,t=s<i.length?i[s]:null)}u();while(o<j){var v=j,w="";if(a!=null)if(a>o)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="cm-"+g[k++]}}a!=null&&b==null&&f(" ","CodeMirror-selected")}c&&e.push("</pre>");return e.join("")}},j.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<a-e.added+e.old.length)this.done.push({start:a,added:b,old:c});else{var f=0;if(a<e.start){for(var g=e.start-a-1;g>=0;--g)e.old.unshift(c[g]);e.added+=e.start-a,e.start=a}else e.start<a&&(f=a-e.start,b+=f);for(var g=e.added-f,h=c.length;g<h;++g)e.old.push(c[g]);e.added<b&&(e.added=b)}this.time=d}},u.prototype={set:function(a,b){clearTimeout(this.id),this.id=setTimeout(b,a)}};var v=function(){var a=document.createElement("pre");a.innerHTML=" ";return!a.innerHTML}(),w=/gecko\/\d{7}/i.test(navigator.userAgent),x=/MSIE \d/.test(navigator.userAgent),y=/Apple Computer/.test(navigator.vendor),z="\n";(function(){var a=document.createElement("textarea");a.value="foo\nbar",a.value.indexOf("\r")>-1&&(z="\r\n")})();var A=8,B=/Mac/.test(navigator.platform),C={};for(var D=35;D<=40;++D)C[D]=C["c"+D]=!0;var L=document.createElement("div");a.htmlEscape=M;var P,Q,R;"\n\nb".split(/\n/).length!=3?P=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}:P=function(a){return a.split(/\r?\n/)},a.splitLines=P,window.getSelection?(Q=function(a){try{return{start:a.selectionStart,end:a.selectionEnd}}catch(b){return null}},y?R=function(a,b,c){b==c?a.setSelectionRange(b,c):(a.setSelectionRange(b,c-1),window.getSelection().modify("extend","forward","character"))}:R=function(a,b,c){try{a.setSelectionRange(b,c)}catch(d){}}):(Q=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<h;i=d.indexOf("\r",i+1),h++);if(f.compareEndPoints("EndToEnd",g)>-1)return{start:h,end:e};var j=-f.moveEnd("character",-e);for(var i=d.indexOf("\r");i>-1&&i<j;i=d.indexOf("\r",i+1),j++);return{start:h,end:j}},R=function(a,b,c){var d=a.createTextRange();d.collapse(!0);var e=d.duplicate(),f=0,g=a.value;for(var h=g.indexOf("\n");h>-1&&h<b;h=g.indexOf("\n",h+1))++f;d.move("character",b-f);for(;h>-1&&h<c;h=g.indexOf("\n",h+1))++f;e.move("character",c-f),d.setEndPoint("EndToEnd",e),d.select()}),a.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}}),a.defineMIME("text/plain","null");return a}();CodeMirror.defineMode("javascript",function(a,b){function R(a,b){if(a=="variable"){v(b);return u()}}function Q(a,b){if(a=="variable"){v(b);return u(Q)}if(a=="(")return u(z(")"),x,I(R,")"),A,C,y)}function P(a){a!=")"&&u(D)}function O(a,b){if(a==";")return u(P);if(b=="in")return u(D);return u(D,B(";"),P)}function N(a,b){if(b=="in")return u(D);return u(E,O)}function M(a){if(a=="var")return u(K,O);if(a==";")return t(O);if(a=="variable")return u(N);return t(O)}function L(a,b){if(b=="=")return u(D,L);if(a==",")return u(K)}function K(a,b){if(a=="variable"){v(b);return u(L)}return u()}function J(a){if(a=="}")return u();return t(C,J)}function I(a,b){function c(d){if(d==",")return u(a,c);if(d==b)return u();return u(B(b))}return function(d){return d==b?u():t(a,c)}}function H(a){a=="variable"&&(s.marked="property");if(o.hasOwnProperty(a))return u(B(":"),D)}function G(a){if(a=="variable"){s.marked="property";return u()}}function F(a){if(a==":")return u(A,C);return t(E,B(";"),A)}function E(a,b){if(a=="operator"&&/\+\+|--/.test(b))return u(E);if(a=="operator")return u(D);if(a!=";"){if(a=="(")return u(z(")"),I(D,")"),A,E);if(a==".")return u(G,E);if(a=="[")return u(z("]"),D,B("]"),A,E)}}function D(a){if(o.hasOwnProperty(a))return u(E);if(a=="function")return u(Q);if(a=="keyword c")return u(D);if(a=="(")return u(z(")"),D,B(")"),A,E);if(a=="operator")return u(D);if(a=="[")return u(z("]"),I(D,"]"),A,E);if(a=="{")return u(z("}"),I(H,"}"),A,E);return u()}function C(a){if(a=="var")return u(z("vardef"),K,B(";"),A);if(a=="keyword a")return u(z("form"),D,C,A);if(a=="keyword b")return u(z("form"),C,A);if(a=="{")return u(z("}"),J,A);if(a==";")return u();if(a=="function")return u(Q);if(a=="for")return u(z("form"),B("("),z(")"),M,B(")"),A,C,A);if(a=="variable")return u(z("stat"),F);if(a=="switch")return u(z("form"),D,z("}","switch"),B("{"),J,A,A);if(a=="case")return u(D,B(":"));if(a=="default")return u(B(":"));if(a=="catch")return u(z("form"),x,B("("),R,B(")"),C,A,y);return t(z("stat"),D,B(";"),A)}function B(a){return function(b){return b==a?u():a==";"?t():u(arguments.callee)}}function A(){var a=s.state;a.lexical.prev&&(a.lexical.type==")"&&(a.indented=a.lexical.indented),a.lexical=a.lexical.prev)}function z(a,b){var c=function(){var c=s.state;c.lexical=new p(c.indented,s.stream.column(),a,null,c.lexical,b)};c.lex=!0;return c}function y(){s.state.localVars=s.state.context.vars,s.state.context=s.state.context.prev}function x(){s.state.context||(s.state.localVars=w),s.state.context={prev:s.state.context,vars:s.state.localVars}}function v(a){var b=s.state;if(b.context){s.marked="def";for(var c=b.localVars;c;c=c.next)if(c.name==a)return;b.localVars={name:a,next:b.localVars}}}function u(){t.apply(null,arguments);return!0}function t(){for(var a=arguments.length-1;a>=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"variable-2";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","comment")}function m(a){return function(b,c){h(b,a)||(c.tokenize=l);return k("string","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","number")}if(/\d/.test(c)){a.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);return k("number","number")}if(c=="/"){if(a.eat("*"))return g(a,b,n);if(a.eat("/")){a.skipToEnd();return k("comment","comment")}if(b.reAllowed){h(a,"/"),a.eatWhile(/[gimy]/);return k("regexp","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","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:"keyword"}}var b=a("keyword a"),c=a("keyword b"),d=a("keyword c"),e=a("operator"),f={type:"atom",style:"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 w(a){return a=="string"?o(w):n()}function v(a){if(a=="word"&&d.allowUnquoted){m="string";return o()}if(a=="string")return o(w);return n()}function u(a){if(a=="word"){m="attribute";return o(u)}if(a=="equals")return o(v,u);return n()}function t(a){return function(b){a&&(m="error");if(b=="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"){var b=!1;l.context?(b=l.context.tagName!=f,q()):b=!0,b&&(m="error");return o(t(b))}if(a=="string"){(!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"string"}}function i(a,b){var c=a.next();if(c==">"||c=="/"&&a.eat(">")){b.tokenize=h,g=c==">"?"endTag":"selfcloseTag";return"tag"}if(c=="="){g="equals";return null}if(/[\'\"]/.test(c)){b.tokenize=j(c);return b.tokenize(a,b)}a.eatWhile(/[^\s\u00a0=<>\"\'\/?]/);return"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("atom","]]>")):null;if(a.match("--"))return c(k("comment","-->"));if(a.match("DOCTYPE",!0,!0)){a.eatWhile(/[\w\._\-]/);return c(k("meta",">"))}return null}if(a.eat("?")){a.eatWhile(/[\w\._\-]/),b.tokenize=k("meta","?>");return"meta"}g=a.eat("/")?"closeTag":"openTag",a.eatSpace(),f="";var e;while(e=a.eat(/[^\s\u00a0=<>\"\'\/?]/))f+=e;b.tokenize=i;return"tag"}if(d=="&"){a.eatWhile(/[^;]/),a.eat(";");return"atom"}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!="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&&/<!\[CDATA\[/.test(b))return 0;d&&/^<\//.test(b)&&(d=d.prev);while(d&&!d.startOfLine)d=d.prev;return d?d.indent+c:0},compareStates:function(a,b){if(a.indented!=b.indented||a.tagName!=b.tagName)return!1;for(var c=a.context,d=b.context;;c=c.prev,d=d.prev){if(!c||!d)return c==d;if(c.tagName!=d.tagName)return!1}},electricChars:"/"}}),CodeMirror.defineMIME("application/xml","xml"),CodeMirror.defineMIME("text/html",{name:"xml",htmlMode:!0}),CodeMirror.defineMode("css",function(a){function h(a){return function(b,c){var f=!1,g;while((g=b.next())!=null){if(g==a&&!f)break;f=!f&&g=="\\"}f||(c.tokenize=e);return d("string","string")}}function g(a,b){var c=0,f;while((f=a.next())!=null){if(c>=2&&f==">"){b.tokenize=e;break}c=f=="-"?c+1:0}return d("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("comment","comment")}function e(a,b){var c=a.next();if(c=="@"){a.eatWhile(/\w/);return d("meta",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("atom","hash")}if(c=="!"){a.match(/^\s*\w*/);return d("keyword","important")}if(/\d/.test(c)){a.eatWhile(/[\w.%]/);return d("number","unit")}if(/[,.+>*\/]/.test(c))return d(null,"select-op");if(/[;{}:\[\]]/.test(c))return d(null,c);a.eatWhile(/[\w\\\-_]/);return d("variable","variable")}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="atom";else if(d=="variable")if(e=="rule")d="number";else if(!e||e=="@media{")d="tag";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=="{"&&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,b.mode="html";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,b.mode="html";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=="tag"&&a.current()==">"&&b.htmlState.context&&(/^script$/i.test(b.htmlState.context.tagName)?(b.token=h,b.localState=d.startState(c.indent(b.htmlState,"")),b.mode="javascript"):/^style$/i.test(b.htmlState.context.tagName)&&(b.token=i,b.localState=e.startState(c.indent(b.htmlState,"")),b.mode="css"));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,mode:"html",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,mode:a.mode,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") |