var CodeMirrorConfig=window.CodeMirrorConfig||{},CodeMirror=function(){function q(a,b){for(var c in b)a.hasOwnProperty(c)||(a[c]=b[c])}function w(a,b){for(var c=0;c<a.length;c++)b(a[c])}function r(a){return document.createElementNS&&null!==document.documentElement.namespaceURI?document.createElementNS("http://www.w3.org/1999/xhtml",a):document.createElement(a)}function x(a,b){var c=r("div"),d=r("div");c.style.position="absolute";c.style.height="100%";if(c.style.setExpression)try{c.style.setExpression("height",
"this.previousSibling.offsetHeight + 'px'")}catch(g){}c.style.top="0px";c.style.left="0px";c.style.overflow="hidden";a.appendChild(c);d.className="CodeMirror-line-numbers";c.appendChild(d);d.innerHTML="<div>"+b+"</div>";return c}function A(a){"string"==typeof a.parserfile&&(a.parserfile=[a.parserfile]);"string"==typeof a.basefiles&&(a.basefiles=[a.basefiles]);"string"==typeof a.stylesheet&&(a.stylesheet=[a.stylesheet]);var b=' spellcheck="'+(a.disableSpellcheck?"false":"true")+'"',c=['<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html'+
b+"><head>"];c.push('<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>');var d=a.noScriptCaching?"?nocache="+(new Date).getTime().toString(16):"";w(a.stylesheet,function(a){c.push('<link rel="stylesheet" type="text/css" href="'+a+d+'"/>')});w(a.basefiles.concat(a.parserfile),function(b){/^https?:/.test(b)||(b=a.path+b);c.push('<script type="text/javascript" src="'+b+d+'">\x3c/script>')});c.push('</head><body style="border-width: 0;" class="editbox"'+b+"></body></html>");return c.join("")}
function h(a,b){this.options=b=b||{};q(b,CodeMirrorConfig);b.dumbTabs?b.tabMode="spaces":b.normalTab&&(b.tabMode="default");b.cursorActivity&&(b.onCursorActivity=b.cursorActivity);var c=this.frame=r("iframe");b.iframeClass&&(c.className=b.iframeClass);b.iframeId&&(c.id=b.iframeId);c.frameBorder=0;c.style.border="0";c.style.width="100%";c.style.height="100%";c.style.display="block";var d=this.wrapping=r("div");d.style.position="relative";d.className="CodeMirror-wrapping";d.style.width=b.width;d.style.height=
"dynamic"==b.height?b.minHeight+"px":b.height;var g=this.textareaHack=r("textarea");d.appendChild(g);g.style.position="absolute";g.style.left="-10000px";g.style.width="10px";g.tabIndex=1E5;c.CodeMirror=this;b.domain&&B?(this.html=A(b),c.src="javascript:(function(){document.open();"+(b.domain?'document.domain="'+b.domain+'";':"")+"document.write(window.frameElement.CodeMirror.html);document.close();})()"):c.src="javascript:;";a.appendChild?a.appendChild(d):a(d);d.appendChild(c);b.lineNumbers&&(this.lineNumbers=
x(d,b.firstLineNumber));this.win=c.contentWindow;b.domain&&B||(this.win.document.open(),this.win.document.write(A(b)),this.win.document.close())}q(CodeMirrorConfig,{stylesheet:[],path:"",parserfile:[],basefiles:"util.js stringstream.js select.js undo.js editor.js tokenize.js".split(" "),iframeId:null,iframeClass:null,passDelay:200,passTime:50,lineNumberDelay:200,lineNumberTime:50,continuousScanning:!1,saveFunction:null,onLoad:null,onChange:null,undoDepth:50,undoDelay:800,disableSpellcheck:!0,textWrapping:!0,
readOnly:!1,width:"",height:"300px",minHeight:100,autoMatchParens:!1,markParen:null,unmarkParen:null,parserConfig:null,tabMode:"indent",enterMode:"indent",electricChars:!0,reindentOnLoad:!1,activeTokens:null,onCursorActivity:null,lineNumbers:!1,firstLineNumber:1,onLineNumberClick:null,indentUnit:2,domain:null,noScriptCaching:!1,incrementalLoading:!1});var B=document.selection&&window.ActiveXObject&&/MSIE/.test(navigator.userAgent);h.prototype={init:function(){this.options.initCallback&&this.options.initCallback(this);
if(this.options.onLoad)this.options.onLoad(this);this.options.lineNumbers&&this.activateLineNumbers();this.options.reindentOnLoad&&this.reindent();"dynamic"==this.options.height&&this.setDynamicHeight()},getCode:function(){return this.editor.getCode()},setCode:function(a){this.editor.importCode(a)},canHighlight:function(){return!0},highlightSql:function(a,b,c){return this.win.highlightSql(a,b,c)},getSelection:function(){this.focusIfIE();return this.editor.selectedText()},reindent:function(){this.editor.reindent()},
reindentSelection:function(){this.focusIfIE();this.editor.reindentSelection(null)},focusIfIE:function(){this.win.select.ie_selection&&document.activeElement!=this.frame&&this.focus()},focus:function(){this.win.focus();this.editor.selectionSnapshot&&this.win.select.setBookmark(this.win.document.body,this.editor.selectionSnapshot)},replaceSelection:function(a){this.focus();this.editor.replaceSelection(a);return!0},replaceChars:function(a,b,c){this.editor.replaceChars(a,b,c)},getSearchCursor:function(a,
b,c){return this.editor.getSearchCursor(a,b,c)},undo:function(){this.editor.history.undo()},redo:function(){this.editor.history.redo()},historySize:function(){return this.editor.history.historySize()},clearHistory:function(){this.editor.history.clear()},grabKeys:function(a,b){this.editor.grabKeys(a,b)},ungrabKeys:function(){this.editor.ungrabKeys()},setParser:function(a,b){this.editor.setParser(a,b)},setSpellcheck:function(a){this.win.document.body.spellcheck=a},setStylesheet:function(a){"string"===
typeof a&&(a=[a]);for(var b={},c={},d=this.win.document.getElementsByTagName("link"),g=0,e;e=d[g];g++)if(-1!==e.rel.indexOf("stylesheet"))for(var f=0;f<a.length;f++){var m=a[f];e.href.substring(e.href.length-m.length)===m&&(b[e.href]=!0,c[m]=!0)}for(g=0;e=d[g];g++)-1!==e.rel.indexOf("stylesheet")&&(e.disabled=!(e.href in b));for(f=0;f<a.length;f++)m=a[f],m in c||(e=this.win.document.createElement("link"),e.rel="stylesheet",e.type="text/css",e.href=m,this.win.document.getElementsByTagName("head")[0].appendChild(e))},
setTextWrapping:function(a){a!=this.options.textWrapping&&(this.win.document.body.style.whiteSpace=a?"":"nowrap",this.options.textWrapping=a,this.lineNumbers&&(this.setLineNumbers(!1),this.setLineNumbers(!0)))},setIndentUnit:function(a){this.win.indentUnit=a},setUndoDepth:function(a){this.editor.history.maxDepth=a},setTabMode:function(a){this.options.tabMode=a},setEnterMode:function(a){this.options.enterMode=a},setLineNumbers:function(a){a&&!this.lineNumbers?(this.lineNumbers=x(this.wrapping,this.options.firstLineNumber),
this.activateLineNumbers()):!a&&this.lineNumbers&&(this.wrapping.removeChild(this.lineNumbers),this.wrapping.style.paddingLeft="",this.lineNumbers=null)},cursorPosition:function(a){this.focusIfIE();return this.editor.cursorPosition(a)},firstLine:function(){return this.editor.firstLine()},lastLine:function(){return this.editor.lastLine()},nextLine:function(a){return this.editor.nextLine(a)},prevLine:function(a){return this.editor.prevLine(a)},lineContent:function(a){return this.editor.lineContent(a)},
setLineContent:function(a,b){this.editor.setLineContent(a,b)},removeLine:function(a){this.editor.removeLine(a)},insertIntoLine:function(a,b,c){this.editor.insertIntoLine(a,b,c)},selectLines:function(a,b,c,d){this.win.focus();this.editor.selectLines(a,b,c,d)},nthLine:function(a){for(var b=this.firstLine();1<a&&!1!==b;a--)b=this.nextLine(b);return b},lineNumber:function(a){for(var b=0;!1!==a;)b++,a=this.prevLine(a);return b},jumpToLine:function(a){"number"==typeof a&&(a=this.nthLine(a));this.selectLines(a,
0);this.win.focus()},currentLine:function(){return this.lineNumber(this.cursorLine())},cursorLine:function(){return this.cursorPosition().line},cursorCoords:function(a){return this.editor.cursorCoords(a)},activateLineNumbers:function(){function a(){if(0!=e.offsetWidth){for(var a=e;a.parentNode;a=a.parentNode);if(k.parentNode&&a==document&&f.Editor)k.offsetWidth!=h&&(h=k.offsetWidth,e.parentNode.style.paddingLeft=h+"px");else{try{z()}catch(b){}clearInterval(q)}}}function b(){k.scrollTop=y.scrollTop||
m.documentElement.scrollTop||0}function c(a){var b=p.firstChild.offsetHeight;if(0!=b)for(var b=Math.ceil((50+Math.max(y.offsetHeight,Math.max(e.offsetHeight,y.scrollHeight||0)))/b),c=p.childNodes.length;c<=b;c++){var d=r("div");d.appendChild(document.createTextNode(a?String(c+l.options.firstLineNumber):"\u00a0"));p.appendChild(d)}}function d(){function a(){c(!0);b()}l.updateNumbers=a;var d=f.addEventHandler(f,"scroll",b,!0),e=f.addEventHandler(f,"resize",a,!0);z=function(){d();e();l.updateNumbers==
a&&(l.updateNumbers=null)};a()}function g(){function a(b,c){h||(h=p.appendChild(r("div")));q&&q(h,c,b);t.push(h);t.push(b);v=h.offsetHeight+h.offsetTop;h=h.nextSibling}function d(){for(var a=0;a<t.length;a+=2)t[a].innerHTML=t[a+1];t=[]}function e(){if(p.parentNode&&p.parentNode==l.lineNumbers){for(var c=(new Date).getTime()+l.options.lineNumberTime;n;){for(a(m++,n.previousSibling);n&&!f.isBR(n);n=n.nextSibling)for(var g=n.offsetTop+n.offsetHeight;p.offsetHeight&&g-3>v;){var k=v;a("&nbsp;");if(v<=
k)break}n&&(n=n.nextSibling);if((new Date).getTime()>c){d();u=setTimeout(e,l.options.lineNumberDelay);return}}for(;h;)a(m++);d();b()}}function g(a){b();c(a);n=y.firstChild;h=p.firstChild;v=0;m=l.options.firstLineNumber;e()}function k(){u&&clearTimeout(u);l.editor.allClean()?g():u=setTimeout(k,200)}var n,h,m,v,t=[],q=l.options.styleNumbers;g(!0);var u=null;l.updateNumbers=k;var w=f.addEventHandler(f,"scroll",b,!0),x=f.addEventHandler(f,"resize",k,!0);z=function(){u&&clearTimeout(u);l.updateNumbers==
k&&(l.updateNumbers=null);w();x()}}var e=this.frame,f=e.contentWindow,m=f.document,y=m.body,k=this.lineNumbers,p=k.firstChild,l=this,h=null;k.onclick=function(a){var b=l.options.onLineNumberClick;if(b){a=(a||window.event).target||(a||window.event).srcElement;var c=a==k?NaN:Number(a.innerHTML);isNaN(c)||b(c,a)}};var z=function(){};a();var q=setInterval(a,500);(this.options.textWrapping||this.options.styleNumbers?g:d)()},setDynamicHeight:function(){function a(){for(var a=0,c=g.lastChild,f;c&&d.isBR(c);)c.hackBR||
a++,c=c.previousSibling;c?(e=c.offsetHeight,f=c.offsetTop+(1+a)*e):e&&(f=a*e);f&&(b.wrapping.style.height=Math.max(h+f,b.options.minHeight)+"px")}var b=this,c=b.options.onCursorActivity,d=b.win,g=d.document.body,e=null,f=null,h=2*b.frame.offsetTop;g.style.overflowY="hidden";d.document.documentElement.style.overflowY="hidden";this.frame.scrolling="no";setTimeout(a,300);b.options.onCursorActivity=function(b){c&&c(b);clearTimeout(f);f=setTimeout(a,100)}}};h.InvalidLineHandle={toString:function(){return"CodeMirror.InvalidLineHandle"}};
h.replace=function(a){"string"==typeof a&&(a=document.getElementById(a));return function(b){a.parentNode.replaceChild(b,a)}};h.fromTextArea=function(a,b){function c(){a.value=e.getCode()}"string"==typeof a&&(a=document.getElementById(a));b=b||{};a.style.width&&null==b.width&&(b.width=a.style.width);a.style.height&&null==b.height&&(b.height=a.style.height);null==b.content&&(b.content=a.value);if(a.form){var d=function(){c();a.form.submit=g;a.form.submit();a.form.submit=d};"function"==typeof a.form.addEventListener?
a.form.addEventListener("submit",c,!1):a.form.attachEvent("onsubmit",c);var g=a.form.submit;try{a.form.submit=d}catch(f){}}a.style.display="none";var e=new h(function(b){a.nextSibling?a.parentNode.insertBefore(b,a.nextSibling):a.parentNode.appendChild(b)},b);e.save=c;e.toTextArea=function(){c();a.parentNode.removeChild(e.wrapping);a.style.display="";if(a.form){try{a.form.submit=g}catch(b){}"function"==typeof a.form.removeEventListener?a.form.removeEventListener("submit",c,!1):a.form.detachEvent("onsubmit",
c)}};return e};h.isProbablySupported=function(){var a;return window.opera?9.52<=Number(window.opera.version()):/Apple Computer, Inc/.test(navigator.vendor)&&(a=navigator.userAgent.match(/Version\/(\d+(?:\.\d+)?)\./))?3<=Number(a[1]):document.selection&&window.ActiveXObject&&(a=navigator.userAgent.match(/MSIE (\d+(?:\.\d*)?)\b/))?6<=Number(a[1]):(a=navigator.userAgent.match(/gecko\/(\d{8})/i))?20050901<=Number(a[1]):(a=navigator.userAgent.match(/AppleWebKit\/(\d+)/))?525<=Number(a[1]):null};return h}();
