(function(a,b){typeof exports==="object"&&typeof module!=="undefined"?module.exports=b():typeof define==="function"&&define.amd?define(b):(a=a||self,a.CodeMirror=b())})(this,function(){"use strict";var a=navigator.userAgent;var b=navigator.platform;var c=/gecko\/\d/i.test(a);var d=/MSIE \d/.test(a);var e=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(a);var f=/Edge\/(\d+)/.exec(a);var g=d||e||f;var h=g&&(d?document.documentMode||6:+(f||e)[1]);var i=!f&&/WebKit\//.test(a);var j=i&&/Qt\/\d+\.\d+/.test(a);var k=!f&&/Chrome\//.test(a);var l=/Opera\//.test(a);var m=/Apple Computer/.test(navigator.vendor);var n=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(a);var o=/PhantomJS/.test(a);var p=!f&&/AppleWebKit/.test(a)&&/Mobile\/\w+/.test(a);var q=/Android/.test(a);var r=p||q||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(a);var s=p||/Mac/.test(b);var t=/\bCrOS\b/.test(a);var u=/win/i.test(b);var v=l&&a.match(/Version\/(\d*\.\d*)/);if(v){v=Number(v[1])}if(v&&v>=15){l=false;i=true}var w=s&&(j||l&&(v==null||v<12.11));var x=c||g&&h>=9;function y(a){return new RegExp("(^|\\s)"+a+"(?:$|\\s)\\s*")}var z=function(a,b){var c=a.className;var d=y(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:"")}};function A(a){for(var b=a.childNodes.length;b>0;--b){a.removeChild(a.firstChild)}return a}function B(a,b){return A(a).appendChild(b)}function C(a,b,c,d){var e=document.createElement(a);if(c){e.className=c}if(d){e.style.cssText=d}if(typeof b=="string"){e.appendChild(document.createTextNode(b))}else if(b){for(var f=0;f=b){return g+(b-f)}g+=h-f;g+=c-g%c;f=h+1}}var N=function(){this.id=null;this.f=null;this.time=0;this.handler=K(this.onTimeout,this)};N.prototype.onTimeout=function(a){a.id=0;if(a.time<=+new Date){a.f()}else{setTimeout(a.handler,a.time-+new Date)}};N.prototype.set=function(a,b){this.f=b;var c=+new Date+a;if(!this.id||c=b){return d+Math.min(g,b-e)}e+=f-d;e+=c-e%c;d=f+1;if(e>=b){return d}}}var V=[""];function W(a){while(V.length<=a){V.push(X(V)+" ")}return V[a]}function X(a){return a[a.length-1]}function Y(a,b){var c=[];for(var d=0;d"€"&&(a.toUpperCase()!=a.toLowerCase()||aa.test(a))}function ca(a,b){if(!b){return ba(a)}if(b.source.indexOf("\\w")>-1&&ba(a)){return true}return b.test(a)}function da(a){for(var b in a){if(a.hasOwnProperty(b)&&a[b]){return false}}return true}var ea=/[\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]/;function fa(a){return a.charCodeAt(0)>=768&&ea.test(a)}function ga(a,b,c){while((c<0?b>0:bc?-1:1;for(;;){if(b==c){return b}var e=(b+c)/2,f=d<0?Math.ceil(e):Math.floor(e);if(f==b){return a(f)?b:c}if(a(f)){c=f}else{b=f+d}}}function ia(a,b,c,d){if(!a){return d(b,c,"ltr",0)}var e=false;for(var f=0;fb||b==c&&g.to==b){d(Math.max(g.from,b),Math.min(g.to,c),g.level==1?"rtl":"ltr",f);e=true}}if(!e){d(b,c,"ltr")}}var ja=null;function ka(a,b,c){var d;ja=null;for(var e=0;eb){return e}if(f.to==b){if(f.from!=f.to&&c=="before"){d=e}else{ja=e}}if(f.from==b){if(f.from!=f.to&&c!="before"){d=e}else{ja=e}}}return d!=null?d:ja}var la=function(){var a="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";var b="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function c(c){if(c<=247){return a.charAt(c)}else if(1424<=c&&c<=1524){return"R"}else if(1536<=c&&c<=1785){return b.charAt(c-1536)}else if(1774<=c&&c<=2220){return"r"}else if(8192<=c&&c<=8203){return"w"}else if(c==8204){return"b"}else{return"L"}}var d=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;var e=/[stwN]/,f=/[LRr]/,g=/[Lb1n]/,h=/[1n]/;function i(a,b,c){this.level=a;this.from=b;this.to=c}return function(a,b){var j=b=="ltr"?"L":"R";if(a.length==0||b=="ltr"&&!d.test(a)){return false}var k=a.length,l=[];for(var m=0;m-1){d[b]=e.slice(0,f).concat(e.slice(f+1))}}}}function ra(a,b){var c=pa(a,b);if(!c.length){return}var d=Array.prototype.slice.call(arguments,2);for(var e=0;e0}function va(a){a.prototype.on=function(a,b){oa(this,a,b)};a.prototype.off=function(a,b){qa(this,a,b)}}function wa(a){if(a.preventDefault){a.preventDefault()}else{a.returnValue=false}}function xa(a){if(a.stopPropagation){a.stopPropagation()}else{a.cancelBubble=true}}function ya(a){return a.defaultPrevented!=null?a.defaultPrevented:a.returnValue==false}function za(a){wa(a);xa(a)}function Aa(a){return a.target||a.srcElement}function Ba(a){var b=a.which;if(b==null){if(a.button&1){b=1}else if(a.button&2){b=3}else if(a.button&4){b=2}}if(s&&a.ctrlKey&&b==1){b=3}return b}var Ca=function(){if(g&&h<9){return false}var a=C("div");return"draggable"in a||"dragDrop"in a}();var Da;function Ea(a){if(Da==null){var b=C("span","​");B(a,C("span",[b,document.createTextNode("x")]));if(a.firstChild.offsetHeight!=0){Da=b.offsetWidth<=1&&b.offsetHeight>2&&!(g&&h<8)}}var c=Da?C("span","​"):C("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");c.setAttribute("cm-text","");return c}var Fa;function Ga(a){if(Fa!=null){return Fa}var b=B(a,document.createTextNode("AخA"));var c=E(b,0,1).getBoundingClientRect();var d=E(b,1,2).getBoundingClientRect();A(a);if(!c||c.left==c.right){return false}return Fa=d.right-c.right<3}var Ha="\n\nb".split(/\n/).length!=3?function(a){var b=0,c=[],d=a.length;while(b<=d){var e=a.indexOf("\n",b);if(e==-1){e=a.length}var f=a.slice(b,a.charAt(e-1)=="\r"?e-1:e);var g=f.indexOf("\r");if(g!=-1){c.push(f.slice(0,g));b+=g+1}else{c.push(f);b=e+1}}return c}:function(a){return a.split(/\r\n?|\n/)};var Ia=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return false}}:function(a){var b;try{b=a.ownerDocument.selection.createRange()}catch(c){}if(!b||b.parentElement()!=a){return false}return b.compareEndPoints("StartToEnd",b)!=0};var Ja=function(){var a=C("div");if("oncopy"in a){return true}a.setAttribute("oncopy","return;");return typeof a.oncopy=="function"}();var Ka=null;function La(a){if(Ka!=null){return Ka}var b=B(a,C("span","x"));var c=b.getBoundingClientRect();var d=E(b,0,1).getBoundingClientRect();return Ka=Math.abs(c.left-d.left)>1}var Ma={},Na={};function Oa(a,b){if(arguments.length>2){b.dependencies=Array.prototype.slice.call(arguments,2)}Ma[a]=b}function Pa(a,b){Na[a]=b}function Qa(a){if(typeof a=="string"&&Na.hasOwnProperty(a)){a=Na[a]}else if(a&&typeof a.name=="string"&&Na.hasOwnProperty(a.name)){var b=Na[a.name];if(typeof b=="string"){b={name:b}}a=_(b,a);a.name=b.name}else if(typeof a=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a)){return Qa("application/xml")}else if(typeof a=="string"&&/^[\w\-]+\/[\w\-]+\+json$/.test(a)){return Qa("application/json")}if(typeof a=="string"){return{name:a}}else{return a||{name:"null"}}}function Ra(a,b){b=Qa(b);var c=Ma[b.name];if(!c){return Ra(a,"text/plain")}var d=c(a,b);if(Sa.hasOwnProperty(b.name)){var e=Sa[b.name];for(var f in e){if(!e.hasOwnProperty(f)){continue}if(d.hasOwnProperty(f)){d["_"+f]=d[f]}d[f]=e[f]}}d.name=b.name;if(b.helperType){d.helperType=b.helperType}if(b.modeProps){for(var g in b.modeProps){d[g]=b.modeProps[g]}}return d}var Sa={};function Ta(a,b){var c=Sa.hasOwnProperty(a)?Sa[a]:Sa[a]={};L(b,c)}function Ua(a,b){if(b===true){return b}if(a.copyState){return a.copyState(b)}var c={};for(var d in b){var e=b[d];if(e instanceof Array){e=e.concat([])}c[d]=e}return c}function Va(a,b){var c;while(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 Wa(a,b,c){return a.startState?a.startState(b,c):true}var Xa=function(a,b,c){this.pos=this.start=0;this.string=a;this.tabSize=b||8;this.lastColumnPos=this.lastColumnValue=0;this.lineStart=0;this.lineOracle=c};Xa.prototype.eol=function(){return this.pos>=this.string.length};Xa.prototype.sol=function(){return this.pos==this.lineStart};Xa.prototype.peek=function(){return this.string.charAt(this.pos)||undefined};Xa.prototype.next=function(){if(this.posb};Xa.prototype.eatSpace=function(){var a=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos))){++this.pos}return this.pos>a};Xa.prototype.skipToEnd=function(){this.pos=this.string.length};Xa.prototype.skipTo=function(a){var b=this.string.indexOf(a,this.pos);if(b>-1){this.pos=b;return true}};Xa.prototype.backUp=function(a){this.pos-=a};Xa.prototype.column=function(){if(this.lastColumnPos0){return null}if(f&&b!==false){this.pos+=f[0].length}return f}};Xa.prototype.current=function(){return this.string.slice(this.start,this.pos)};Xa.prototype.hideFirstChars=function(a,b){this.lineStart+=a;try{return b()}finally{this.lineStart-=a}};Xa.prototype.lookAhead=function(a){var b=this.lineOracle;return b&&b.lookAhead(a)};Xa.prototype.baseToken=function(){var a=this.lineOracle;return a&&a.baseToken(this.pos)};function Ya(a,b){b-=a.first;if(b<0||b>=a.size){throw new Error("There is no line "+(b+a.first)+" in the document.")}var c=a;while(!c.lines){for(var d=0;;++d){var e=c.children[d],f=e.chunkSize();if(b=a.first&&bc){return eb(c,Ya(a,c).text.length)}return mb(b,Ya(a,b.line).text.length)}function mb(a,b){var c=a.ch;if(c==null||c>b){return eb(a.line,b)}else if(c<0){return eb(a.line,0)}else{return a}}function nb(a,b){var c=[];for(var d=0;dthis.maxLookAhead){this.maxLookAhead=a}return b};pb.prototype.baseToken=function(a){if(!this.baseTokens){return null}while(this.baseTokens[this.baseTokenPos]<=a){this.baseTokenPos+=2}var b=this.baseTokens[this.baseTokenPos+1];return{type:b&&b.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-a}};pb.prototype.nextLine=function(){this.line++;if(this.maxLookAhead>0){this.maxLookAhead--}};pb.fromSaved=function(a,b,c){if(b instanceof ob){return new pb(a,Ua(a.mode,b.state),c,b.lookAhead)}else{return new pb(a,Ua(a.mode,b),c)}};pb.prototype.save=function(a){var b=a!==false?Ua(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new ob(b,this.maxLookAhead):b};function qb(a,b,c,d){var e=[a.state.modeGen],f={};zb(a,b.text,a.doc.mode,c,function(a,b){return e.push(a,b)},f,d);var g=c.state;var h=function(d){c.baseTokens=e;var h=a.state.overlays[d],i=1,j=0;c.state=true;zb(a,b.text,h.mode,c,function(a,b){var c=i;while(ja){e.splice(i,1,a,e[i+1],d)}i+=2;j=Math.min(a,d)}if(!b){return}if(h.opaque){e.splice(c,i-c,a,"overlay "+b);i=c+2}else{for(;ca.options.maxHighlightLength&&Ua(a.doc.mode,d.state);var f=qb(a,b,d);if(e){d.state=e}b.stateAfter=d.save(!e);b.styles=f.styles;if(f.classes){b.styleClasses=f.classes}else if(b.styleClasses){b.styleClasses=null}if(c===a.doc.highlightFrontier){a.doc.modeFrontier=Math.max(a.doc.modeFrontier,++a.doc.highlightFrontier)}}return b.styles}function sb(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState){return new pb(d,true,b)}var f=Ab(a,b,c);var g=f>d.first&&Ya(d,f-1).stateAfter;var h=g?pb.fromSaved(d,g,f):new pb(d,Wa(d.mode),f);d.iter(f,b,function(c){tb(a,c.text,h);var d=h.line;c.stateAfter=d==b-1||d%5==0||d>=e.viewFrom&&db.start){return f}}throw new Error("Mode "+a.name+" failed to advance stream.")}var wb=function(a,b,c){this.start=a.start;this.end=a.pos;this.string=a.current();this.type=b||null;this.state=c};function xb(a,b,c,d){var e=a.doc,f=e.mode,g;b=lb(e,b);var h=Ya(e,b.line),i=sb(a,b.line,c);var j=new Xa(h.text,a.options.tabSize,i),k;if(d){k=[]}while((d||j.posa.options.maxHighlightLength){h=false;if(g){tb(a,b,d,k.pos)}k.pos=b.length;l=null}else{l=yb(vb(c,k,d.state,m),f)}if(m){var n=m[0].name;if(n){l="m-"+(l?n+" "+l:n)}}if(!h||j!=l){while(ig;--h){if(h<=f.first){return f.first}var i=Ya(f,h-1),j=i.stateAfter;if(j&&(!c||h+(j instanceof ob?j.lookAhead:0)<=f.modeFrontier)){return h}var k=M(i.text,null,a.options.tabSize);if(e==null||d>k){e=h-1;d=k}}return e}function Bb(a,b){a.modeFrontier=Math.min(a.modeFrontier,b);if(a.highlightFrontierc;d--){var e=Ya(a,d).stateAfter;if(e&&(!(e instanceof ob)||d+e.lookAhead=b:f.to>b);(d||(d=[])).push(new Gb(g,f.from,i?null:f.to))}}}return d}function Lb(a,b,c){var d;if(a){for(var e=0;e=b:f.to>b);if(h||f.from==b&&g.type=="bookmark"&&(!c||f.marker.insertLeft)){var i=f.from==null||(g.inclusiveLeft?f.from<=b:f.from0&&h){for(var u=0;u0){continue}var k=[i,1],l=fb(j.from,h.from),m=fb(j.to,h.to);if(l<0||!g.inclusiveLeft&&!l){k.push({from:j.from,to:h.from})}if(m>0||!g.inclusiveRight&&!m){k.push({from:h.to,to:j.to})}e.splice.apply(e,k);i+=k.length-3}}return e}function Pb(a){var b=a.markedSpans;if(!b){return}for(var c=0;cb)&&(!d||Tb(d,f.marker)<0)){d=f.marker}}}return d}function Yb(a,b,c,d,e){var f=Ya(a,b);var g=Db&&f.markedSpans;if(g){for(var h=0;h=0&&l<=0||k<=0&&l>=0){continue}if(k<=0&&(i.marker.inclusiveRight&&e.inclusiveLeft?fb(j.to,c)>=0:fb(j.to,c)>0)||k>=0&&(i.marker.inclusiveRight&&e.inclusiveLeft?fb(j.from,d)<=0:fb(j.from,d)<0)){return true}}}}function Zb(a){var b;while(b=Vb(a)){a=b.find(-1,true).line}return a}function $b(a){var b;while(b=Wb(a)){a=b.find(1,true).line}return a}function _b(a){var b,c;while(b=Wb(a)){a=b.find(1,true).line;(c||(c=[])).push(a)}return c}function ac(a,b){var c=Ya(a,b),d=Zb(c);if(c==d){return b}return ab(d)}function bc(a,b){if(b>a.lastLine()){return b}var c=Ya(a,b),d;if(!cc(a,c)){return b}while(d=Wb(c)){c=d.find(1,true).line}return ab(c)+1}function cc(a,b){var c=Db&&b.markedSpans;if(c){for(var d=void 0,e=0;eb.maxLineLength){b.maxLineLength=c;b.maxLine=a}})}var hc=function(a,b,c){this.text=a;Qb(this,b);this.height=c?c(this):1};hc.prototype.lineNo=function(){return ab(this)};va(hc);function ic(a,b,c,d){a.text=b;if(a.stateAfter){a.stateAfter=null}if(a.styles){a.styles=null}if(a.order!=null){a.order=null}Pb(a);Qb(a,c);var e=d?d(a):1;if(e!=a.height){_a(a,e)}}function jc(a){a.parent=null;Pb(a)}var kc={},lc={};function mc(a,b){if(!a||/^\s*$/.test(a)){return null}var c=b.addModeClass?lc:kc;return c[a]||(c[a]=a.replace(/\S+/g,"cm-$&"))}function nc(a,b){var c=D("span",null,null,i?"padding-right: .1px":null);var d={pre:D("pre",[c],"CodeMirror-line"),content:c,col:0,pos:0,cm:a,trailingSpace:false,splitSpaces:a.getOption("lineWrapping")};b.measure={};for(var e=0;e<=(b.rest?b.rest.length:0);e++){var f=e?b.rest[e-1]:b.line,g=void 0;d.pos=0;d.addToken=pc;if(Ga(a.display.measure)&&(g=ma(f,a.doc.direction))){d.addToken=rc(d.addToken,g)}d.map=[];var h=b!=a.display.externalMeasured&&ab(f);tc(f,d,rb(a,f,h));if(f.styleClasses){if(f.styleClasses.bgClass){d.bgClass=I(f.styleClasses.bgClass,d.bgClass||"")}if(f.styleClasses.textClass){d.textClass=I(f.styleClasses.textClass,d.textClass||"")}}if(d.map.length==0){d.map.push(0,0,d.content.appendChild(Ea(a.display.measure)))}if(e==0){b.measure.map=d.map;b.measure.cache={}}else{(b.measure.maps||(b.measure.maps=[])).push(d.map);(b.measure.caches||(b.measure.caches=[])).push({})}}if(i){var j=d.content.lastChild;if(/\bcm-tab\b/.test(j.className)||j.querySelector&&j.querySelector(".cm-tab")){d.content.className="cm-tab-wrap-hack"}}ra(a,"renderLine",a,b.line,d.pre);if(d.pre.className){d.textClass=I(d.pre.className,d.textClass||"")}return d}function oc(a){var b=C("span","•","cm-invalidchar");b.title="\\u"+a.charCodeAt(0).toString(16);b.setAttribute("aria-label",b.title);return b}function pc(a,b,c,d,e,f,i){if(!b){return}var j=a.splitSpaces?qc(b,a.trailingSpace):b;var k=a.cm.state.specialChars,l=false;var m;if(!k.test(b)){a.col+=b.length;m=document.createTextNode(j);a.map.push(a.pos,a.pos+b.length,m);if(g&&h<9){l=true}a.pos+=b.length}else{m=document.createDocumentFragment();var n=0;while(true){k.lastIndex=n;var o=k.exec(b);var p=o?o.index-n:b.length-n;if(p){var q=document.createTextNode(j.slice(n,n+p));if(g&&h<9){m.appendChild(C("span",[q]))}else{m.appendChild(q)}a.map.push(a.pos,a.pos+p,q);a.col+=p;a.pos+=p}if(!o){break}n+=p+1;var r=void 0;if(o[0]=="\t"){var s=a.cm.options.tabSize,t=s-a.col%s;r=m.appendChild(C("span",W(t),"cm-tab"));r.setAttribute("role","presentation");r.setAttribute("cm-text","\t");a.col+=t}else if(o[0]=="\r"||o[0]=="\n"){r=m.appendChild(C("span",o[0]=="\r"?"␍":"␤","cm-invalidchar"));r.setAttribute("cm-text",o[0]);a.col+=1}else{r=a.cm.options.specialCharPlaceholder(o[0]);r.setAttribute("cm-text",o[0]);if(g&&h<9){m.appendChild(C("span",[r]))}else{m.appendChild(r)}a.col+=1}a.map.push(a.pos,a.pos+1,r);a.pos++}}a.trailingSpace=j.charCodeAt(b.length-1)==32 ;if(c||d||e||l||f){var u=c||"";if(d){u+=d}if(e){u+=e}var v=C("span",[m],u,f);if(i){for(var w in i){if(i.hasOwnProperty(w)&&w!="style"&&w!="class"){v.setAttribute(w,i[w])}}}return a.content.appendChild(v)}a.content.appendChild(m)}function qc(a,b){if(a.length>1&&!/ /.test(a)){return a}var c=b,d="";for(var e=0;ej&&l.from<=j){break}}if(l.to>=k){return a(c,d,e,f,g,h,i)}a(c,d.slice(0,l.to-j),e,f,null,h,i);f=null;d=d.slice(l.to-j);j=l.to}}}function sc(a,b,c,d){var e=!d&&c.widgetNode;if(e){a.map.push(a.pos,a.pos+b,e)}if(!d&&a.cm.display.input.needsContentAttribute){if(!e){e=a.content.appendChild(document.createElement("span"))}e.setAttribute("cm-marker",c.id)}if(e){a.cm.display.input.setUneditable(e);a.content.appendChild(e)}a.pos+=b;a.trailingSpace=false}function tc(a,b,c){var d=a.markedSpans,e=a.text,f=0;if(!d){for(var g=1;gi||x.collapsed&&w.to==i&&w.from==i)){if(w.to!=null&&w.to!=i&&n>w.to){n=w.to;p=""}if(x.className){o+=" "+x.className}if(x.css){m=(m?m+";":"")+x.css}if(x.startStyle&&w.from==i){q+=" "+x.startStyle}if(x.endStyle&&w.to==n){(u||(u=[])).push(x.endStyle,w.to)}if(x.title){(s||(s={})).title=x.title}if(x.attributes){for(var y in x.attributes){(s||(s={}))[y]=x.attributes[y]}}if(x.collapsed&&(!r||Tb(r.marker,x)<0)){r=w}}else if(w.from>i&&n>w.from){n=w.from}}if(u){for(var z=0;z=h){break}var B=Math.min(h,n);while(true){if(k){var C=i+k.length;if(!r){var D=C>B?k.slice(0,B-i):k;b.addToken(b,D,l?l+o:o,q,i+D.length==n?p:"",m,s)}if(C>=B){k=k.slice(B-i);i=B;break}i=C;q=""}k=e.slice(f,f=c[j++]);l=mc(c[j++],b.cm.options)}}}function uc(a,b,c){this.line=b;this.rest=_b(b);this.size=this.rest?ab(X(this.rest))-c+1:1;this.node=this.text=null;this.hidden=cc(a,b)}function vc(a,b,c){var d=[],e;for(var f=b;f2){f.push((i.bottom+j.top)/2-c.top)}}}f.push(c.bottom-c.top)}}function Yc(a,b,c){if(a.line==b){return{map:a.measure.map,cache:a.measure.cache}}for(var d=0;dc){return{map:a.measure.maps[e],cache:a.measure.caches[e],before:true}}}}function Zc(a,b){b=Zb(b);var c=ab(b);var d=a.display.externalMeasured=new uc(a.doc,b,c);d.lineN=c;var e=d.built=nc(a,d);d.text=e.pre;B(a.display.lineMeasure,e.pre);return d}function $c(a,b,c,d){return bd(a,ad(a,b),c,d)}function _c(a,b){if(b>=a.display.viewFrom&&b=c.lineN&&bb){f=i-h;e=f-1;if(b>=i){g="right"}}if(e!=null){d=a[j+2];if(h==i&&c==(d.insertLeft?"left":"right")){g=c}if(c=="left"&&e==0){while(j&&a[j-2]==a[j-3]&&a[j-1].insertLeft){d=a[(j-=3)+2];g="left"}}if(c=="right"&&e==i-h){while(j=0;e--){if((c=a[e]).left!=c.right){break}}}return c}function fd(a,b,c,d){var e=dd(b.map,c,d);var f=e.node,i=e.start,j=e.end,k=e.collapse;var l;if(f.nodeType==3){for(var m=0;m<4;m++){while(i&&fa(b.line.text.charAt(e.coverStart+i))){--i}while(e.coverStart+j0){k=d="right"}var n;if(a.options.lineWrapping&&(n=f.getClientRects()).length>1){l=n[d=="right"?n.length-1:0]}else{l=f.getBoundingClientRect()}}if(g&&h<9&&!i&&(!l||!l.left&&!l.right)){var o=f.parentNode.getClientRects()[0];if(o){l={left:o.left,right:o.left+Cd(a.display),top:o.top,bottom:o.bottom}}else{l=cd}}var p=l.top-b.rect.top,q=l.bottom-b.rect.top;var r=(p+q)/2;var s=b.view.measure.heights;var t=0;for(;t=d.text.length){i=d.text.length;j="before"}else if(i<=0){i=0;j="after"}if(!h){return g(j=="before"?i-1:i,j=="before")}function k(a,b,c){var d=h[b],e=d.level==1;return g(c?a-1:a,e!=c)}var l=ka(h,i,j);var m=ja;var n=k(i,l,j=="before");if(m!=null){n.other=k(i,m,j!="before")}return n}function rd(a,b){var c=0;b=lb(a.doc,b);if(!a.options.lineWrapping){c=Cd(a.display)*b.ch}var d=Ya(a.doc,b.line);var e=ec(d)+Rc(a.display);return{left:c,right:c,top:e,bottom:e+d.height}}function sd(a,b,c,d,e){var f=eb(a,b,c);f.xRel=e;if(d){f.outside=d}return f}function td(a,b,c){var d=a.doc;c+=a.display.viewOffset;if(c<0){return sd(d.first,0,null,-1,-1)}var e=bb(d,c),f=d.first+d.size-1;if(e>f){return sd(d.first+d.size-1,Ya(d,f).text.length,null,1,1)}if(b<0){b=0}var g=Ya(d,e);for(;;){var h=xd(a,g,e,b,c);var i=Xb(g,h.ch+(h.xRel>0||h.outside>0?1:0));if(!i){return h}var j=i.find(1);if(j.line==e){return j}g=Ya(d,e=j.line)}}function ud(a,b,c,d){d-=md(b);var e=b.text.length;var f=ha(function(b){return bd(a,c,b-1).bottom<=d},e,0);e=ha(function(b){return bd(a,c,b).top>d},f,e);return{begin:f,end:e}}function vd(a,b,c,d){if(!c){c=ad(a,b)}var e=nd(a,b,bd(a,c,d),"line").top;return ud(a,b,c,e)}function wd(a,b,c,d){return a.bottom<=c?false:a.top>c?true:(d?a.left:a.right)>b}function xd(a,b,c,d,e){e-=ec(b);var f=ad(a,b);var g=md(b);var h=0,i=b.text.length,j=true;var k=ma(b,a.doc.direction);if(k){var l=(a.options.lineWrapping?zd:yd)(a,b,c,f,k,d,e);j=l.level!=1;h=j?l.from:l.to-1;i=j?l.to:l.from-1}var m=null,n=null;var o=ha(function(b){var c=bd(a,f,b);c.top+=g;c.bottom+=g;if(!wd(c,d,e,false)){return false}if(c.top<=e&&c.left<=d){m=b;n=c}return true},h,i);var p,q,r=false;if(n){var s=d-n.left=u.bottom?1:0}o=ga(b.text,o,1);return sd(c,o,q,r,d-p)}function yd(a,b,c,d,e,f,g){var h=ha(function(h){var i=e[h],j=i.level!=1;return wd(qd(a,eb(c,j?i.to:i.from,j?"before":"after"),"line",b,d),f,g,true)},0,e.length-1);var i=e[h];if(h>0){var j=i.level!=1;var k=qd(a,eb(c,j?i.from:i.to,j?"after":"before"),"line",b,d);if(wd(k,f,g,true)&&k.top>g){i=e[h-1]}}return i}function zd(a,b,c,d,e,f,g){var h=ud(a,b,d,g);var i=h.begin;var j=h.end;if(/\s/.test(b.text.charAt(j-1))){j--}var k=null,l=null;for(var m=0;m=j||n.to<=i){continue}var o=n.level!=1;var p=bd(a,d,o?Math.min(j,n.to)-1:Math.max(i,n.from)).right;var q=pq){k=n;l=q}}if(!k){k=e[e.length-1]}if(k.fromj){k={from:k.from,to:j,level:k.level}}return k}var Ad;function Bd(a){if(a.cachedTextHeight!=null){return a.cachedTextHeight}if(Ad==null){Ad=C("pre",null,"CodeMirror-line-like");for(var b=0;b<49;++b){Ad.appendChild(document.createTextNode("x"));Ad.appendChild(C("br"))}Ad.appendChild(document.createTextNode("x"))}B(a.measure,Ad);var c=Ad.offsetHeight/50;if(c>3){a.cachedTextHeight=c}A(a.measure);return c||1}function Cd(a){if(a.cachedCharWidth!=null){return a.cachedCharWidth}var b=C("span","xxxxxxxxxx");var c=C("pre",[b],"CodeMirror-line-like");B(a.measure,c);var d=b.getBoundingClientRect(),e=(d.right-d.left)/10;if(e>2){a.cachedCharWidth=e}return e||10}function Dd(a){var b=a.display,c={},d={};var e=b.gutters.clientLeft;for(var f=b.gutters.firstChild,g=0;f;f=f.nextSibling,++g){var h=a.display.gutterSpecs[g].className;c[h]=f.offsetLeft+f.clientLeft+e;d[h]=f.clientWidth}return{fixedPos:Ed(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function Ed(a){return a.scroller.getBoundingClientRect().left-a.sizer.getBoundingClientRect().left}function Fd(a){var b=Bd(a.display),c=a.options.lineWrapping;var d=c&&Math.max(5,a.display.scroller.clientWidth/Cd(a.display)-3);return function(e){if(cc(a.doc,e)){return 0}var f=0;if(e.widgets){for(var g=0;g0&&(j=Ya(a.doc,i.line).text).length==i.ch){var k=M(j,j.length,a.options.tabSize)-j.length;i=eb(i.line,Math.max(0,Math.round((f-Tc(a.display).left)/Cd(a.display))-k))}return i}function Id(a,b){if(b>=a.display.viewTo){return null}b-=a.display.viewFrom;if(b<0){return null}var c=a.display.view;for(var d=0;db)){e.updateLineNumbers=b}a.curOp.viewChanged=true;if(b>=e.viewTo){if(Db&&ac(a.doc,b)e.viewFrom){Ld(a)}else{e.viewFrom+=d;e.viewTo+=d}}else if(b<=e.viewFrom&&c>=e.viewTo){Ld(a)}else if(b<=e.viewFrom){var f=Md(a,c,c+d,1);if(f){e.view=e.view.slice(f.index);e.viewFrom=f.lineN;e.viewTo+=d}else{Ld(a)}}else if(c>=e.viewTo){var g=Md(a,b,b,-1);if(g){e.view=e.view.slice(0,g.index);e.viewTo=g.lineN}else{Ld(a)}}else{var h=Md(a,b,b,-1);var i=Md(a,c,c+d,1);if(h&&i){e.view=e.view.slice(0,h.index).concat(vc(a,h.lineN,i.lineN)).concat(e.view.slice(i.index));e.viewTo+=d}else{Ld(a)}}var j=e.externalMeasured;if(j){if(c=e.lineN&&b=d.viewTo){return}var f=d.view[Id(a,b)];if(f.node==null){return}var g=f.changes||(f.changes=[]);if(O(g,c)==-1){g.push(c)}}function Ld(a){a.display.viewFrom=a.display.viewTo=a.doc.first;a.display.view=[];a.display.viewOffset=0}function Md(a,b,c,d){var e=Id(a,b),f,g=a.display.view;if(!Db||c==a.doc.first+a.doc.size){return{index:e,lineN:c}}var h=a.display.viewFrom;for(var i=0;i0){if(e==g.length-1){return null}f=h+g[e].size-b;e++}else{f=h-b}b+=f;c+=f}while(ac(a.doc,c)!=c){if(e==(d<0?0:g.length-1)){return null}c+=d*g[e-(d<0?1:0)].size;e+=d}return{index:e,lineN:c}}function Nd(a,b,c){var d=a.display,e=d.view;if(e.length==0||b>=d.viewTo||c<=d.viewFrom){d.view=vc(a,b,c);d.viewFrom=b}else{if(d.viewFrom>b){d.view=vc(a,b,d.viewFrom).concat(d.view)}else if(d.viewFromc){d.view=d.view.slice(0,Id(a,c))}}d.viewTo=c}function Od(a){var b=a.display.view,c=0;for(var d=0;d=a.display.viewTo||h.to().line0){b.blinker=setInterval(function(){return b.cursorDiv.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate)}else if(a.options.cursorBlinkRate<0){b.cursorDiv.style.visibility="hidden"}}function Vd(a){if(!a.state.focused){a.display.input.focus();Xd(a)}}function Wd(a){a.state.delayingBlurEvent=true;setTimeout(function(){if(a.state.delayingBlurEvent){a.state.delayingBlurEvent=false;Yd(a)}},100)}function Xd(a,b){if(a.state.delayingBlurEvent){a.state.delayingBlurEvent=false}if(a.options.readOnly=="nocursor"){return}if(!a.state.focused){ra(a,"focus",a,b);a.state.focused=true;H(a.display.wrapper,"CodeMirror-focused");if(!a.curOp&&a.display.selForContextMenu!=a.doc.sel){a.display.input.reset();if(i){setTimeout(function(){return a.display.input.reset(true)},20)}}a.display.input.receivedFocus()}Ud(a)}function Yd(a,b){if(a.state.delayingBlurEvent){return}if(a.state.focused){ra(a,"blur",a,b);a.state.focused=false;z(a.display.wrapper,"CodeMirror-focused")}clearInterval(a.display.blinker);setTimeout(function(){if(!a.state.focused){a.display.shift=false}},150)}function Zd(a){var b=a.display;var c=b.lineDiv.offsetTop;for(var d=0;d.005||m<-.005){_a(e.line,i);$d(e.line);if(e.rest){for(var n=0;na.display.sizerWidth){var o=Math.ceil(j/Cd(a.display));if(o>a.display.maxLineLength){a.display.maxLineLength=o;a.display.maxLine=e.line;a.display.maxLineChanged=true}}}}function $d(a){if(a.widgets){for(var b=0;b=g){f=bb(b,ec(Ya(b,i))-a.wrapper.clientHeight);g=i}}return{from:f,to:Math.max(g,f+1)}}function ae(a,b){if(sa(a,"scrollCursorIntoView")){return}var c=a.display,d=c.sizer.getBoundingClientRect(),e=null;if(b.top+d.top<0){e=true}else if(b.bottom+d.top>(window.innerHeight||document.documentElement.clientHeight)){e=false}if(e!=null&&!o){var f=C("div","​",null,"position: absolute;\n top: "+(b.top-c.viewOffset-Rc(a.display))+"px;\n height: "+(b.bottom-b.top+Uc(a)+c.barHeight)+"px;\n left: "+b.left+"px; width: "+Math.max(2,b.right-b.left)+"px;");a.display.lineSpace.appendChild(f);f.scrollIntoView(e);a.display.lineSpace.removeChild(f)}}function be(a,b,c,d){if(d==null){d=0}var e;if(!a.options.lineWrapping&&b==c){b=b.ch?eb(b.line,b.sticky=="before"?b.ch-1:b.ch,"after"):b;c=b.sticky=="before"?eb(b.line,b.ch+1,"before"):b}for(var f=0;f<5;f++){var g=false;var h=qd(a,b);var i=!c||c==b?h:qd(a,c);e={left:Math.min(h.left,i.left),top:Math.min(h.top,i.top)-d,right:Math.max(h.left,i.left),bottom:Math.max(h.bottom,i.bottom)+d};var j=de(a,e);var k=a.doc.scrollTop,l=a.doc.scrollLeft;if(j.scrollTop!=null){ke(a,j.scrollTop);if(Math.abs(a.doc.scrollTop-k)>1){g=true}}if(j.scrollLeft!=null){me(a,j.scrollLeft);if(Math.abs(a.doc.scrollLeft-l)>1){g=true}}if(!g){break}}return e}function ce(a,b){var c=de(a,b);if(c.scrollTop!=null){ke(a,c.scrollTop)}if(c.scrollLeft!=null){me(a,c.scrollLeft)}}function de(a,b){var c=a.display,d=Bd(a.display);if(b.top<0){b.top=0}var e=a.curOp&&a.curOp.scrollTop!=null?a.curOp.scrollTop:c.scroller.scrollTop;var f=Wc(a),g={};if(b.bottom-b.top>f){b.bottom=b.top+f}var h=a.doc.height+Sc(c);var i=b.toph-d;if(b.tope+f){var k=Math.min(b.top,(j?h:b.bottom)-f);if(k!=e){g.scrollTop=k}}var l=a.curOp&&a.curOp.scrollLeft!=null?a.curOp.scrollLeft:c.scroller.scrollLeft;var m=Vc(a)-(a.options.fixedGutter?c.gutters.offsetWidth:0);var n=b.right-b.left>m;if(n){b.right=b.left+m}if(b.left<10){g.scrollLeft=0}else if(b.leftm+l-3){g.scrollLeft=b.right+(n?0:10)-m}return g}function ee(a,b){if(b==null){return}ie(a);a.curOp.scrollTop=(a.curOp.scrollTop==null?a.doc.scrollTop:a.curOp.scrollTop)+b}function fe(a){ie(a);var b=a.getCursor();a.curOp.scrollToPos={from:b,to:b,margin:a.options.cursorScrollMargin}}function ge(a,b,c){if(b!=null||c!=null){ie(a)}if(b!=null){a.curOp.scrollLeft=b}if(c!=null){a.curOp.scrollTop=c}}function he(a,b){ie(a);a.curOp.scrollToPos=b}function ie(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=rd(a,b.from),d=rd(a,b.to);je(a,c,d,b.margin)}}function je(a,b,c,d){var e=de(a,{left:Math.min(b.left,c.left),top:Math.min(b.top,c.top)-d,right:Math.max(b.right,c.right),bottom:Math.max(b.bottom,c.bottom)+d});ge(a,e.scrollLeft,e.scrollTop)}function ke(a,b){if(Math.abs(a.doc.scrollTop-b)<2){return}if(!c){Pe(a,{top:b})}le(a,b,true);if(c){Pe(a)}He(a,100)}function le(a,b,c){b=Math.max(0,Math.min(a.display.scroller.scrollHeight-a.display.scroller.clientHeight,b));if(a.display.scroller.scrollTop==b&&!c){return}a.doc.scrollTop=b;a.display.scrollbars.setScrollTop(b);if(a.display.scroller.scrollTop!=b){a.display.scroller.scrollTop=b}}function me(a,b,c,d){b=Math.max(0,Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth));if((c?b==a.doc.scrollLeft:Math.abs(a.doc.scrollLeft-b)<2)&&!d){return}a.doc.scrollLeft=b;Te(a);if(a.display.scroller.scrollLeft!=b){a.display.scroller.scrollLeft=b}a.display.scrollbars.setScrollLeft(b)}function ne(a){var b=a.display,c=b.gutters.offsetWidth;var d=Math.round(a.doc.height+Sc(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+Uc(a)+b.barHeight,nativeBarWidth:b.nativeBarWidth,gutterWidth:c}}var oe=function(a,b,c){this.cm=c;var d=this.vert=C("div",[C("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar");var e=this.horiz=C("div",[C("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");d.tabIndex=e.tabIndex=-1;a(d);a(e);oa(d,"scroll",function(){if(d.clientHeight){b(d.scrollTop,"vertical")}});oa(e,"scroll",function(){if(e.clientWidth){b(e.scrollLeft,"horizontal")}});this.checkedZeroWidth=false;if(g&&h<8){this.horiz.style.minHeight=this.vert.style.minWidth="18px"}};oe.prototype.update=function(a){var b=a.scrollWidth>a.clientWidth+1;var c=a.scrollHeight>a.clientHeight+1;var d=a.nativeBarWidth;if(c){this.vert.style.display="block";this.vert.style.bottom=b?d+"px":"0";var e=a.viewHeight-(b?d:0);this.vert.firstChild.style.height=Math.max(0,a.scrollHeight-a.clientHeight+e)+"px"}else{this.vert.style.display="";this.vert.firstChild.style.height="0"}if(b){this.horiz.style.display="block";this.horiz.style.right=c?d+"px":"0";this.horiz.style.left=a.barLeft+"px";var f=a.viewWidth-a.barLeft-(c?d:0);this.horiz.firstChild.style.width=Math.max(0,a.scrollWidth-a.clientWidth+f)+"px"}else{this.horiz.style.display="";this.horiz.firstChild.style.width="0"}if(!this.checkedZeroWidth&&a.clientHeight>0){if(d==0){this.zeroWidthHack()}this.checkedZeroWidth=true}return{ right:c?d:0,bottom:b?d:0}};oe.prototype.setScrollLeft=function(a){if(this.horiz.scrollLeft!=a){this.horiz.scrollLeft=a}if(this.disableHoriz){this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")}};oe.prototype.setScrollTop=function(a){if(this.vert.scrollTop!=a){this.vert.scrollTop=a}if(this.disableVert){this.enableZeroWidthBar(this.vert,this.disableVert,"vert")}};oe.prototype.zeroWidthHack=function(){var a=s&&!n?"12px":"18px";this.horiz.style.height=this.vert.style.width=a;this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none";this.disableHoriz=new N;this.disableVert=new N};oe.prototype.enableZeroWidthBar=function(a,b,c){a.style.pointerEvents="auto";function d(){var e=a.getBoundingClientRect();var f=c=="vert"?document.elementFromPoint(e.right-1,(e.top+e.bottom)/2):document.elementFromPoint((e.right+e.left)/2,e.bottom-1);if(f!=a){a.style.pointerEvents="none"}else{b.set(1e3,d)}}b.set(1e3,d)};oe.prototype.clear=function(){var a=this.horiz.parentNode;a.removeChild(this.horiz);a.removeChild(this.vert)};var pe=function(){};pe.prototype.update=function(){return{bottom:0,right:0}};pe.prototype.setScrollLeft=function(){};pe.prototype.setScrollTop=function(){};pe.prototype.clear=function(){};function qe(a,b){if(!b){b=ne(a)}var c=a.display.barWidth,d=a.display.barHeight;re(a,b);for(var e=0;e<4&&c!=a.display.barWidth||d!=a.display.barHeight;e++){if(c!=a.display.barWidth&&a.options.lineWrapping){Zd(a)}re(a,ne(a));c=a.display.barWidth;d=a.display.barHeight}}function re(a,b){var c=a.display;var 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";if(d.right&&d.bottom){c.scrollbarFiller.style.display="block";c.scrollbarFiller.style.height=d.bottom+"px";c.scrollbarFiller.style.width=d.right+"px"}else{c.scrollbarFiller.style.display=""}if(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"}else{c.gutterFiller.style.display=""}}var se={"native":oe,"null":pe};function te(a){if(a.display.scrollbars){a.display.scrollbars.clear();if(a.display.scrollbars.addClass){z(a.display.wrapper,a.display.scrollbars.addClass)}}a.display.scrollbars=new se[a.options.scrollbarStyle](function(b){a.display.wrapper.insertBefore(b,a.display.scrollbarFiller);oa(b,"mousedown",function(){if(a.state.focused){setTimeout(function(){return a.display.input.focus()},0)}});b.setAttribute("cm-not-content","true")},function(b,c){if(c=="horizontal"){me(a,b)}else{ke(a,b)}},a);if(a.display.scrollbars.addClass){H(a.display.wrapper,a.display.scrollbars.addClass)}}var ue=0;function ve(a){a.curOp={cm:a,viewChanged:false,startHeight:a.doc.height,forceUpdate:false,updateInput:0,typing:false,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:false,updateMaxLine:false,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:false,id:++ue};xc(a.curOp)}function we(a){var b=a.curOp;if(b){zc(b,function(a){for(var b=0;b=c.viewTo)||c.maxLineChanged&&b.options.lineWrapping;a.update=a.mustUpdate&&new Je(b,a.mustUpdate&&{top:a.scrollTop,ensure:a.scrollToPos},a.forceUpdate)}function ze(a){a.updatedDisplay=a.mustUpdate&&Ne(a.cm,a.update)}function Ae(a){var b=a.cm,c=b.display;if(a.updatedDisplay){Zd(b)}a.barMeasure=ne(b);if(c.maxLineChanged&&!b.options.lineWrapping){a.adjustWidthTo=$c(b,c.maxLine,c.maxLine.text.length).left+3;b.display.sizerWidth=a.adjustWidthTo;a.barMeasure.scrollWidth=Math.max(c.scroller.clientWidth,c.sizer.offsetLeft+a.adjustWidthTo+Uc(b)+b.display.barWidth);a.maxScrollLeft=Math.max(0,c.sizer.offsetLeft+a.adjustWidthTo-Vc(b))}if(a.updatedDisplay||a.selectionChanged){a.preparedSelection=c.input.prepareSelection()}}function Be(a){var b=a.cm;if(a.adjustWidthTo!=null){b.display.sizer.style.minWidth=a.adjustWidthTo+"px";if(a.maxScrollLeft=a.display.viewTo){return}var c=+new Date+a.options.workTime;var d=sb(a,b.highlightFrontier);var e=[];b.iter(d.line,Math.min(b.first+b.size,a.display.viewTo+500),function(f){if(d.line>=a.display.viewFrom){var g=f.styles;var h=f.text.length>a.options.maxHighlightLength?Ua(b.mode,d.state):null;var i=qb(a,f,d,true);if(h){d.state=h}f.styles=i.styles;var j=f.styleClasses,k=i.classes;if(k){f.styleClasses=k}else if(j){f.styleClasses=null}var l=!g||g.length!=f.styles.length||j!=k&&(!j||!k||j.bgClass!=k.bgClass||j.textClass!=k.textClass);for(var m=0;!l&&mc){He(a,a.options.workDelay);return true}});b.highlightFrontier=d.line;b.modeFrontier=Math.max(b.modeFrontier,d.line);if(e.length){De(a,function(){for(var b=0;b=c.viewFrom&&b.visible.to<=c.viewTo&&(c.updateLineNumbers==null||c.updateLineNumbers>=c.viewTo)&&c.renderedView==c.view&&Od(a)==0){return false}if(Ue(a)){Ld(a);b.dims=Dd(a)}var e=d.first+d.size;var f=Math.max(b.visible.from-a.options.viewportMargin,d.first);var g=Math.min(e,b.visible.to+a.options.viewportMargin);if(c.viewFromg&&c.viewTo-g<20){g=Math.min(e,c.viewTo)}if(Db){f=ac(a.doc,f);g=bc(a.doc,g)}var h=f!=c.viewFrom||g!=c.viewTo||c.lastWrapHeight!=b.wrapperHeight||c.lastWrapWidth!=b.wrapperWidth;Nd(a,f,g);c.viewOffset=ec(Ya(a.doc,c.viewFrom));a.display.mover.style.top=c.viewOffset+"px";var i=Od(a);if(!h&&i==0&&!b.force&&c.renderedView==c.view&&(c.updateLineNumbers==null||c.updateLineNumbers>=c.viewTo)){return false}var j=Le(a);if(i>4){c.lineDiv.style.display="none"}Qe(a,c.updateLineNumbers,b.dims);if(i>4){c.lineDiv.style.display=""}c.renderedView=c.view;Me(j);A(c.cursorDiv);A(c.selectionDiv);c.gutters.style.height=c.sizer.style.minHeight=0;if(h){c.lastWrapHeight=b.wrapperHeight;c.lastWrapWidth=b.wrapperWidth;He(a,400)}c.updateLineNumbers=null;return true}function Oe(a,b){var c=b.viewport;for(var d=true;;d=false){if(!d||!a.options.lineWrapping||b.oldDisplayWidth==Vc(a)){if(c&&c.top!=null){c={top:Math.min(a.doc.height+Sc(a.display)-Wc(a),c.top)}}b.visible=_d(a.display,a.doc,c);if(b.visible.from>=a.display.viewFrom&&b.visible.to<=a.display.viewTo){break}}else if(d){b.visible=_d(a.display,a.doc,c)}if(!Ne(a,b)){break}Zd(a);var e=ne(a);Pd(a);qe(a,e);Se(a,e);b.force=false}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 Pe(a,b){var c=new Je(a,b);if(Ne(a,c)){Zd(a);Oe(a,c);var d=ne(a);Pd(a);qe(a,d);Se(a,d);c.finish()}}function Qe(a,b,c){var d=a.display,e=a.options.lineNumbers;var f=d.lineDiv,g=f.firstChild;function h(b){var c=b.nextSibling;if(i&&s&&a.display.currentWheelTarget==b){b.style.display="none"}else{b.parentNode.removeChild(b)}return c}var j=d.view,k=d.viewFrom;for(var l=0;l-1){o=false}Dc(a,m,k,c)}if(o){A(m.lineNumber);m.lineNumber.appendChild(document.createTextNode(db(a.options,k)))}g=m.node.nextSibling}k+=m.size}while(g){g=h(g)}}function Re(a){var b=a.gutters.offsetWidth;a.sizer.style.marginLeft=b+"px"}function Se(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+Uc(a)+"px"}function Te(a){var b=a.display,c=b.view;if(!b.alignWidgets&&(!b.gutters.firstChild||!a.options.fixedGutter)){return}var d=Ed(b)-b.scroller.scrollLeft+a.doc.scrollLeft;var e=b.gutters.offsetWidth,f=d+"px";for(var g=0;gh.clientWidth;var k=h.scrollHeight>h.clientHeight;if(!(e&&j||f&&k)){return}if(f&&s&&i){a:for(var m=b.target,n=g.view;m!=h;m=m.parentNode){for(var o=0;o=0&&fb(a,d.to())<=0){return c}}return-1};var df=function(a,b){this.anchor=a;this.head=b};df.prototype.from=function(){return jb(this.anchor,this.head)};df.prototype.to=function(){return ib(this.anchor,this.head)};df.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function ef(a,b,c){var d=a&&a.options.selectionsMayTouch;var e=b[c];b.sort(function(a,b){return fb(a.from(),b.from())});c=O(b,e);for(var f=1;f0:i>=0){var j=jb(h.from(),g.from()),k=ib(h.to(),g.to());var l=h.empty()?g.from()==g.head:h.from()==h.head;if(f<=c){--c}b.splice(--f,2,new df(l?k:j,l?j:k))}}return new cf(b,c)}function ff(a,b){return new cf([new df(a,b||a)],0)}function gf(a){if(!a.text){return a.to}return eb(a.from.line+a.text.length-1,X(a.text).length+(a.text.length==1?a.from.ch:0))}function hf(a,b){if(fb(a,b.from)<0){return a}if(fb(a,b.to)<=0){return gf(b)}var c=a.line+b.text.length-(b.to.line-b.from.line)-1,d=a.ch;if(a.line==b.to.line){d+=gf(b).ch-b.to.ch}return eb(c,d)}function jf(a,b){var c=[];for(var d=0;d1){a.remove(h.line+1,o-1)}a.insert(h.line+1,r)}Bc(a,"change",a,b)}function qf(a,b,c){function d(a,e,f){if(a.linked){for(var g=0;g1&&!a.done[a.done.length-2].ranges){a.done.pop();return X(a.done)}}function yf(a,b,c,d){var e=a.history;e.undone.length=0;var f=+new Date,g;var h;if((e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&(b.origin.charAt(0)=="+"&&e.lastModTime>f-(a.cm?a.cm.options.historyEventDelay:500)||b.origin.charAt(0)=="*"))&&(g=xf(e,e.lastOp==d))){h=X(g.changes);if(fb(b.from,b.to)==0&&fb(b.from,h.to)==0){h.to=gf(b)}else{g.changes.push(vf(a,b))}}else{var i=X(e.done);if(!i||!i.ranges){Bf(a.sel,e.done)}g={changes:[vf(a,b)],generation:e.generation};e.done.push(g);while(e.done.length>e.undoDepth){e.done.shift();if(!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;if(!h){ra(a,"historyAdded")}}function zf(a,b,c,d){var e=b.charAt(0);return e=="*"||e=="+"&&c.ranges.length==d.ranges.length&&c.somethingSelected()==d.somethingSelected()&&new Date-a.history.lastSelTime<=(a.cm?a.cm.options.historyEventDelay:500)}function Af(a,b,c,d){var e=a.history,f=d&&d.origin;if(c==e.lastSelOp||f&&e.lastSelOrigin==f&&(e.lastModTime==e.lastSelTime&&e.lastOrigin==f||zf(a,f,X(e.done),b))){e.done[e.done.length-1]=b}else{Bf(b,e.done)}e.lastSelTime=+new Date;e.lastSelOrigin=f;e.lastSelOp=c;if(d&&d.clearRedo!==false){wf(e.undone)}}function Bf(a,b){var c=X(b);if(!(c&&c.ranges&&c.equals(a))){b.push(a)}}function Cf(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(c){if(c.markedSpans){(e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans}++f})}function Df(a){if(!a){return null}var b;for(var c=0;c-1){X(h)[l]=j[l];delete j[l]}}}}}}return d}function Hf(a,b,c,d){if(d){var e=a.anchor;if(c){var f=fb(b,e)<0;if(f!=fb(c,e)<0){e=b;b=c}else if(f!=fb(b,c)<0){b=c}}return new df(e,b)}else{return new df(c||b,b)}}function If(a,b,c,d,e){if(e==null){e=a.cm&&(a.cm.display.shift||a.extend)}Of(a,new cf([Hf(a.sel.primary(),b,c,e)],0),d)}function Jf(a,b,c){var d=[];var e=a.cm&&(a.cm.display.shift||a.extend);for(var f=0;f=b.ch:h.to>b.ch))){if(e){ra(i,"beforeCursorEnter");if(i.explicitlyCleared){if(!f.markedSpans){break}else{--g;continue}}}if(!i.atomic){continue}if(c){var l=i.find(d<0?1:-1),m=void 0;if(d<0?k:j){l=Vf(a,l,-d,l&&l.line==b.line?f:null)}if(l&&l.line==b.line&&(m=fb(l,c))&&(d<0?m<0:m>0)){return Tf(a,l,b,d,e)}}var n=i.find(d<0?-1:1);if(d<0?j:k){n=Vf(a,n,d,n.line==b.line?f:null)}return n?Tf(a,n,b,d,e):null}}}return b}function Uf(a,b,c,d,e){var f=d||1;var g=Tf(a,b,c,f,e)||!e&&Tf(a,b,c,f,true)||Tf(a,b,c,-f,e)||!e&&Tf(a,b,c,-f,true);if(!g){a.cantEdit=true;return eb(a.first,0)}return g}function Vf(a,b,c,d){if(c<0&&b.ch==0){if(b.line>a.first){return lb(a,eb(b.line-1))}else{return null}}else if(c>0&&b.ch==(d||Ya(a,b.line)).text.length){if(b.line=0;--e){Zf(a,{from:d[e].from,to:d[e].to,text:e?[""]:b.text,origin:b.origin})}}else{Zf(a,b)}}function Zf(a,b){if(b.text.length==1&&b.text[0]==""&&fb(b.from,b.to)==0){return}var c=jf(a,b);yf(a,b,c,a.cm?a.cm.curOp.id:NaN);ag(a,b,c,Mb(a,b));var d=[];qf(a,function(a,c){if(!c&&O(d,a.history)==-1){fg(a.history,b);d.push(a.history)}ag(a,b,null,Mb(a,b))})}function $f(a,b,c){var d=a.cm&&a.cm.state.suppressEdits;if(d&&!c){return}var e=a.history,f,g=a.sel;var h=b=="undo"?e.done:e.undone,i=b=="undo"?e.undone:e.done;var j=0;for(;j=0;--n){var o=m(n);if(o)return o.v}}function _f(a,b){if(b==0){return}a.first+=b;a.sel=new cf(Y(a.sel.ranges,function(a){return new df(eb(a.anchor.line+b,a.anchor.ch),eb(a.head.line+b,a.head.ch))}),a.sel.primIndex);if(a.cm){Jd(a.cm,a.first,a.first-b,b);for(var c=a.cm.display,d=c.viewFrom;da.lastLine()){return}if(b.from.linef){b={from:b.from,to:eb(f,Ya(a,f).text.length),text:[b.text[0]],origin:b.origin}}b.removed=Za(a,b.from,b.to);if(!c){c=jf(a,b)}if(a.cm){bg(a.cm,b,d)}else{pf(a,b,d)}Pf(a,c,R);if(a.cantEdit&&Uf(a,eb(a.firstLine(),0))){a.cantEdit=false}}function bg(a,b,c){var d=a.doc,e=a.display,f=b.from,g=b.to;var h=false,i=f.line;if(!a.options.lineWrapping){i=ab(Zb(Ya(d,f.line)));d.iter(i,g.line+1,function(a){if(a==e.maxLine){h=true;return true}})}if(d.sel.contains(b.from,b.to)>-1){ta(a)}pf(d,b,c,Fd(a));if(!a.options.lineWrapping){d.iter(i,f.line+b.text.length,function(a){var b=fc(a);if(b>e.maxLineLength){e.maxLine=a;e.maxLineLength=b;e.maxLineChanged=true;h=false}});if(h){a.curOp.updateMaxLine=true}}Bb(d,f.line);He(a,400);var j=b.text.length-(g.line-f.line)-1;if(b.full){Jd(a)}else if(f.line==g.line&&b.text.length==1&&!of(a.doc,b)){Kd(a,f.line,"text")}else{Jd(a,f.line,g.line+1,j)}var k=ua(a,"changes"),l=ua(a,"change");if(l||k){var m={from:f,to:g,text:b.text,removed:b.removed,origin:b.origin};if(l){Bc(a,"change",a,m)}if(k){(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(m)}}a.display.selForContextMenu=null}function cg(a,b,c,d,e){var f;if(!d){d=c}if(fb(d,c)<0){f=[d,c],c=f[0],d=f[1]}if(typeof b=="string"){b=a.splitLines(b)}Yf(a,{from:c,to:d,text:b,origin:e})}function dg(a,b,c,d){if(c1||!(this.children[0]instanceof hg))){var h=[];this.collapse(h);this.children=[new hg(h)];this.children[0].parent=this}},collapse:function(a){for(var b=0;b50){var g=e.lines.length%25+25;for(var h=g;h10);a.parent.maybeSpill()},iterN:function(a,b,c){for(var d=0;da.display.maxLineLength){a.display.maxLine=j;a.display.maxLineLength=k;a.display.maxLineChanged=true}}}if(d!=null&&a&&this.collapsed){Jd(a,d,e+1)}this.lines.length=0;this.explicitlyCleared=true;if(this.atomic&&this.doc.cantEdit){this.doc.cantEdit=false;if(a){Rf(a.doc)}}if(a){Bc(a,"markerCleared",a,this,d,e)}if(b){we(a)}if(this.parent){this.parent.clear()}};ng.prototype.find=function(a,b){if(a==null&&this.type=="bookmark"){a=1}var c,d;for(var e=0;e0||g==0&&f.clearWhenEmpty!==false){return f}if(f.replacedWith){f.collapsed=true;f.widgetNode=D("span",[f.replacedWith],"CodeMirror-widget");if(!d.handleMouseEvents){f.widgetNode.setAttribute("cm-ignore-events","true")}if(d.insertLeft){f.widgetNode.insertLeft=true}}if(f.collapsed){if(Yb(a,b.line,b,c,f)||b.line!=c.line&&Yb(a,c.line,b,c,f)){throw new Error("Inserting collapsed marker partially overlapping an existing one")}Fb()}if(f.addToHistory){yf(a,{from:b,to:c,origin:"markText"},a.sel,NaN)}var h=b.line,i=a.cm,j;a.iter(h,c.line+1,function(a){if(i&&f.collapsed&&!i.options.lineWrapping&&Zb(a)==i.display.maxLine){j=true}if(f.collapsed&&h!=b.line){_a(a,0)}Jb(a,new Gb(f,h==b.line?b.ch:null,h==c.line?c.ch:null));++h});if(f.collapsed){a.iter(b.line,c.line+1,function(b){if(cc(a,b)){_a(b,0)}})}if(f.clearOnEnter){oa(f,"beforeCursorEnter",function(){return f.clear()})}if(f.readOnly){Eb();if(a.history.done.length||a.history.undone.length){a.clearHistory()}}if(f.collapsed){f.id=++mg;f.atomic=true}if(i){if(j){i.curOp.updateMaxLine=true}if(f.collapsed){Jd(i,b.line,c.line+1)}else if(f.className||f.startStyle||f.endStyle||f.css||f.attributes||f.title){for(var k=b.line;k<=c.line;k++){Kd(i,k,"text")}}if(f.atomic){Rf(i.doc)}Bc(i,"markerAdded",i,f)}return f}var pg=function(a,b){this.markers=a;this.primary=b;for(var c=0;c=0;i--){Yf(this,d[i])}if(h){Nf(this,h)}else if(this.cm){fe(this.cm)}}),undo:Ge(function(){$f(this,"undo")}),redo:Ge(function(){$f(this,"redo")}),undoSelection:Ge(function(){$f(this,"undo",true)}),redoSelection:Ge(function(){$f(this,"redo",true)}),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){var a=this.history,b=0,c=0;for(var d=0;d=a.ch)){b.push(e.marker.parent||e.marker)}}}return b},findMarks:function(a,b,c){a=lb(this,a);b=lb(this,b);var d=[],e=a.line;this.iter(a.line,b.line+1,function(f){var g=f.markedSpans;if(g){for(var h=0;h=i.to||i.from==null&&e!=a.line||i.from!=null&&e==b.line&&i.from>=b.ch)&&(!c||c(i.marker))){d.push(i.marker.parent||i.marker)}}}++e});return d},getAllMarks:function(){var a=[];this.iter(function(b){var c=b.markedSpans;if(c){for(var d=0;da){b=a;return true}a-=f;++c});return lb(this,eb(c,b))},indexFromPos:function(a){a=lb(this,a);var b=a.ch;if(a.lineb){b=a.from}if(a.to!=null&&a.to-1){b.state.draggingText(a);setTimeout(function(){return b.display.input.focus()},20);return}try{var l=a.dataTransfer.getData("Text");if(l){var m;if(b.state.draggingText&&!b.state.draggingText.copy){m=b.listSelections()}Pf(b.doc,ff(c,c));if(m){for(var n=0;n=0;b--){cg(a.doc,"",d[b].from,d[b].to,"+delete")}fe(a)})}function Tg(a,b,c){var d=ga(a.text,b+c,c);return d<0||d>a.text.length?null:d}function Ug(a,b,c){var d=Tg(a,b.ch,c);return d==null?null:new eb(b.line,d,c<0?"after":"before")}function Vg(a,b,c,d,e){if(a){if(b.doc.direction=="rtl"){e=-e}var f=ma(c,b.doc.direction);if(f){var g=e<0?X(f):f[0];var h=e<0==(g.level==1);var i=h?"after":"before";var j;if(g.level>0||b.doc.direction=="rtl"){var k=ad(b,c);j=e<0?c.text.length-1:0;var l=bd(b,k,j).top;j=ha(function(a){return bd(b,k,a).top==l},e<0==(g.level==1)?g.from:g.to-1,j);if(i=="before"){j=Tg(c,j,1)}}else{j=e<0?g.to:g.from}return new eb(d,j,i)}}return new eb(d,e<0?c.text.length:0,e<0?"before":"after")}function Wg(a,b,c,d){var e=ma(b,a.doc.direction);if(!e){return Ug(b,c,d)}if(c.ch>=b.text.length){c.ch=b.text.length;c.sticky="before"}else if(c.ch<=0){c.ch=0;c.sticky="after"}var f=ka(e,c.ch,c.sticky),g=e[f];if(a.doc.direction=="ltr"&&g.level%2==0&&(d>0?g.to>c.ch:g.from=g.from&&m>=k.begin:m<=g.to&&m<=k.end)){var n=l?"before":"after";return new eb(c.line,m,n)}}var o=function(a,b,d){var f=function(a,b){return b?new eb(c.line,h(a,1),"before"):new eb(c.line,a,"after")};for(;a>=0&&a0==(g.level!=1);var j=i?d.begin:h(d.end,-1);if(g.from<=j&&j0?k.end:h(k.begin,-1);if(q!=null&&!(d>0&&q==b.text.length)){p=o(d>0?0:e.length-1,d,j(q));if(p){return p}}return null}var Xg={selectAll:Wf,singleSelection:function(a){return a.setSelection(a.getCursor("anchor"),a.getCursor("head"),R)},killLine:function(a){return Sg(a,function(b){if(b.empty()){var c=Ya(a.doc,b.head.line).text.length;if(b.head.ch==c&&b.head.line0){e=new eb(e.line,e.ch+1);a.replaceRange(f.charAt(e.ch-1)+f.charAt(e.ch-2),eb(e.line,e.ch-2),e,"+transpose")}else if(e.line>a.doc.first){var g=Ya(a.doc,e.line-1).text;if(g){e=new eb(e.line,1);a.replaceRange(f.charAt(0)+a.doc.lineSeparator()+g.charAt(g.length-1),eb(e.line-1,g.length-1),e,"+transpose")}}}c.push(new df(e,e))}a.setSelections(c)})},newlineAndIndent:function(a){return De(a,function(){var b=a.listSelections();for(var c=b.length-1;c>=0;c--){a.replaceRange(a.doc.lineSeparator(),b[c].anchor,b[c].head,"+input")}b=a.listSelections();for(var d=0;da&&fb(b,this.pos)==0&&c==this.button};var nh,oh;function ph(a,b){var c=+new Date;if(oh&&oh.compare(c,a,b)){nh=oh=null;return"triple"}else if(nh&&nh.compare(c,a,b)){oh=new mh(c,a,b);nh=null;return"double"}else{nh=new mh(c,a,b);oh=null;return"single"}}function qh(a){var b=this,c=b.display;if(sa(b,a)||c.activeTouch&&c.input.supportsTouch()){return}c.input.ensurePolled();c.shift=a.shiftKey;if(Qc(c,a)){if(!i){c.scroller.draggable=false;setTimeout(function(){return c.scroller.draggable=true},100)}return}if(zh(b,a)){return}var d=Hd(b,a),e=Ba(a),f=d?ph(d,e):"single";window.focus();if(e==1&&b.state.selectingText){b.state.selectingText(a)}if(d&&rh(b,e,d,f,a)){return}if(e==1){if(d){th(b,d,f,a)}else if(Aa(a)==c.scroller){wa(a)}}else if(e==2){if(d){If(b.doc,d)}setTimeout(function(){return c.input.focus()},20)}else if(e==3){if(x){b.display.input.onContextMenu(a)}else{Wd(b)}}}function rh(a,b,c,d,e){var f="Click";if(d=="double"){f="Double"+f}else if(d=="triple"){f="Triple"+f}f=(b==1?"Left":b==2?"Middle":"Right")+f;return ch(a,Pg(f,e),e,function(b){if(typeof b=="string"){b=Xg[b]}if(!b){return false}var d=false;try{if(a.isReadOnly()){a.state.suppressEdits=true}d=b(a,c)!=Q}finally{a.state.suppressEdits=false}return d})}function sh(a,b,c){var d=a.getOption("configureMouse");var e=d?d(a,b,c):{};if(e.unit==null){var f=t?c.shiftKey&&c.metaKey:c.altKey;e.unit=f?"rectangle":b=="single"?"char":b=="double"?"word":"line"}if(e.extend==null||a.doc.extend){e.extend=a.doc.extend||c.shiftKey}if(e.addNew==null){e.addNew=s?c.metaKey:c.ctrlKey}if(e.moveOnDrag==null){e.moveOnDrag=!(s?c.altKey:c.ctrlKey)}return e}function th(a,b,c,d){if(g){setTimeout(K(Vd,a),0)}else{a.curOp.focus=G()}var e=sh(a,c,d);var f=a.doc.sel,h;if(a.options.dragDrop&&Ca&&!a.isReadOnly()&&c=="single"&&(h=f.contains(b))>-1&&(fb((h=f.ranges[h]).from(),b)<0||b.xRel>0)&&(fb(h.to(),b)>0||b.xRel<0)){uh(a,d,b,e)}else{wh(a,d,b,e)}}function uh(a,b,c,d){var e=a.display,f=false;var j=Ee(a,function(b){if(i){e.scroller.draggable=false}a.state.draggingText=false;qa(e.wrapper.ownerDocument,"mouseup",j);qa(e.wrapper.ownerDocument,"mousemove",k);qa(e.scroller,"dragstart",l);qa(e.scroller,"drop",j);if(!f){wa(b);if(!d.addNew){If(a.doc,c,null,null,d.extend)}if(i&&!m||g&&h==9){setTimeout(function(){e.wrapper.ownerDocument.body.focus({preventScroll:true});e.input.focus()},20)}else{e.input.focus()}}});var k=function(a){f=f||Math.abs(b.clientX-a.clientX)+Math.abs(b.clientY-a.clientY)>=10};var l=function(){return f=true};if(i){e.scroller.draggable=true}a.state.draggingText=j;j.copy=!d.moveOnDrag;if(e.scroller.dragDrop){e.scroller.dragDrop()}oa(e.wrapper.ownerDocument,"mouseup",j);oa(e.wrapper.ownerDocument,"mousemove",k);oa(e.scroller,"dragstart",l);oa(e.scroller,"drop",j);Wd(a);setTimeout(function(){return e.input.focus()},20)}function vh(a,b,c){if(c=="char"){return new df(b,b)}if(c=="word"){return a.findWordAt(b)}if(c=="line"){return new df(eb(b.line,0),lb(a.doc,eb(b.line+1,0)))}var d=c(a,b);return new df(d.from,d.to)}function wh(a,b,c,d){var e=a.display,f=a.doc;wa(b);var g,h,i=f.sel,j=i.ranges;if(d.addNew&&!d.extend){h=f.sel.contains(c);if(h>-1){g=j[h]}else{g=new df(c,c)}}else{g=f.sel.primary();h=f.sel.primIndex}if(d.unit=="rectangle"){if(!d.addNew){g=new df(c,c)}c=Hd(a,b,true,true);h=-1}else{var k=vh(a,c,d.unit);if(d.extend){g=Hf(g,k.anchor,k.head,d.extend)}else{g=k}}if(!d.addNew){h=0;Of(f,new cf([g],0),S);i=f.sel}else if(h==-1){h=j.length;Of(f,ef(a,j.concat([g]),h),{scroll:false,origin:"*mouse"})}else if(j.length>1&&j[h].empty()&&d.unit=="char"&&!d.extend){Of(f,ef(a,j.slice(0,h).concat(j.slice(h+1)),0),{scroll:false,origin:"*mouse"});i=f.sel}else{Kf(f,h,g,S)}var l=c;function m(b){if(fb(l,b)==0){return}l=b;if(d.unit=="rectangle"){var e=[],j=a.options.tabSize;var k=M(Ya(f,c.line).text,c.ch,j);var m=M(Ya(f,b.line).text,b.ch,j);var n=Math.min(k,m),o=Math.max(k,m);for(var p=Math.min(c.line,b.line),q=Math.min(a.lastLine(),Math.max(c.line,b.line));p<=q;p++){var r=Ya(f,p).text,s=U(r,n,j);if(n==o){e.push(new df(eb(p,s),eb(p,s)))}else if(r.length>s){e.push(new df(eb(p,s),eb(p,U(r,o,j))))}}if(!e.length){e.push(new df(c,c))}Of(f,ef(a,i.ranges.slice(0,h).concat(e),h),{origin:"*mouse",scroll:false});a.scrollIntoView(b)}else{var t=g;var u=vh(a,b,d.unit);var v=t.anchor,w;if(fb(u.anchor,v)>0){w=u.head;v=jb(t.from(),u.anchor)}else{w=u.anchor;v=ib(t.to(),u.head)}var x=i.ranges.slice(0);x[h]=xh(a,new df(lb(f,v),w));Of(f,ef(a,x,h),S)}}var n=e.wrapper.getBoundingClientRect();var o=0;function p(b){var c=++o;var g=Hd(a,b,true,d.unit=="rectangle");if(!g){return}if(fb(g,l)!=0){a.curOp.focus=G();m(g);var h=_d(e,f);if(g.line>=h.to||g.linen.bottom?20:0;if(i){setTimeout(Ee(a,function(){if(o!=c){return}e.scroller.scrollTop+=i;p(b)}),50)}}}function q(b){a.state.selectingText=false;o=Infinity;if(b){wa(b);e.input.focus()}qa(e.wrapper.ownerDocument,"mousemove",r);qa(e.wrapper.ownerDocument,"mouseup",s);f.history.lastSelOrigin=null}var r=Ee(a,function(a){if(a.buttons===0||!Ba(a)){q(a)}else{p(a)}});var s=Ee(a,q);a.state.selectingText=s;oa(e.wrapper.ownerDocument,"mousemove",r);oa(e.wrapper.ownerDocument,"mouseup",s)}function xh(a,b){var c=b.anchor;var d=b.head;var e=Ya(a.doc,c.line);if(fb(c,d)==0&&c.sticky==d.sticky){return b}var f=ma(e);if(!f){return b}var g=ka(f,c.ch,c.sticky),h=f[g];if(h.from!=c.ch&&h.to!=c.ch){return b}var i=g+(h.from==c.ch==(h.level!=1)?0:1);if(i==0||i==f.length){return b}var j;if(d.line!=c.line){j=(d.line-c.line)*(a.doc.direction=="ltr"?1:-1)>0}else{var k=ka(f,d.ch,d.sticky);var l=k-g||(d.ch-c.ch)*(h.level==1?-1:1);if(k==i-1||k==i){j=l<0}else{j=l>0}}var m=f[i+(j?-1:0)];var n=j==(m.level==1);var o=n?m.from:m.to,p=n?"after":"before";return c.ch==o&&c.sticky==p?b:new df(new eb(c.line,o,p),d)}function yh(a,b,c,d){var e,f;if(b.touches){e=b.touches[0].clientX;f=b.touches[0].clientY}else{try{e=b.clientX;f=b.clientY}catch(m){return false}}if(e>=Math.floor(a.display.gutters.getBoundingClientRect().right)){return false}if(d){wa(b)}var g=a.display;var h=g.lineDiv.getBoundingClientRect();if(f>h.bottom||!ua(a,c)){return ya(b)}f-=h.top-g.viewOffset;for(var i=0;i=e){var k=bb(a.doc,f);var l=a.display.gutterSpecs[i];ra(a,c,a,k,l.className,b);return ya(b)}}}function zh(a,b){return yh(a,b,"gutterClick",true)}function Ah(a,b){if(Qc(a.display,b)||Bh(a,b)){return}if(sa(a,b,"contextmenu")){return}if(!x){a.display.input.onContextMenu(b)}}function Bh(a,b){if(!ua(a,"gutterContextMenu")){return false}return yh(a,b,"gutterContextMenu",false)}function Ch(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-");jd(a)}var Dh={toString:function(){return"CodeMirror.Init"}};var Eh={};var Fh={};function Gh(a){var b=a.optionHandlers;function c(c,d,e,f){a.defaults[c]=d;if(e){b[c]=f?function(a,b,c){if(c!=Dh){e(a,b,c)}}:e}}a.defineOption=c;a.Init=Dh;c("value","",function(a,b){return a.setValue(b)},true);c("mode",null,function(a,b){a.doc.modeOption=b;mf(a)},true);c("indentUnit",2,mf,true);c("indentWithTabs",false);c("smartIndent",true);c("tabSize",4,function(a){nf(a);jd(a);Jd(a)},true);c("lineSeparator",null,function(a,b){a.doc.lineSep=b;if(!b){return}var c=[],d=a.doc.first;a.doc.iter(function(a){for(var e=0;;){var f=a.text.indexOf(b,e);if(f==-1){break}e=f+b.length;c.push(eb(d,f))}d++});for(var e=c.length-1;e>=0;e--){cg(a.doc,b,c[e],eb(c[e].line,c[e].ch+b.length))}});c("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(a,b,c){a.state.specialChars=new RegExp(b.source+(b.test("\t")?"":"|\t"),"g");if(c!=Dh){a.refresh()}});c("specialCharPlaceholder",oc,function(a){return a.refresh()},true);c("electricChars",true);c("inputStyle",r?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},true);c("spellcheck",false,function(a,b){return a.getInputField().spellcheck=b},true);c("autocorrect",false,function(a,b){return a.getInputField().autocorrect=b},true);c("autocapitalize",false,function(a,b){return a.getInputField().autocapitalize=b},true);c("rtlMoveVisually",!u);c("wholeLineUpdateBefore",true);c("theme","default",function(a){Ch(a);Xe(a)},true);c("keyMap","default",function(a,b,c){var d=Rg(b);var e=c!=Dh&&Rg(c);if(e&&e.detach){e.detach(a,d)}if(d.attach){d.attach(a,e||null)}});c("extraKeys",null);c("configureMouse",null);c("lineWrapping",false,Ih,true);c("gutters",[],function(a,b){a.display.gutterSpecs=Ve(b,a.options.lineNumbers);Xe(a)},true);c("fixedGutter",true,function(a,b){a.display.gutters.style.left=b?Ed(a.display)+"px":"0";a.refresh()},true);c("coverGutterNextToScrollbar",false,function(a){return qe(a)},true);c("scrollbarStyle","native",function(a){te(a);qe(a);a.display.scrollbars.setScrollTop(a.doc.scrollTop);a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)},true);c("lineNumbers",false,function(a,b){a.display.gutterSpecs=Ve(a.options.gutters,b);Xe(a)},true);c("firstLineNumber",1,Xe,true);c("lineNumberFormatter",function(a){return a},Xe,true);c("showCursorWhenSelecting",false,Pd,true);c("resetSelectionOnContextMenu",true);c("lineWiseCopyCut",true);c("pasteLinesPerSelection",true);c("selectionsMayTouch",false);c("readOnly",false,function(a,b){if(b=="nocursor"){Yd(a);a.display.input.blur()}a.display.input.readOnlyChanged(b)});c("screenReaderLabel",null,function(a,b){b=b===""?null:b;a.display.input.screenReaderLabelChanged(b)});c("disableInput",false,function(a,b){if(!b){a.display.input.reset()}},true);c("dragDrop",true,Hh);c("allowDropFileTypes",null);c("cursorBlinkRate",530);c("cursorScrollMargin",0);c("cursorHeight",1,Pd,true);c("singleCursorHeightPerLine",true,Pd,true);c("workTime",100);c("workDelay",100);c("flattenSpans",true,nf,true);c("addModeClass",false,nf,true);c("pollInterval",100);c("undoDepth",200,function(a,b){return a.doc.history.undoDepth=b});c("historyEventDelay",1250);c("viewportMargin",10,function(a){return a.refresh()},true);c("maxHighlightLength",1e4,nf,true);c("moveInputWithCursor",true,function(a,b){if(!b){a.display.input.resetPosition()}});c("tabindex",null,function(a,b){return a.display.input.getField().tabIndex=b||""});c("autofocus",null);c("direction","ltr",function(a,b){return a.doc.setDirection(b)},true);c("phrases",null)}function Hh(a,b,c){var d=c&&c!=Dh;if(!b!=!d){var e=a.display.dragFunctions;var f=b?oa:qa;f(a.display.scroller,"dragstart",e.start);f(a.display.scroller,"dragenter",e.enter);f(a.display.scroller,"dragover",e.over);f(a.display.scroller,"dragleave",e.leave);f(a.display.scroller,"drop",e.drop)}}function Ih(a){if(a.options.lineWrapping){H(a.display.wrapper,"CodeMirror-wrap");a.display.sizer.style.minWidth="";a.display.sizerWidth=null}else{z(a.display.wrapper,"CodeMirror-wrap");gc(a)}Gd(a);Jd(a);jd(a);setTimeout(function(){return qe(a)},100)}function Jh(a,b){var c=this;if(!(this instanceof Jh)){return new Jh(a,b)}this.options=b=b?L(b):{};L(Eh,b,false);var d=b.value;if(typeof d=="string"){d=new vg(d,b.mode,null,b.lineSeparator,b.direction)}else if(b.mode){d.modeOption=b.mode}this.doc=d;var e=new Jh.inputStyles[b.inputStyle](this);var f=this.display=new Ye(a,d,e,b);f.wrapper.CodeMirror=this;Ch(this);if(b.lineWrapping){this.display.wrapper.className+=" CodeMirror-wrap"}te(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:false,delayingBlurEvent:false,focused:false,suppressEdits:false,pasteIncoming:-1,cutIncoming:-1,selectingText:false,draggingText:false,highlight:new N,keySeq:null,specialChars:null};if(b.autofocus&&!r){f.input.focus()}if(g&&h<11){setTimeout(function(){return c.display.input.reset(true)},20)}Kh(this);Dg();ve(this);this.curOp.forceUpdate=true;rf(this,d);if(b.autofocus&&!r||this.hasFocus()){setTimeout(K(Xd,this),20)}else{Yd(this)}for(var j in Fh){if(Fh.hasOwnProperty(j)){Fh[j](this,b[j],Dh)}}Ue(this);if(b.finishInit){b.finishInit(this)}for(var k=0;k20*20}oa(b.scroller,"touchstart",function(e){if(!sa(a,e)&&!f(e)&&!zh(a,e)){b.input.ensurePolled();clearTimeout(c);var g=+new Date;b.activeTouch={start:g,moved:false,prev:g-d.end<=300?d:null};if(e.touches.length==1){b.activeTouch.left=e.touches[0].pageX;b.activeTouch.top=e.touches[0].pageY}}});oa(b.scroller,"touchmove",function(){if(b.activeTouch){b.activeTouch.moved=true}});oa(b.scroller,"touchend",function(c){var d=b.activeTouch;if(d&&!Qc(b,c)&&d.left!=null&&!d.moved&&new Date-d.start<300){var f=a.coordsChar(b.activeTouch,"page"),g;if(!d.prev||i(d,d.prev)){g=new df(f,f)}else if(!d.prev.prev||i(d,d.prev.prev)){g=a.findWordAt(f)}else{g=new df(eb(f.line,0),lb(a.doc,eb(f.line+1,0)))}a.setSelection(g.anchor,g.head);a.focus();wa(c)}e()});oa(b.scroller,"touchcancel",e);oa(b.scroller,"scroll",function(){if(b.scroller.clientHeight){ke(a,b.scroller.scrollTop);me(a,b.scroller.scrollLeft,true);ra(a,"scroll",a)}});oa(b.scroller,"mousewheel",function(b){return bf(a,b)});oa(b.scroller,"DOMMouseScroll",function(b){return bf(a,b)});oa(b.wrapper,"scroll",function(){return b.wrapper.scrollTop=b.wrapper.scrollLeft=0});b.dragFunctions={enter:function(b){if(!sa(a,b)){za(b)}},over:function(b){if(!sa(a,b)){zg(a,b);za(b)}},start:function(b){return yg(a,b)},drop:Ee(a,xg),leave:function(b){if(!sa(a,b)){Ag(a)}}};var j=b.input.getField();oa(j,"keyup",function(b){return jh.call(a,b)});oa(j,"keydown",Ee(a,hh));oa(j,"keypress",Ee(a,kh));oa(j,"focus",function(b){return Xd(a,b)});oa(j,"blur",function(b){return Yd(a,b)})}var Lh=[];Jh.defineInitHook=function(a){return Lh.push(a)};function Mh(a,b,c,d){var e=a.doc,f;if(c==null){c="add"}if(c=="smart"){if(!e.mode.indent){c="prev"}else{f=sb(a,b).state}}var g=a.options.tabSize;var h=Ya(e,b),i=M(h.text,null,g);if(h.stateAfter){h.stateAfter=null}var j=h.text.match(/^\s*/)[0],k;if(!d&&!/\S/.test(h.text)){k=0;c="not"}else if(c=="smart"){k=e.mode.indent(f,h.text.slice(j.length),h.text);if(k==Q||k>150){if(!d){return}c="prev"}}if(c=="prev"){if(b>e.first){k=M(Ya(e,b-1).text,null,g)}else{k=0}}else if(c=="add"){k=i+a.options.indentUnit}else if(c=="subtract"){k=i-a.options.indentUnit}else if(typeof c=="number"){k=i+c}k=Math.max(0,k);var l="",m=0;if(a.options.indentWithTabs){for(var n=Math.floor(k/g);n;--n){m+=g;l+="\t"}}if(mg;var i=Ha(b),j=null;if(h&&d.ranges.length>1){if(Nh&&Nh.text.join("\n")==b){if(d.ranges.length%Nh.text.length==0){j=[];for(var k=0;k=0;m--){var n=d.ranges[m];var o=n.from(),p=n.to();if(n.empty()){if(c&&c>0){o=eb(o.line,o.ch-c)}else if(a.state.overwrite&&!h){p=eb(p.line,Math.min(Ya(f,p.line).text.length,p.ch+X(i).length))}else if(h&&Nh&&Nh.lineWise&&Nh.text.join("\n")==i.join("\n")){o=p=eb(o.line,0)}}var q={from:o,to:p,text:j?j[m%j.length]:i,origin:e||(h?"paste":a.state.cutIncoming>g?"cut":"+input")};Yf(a.doc,q);Bc(a,"inputRead",a,q)}if(b&&!h){Rh(a,b)}fe(a);if(a.curOp.updateInput<2){a.curOp.updateInput=l}a.curOp.typing=true;a.state.pasteIncoming=a.state.cutIncoming=-1}function Qh(a,b){var c=a.clipboardData&&a.clipboardData.getData("Text");if(c){a.preventDefault();if(!b.isReadOnly()&&!b.options.disableInput){De(b,function(){return Ph(b,c,0,null,"paste")})}return true}}function Rh(a,b){if(!a.options.electricChars||!a.options.smartIndent){return}var c=a.doc.sel;for(var d=c.ranges.length-1;d>=0;d--){var e=c.ranges[d];if(e.head.ch>100||d&&c.ranges[d-1].head.line==e.head.line){continue}var f=a.getModeAt(e.head);var g=false;if(f.electricChars){for(var h=0;h-1){g=Mh(a,e.head.line,"smart");break}}}else if(f.electricInput){if(f.electricInput.test(Ya(a.doc,e.head.line).text.slice(0,e.head.ch))){g=Mh(a,e.head.line,"smart")}}if(g){Bc(a,"electricInput",a,e.head.line)}}}function Sh(a){var b=[],c=[];for(var d=0;d0){Kf(this.doc,d,new df(f,j[d].to()),R)}}else if(e.head.line>c){Mh(this,e.head.line,a,true);c=e.head.line;if(d==this.doc.sel.primIndex){fe(this)}}}}),getTokenAt:function(a,b){return xb(this,a,b)},getLineTokens:function(a,b){return xb(this,eb(a),b,true)},getTokenTypeAt:function(a){a=lb(this.doc,a);var b=rb(this,Ya(this.doc,a.line));var c=0,d=(b.length-1)/2,e=a.ch;var f;if(e==0){f=b[2]}else{for(;;){var g=c+d>>1;if((g?b[g*2-1]:0)>=e){d=g}else if(b[g*2+1]f){a=f;d=true}e=Ya(this.doc,a)}else{e=a}return nd(this,e,{top:0,left:0},b||"page",c||d).top+(d?this.doc.height-ec(e):0)},defaultTextHeight:function(){return Bd(this.display)},defaultCharWidth:function(){return Cd(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=qd(this,lb(this.doc,a));var g=a.bottom,h=a.left;b.style.position="absolute";b.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(b);f.sizer.appendChild(b);if(d=="over"){g=a.top}else if(d=="above"||d=="near"){var i=Math.max(f.wrapper.clientHeight,this.doc.height),j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);if((d=="above"||a.bottom+b.offsetHeight>i)&&a.top>b.offsetHeight){g=a.top-b.offsetHeight}else if(a.bottom+b.offsetHeight<=i){g=a.bottom}if(h+b.offsetWidth>j){h=j-b.offsetWidth}}b.style.top=g+"px";b.style.left=b.style.right="";if(e=="right"){h=f.sizer.clientWidth-b.offsetWidth;b.style.right="0px"}else{if(e=="left"){h=0}else if(e=="middle"){h=(f.sizer.clientWidth-b.offsetWidth)/2}b.style.left=h+"px"}if(c){ce(this,{left:h,top:g,right:h+b.offsetWidth,bottom:g+b.offsetHeight})}},triggerOnKeyDown:Fe(hh),triggerOnKeyPress:Fe(kh),triggerOnKeyUp:jh,triggerOnMouseDown:Fe(qh),execCommand:function(a){if(Xg.hasOwnProperty(a)){return Xg[a].call(null,this)}},triggerElectric:Fe(function(a){Rh(this,a)}),findPosH:function(a,b,c,d){var e=1;if(b<0){e=-1;b=-b}var f=lb(this.doc,a);for(var g=0;g0&&h(c.charAt(d-1))){--d}while(e.5||this.options.lineWrapping){Gd(this)}ra(this,"refresh",this)}),swapDoc:Fe(function(a){var b=this.doc;b.cm=null;if(this.state.selectingText){this.state.selectingText()}rf(this,a);jd(this);this.display.input.reset();ge(this,a.scrollLeft,a.scrollTop);this.curOp.forceScroll=true;Bc(this,"swapDoc",this,b);return b}),phrase:function(a){var b=this.options.phrases;return b&&Object.prototype.hasOwnProperty.call(b,a)?b[a]:a},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}};va(a);a.registerHelper=function(b,d,e){if(!c.hasOwnProperty(b)){c[b]=a[b]={_global:[]}}c[b][d]=e};a.registerGlobalHelper=function(b,d,e,f){a.registerHelper(b,d,f);c[b]._global.push({pred:e,val:f})}}function Wh(a,b,c,d,e){var f=b;var g=c;var h=Ya(a,b.line);var i=e&&a.direction=="rtl"?-c:c;function j(){var c=b.line+i;if(c=a.first+a.size){return false}b=new eb(c,b.ch,b.sticky);return h=Ya(a,c)}function k(d){var f;if(e){f=Wg(a.cm,h,b,c)}else{f=Ug(h,b,c)}if(f==null){if(!d&&j()){b=Vg(e,a.cm,h,b.line,i)}else{return false}}else{b=f}return true}if(d=="char"){k()}else if(d=="column"){k(true)}else if(d=="word"||d=="group"){var l=null,m=d=="group";var n=a.cm&&a.cm.getHelper(b,"wordChars");for(var o=true;;o=false){if(c<0&&!k(!o)){break}var p=h.text.charAt(b.ch)||"\n";var q=ca(p,n)?"w":m&&p=="\n"?"n":!m||/\s/.test(p)?null:"p";if(m&&!o&&!q){q="s"}if(l&&l!=q){if(c<0){c=1;k();b.sticky="after"}break}if(q){l=q}if(c>0&&!k(!o)){break}}}var r=Uf(a,b,f,g,true);if(gb(f,r)){r.hitSide=true}return r}function Xh(a,b,c,d){var e=a.doc,f=b.left,g;if(d=="page"){var h=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);var i=Math.max(h-.5*Bd(a.display),3);g=(c>0?b.bottom:b.top)+c*i}else if(d=="line"){g=c>0?b.bottom+3:b.top-3}var j;for(;;){j=td(a,f,g);if(!j.outside){break}if(c<0?g<=0:g>=e.height){j.hitSide=true;break}g+=c*5}return j}var Yh=function(a){this.cm=a;this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null;this.polling=new N;this.composing=null;this.gracePeriod=false;this.readDOMTimeout=null};Yh.prototype.init=function(a){var b=this;var c=this,d=c.cm;var e=c.div=a.lineDiv;Th(e,d.options.spellcheck,d.options.autocorrect,d.options.autocapitalize);function f(a){for(var b=a.target;b;b=b.parentNode){if(b==e){return true} if(/\bCodeMirror-(?:line)?widget\b/.test(b.className)){break}}return false}oa(e,"paste",function(a){if(!f(a)||sa(d,a)||Qh(a,d)){return}if(h<=11){setTimeout(Ee(d,function(){return b.updateFromDOM()}),20)}});oa(e,"compositionstart",function(a){b.composing={data:a.data,done:false}});oa(e,"compositionupdate",function(a){if(!b.composing){b.composing={data:a.data,done:false}}});oa(e,"compositionend",function(a){if(b.composing){if(a.data!=b.composing.data){b.readFromDOMSoon()}b.composing.done=true}});oa(e,"touchstart",function(){return c.forceCompositionEnd()});oa(e,"input",function(){if(!b.composing){b.readFromDOMSoon()}});function g(a){if(!f(a)||sa(d,a)){return}if(d.somethingSelected()){Oh({lineWise:false,text:d.getSelections()});if(a.type=="cut"){d.replaceSelection("",null,"cut")}}else if(!d.options.lineWiseCopyCut){return}else{var b=Sh(d);Oh({lineWise:true,text:b.text});if(a.type=="cut"){d.operation(function(){d.setSelections(b.ranges,0,R);d.replaceSelection("",null,"cut")})}}if(a.clipboardData){a.clipboardData.clearData();var g=Nh.text.join("\n");a.clipboardData.setData("Text",g);if(a.clipboardData.getData("Text")==g){a.preventDefault();return}}var h=Uh(),i=h.firstChild;d.display.lineSpace.insertBefore(h,d.display.lineSpace.firstChild);i.value=Nh.text.join("\n");var j=document.activeElement;J(i);setTimeout(function(){d.display.lineSpace.removeChild(h);j.focus();if(j==e){c.showPrimarySelection()}},50)}oa(e,"copy",g);oa(e,"cut",g)};Yh.prototype.screenReaderLabelChanged=function(a){if(a){this.div.setAttribute("aria-label",a)}else{this.div.removeAttribute("aria-label")}};Yh.prototype.prepareSelection=function(){var a=Qd(this.cm,false);a.focus=document.activeElement==this.div;return a};Yh.prototype.showSelection=function(a,b){if(!a||!this.cm.display.view.length){return}if(a.focus||b){this.showPrimarySelection()}this.showMultipleSelections(a)};Yh.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()};Yh.prototype.showPrimarySelection=function(){var a=this.getSelection(),b=this.cm,d=b.doc.sel.primary();var e=d.from(),f=d.to();if(b.display.viewTo==b.display.viewFrom||e.line>=b.display.viewTo||f.line=b.display.viewFrom&&Zh(b,e)||{node:i[0].measure.map[2],offset:0};var k=f.linea.firstLine()){d=eb(d.line-1,Ya(a.doc,d.line-1).length)}if(e.ch==Ya(a.doc,e.line).text.length&&e.lineb.viewTo-1){return false}var f,g,h;if(d.line==b.viewFrom||(f=Id(a,d.line))==0){g=ab(b.view[0].line);h=b.view[0].node}else{g=ab(b.view[f].line);h=b.view[f-1].node.nextSibling}var i=Id(a,e.line);var j,k;if(i==b.view.length-1){j=b.viewTo-1;k=b.lineDiv.lastChild}else{j=ab(b.view[i+1].line)-1;k=b.view[i+1].node.previousSibling}if(!h){return false}var l=a.doc.splitLines(ai(a,h,k,g,j));var m=Za(a.doc,eb(g,0),eb(j,Ya(a.doc,j).text.length));while(l.length>1&&m.length>1){if(X(l)==X(m)){l.pop();m.pop();j--}else if(l[0]==m[0]){l.shift();m.shift();g++}else{break}}var n=0,o=0;var p=l[0],q=m[0],r=Math.min(p.length,q.length);while(nd.ch&&s.charCodeAt(s.length-o-1)==t.charCodeAt(t.length-o-1)){n--;o++}}l[l.length-1]=s.slice(0,s.length-o).replace(/^\u200b+/,"");l[0]=l[0].slice(n).replace(/\u200b+$/,"");var v=eb(g,n);var w=eb(j,m.length?X(m).length-o:0);if(l.length>1||l[0]||fb(v,w)){cg(a.doc,l,v,w,"+input");return true}};Yh.prototype.ensurePolled=function(){this.forceCompositionEnd()};Yh.prototype.reset=function(){this.forceCompositionEnd()};Yh.prototype.forceCompositionEnd=function(){if(!this.composing){return}clearTimeout(this.readDOMTimeout);this.composing=null;this.updateFromDOM();this.div.blur();this.div.focus()};Yh.prototype.readFromDOMSoon=function(){var a=this;if(this.readDOMTimeout!=null){return}this.readDOMTimeout=setTimeout(function(){a.readDOMTimeout=null;if(a.composing){if(a.composing.done){a.composing=null}else{return}}a.updateFromDOM()},80)};Yh.prototype.updateFromDOM=function(){var a=this;if(this.cm.isReadOnly()||!this.pollContent()){De(this.cm,function(){return Jd(a.cm)})}};Yh.prototype.setUneditable=function(a){a.contentEditable="false"};Yh.prototype.onKeyPress=function(a){if(a.charCode==0||this.composing){return}a.preventDefault();if(!this.cm.isReadOnly()){Ee(this.cm,Ph)(this.cm,String.fromCharCode(a.charCode==null?a.keyCode:a.charCode),0)}};Yh.prototype.readOnlyChanged=function(a){this.div.contentEditable=String(a!="nocursor")};Yh.prototype.onContextMenu=function(){};Yh.prototype.resetPosition=function(){};Yh.prototype.needsContentAttribute=true;function Zh(a,b){var c=_c(a,b.line);if(!c||c.hidden){return null}var d=Ya(a.doc,b.line);var e=Yc(c,d,b.line);var f=ma(d,a.doc.direction),g="left";if(f){var h=ka(f,b.ch);g=h%2?"right":"left"}var i=dd(e.map,b.ch,g);i.offset=i.collapse=="right"?i.end:i.start;return i}function $h(a){for(var b=a;b;b=b.parentNode){if(/CodeMirror-gutter-wrapper/.test(b.className)){return true}}return false}function _h(a,b){if(b){a.bad=true}return a}function ai(a,b,c,d,e){var f="",g=false,h=a.doc.lineSeparator(),i=false;function j(a){return function(b){return b.id==a}}function k(){if(g){f+=h;if(i){f+=h}g=i=false}}function l(a){if(a){k();f+=a}}function m(b){if(b.nodeType==1){var c=b.getAttribute("cm-text");if(c){l(c);return}var f=b.getAttribute("cm-marker"),n;if(f){var o=a.findMarks(eb(d,0),eb(e+1,0),j(+f));if(o.length&&(n=o[0].find(0))){l(Za(a.doc,n.from,n.to).join(h))}return}if(b.getAttribute("contenteditable")=="false"){return}var p=/^(pre|div|p|li|table|br)$/i.test(b.nodeName);if(!/^br$/i.test(b.nodeName)&&b.textContent.length==0){return}if(p){k()}for(var q=0;q=9&&b.hasSelection){b.hasSelection=null}c.poll()});oa(e,"paste",function(a){if(sa(d,a)||Qh(a,d)){return}d.state.pasteIncoming=+new Date;c.fastPoll()});function f(a){if(sa(d,a)){return}if(d.somethingSelected()){Oh({lineWise:false,text:d.getSelections()})}else if(!d.options.lineWiseCopyCut){return}else{var b=Sh(d);Oh({lineWise:true,text:b.text});if(a.type=="cut"){d.setSelections(b.ranges,null,R)}else{c.prevInput="";e.value=b.text.join("\n");J(e)}}if(a.type=="cut"){d.state.cutIncoming=+new Date}}oa(e,"cut",f);oa(e,"copy",f);oa(a.scroller,"paste",function(b){if(Qc(a,b)||sa(d,b)){return}if(!e.dispatchEvent){d.state.pasteIncoming=+new Date;c.focus();return}var f=new Event("paste");f.clipboardData=b.clipboardData;e.dispatchEvent(f)});oa(a.lineSpace,"selectstart",function(b){if(!Qc(a,b)){wa(b)}});oa(e,"compositionstart",function(){var a=d.getCursor("from");if(c.composing){c.composing.range.clear()}c.composing={start:a,range:d.markText(a,d.getCursor("to"),{className:"CodeMirror-composing"})}});oa(e,"compositionend",function(){if(c.composing){c.poll();c.composing.range.clear();c.composing=null}})};di.prototype.createField=function(a){this.wrapper=Uh();this.textarea=this.wrapper.firstChild};di.prototype.screenReaderLabelChanged=function(a){if(a){this.textarea.setAttribute("aria-label",a)}else{this.textarea.removeAttribute("aria-label")}};di.prototype.prepareSelection=function(){var a=this.cm,b=a.display,c=a.doc;var d=Qd(a);if(a.options.moveInputWithCursor){var e=qd(a,c.sel.primary().head,"div");var f=b.wrapper.getBoundingClientRect(),g=b.lineDiv.getBoundingClientRect();d.teTop=Math.max(0,Math.min(b.wrapper.clientHeight-10,e.top+g.top-f.top));d.teLeft=Math.max(0,Math.min(b.wrapper.clientWidth-10,e.left+g.left-f.left))}return d};di.prototype.showSelection=function(a){var b=this.cm,c=b.display;B(c.cursorDiv,a.cursors);B(c.selectionDiv,a.selection);if(a.teTop!=null){this.wrapper.style.top=a.teTop+"px";this.wrapper.style.left=a.teLeft+"px"}};di.prototype.reset=function(a){if(this.contextMenuPending||this.composing){return}var b=this.cm;if(b.somethingSelected()){this.prevInput="";var c=b.getSelection();this.textarea.value=c;if(b.state.focused){J(this.textarea)}if(g&&h>=9){this.hasSelection=c}}else if(!a){this.prevInput=this.textarea.value="";if(g&&h>=9){this.hasSelection=null}}};di.prototype.getField=function(){return this.textarea};di.prototype.supportsTouch=function(){return false};di.prototype.focus=function(){if(this.cm.options.readOnly!="nocursor"&&(!r||G()!=this.textarea)){try{this.textarea.focus()}catch(a){}}};di.prototype.blur=function(){this.textarea.blur()};di.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0};di.prototype.receivedFocus=function(){this.slowPoll()};di.prototype.slowPoll=function(){var a=this;if(this.pollingFast){return}this.polling.set(this.cm.options.pollInterval,function(){a.poll();if(a.cm.state.focused){a.slowPoll()}})};di.prototype.fastPoll=function(){var a=false,b=this;b.pollingFast=true;function c(){var d=b.poll();if(!d&&!a){a=true;b.polling.set(60,c)}else{b.pollingFast=false;b.slowPoll()}}b.polling.set(20,c)};di.prototype.poll=function(){var a=this;var b=this.cm,c=this.textarea,d=this.prevInput;if(this.contextMenuPending||!b.state.focused||Ia(c)&&!d&&!this.composing||b.isReadOnly()||b.options.disableInput||b.state.keySeq){return false}var e=c.value;if(e==d&&!b.somethingSelected()){return false}if(g&&h>=9&&this.hasSelection===e||s&&/[\uf700-\uf7ff]/.test(e)){b.display.input.reset();return false}if(b.doc.sel==b.display.selForContextMenu){var f=e.charCodeAt(0);if(f==8203&&!d){d="​"}if(f==8666){this.reset();return this.cm.execCommand("undo")}}var i=0,j=Math.min(d.length,e.length);while(i1e3||e.indexOf("\n")>-1){c.value=a.prevInput=""}else{a.prevInput=e}if(a.composing){a.composing.range.clear();a.composing.range=b.markText(a.composing.start,b.getCursor("to"),{className:"CodeMirror-composing"})}});return true};di.prototype.ensurePolled=function(){if(this.pollingFast&&this.poll()){this.pollingFast=false}};di.prototype.onKeyPress=function(){if(g&&h>=9){this.hasSelection=null}this.fastPoll()};di.prototype.onContextMenu=function(a){var b=this,c=b.cm,d=c.display,e=b.textarea;if(b.contextMenuPending){b.contextMenuPending()}var f=Hd(c,a),j=d.scroller.scrollTop;if(!f||l){return}var k=c.options.resetSelectionOnContextMenu;if(k&&c.doc.sel.contains(f)==-1){Ee(c,Of)(c.doc,ff(f),R)}var m=e.style.cssText,n=b.wrapper.style.cssText;var o=b.wrapper.offsetParent.getBoundingClientRect();b.wrapper.style.cssText="position: static";e.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(a.clientY-o.top-5)+"px; left: "+(a.clientX-o.left-5)+"px;\n z-index: 1000; background: "+(g?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var p;if(i){p=window.scrollY}d.input.focus();if(i){window.scrollTo(null,p)}d.input.reset();if(!c.somethingSelected()){e.value=b.prevInput=" "}b.contextMenuPending=r;d.selForContextMenu=c.doc.sel;clearTimeout(d.detectingSelectAll);function q(){if(e.selectionStart!=null){var a=c.somethingSelected();var f="​"+(a?e.value:"");e.value="⇚";e.value=f;b.prevInput=a?"":"​";e.selectionStart=1;e.selectionEnd=f.length;d.selForContextMenu=c.doc.sel}}function r(){if(b.contextMenuPending!=r){return}b.contextMenuPending=false;b.wrapper.style.cssText=n;e.style.cssText=m;if(g&&h<9){d.scrollbars.setScrollTop(d.scroller.scrollTop=j)}if(e.selectionStart!=null){if(!g||g&&h<9){q()}var a=0,f=function(){if(d.selForContextMenu==c.doc.sel&&e.selectionStart==0&&e.selectionEnd>0&&b.prevInput=="​"){Ee(c,Wf)(c)}else if(a++<10){d.detectingSelectAll=setTimeout(f,500)}else{d.selForContextMenu=null;d.input.reset()}};d.detectingSelectAll=setTimeout(f,200)}}if(g&&h>=9){q()}if(x){za(a);var s=function(){qa(window,"mouseup",s);setTimeout(r,20)};oa(window,"mouseup",s)}else{setTimeout(r,50)}};di.prototype.readOnlyChanged=function(a){if(!a){this.reset()}this.textarea.disabled=a=="nocursor"};di.prototype.setUneditable=function(){};di.prototype.needsContentAttribute=false;function ei(a,b){b=b?L(b):{};b.value=a.value;if(!b.tabindex&&a.tabIndex){b.tabindex=a.tabIndex}if(!b.placeholder&&a.placeholder){b.placeholder=a.placeholder}if(b.autofocus==null){var c=G();b.autofocus=c==a||a.getAttribute("autofocus")!=null&&c==document.body}function d(){a.value=h.getValue()}var e;if(a.form){oa(a.form,"submit",d);if(!b.leaveSubmitMethodAlone){var f=a.form;e=f.submit;try{var g=f.submit=function(){d();f.submit=e;f.submit();f.submit=g}}catch(i){}}}b.finishInit=function(c){c.save=d;c.getTextArea=function(){return a};c.toTextArea=function(){c.toTextArea=isNaN;d();a.parentNode.removeChild(c.getWrapperElement());a.style.display="";if(a.form){qa(a.form,"submit",d);if(!b.leaveSubmitMethodAlone&&typeof a.form.submit=="function"){a.form.submit=e}}}};a.style.display="none";var h=Jh(function(b){return a.parentNode.insertBefore(b,a.nextSibling)},b);return h}function fi(a){a.off=qa;a.on=oa;a.wheelEventPixels=af;a.Doc=vg;a.splitLines=Ha;a.countColumn=M;a.findColumn=U;a.isWordChar=ba;a.Pass=Q;a.signal=ra;a.Line=hc;a.changeEnd=gf;a.scrollbarModel=se;a.Pos=eb;a.cmpPos=fb;a.modes=Ma;a.mimeModes=Na;a.resolveMode=Qa;a.getMode=Ra;a.modeExtensions=Sa;a.extendMode=Ta;a.copyState=Ua;a.startState=Wa;a.innerMode=Va;a.commands=Xg;a.keyMap=Kg;a.keyName=Qg;a.isModifierKey=Og;a.lookupKey=Ng;a.normalizeKeyMap=Mg;a.StringStream=Xa;a.SharedTextMarker=pg;a.TextMarker=ng;a.LineWidget=jg;a.e_preventDefault=wa;a.e_stopPropagation=xa;a.e_stop=za;a.addClass=H;a.contains=F;a.rmClass=z;a.keyNames=Gg}Gh(Jh);Vh(Jh);var gi="iter insert remove copy getEditor constructor".split(" ");for(var hi in vg.prototype){if(vg.prototype.hasOwnProperty(hi)&&O(gi,hi)<0){Jh.prototype[hi]=function(a){return function(){return a.apply(this.doc,arguments)}}(vg.prototype[hi])}}va(vg);Jh.inputStyles={textarea:di,contenteditable:Yh};Jh.defineMode=function(a){if(!Jh.defaults.mode&&a!="null"){Jh.defaults.mode=a}Oa.apply(this,arguments)};Jh.defineMIME=Pa;Jh.defineMode("null",function(){return{token:function(a){return a.skipToEnd()}}});Jh.defineMIME("text/plain","null");Jh.defineExtension=function(a,b){Jh.prototype[a]=b};Jh.defineDocExtension=function(a,b){vg.prototype[a]=b};Jh.fromTextArea=ei;fi(Jh);Jh.version="5.57.0";return Jh});(function(a){if(typeof exports=="object"&&typeof module=="object")a(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)define(["../../lib/codemirror"],a);else a(CodeMirror)})(function(a){function b(b,c,d){var e=b.getWrapperElement();var f;f=e.appendChild(document.createElement("div"));if(d)f.className="CodeMirror-dialog CodeMirror-dialog-bottom";else f.className="CodeMirror-dialog CodeMirror-dialog-top";if(typeof c=="string"){f.innerHTML=c}else{f.appendChild(c)}a.addClass(e,"dialog-opened");return f}function c(a,b){if(a.state.currentNotificationClose)a.state.currentNotificationClose();a.state.currentNotificationClose=b}a.defineExtension("openDialog",function(d,e,f){if(!f)f={};c(this,null);var g=b(this,d,f.bottom);var h=false,i=this;function j(b){if(typeof b=="string"){k.value=b}else{if(h)return;h=true;a.rmClass(g.parentNode,"dialog-opened");g.parentNode.removeChild(g);i.focus();if(f.onClose)f.onClose(g)}}var k=g.getElementsByTagName("input")[0],l;if(k){k.focus();if(f.value){k.value=f.value;if(f.selectValueOnOpen!==false){k.select()}}if(f.onInput)a.on(k,"input",function(a){f.onInput(a,k.value,j)});if(f.onKeyUp)a.on(k,"keyup",function(a){f.onKeyUp(a,k.value,j)});a.on(k,"keydown",function(b){if(f&&f.onKeyDown&&f.onKeyDown(b,k.value,j)){return}if(b.keyCode==27||f.closeOnEnter!==false&&b.keyCode==13){k.blur();a.e_stop(b);j()}if(b.keyCode==13)e(k.value,b)});if(f.closeOnBlur!==false)a.on(g,"focusout",function(a){if(a.relatedTarget!==null)j()})}else if(l=g.getElementsByTagName("button")[0]){a.on(l,"click",function(){j();i.focus()});if(f.closeOnBlur!==false)a.on(l,"blur",j);l.focus()}return j});a.defineExtension("openConfirm",function(d,e,f){c(this,null);var g=b(this,d,f&&f.bottom);var h=g.getElementsByTagName("button");var i=false,j=this,k=1;function l(){if(i)return;i=true;a.rmClass(g.parentNode,"dialog-opened");g.parentNode.removeChild(g);j.focus()}h[0].focus();for(var m=0;m",triples:"",explode:"[]{}"};var c=a.Pos;a.defineOption("autoCloseBrackets",false,function(b,c,g){if(g&&g!=a.Init){b.removeKeyMap(e);b.state.closeBrackets=null}if(c){f(d(c,"pairs"));b.state.closeBrackets=c;b.addKeyMap(e)}});function d(a,c){if(c=="pairs"&&typeof a=="string")return a;if(typeof a=="object"&&a[c]!=null)return a[c];return b[c]}var e={Backspace:i,Enter:j};function f(a){for(var b=0;b=0;i--){var k=g[i].head;b.replaceRange("",c(k.line,k.ch-1),c(k.line,k.ch+1),"+delete")}}function j(b){var c=h(b);var e=c&&d(c,"explode");if(!e||b.getOption("disableInput"))return a.Pass;var f=b.listSelections();for(var g=0;g0;return{anchor:new c(b.anchor.line,b.anchor.ch+(d?-1:1)),head:new c(b.head.line,b.head.ch+(d?1:-1))}}function l(b,e){var f=h(b);if(!f||b.getOption("disableInput"))return a.Pass;var g=d(f,"pairs");var i=g.indexOf(e);if(i==-1)return a.Pass;var j=d(f,"closeBefore");var l=d(f,"triples");var m=g.charAt(i+1)==e;var o=b.listSelections();var p=i%2==0;var q;for(var r=0;r=0&&b.getRange(t,c(t.line,t.ch+3))==e+e+e)u="skipThree";else u="skip"}else if(m&&t.ch>1&&l.indexOf(e)>=0&&b.getRange(c(t.line,t.ch-2),t)==e+e){if(t.ch>2&&/\bstring/.test(b.getTokenTypeAt(c(t.line,t.ch-2))))return a.Pass;u="addFour"}else if(m){var w=t.ch==0?" ":b.getRange(c(t.line,t.ch-1),t);if(!a.isWordChar(v)&&w!=e&&!a.isWordChar(w))u="both";else return a.Pass}else if(p&&(v.length===0||/\s/.test(v)||j.indexOf(v)>-1)){u="both"}else{return a.Pass}if(!q)q=u;else if(q!=u)return a.Pass}var x=i%2?g.charAt(i-1):e;var y=i%2?e:g.charAt(i+1);b.operation(function(){if(q=="skip"){b.execCommand("goCharRight")}else if(q=="skipThree"){for(var a=0;a<3;a++)b.execCommand("goCharRight")}else if(q=="surround"){var c=b.getSelections();for(var a=0;a",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function e(a){return a&&a.bracketRegex||/[(){}[\]]/}function f(a,b,f){var h=a.getLineHandle(b.line),i=b.ch-1;var j=f&&f.afterCursor;if(j==null)j=/(^| )cm-fat-cursor($| )/.test(a.getWrapperElement().className);var k=e(f);var l=!j&&i>=0&&k.test(h.text.charAt(i))&&d[h.text.charAt(i)]||k.test(h.text.charAt(i+1))&&d[h.text.charAt(++i)];if(!l)return null;var m=l.charAt(1)==">"?1:-1;if(f&&f.strict&&m>0!=(i==b.ch))return null;var n=a.getTokenTypeAt(c(b.line,i+1));var o=g(a,c(b.line,i+(m>0?1:0)),m,n||null,f);if(o==null)return null;return{from:c(b.line,i),to:o&&o.pos,match:o&&o.ch==l.charAt(0),forward:m>0}}function g(a,b,f,g,h){var i=h&&h.maxScanLineLength||1e4;var j=h&&h.maxScanLines||1e3;var k=[];var l=e(h);var m=f>0?Math.min(b.line+j,a.lastLine()+1):Math.max(a.firstLine()-1,b.line-j);for(var n=b.line;n!=m;n+=f){var o=a.getLine(n);if(!o)continue;var p=f>0?0:o.length-1,q=f>0?o.length:-1;if(o.length>i)continue;if(n==b.line)p=b.ch-(f<0?1:0);for(;p!=q;p+=f){var r=o.charAt(p);if(l.test(r)&&(g===undefined||a.getTokenTypeAt(c(n,p+1))==g)){var s=d[r];if(s&&s.charAt(1)==">"==f>0)k.push(r);else if(!k.length)return{pos:c(n,p),ch:r};else k.pop()}}}return n-f==(f>0?a.lastLine():a.firstLine())?false:null}function h(a,d,e){var g=a.state.matchBrackets.maxHighlightLineLength||1e3;var h=[],i=a.listSelections();for(var j=0;j-1?e+b.length:e}var f=b.exec(c?a.slice(c):a);return f?f.index+c+(d?f[0].length:0):-1}return{startState:function(){return{outer:a.startState(b),innerActive:null,inner:null}},copyState:function(c){return{outer:a.copyState(b,c.outer),innerActive:c.innerActive,inner:c.innerActive&&a.copyState(c.innerActive.mode,c.inner)}},token:function(e,f){if(!f.innerActive){var g=Infinity,h=e.string;for(var i=0;i-1)e.string=h.slice(0,k);var p=o.mode.token(e,f.inner);if(k>-1)e.string=h;if(k==e.pos&&o.parseDelimiters)f.innerActive=f.inner=null;if(o.innerStyle){if(p)p=p+" "+o.innerStyle;else p=o.innerStyle}return p}},indent:function(c,d,e){var f=c.innerActive?c.innerActive.mode:b;if(!f.indent)return a.Pass;return f.indent(c.innerActive?c.inner:c.outer,d,e)},blankLine:function(d){var e=d.innerActive?d.innerActive.mode:b;if(e.blankLine){ e.blankLine(d.innerActive?d.inner:d.outer)}if(!d.innerActive){for(var f=0;f2&&k.token&&typeof k.token!="string"){d.pending=[];for(var n=2;n-1)return a.Pass;var g=d.indent.length-1,h=b[d.state];a:for(;;){for(var j=0;j '+a.phrase("(Use line:column or scroll% syntax)")+""}function d(a,b){var c=Number(b);if(/^[-+]/.test(b))return a.getCursor().line+c;else return c-1}a.commands.jumpToLine=function(a){var e=a.getCursor();b(a,c(a),a.phrase("Jump to line:"),e.line+1+":"+e.ch,function(b){if(!b)return;var c;if(c=/^\s*([\+\-]?\d+)\s*\:\s*(\d+)\s*$/.exec(b)){a.setCursor(d(a,c[1]),Number(c[2]))}else if(c=/^\s*([\+\-]?\d+(\.\d+)?)\%\s*/.exec(b)){var f=Math.round(a.lineCount()*Number(c[1])/100);if(/^[-+]/.test(c[1]))f=e.line+f+1;a.setCursor(f-1,e.ch)}else if(c=/^\s*\:?\s*([\+\-]?\d+)\s*/.exec(b)){a.setCursor(d(a,c[1]),e.ch)}})};a.keyMap["default"]["Alt-G"]="jumpToLine"});(function(a){if(typeof exports=="object"&&typeof module=="object")a(require("../../lib/codemirror"),require("./searchcursor"),require("../scroll/annotatescrollbar"));else if(typeof define=="function"&&define.amd)define(["../../lib/codemirror","./searchcursor","../scroll/annotatescrollbar"],a);else a(CodeMirror)})(function(a){"use strict";a.defineExtension("showMatchesOnScrollbar",function(a,c,d){if(typeof d=="string")d={className:d};if(!d)d={};return new b(this,a,c,d)});function b(a,b,c,d){this.cm=a;this.options=d;var e={listenForChanges:false};for(var f in d)e[f]=d[f];if(!e.className)e.className="CodeMirror-search-match";this.annotation=a.annotateScrollbar(e);this.query=b;this.caseFold=c;this.gap={from:a.firstLine(),to:a.lastLine()+1};this.matches=[];this.update=null;this.findMatches();this.annotation.update(this.matches);var g=this;a.on("change",this.changeHandler=function(a,b){g.onChange(b)})}var c=1e3;b.prototype.findMatches=function(){if(!this.gap)return;for(var b=0;b=this.gap.to)break;if(d.to.line>=this.gap.from)this.matches.splice(b--,1)}var e=this.cm.getSearchCursor(this.query,a.Pos(this.gap.from,0),{caseFold:this.caseFold,multiline:this.options.multiline});var f=this.options&&this.options.maxMatches||c;while(e.findNext()){var d={from:e.from(),to:e.to()};if(d.from.line>=this.gap.to)break;this.matches.splice(b++,0,d);if(this.matches.length>f)break}this.gap=null};function d(a,b,c){if(a<=b)return a;return Math.max(b,a+c)}b.prototype.onChange=function(b){var c=b.from.line;var e=a.changeEnd(b).line;var f=e-b.to.line;if(this.gap){this.gap.from=Math.min(d(this.gap.from,c,f),b.from.line);this.gap.to=Math.max(d(this.gap.to,c,f),b.from.line)}else{this.gap={from:b.from.line,to:e+1}}if(f)for(var g=0;gk)break;var m=a.getLine(j++);h=h==null?m:h+"\n"+m}i=i*2;c.lastIndex=g.ch;var n=c.exec(h);if(n){var o=h.slice(0,n.index).split("\n"),p=n[0].split("\n");var q=g.line+o.length-1,r=o[o.length-1].length;return{from:b(q,r),to:b(q+p.length-1,p.length==1?r+p[0].length:p[p.length-1].length),match:n}}}}function h(a,b,c){var d,e=0;while(e<=a.length){b.lastIndex=e;var f=b.exec(a);if(!f)break;var g=f.index+f[0].length;if(g>a.length-c)break;if(!d||g>d.index+d[0].length)d=f;e=f.index+1}return d}function i(a,c,e){c=d(c,"g");for(var f=e.line,g=e.ch,i=a.firstLine();f>=i;f--,g=-1){var j=a.getLine(f);var k=h(j,c,g<0?0:j.length-g);if(k)return{from:b(f,k.index),to:b(f,k.index+k[0].length),match:k}}}function j(a,c,f){if(!e(c))return i(a,c,f);c=d(c,"gm");var g,j=1,k=a.getLine(f.line).length-f.ch;for(var l=f.line,m=a.firstLine();l>=m;){for(var n=0;n=m;n++){var o=a.getLine(l--);g=g==null?o:o+"\n"+g}j*=2;var p=h(g,c,k);if(p){var q=g.slice(0,p.index).split("\n"),r=p[0].split("\n");var s=l+q.length,t=q[q.length-1].length;return{from:b(s,t),to:b(s+r.length-1,r.length==1?t+r[0].length:r[r.length-1].length),match:p}}}}var k,l;if(String.prototype.normalize){k=function(a){return a.normalize("NFD").toLowerCase()};l=function(a){return a.normalize("NFD")}}else{k=function(a){return a.toLowerCase()};l=function(a){return a}}function m(a,b,c,d){if(a.length==b.length)return c;for(var e=0,f=c+Math.max(0,a.length-b.length);;){if(e==f)return e;var g=e+f>>1;var h=d(a.slice(0,g)).length;if(h==c)return g;else if(h>c)f=g;else e=g+1}}function n(a,c,d,e){if(!c.length)return null;var f=e?k:l;var g=f(c).split(/\r|\n\r?/);a:for(var h=d.line,i=d.ch,j=a.lastLine()+1-g.length;h<=j;h++,i=0){var n=a.getLine(h).slice(i),o=f(n);if(g.length==1){var p=o.indexOf(g[0]);if(p==-1)continue a;var d=m(n,o,p,f)+i;return{from:b(h,m(n,o,p,f)+i),to:b(h,m(n,o,p+g[0].length,f)+i)}}else{var q=o.length-g[0].length;if(o.slice(q)!=g[0])continue a;for(var r=1;r=j;h--,i=-1){var n=a.getLine(h);if(i>-1)n=n.slice(0,i);var o=f(n);if(g.length==1){var p=o.lastIndexOf(g[0]);if(p==-1)continue a;return{from:b(h,m(n,o,p,f)),to:b(h,m(n,o,p+g[0].length,f))}}else{var q=g[g.length-1];if(o.slice(0,q.length)!=q)continue a;for(var r=1,d=h-g.length+1;r0)break;d.push({anchor:e.from(),head:e.to()})}if(d.length)this.setSelections(d,0)})});(function(a){if(typeof exports=="object"&&typeof module=="object")a(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog"));else if(typeof define=="function"&&define.amd)define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],a);else a(CodeMirror)})(function(a){"use strict";function b(a,b){if(typeof a=="string")a=new RegExp(a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),b?"gi":"g");else if(!a.global)a=new RegExp(a.source,a.ignoreCase?"gi":"g");return{token:function(b){a.lastIndex=b.pos;var c=a.exec(b.string);if(c&&c.index==b.pos){b.pos+=c[0].length||1;return"searching"}else if(c){b.pos=c.index}else{b.skipToEnd()}}}}function c(){this.posFrom=this.posTo=this.lastQuery=this.query=null;this.overlay=null}function d(a){return a.state.search||(a.state.search=new c)}function e(a){return typeof a=="string"&&a==a.toLowerCase()}function f(a,b,c){return a.getSearchCursor(b,c,{caseFold:e(b),multiline:true})}function g(a,b,c,d,e){a.openDialog(b,d,{value:c,selectValueOnOpen:true,closeOnEnter:false,onClose:function(){o(a)},onKeyDown:e})}function h(a,b,c,d,e){if(a.openDialog)a.openDialog(b,e,{value:d,selectValueOnOpen:true});else e(prompt(c,d))}function i(a,b,c,d){if(a.openConfirm)a.openConfirm(b,d);else if(confirm(c))d[0]()}function j(a){return a.replace(/\\([nrt\\])/g,function(a,b){if(b=="n")return"\n";if(b=="r")return"\r";if(b=="t")return"\t";if(b=="\\")return"\\";return a})}function k(a){var b=a.match(/^\/(.*)\/([a-z]*)$/);if(b){try{a=new RegExp(b[1],b[2].indexOf("i")==-1?"":"i")}catch(c){}}else{a=j(a)}if(typeof a=="string"?a=="":a.test(""))a=/x^/;return a}function l(a,c,d){c.queryText=d;c.query=k(d);a.removeOverlay(c.overlay,e(c.query));c.overlay=b(c.query,e(c.query));a.addOverlay(c.overlay);if(a.showMatchesOnScrollbar){if(c.annotate){c.annotate.clear();c.annotate=null}c.annotate=a.showMatchesOnScrollbar(c.query,e(c.query))}}function m(b,c,e,f){var i=d(b);if(i.query)return n(b,c);var j=b.getSelection()||i.lastQuery;if(j instanceof RegExp&&j.source=="x^")j=null;if(e&&b.openDialog){var k=null;var m=function(c,d){a.e_stop(d);if(!c)return;if(c!=i.queryText){l(b,i,c);i.posFrom=i.posTo=b.getCursor()}if(k)k.style.opacity=1;n(b,d.shiftKey,function(a,c){var d;if(c.line<3&&document.querySelector&&(d=b.display.wrapper.querySelector(".CodeMirror-dialog"))&&d.getBoundingClientRect().bottom-4>b.cursorCoords(c,"window").top)(k=d).style.opacity=.4})};g(b,p(b),j,m,function(c,e){var f=a.keyName(c);var g=b.getOption("extraKeys"),h=g&&g[f]||a.keyMap[b.getOption("keyMap")][f];if(h=="findNext"||h=="findPrev"||h=="findPersistentNext"||h=="findPersistentPrev"){a.e_stop(c);l(b,d(b),e);b.execCommand(h)}else if(h=="find"||h=="findPersistent"){a.e_stop(c);m(e,c)}});if(f&&j){l(b,i,j);n(b,c)}}else{h(b,p(b),"Search for:",j,function(a){if(a&&!i.query)b.operation(function(){l(b,i,a);i.posFrom=i.posTo=b.getCursor();n(b,c)})})}}function n(b,c,e){b.operation(function(){var g=d(b);var h=f(b,g.query,c?g.posFrom:g.posTo);if(!h.find(c)){h=f(b,g.query,c?a.Pos(b.lastLine()):a.Pos(b.firstLine(),0));if(!h.find(c))return}b.setSelection(h.from(),h.to());b.scrollIntoView({from:h.from(),to:h.to()},20);g.posFrom=h.from();g.posTo=h.to();if(e)e(h.from(),h.to())})}function o(a){a.operation(function(){var b=d(a);b.lastQuery=b.query;if(!b.query)return;b.query=b.queryText=null;a.removeOverlay(b.overlay);if(b.annotate){b.annotate.clear();b.annotate=null}})}function p(a){return''+a.phrase("Search:")+' '+a.phrase("(Use /re/ syntax for regexp search)")+""}function q(a){return' '+a.phrase("(Use /re/ syntax for regexp search)")+""}function r(a){return''+a.phrase("With:")+' '}function s(a){return''+a.phrase("Replace?")+" "}function t(a,b,c){a.operation(function(){for(var d=f(a,b);d.findNext();){if(typeof b!="string"){var e=a.getRange(d.from(),d.to()).match(b);d.replace(c.replace(/\$(\d)/g,function(a,b){return e[b]}))}else d.replace(c)}})}function u(a,b){if(a.getOption("readOnly"))return;var c=a.getSelection()||d(a).lastQuery;var e=''+(b?a.phrase("Replace all:"):a.phrase("Replace:"))+"";h(a,e+q(a),e,c,function(c){if(!c)return;c=k(c);h(a,r(a),a.phrase("Replace with:"),"",function(d){d=j(d);if(b){t(a,c,d)}else{o(a);var e=f(a,c,a.getCursor("from"));var g=function(){var b=e.from(),j;if(!(j=e.findNext())){e=f(a,c);if(!(j=e.findNext())||b&&e.from().line==b.line&&e.from().ch==b.ch)return}a.setSelection(e.from(),e.to());a.scrollIntoView({from:e.from(),to:e.to()});i(a,s(a),a.phrase("Replace?"),[function(){h(j)},g,function(){t(a,c,d)}])};var h=function(a){e.replace(typeof c=="string"?d:d.replace(/\$(\d)/g,function(b,c){return a[c]}));g()};g()}})})}a.commands.find=function(a){o(a);m(a)};a.commands.findPersistent=function(a){o(a);m(a,false,true)};a.commands.findPersistentNext=function(a){m(a,false,true,true)};a.commands.findPersistentPrev=function(a){m(a,true,true,true)};a.commands.findNext=m;a.commands.findPrev=function(a){m(a,true)};a.commands.clearSearch=o;a.commands.replace=u;a.commands.replaceAll=function(a){u(a,true)}});(function(a){if(typeof exports=="object"&&typeof module=="object")a(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)define(["../../lib/codemirror"],a);else a(CodeMirror)})(function(a){"use strict";var b="CodeMirror-activeline";var c="CodeMirror-activeline-background";var d="CodeMirror-activeline-gutter";a.defineOption("styleActiveLine",false,function(b,c,d){var f=d==a.Init?false:d;if(c==f)return;if(f){b.off("beforeSelectionChange",h);e(b);delete b.state.activeLines}if(c){b.state.activeLines=[];g(b,b.listSelections());b.on("beforeSelectionChange",h)}});function e(a){for(var e=0;eg)return b.charCoords(a,"local")[c?"top":"bottom"];var e=b.heightAtLine(i,"local");return e+(c?0:i.height)}var k=b.lastLine();if(b.display.barWidth)for(var l=0,m;lk)continue;var o=m||j(n.from,true)*c;var p=j(n.to,false)*c;while(lk)break;m=j(e[l+1].from,true)*c;if(m>p+.9)break;n=e[++l];p=j(n.to,false)*c}if(p==o)continue;var q=Math.max(p-o,3);var r=d.appendChild(document.createElement("div"));r.style.cssText="position: absolute; right: 0px; width: "+Math.max(b.display.barWidth-1,2)+"px; top: "+(o+this.buttonHeight)+"px; height: "+q+"px";r.className=this.options.className;if(n.id){r.setAttribute("annotation-id",n.id)}}this.div.textContent="";this.div.appendChild(d)};b.prototype.clear=function(){this.cm.off("refresh",this.resizeHandler);this.cm.off("markerAdded",this.resizeHandler);this.cm.off("markerCleared",this.resizeHandler);if(this.changeHandler)this.cm.off("changes",this.changeHandler);this.div.parentNode.removeChild(this.div)}});(function(a){if(typeof exports=="object"&&typeof module=="object")a(require("../../lib/codemirror"));else if(typeof define=="function"&&define.amd)define(["../../lib/codemirror"],a);else a(CodeMirror)})(function(a){"use strict";function b(b,c,d){this.orientation=c;this.scroll=d;this.screen=this.total=this.size=1;this.pos=0;this.node=document.createElement("div");this.node.className=b+"-"+c;this.inner=this.node.appendChild(document.createElement("div"));var e=this;a.on(this.inner,"mousedown",function(b){if(b.which!=1)return;a.e_preventDefault(b);var c=e.orientation=="horizontal"?"pageX":"pageY";var d=b[c],f=e.pos;function g(){a.off(document,"mousemove",h);a.off(document,"mouseup",g)}function h(a){if(a.which!=1)return g();e.moveTo(f+(a[c]-d)*(e.total/e.size))}a.on(document,"mousemove",h);a.on(document,"mouseup",g)});a.on(this.node,"click",function(b){a.e_preventDefault(b);var c=e.inner.getBoundingClientRect(),d;if(e.orientation=="horizontal")d=b.clientXc.right?1:0;else d=b.clientYc.bottom?1:0;e.moveTo(e.pos+d*e.screen)});function f(b){var c=a.wheelEventPixels(b)[e.orientation=="horizontal"?"x":"y"];var d=e.pos;e.moveTo(e.pos+c);if(e.pos!=d)a.e_preventDefault(b)}a.on(this.node,"mousewheel",f);a.on(this.node,"DOMMouseScroll",f)}b.prototype.setPos=function(a,b){if(a<0)a=0;if(a>this.total-this.screen)a=this.total-this.screen;if(!b&&a==this.pos)return false;this.pos=a;this.inner.style[this.orientation=="horizontal"?"left":"top"]=a*(this.size/this.total)+"px";return true};b.prototype.moveTo=function(a){if(this.setPos(a))this.scroll(a,this.orientation)};var c=10;b.prototype.update=function(a,b,d){var e=this.screen!=b||this.total!=a||this.size!=d;if(e){this.screen=b;this.total=a;this.size=d}var f=this.screen*(this.size/this.total);if(fa.clientWidth+1;var e=a.scrollHeight>a.clientHeight+1;this.vert.node.style.display=e?"block":"none";this.horiz.node.style.display=d?"block":"none";if(e){this.vert.update(a.scrollHeight,a.clientHeight,a.viewHeight-(d?c:0));this.vert.node.style.bottom=d?c+"px":"0"}if(d){this.horiz.update(a.scrollWidth,a.clientWidth,a.viewWidth-(e?c:0)-a.barLeft);this.horiz.node.style.right=e?c+"px":"0";this.horiz.node.style.left=a.barLeft+"px"}return{right:e?c:0,bottom:d?c:0}};d.prototype.setScrollTop=function(a){this.vert.setPos(a)};d.prototype.setScrollLeft=function(a){this.horiz.setPos(a)};d.prototype.clear=function(){var a=this.horiz.node.parentNode;a.removeChild(this.horiz.node);a.removeChild(this.vert.node)};a.scrollbarModel.simple=function(a,b){return new d("CodeMirror-simplescroll",a,b)};a.scrollbarModel.overlay=function(a,b){return new d("CodeMirror-overlayscroll",a,b)}});(function(a){"use strict";if(typeof exports==="object"&&typeof module==="object")a(require("../../lib/codemirror"));else if(typeof define==="function"&&define.amd)define(["../../lib/codemirror"],a);else a(CodeMirror)})(function(a){"use strict";a.defineOption("showInvisibles",false,function(d,e,f){var g=0,h=d.getOption("maxInvisibles")||16;if(f===a.Init)f=false;if(f&&!e){d.removeOverlay("invisibles");c()}else if(!f&&e){b(h);d.addOverlay({name:"invisibles",token:function i(a){var b,c=0,d=a.peek()===" ";if(d){while(d&&c div > pre > span::after {","pointer-events: none;","color: #404F7D;",'content: "¬"',"}"].join("");return a}});CodeMirror.defineMode("doku",function(a,b){"use strict";var c;var d={blankLine:function(a){if(a.current.patterns){for(var b=0;b",style:"tag"}],patterns:[{match:"",exit:true,style:"tag"}]},{name:"superscript",type:"formatting",allowedTypes:["formatting","substition","disabled"],entries:[{match:"",style:"tag"}],patterns:[{match:"",exit:true,style:"tag"}]},{name:"deleted",type:"formatting",allowedTypes:["formatting","substition","disabled"],entries:[{match:"",style:"tag"}],patterns:[{match:"",exit:true,style:"tag"}]},{name:"linebreak",type:"substition",entries:[{match:/^\\\\(?:[ \t]|$)/,exit:true}],style:"tag"},{name:"footnote",type:"formatting",allowedTypes:["container","formatting","substition","protected","disabled"],entries:[{match:"((",style:"tag"}],patterns:[{match:"))",exit:true,style:"tag"}]},{name:"hr",type:"container",entries:[{sol:true,match:/^[ \t]*-{4,}[ \t]*$/,exit:true}],style:"hr"},{name:"unformatted",type:"disabled",entries:[{match:"",style:"tag"}],patterns:[{match:"",exit:true,style:"tag"}]},{name:"unformattedalt",type:"disabled",entries:[{match:"%%"}],patterns:[{match:"%%",exit:true}],style:"string"},{name:"php",type:"protected",entries:[{match:"",style:"tag",lang:"php"}],patterns:[{match:"",exit:true,style:"tag"}]},{name:"phpblock",type:"protected",entries:[{match:"",style:"tag",lang:"php"}],patterns:[{match:"",exit:true,style:"tag"}]},{name:"html",type:"protected",entries:[{match:"",style:"tag",lang:"html"}],patterns:[{match:"",exit:true,style:"tag"}]},{name:"htmlblock",type:"protected",entries:[{match:"",style:"tag",lang:"html"}],patterns:[{match:"",exit:true,style:"tag"}]},{name:"code",type:"protected",entries:[{match:/^|$)/,style:"tag"}],patterns:[{match:"",exit:true,style:"tag"}],token:m},{name:"file",type:"protected",entries:[{match:/^|$)/,style:"tag"}],patterns:[{match:"",exit:true,style:"tag"}],token:m},{name:"quote",type:"container",allowedTypess:["formatting","substition","disabled","protected"],entries:[{sol:true,match:/^>{1,}/,style:"def"}],patterns:[{sol:true,match:/^>{1,}/,style:"def"},{sol:true,exit:true}]}];if(b.smileys.length>0){c.push({name:"smiley",type:"substition",entries:[{behind:/\B$/,match:f(b.smileys,"(?=\\W|$)"),exit:true}],style:"keyword"})}if(b.acronyms.length>0){c.push({name:"acronym",type:"substition",entries:[{behind:/\B$/,match:f(b.acronyms,"(?=\\W|$)"),exit:true}],style:"keyword"})}if(b.entities.length>0){c.push({name:"entity",type:"substition",entries:[{match:f(b.entities),exit:true}],style:"keyword"})}c.push({name:"multipluentity",type:"substition",sort:270,entries:[{behind:/\B$/,match:/^(?:[1-9]|\d{2,})(?=[xX]\d+\b)/}],patterns:[{match:/^[xX]/,style:"keyword"},{match:/^\d+\b/,exit:true}]});if(b.camelcase){c.push({name:"camelcaselink",type:"substition",emtry:[{behind:/\B$/,match:/^[A-Z]+[a-z]+[A-Z][A-Za-z]*\b/,exit:true}],style:"link"})}c.push({name:"internallink",type:"substition",entries:[{match:"[["}],token:function(a,b){var c;if(a.match("]]")){b.current=b.stack.pop();b.linkTitle=false}else if(!b.linkTitle&&a.match("|")){b.linkTitle=true}else{a.next();c=b.linkTitle?"string":"link"}return o(b,c)}},{name:"rss",type:"substition",entries:[{match:"{{rss>",style:"tag"}],patterns:[{match:"}}",exit:true,style:"tag"}]},{name:"media",type:"substition",entries:[{match:/^\{\{ */}],token:function(a,b){var c;if(a.match(/^ *\}\}/)){b.current=b.stack.pop();b.linkParam=false;b.linkTitle=false}else if(b.linkTitle){c="string";a.next()}else if(a.match(/^\s*\|/)){b.linkTitle=true}else if(b.linkParam){if(a.match(/^(?:nolink|direct|linkonly)/)){c="keyword"}else if(a.match(/^(?:nocache|recache)/)){c="meta"}else if(a.match(/^\d+(?:[xX]\d+)?/)){c="number"}else if(!a.match(/^\s+/)){a.next();c="error"}}else if(a.match(/^\?(?=[^\?]*$)/)){b.linkParam=true}else{a.next();c="link"}return o(b,c)}},{name:"externallink",type:"substition",entries:[{behind:/\B$/,match:h(b.schemes),exit:true}],style:"link"},{name:"emaillink",type:"substition",entries:[{match:g(),exit:true}],style:"link"},{name:"windowssharelink",type:"substition",entries:[{match:/^\\\\\w+?(?:\\[\w-$]+)+/,exit:true}],style:"link"},{name:"filelink",type:"substition",entries:[{behind:/\B$/,match:i(),exit:true}],style:"link"});p();return d;function e(a){return a.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")}function f(a,b,c){var d=[];for(var f=0;f","i")}function h(a){var b=".:?\\-;,";var c="\\w"+b;var d="\\w/\\#~:.?+=&%@!\\-\\[\\]"+b;var e=[];for(var f=0;f")){j(c,c.codeLang);c.codeLang=null;c.codeFilename=false;return o(c,"tag")}if(a.match(/^\s+/)){return o(c)}if(a.match(/^[^\s>]+/)){var d;if(!c.codeLang){c.codeLang=a.current();if(b.validLang(c.codeLang)){d="keyword"}else{d="error"}}else if(!c.codeFilename){c.codeFilename=true;d="string"}else{d="error"}return o(c,d)}}function n(a,b){var c=b.current.allowedModes;var d,e;for(var f=0;!d&&f0){CodeMirror.requireMode(f.pop(),g)}else{d()}};do{var h=f.pop();if(!CodeMirror.modes.hasOwnProperty(h)){CodeMirror.requireMode(h,g);return CodeMirror.getMode(b,{name:"doku-null"})}}while(f.length>0);var i=e.options||{};i.name=e.mime||e.name;return CodeMirror.getMode(b,i)}function g(){var b=window.DWgetSelection(e.get(0));a.toTextArea();a=null;window.DWsetSelection(b);e.focus();if(JSINFO.plugin_codemirror.autoheight.toString()==="1"){jQuery('#size__ctl img[src$="/larger.gif"], '+'#size__ctl img[src$="/smaller.gif"]').show()}}function h(){var b=window.DWgetSelection(e.get(0));a=CodeMirror.fromTextArea(e.get(0),{mode:"null"});a.setOption("lineWrapping",e.prop("wrap")!=="off");a.setOption("readOnly",e.prop("readonly"));a.setOption("tabSize",8);a.setOption("extraKeys",{Enter:function(a){return p(a,"Enter")},Space:function(a){return p(a,"Space")},Backspace:function(a){return p(a,"Backspace")},"Ctrl-Enter":function(){jQuery("#edbtn__save").click()}});a.setOption("scrollbarStyle",JSINFO.plugin_codemirror.usenativescroll.toString()==="1"?"native":"overlay");a.setSize(null,e.css("height"));a.getDoc().on("change",function(){var b=new Date;if(b.getTime()-dw_locktimer.lasttime.getTime()>3e4){e.val(a.getDoc().getValue());dw_locktimer.refresh()}});jQuery.each(d,function(a,b){if(a!=="nativeeditor"){var c=m(a);b.callback(c)}});window.DWsetSelection(b);if(JSINFO.plugin_codemirror.autoheight.toString()==="1"){jQuery("form#dw__editform .CodeMirror").css({height:"auto"});jQuery('#size__ctl img[src$="/larger.gif"], '+'#size__ctl img[src$="/smaller.gif"]').hide();a.setOption("viewportMargin",Infinity)}}function i(){b=JSINFO.plugin_codemirror;b.name="doku";b.loadMode=function(c){var d=function(){a.setOption("mode",b)};return f(c,a.options,d)};b.validLang=function(a){return c[a]!==undefined};CodeMirror.defineMode("doku-null",function(){return{token:function(a){a.next()}}})}function j(){var b={setWrap:dw_editor.setWrap,sizeCtl:dw_editor.sizeCtl,currentHeadlineLevel:window.currentHeadlineLevel,selection_class:window.selection_class,DWgetSelection:window.DWgetSelection||window.getSelection,DWsetSelection:window.DWsetSelection||window.setSelection,pasteText:window.pasteText};dw_editor.setWrap=function(c,d){b.setWrap(c,d);if(a&&e.is(c)){a.setOption("lineWrapping",d!=="off")}};dw_editor.sizeCtl=function(c,d){b.sizeCtl(c,d);if(a&&e.is(c)){a.setSize(null,e.css("height"))}};window.currentHeadlineLevel=function(c){if(a&&e.is("#"+c)){e.val(a.getDoc().getValue())}return b.currentHeadlineLevel(c)};window.selection_class=function(){b.selection_class.apply(this);var c=this.getText;this.geText=function(){if(a&&e.is(this.obj)){var b=a.getDoc();var d=b.indexFromPos(this.start);var f=b.indexFromPos(this.end);return b.getRange(d,f)}else{return c.apply(this)}}};window.DWgetSelection=function(c){if(a&&e.is(c)){var d=a.getDoc();var f=new window.selection_class;f.obj=c;f.start=d.indexFromPos(d.getCursor("from"));f.end=d.indexFromPos(d.getCursor("to"));e.val(d.getValue());return f}else{return b.DWgetSelection(c)}};window.DWsetSelection=function(c){if(a&&e.is(c.obj)){var d=a.getDoc();var f=d.posFromIndex(c.start);var g=d.posFromIndex(c.end);d.setSelection(f,g);a.focus()}else{b.DWsetSelection(c)}};window.pasteText=function(c,d,f){if(a&&e.is(c.obj)){var g=a.getDoc();e.val(g.getValue());var h=g.posFromIndex(c.start);var i=g.posFromIndex(c.end);g.replaceRange(d,h,i);b.pasteText(c,d,f);a.focus()}else{b.pasteText(c,d,f)}}}function k(a){var b=jQuery("").attr("class","cm-settings-button");b.attr("src",JSINFO.plugin_codemirror.iconURL);b.on("click",function(){var b=jQuery(this).offset();var c=jQuery(this).outerWidth();var d=a.outerWidth();var e=a.outerHeight();a.css("top",b.top-e);a.css("left",b.left+c-d);a.toggle();return false});if(jQuery("#size__ctl").length>0){b.appendTo("#size__ctl")}else{b.appendTo("#draft__status")}}function l(){var a=jQuery("