"A\u062EA")),i=t(n,0,1).getBoundingClientRect(),o=t(n,1,2).getBoundingClientRect();return removeChildren(e),!!i&&i.left!=i.right&&(r=o.right-i.right<3)}var G=3!=`

b`.split(/\n/).length?function(e){for(var t=0,n=[],r=e.length;t<=r;){var i=e.indexOf(`
`,t);-1==i&&(i=e.length);var o=e.slice(t,`\r`==e.charAt(i-1)?i-1:i),a=o.indexOf(`\r`);-1!=a?(n.push(o.slice(0,a)),t+=a+1):(n.push(o),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},_=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch{return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch{}return!!t&&t.parentElement()==e&&0!=t.compareEndPoints("StartToEnd",t)},K="oncopy"in(e=elt("div"))||(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy),j=null;function hasBadZoomedRects(e){if(null!=j)return j;var n=removeChildrenAndAdd(e,elt("span","x")),r=n.getBoundingClientRect(),i=t(n,0,1).getBoundingClientRect();return j=Math.abs(r.left-i.left)>1}var X={},Y={};function defineMode(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),X[e]=t}function defineMIME(e,t){Y[e]=t}function resolveMode(e){if("string"==typeof e&&Y.hasOwnProperty(e))e=Y[e];else if(e&&"string"==typeof e.name&&Y.hasOwnProperty(e.name)){var t=Y[e.name];"string"==typeof t&&(t={name:t}),(e=createObj(t,e)).name=t.name}else if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return resolveMode("application/xml");else if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return resolveMode("application/json");return"string"==typeof e?{name:e}:e||{name:"null"}}function getMode(e,t){var n=X[(t=resolveMode(t)).name];if(!n)return getMode(e,"text/plain");var r=n(e,t);if(q.hasOwnProperty(t.name)){var i=q[t.name];for(var o in i)i.hasOwnProperty(o)&&(r.hasOwnProperty(o)&&(r["_"+o]=r[o]),r[o]=i[o])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var a in t.modeProps)r[a]=t.modeProps[a];return r}var q={};function extendMode(e,t){copyObj(t,q.hasOwnProperty(e)?q[e]:q[e]={})}function copyState(e,t){if(!0===t)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n}function innerMode(e,t){for(var n;e.innerMode&&(n=e.innerMode(t))&&n.mode!=e;)t=n.state,e=n.mode;return n||{mode:e,state:t}}function startState(e,t,n){return!e.startState||e.startState(t,n)}var StringStream=function(e,t,n){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};function getLine(e,t){if((t-=e.first)<0||t>=e.size)throw Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(t<o){n=i;break}t-=o}return n.lines[t]}function getBetween(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,function(e){var o=e.text;i==n.line&&(o=o.slice(0,n.ch)),i==t.line&&(o=o.slice(t.ch)),r.push(o),++i}),r}function getLines(e,t,n){var r=[];return e.iter(t,n,function(e){r.push(e.text)}),r}function updateLineHeight(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function lineNo(e){if(null==e.parent)return null;for(var t=e.parent,n=indexOf(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var i=0;r.children[i]!=t;++i)n+=r.children[i].chunkSize();return n+t.first}function lineAtHeight(e,t){var n=e.first;e:do{for(var r=0;r<e.children.length;++r){var i=e.children[r],o=i.height;if(t<o){e=i;continue e}t-=o,n+=i.chunkSize()}return n}while(!e.lines)for(var a=0;a<e.lines.length;++a){var s=e.lines[a].height;if(t<s)break;t-=s}return n+a}function isLine(e,t){return t>=e.first&&t<e.first+e.size}function lineNumberFor(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function Pos(e,t,n){if(void 0===n&&(n=null),!(this instanceof Pos))return new Pos(e,t,n);this.line=e,this.ch=t,this.sticky=n}function cmp(e,t){return e.line-t.line||e.ch-t.ch}function equalCursorPos(e,t){return e.sticky==t.sticky&&0==cmp(e,t)}function copyPos(e){return Pos(e.line,e.ch)}function maxPos(e,t){return 0>cmp(e,t)?t:e}function minPos(e,t){return 0>cmp(e,t)?e:t}function clipLine(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function clipPos(e,t){if(t.line<e.first)return Pos(e.first,0);var n=e.first+e.size-1;return t.line>n?Pos(n,getLine(e,n).text.length):clipToLen(t,getLine(e,t.line).text.length)}function clipToLen(e,t){var n=e.ch;return null==n||n>t?Pos(e.line,t):n<0?Pos(e.line,0):e}function clipPosArray(e,t){for(var n=[],r=0;r<t.length;r++)n[r]=clipPos(e,t[r]);return n}StringStream.prototype.eol=function(){return this.pos>=this.string.length},StringStream.prototype.sol=function(){return this.pos==this.lineStart},StringStream.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},StringStream.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},StringStream.prototype.eat=function(e){var t=this.string.charAt(this.pos);if("string"==typeof e?t==e:t&&(e.test?e.test(t):e(t)))return++this.pos,t},StringStream.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},StringStream.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},StringStream.prototype.skipToEnd=function(){this.pos=this.string.length},StringStream.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},StringStream.prototype.backUp=function(e){this.pos-=e},StringStream.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=countColumn(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?countColumn(this.string,this.lineStart,this.tabSize):0)},StringStream.prototype.indentation=function(){return countColumn(this.string,null,this.tabSize)-(this.lineStart?countColumn(this.string,this.lineStart,this.tabSize):0)},StringStream.prototype.match=function(e,t,n){if("string"==typeof e){var cased=function(e){return n?e.toLowerCase():e};if(cased(this.string.substr(this.pos,e.length))==cased(e))return!1!==t&&(this.pos+=e.length),!0}else{var r=this.string.slice(this.pos).match(e);return r&&r.index>0?null:(r&&!1!==t&&(this.pos+=r[0].length),r)}},StringStream.prototype.current=function(){return this.string.slice(this.start,this.pos)},StringStream.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},StringStream.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},StringStream.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var SavedContext=function(e,t){this.state=e,this.lookAhead=t},Context=function(e,t,n,r){this.state=t,this.doc=e,this.line=n,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};function highlightLine(e,t,n,r){var i=[e.state.modeGen],o={};runMode(e,t.text,e.doc.mode,n,function(e,t){return i.push(e,t)},o,r);for(var a=n.state,s=0;s<e.state.overlays.length;++s)!function(r){n.baseTokens=i;var s=e.state.overlays[r],l=1,c=0;n.state=!0,runMode(e,t.text,s.mode,n,function(e,t){for(var n=l;c<e;){var r=i[l];r>e&&i.splice(l,1,e,i[l+1],r),l+=2,c=Math.min(e,r)}if(t)if(s.opaque)i.splice(n,l-n,e,"overlay "+t),l=n+2;else for(;n<l;n+=2){var o=i[n+1];i[n+1]=(o?o+" ":"")+"overlay "+t}},o),n.state=a,n.baseTokens=null,n.baseTokenPos=1}(s);return{styles:i,classes:o.bgClass||o.textClass?o:null}}function getLineStyles(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=getContextBefore(e,lineNo(t)),i=t.text.length>e.options.maxHighlightLength&&copyState(e.doc.mode,r.state),o=highlightLine(e,t,r);i&&(r.state=i),t.stateAfter=r.save(!i),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function getContextBefore(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return new Context(r,!0,t);var o=findStartLine(e,t,n),a=o>r.first&&getLine(r,o-1).stateAfter,s=a?Context.fromSaved(r,a,o):new Context(r,startState(r.mode),o);return r.iter(o,t,function(n){processLine(e,n.text,s);var r=s.line;n.stateAfter=r==t-1||r%5==0||r>=i.viewFrom&&r<i.viewTo?s.save():null,s.nextLine()}),n&&(r.modeFrontier=s.line),s}function processLine(e,t,n,r){var i=e.doc.mode,o=new StringStream(t,e.options.tabSize,n);for(o.start=o.pos=r||0,""==t&&callBlankLine(i,n.state);!o.eol();)readToken(i,o,n.state),o.start=o.pos}function callBlankLine(e,t){if(e.blankLine)return e.blankLine(t);if(e.innerMode){var n=innerMode(e,t);if(n.mode.blankLine)return n.mode.blankLine(n.state)}}function readToken(e,t,n,r){for(var i=0;i<10;i++){r&&(r[0]=innerMode(e,n).mode);var o=e.token(t,n);if(t.pos>t.start)return o}throw Error("Mode "+e.name+" failed to advance stream.")}Context.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Context.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},Context.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Context.fromSaved=function(e,t,n){return t instanceof SavedContext?new Context(e,copyState(e.mode,t.state),n,t.lookAhead):new Context(e,copyState(e.mode,t),n)},Context.prototype.save=function(e){var t=!1!==e?copyState(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new SavedContext(t,this.maxLookAhead):t};var Token=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n};function takeToken(e,t,n,r){var i,o=e.doc,a=o.mode;t=clipPos(o,t);var s,l=getLine(o,t.line),c=getContextBefore(e,t.line,n),u=new StringStream(l.text,e.options.tabSize,c);for(r&&(s=[]);(r||u.pos<t.ch)&&!u.eol();)u.start=u.pos,i=readToken(a,u,c.state),r&&s.push(new Token(u,i,copyState(o.mode,c.state)));return r?s:new Token(u,i,c.state)}function extractLineClasses(e,t){if(e)for(;;){var n=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;e=e.slice(0,n.index)+e.slice(n.index+n[0].length);var r=n[1]?"bgClass":"textClass";null==t[r]?t[r]=n[2]:RegExp("(?:^|\\s)"+n[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+n[2])}return e}function runMode(e,t,n,r,i,o,a){var s=n.flattenSpans;null==s&&(s=e.options.flattenSpans);var l,c=0,u=null,d=new StringStream(t,e.options.tabSize,r),h=e.options.addModeClass&&[null];for(""==t&&extractLineClasses(callBlankLine(n,r.state),o);!d.eol();){if(d.pos>e.options.maxHighlightLength?(s=!1,a&&processLine(e,t,r,d.pos),d.pos=t.length,l=null):l=extractLineClasses(readToken(n,d,r.state,h),o),h){var f=h[0].name;f&&(l="m-"+(l?f+" "+l:f))}if(!s||u!=l){for(;c<d.start;)i(c=Math.min(d.start,c+5e3),u);u=l}d.start=d.pos}for(;c<d.pos;){var g=Math.min(d.pos,c+5e3);i(g,u),c=g}}function findStartLine(e,t,n){for(var r,i,o=e.doc,a=n?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>a;--s){if(s<=o.first)return o.first;var l=getLine(o,s-1),c=l.stateAfter;if(c&&(!n||s+(c instanceof SavedContext?c.lookAhead:0)<=o.modeFrontier))return s;var u=countColumn(l.text,null,e.options.tabSize);(null==i||r>u)&&(i=s-1,r=u)}return i}function retreatFrontier(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontier<t-10)){for(var n=e.first,r=t-1;r>n;r--){var i=getLine(e,r).stateAfter;if(i&&(!(i instanceof SavedContext)||r+i.lookAhead<t)){n=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,n)}}var $=!1,Z=!1;function seeReadOnlySpans(){$=!0}function seeCollapsedSpans(){Z=!0}function MarkedSpan(e,t,n){this.marker=e,this.from=t,this.to=n}function getMarkedSpanFor(e,t){if(e)for(var n=0;n<e.length;++n){var r=e[n];if(r.marker==t)return r}}function removeMarkedSpan(e,t){for(var n,r=0;r<e.length;++r)e[r]!=t&&(n||(n=[])).push(e[r]);return n}function addMarkedSpan(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}function markedSpansBefore(e,t,n){var r;if(e)for(var i=0;i<e.length;++i){var o=e[i],a=o.marker;if(null==o.from||(a.inclusiveLeft?o.from<=t:o.from<t)||o.from==t&&"bookmark"==a.type&&(!n||!o.marker.insertLeft)){var s=null==o.to||(a.inclusiveRight?o.to>=t:o.to>t);(r||(r=[])).push(new MarkedSpan(a,o.from,s?null:o.to))}}return r}function markedSpansAfter(e,t,n){var r;if(e)for(var i=0;i<e.length;++i){var o=e[i],a=o.marker;if(null==o.to||(a.inclusiveRight?o.to>=t:o.to>t)||o.from==t&&"bookmark"==a.type&&(!n||o.marker.insertLeft)){var s=null==o.from||(a.inclusiveLeft?o.from<=t:o.from<t);(r||(r=[])).push(new MarkedSpan(a,s?null:o.from-t,null==o.to?null:o.to-t))}}return r}function stretchSpansOverChange(e,t){if(t.full)return null;var n=isLine(e,t.from.line)&&getLine(e,t.from.line).markedSpans,r=isLine(e,t.to.line)&&getLine(e,t.to.line).markedSpans;if(!n&&!r)return null;var i=t.from.ch,o=t.to.ch,a=0==cmp(t.from,t.to),s=markedSpansBefore(n,i,a),l=markedSpansAfter(r,o,a),c=1==t.text.length,u=lst(t.text).length+(c?i:0);if(s)for(var d=0;d<s.length;++d){var h=s[d];if(null==h.to){var f=getMarkedSpanFor(l,h.marker);f?c&&(h.to=null==f.to?null:f.to+u):h.to=i}}if(l)for(var g=0;g<l.length;++g){var m=l[g];null!=m.to&&(m.to+=u),null==m.from?!getMarkedSpanFor(s,m.marker)&&(m.from=u,c&&(s||(s=[])).push(m)):(m.from+=u,c&&(s||(s=[])).push(m))}s&&(s=clearEmptySpans(s)),l&&l!=s&&(l=clearEmptySpans(l));var v=[s];if(!c){var y,C=t.text.length-2;if(C>0&&s)for(var b=0;b<s.length;++b)null==s[b].to&&(y||(y=[])).push(new MarkedSpan(s[b].marker,null,null));for(var S=0;S<C;++S)v.push(y);v.push(l)}return v}function clearEmptySpans(e){for(var t=0;t<e.length;++t){var n=e[t];null!=n.from&&n.from==n.to&&!1!==n.marker.clearWhenEmpty&&e.splice(t--,1)}return e.length?e:null}function removeReadOnlyRanges(e,t,n){var r=null;if(e.iter(t.line,n.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var n=e.markedSpans[t].marker;n.readOnly&&(!r||-1==indexOf(r,n))&&(r||(r=[])).push(n)}}),!r)return null;for(var i=[{from:t,to:n}],o=0;o<r.length;++o)for(var a=r[o],s=a.find(0),l=0;l<i.length;++l){var c=i[l];if(!(0>cmp(c.to,s.from)||cmp(c.from,s.to)>0)){var u=[l,1],d=cmp(c.from,s.from),h=cmp(c.to,s.to);!(d<0)&&(a.inclusiveLeft||d)||u.push({from:c.from,to:s.from}),!(h>0)&&(a.inclusiveRight||h)||u.push({from:s.to,to:c.to}),i.splice.apply(i,u),l+=u.length-3}}return i}function detachMarkedSpans(e){var t=e.markedSpans;if(t){for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}}function attachMarkedSpans(e,t){if(t){for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}}function extraLeft(e){return e.inclusiveLeft?-1:0}function extraRight(e){return+!!e.inclusiveRight}function compareCollapsedMarkers(e,t){var n=e.lines.length-t.lines.length;if(0!=n)return n;var r=e.find(),i=t.find(),o=cmp(r.from,i.from)||extraLeft(e)-extraLeft(t);if(o)return-o;var a=cmp(r.to,i.to)||extraRight(e)-extraRight(t);return a||t.id-e.id}function collapsedSpanAtSide(e,t){var n,r=Z&&e.markedSpans;if(r)for(var i=void 0,o=0;o<r.length;++o)(i=r[o]).marker.collapsed&&(t?i.from:i.to)==null&&(!n||0>compareCollapsedMarkers(n,i.marker))&&(n=i.marker);return n}function collapsedSpanAround(e,t){var n,r=Z&&e.markedSpans;if(r)for(var i=0;i<r.length;++i){var o=r[i];o.marker.collapsed&&(null==o.from||o.from<t)&&(null==o.to||o.to>t)&&(!n||0>compareCollapsedMarkers(n,o.marker))&&(n=o.marker)}return n}function conflictingCollapsedRange(e,t,n,r,i){var o=getLine(e,t),a=Z&&o.markedSpans;if(a)for(var s=0;s<a.length;++s){var l=a[s];if(l.marker.collapsed){var c=l.marker.find(0),u=cmp(c.from,n)||extraLeft(l.marker)-extraLeft(i),d=cmp(c.to,r)||extraRight(l.marker)-extraRight(i);if((!(u>=0)||!(d<=0))&&(!(u<=0)||!(d>=0))&&(u<=0&&(l.marker.inclusiveRight&&i.inclusiveLeft?cmp(c.to,n)>=0:cmp(c.to,n)>0)||u>=0&&(l.marker.inclusiveRight&&i.inclusiveLeft?0>=cmp(c.from,r):0>cmp(c.from,r))))return!0}}}function visualLine(e){for(var t;t=collapsedSpanAtSide(e,!0);)e=t.find(-1,!0).line;return e}function visualLineEnd(e){for(var t;t=collapsedSpanAtSide(e,!1);)e=t.find(1,!0).line;return e}function visualLineContinued(e){for(var t,n;t=collapsedSpanAtSide(e,!1);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function visualLineNo(e,t){var n=getLine(e,t),r=visualLine(n);return n==r?t:lineNo(r)}function visualLineEndNo(e,t){if(t>e.lastLine())return t;var n,r=getLine(e,t);if(!lineIsHidden(e,r))return t;for(;n=collapsedSpanAtSide(r,!1);)r=n.find(1,!0).line;return lineNo(r)+1}function lineIsHidden(e,t){var n=Z&&t.markedSpans;if(n){for(var r=void 0,i=0;i<n.length;++i)if((r=n[i]).marker.collapsed&&(null==r.from||!r.marker.widgetNode&&0==r.from&&r.marker.inclusiveLeft&&lineIsHiddenInner(e,t,r)))return!0}}function lineIsHiddenInner(e,t,n){if(null==n.to){var r=n.marker.find(1,!0);return lineIsHiddenInner(e,r.line,getMarkedSpanFor(r.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length)return!0;for(var i=void 0,o=0;o<t.markedSpans.length;++o)if((i=t.markedSpans[o]).marker.collapsed&&!i.marker.widgetNode&&i.from==n.to&&(null==i.to||i.to!=n.from)&&(i.marker.inclusiveLeft||n.marker.inclusiveRight)&&lineIsHiddenInner(e,t,i))return!0}function heightAtLine(e){e=visualLine(e);for(var t=0,n=e.parent,r=0;r<n.lines.length;++r){var i=n.lines[r];if(i==e)break;t+=i.height}for(var o=n.parent;o;o=(n=o).parent)for(var a=0;a<o.children.length;++a){var s=o.children[a];if(s==n)break;t+=s.height}return t}function lineLength(e){if(0==e.height)return 0;for(var t,n=e.text.length,r=e;t=collapsedSpanAtSide(r,!0);){var i=t.find(0,!0);r=i.from.line,n+=i.from.ch-i.to.ch}for(r=e;t=collapsedSpanAtSide(r,!1);){var o=t.find(0,!0);n-=r.text.length-o.from.ch,n+=(r=o.to.line).text.length-o.to.ch}return n}function findMaxLine(e){var t=e.display,n=e.doc;t.maxLine=getLine(n,n.first),t.maxLineLength=lineLength(t.maxLine),t.maxLineChanged=!0,n.iter(function(e){var n=lineLength(e);n>t.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}var Line=function(e,t,n){this.text=e,attachMarkedSpans(this,t),this.height=n?n(this):1};function updateLine(e,t,n,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),detachMarkedSpans(e),attachMarkedSpans(e,n);var i=r?r(e):1;i!=e.height&&updateLineHeight(e,i)}function cleanUpLine(e){e.parent=null,detachMarkedSpans(e)}Line.prototype.lineNo=function(){return lineNo(this)},eventMixin(Line);var Q={},J={};function interpretTokenStyle(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?J:Q;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function buildLineContent(e,t){var n=eltP("span",null,null,m?"padding-right: .1px":null),r={pre:eltP("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o=i?t.rest[i-1]:t.line,a=void 0;r.pos=0,r.addToken=buildToken,hasBadBidiRects(e.display.measure)&&(a=getOrder(o,e.doc.direction))&&(r.addToken=buildTokenBadBidi(r.addToken,a)),r.map=[];var s=t!=e.display.externalMeasured&&lineNo(o);insertLineContent(o,r,getLineStyles(e,o,s)),o.styleClasses&&(o.styleClasses.bgClass&&(r.bgClass=joinClasses(o.styleClasses.bgClass,r.bgClass||"")),o.styleClasses.textClass&&(r.textClass=joinClasses(o.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(zeroWidthElement(e.display.measure))),0==i?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(m){var l=r.content.lastChild;(/\bcm-tab\b/.test(l.className)||l.querySelector&&l.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return signal(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=joinClasses(r.pre.className,r.textClass||"")),r}function defaultSpecialCharPlaceholder(e){var t=elt("span","\u2022","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function buildToken(e,t,n,r,i,o,a){if(t){var s,l=e.splitSpaces?splitSpaces(t,e.trailingSpace):t,c=e.cm.state.specialChars,u=!1;if(c.test(t)){s=document.createDocumentFragment();for(var d=0;;){c.lastIndex=d;var h=c.exec(t),m=h?h.index-d:t.length-d;if(m){var v=document.createTextNode(l.slice(d,d+m));f&&g<9?s.appendChild(elt("span",[v])):s.appendChild(v),e.map.push(e.pos,e.pos+m,v),e.col+=m,e.pos+=m}if(!h)break;d+=m+1;var y=void 0;if("	"==h[0]){var C=e.cm.options.tabSize,b=C-e.col%C;(y=s.appendChild(elt("span",spaceStr(b),"cm-tab"))).setAttribute("role","presentation"),y.setAttribute("cm-text","	"),e.col+=b}else`\r`==h[0]||`
`==h[0]?(y=s.appendChild(elt("span",`\r`==h[0]?"\u240D":"\u2424","cm-invalidchar"))).setAttribute("cm-text",h[0]):((y=e.cm.options.specialCharPlaceholder(h[0])).setAttribute("cm-text",h[0]),f&&g<9?s.appendChild(elt("span",[y])):s.appendChild(y)),e.col+=1;e.map.push(e.pos,e.pos+1,y),e.pos++}}else e.col+=t.length,s=document.createTextNode(l),e.map.push(e.pos,e.pos+t.length,s),f&&g<9&&(u=!0),e.pos+=t.length;if(e.trailingSpace=32==l.charCodeAt(t.length-1),n||r||i||u||o||a){var S=n||"";r&&(S+=r),i&&(S+=i);var x=elt("span",[s],S,o);if(a)for(var w in a)a.hasOwnProperty(w)&&"style"!=w&&"class"!=w&&x.setAttribute(w,a[w]);return e.content.appendChild(x)}e.content.appendChild(s)}}function splitSpaces(e,t){if(e.length>1&&!/  /.test(e))return e;for(var n=t,r="",i=0;i<e.length;i++){var o=e.charAt(i);" "==o&&n&&(i==e.length-1||32==e.charCodeAt(i+1))&&(o="\xa0"),r+=o,n=" "==o}return r}function buildTokenBadBidi(e,t){return function(n,r,i,o,a,s,l){i=i?i+" cm-force-border":"cm-force-border";for(var c=n.pos,u=c+r.length;;){for(var d=void 0,h=0;h<t.length&&(!((d=t[h]).to>c)||!(d.from<=c));h++);if(d.to>=u)return e(n,r,i,o,a,s,l);e(n,r.slice(0,d.to-c),i,o,null,s,l),o=null,r=r.slice(d.to-c),c=d.to}}}function buildCollapsedSpan(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function insertLineContent(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(!r){for(var a=1;a<n.length;a+=2)t.addToken(t,i.slice(o,o=n[a]),interpretTokenStyle(n[a+1],t.cm.options));return}for(var s,l,c,u,d,h,f,g=i.length,m=0,v=1,y="",C=0;;){if(C==m){c=u=d=l="",f=null,h=null,C=1/0;for(var b=[],S=void 0,x=0;x<r.length;++x){var w=r[x],L=w.marker;if("bookmark"==L.type&&w.from==m&&L.widgetNode)b.push(L);else if(w.from<=m&&(null==w.to||w.to>m||L.collapsed&&w.to==m&&w.from==m)){if(null!=w.to&&w.to!=m&&C>w.to&&(C=w.to,u=""),L.className&&(c+=" "+L.className),L.css&&(l=(l?l+";":"")+L.css),L.startStyle&&w.from==m&&(d+=" "+L.startStyle),L.endStyle&&w.to==C&&(S||(S=[])).push(L.endStyle,w.to),L.title&&((f||(f={})).title=L.title),L.attributes)for(var k in L.attributes)(f||(f={}))[k]=L.attributes[k];L.collapsed&&(!h||0>compareCollapsedMarkers(h.marker,L))&&(h=w)}else w.from>m&&C>w.from&&(C=w.from)}if(S)for(var M=0;M<S.length;M+=2)S[M+1]==C&&(u+=" "+S[M]);if(!h||h.from==m)for(var T=0;T<b.length;++T)buildCollapsedSpan(t,0,b[T]);if(h&&(h.from||0)==m){if(buildCollapsedSpan(t,(null==h.to?g+1:h.to)-m,h.marker,null==h.from),null==h.to)return;h.to==m&&(h=!1)}}if(m>=g)break;for(var O=Math.min(g,C);;){if(y){var P=m+y.length;if(!h){var D=P>O?y.slice(0,O-m):y;t.addToken(t,D,s?s+c:c,d,m+D.length==C?u:"",l,f)}if(P>=O){y=y.slice(O-m),m=O;break}m=P,d=""}y=i.slice(o,o=n[v++]),s=interpretTokenStyle(n[v++],t.cm.options)}}}function LineView(e,t,n){this.line=t,this.rest=visualLineContinued(t),this.size=this.rest?lineNo(lst(this.rest))-n+1:1,this.node=this.text=null,this.hidden=lineIsHidden(e,t)}function buildViewArray(e,t,n){for(var r,i=[],o=t;o<n;o=r){var a=new LineView(e.doc,getLine(e.doc,o),o);r=o+a.size,i.push(a)}return i}var ee=null;function pushOperation(e){ee?ee.ops.push(e):e.ownsGroup=ee={ops:[e],delayedCallbacks:[]}}function fireCallbacksForOps(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n].call(null);for(var r=0;r<e.ops.length;r++){var i=e.ops[r];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(n<t.length)}function finishOperation(e,t){var n=e.ownsGroup;if(n)try{fireCallbacksForOps(n)}finally{ee=null,t(n)}}var et=null;function signalLater(e,t){var n=getHandlers(e,t);if(n.length){var r,i=Array.prototype.slice.call(arguments,2);ee?r=ee.delayedCallbacks:et?r=et:(r=et=[],setTimeout(fireOrphanDelayed,0));for(var loop=function(e){r.push(function(){return n[e].apply(null,i)})},o=0;o<n.length;++o)loop(o)}}function fireOrphanDelayed(){var e=et;et=null;for(var t=0;t<e.length;++t)e[t]()}function updateLineForChanges(e,t,n,r){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?updateLineText(e,t):"gutter"==o?updateLineGutter(e,t,n,r):"class"==o?updateLineClasses(e,t):"widget"==o&&updateLineWidgets(e,t,r)}t.changes=null}function ensureLineWrapped(e){return e.node==e.text&&(e.node=elt("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),f&&g<8&&(e.node.style.zIndex=2)),e.node}function updateLineBackground(e,t){var n=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(n&&(n+=" CodeMirror-linebackground"),t.background)n?t.background.className=n:(t.background.parentNode.removeChild(t.background),t.background=null);else if(n){var r=ensureLineWrapped(t);t.background=r.insertBefore(elt("div",null,n),r.firstChild),e.display.input.setUneditable(t.background)}}function getLineContent(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):buildLineContent(e,t)}function updateLineText(e,t){var n=t.text.className,r=getLineContent(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,updateLineClasses(e,t)):n&&(t.text.className=n)}function updateLineClasses(e,t){updateLineBackground(e,t),t.line.wrapClass?ensureLineWrapped(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var n=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=n||""}function updateLineGutter(e,t,n,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var i=ensureLineWrapped(t);t.gutterBackground=elt("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),i.insertBefore(t.gutterBackground,t.text)}var o=t.line.gutterMarkers;if(e.options.lineNumbers||o){var a=ensureLineWrapped(t),s=t.gutter=elt("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(s),a.insertBefore(s,t.text),t.line.gutterClass&&(s.className+=" "+t.line.gutterClass),!e.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(t.lineNumber=s.appendChild(elt("div",lineNumberFor(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),o)for(var l=0;l<e.display.gutterSpecs.length;++l){var c=e.display.gutterSpecs[l].className,u=o.hasOwnProperty(c)&&o[c];u&&s.appendChild(elt("div",[u],"CodeMirror-gutter-elt","left: "+r.gutterLeft[c]+"px; width: "+r.gutterWidth[c]+"px"))}}}function updateLineWidgets(e,t,n){t.alignable&&(t.alignable=null);for(var r=classTest("CodeMirror-linewidget"),i=t.node.firstChild,o=void 0;i;i=o)o=i.nextSibling,r.test(i.className)&&t.node.removeChild(i);insertLineWidgets(e,t,n)}function buildLineElement(e,t,n,r){var i=getLineContent(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),updateLineClasses(e,t),updateLineGutter(e,t,n,r),insertLineWidgets(e,t,r),t.node}function insertLineWidgets(e,t,n){if(insertLineWidgetsFor(e,t.line,t,n,!0),t.rest)for(var r=0;r<t.rest.length;r++)insertLineWidgetsFor(e,t.rest[r],t,n,!1)}function insertLineWidgetsFor(e,t,n,r,i){if(t.widgets)for(var o=ensureLineWrapped(n),a=0,s=t.widgets;a<s.length;++a){var l=s[a],c=elt("div",[l.node],"CodeMirror-linewidget"+(l.className?" "+l.className:""));l.handleMouseEvents||c.setAttribute("cm-ignore-events","true"),positionLineWidget(l,c,n,r),e.display.input.setUneditable(c),i&&l.above?o.insertBefore(c,n.gutter||n.text):o.appendChild(c),signalLater(l,"redraw")}}function positionLineWidget(e,t,n,r){if(e.noHScroll){(n.alignable||(n.alignable=[])).push(t);var i=r.wrapperWidth;t.style.left=r.fixedPos+"px",e.coverGutter||(i-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=i+"px"}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}function widgetHeight(e){if(null!=e.height)return e.height;var t=e.doc.cm;if(!t)return 0;if(!contains(document.body,e.node)){var n="position: relative;";e.coverGutter&&(n+="margin-left: -"+t.display.gutters.offsetWidth+"px;"),e.noHScroll&&(n+="width: "+t.display.wrapper.clientWidth+"px;"),removeChildrenAndAdd(t.display.measure,elt("div",[e.node],null,n))}return e.height=e.node.parentNode.offsetHeight}function eventInWidget(e,t){for(var n=e_target(t);n!=e.wrapper;n=n.parentNode)if(!n||1==n.nodeType&&"true"==n.getAttribute("cm-ignore-events")||n.parentNode==e.sizer&&n!=e.mover)return!0}function paddingTop(e){return e.lineSpace.offsetTop}function paddingVert(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function paddingH(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=removeChildrenAndAdd(e.measure,elt("pre","x","CodeMirror-line-like")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return isNaN(r.left)||isNaN(r.right)||(e.cachedPaddingH=r),r}function scrollGap(e){return 50-e.display.nativeBarWidth}function displayWidth(e){return e.display.scroller.clientWidth-scrollGap(e)-e.display.barWidth}function displayHeight(e){return e.display.scroller.clientHeight-scrollGap(e)-e.display.barHeight}function ensureLineHeights(e,t,n){var r=e.options.lineWrapping,i=r&&displayWidth(e);if(!t.measure.heights||r&&t.measure.width!=i){var o=t.measure.heights=[];if(r){t.measure.width=i;for(var a=t.text.firstChild.getClientRects(),s=0;s<a.length-1;s++){var l=a[s],c=a[s+1];Math.abs(l.bottom-c.bottom)>2&&o.push((l.bottom+c.top)/2-n.top)}}o.push(n.bottom-n.top)}}function mapFromLineView(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var i=0;i<e.rest.length;i++)if(lineNo(e.rest[i])>n)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function updateExternalMeasurement(e,t){var n=lineNo(t=visualLine(t)),r=e.display.externalMeasured=new LineView(e.doc,t,n);r.lineN=n;var i=r.built=buildLineContent(e,r);return r.text=i.pre,removeChildrenAndAdd(e.display.lineMeasure,i.pre),r}function findViewForLine(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[findViewIndex(e,t)];var n=e.display.externalMeasured;if(n&&t>=n.lineN&&t<n.lineN+n.size)return n}function prepareMeasureForLine(e,t){var n=lineNo(t),r=findViewForLine(e,n);r&&!r.text?r=null:r&&r.changes&&(updateLineForChanges(e,r,n,getDimensions(e)),e.curOp.forceUpdate=!0),r||(r=updateExternalMeasurement(e,t));var i=mapFromLineView(r,t,n);return{line:t,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function measureCharPrepared(e,t,n,r,i){t.before&&(n=-1);var o,a=n+(r||"");return t.cache.hasOwnProperty(a)?o=t.cache[a]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(ensureLineHeights(e,t.view,t.rect),t.hasHeights=!0),(o=measureCharInner(e,t,n,r)).bogus||(t.cache[a]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}var en={left:0,right:0,top:0,bottom:0};function nodeAndOffsetInLineMap(e,t,n){for(var r,i,o,a,s,l,c=0;c<e.length;c+=3)if(s=e[c],l=e[c+1],t<s?(i=0,o=1,a="left"):t<l?o=(i=t-s)+1:(c==e.length-3||t==l&&e[c+3]>t)&&(i=(o=l-s)-1,t>=l&&(a="right")),null!=i){if(r=e[c+2],s==l&&n==(r.insertLeft?"left":"right")&&(a=n),"left"==n&&0==i)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)r=e[(c-=3)+2],a="left";if("right"==n&&i==l-s)for(;c<e.length-3&&e[c+3]==e[c+4]&&!e[c+5].insertLeft;)r=e[(c+=3)+2],a="right";break}return{node:r,start:i,end:o,collapse:a,coverStart:s,coverEnd:l}}function getUsefulRect(e,t){var n=en;if("left"==t)for(var r=0;r<e.length&&(n=e[r]).left==n.right;r++);else for(var i=e.length-1;i>=0&&(n=e[i]).left==n.right;i--);return n}function measureCharInner(e,n,r,i){var o,a,s=nodeAndOffsetInLineMap(n.map,r,i),l=s.node,c=s.start,u=s.end,d=s.collapse;if(3==l.nodeType){for(var h=0;h<4;h++){for(;c&&isExtendingChar(n.line.text.charAt(s.coverStart+c));)--c;for(;s.coverStart+u<s.coverEnd&&isExtendingChar(n.line.text.charAt(s.coverStart+u));)++u;if((o=f&&g<9&&0==c&&u==s.coverEnd-s.coverStart?l.parentNode.getBoundingClientRect():getUsefulRect(t(l,c,u).getClientRects(),i)).left||o.right||0==c)break;u=c,c-=1,d="right"}f&&g<11&&(o=maybeUpdateRectForZooming(e.display.measure,o))}else c>0&&(d=i="right"),o=e.options.lineWrapping&&(a=l.getClientRects()).length>1?a["right"==i?a.length-1:0]:l.getBoundingClientRect();if(f&&g<9&&!c&&(!o||!o.left&&!o.right)){var m=l.parentNode.getClientRects()[0];o=m?{left:m.left,right:m.left+charWidth(e.display),top:m.top,bottom:m.bottom}:en}for(var v=o.top-n.rect.top,y=o.bottom-n.rect.top,C=(v+y)/2,b=n.view.measure.heights,S=0;S<b.length-1&&!(C<b[S]);S++);var x=S?b[S-1]:0,w=b[S],L={left:("right"==d?o.right:o.left)-n.rect.left,right:("left"==d?o.left:o.right)-n.rect.left,top:x,bottom:w};return o.left||o.right||(L.bogus=!0),e.options.singleCursorHeightPerLine||(L.rtop=v,L.rbottom=y),L}function maybeUpdateRectForZooming(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!hasBadZoomedRects(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}function clearLineMeasurementCacheFor(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function clearLineMeasurementCache(e){e.display.externalMeasure=null,removeChildren(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)clearLineMeasurementCacheFor(e.display.view[t])}function clearCaches(e){clearLineMeasurementCache(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function pageScrollX(){return y&&L?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function pageScrollY(){return y&&L?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function widgetTopHeight(e){var t=0;if(e.widgets)for(var n=0;n<e.widgets.length;++n)e.widgets[n].above&&(t+=widgetHeight(e.widgets[n]));return t}function intoCoordSystem(e,t,n,r,i){if(!i){var o=widgetTopHeight(t);n.top+=o,n.bottom+=o}if("line"==r)return n;r||(r="local");var a=heightAtLine(t);if("local"==r?a+=paddingTop(e.display):a-=e.display.viewOffset,"page"==r||"window"==r){var s=e.display.lineSpace.getBoundingClientRect();a+=s.top+("window"==r?0:pageScrollY());var l=s.left+("window"==r?0:pageScrollX());n.left+=l,n.right+=l}return n.top+=a,n.bottom+=a,n}function fromCoordSystem(e,t,n){if("div"==n)return t;var r=t.left,i=t.top;if("page"==n)r-=pageScrollX(),i-=pageScrollY();else if("local"==n||!n){var o=e.display.sizer.getBoundingClientRect();r+=o.left,i+=o.top}var a=e.display.lineSpace.getBoundingClientRect();return{left:r-a.left,top:i-a.top}}function charCoords(e,t,n,r,i){var o,a;return r||(r=getLine(e.doc,t.line)),intoCoordSystem(e,r,(o=r,a=t.ch,measureCharPrepared(e,prepareMeasureForLine(e,o),a,i)),n)}function cursorCoords(e,t,n,r,i,o){function get(t,a){var s=measureCharPrepared(e,i,t,a?"right":"left",o);return a?s.left=s.right:s.right=s.left,intoCoordSystem(e,r,s,n)}r=r||getLine(e.doc,t.line),i||(i=prepareMeasureForLine(e,r));var a=getOrder(r,e.doc.direction),s=t.ch,l=t.sticky;if(s>=r.text.length?(s=r.text.length,l="before"):s<=0&&(s=0,l="after"),!a)return get("before"==l?s-1:s,"before"==l);function getBidi(e,t,n){return get(n?e-1:e,1==a[t].level!=n)}var c=getBidiPartAt(a,s,l),u=B,d=getBidi(s,c,"before"==l);return null!=u&&(d.other=getBidi(s,u,"before"!=l)),d}function estimateCoords(e,t){var n=0;t=clipPos(e.doc,t),e.options.lineWrapping||(n=charWidth(e.display)*t.ch);var r=getLine(e.doc,t.line),i=heightAtLine(r)+paddingTop(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function PosWithInfo(e,t,n,r,i){var o=Pos(e,t,n);return o.xRel=i,r&&(o.outside=r),o}function coordsChar(e,t,n){var r=e.doc;if((n+=e.display.viewOffset)<0)return PosWithInfo(r.first,0,null,-1,-1);var i=lineAtHeight(r,n),o=r.first+r.size-1;if(i>o)return PosWithInfo(r.first+r.size-1,getLine(r,o).text.length,null,1,1);t<0&&(t=0);for(var a=getLine(r,i);;){var s=coordsCharInner(e,a,i,t,n),l=collapsedSpanAround(a,s.ch+ +(s.xRel>0||s.outside>0));if(!l)return s;var c=l.find(1);if(c.line==i)return c;a=getLine(r,i=c.line)}}function wrappedLineExtent(e,t,n,r){r-=widgetTopHeight(t);var i=t.text.length,o=findFirst(function(t){return measureCharPrepared(e,n,t-1).bottom<=r},i,0);return i=findFirst(function(t){return measureCharPrepared(e,n,t).top>r},o,i),{begin:o,end:i}}function wrappedLineExtentChar(e,t,n,r){n||(n=prepareMeasureForLine(e,t));var i=intoCoordSystem(e,t,measureCharPrepared(e,n,r),"line").top;return wrappedLineExtent(e,t,n,i)}function boxIsAfter(e,t,n,r){return!(e.bottom<=n)&&(e.top>n||(r?e.left:e.right)>t)}function coordsCharInner(e,t,n,r,i){i-=heightAtLine(t);var o=prepareMeasureForLine(e,t),a=widgetTopHeight(t),s=0,l=t.text.length,c=!0,u=getOrder(t,e.doc.direction);if(u){var d=(e.options.lineWrapping?coordsBidiPartWrapped:coordsBidiPart)(e,t,n,o,u,r,i);s=(c=1!=d.level)?d.from:d.to-1,l=c?d.to:d.from-1}var h,f,g=null,m=null,v=findFirst(function(t){var n=measureCharPrepared(e,o,t);return n.top+=a,n.bottom+=a,!!boxIsAfter(n,r,i,!1)&&(n.top<=i&&n.left<=r&&(g=t,m=n),!0)},s,l),y=!1;if(m){var C=r-m.left<m.right-r,b=C==c;v=g+ +!b,f=b?"after":"before",h=C?m.left:m.right}else{!c&&(v==l||v==s)&&v++,f=0==v?"after":v==t.text.length?"before":measureCharPrepared(e,o,v-!!c).bottom+a<=i==c?"after":"before";var S=cursorCoords(e,Pos(n,v,f),"line",t,o);h=S.left,y=i<S.top?-1:+(i>=S.bottom)}return PosWithInfo(n,v=skipExtendingChars(t.text,v,1),f,y,r-h)}function coordsBidiPart(e,t,n,r,i,o,a){var s=findFirst(function(s){var l=i[s],c=1!=l.level;return boxIsAfter(cursorCoords(e,Pos(n,c?l.to:l.from,c?"before":"after"),"line",t,r),o,a,!0)},0,i.length-1),l=i[s];if(s>0){var c=1!=l.level,u=cursorCoords(e,Pos(n,c?l.from:l.to,c?"after":"before"),"line",t,r);boxIsAfter(u,o,a,!0)&&u.top>a&&(l=i[s-1])}return l}function coordsBidiPartWrapped(e,t,n,r,i,o,a){var s=wrappedLineExtent(e,t,r,a),l=s.begin,c=s.end;/\s/.test(t.text.charAt(c-1))&&c--;for(var u=null,d=null,h=0;h<i.length;h++){var f=i[h];if(!(f.from>=c)&&!(f.to<=l)){var g=measureCharPrepared(e,r,1!=f.level?Math.min(c,f.to)-1:Math.max(l,f.from)).right,m=g<o?o-g+1e9:g-o;(!u||d>m)&&(u=f,d=m)}}return u||(u=i[i.length-1]),u.from<l&&(u={from:l,to:u.to,level:u.level}),u.to>c&&(u={from:u.from,to:c,level:u.level}),u}function textHeight(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==i){i=elt("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)i.appendChild(document.createTextNode("x")),i.appendChild(elt("br"));i.appendChild(document.createTextNode("x"))}removeChildrenAndAdd(e.measure,i);var n=i.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),removeChildren(e.measure),n||1}function charWidth(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=elt("span","xxxxxxxxxx"),n=elt("pre",[t],"CodeMirror-line-like");removeChildrenAndAdd(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function getDimensions(e){for(var t=e.display,n={},r={},i=t.gutters.clientLeft,o=t.gutters.firstChild,a=0;o;o=o.nextSibling,++a){var s=e.display.gutterSpecs[a].className;n[s]=o.offsetLeft+o.clientLeft+i,r[s]=o.clientWidth}return{fixedPos:compensateForHScroll(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function compensateForHScroll(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function estimateHeight(e){var t=textHeight(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/charWidth(e.display)-3);return function(i){if(lineIsHidden(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;a<i.widgets.length;a++)i.widgets[a].height&&(o+=i.widgets[a].height);return n?o+(Math.ceil(i.text.length/r)||1)*t:o+t}}function estimateLineHeights(e){var t=e.doc,n=estimateHeight(e);t.iter(function(e){var t=n(e);t!=e.height&&updateLineHeight(e,t)})}function posFromMouse(e,t,n,r){var i=e.display;if(!n&&"true"==e_target(t).getAttribute("cm-not-content"))return null;var o,a,s=i.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,a=t.clientY-s.top}catch{return null}var l,c=coordsChar(e,o,a);if(r&&c.xRel>0&&(l=getLine(e.doc,c.line).text).length==c.ch){var u=countColumn(l,l.length,e.options.tabSize)-l.length;c=Pos(c.line,Math.max(0,Math.round((o-paddingH(e.display).left)/charWidth(e.display))-u))}return c}function findViewIndex(e,t){if(t>=e.display.viewTo||(t-=e.display.viewFrom)<0)return null;for(var n=e.display.view,r=0;r<n.length;r++)if((t-=n[r].size)<0)return r}function regChange(e,t,n,r){null==t&&(t=e.doc.first),null==n&&(n=e.doc.first+e.doc.size),r||(r=0);var i=e.display;if(r&&n<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>t)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Z&&visualLineNo(e.doc,t)<i.viewTo&&resetView(e);else if(n<=i.viewFrom)Z&&visualLineEndNo(e.doc,n+r)>i.viewFrom?resetView(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)resetView(e);else if(t<=i.viewFrom){var o=viewCuttingPoint(e,n,n+r,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=r):resetView(e)}else if(n>=i.viewTo){var a=viewCuttingPoint(e,t,t,-1);a?(i.view=i.view.slice(0,a.index),i.viewTo=a.lineN):resetView(e)}else{var s=viewCuttingPoint(e,t,t,-1),l=viewCuttingPoint(e,n,n+r,1);s&&l?(i.view=i.view.slice(0,s.index).concat(buildViewArray(e,s.lineN,l.lineN)).concat(i.view.slice(l.index)),i.viewTo+=r):resetView(e)}var c=i.externalMeasured;c&&(n<c.lineN?c.lineN+=r:t<c.lineN+c.size&&(i.externalMeasured=null))}function regLineChange(e,t,n){e.curOp.viewChanged=!0;var r=e.display,i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size&&(r.externalMeasured=null),!(t<r.viewFrom)&&!(t>=r.viewTo)){var o=r.view[findViewIndex(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==indexOf(a,n)&&a.push(n)}}}function resetView(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function viewCuttingPoint(e,t,n,r){var i,o=findViewIndex(e,t),a=e.display.view;if(!Z||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var s=e.display.viewFrom,l=0;l<o;l++)s+=a[l].size;if(s!=t){if(r>0){if(o==a.length-1)return null;i=s+a[o].size-t,o++}else i=s-t;t+=i,n+=i}for(;visualLineNo(e.doc,n)!=n;){if(o==(r<0?0:a.length-1))return null;n+=r*a[o-(r<0)].size,o+=r}return{index:o,lineN:n}}function adjustView(e,t,n){var r=e.display;0==r.view.length||t>=r.viewTo||n<=r.viewFrom?(r.view=buildViewArray(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=buildViewArray(e,t,r.viewFrom).concat(r.view):r.viewFrom<t&&(r.view=r.view.slice(findViewIndex(e,t))),r.viewFrom=t,r.viewTo<n?r.view=r.view.concat(buildViewArray(e,r.viewTo,n)):r.viewTo>n&&(r.view=r.view.slice(0,findViewIndex(e,n)))),r.viewTo=n}function countDirtyView(e){for(var t=e.display.view,n=0,r=0;r<t.length;r++){var i=t[r];!i.hidden&&(!i.node||i.changes)&&++n}return n}function updateSelection(e){e.display.input.showSelection(e.display.input.prepareSelection())}function prepareSelection(e,t){void 0===t&&(t=!0);for(var n=e.doc,r={},i=r.cursors=document.createDocumentFragment(),o=r.selection=document.createDocumentFragment(),a=0;a<n.sel.ranges.length;a++)if(t||a!=n.sel.primIndex){var s=n.sel.ranges[a];if(!(s.from().line>=e.display.viewTo)&&!(s.to().line<e.display.viewFrom)){var l=s.empty();(l||e.options.showCursorWhenSelecting)&&drawSelectionCursor(e,s.head,i),l||drawSelectionRange(e,s,o)}}return r}function drawSelectionCursor(e,t,n){var r=cursorCoords(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),i=n.appendChild(elt("div","\xa0","CodeMirror-cursor"));if(i.style.left=r.left+"px",i.style.top=r.top+"px",i.style.height=Math.max(0,r.bottom-r.top)*e.options.cursorHeight+"px",r.other){var o=n.appendChild(elt("div","\xa0","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=r.other.left+"px",o.style.top=r.other.top+"px",o.style.height=(r.other.bottom-r.other.top)*.85+"px"}}function cmpCoords(e,t){return e.top-t.top||e.left-t.left}function drawSelectionRange(e,t,n){var r=e.display,i=e.doc,o=document.createDocumentFragment(),a=paddingH(e.display),s=a.left,l=Math.max(r.sizerWidth,displayWidth(e)-r.sizer.offsetLeft)-a.right,c="ltr"==i.direction;function add(e,t,n,r){t<0&&(t=0),t=Math.round(t),r=Math.round(r),o.appendChild(elt("div",null,"CodeMirror-selected","position: absolute; left: "+e+`px;
                             top: `+t+"px; width: "+(null==n?l-e:n)+`px;
                             height: `+(r-t)+"px"))}function drawForLine(t,n,r){var o,a,u=getLine(i,t),d=u.text.length;function coords(n,r){return charCoords(e,Pos(t,n),"div",u,r)}function wrapX(t,n,r){var i=wrappedLineExtentChar(e,u,null,t),o="ltr"==n==("after"==r)?"left":"right";return coords("after"==r?i.begin:i.end-(/\s/.test(u.text.charAt(i.end-1))?2:1),o)[o]}var h=getOrder(u,i.direction);return iterateBidiSections(h,n||0,null==r?d:r,function(e,t,i,u){var f,g,m,v,y="ltr"==i,C=coords(e,y?"left":"right"),b=coords(t-1,y?"right":"left"),S=null==n&&0==e,x=null==r&&t==d,w=0==u,L=!h||u==h.length-1;if(b.top-C.top<=3){var k=(c?S:x)&&w,M=(c?x:S)&&L,T=k?s:(y?C:b).left,O=M?l:(y?b:C).right;add(T,C.top,O-T,C.bottom)}else y?(f=c&&S&&w?s:C.left,g=c?l:wrapX(e,i,"before"),m=c?s:wrapX(t,i,"after"),v=c&&x&&L?l:b.right):(f=c?wrapX(e,i,"before"):s,g=!c&&S&&w?l:C.right,m=!c&&x&&L?s:b.left,v=c?wrapX(t,i,"after"):l),add(f,C.top,g-f,C.bottom),C.bottom<b.top&&add(s,C.bottom,null,b.top),add(m,b.top,v-m,b.bottom);(!o||0>cmpCoords(C,o))&&(o=C),0>cmpCoords(b,o)&&(o=b),(!a||0>cmpCoords(C,a))&&(a=C),0>cmpCoords(b,a)&&(a=b)}),{start:o,end:a}}var u=t.from(),d=t.to();if(u.line==d.line)drawForLine(u.line,u.ch,d.ch);else{var h=getLine(i,u.line),f=getLine(i,d.line),g=visualLine(h)==visualLine(f),m=drawForLine(u.line,u.ch,g?h.text.length+1:null).end,v=drawForLine(d.line,g?0:null,d.ch).start;g&&(m.top<v.top-2?(add(m.right,m.top,null,m.bottom),add(s,v.top,v.left,v.bottom)):add(m.right,m.top,v.left-m.right,m.bottom)),m.bottom<v.top&&add(s,m.bottom,null,v.top)}n.appendChild(o)}function restartBlink(e){if(e.state.focused){var t=e.display;clearInterval(t.blinker);var n=!0;t.cursorDiv.style.visibility="",e.options.cursorBlinkRate>0?t.blinker=setInterval(function(){e.hasFocus()||onBlur(e),t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function ensureFocus(e){!e.hasFocus()&&(e.display.input.focus(),e.state.focused||onFocus(e))}function delayBlurEvent(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,e.state.focused&&onBlur(e))},100)}function onFocus(e,t){e.state.delayingBlurEvent&&!e.state.draggingText&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(signal(e,"focus",e,t),e.state.focused=!0,addClass(e.display.wrapper,"CodeMirror-focused"),!e.curOp&&e.display.selForContextMenu!=e.doc.sel&&(e.display.input.reset(),m&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),restartBlink(e))}function onBlur(e,t){e.state.delayingBlurEvent||(e.state.focused&&(signal(e,"blur",e,t),e.state.focused=!1,rmClass(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function updateHeightsInViewport(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var i=t.view[r],o=e.options.lineWrapping,a=void 0,s=0;if(!i.hidden){if(f&&g<8){var l=i.node.offsetTop+i.node.offsetHeight;a=l-n,n=l}else{var c=i.node.getBoundingClientRect();a=c.bottom-c.top,!o&&i.text.firstChild&&(s=i.text.firstChild.getBoundingClientRect().right-c.left-1)}var u=i.line.height-a;if((u>.005||u<-.005)&&(updateLineHeight(i.line,a),updateWidgetHeight(i.line),i.rest))for(var d=0;d<i.rest.length;d++)updateWidgetHeight(i.rest[d]);if(s>e.display.sizerWidth){var h=Math.ceil(s/charWidth(e.display));h>e.display.maxLineLength&&(e.display.maxLineLength=h,e.display.maxLine=i.line,e.display.maxLineChanged=!0)}}}}function updateWidgetHeight(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var n=e.widgets[t],r=n.node.parentNode;r&&(n.height=r.offsetHeight)}}function visibleLines(e,t,n){var r=n&&null!=n.top?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-paddingTop(e));var i=n&&null!=n.bottom?n.bottom:r+e.wrapper.clientHeight,o=lineAtHeight(t,r),a=lineAtHeight(t,i);if(n&&n.ensure){var s=n.ensure.from.line,l=n.ensure.to.line;s<o?(o=s,a=lineAtHeight(t,heightAtLine(getLine(t,s))+e.wrapper.clientHeight)):Math.min(l,t.lastLine())>=a&&(o=lineAtHeight(t,heightAtLine(getLine(t,l))-e.wrapper.clientHeight),a=l)}return{from:o,to:Math.max(a,o+1)}}function maybeScrollWindow(e,t){if(!signalDOMEvent(e,"scrollCursorIntoView")){var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;if(t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!x){var o=elt("div","\u200B",null,`position: absolute;
                         top: `+(t.top-n.viewOffset-paddingTop(e.display))+`px;
                         height: `+(t.bottom-t.top+scrollGap(e)+n.barHeight)+`px;
                         left: `+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function scrollPosIntoView(e,t,n,r){null==r&&(r=0),e.options.lineWrapping||t!=n||(n="before"==(t=t.ch?Pos(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t).sticky?Pos(t.line,t.ch+1,"before"):t);for(var i,o=0;o<5;o++){var a=!1,s=cursorCoords(e,t),l=n&&n!=t?cursorCoords(e,n):s,c=calculateScrollPos(e,i={left:Math.min(s.left,l.left),top:Math.min(s.top,l.top)-r,right:Math.max(s.left,l.left),bottom:Math.max(s.bottom,l.bottom)+r}),u=e.doc.scrollTop,d=e.doc.scrollLeft;if(null!=c.scrollTop&&(updateScrollTop(e,c.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(a=!0)),null!=c.scrollLeft&&(setScrollLeft(e,c.scrollLeft),Math.abs(e.doc.scrollLeft-d)>1&&(a=!0)),!a)break}return i}function scrollIntoView(e,t){var n=calculateScrollPos(e,t);null!=n.scrollTop&&updateScrollTop(e,n.scrollTop),null!=n.scrollLeft&&setScrollLeft(e,n.scrollLeft)}function calculateScrollPos(e,t){var n=e.display,r=textHeight(e.display);t.top<0&&(t.top=0);var i=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:n.scroller.scrollTop,o=displayHeight(e),a={};t.bottom-t.top>o&&(t.bottom=t.top+o);var s=e.doc.height+paddingVert(n),l=t.top<r,c=t.bottom>s-r;if(t.top<i)a.scrollTop=l?0:t.top;else if(t.bottom>i+o){var u=Math.min(t.top,(c?s:t.bottom)-o);u!=i&&(a.scrollTop=u)}var d=e.options.fixedGutter?0:n.gutters.offsetWidth,h=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft-d,f=displayWidth(e)-n.gutters.offsetWidth,g=t.right-t.left>f;return g&&(t.right=t.left+f),t.left<10?a.scrollLeft=0:t.left<h?a.scrollLeft=Math.max(0,t.left+d-10*!g):t.right>f+h-3&&(a.scrollLeft=t.right+10*!g-f),a}function addToScrollTop(e,t){null!=t&&(resolveScrollToPos(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function ensureCursorVisible(e){resolveScrollToPos(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function scrollToCoords(e,t,n){(null!=t||null!=n)&&resolveScrollToPos(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function scrollToRange(e,t){resolveScrollToPos(e),e.curOp.scrollToPos=t}function resolveScrollToPos(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=estimateCoords(e,t.from),r=estimateCoords(e,t.to);scrollToCoordsRange(e,n,r,t.margin)}}function scrollToCoordsRange(e,t,n,r){var i=calculateScrollPos(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-r,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+r});scrollToCoords(e,i.scrollLeft,i.scrollTop)}function updateScrollTop(e,t){2>Math.abs(e.doc.scrollTop-t)||(c||updateDisplaySimple(e,{top:t}),setScrollTop(e,t,!0),c&&updateDisplaySimple(e),startWorker(e,100))}function setScrollTop(e,t,n){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),(e.display.scroller.scrollTop!=t||n)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function setScrollLeft(e,t,n,r){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),((n?t!=e.doc.scrollLeft:!(2>Math.abs(e.doc.scrollLeft-t)))||r)&&(e.doc.scrollLeft=t,alignHorizontally(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function measureForScrollbars(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+paddingVert(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+scrollGap(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}var NativeScrollbars=function(e,t,n){this.cm=n;var r=this.vert=elt("div",[elt("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=elt("div",[elt("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=i.tabIndex=-1,e(r),e(i),on(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),on(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,f&&g<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};NativeScrollbars.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+o)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==r&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?r:0,bottom:t?r:0}},NativeScrollbars.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},NativeScrollbars.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},NativeScrollbars.prototype.zeroWidthHack=function(){this.horiz.style.height=this.vert.style.width=M&&!S?"12px":"18px",this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Delayed,this.disableVert=new Delayed},NativeScrollbars.prototype.enableZeroWidthBar=function(e,t,n){function maybeDisable(){var r=e.getBoundingClientRect();("vert"==n?document.elementFromPoint(r.right-1,(r.top+r.bottom)/2):document.elementFromPoint((r.right+r.left)/2,r.bottom-1))!=e?e.style.pointerEvents="none":t.set(1e3,maybeDisable)}e.style.pointerEvents="auto",t.set(1e3,maybeDisable)},NativeScrollbars.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var NullScrollbars=function(){};function updateScrollbars(e,t){t||(t=measureForScrollbars(e));var n=e.display.barWidth,r=e.display.barHeight;updateScrollbarsInner(e,t);for(var i=0;i<4&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&updateHeightsInViewport(e),updateScrollbarsInner(e,measureForScrollbars(e)),n=e.display.barWidth,r=e.display.barHeight}function updateScrollbarsInner(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}NullScrollbars.prototype.update=function(){return{bottom:0,right:0}},NullScrollbars.prototype.setScrollLeft=function(){},NullScrollbars.prototype.setScrollTop=function(){},NullScrollbars.prototype.clear=function(){};var er={native:NativeScrollbars,null:NullScrollbars};function initScrollbars(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&rmClass(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new er[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),on(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,n){"horizontal"==n?setScrollLeft(e,t):updateScrollTop(e,t)},e),e.display.scrollbars.addClass&&addClass(e.display.wrapper,e.display.scrollbars.addClass)}var ei=0;function startOperation(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++ei},pushOperation(e.curOp)}function endOperation(e){var t=e.curOp;t&&finishOperation(t,function(e){for(var t=0;t<e.ops.length;t++)e.ops[t].cm.curOp=null;endOperations(e)})}function endOperations(e){for(var t=e.ops,n=0;n<t.length;n++)endOperation_R1(t[n]);for(var r=0;r<t.length;r++)endOperation_W1(t[r]);for(var i=0;i<t.length;i++)endOperation_R2(t[i]);for(var o=0;o<t.length;o++)endOperation_W2(t[o]);for(var a=0;a<t.length;a++)endOperation_finish(t[a])}function endOperation_R1(e){var t=e.cm,n=t.display;maybeClipScrollbars(t),e.updateMaxLine&&findMaxLine(t),e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<n.viewFrom||e.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new DisplayUpdate(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function endOperation_W1(e){e.updatedDisplay=e.mustUpdate&&updateDisplayIfNeeded(e.cm,e.update)}function endOperation_R2(e){var t,n,r=e.cm,i=r.display;e.updatedDisplay&&updateHeightsInViewport(r),e.barMeasure=measureForScrollbars(r),i.maxLineChanged&&!r.options.lineWrapping&&(e.adjustWidthTo=(t=i.maxLine,n=i.maxLine.text.length,measureCharPrepared(r,prepareMeasureForLine(r,t),n,void 0)).left+3,r.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+scrollGap(r)+r.display.barWidth),e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-displayWidth(r))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function endOperation_W2(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&setScrollLeft(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var n=e.focus&&e.focus==activeElt();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,n),(e.updatedDisplay||e.startHeight!=t.doc.height)&&updateScrollbars(t,e.barMeasure),e.updatedDisplay&&setDocumentHeight(t,e.barMeasure),e.selectionChanged&&restartBlink(t),t.state.focused&&e.updateInput&&t.display.input.reset(e.typing),n&&ensureFocus(e.cm)}function endOperation_finish(e){var t=e.cm,n=t.display,r=t.doc;if(e.updatedDisplay&&postUpdateDisplay(t,e.update),null!=n.wheelStartX&&(null!=e.scrollTop||null!=e.scrollLeft||e.scrollToPos)&&(n.wheelStartX=n.wheelStartY=null),null!=e.scrollTop&&setScrollTop(t,e.scrollTop,e.forceScroll),null!=e.scrollLeft&&setScrollLeft(t,e.scrollLeft,!0,!0),e.scrollToPos){var i=scrollPosIntoView(t,clipPos(r,e.scrollToPos.from),clipPos(r,e.scrollToPos.to),e.scrollToPos.margin);maybeScrollWindow(t,i)}var o=e.maybeHiddenMarkers,a=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||signal(o[s],"hide");if(a)for(var l=0;l<a.length;++l)a[l].lines.length&&signal(a[l],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop),e.changeObjs&&signal(t,"changes",t,e.changeObjs),e.update&&e.update.finish()}function runInOp(e,t){if(e.curOp)return t();startOperation(e);try{return t()}finally{endOperation(e)}}function operation(e,t){return function(){if(e.curOp)return t.apply(e,arguments);startOperation(e);try{return t.apply(e,arguments)}finally{endOperation(e)}}}function methodOp(e){return function(){if(this.curOp)return e.apply(this,arguments);startOperation(this);try{return e.apply(this,arguments)}finally{endOperation(this)}}}function docMethodOp(e){return function(){var t=this.cm;if(!t||t.curOp)return e.apply(this,arguments);startOperation(t);try{return e.apply(this,arguments)}finally{endOperation(t)}}}function startWorker(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,bind(highlightWorker,e))}function highlightWorker(e){var t=e.doc;if(!(t.highlightFrontier>=e.display.viewTo)){var n=+new Date+e.options.workTime,r=getContextBefore(e,t.highlightFrontier),i=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(r.line>=e.display.viewFrom){var a=o.styles,s=o.text.length>e.options.maxHighlightLength?copyState(t.mode,r.state):null,l=highlightLine(e,o,r,!0);s&&(r.state=s),o.styles=l.styles;var c=o.styleClasses,u=l.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var d=!a||a.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),h=0;!d&&h<a.length;++h)d=a[h]!=o.styles[h];d&&i.push(r.line),o.stateAfter=r.save(),r.nextLine()}else o.text.length<=e.options.maxHighlightLength&&processLine(e,o.text,r),o.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>n)return startWorker(e,e.options.workDelay),!0}),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),i.length&&runInOp(e,function(){for(var t=0;t<i.length;t++)regLineChange(e,i[t],"text")})}}var DisplayUpdate=function(e,t,n){var r=e.display;this.viewport=t,this.visible=visibleLines(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=displayWidth(e),this.force=n,this.dims=getDimensions(e),this.events=[]};function maybeClipScrollbars(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=scrollGap(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=scrollGap(e)+"px",t.scrollbarsClipped=!0)}function selectionSnapshot(e){if(e.hasFocus())return null;var t=activeElt();if(!t||!contains(e.display.lineDiv,t))return null;var n={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&contains(e.display.lineDiv,r.anchorNode)&&(n.anchorNode=r.anchorNode,n.anchorOffset=r.anchorOffset,n.focusNode=r.focusNode,n.focusOffset=r.focusOffset)}return n}function restoreSelection(e){if(e&&e.activeElt&&e.activeElt!=activeElt()&&(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&contains(document.body,e.anchorNode)&&contains(document.body,e.focusNode))){var t=window.getSelection(),n=document.createRange();n.setEnd(e.anchorNode,e.anchorOffset),n.collapse(!1),t.removeAllRanges(),t.addRange(n),t.extend(e.focusNode,e.focusOffset)}}function updateDisplayIfNeeded(e,t){var n=e.display,r=e.doc;if(t.editorIsHidden)return resetView(e),!1;if(!t.force&&t.visible.from>=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==countDirtyView(e))return!1;maybeUpdateLineNumberWidth(e)&&(resetView(e),t.dims=getDimensions(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),a=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFrom<o&&o-n.viewFrom<20&&(o=Math.max(r.first,n.viewFrom)),n.viewTo>a&&n.viewTo-a<20&&(a=Math.min(i,n.viewTo)),Z&&(o=visualLineNo(e.doc,o),a=visualLineEndNo(e.doc,a));var s=o!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;adjustView(e,o,a),n.viewOffset=heightAtLine(getLine(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var l=countDirtyView(e);if(!s&&0==l&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var c=selectionSnapshot(e);return l>4&&(n.lineDiv.style.display="none"),patchDisplay(e,n.updateLineNumbers,t.dims),l>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,restoreSelection(c),removeChildren(n.cursorDiv),removeChildren(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,s&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,startWorker(e,400)),n.updateLineNumbers=null,!0}function postUpdateDisplay(e,t){for(var n=t.viewport,r=!0;;r=!1){if(r&&e.options.lineWrapping&&t.oldDisplayWidth!=displayWidth(e))r&&(t.visible=visibleLines(e.display,e.doc,n));else if(n&&null!=n.top&&(n={top:Math.min(e.doc.height+paddingVert(e.display)-displayHeight(e),n.top)}),t.visible=visibleLines(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!updateDisplayIfNeeded(e,t))break;updateHeightsInViewport(e);var i=measureForScrollbars(e);updateSelection(e),updateScrollbars(e,i),setDocumentHeight(e,i),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function updateDisplaySimple(e,t){var n=new DisplayUpdate(e,t);if(updateDisplayIfNeeded(e,n)){updateHeightsInViewport(e),postUpdateDisplay(e,n);var r=measureForScrollbars(e);updateSelection(e),updateScrollbars(e,r),setDocumentHeight(e,r),n.finish()}}function patchDisplay(e,t,n){var r=e.display,i=e.options.lineNumbers,o=r.lineDiv,a=o.firstChild;function rm(t){var n=t.nextSibling;return m&&M&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}for(var s=r.view,l=r.viewFrom,c=0;c<s.length;c++){var u=s[c];if(u.hidden);else if(u.node&&u.node.parentNode==o){for(;a!=u.node;)a=rm(a);var d=i&&null!=t&&t<=l&&u.lineNumber;u.changes&&(indexOf(u.changes,"gutter")>-1&&(d=!1),updateLineForChanges(e,u,l,n)),d&&(removeChildren(u.lineNumber),u.lineNumber.appendChild(document.createTextNode(lineNumberFor(e.options,l)))),a=u.node.nextSibling}else{var h=buildLineElement(e,u,l,n);o.insertBefore(h,a)}l+=u.size}for(;a;)a=rm(a)}function updateGutterSpace(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function setDocumentHeight(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+scrollGap(e)+"px"}function alignHorizontally(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=compensateForHScroll(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",a=0;a<n.length;a++)if(!n[a].hidden){e.options.fixedGutter&&(n[a].gutter&&(n[a].gutter.style.left=o),n[a].gutterBackground&&(n[a].gutterBackground.style.left=o));var s=n[a].alignable;if(s)for(var l=0;l<s.length;l++)s[l].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=r+i+"px")}}function maybeUpdateLineNumberWidth(e){if(!e.options.lineNumbers)return!1;var t=e.doc,n=lineNumberFor(e.options,t.first+t.size-1),r=e.display;if(n.length!=r.lineNumChars){var i=r.measure.appendChild(elt("div",[elt("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,a=i.offsetWidth-o;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(o,r.lineGutter.offsetWidth-a)+1,r.lineNumWidth=r.lineNumInnerWidth+a,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",updateGutterSpace(e.display),!0}return!1}function getGutters(e,t){for(var n=[],r=!1,i=0;i<e.length;i++){var o=e[i],a=null;if("string"!=typeof o&&(a=o.style,o=o.className),"CodeMirror-linenumbers"==o)if(!t)continue;else r=!0;n.push({className:o,style:a})}return t&&!r&&n.push({className:"CodeMirror-linenumbers",style:null}),n}function renderGutters(e){var t=e.gutters,n=e.gutterSpecs;removeChildren(t),e.lineGutter=null;for(var r=0;r<n.length;++r){var i=n[r],o=i.className,a=i.style,s=t.appendChild(elt("div",null,"CodeMirror-gutter "+o));a&&(s.style.cssText=a),"CodeMirror-linenumbers"==o&&(e.lineGutter=s,s.style.width=(e.lineNumWidth||1)+"px")}t.style.display=n.length?"":"none",updateGutterSpace(e)}function updateGutters(e){renderGutters(e.display),regChange(e),alignHorizontally(e)}function Display(e,t,n,r){this.input=n,this.scrollbarFiller=elt("div",null,"CodeMirror-scrollbar-filler"),this.scrollbarFiller.setAttribute("cm-not-content","true"),this.gutterFiller=elt("div",null,"CodeMirror-gutter-filler"),this.gutterFiller.setAttribute("cm-not-content","true"),this.lineDiv=eltP("div",null,"CodeMirror-code"),this.selectionDiv=elt("div",null,null,"position: relative; z-index: 1"),this.cursorDiv=elt("div",null,"CodeMirror-cursors"),this.measure=elt("div",null,"CodeMirror-measure"),this.lineMeasure=elt("div",null,"CodeMirror-measure"),this.lineSpace=eltP("div",[this.measure,this.lineMeasure,this.selectionDiv,this.cursorDiv,this.lineDiv],null,"position: relative; outline: none");var i=eltP("div",[this.lineSpace],"CodeMirror-lines");this.mover=elt("div",[i],null,"position: relative"),this.sizer=elt("div",[this.mover],"CodeMirror-sizer"),this.sizerWidth=null,this.heightForcer=elt("div",null,null,"position: absolute; height: 50px; width: 1px;"),this.gutters=elt("div",null,"CodeMirror-gutters"),this.lineGutter=null,this.scroller=elt("div",[this.sizer,this.heightForcer,this.gutters],"CodeMirror-scroll"),this.scroller.setAttribute("tabIndex","-1"),this.wrapper=elt("div",[this.scrollbarFiller,this.gutterFiller,this.scroller],"CodeMirror"),f&&g<8&&(this.gutters.style.zIndex=-1,this.scroller.style.paddingRight=0),m||c&&k||(this.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(this.wrapper):e(this.wrapper)),this.viewFrom=this.viewTo=t.first,this.reportedViewFrom=this.reportedViewTo=t.first,this.view=[],this.renderedView=null,this.externalMeasured=null,this.viewOffset=0,this.lastWrapHeight=this.lastWrapWidth=0,this.updateLineNumbers=null,this.nativeBarWidth=this.barHeight=this.barWidth=0,this.scrollbarsClipped=!1,this.lineNumWidth=this.lineNumInnerWidth=this.lineNumChars=null,this.alignWidgets=!1,this.cachedCharWidth=this.cachedTextHeight=this.cachedPaddingH=null,this.maxLine=null,this.maxLineLength=0,this.maxLineChanged=!1,this.wheelDX=this.wheelDY=this.wheelStartX=this.wheelStartY=null,this.shift=!1,this.selForContextMenu=null,this.activeTouch=null,this.gutterSpecs=getGutters(r.gutters,r.lineNumbers),renderGutters(this),n.init(this)}DisplayUpdate.prototype.signal=function(e,t){hasHandler(e,t)&&this.events.push(arguments)},DisplayUpdate.prototype.finish=function(){for(var e=0;e<this.events.length;e++)signal.apply(null,this.events[e])};var eo=0,ea=null;function wheelEventDelta(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==n&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:null==n&&(n=e.wheelDelta),{x:t,y:n}}function wheelEventPixels(e){var t=wheelEventDelta(e);return t.x*=ea,t.y*=ea,t}function onScrollWheel(e,t){var n=wheelEventDelta(t),r=n.x,i=n.y,o=e.display,a=o.scroller,s=a.scrollWidth>a.clientWidth,l=a.scrollHeight>a.clientHeight;if(r&&s||i&&l){if(i&&M&&m){e:for(var u=t.target,d=o.view;u!=a;u=u.parentNode)for(var h=0;h<d.length;h++)if(d[h].node==u){e.display.currentWheelTarget=u;break e}}if(r&&!c&&!C&&null!=ea){i&&l&&updateScrollTop(e,Math.max(0,a.scrollTop+i*ea)),setScrollLeft(e,Math.max(0,a.scrollLeft+r*ea)),(!i||i&&l)&&e_preventDefault(t),o.wheelStartX=null;return}if(i&&null!=ea){var f=i*ea,g=e.doc.scrollTop,v=g+o.wrapper.clientHeight;f<0?g=Math.max(0,g+f-50):v=Math.min(e.doc.height,v+f+50),updateDisplaySimple(e,{top:g,bottom:v})}eo<20&&(null==o.wheelStartX?(o.wheelStartX=a.scrollLeft,o.wheelStartY=a.scrollTop,o.wheelDX=r,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=a.scrollLeft-o.wheelStartX,t=a.scrollTop-o.wheelStartY,n=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,n&&(ea=(ea*eo+n)/(eo+1),++eo)}},200)):(o.wheelDX+=r,o.wheelDY+=i))}}f?ea=-.53:c?ea=15:y?ea=-.7:b&&(ea=-1/3);var Selection=function(e,t){this.ranges=e,this.primIndex=t};Selection.prototype.primary=function(){return this.ranges[this.primIndex]},Selection.prototype.equals=function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t<this.ranges.length;t++){var n=this.ranges[t],r=e.ranges[t];if(!equalCursorPos(n.anchor,r.anchor)||!equalCursorPos(n.head,r.head))return!1}return!0},Selection.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new Range(copyPos(this.ranges[t].anchor),copyPos(this.ranges[t].head));return new Selection(e,this.primIndex)},Selection.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},Selection.prototype.contains=function(e,t){t||(t=e);for(var n=0;n<this.ranges.length;n++){var r=this.ranges[n];if(cmp(t,r.from())>=0&&0>=cmp(e,r.to()))return n}return -1};var Range=function(e,t){this.anchor=e,this.head=t};function normalizeSelection(e,t,n){var r=e&&e.options.selectionsMayTouch,i=t[n];t.sort(function(e,t){return cmp(e.from(),t.from())}),n=indexOf(t,i);for(var o=1;o<t.length;o++){var a=t[o],s=t[o-1],l=cmp(s.to(),a.from());if(r&&!a.empty()?l>0:l>=0){var c=minPos(s.from(),a.from()),u=maxPos(s.to(),a.to()),d=s.empty()?a.from()==a.head:s.from()==s.head;o<=n&&--n,t.splice(--o,2,new Range(d?u:c,d?c:u))}}return new Selection(t,n)}function simpleSelection(e,t){return new Selection([new Range(e,t||e)],0)}function changeEnd(e){return e.text?Pos(e.from.line+e.text.length-1,lst(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function adjustForChange(e,t){if(0>cmp(e,t.from))return e;if(0>=cmp(e,t.to))return changeEnd(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=changeEnd(t).ch-t.to.ch),Pos(n,r)}function computeSelAfterChange(e,t){for(var n=[],r=0;r<e.sel.ranges.length;r++){var i=e.sel.ranges[r];n.push(new Range(adjustForChange(i.anchor,t),adjustForChange(i.head,t)))}return normalizeSelection(e.cm,n,e.sel.primIndex)}function offsetPos(e,t,n){return e.line==t.line?Pos(n.line,e.ch-t.ch+n.ch):Pos(n.line+(e.line-t.line),e.ch)}function computeReplacedSel(e,t,n){for(var r=[],i=Pos(e.first,0),o=i,a=0;a<t.length;a++){var s=t[a],l=offsetPos(s.from,i,o),c=offsetPos(changeEnd(s),i,o);if(i=s.to,o=c,"around"==n){var u=e.sel.ranges[a],d=0>cmp(u.head,u.anchor);r[a]=new Range(d?c:l,d?l:c)}else r[a]=new Range(l,l)}return new Selection(r,e.sel.primIndex)}function loadMode(e){e.doc.mode=getMode(e.options,e.doc.modeOption),resetModeState(e)}function resetModeState(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,startWorker(e,100),e.state.modeGen++,e.curOp&&regChange(e)}function isWholeLineUpdate(e,t){return 0==t.from.ch&&0==t.to.ch&&""==lst(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function updateDoc(e,t,n,r){function spansFor(e){return n?n[e]:null}function update(e,n,i){updateLine(e,n,i,r),signalLater(e,"change",e,t)}function linesFor(e,t){for(var n=[],i=e;i<t;++i)n.push(new Line(a[i],spansFor(i),r));return n}var i=t.from,o=t.to,a=t.text,s=getLine(e,i.line),l=getLine(e,o.line),c=lst(a),u=spansFor(a.length-1),d=o.line-i.line;if(t.full)e.insert(0,linesFor(0,a.length)),e.remove(a.length,e.size-a.length);else if(isWholeLineUpdate(e,t)){var h=linesFor(0,a.length-1);update(l,l.text,u),d&&e.remove(i.line,d),h.length&&e.insert(i.line,h)}else if(s==l)if(1==a.length)update(s,s.text.slice(0,i.ch)+c+s.text.slice(o.ch),u);else{var f=linesFor(1,a.length-1);f.push(new Line(c+s.text.slice(o.ch),u,r)),update(s,s.text.slice(0,i.ch)+a[0],spansFor(0)),e.insert(i.line+1,f)}else if(1==a.length)update(s,s.text.slice(0,i.ch)+a[0]+l.text.slice(o.ch),spansFor(0)),e.remove(i.line+1,d);else{update(s,s.text.slice(0,i.ch)+a[0],spansFor(0)),update(l,c+l.text.slice(o.ch),u);var g=linesFor(1,a.length-1);d>1&&e.remove(i.line+1,d-1),e.insert(i.line+1,g)}signalLater(e,"change",e,t)}function linkedDocs(e,t,n){function propagate(e,r,i){if(e.linked)for(var o=0;o<e.linked.length;++o){var a=e.linked[o];if(a.doc!=r){var s=i&&a.sharedHist;(!n||s)&&(t(a.doc,s),propagate(a.doc,e,s))}}}propagate(e,null,!0)}function attachDoc(e,t){if(t.cm)throw Error("This document is already in use.");e.doc=t,t.cm=e,estimateLineHeights(e),loadMode(e),setDirectionClass(e),e.options.lineWrapping||findMaxLine(e),e.options.mode=t.modeOption,regChange(e)}function setDirectionClass(e){("rtl"==e.doc.direction?addClass:rmClass)(e.display.lineDiv,"CodeMirror-rtl")}function directionChanged(e){runInOp(e,function(){setDirectionClass(e),regChange(e)})}function History(e){this.done=[],this.undone=[],this.undoDepth=e?e.undoDepth:1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=e?e.maxGeneration:1}function historyChangeFromChange(e,t){var n={from:copyPos(t.from),to:changeEnd(t),text:getBetween(e,t.from,t.to)};return attachLocalSpans(e,n,t.from.line,t.to.line+1),linkedDocs(e,function(e){return attachLocalSpans(e,n,t.from.line,t.to.line+1)},!0),n}function clearSelectionEvents(e){for(;e.length;)if(lst(e).ranges)e.pop();else break}function lastChangeEvent(e,t){return t?(clearSelectionEvents(e.done),lst(e.done)):e.done.length&&!lst(e.done).ranges?lst(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),lst(e.done)):void 0}function addChangeToHistory(e,t,n,r){var i,o=e.history;o.undone.length=0;var a,s=+new Date;if((o.lastOp==r||o.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&o.lastModTime>s-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(a=lastChangeEvent(o,o.lastOp==r)))i=lst(a.changes),0==cmp(t.from,t.to)&&0==cmp(t.from,i.to)?i.to=changeEnd(t):a.changes.push(historyChangeFromChange(e,t));else{var l=lst(o.done);for(l&&l.ranges||pushSelectionToHistory(e.sel,o.done),a={changes:[historyChangeFromChange(e,t)],generation:o.generation},o.done.push(a);o.done.length>o.undoDepth;)o.done.shift(),o.done[0].ranges||o.done.shift()}o.done.push(n),o.generation=++o.maxGeneration,o.lastModTime=o.lastSelTime=s,o.lastOp=o.lastSelOp=r,o.lastOrigin=o.lastSelOrigin=t.origin,i||signal(e,"historyAdded")}function selectionEventCanBeMerged(e,t,n,r){var i=t.charAt(0);return"*"==i||"+"==i&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function addSelectionToHistory(e,t,n,r){var i=e.history,o=r&&r.origin;n==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||selectionEventCanBeMerged(e,o,lst(i.done),t))?i.done[i.done.length-1]=t:pushSelectionToHistory(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=n,r&&!1!==r.clearRedo&&clearSelectionEvents(i.undone)}function pushSelectionToHistory(e,t){var n=lst(t);n&&n.ranges&&n.equals(e)||t.push(e)}function attachLocalSpans(e,t,n,r){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=n.markedSpans),++o})}function removeClearedSpans(e){if(!e)return null;for(var t,n=0;n<e.length;++n)e[n].marker.explicitlyCleared?t||(t=e.slice(0,n)):t&&t.push(e[n]);return t?t.length?t:null:e}function getOldSpans(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var r=[],i=0;i<t.text.length;++i)r.push(removeClearedSpans(n[i]));return r}function mergeOldSpans(e,t){var n=getOldSpans(e,t),r=stretchSpansOverChange(e,t);if(!n)return r;if(!r)return n;for(var i=0;i<n.length;++i){var o=n[i],a=r[i];if(o&&a)t:for(var s=0;s<a.length;++s){for(var l=a[s],c=0;c<o.length;++c)if(o[c].marker==l.marker)continue t;o.push(l)}else a&&(n[i]=a)}return n}function copyHistoryArray(e,t,n){for(var r=[],i=0;i<e.length;++i){var o=e[i];if(o.ranges){r.push(n?Selection.prototype.deepCopy.call(o):o);continue}var a=o.changes,s=[];r.push({changes:s});for(var l=0;l<a.length;++l){var c=a[l],u=void 0;if(s.push({from:c.from,to:c.to,text:c.text}),t)for(var d in c)(u=d.match(/^spans_(\d+)$/))&&indexOf(t,Number(u[1]))>-1&&(lst(s)[d]=c[d],delete c[d])}}return r}function extendRange(e,t,n,r){if(!r)return new Range(n||t,t);var i=e.anchor;if(n){var o=0>cmp(t,i);o!=0>cmp(n,i)?(i=t,t=n):o!=0>cmp(t,n)&&(t=n)}return new Range(i,t)}function extendSelection(e,t,n,r,i){null==i&&(i=e.cm&&(e.cm.display.shift||e.extend)),setSelection(e,new Selection([extendRange(e.sel.primary(),t,n,i)],0),r)}function extendSelections(e,t,n){for(var r=[],i=e.cm&&(e.cm.display.shift||e.extend),o=0;o<e.sel.ranges.length;o++)r[o]=extendRange(e.sel.ranges[o],t[o],null,i);var a=normalizeSelection(e.cm,r,e.sel.primIndex);setSelection(e,a,n)}function replaceOneSelection(e,t,n,r){var i=e.sel.ranges.slice(0);i[t]=n,setSelection(e,normalizeSelection(e.cm,i,e.sel.primIndex),r)}function filterSelectionChange(e,t,n){var r={ranges:t.ranges,update:function(t){this.ranges=[];for(var n=0;n<t.length;n++)this.ranges[n]=new Range(clipPos(e,t[n].anchor),clipPos(e,t[n].head))},origin:n&&n.origin};return(signal(e,"beforeSelectionChange",e,r),e.cm&&signal(e.cm,"beforeSelectionChange",e.cm,r),r.ranges!=t.ranges)?normalizeSelection(e.cm,r.ranges,r.ranges.length-1):t}function setSelectionReplaceHistory(e,t,n){var r=e.history.done,i=lst(r);i&&i.ranges?(r[r.length-1]=t,setSelectionNoUndo(e,t,n)):setSelection(e,t,n)}function setSelection(e,t,n){setSelectionNoUndo(e,t,n),addSelectionToHistory(e,e.sel,e.cm?e.cm.curOp.id:NaN,n)}function setSelectionNoUndo(e,t,n){(hasHandler(e,"beforeSelectionChange")||e.cm&&hasHandler(e.cm,"beforeSelectionChange"))&&(t=filterSelectionChange(e,t,n));var r=n&&n.bias||(0>cmp(t.primary().head,e.sel.primary().head)?-1:1);setSelectionInner(e,skipAtomicInSelection(e,t,r,!0)),!(n&&!1===n.scroll)&&e.cm&&"nocursor"!=e.cm.getOption("readOnly")&&ensureCursorVisible(e.cm)}function setSelectionInner(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,signalCursorActivity(e.cm)),signalLater(e,"cursorActivity",e))}function reCheckSelection(e){setSelectionInner(e,skipAtomicInSelection(e,e.sel,null,!1))}function skipAtomicInSelection(e,t,n,r){for(var i,o=0;o<t.ranges.length;o++){var a=t.ranges[o],s=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[o],l=skipAtomic(e,a.anchor,s&&s.anchor,n,r),c=skipAtomic(e,a.head,s&&s.head,n,r);(i||l!=a.anchor||c!=a.head)&&(i||(i=t.ranges.slice(0,o)),i[o]=new Range(l,c))}return i?normalizeSelection(e.cm,i,t.primIndex):t}function skipAtomicInner(e,t,n,r,i){var o=getLine(e,t.line);if(o.markedSpans)for(var a=0;a<o.markedSpans.length;++a){var s=o.markedSpans[a],l=s.marker,c="selectLeft"in l?!l.selectLeft:l.inclusiveLeft,u="selectRight"in l?!l.selectRight:l.inclusiveRight;if((null==s.from||(c?s.from<=t.ch:s.from<t.ch))&&(null==s.to||(u?s.to>=t.ch:s.to>t.ch))){if(i&&(signal(l,"beforeCursorEnter"),l.explicitlyCleared))if(o.markedSpans){--a;continue}else break;if(!l.atomic)continue;if(n){var d=l.find(r<0?1:-1),h=void 0;if((r<0?u:c)&&(d=movePos(e,d,-r,d&&d.line==t.line?o:null)),d&&d.line==t.line&&(h=cmp(d,n))&&(r<0?h<0:h>0))return skipAtomicInner(e,d,t,r,i)}var f=l.find(r<0?-1:1);return(r<0?c:u)&&(f=movePos(e,f,r,f.line==t.line?o:null)),f?skipAtomicInner(e,f,t,r,i):null}}return t}function skipAtomic(e,t,n,r,i){var o=r||1,a=skipAtomicInner(e,t,n,o,i)||!i&&skipAtomicInner(e,t,n,o,!0)||skipAtomicInner(e,t,n,-o,i)||!i&&skipAtomicInner(e,t,n,-o,!0);return a||(e.cantEdit=!0,Pos(e.first,0))}function movePos(e,t,n,r){if(n<0&&0==t.ch)if(t.line>e.first)return clipPos(e,Pos(t.line-1));else return null;return n>0&&t.ch==(r||getLine(e,t.line)).text.length?t.line<e.first+e.size-1?Pos(t.line+1,0):null:new Pos(t.line,t.ch+n)}function selectAll(e){e.setSelection(Pos(e.firstLine(),0),Pos(e.lastLine()),H)}function filterChange(e,t,n){var r={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function(){return r.canceled=!0}};return(n&&(r.update=function(t,n,i,o){t&&(r.from=clipPos(e,t)),n&&(r.to=clipPos(e,n)),i&&(r.text=i),void 0!==o&&(r.origin=o)}),signal(e,"beforeChange",e,r),e.cm&&signal(e.cm,"beforeChange",e.cm,r),r.canceled)?(e.cm&&(e.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function makeChange(e,t,n){if(e.cm){if(!e.cm.curOp)return operation(e.cm,makeChange)(e,t,n);if(e.cm.state.suppressEdits)return}if(!(hasHandler(e,"beforeChange")||e.cm&&hasHandler(e.cm,"beforeChange"))||(t=filterChange(e,t,!0))){var r=$&&!n&&removeReadOnlyRanges(e,t.from,t.to);if(r)for(var i=r.length-1;i>=0;--i)makeChangeInner(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text,origin:t.origin});else makeChangeInner(e,t)}}function makeChangeInner(e,t){if(1!=t.text.length||""!=t.text[0]||0!=cmp(t.from,t.to)){var n=computeSelAfterChange(e,t);addChangeToHistory(e,t,n,e.cm?e.cm.curOp.id:NaN),makeChangeSingleDoc(e,t,n,stretchSpansOverChange(e,t));var r=[];linkedDocs(e,function(e,n){n||-1!=indexOf(r,e.history)||(rebaseHist(e.history,t),r.push(e.history)),makeChangeSingleDoc(e,t,null,stretchSpansOverChange(e,t))})}}function makeChangeFromHistory(e,t,n){var r=e.cm&&e.cm.state.suppressEdits;if(!r||n){for(var i,o=e.history,a=e.sel,s="undo"==t?o.done:o.undone,l="undo"==t?o.undone:o.done,c=0;c<s.length&&(i=s[c],n?!i.ranges||i.equals(e.sel):i.ranges);c++);if(c!=s.length){for(o.lastOrigin=o.lastSelOrigin=null;;)if((i=s.pop()).ranges){if(pushSelectionToHistory(i,l),n&&!i.equals(e.sel))return void setSelection(e,i,{clearRedo:!1});a=i}else if(r)return void s.push(i);else break;var u=[];pushSelectionToHistory(a,l),l.push({changes:u,generation:o.generation}),o.generation=i.generation||++o.maxGeneration;for(var d=hasHandler(e,"beforeChange")||e.cm&&hasHandler(e.cm,"beforeChange"),h=i.changes.length-1;h>=0;--h){var f=function(n){var r=i.changes[n];if(r.origin=t,d&&!filterChange(e,r,!1))return s.length=0,{};u.push(historyChangeFromChange(e,r));var o=n?computeSelAfterChange(e,r):lst(s);makeChangeSingleDoc(e,r,o,mergeOldSpans(e,r)),!n&&e.cm&&e.cm.scrollIntoView({from:r.from,to:changeEnd(r)});var a=[];linkedDocs(e,function(e,t){t||-1!=indexOf(a,e.history)||(rebaseHist(e.history,r),a.push(e.history)),makeChangeSingleDoc(e,r,null,mergeOldSpans(e,r))})}(h);if(f)return f.v}}}}function shiftDoc(e,t){if(0!=t&&(e.first+=t,e.sel=new Selection(map(e.sel.ranges,function(e){return new Range(Pos(e.anchor.line+t,e.anchor.ch),Pos(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){regChange(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;r<n.viewTo;r++)regLineChange(e.cm,r,"gutter")}}function makeChangeSingleDoc(e,t,n,r){if(e.cm&&!e.cm.curOp)return operation(e.cm,makeChangeSingleDoc)(e,t,n,r);if(t.to.line<e.first)return void shiftDoc(e,t.text.length-1-(t.to.line-t.from.line));if(!(t.from.line>e.lastLine())){if(t.from.line<e.first){var i=t.text.length-1-(e.first-t.from.line);shiftDoc(e,i),t={from:Pos(e.first,0),to:Pos(t.to.line+i,t.to.ch),text:[lst(t.text)],origin:t.origin}}var o=e.lastLine();t.to.line>o&&(t={from:t.from,to:Pos(o,getLine(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=getBetween(e,t.from,t.to),n||(n=computeSelAfterChange(e,t)),e.cm?makeChangeSingleDocInEditor(e.cm,t,r):updateDoc(e,t,r),setSelectionNoUndo(e,n,H),e.cantEdit&&skipAtomic(e,Pos(e.firstLine(),0))&&(e.cantEdit=!1)}}function makeChangeSingleDocInEditor(e,t,n){var r=e.doc,i=e.display,o=t.from,a=t.to,s=!1,l=o.line;e.options.lineWrapping||(l=lineNo(visualLine(getLine(r,o.line))),r.iter(l,a.line+1,function(e){if(e==i.maxLine)return s=!0,!0})),r.sel.contains(t.from,t.to)>-1&&signalCursorActivity(e),updateDoc(r,t,n,estimateHeight(e)),!e.options.lineWrapping&&(r.iter(l,o.line+t.text.length,function(e){var t=lineLength(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),retreatFrontier(r,o.line),startWorker(e,400);var c=t.text.length-(a.line-o.line)-1;t.full?regChange(e):o.line!=a.line||1!=t.text.length||isWholeLineUpdate(e.doc,t)?regChange(e,o.line,a.line+1,c):regLineChange(e,o.line,"text");var u=hasHandler(e,"changes"),d=hasHandler(e,"change");if(d||u){var h={from:o,to:a,text:t.text,removed:t.removed,origin:t.origin};d&&signalLater(e,"change",e,h),u&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function replaceRange(e,t,n,r,i){var o;r||(r=n),0>cmp(r,n)&&(n=(o=[r,n])[0],r=o[1]),"string"==typeof t&&(t=e.splitLines(t)),makeChange(e,{from:n,to:r,text:t,origin:i})}function rebaseHistSelSingle(e,t,n,r){n<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function rebaseHistArray(e,t,n,r){for(var i=0;i<e.length;++i){var o=e[i],a=!0;if(o.ranges){o.copied||((o=e[i]=o.deepCopy()).copied=!0);for(var s=0;s<o.ranges.length;s++)rebaseHistSelSingle(o.ranges[s].anchor,t,n,r),rebaseHistSelSingle(o.ranges[s].head,t,n,r);continue}for(var l=0;l<o.changes.length;++l){var c=o.changes[l];if(n<c.from.line)c.from=Pos(c.from.line+r,c.from.ch),c.to=Pos(c.to.line+r,c.to.ch);else if(t<=c.to.line){a=!1;break}}a||(e.splice(0,i+1),i=0)}}function rebaseHist(e,t){var n=t.from.line,r=t.to.line,i=t.text.length-(r-n)-1;rebaseHistArray(e.done,n,r,i),rebaseHistArray(e.undone,n,r,i)}function changeLine(e,t,n,r){var i=t,o=t;return("number"==typeof t?o=getLine(e,clipLine(e,t)):i=lineNo(t),null==i)?null:(r(o,i)&&e.cm&&regLineChange(e.cm,i,n),o)}function LeafChunk(e){this.lines=e,this.parent=null;for(var t=0,n=0;n<e.length;++n)e[n].parent=this,t+=e[n].height;this.height=t}function BranchChunk(e){this.children=e;for(var t=0,n=0,r=0;r<e.length;++r){var i=e[r];t+=i.chunkSize(),n+=i.height,i.parent=this}this.size=t,this.height=n,this.parent=null}Range.prototype.from=function(){return minPos(this.anchor,this.head)},Range.prototype.to=function(){return maxPos(this.anchor,this.head)},Range.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},LeafChunk.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n=e,r=e+t;n<r;++n){var i=this.lines[n];this.height-=i.height,cleanUpLine(i),signalLater(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,n){for(var r=e+t;e<r;++e)if(n(this.lines[e]))return!0}},BranchChunk.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;n<this.children.length;++n){var r=this.children[n],i=r.chunkSize();if(e<i){var o=Math.min(t,i-e),a=r.height;if(r.removeInner(e,o),this.height-=a-r.height,i==o&&(this.children.splice(n--,1),r.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof LeafChunk))){var s=[];this.collapse(s),this.children=[new LeafChunk(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,n){this.size+=t.length,this.height+=n;for(var r=0;r<this.children.length;++r){var i=this.children[r],o=i.chunkSize();if(e<=o){if(i.insertInner(e,t,n),i.lines&&i.lines.length>50){for(var a=i.lines.length%25+25,s=a;s<i.lines.length;){var l=new LeafChunk(i.lines.slice(s,s+=25));i.height-=l.height,this.children.splice(++r,0,l),l.parent=this}i.lines=i.lines.slice(0,a),this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t=new BranchChunk(e.children.splice(e.children.length-5,5));if(e.parent){e.size-=t.size,e.height-=t.height;var n=indexOf(e.parent.children,e);e.parent.children.splice(n+1,0,t)}else{var r=new BranchChunk(e.children);r.parent=e,e.children=[r,t],e=r}t.parent=e.parent}while(e.children.length>10)e.parent.maybeSpill()}},iterN:function(e,t,n){for(var r=0;r<this.children.length;++r){var i=this.children[r],o=i.chunkSize();if(e<o){var a=Math.min(t,o-e);if(i.iterN(e,a,n))return!0;if(0==(t-=a))break;e=0}else e-=o}}};var LineWidget=function(e,t,n){if(n)for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.doc=e,this.node=t};function adjustScrollWhenAboveVisible(e,t,n){heightAtLine(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&addToScrollTop(e,n)}function addLineWidget(e,t,n,r){var i=new LineWidget(e,n,r),o=e.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),changeLine(e,t,"widget",function(t){var n=t.widgets||(t.widgets=[]);if(null==i.insertAt?n.push(i):n.splice(Math.min(n.length,Math.max(0,i.insertAt)),0,i),i.line=t,o&&!lineIsHidden(e,t)){var r=heightAtLine(t)<e.scrollTop;updateLineHeight(t,t.height+widgetHeight(i)),r&&addToScrollTop(o,i.height),o.curOp.forceUpdate=!0}return!0}),o&&signalLater(o,"lineWidgetAdded",o,i,"number"==typeof t?t:lineNo(t)),i}LineWidget.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,n=this.line,r=lineNo(n);if(null!=r&&t){for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(n.widgets=null);var o=widgetHeight(this);updateLineHeight(n,Math.max(0,n.height-o)),e&&(runInOp(e,function(){adjustScrollWhenAboveVisible(e,n,-o),regLineChange(e,r,"widget")}),signalLater(e,"lineWidgetCleared",e,this,r))}},LineWidget.prototype.changed=function(){var e=this,t=this.height,n=this.doc.cm,r=this.line;this.height=null;var i=widgetHeight(this)-t;i&&(lineIsHidden(this.doc,r)||updateLineHeight(r,r.height+i),n&&runInOp(n,function(){n.curOp.forceUpdate=!0,adjustScrollWhenAboveVisible(n,r,i),signalLater(n,"lineWidgetChanged",n,e,lineNo(r))}))},eventMixin(LineWidget);var es=0,TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++es};function markText(e,t,n,r,i){if(r&&r.shared)return markTextShared(e,t,n,r,i);if(e.cm&&!e.cm.curOp)return operation(e.cm,markText)(e,t,n,r,i);var o=new TextMarker(e,i),a=cmp(t,n);if(r&&copyObj(r,o,!1),a>0||0==a&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=eltP("span",[o.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(conflictingCollapsedRange(e,t.line,t,n,o)||t.line!=n.line&&conflictingCollapsedRange(e,n.line,t,n,o))throw Error("Inserting collapsed marker partially overlapping an existing one");seeCollapsedSpans()}o.addToHistory&&addChangeToHistory(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var s,l=t.line,c=e.cm;if(e.iter(l,n.line+1,function(e){c&&o.collapsed&&!c.options.lineWrapping&&visualLine(e)==c.display.maxLine&&(s=!0),o.collapsed&&l!=t.line&&updateLineHeight(e,0),addMarkedSpan(e,new MarkedSpan(o,l==t.line?t.ch:null,l==n.line?n.ch:null)),++l}),o.collapsed&&e.iter(t.line,n.line+1,function(t){lineIsHidden(e,t)&&updateLineHeight(t,0)}),o.clearOnEnter&&on(o,"beforeCursorEnter",function(){return o.clear()}),o.readOnly&&(seeReadOnlySpans(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++es,o.atomic=!0),c){if(s&&(c.curOp.updateMaxLine=!0),o.collapsed)regChange(c,t.line,n.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(var u=t.line;u<=n.line;u++)regLineChange(c,u,"text");o.atomic&&reCheckSelection(c.doc),signalLater(c,"markerAdded",c,o)}return o}TextMarker.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&startOperation(e),hasHandler(this,"clear")){var n=this.find();n&&signalLater(this,"clear",n.from,n.to)}for(var r=null,i=null,o=0;o<this.lines.length;++o){var a=this.lines[o],s=getMarkedSpanFor(a.markedSpans,this);e&&!this.collapsed?regLineChange(e,lineNo(a),"text"):e&&(null!=s.to&&(i=lineNo(a)),null!=s.from&&(r=lineNo(a))),a.markedSpans=removeMarkedSpan(a.markedSpans,s),null==s.from&&this.collapsed&&!lineIsHidden(this.doc,a)&&e&&updateLineHeight(a,textHeight(e.display))}if(e&&this.collapsed&&!e.options.lineWrapping)for(var l=0;l<this.lines.length;++l){var c=visualLine(this.lines[l]),u=lineLength(c);u>e.display.maxLineLength&&(e.display.maxLine=c,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&regChange(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&reCheckSelection(e.doc)),e&&signalLater(e,"markerCleared",e,this,r,i),t&&endOperation(e),this.parent&&this.parent.clear()}},TextMarker.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var n,r,i=0;i<this.lines.length;++i){var o=this.lines[i],a=getMarkedSpanFor(o.markedSpans,this);if(null!=a.from&&(n=Pos(t?o:lineNo(o),a.from),-1==e))return n;if(null!=a.to&&(r=Pos(t?o:lineNo(o),a.to),1==e))return r}return n&&{from:n,to:r}},TextMarker.prototype.changed=function(){var e=this,t=this.find(-1,!0),n=this,r=this.doc.cm;t&&r&&runInOp(r,function(){var i=t.line,o=findViewForLine(r,lineNo(t.line));if(o&&(clearLineMeasurementCacheFor(o),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!lineIsHidden(n.doc,i)&&null!=n.height){var a=n.height;n.height=null;var s=widgetHeight(n)-a;s&&updateLineHeight(i,i.height+s)}signalLater(r,"markerChanged",r,e)})},TextMarker.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;t.maybeHiddenMarkers&&-1!=indexOf(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(e)},TextMarker.prototype.detachLine=function(e){if(this.lines.splice(indexOf(this.lines,e),1),!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}},eventMixin(TextMarker);var SharedTextMarker=function(e,t){this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=this};function markTextShared(e,t,n,r,i){(r=copyObj(r)).shared=!1;var o=[markText(e,t,n,r,i)],a=o[0],s=r.widgetNode;return linkedDocs(e,function(e){s&&(r.widgetNode=s.cloneNode(!0)),o.push(markText(e,clipPos(e,t),clipPos(e,n),r,i));for(var l=0;l<e.linked.length;++l)if(e.linked[l].isParent)return;a=lst(o)}),new SharedTextMarker(o,a)}function findSharedMarkers(e){return e.findMarks(Pos(e.first,0),e.clipPos(Pos(e.lastLine())),function(e){return e.parent})}function copySharedMarkers(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.find(),o=e.clipPos(i.from),a=e.clipPos(i.to);if(cmp(o,a)){var s=markText(e,o,a,r.primary,r.primary.type);r.markers.push(s),s.parent=r}}}function detachSharedMarkers(e){for(var t=0;t<e.length;t++)!function(t){var n=e[t],r=[n.primary.doc];linkedDocs(n.primary.doc,function(e){return r.push(e)});for(var i=0;i<n.markers.length;i++){var o=n.markers[i];-1==indexOf(r,o.doc)&&(o.parent=null,n.markers.splice(i--,1))}}(t)}SharedTextMarker.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();signalLater(this,"clear")}},SharedTextMarker.prototype.find=function(e,t){return this.primary.find(e,t)},eventMixin(SharedTextMarker);var el=0,Doc=function(e,t,n,r,i){if(!(this instanceof Doc))return new Doc(e,t,n,r,i);null==n&&(n=0),BranchChunk.call(this,[new LeafChunk([new Line("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=n;var o=Pos(n,0);this.sel=simpleSelection(o),this.history=new History(null),this.id=++el,this.modeOption=t,this.lineSep=r,this.direction="rtl"==i?"rtl":"ltr",this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),updateDoc(this,{from:o,to:o,text:e}),setSelection(this,simpleSelection(o),H)};Doc.prototype=createObj(BranchChunk.prototype,{constructor:Doc,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var n=0,r=0;r<t.length;++r)n+=t[r].height;this.insertInner(e-this.first,t,n)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=getLines(this,this.first,this.first+this.size);return!1===e?t:t.join(e||this.lineSeparator())},setValue:docMethodOp(function(e){var t=Pos(this.first,0),n=this.first+this.size-1;makeChange(this,{from:t,to:Pos(n,getLine(this,n).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&scrollToCoords(this.cm,0,0),setSelection(this,simpleSelection(t),H)}),replaceRange:function(e,t,n,r){t=clipPos(this,t),n=n?clipPos(this,n):t,replaceRange(this,e,t,n,r)},getRange:function(e,t,n){var r=getBetween(this,clipPos(this,e),clipPos(this,t));return!1===n?r:r.join(n||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(isLine(this,e))return getLine(this,e)},getLineNumber:function(e){return lineNo(e)},getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=getLine(this,e)),visualLine(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return clipPos(this,e)},getCursor:function(e){var t=this.sel.primary();return null==e||"head"==e?t.head:"anchor"==e?t.anchor:"end"==e||"to"==e||!1===e?t.to():t.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:docMethodOp(function(e,t,n){var r;r=clipPos(this,"number"==typeof e?Pos(e,t||0):e),setSelection(this,simpleSelection(r,null),n)}),setSelection:docMethodOp(function(e,t,n){var r,i;r=clipPos(this,e),i=clipPos(this,t||e),setSelection(this,simpleSelection(r,i),n)}),extendSelection:docMethodOp(function(e,t,n){extendSelection(this,clipPos(this,e),t&&clipPos(this,t),n)}),extendSelections:docMethodOp(function(e,t){extendSelections(this,clipPosArray(this,e),t)}),extendSelectionsBy:docMethodOp(function(e,t){extendSelections(this,clipPosArray(this,map(this.sel.ranges,e)),t)}),setSelections:docMethodOp(function(e,t,n){if(e.length){for(var r=[],i=0;i<e.length;i++)r[i]=new Range(clipPos(this,e[i].anchor),clipPos(this,e[i].head||e[i].anchor));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),setSelection(this,normalizeSelection(this.cm,r,t),n)}}),addSelection:docMethodOp(function(e,t,n){var r=this.sel.ranges.slice(0);r.push(new Range(clipPos(this,e),clipPos(this,t||e))),setSelection(this,normalizeSelection(this.cm,r,r.length-1),n)}),getSelection:function(e){for(var t,n=this.sel.ranges,r=0;r<n.length;r++){var i=getBetween(this,n[r].from(),n[r].to());t=t?t.concat(i):i}return!1===e?t:t.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],n=this.sel.ranges,r=0;r<n.length;r++){var i=getBetween(this,n[r].from(),n[r].to());!1!==e&&(i=i.join(e||this.lineSeparator())),t[r]=i}return t},replaceSelection:function(e,t,n){for(var r=[],i=0;i<this.sel.ranges.length;i++)r[i]=e;this.replaceSelections(r,t,n||"+input")},replaceSelections:docMethodOp(function(e,t,n){for(var r=[],i=this.sel,o=0;o<i.ranges.length;o++){var a=i.ranges[o];r[o]={from:a.from(),to:a.to(),text:this.splitLines(e[o]),origin:n}}for(var s=t&&"end"!=t&&computeReplacedSel(this,r,t),l=r.length-1;l>=0;l--)makeChange(this,r[l]);s?setSelectionReplaceHistory(this,s):this.cm&&ensureCursorVisible(this.cm)}),undo:docMethodOp(function(){makeChangeFromHistory(this,"undo")}),redo:docMethodOp(function(){makeChangeFromHistory(this,"redo")}),undoSelection:docMethodOp(function(){makeChangeFromHistory(this,"undo",!0)}),redoSelection:docMethodOp(function(){makeChangeFromHistory(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,r=0;r<e.done.length;r++)!e.done[r].ranges&&++t;for(var i=0;i<e.undone.length;i++)!e.undone[i].ranges&&++n;return{undo:t,redo:n}},clearHistory:function(){var e=this;this.history=new History(this.history),linkedDocs(this,function(t){return t.history=e.history},!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:copyHistoryArray(this.history.done),undone:copyHistoryArray(this.history.undone)}},setHistory:function(e){var t=this.history=new History(this.history);t.done=copyHistoryArray(e.done.slice(0),null,!0),t.undone=copyHistoryArray(e.undone.slice(0),null,!0)},setGutterMarker:docMethodOp(function(e,t,n){return changeLine(this,e,"gutter",function(e){var r=e.gutterMarkers||(e.gutterMarkers={});return r[t]=n,!n&&isEmpty(r)&&(e.gutterMarkers=null),!0})}),clearGutter:docMethodOp(function(e){var t=this;this.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&changeLine(t,n,"gutter",function(){return n.gutterMarkers[e]=null,isEmpty(n.gutterMarkers)&&(n.gutterMarkers=null),!0})})}),lineInfo:function(e){var t;if("number"==typeof e){if(!isLine(this,e)||(t=e,!(e=getLine(this,e))))return null}else if(null==(t=lineNo(e)))return null;return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},addLineClass:docMethodOp(function(e,t,n){return changeLine(this,e,"gutter"==t?"gutter":"class",function(e){var r="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass";if(e[r]){if(classTest(n).test(e[r]))return!1;e[r]+=" "+n}else e[r]=n;return!0})}),removeLineClass:docMethodOp(function(e,t,n){return changeLine(this,e,"gutter"==t?"gutter":"class",function(e){var r="text"==t?"textClass":"background"==t?"bgClass":"gutter"==t?"gutterClass":"wrapClass",i=e[r];if(!i)return!1;if(null==n)e[r]=null;else{var o=i.match(classTest(n));if(!o)return!1;var a=o.index+o[0].length;e[r]=i.slice(0,o.index)+(o.index&&a!=i.length?" ":"")+i.slice(a)||null}return!0})}),addLineWidget:docMethodOp(function(e,t,n){return addLineWidget(this,e,t,n)}),removeLineWidget:function(e){e.clear()},markText:function(e,t,n){return markText(this,clipPos(this,e),clipPos(this,t),n,n&&n.type||"range")},setBookmark:function(e,t){var n={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return markText(this,e=clipPos(this,e),e,n,"bookmark")},findMarksAt:function(e){e=clipPos(this,e);var t=[],n=getLine(this,e.line).markedSpans;if(n)for(var r=0;r<n.length;++r){var i=n[r];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=clipPos(this,e),t=clipPos(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var a=o.markedSpans;if(a)for(var s=0;s<a.length;s++){var l=a[s];!(null!=l.to&&i==e.line&&e.ch>=l.to||null==l.from&&i!=e.line||null!=l.from&&i==t.line&&l.from>=t.ch)&&(!n||n(l.marker))&&r.push(l.marker.parent||l.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;r<n.length;++r)null!=n[r].from&&e.push(n[r].marker)}),e},posFromIndex:function(e){var t,n=this.first,r=this.lineSeparator().length;return this.iter(function(i){var o=i.text.length+r;if(o>e)return t=e,!0;e-=o,++n}),clipPos(this,Pos(n,t))},indexFromPos:function(e){var t=(e=clipPos(this,e)).ch;if(e.line<this.first||e.ch<0)return 0;var n=this.lineSeparator().length;return this.iter(this.first,e.line,function(e){t+=e.text.length+n}),t},copy:function(e){var t=new Doc(getLines(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,n=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<n&&(n=e.to);var r=new Doc(getLines(this,t,n),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],copySharedMarkers(r,findSharedMarkers(this)),r},unlinkDoc:function(e){if(e instanceof CodeMirror&&(e=e.doc),this.linked){for(var t=0;t<this.linked.length;++t)if(this.linked[t].doc==e){this.linked.splice(t,1),e.unlinkDoc(this),detachSharedMarkers(findSharedMarkers(this));break}}if(e.history==this.history){var n=[e.id];linkedDocs(e,function(e){return n.push(e.id)},!0),e.history=new History(null),e.history.done=copyHistoryArray(this.history.done,n),e.history.undone=copyHistoryArray(this.history.undone,n)}},iterLinkedDocs:function(e){linkedDocs(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):G(e)},lineSeparator:function(){return this.lineSep||`
`},setDirection:docMethodOp(function(e){"rtl"!=e&&(e="ltr"),e!=this.direction&&(this.direction=e,this.iter(function(e){return e.order=null}),this.cm&&directionChanged(this.cm))})}),Doc.prototype.eachLine=Doc.prototype.iter;var ec=0;function onDrop(e){var t=this;if(clearDragCursor(t),!(signalDOMEvent(t,e)||eventInWidget(t.display,e))){e_preventDefault(e),f&&(ec=+new Date);var n=posFromMouse(t,e,!0),r=e.dataTransfer.files;if(!(!n||t.isReadOnly()))if(r&&r.length&&window.FileReader&&window.File)for(var i=r.length,o=Array(i),a=0,markAsReadAndPasteIfAllFilesAreRead=function(){++a==i&&operation(t,function(){var e={from:n=clipPos(t.doc,n),to:n,text:t.doc.splitLines(o.filter(function(e){return null!=e}).join(t.doc.lineSeparator())),origin:"paste"};makeChange(t.doc,e),setSelectionReplaceHistory(t.doc,simpleSelection(clipPos(t.doc,n),clipPos(t.doc,changeEnd(e))))})()},readTextFromFile=function(e,n){if(t.options.allowDropFileTypes&&-1==indexOf(t.options.allowDropFileTypes,e.type))return void markAsReadAndPasteIfAllFilesAreRead();var r=new FileReader;r.onerror=function(){return markAsReadAndPasteIfAllFilesAreRead()},r.onload=function(){var e=r.result;/[\x00-\x08\x0e-\x1f]{2}/.test(e)||(o[n]=e),markAsReadAndPasteIfAllFilesAreRead()},r.readAsText(e)},s=0;s<r.length;s++)readTextFromFile(r[s],s);else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1){t.state.draggingText(e),setTimeout(function(){return t.display.input.focus()},20);return}try{var l,c=e.dataTransfer.getData("Text");if(c){if(t.state.draggingText&&!t.state.draggingText.copy&&(l=t.listSelections()),setSelectionNoUndo(t.doc,simpleSelection(n,n)),l)for(var u=0;u<l.length;++u)replaceRange(t.doc,"",l[u].anchor,l[u].head,"drag");t.replaceSelection(c,"around","paste"),t.display.input.focus()}}catch{}}}}function onDragStart(e,t){if(f&&(!e.state.draggingText||new Date-ec<100))return void e_stop(t);if(!(signalDOMEvent(e,t)||eventInWidget(e.display,t))&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!b)){var n=elt("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",C&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),C&&n.parentNode.removeChild(n)}}function onDragOver(e,t){var n=posFromMouse(e,t);if(n){var r=document.createDocumentFragment();drawSelectionCursor(e,n,r),e.display.dragCursor||(e.display.dragCursor=elt("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),removeChildrenAndAdd(e.display.dragCursor,r)}}function clearDragCursor(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function forEachCodeMirror(e){if(document.getElementsByClassName){for(var t=document.getElementsByClassName("CodeMirror"),n=[],r=0;r<t.length;r++){var i=t[r].CodeMirror;i&&n.push(i)}n.length&&n[0].operation(function(){for(var t=0;t<n.length;t++)e(n[t])})}}var eu=!1;function ensureGlobalHandlers(){eu||(registerGlobalHandlers(),eu=!0)}function registerGlobalHandlers(){var e;on(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,forEachCodeMirror(onResize)},100))}),on(window,"blur",function(){return forEachCodeMirror(onBlur)})}function onResize(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var ed={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},eh=0;eh<10;eh++)ed[eh+48]=ed[eh+96]=String(eh);for(var ep=65;ep<=90;ep++)ed[ep]=String.fromCharCode(ep);for(var ef=1;ef<=12;ef++)ed[ef+111]=ed[ef+63235]="F"+ef;var eg={};function normalizeKeyName(e){var t,n,r,i,o=e.split(/-(?!$)/);e=o[o.length-1];for(var a=0;a<o.length-1;a++){var s=o[a];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else throw Error("Unrecognized modifier name: "+s)}return t&&(e="Alt-"+e),n&&(e="Ctrl-"+e),i&&(e="Cmd-"+e),r&&(e="Shift-"+e),e}function normalizeKeyMap(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if("..."==r){delete e[n];continue}for(var i=map(n.split(" "),normalizeKeyName),o=0;o<i.length;o++){var a=void 0,s=void 0;o==i.length-1?(s=i.join(" "),a=r):(s=i.slice(0,o+1).join(" "),a="...");var l=t[s];if(l){if(l!=a)throw Error("Inconsistent bindings for "+s)}else t[s]=a}delete e[n]}for(var c in t)e[c]=t[c];return e}function lookupKey(e,t,n,r){var i=(t=getKeyMap(t)).call?t.call(e,r):t[e];if(!1===i)return"nothing";if("..."===i)return"multi";if(null!=i&&n(i))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return lookupKey(e,t.fallthrough,n,r);for(var o=0;o<t.fallthrough.length;o++){var a=lookupKey(e,t.fallthrough[o],n,r);if(a)return a}}}function isModifierKey(e){var t="string"==typeof e?e:ed[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t}function addModifierNames(e,t,n){var r=e;return t.altKey&&"Alt"!=r&&(e="Alt-"+e),(D?t.metaKey:t.ctrlKey)&&"Ctrl"!=r&&(e="Ctrl-"+e),(D?t.ctrlKey:t.metaKey)&&"Mod"!=r&&(e="Cmd-"+e),!n&&t.shiftKey&&"Shift"!=r&&(e="Shift-"+e),e}function keyName(e,t){if(C&&34==e.keyCode&&e.char)return!1;var n=ed[e.keyCode];return null!=n&&!e.altGraphKey&&(3==e.keyCode&&e.code&&(n=e.code),addModifierNames(n,e,t))}function getKeyMap(e){return"string"==typeof e?eg[e]:e}function deleteNearSelection(e,t){for(var n=e.doc.sel.ranges,r=[],i=0;i<n.length;i++){for(var o=t(n[i]);r.length&&0>=cmp(o.from,lst(r).to);){var a=r.pop();if(0>cmp(a.from,o.from)){o.from=a.from;break}}r.push(o)}runInOp(e,function(){for(var t=r.length-1;t>=0;t--)replaceRange(e.doc,"",r[t].from,r[t].to,"+delete");ensureCursorVisible(e)})}function moveCharLogically(e,t,n){var r=skipExtendingChars(e.text,t+n,n);return r<0||r>e.text.length?null:r}function moveLogically(e,t,n){var r=moveCharLogically(e,t.ch,n);return null==r?null:new Pos(t.line,r,n<0?"after":"before")}function endOfLine(e,t,n,r,i){if(e){"rtl"==t.doc.direction&&(i=-i);var o=getOrder(n,t.doc.direction);if(o){var a,s=i<0?lst(o):o[0],l=i<0==(1==s.level)?"after":"before";if(s.level>0||"rtl"==t.doc.direction){var c=prepareMeasureForLine(t,n),u=measureCharPrepared(t,c,a=i<0?n.text.length-1:0).top;a=findFirst(function(e){return measureCharPrepared(t,c,e).top==u},i<0==(1==s.level)?s.from:s.to-1,a),"before"==l&&(a=moveCharLogically(n,a,1))}else a=i<0?s.to:s.from;return new Pos(r,a,l)}}return new Pos(r,i<0?n.text.length:0,i<0?"before":"after")}function moveVisually(e,t,n,r){var i,o=getOrder(t,e.doc.direction);if(!o)return moveLogically(t,n,r);n.ch>=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var a=getBidiPartAt(o,n.ch,n.sticky),s=o[a];if("ltr"==e.doc.direction&&s.level%2==0&&(r>0?s.to>n.ch:s.from<n.ch))return moveLogically(t,n,r);var mv=function(e,n){return moveCharLogically(t,e instanceof Pos?e.ch:e,n)},getWrappedLineExtent=function(n){return e.options.lineWrapping?(i=i||prepareMeasureForLine(e,t),wrappedLineExtentChar(e,t,i,n)):{begin:0,end:t.text.length}},l=getWrappedLineExtent("before"==n.sticky?mv(n,-1):n.ch);if("rtl"==e.doc.direction||1==s.level){var c=1==s.level==r<0,u=mv(n,c?1:-1);if(null!=u&&(c?u<=s.to&&u<=l.end:u>=s.from&&u>=l.begin))return new Pos(n.line,u,c?"before":"after")}var searchInVisualLine=function(e,t,r){for(var getRes=function(e,t){return t?new Pos(n.line,mv(e,1),"before"):new Pos(n.line,e,"after")};e>=0&&e<o.length;e+=t){var i=o[e],a=t>0==(1!=i.level),s=a?r.begin:mv(r.end,-1);if(i.from<=s&&s<i.to||(s=a?i.from:mv(i.to,-1),r.begin<=s&&s<r.end))return getRes(s,a)}},d=searchInVisualLine(a+r,r,l);if(d)return d;var h=r>0?l.end:mv(l.begin,-1);return null!=h&&!(r>0&&h==t.text.length)&&(d=searchInVisualLine(r>0?0:o.length-1,r,getWrappedLineExtent(h)))?d:null}eg.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},eg.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},eg.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},eg.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},eg.default=M?eg.macDefault:eg.pcDefault;var em={selectAll:selectAll,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),H)},killLine:function(e){return deleteNearSelection(e,function(t){if(!t.empty())return{from:t.from(),to:t.to()};var n=getLine(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line<e.lastLine()?{from:t.head,to:Pos(t.head.line+1,0)}:{from:t.head,to:Pos(t.head.line,n)}})},deleteLine:function(e){return deleteNearSelection(e,function(t){return{from:Pos(t.from().line,0),to:clipPos(e.doc,Pos(t.to().line+1,0))}})},delLineLeft:function(e){return deleteNearSelection(e,function(e){return{from:Pos(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(e){return deleteNearSelection(e,function(t){var n=e.charCoords(t.head,"div").top+5;return{from:e.coordsChar({left:0,top:n},"div"),to:t.from()}})},delWrappedLineRight:function(e){return deleteNearSelection(e,function(t){var n=e.charCoords(t.head,"div").top+5,r=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div");return{from:t.from(),to:r}})},undo:function(e){return e.undo()},redo:function(e){return e.redo()},undoSelection:function(e){return e.undoSelection()},redoSelection:function(e){return e.redoSelection()},goDocStart:function(e){return e.extendSelection(Pos(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(Pos(e.lastLine()))},goLineStart:function(e){return e.extendSelectionsBy(function(t){return lineStart(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(e){return e.extendSelectionsBy(function(t){return lineStartSmart(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function(e){return e.extendSelectionsBy(function(t){return lineEnd(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function(e){return e.extendSelectionsBy(function(t){var n=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:n},"div")},W)},goLineLeft:function(e){return e.extendSelectionsBy(function(t){var n=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:n},"div")},W)},goLineLeftSmart:function(e){return e.extendSelectionsBy(function(t){var n=e.cursorCoords(t.head,"div").top+5,r=e.coordsChar({left:0,top:n},"div");return r.ch<e.getLine(r.line).search(/\S/)?lineStartSmart(e,t.head):r},W)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"codepoint")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection("	")},insertSoftTab:function(e){for(var t=[],n=e.listSelections(),r=e.options.tabSize,i=0;i<n.length;i++){var o=n[i].from(),a=countColumn(e.getLine(o.line),o.ch,r);t.push(spaceStr(r-a%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(e){return runInOp(e,function(){for(var t=e.listSelections(),n=[],r=0;r<t.length;r++)if(t[r].empty()){var i=t[r].head,o=getLine(e.doc,i.line).text;if(o){if(i.ch==o.length&&(i=new Pos(i.line,i.ch-1)),i.ch>0)i=new Pos(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),Pos(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var a=getLine(e.doc,i.line-1).text;a&&(i=new Pos(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),Pos(i.line-1,a.length-1),i,"+transpose"))}}n.push(new Range(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){return runInOp(e,function(){for(var t=e.listSelections(),n=t.length-1;n>=0;n--)e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input");t=e.listSelections();for(var r=0;r<t.length;r++)e.indentLine(t[r].from().line,null,!0);ensureCursorVisible(e)})},openLine:function(e){return e.replaceSelection(`
`,"start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function lineStart(e,t){var n=getLine(e.doc,t),r=visualLine(n);return r!=n&&(t=lineNo(r)),endOfLine(!0,e,r,t,1)}function lineEnd(e,t){var n=getLine(e.doc,t),r=visualLineEnd(n);return r!=n&&(t=lineNo(r)),endOfLine(!0,e,n,t,-1)}function lineStartSmart(e,t){var n=lineStart(e,t.line),r=getLine(e.doc,n.line),i=getOrder(r,e.doc.direction);if(!i||0==i[0].level){var o=Math.max(n.ch,r.text.search(/\S/)),a=t.line==n.line&&t.ch<=o&&t.ch;return Pos(n.line,a?0:o,n.sticky)}return n}function doHandleBinding(e,t,n){if("string"==typeof t&&!(t=em[t]))return!1;e.display.input.ensurePolled();var r=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=N}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}function lookupKeyForEditor(e,t,n){for(var r=0;r<e.state.keyMaps.length;r++){var i=lookupKey(t,e.state.keyMaps[r],n,e);if(i)return i}return e.options.extraKeys&&lookupKey(t,e.options.extraKeys,n,e)||lookupKey(t,e.options.keyMap,n,e)}var ev=new Delayed;function dispatchKey(e,t,n,r){var i=e.state.keySeq;if(i){if(isModifierKey(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:ev.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),dispatchKeyInner(e,i+" "+t,n,r))return!0}return dispatchKeyInner(e,t,n,r)}function dispatchKeyInner(e,t,n,r){var i=lookupKeyForEditor(e,t,r);return"multi"==i&&(e.state.keySeq=t),"handled"==i&&signalLater(e,"keyHandled",e,t,n),("handled"==i||"multi"==i)&&(e_preventDefault(n),restartBlink(e)),!!i}function handleKeyBinding(e,t){var n=keyName(t,!0);return!!n&&(t.shiftKey&&!e.state.keySeq?dispatchKey(e,"Shift-"+n,t,function(t){return doHandleBinding(e,t,!0)})||dispatchKey(e,n,t,function(t){if("string"==typeof t?/^go[A-Z]/.test(t):t.motion)return doHandleBinding(e,t)}):dispatchKey(e,n,t,function(t){return doHandleBinding(e,t)}))}function handleCharBinding(e,t,n){return dispatchKey(e,"'"+n+"'",t,function(t){return doHandleBinding(e,t,!0)})}var ey=null;function onKeyDown(e){if((!e.target||e.target==this.display.input.getField())&&(this.curOp.focus=activeElt(),!signalDOMEvent(this,e))){f&&g<11&&27==e.keyCode&&(e.returnValue=!1);var t=e.keyCode;this.display.shift=16==t||e.shiftKey;var n=handleKeyBinding(this,e);C&&(ey=n?t:null,!n&&88==t&&!K&&(M?e.metaKey:e.ctrlKey)&&this.replaceSelection("",null,"cut")),c&&!M&&!n&&46==t&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),18!=t||/\bCodeMirror-crosshair\b/.test(this.display.lineDiv.className)||showCrossHair(this)}}function showCrossHair(e){var t=e.display.lineDiv;function up(e){18!=e.keyCode&&e.altKey||(rmClass(t,"CodeMirror-crosshair"),off(document,"keyup",up),off(document,"mouseover",up))}addClass(t,"CodeMirror-crosshair"),on(document,"keyup",up),on(document,"mouseover",up)}function onKeyUp(e){16==e.keyCode&&(this.doc.sel.shift=!1),signalDOMEvent(this,e)}function onKeyPress(e){if(!(e.target&&e.target!=this.display.input.getField()||eventInWidget(this.display,e)||signalDOMEvent(this,e)||e.ctrlKey&&!e.altKey)&&(!M||!e.metaKey)){var t=e.keyCode,n=e.charCode;if(C&&t==ey){ey=null,e_preventDefault(e);return}if(!(C&&(!e.which||e.which<10)&&handleKeyBinding(this,e))){var r=String.fromCharCode(null==n?t:n);"\b"==r||handleCharBinding(this,e,r)||this.display.input.onKeyPress(e)}}}var PastClick=function(e,t,n){this.time=e,this.pos=t,this.button=n};function clickRepeat(e,t){var n=+new Date;return a&&a.compare(n,e,t)?(o=a=null,"triple"):o&&o.compare(n,e,t)?(a=new PastClick(n,e,t),o=null,"double"):(o=new PastClick(n,e,t),a=null,"single")}function onMouseDown(e){var t=this.display;if(!(signalDOMEvent(this,e)||t.activeTouch&&t.input.supportsTouch())){if(t.input.ensurePolled(),t.shift=e.shiftKey,eventInWidget(t,e)){m||(t.scroller.draggable=!1,setTimeout(function(){return t.scroller.draggable=!0},100));return}if(!clickInGutter(this,e)){var n=posFromMouse(this,e),r=e_button(e),i=n?clickRepeat(n,r):"single";window.focus(),1==r&&this.state.selectingText&&this.state.selectingText(e),n&&handleMappedButton(this,r,n,i,e)||(1==r?n?leftButtonDown(this,n,i,e):e_target(e)==t.scroller&&e_preventDefault(e):2==r?(n&&extendSelection(this.doc,n),setTimeout(function(){return t.input.focus()},20)):3==r&&(A?this.display.input.onContextMenu(e):delayBlurEvent(this)))}}}function handleMappedButton(e,t,n,r,i){var o="Click";return"double"==r?o="Double"+o:"triple"==r&&(o="Triple"+o),dispatchKey(e,addModifierNames(o=(1==t?"Left":2==t?"Middle":"Right")+o,i),i,function(t){if("string"==typeof t&&(t=em[t]),!t)return!1;var r=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),r=t(e,n)!=N}finally{e.state.suppressEdits=!1}return r})}function configureMouse(e,t,n){var r=e.getOption("configureMouse"),i=r?r(e,t,n):{};return null==i.unit&&(i.unit=(T?n.shiftKey&&n.metaKey:n.altKey)?"rectangle":"single"==t?"char":"double"==t?"word":"line"),(null==i.extend||e.doc.extend)&&(i.extend=e.doc.extend||n.shiftKey),null==i.addNew&&(i.addNew=M?n.metaKey:n.ctrlKey),null==i.moveOnDrag&&(i.moveOnDrag=!(M?n.altKey:n.ctrlKey)),i}function leftButtonDown(e,t,n,r){f?setTimeout(bind(ensureFocus,e),0):e.curOp.focus=activeElt();var i,o=configureMouse(e,n,r),a=e.doc.sel;e.options.dragDrop&&U&&!e.isReadOnly()&&"single"==n&&(i=a.contains(t))>-1&&(0>cmp((i=a.ranges[i]).from(),t)||t.xRel>0)&&(cmp(i.to(),t)>0||t.xRel<0)?leftButtonStartDrag(e,r,t,o):leftButtonSelect(e,r,t,o)}function leftButtonStartDrag(e,t,n,r){var i=e.display,o=!1,a=operation(e,function(t){m&&(i.scroller.draggable=!1),e.state.draggingText=!1,e.state.delayingBlurEvent&&(e.hasFocus()?e.state.delayingBlurEvent=!1:delayBlurEvent(e)),off(i.wrapper.ownerDocument,"mouseup",a),off(i.wrapper.ownerDocument,"mousemove",mouseMove),off(i.scroller,"dragstart",dragStart),off(i.scroller,"drop",a),o||(e_preventDefault(t),r.addNew||extendSelection(e.doc,n,null,null,r.extend),m&&!b||f&&9==g?setTimeout(function(){i.wrapper.ownerDocument.body.focus({preventScroll:!0}),i.input.focus()},20):i.input.focus())}),mouseMove=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},dragStart=function(){return o=!0};m&&(i.scroller.draggable=!0),e.state.draggingText=a,a.copy=!r.moveOnDrag,on(i.wrapper.ownerDocument,"mouseup",a),on(i.wrapper.ownerDocument,"mousemove",mouseMove),on(i.scroller,"dragstart",dragStart),on(i.scroller,"drop",a),e.state.delayingBlurEvent=!0,setTimeout(function(){return i.input.focus()},20),i.scroller.dragDrop&&i.scroller.dragDrop()}function rangeForUnit(e,t,n){if("char"==n)return new Range(t,t);if("word"==n)return e.findWordAt(t);if("line"==n)return new Range(Pos(t.line,0),clipPos(e.doc,Pos(t.line+1,0)));var r=n(e,t);return new Range(r.from,r.to)}function leftButtonSelect(e,t,n,r){f&&delayBlurEvent(e);var i=e.display,o=e.doc;e_preventDefault(t);var a,s,l=o.sel,c=l.ranges;if(r.addNew&&!r.extend?a=(s=o.sel.contains(n))>-1?c[s]:new Range(n,n):(a=o.sel.primary(),s=o.sel.primIndex),"rectangle"==r.unit)r.addNew||(a=new Range(n,n)),n=posFromMouse(e,t,!0,!0),s=-1;else{var u=rangeForUnit(e,n,r.unit);a=r.extend?extendRange(a,u.anchor,u.head,r.extend):u}r.addNew?-1==s?(s=c.length,setSelection(o,normalizeSelection(e,c.concat([a]),s),{scroll:!1,origin:"*mouse"})):c.length>1&&c[s].empty()&&"char"==r.unit&&!r.extend?(setSelection(o,normalizeSelection(e,c.slice(0,s).concat(c.slice(s+1)),0),{scroll:!1,origin:"*mouse"}),l=o.sel):replaceOneSelection(o,s,a,I):(s=0,setSelection(o,new Selection([a],0),I),l=o.sel);var d=n;function extendTo(t){if(0!=cmp(d,t))if(d=t,"rectangle"==r.unit){for(var i=[],c=e.options.tabSize,u=countColumn(getLine(o,n.line).text,n.ch,c),h=countColumn(getLine(o,t.line).text,t.ch,c),f=Math.min(u,h),g=Math.max(u,h),m=Math.min(n.line,t.line),v=Math.min(e.lastLine(),Math.max(n.line,t.line));m<=v;m++){var y=getLine(o,m).text,C=findColumn(y,f,c);f==g?i.push(new Range(Pos(m,C),Pos(m,C))):y.length>C&&i.push(new Range(Pos(m,C),Pos(m,findColumn(y,g,c))))}i.length||i.push(new Range(n,n)),setSelection(o,normalizeSelection(e,l.ranges.slice(0,s).concat(i),s),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b,S=a,x=rangeForUnit(e,t,r.unit),w=S.anchor;cmp(x.anchor,w)>0?(b=x.head,w=minPos(S.from(),x.anchor)):(b=x.anchor,w=maxPos(S.to(),x.head));var L=l.ranges.slice(0);L[s]=bidiSimplify(e,new Range(clipPos(o,w),b)),setSelection(o,normalizeSelection(e,L,s),I)}}var h=i.wrapper.getBoundingClientRect(),g=0;function extend(t){var n=++g,a=posFromMouse(e,t,!0,"rectangle"==r.unit);if(a)if(0!=cmp(a,d)){e.curOp.focus=activeElt(),extendTo(a);var s=visibleLines(i,o);(a.line>=s.to||a.line<s.from)&&setTimeout(operation(e,function(){g==n&&extend(t)}),150)}else{var l=t.clientY<h.top?-20:20*(t.clientY>h.bottom);l&&setTimeout(operation(e,function(){g==n&&(i.scroller.scrollTop+=l,extend(t))}),50)}}function done(t){e.state.selectingText=!1,g=1/0,t&&(e_preventDefault(t),i.input.focus()),off(i.wrapper.ownerDocument,"mousemove",m),off(i.wrapper.ownerDocument,"mouseup",v),o.history.lastSelOrigin=null}var m=operation(e,function(e){0!==e.buttons&&e_button(e)?extend(e):done(e)}),v=operation(e,done);e.state.selectingText=v,on(i.wrapper.ownerDocument,"mousemove",m),on(i.wrapper.ownerDocument,"mouseup",v)}function bidiSimplify(e,t){var n,r=t.anchor,i=t.head,o=getLine(e.doc,r.line);if(0==cmp(r,i)&&r.sticky==i.sticky)return t;var a=getOrder(o);if(!a)return t;var s=getBidiPartAt(a,r.ch,r.sticky),l=a[s];if(l.from!=r.ch&&l.to!=r.ch)return t;var c=s+ +(l.from==r.ch!=(1!=l.level));if(0==c||c==a.length)return t;if(i.line!=r.line)n=(i.line-r.line)*("ltr"==e.doc.direction?1:-1)>0;else{var u=getBidiPartAt(a,i.ch,i.sticky),d=u-s||(i.ch-r.ch)*(1==l.level?-1:1);n=u==c-1||u==c?d<0:d>0}var h=a[c+(n?-1:0)],f=n==(1==h.level),g=f?h.from:h.to,m=f?"after":"before";return r.ch==g&&r.sticky==m?t:new Range(new Pos(r.line,g,m),i)}function gutterEvent(e,t,n,r){if(t.touches)i=t.touches[0].clientX,o=t.touches[0].clientY;else try{i=t.clientX,o=t.clientY}catch{return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&e_preventDefault(t);var i,o,a=e.display,s=a.lineDiv.getBoundingClientRect();if(o>s.bottom||!hasHandler(e,n))return e_defaultPrevented(t);o-=s.top-a.viewOffset;for(var l=0;l<e.display.gutterSpecs.length;++l){var c=a.gutters.childNodes[l];if(c&&c.getBoundingClientRect().right>=i){var u=lineAtHeight(e.doc,o),d=e.display.gutterSpecs[l];return signal(e,n,e,u,d.className,t),e_defaultPrevented(t)}}}function clickInGutter(e,t){return gutterEvent(e,t,"gutterClick",!0)}function onContextMenu(e,t){eventInWidget(e.display,t)||contextMenuInGutter(e,t)||!signalDOMEvent(e,t,"contextmenu")&&(A||e.display.input.onContextMenu(t))}function contextMenuInGutter(e,t){return!!hasHandler(e,"gutterContextMenu")&&gutterEvent(e,t,"gutterContextMenu",!1)}function themeChanged(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),clearCaches(e)}PastClick.prototype.compare=function(e,t,n){return this.time+400>e&&0==cmp(t,this.pos)&&n==this.button};var eC={toString:function(){return"CodeMirror.Init"}},eb={},eS={};function defineOptions(e){var t=e.optionHandlers;function option(n,r,i,o){e.defaults[n]=r,i&&(t[n]=o?function(e,t,n){n!=eC&&i(e,t,n)}:i)}e.defineOption=option,e.Init=eC,option("value","",function(e,t){return e.setValue(t)},!0),option("mode",null,function(e,t){e.doc.modeOption=t,loadMode(e)},!0),option("indentUnit",2,loadMode,!0),option("indentWithTabs",!1),option("smartIndent",!0),option("tabSize",4,function(e){resetModeState(e),clearCaches(e),regChange(e)},!0),option("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var n=[],r=e.doc.first;e.doc.iter(function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(-1==o)break;i=o+t.length,n.push(Pos(r,o))}r++});for(var i=n.length-1;i>=0;i--)replaceRange(e.doc,t,n[i],Pos(n[i].line,n[i].ch+t.length))}}),option("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(e,t,n){e.state.specialChars=RegExp(t.source+(t.test("	")?"":"|	"),"g"),n!=eC&&e.refresh()}),option("specialCharPlaceholder",defaultSpecialCharPlaceholder,function(e){return e.refresh()},!0),option("electricChars",!0),option("inputStyle",k?"contenteditable":"textarea",function(){throw Error("inputStyle can not (yet) be changed in a running editor")},!0),option("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),option("autocorrect",!1,function(e,t){return e.getInputField().autocorrect=t},!0),option("autocapitalize",!1,function(e,t){return e.getInputField().autocapitalize=t},!0),option("rtlMoveVisually",!O),option("wholeLineUpdateBefore",!0),option("theme","default",function(e){themeChanged(e),updateGutters(e)},!0),option("keyMap","default",function(e,t,n){var r=getKeyMap(t),i=n!=eC&&getKeyMap(n);i&&i.detach&&i.detach(e,r),r.attach&&r.attach(e,i||null)}),option("extraKeys",null),option("configureMouse",null),option("lineWrapping",!1,wrappingChanged,!0),option("gutters",[],function(e,t){e.display.gutterSpecs=getGutters(t,e.options.lineNumbers),updateGutters(e)},!0),option("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?compensateForHScroll(e.display)+"px":"0",e.refresh()},!0),option("coverGutterNextToScrollbar",!1,function(e){return updateScrollbars(e)},!0),option("scrollbarStyle","native",function(e){initScrollbars(e),updateScrollbars(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),option("lineNumbers",!1,function(e,t){e.display.gutterSpecs=getGutters(e.options.gutters,t),updateGutters(e)},!0),option("firstLineNumber",1,updateGutters,!0),option("lineNumberFormatter",function(e){return e},updateGutters,!0),option("showCursorWhenSelecting",!1,updateSelection,!0),option("resetSelectionOnContextMenu",!0),option("lineWiseCopyCut",!0),option("pasteLinesPerSelection",!0),option("selectionsMayTouch",!1),option("readOnly",!1,function(e,t){"nocursor"==t&&(onBlur(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)}),option("screenReaderLabel",null,function(e,t){t=""===t?null:t,e.display.input.screenReaderLabelChanged(t)}),option("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),option("dragDrop",!0,dragDropChanged),option("allowDropFileTypes",null),option("cursorBlinkRate",530),option("cursorScrollMargin",0),option("cursorHeight",1,updateSelection,!0),option("singleCursorHeightPerLine",!0,updateSelection,!0),option("workTime",100),option("workDelay",100),option("flattenSpans",!0,resetModeState,!0),option("addModeClass",!1,resetModeState,!0),option("pollInterval",100),option("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),option("historyEventDelay",1250),option("viewportMargin",10,function(e){return e.refresh()},!0),option("maxHighlightLength",1e4,resetModeState,!0),option("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),option("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),option("autofocus",null),option("direction","ltr",function(e,t){return e.doc.setDirection(t)},!0),option("phrases",null)}function dragDropChanged(e,t,n){if(!t!=!(n&&n!=eC)){var r=e.display.dragFunctions,i=t?on:off;i(e.display.scroller,"dragstart",r.start),i(e.display.scroller,"dragenter",r.enter),i(e.display.scroller,"dragover",r.over),i(e.display.scroller,"dragleave",r.leave),i(e.display.scroller,"drop",r.drop)}}function wrappingChanged(e){e.options.lineWrapping?(addClass(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(rmClass(e.display.wrapper,"CodeMirror-wrap"),findMaxLine(e)),estimateLineHeights(e),regChange(e),clearCaches(e),setTimeout(function(){return updateScrollbars(e)},100)}function CodeMirror(e,t){var n=this;if(!(this instanceof CodeMirror))return new CodeMirror(e,t);this.options=t=t?copyObj(t):{},copyObj(eb,t,!1);var r=t.value;"string"==typeof r?r=new Doc(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var i=new CodeMirror.inputStyles[t.inputStyle](this),o=this.display=new Display(e,r,i,t);for(var a in o.wrapper.CodeMirror=this,themeChanged(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),initScrollbars(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new Delayed,keySeq:null,specialChars:null},t.autofocus&&!k&&o.input.focus(),f&&g<11&&setTimeout(function(){return n.display.input.reset(!0)},20),registerEventHandlers(this),ensureGlobalHandlers(),startOperation(this),this.curOp.forceUpdate=!0,attachDoc(this,r),t.autofocus&&!k||this.hasFocus()?setTimeout(function(){n.hasFocus()&&!n.state.focused&&onFocus(n)},20):onBlur(this),eS)eS.hasOwnProperty(a)&&eS[a](this,t[a],eC);maybeUpdateLineNumberWidth(this),t.finishInit&&t.finishInit(this);for(var s=0;s<ex.length;++s)ex[s](this);endOperation(this),m&&t.lineWrapping&&"optimizelegibility"==getComputedStyle(o.lineDiv).textRendering&&(o.lineDiv.style.textRendering="auto")}function registerEventHandlers(e){var t=e.display;on(t.scroller,"mousedown",operation(e,onMouseDown)),f&&g<11?on(t.scroller,"dblclick",operation(e,function(t){if(!signalDOMEvent(e,t)){var n=posFromMouse(e,t);if(!(!n||clickInGutter(e,t)||eventInWidget(e.display,t))){e_preventDefault(t);var r=e.findWordAt(n);extendSelection(e.doc,r.anchor,r.head)}}})):on(t.scroller,"dblclick",function(t){return signalDOMEvent(e,t)||e_preventDefault(t)}),on(t.scroller,"contextmenu",function(t){return onContextMenu(e,t)}),on(t.input.getField(),"contextmenu",function(n){t.scroller.contains(n.target)||onContextMenu(e,n)});var n,r={end:0};function finishTouch(){t.activeTouch&&(n=setTimeout(function(){return t.activeTouch=null},1e3),(r=t.activeTouch).end=+new Date)}function isMouseLikeTouchEvent(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function farAway(e,t){if(null==t.left)return!0;var n=t.left-e.left,r=t.top-e.top;return n*n+r*r>400}on(t.scroller,"touchstart",function(i){if(!signalDOMEvent(e,i)&&!isMouseLikeTouchEvent(i)&&!clickInGutter(e,i)){t.input.ensurePolled(),clearTimeout(n);var o=+new Date;t.activeTouch={start:o,moved:!1,prev:o-r.end<=300?r:null},1==i.touches.length&&(t.activeTouch.left=i.touches[0].pageX,t.activeTouch.top=i.touches[0].pageY)}}),on(t.scroller,"touchmove",function(){t.activeTouch&&(t.activeTouch.moved=!0)}),on(t.scroller,"touchend",function(n){var r=t.activeTouch;if(r&&!eventInWidget(t,n)&&null!=r.left&&!r.moved&&new Date-r.start<300){var i,o=e.coordsChar(t.activeTouch,"page");i=!r.prev||farAway(r,r.prev)?new Range(o,o):!r.prev.prev||farAway(r,r.prev.prev)?e.findWordAt(o):new Range(Pos(o.line,0),clipPos(e.doc,Pos(o.line+1,0))),e.setSelection(i.anchor,i.head),e.focus(),e_preventDefault(n)}finishTouch()}),on(t.scroller,"touchcancel",finishTouch),on(t.scroller,"scroll",function(){t.scroller.clientHeight&&(updateScrollTop(e,t.scroller.scrollTop),setScrollLeft(e,t.scroller.scrollLeft,!0),signal(e,"scroll",e))}),on(t.scroller,"mousewheel",function(t){return onScrollWheel(e,t)}),on(t.scroller,"DOMMouseScroll",function(t){return onScrollWheel(e,t)}),on(t.wrapper,"scroll",function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0}),t.dragFunctions={enter:function(t){signalDOMEvent(e,t)||e_stop(t)},over:function(t){signalDOMEvent(e,t)||(onDragOver(e,t),e_stop(t))},start:function(t){return onDragStart(e,t)},drop:operation(e,onDrop),leave:function(t){signalDOMEvent(e,t)||clearDragCursor(e)}};var i=t.input.getField();on(i,"keyup",function(t){return onKeyUp.call(e,t)}),on(i,"keydown",operation(e,onKeyDown)),on(i,"keypress",operation(e,onKeyPress)),on(i,"focus",function(t){return onFocus(e,t)}),on(i,"blur",function(t){return onBlur(e,t)})}CodeMirror.defaults=eb,CodeMirror.optionHandlers=eS;var ex=[];function indentLine(e,t,n,r){var i,o=e.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?i=getContextBefore(e,t).state:n="prev");var a=e.options.tabSize,s=getLine(o,t),l=countColumn(s.text,null,a);s.stateAfter&&(s.stateAfter=null);var c,u=s.text.match(/^\s*/)[0];if(r||/\S/.test(s.text)){if("smart"==n&&((c=o.mode.indent(i,s.text.slice(u.length),s.text))==N||c>150)){if(!r)return;n="prev"}}else c=0,n="not";"prev"==n?c=t>o.first?countColumn(getLine(o,t-1).text,null,a):0:"add"==n?c=l+e.options.indentUnit:"subtract"==n?c=l-e.options.indentUnit:"number"==typeof n&&(c=l+n),c=Math.max(0,c);var d="",h=0;if(e.options.indentWithTabs)for(var f=Math.floor(c/a);f;--f)h+=a,d+="	";if(h<c&&(d+=spaceStr(c-h)),d!=u)return replaceRange(o,d,Pos(t,0),Pos(t,u.length),"+input"),s.stateAfter=null,!0;for(var g=0;g<o.sel.ranges.length;g++){var m=o.sel.ranges[g];if(m.head.line==t&&m.head.ch<u.length){var v=Pos(t,u.length);replaceOneSelection(o,g,new Range(v,v));break}}}CodeMirror.defineInitHook=function(e){return ex.push(e)};var ew=null;function applyTextInput(e,t,n,r,i){var o=e.doc;e.display.shift=!1,r||(r=o.sel);var a=new Date-200,s="paste"==i||e.state.pasteIncoming>a,l=G(t),c=null;if(s&&r.ranges.length>1)if(ew&&ew.text.join(`
`)==t){if(r.ranges.length%ew.text.length==0){c=[];for(var u=0;u<ew.text.length;u++)c.push(o.splitLines(ew.text[u]))}}else l.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(c=map(l,function(e){return[e]}));for(var d=e.curOp.updateInput,h=r.ranges.length-1;h>=0;h--){var f=r.ranges[h],g=f.from(),m=f.to();f.empty()&&(n&&n>0?g=Pos(g.line,g.ch-n):e.state.overwrite&&!s?m=Pos(m.line,Math.min(getLine(o,m.line).text.length,m.ch+lst(l).length)):s&&ew&&ew.lineWise&&ew.text.join(`
`)==l.join(`
`)&&(g=m=Pos(g.line,0)));var v={from:g,to:m,text:c?c[h%c.length]:l,origin:i||(s?"paste":e.state.cutIncoming>a?"cut":"+input")};makeChange(e.doc,v),signalLater(e,"inputRead",e,v)}t&&!s&&triggerElectric(e,t),ensureCursorVisible(e),e.curOp.updateInput<2&&(e.curOp.updateInput=d),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function handlePaste(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");if(n)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||runInOp(t,function(){return applyTextInput(t,n,0,null,"paste")}),!0}function triggerElectric(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(!(i.head.ch>100)&&(!r||n.ranges[r-1].head.line!=i.head.line)){var o=e.getModeAt(i.head),a=!1;if(o.electricChars){for(var s=0;s<o.electricChars.length;s++)if(t.indexOf(o.electricChars.charAt(s))>-1){a=indentLine(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(getLine(e.doc,i.head.line).text.slice(0,i.head.ch))&&(a=indentLine(e,i.head.line,"smart"));a&&signalLater(e,"electricInput",e,i.head.line)}}}function copyableRanges(e){for(var t=[],n=[],r=0;r<e.doc.sel.ranges.length;r++){var i=e.doc.sel.ranges[r].head.line,o={anchor:Pos(i,0),head:Pos(i+1,0)};n.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:n}}function disableBrowserMagic(e,t,n,r){e.setAttribute("autocorrect",n?"":"off"),e.setAttribute("autocapitalize",r?"":"off"),e.setAttribute("spellcheck",!!t)}function hiddenTextarea(){var e=elt("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=elt("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return m?e.style.width="1000px":e.setAttribute("wrap","off"),w&&(e.style.border="1px solid black"),disableBrowserMagic(e),t}function addEditorMethods(e){var t=e.optionHandlers,n=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,n){var r=this.options,i=r[e];(r[e]!=n||"mode"==e)&&(r[e]=n,t.hasOwnProperty(e)&&operation(this,t[e])(this,n,i),signal(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](getKeyMap(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;n<t.length;++n)if(t[n]==e||t[n].name==e)return t.splice(n,1),!0},addOverlay:methodOp(function(t,n){var r=t.token?t:e.getMode(this.options,t);if(r.startState)throw Error("Overlays may not be stateful.");insertSorted(this.state.overlays,{mode:r,modeSpec:t,opaque:n&&n.opaque,priority:n&&n.priority||0},function(e){return e.priority}),this.state.modeGen++,regChange(this)}),removeOverlay:methodOp(function(e){for(var t=this.state.overlays,n=0;n<t.length;++n){var r=t[n].modeSpec;if(r==e||"string"==typeof e&&r.name==e){t.splice(n,1),this.state.modeGen++,regChange(this);return}}}),indentLine:methodOp(function(e,t,n){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),isLine(this.doc,e)&&indentLine(this,e,t,n)}),indentSelection:methodOp(function(e){for(var t=this.doc.sel.ranges,n=-1,r=0;r<t.length;r++){var i=t[r];if(i.empty())i.head.line>n&&(indentLine(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&ensureCursorVisible(this));else{var o=i.from(),a=i.to(),s=Math.max(n,o.line);n=Math.min(this.lastLine(),a.line-!a.ch)+1;for(var l=s;l<n;++l)indentLine(this,l,e);var c=this.doc.sel.ranges;0==o.ch&&t.length==c.length&&c[r].from().ch>0&&replaceOneSelection(this.doc,r,new Range(o,c[r].to()),H)}}}),getTokenAt:function(e,t){return takeToken(this,e,t)},getLineTokens:function(e,t){return takeToken(this,Pos(e),t,!0)},getTokenTypeAt:function(e){e=clipPos(this.doc,e);var t,n=getLineStyles(this,getLine(this.doc,e.line)),r=0,i=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var a=r+i>>1;if((a?n[2*a-1]:0)>=o)i=a;else if(n[2*a+1]<o)r=a+1;else{t=n[2*a+2];break}}var s=t?t.indexOf("overlay "):-1;return s<0?t:0==s?null:t.slice(0,s-1)},getModeAt:function(t){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(t).state).mode:n},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var r=[];if(!n.hasOwnProperty(t))return r;var i=n[t],o=this.getModeAt(e);if("string"==typeof o[t])i[o[t]]&&r.push(i[o[t]]);else if(o[t])for(var a=0;a<o[t].length;a++){var s=i[o[t][a]];s&&r.push(s)}else o.helperType&&i[o.helperType]?r.push(i[o.helperType]):i[o.name]&&r.push(i[o.name]);for(var l=0;l<i._global.length;l++){var c=i._global[l];c.pred(o,this)&&-1==indexOf(r,c.val)&&r.push(c.val)}return r},getStateAfter:function(e,t){var n=this.doc;return getContextBefore(this,(e=clipLine(n,null==e?n.first+n.size-1:e))+1,t).state},cursorCoords:function(e,t){var n=this.doc.sel.primary();return cursorCoords(this,null==e?n.head:"object"==typeof e?clipPos(this.doc,e):e?n.from():n.to(),t||"page")},charCoords:function(e,t){return charCoords(this,clipPos(this.doc,e),t||"page")},coordsChar:function(e,t){return coordsChar(this,(e=fromCoordSystem(this,e,t||"page")).left,e.top)},lineAtHeight:function(e,t){return e=fromCoordSystem(this,{top:e,left:0},t||"page").top,lineAtHeight(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t,n){var r,i=!1;if("number"==typeof e){var o=this.doc.first+this.doc.size-1;e<this.doc.first?e=this.doc.first:e>o&&(e=o,i=!0),r=getLine(this.doc,e)}else r=e;return intoCoordSystem(this,r,{top:0,left:0},t||"page",n||i).top+(i?this.doc.height-heightAtLine(r):0)},defaultTextHeight:function(){return textHeight(this.display)},defaultCharWidth:function(){return charWidth(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var o=this.display,a=(e=cursorCoords(this,clipPos(this.doc,e))).bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==r)a=e.top;else if("above"==r||"near"==r){var l=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>l)&&e.top>t.offsetHeight?a=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=l&&(a=e.bottom),s+t.offsetWidth>c&&(s=c-t.offsetWidth)}t.style.top=a+"px",t.style.left=t.style.right="","right"==i?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),n&&scrollIntoView(this,{left:s,top:a,right:s+t.offsetWidth,bottom:a+t.offsetHeight})},triggerOnKeyDown:methodOp(onKeyDown),triggerOnKeyPress:methodOp(onKeyPress),triggerOnKeyUp:onKeyUp,triggerOnMouseDown:methodOp(onMouseDown),execCommand:function(e){if(em.hasOwnProperty(e))return em[e].call(null,this)},triggerElectric:methodOp(function(e){triggerElectric(this,e)}),findPosH:function(e,t,n,r){var i=1;t<0&&(i=-1,t=-t);for(var o=clipPos(this.doc,e),a=0;a<t&&!(o=findPosH(this.doc,o,i,n,r)).hitSide;++a);return o},moveH:methodOp(function(e,t){var n=this;this.extendSelectionsBy(function(r){return n.display.shift||n.doc.extend||r.empty()?findPosH(n.doc,r.head,e,t,n.options.rtlMoveVisually):e<0?r.from():r.to()},W)}),deleteH:methodOp(function(e,t){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):deleteNearSelection(this,function(n){var i=findPosH(r,n.head,e,t,!1);return e<0?{from:i,to:n.head}:{from:n.head,to:i}})}),findPosV:function(e,t,n,r){var i=1,o=r;t<0&&(i=-1,t=-t);for(var a=clipPos(this.doc,e),s=0;s<t;++s){var l=cursorCoords(this,a,"div");if(null==o?o=l.left:l.left=o,(a=findPosV(this,l,i,n)).hitSide)break}return a},moveV:methodOp(function(e,t){var n=this,r=this.doc,i=[],o=!this.display.shift&&!r.extend&&r.sel.somethingSelected();if(r.extendSelectionsBy(function(a){if(o)return e<0?a.from():a.to();var s=cursorCoords(n,a.head,"div");null!=a.goalColumn&&(s.left=a.goalColumn),i.push(s.left);var l=findPosV(n,s,e,t);return"page"==t&&a==r.sel.primary()&&addToScrollTop(n,charCoords(n,l,"div").top-s.top),l},W),i.length)for(var a=0;a<r.sel.ranges.length;a++)r.sel.ranges[a].goalColumn=i[a]}),findWordAt:function(e){var t=getLine(this.doc,e.line).text,n=e.ch,r=e.ch;if(t){var i=this.getHelper(e,"wordChars");("before"==e.sticky||r==t.length)&&n?--n:++r;for(var o=t.charAt(n),a=isWordChar(o,i)?function(e){return isWordChar(e,i)}:/\s/.test(o)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!isWordChar(e)};n>0&&a(t.charAt(n-1));)--n;for(;r<t.length&&a(t.charAt(r));)++r}return new Range(Pos(e.line,n),Pos(e.line,r))},toggleOverwrite:function(e){(null==e||e!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?addClass(this.display.cursorDiv,"CodeMirror-overwrite"):rmClass(this.display.cursorDiv,"CodeMirror-overwrite"),signal(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==activeElt()},isReadOnly:function(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:methodOp(function(e,t){scrollToCoords(this,e,t)}),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-scrollGap(this)-this.display.barHeight,width:e.scrollWidth-scrollGap(this)-this.display.barWidth,clientHeight:displayHeight(this),clientWidth:displayWidth(this)}},scrollIntoView:methodOp(function(e,t){null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:Pos(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line?scrollToRange(this,e):scrollToCoordsRange(this,e.from,e.to,e.margin)}),setSize:methodOp(function(e,t){var n=this,interpret=function(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e};null!=e&&(this.display.wrapper.style.width=interpret(e)),null!=t&&(this.display.wrapper.style.height=interpret(t)),this.options.lineWrapping&&clearLineMeasurementCache(this);var r=this.display.viewFrom;this.doc.iter(r,this.display.viewTo,function(e){if(e.widgets){for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){regLineChange(n,r,"widget");break}}++r}),this.curOp.forceUpdate=!0,signal(this,"refresh",this)}),operation:function(e){return runInOp(this,e)},startOperation:function(){return startOperation(this)},endOperation:function(){return endOperation(this)},refresh:methodOp(function(){var e=this.display.cachedTextHeight;regChange(this),this.curOp.forceUpdate=!0,clearCaches(this),scrollToCoords(this,this.doc.scrollLeft,this.doc.scrollTop),updateGutterSpace(this.display),(null==e||Math.abs(e-textHeight(this.display))>.5||this.options.lineWrapping)&&estimateLineHeights(this),signal(this,"refresh",this)}),swapDoc:methodOp(function(e){var t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),attachDoc(this,e),clearCaches(this),this.display.input.reset(),scrollToCoords(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,signalLater(this,"swapDoc",this,t),t}),phrase:function(e){var t=this.options.phrases;return t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:e},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}},eventMixin(e),e.registerHelper=function(t,r,i){n.hasOwnProperty(t)||(n[t]=e[t]={_global:[]}),n[t][r]=i},e.registerGlobalHelper=function(t,r,i,o){e.registerHelper(t,r,o),n[t]._global.push({pred:i,val:o})}}function findPosH(e,t,n,r,i){var o=t,a=n,s=getLine(e,t.line),l=i&&"rtl"==e.direction?-n:n;function findNextLine(){var n=t.line+l;return!(n<e.first)&&!(n>=e.first+e.size)&&(t=new Pos(n,t.ch,t.sticky),s=getLine(e,n))}function moveOnce(o){var a;if("codepoint"==r){var c=s.text.charCodeAt(t.ch+(n>0?0:-1));if(isNaN(c))a=null;else{var u=n>0?c>=55296&&c<56320:c>=56320&&c<57343;a=new Pos(t.line,Math.max(0,Math.min(s.text.length,t.ch+n*(u?2:1))),-n)}}else a=i?moveVisually(e.cm,s,t,n):moveLogically(s,t,n);if(null==a)if(!(!o&&findNextLine()))return!1;else t=endOfLine(i,e.cm,s,t.line,l);else t=a;return!0}if("char"==r||"codepoint"==r)moveOnce();else if("column"==r)moveOnce(!0);else if("word"==r||"group"==r)for(var c=null,u="group"==r,d=e.cm&&e.cm.getHelper(t,"wordChars"),h=!0;!(n<0)||moveOnce(!h);h=!1){var f=s.text.charAt(t.ch)||`
`,g=isWordChar(f,d)?"w":u&&`
`==f?"n":!u||/\s/.test(f)?null:"p";if(!u||h||g||(g="s"),c&&c!=g){n<0&&(n=1,moveOnce(),t.sticky="after");break}if(g&&(c=g),n>0&&!moveOnce(!h))break}var m=skipAtomic(e,t,o,a,!0);return equalCursorPos(o,m)&&(m.hitSide=!0),m}function findPosV(e,t,n,r){var i,o,a=e.doc,s=t.left;if("page"==r){var l=Math.max(Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight)-.5*textHeight(e.display),3);o=(n>0?t.bottom:t.top)+n*l}else"line"==r&&(o=n>0?t.bottom+3:t.top-3);for(;(i=coordsChar(e,s,o)).outside;){if(n<0?o<=0:o>=a.height){i.hitSide=!0;break}o+=5*n}return i}var ContentEditableInput=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Delayed,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function posToDOM(e,t){var n=findViewForLine(e,t.line);if(!n||n.hidden)return null;var r=getLine(e.doc,t.line),i=mapFromLineView(n,r,t.line),o=getOrder(r,e.doc.direction),a="left";o&&(a=getBidiPartAt(o,t.ch)%2?"right":"left");var s=nodeAndOffsetInLineMap(i.map,t.ch,a);return s.offset="right"==s.collapse?s.end:s.start,s}function isInGutter(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function badPos(e,t){return t&&(e.bad=!0),e}function domTextBetween(e,t,n,r,i){var o="",a=!1,s=e.doc.lineSeparator(),l=!1;function recognizeMarker(e){return function(t){return t.id==e}}function close(){a&&(o+=s,l&&(o+=s),a=l=!1)}function addText(e){e&&(close(),o+=e)}function walk(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(n)return void addText(n);var o,c=t.getAttribute("cm-marker");if(c){var u=e.findMarks(Pos(r,0),Pos(i+1,0),recognizeMarker(+c));u.length&&(o=u[0].find(0))&&addText(getBetween(e.doc,o.from,o.to).join(s));return}if("false"!=t.getAttribute("contenteditable")){var d=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(/^br$/i.test(t.nodeName)||0!=t.textContent.length){d&&close();for(var h=0;h<t.childNodes.length;h++)walk(t.childNodes[h]);/^(pre|p)$/i.test(t.nodeName)&&(l=!0),d&&(a=!0)}}}else 3==t.nodeType&&addText(t.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;walk(t),t!=n;)t=t.nextSibling,l=!1;return o}function domToPos(e,t,n){var r;if(t==e.display.lineDiv){if(!(r=e.display.lineDiv.childNodes[n]))return badPos(e.clipPos(Pos(e.display.viewTo-1)),!0);t=null,n=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==r)return locateNodeInLineView(o,t,n)}}function locateNodeInLineView(e,t,n){var r=e.text.firstChild,i=!1;if(!t||!contains(r,t))return badPos(Pos(lineNo(e.line),0),!0);if(t==r&&(i=!0,t=r.childNodes[n],n=0,!t)){var o=e.rest?lst(e.rest):e.line;return badPos(Pos(lineNo(o),o.text.length),i)}var a=3==t.nodeType?t:null,s=t;for(!a&&1==t.childNodes.length&&3==t.firstChild.nodeType&&(a=t.firstChild,n&&(n=a.nodeValue.length));s.parentNode!=r;)s=s.parentNode;var l=e.measure,c=l.maps;function find(t,n,r){for(var i=-1;i<(c?c.length:0);i++)for(var o=i<0?l.map:c[i],a=0;a<o.length;a+=3){var s=o[a+2];if(s==t||s==n){var u=lineNo(i<0?e.line:e.rest[i]),d=o[a]+r;return(r<0||s!=t)&&(d=o[a+ +!!r]),Pos(u,d)}}}var u=find(a,s,n);if(u)return badPos(u,i);for(var d=s.nextSibling,h=a?a.nodeValue.length-n:0;d;d=d.nextSibling){if(u=find(d,d.firstChild,0))return badPos(Pos(u.line,u.ch-h),i);h+=d.textContent.length}for(var f=s.previousSibling,g=n;f;f=f.previousSibling){if(u=find(f,f.firstChild,-1))return badPos(Pos(u.line,u.ch+g),i);g+=f.textContent.length}}ContentEditableInput.prototype.init=function(e){var t=this,n=this,r=n.cm,i=n.div=e.lineDiv;function belongsToInput(e){for(var t=e.target;t;t=t.parentNode){if(t==i)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(t.className))break}return!1}function onCopyCut(e){if(!(!belongsToInput(e)||signalDOMEvent(r,e))){if(r.somethingSelected())ew={lineWise:!1,text:r.getSelections()},"cut"==e.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var t=copyableRanges(r);ew={lineWise:!0,text:t.text},"cut"==e.type&&r.operation(function(){r.setSelections(t.ranges,0,H),r.replaceSelection("",null,"cut")})}if(e.clipboardData){e.clipboardData.clearData();var o=ew.text.join(`
`);if(e.clipboardData.setData("Text",o),e.clipboardData.getData("Text")==o)return void e.preventDefault()}var a=hiddenTextarea(),s=a.firstChild;r.display.lineSpace.insertBefore(a,r.display.lineSpace.firstChild),s.value=ew.text.join(`
`);var l=document.activeElement;selectInput(s),setTimeout(function(){r.display.lineSpace.removeChild(a),l.focus(),l==i&&n.showPrimarySelection()},50)}}i.contentEditable=!0,disableBrowserMagic(i,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize),on(i,"paste",function(e){!(!belongsToInput(e)||signalDOMEvent(r,e)||handlePaste(e,r))&&g<=11&&setTimeout(operation(r,function(){return t.updateFromDOM()}),20)}),on(i,"compositionstart",function(e){t.composing={data:e.data,done:!1}}),on(i,"compositionupdate",function(e){t.composing||(t.composing={data:e.data,done:!1})}),on(i,"compositionend",function(e){t.composing&&(e.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),on(i,"touchstart",function(){return n.forceCompositionEnd()}),on(i,"input",function(){t.composing||t.readFromDOMSoon()}),on(i,"copy",onCopyCut),on(i,"cut",onCopyCut)},ContentEditableInput.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},ContentEditableInput.prototype.prepareSelection=function(){var e=prepareSelection(this.cm,!1);return e.focus=document.activeElement==this.div,e},ContentEditableInput.prototype.showSelection=function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},ContentEditableInput.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},ContentEditableInput.prototype.showPrimarySelection=function(){var e=this.getSelection(),n=this.cm,r=n.doc.sel.primary(),i=r.from(),o=r.to();if(n.display.viewTo==n.display.viewFrom||i.line>=n.display.viewTo||o.line<n.display.viewFrom)return void e.removeAllRanges();var a=domToPos(n,e.anchorNode,e.anchorOffset),s=domToPos(n,e.focusNode,e.focusOffset);if(!a||a.bad||!s||s.bad||0!=cmp(minPos(a,s),i)||0!=cmp(maxPos(a,s),o)){var l=n.display.view,u=i.line>=n.display.viewFrom&&posToDOM(n,i)||{node:l[0].measure.map[2],offset:0},d=o.line<n.display.viewTo&&posToDOM(n,o);if(!d){var h=l[l.length-1].measure,f=h.maps?h.maps[h.maps.length-1]:h.map;d={node:f[f.length-1],offset:f[f.length-2]-f[f.length-3]}}if(!u||!d)return void e.removeAllRanges();var g,m=e.rangeCount&&e.getRangeAt(0);try{g=t(u.node,u.offset,d.offset,d.node)}catch{}g&&(!c&&n.state.focused?(e.collapse(u.node,u.offset),g.collapsed||(e.removeAllRanges(),e.addRange(g))):(e.removeAllRanges(),e.addRange(g)),m&&null==e.anchorNode?e.addRange(m):c&&this.startGracePeriod()),this.rememberSelection()}},ContentEditableInput.prototype.startGracePeriod=function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){return e.cm.curOp.selectionChanged=!0})},20)},ContentEditableInput.prototype.showMultipleSelections=function(e){removeChildrenAndAdd(this.cm.display.cursorDiv,e.cursors),removeChildrenAndAdd(this.cm.display.selectionDiv,e.selection)},ContentEditableInput.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},ContentEditableInput.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return contains(this.div,t)},ContentEditableInput.prototype.focus=function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()&&document.activeElement==this.div||this.showSelection(this.prepareSelection(),!0),this.div.focus())},ContentEditableInput.prototype.blur=function(){this.div.blur()},ContentEditableInput.prototype.getField=function(){return this.div},ContentEditableInput.prototype.supportsTouch=function(){return!0},ContentEditableInput.prototype.receivedFocus=function(){var e=this;function poll(){e.cm.state.focused&&(e.pollSelection(),e.polling.set(e.cm.options.pollInterval,poll))}this.selectionInEditor()?this.pollSelection():runInOp(this.cm,function(){return e.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,poll)},ContentEditableInput.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},ContentEditableInput.prototype.pollSelection=function(){if(null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var e=this.getSelection(),t=this.cm;if(L&&y&&this.cm.display.gutterSpecs.length&&isInGutter(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),this.focus();return}if(!this.composing){this.rememberSelection();var n=domToPos(t,e.anchorNode,e.anchorOffset),r=domToPos(t,e.focusNode,e.focusOffset);n&&r&&runInOp(t,function(){setSelection(t.doc,simpleSelection(n,r),H),(n.bad||r.bad)&&(t.curOp.selectionChanged=!0)})}}},ContentEditableInput.prototype.pollContent=function(){null!=this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e,t,n,r,i,o=this.cm,a=o.display,s=o.doc.sel.primary(),l=s.from(),c=s.to();if(0==l.ch&&l.line>o.firstLine()&&(l=Pos(l.line-1,getLine(o.doc,l.line-1).length)),c.ch==getLine(o.doc,c.line).text.length&&c.line<o.lastLine()&&(c=Pos(c.line+1,0)),l.line<a.viewFrom||c.line>a.viewTo-1)return!1;l.line==a.viewFrom||0==(e=findViewIndex(o,l.line))?(t=lineNo(a.view[0].line),n=a.view[0].node):(t=lineNo(a.view[e].line),n=a.view[e-1].node.nextSibling);var u=findViewIndex(o,c.line);if(u==a.view.length-1?(r=a.viewTo-1,i=a.lineDiv.lastChild):(r=lineNo(a.view[u+1].line)-1,i=a.view[u+1].node.previousSibling),!n)return!1;for(var d=o.doc.splitLines(domTextBetween(o,n,i,t,r)),h=getBetween(o.doc,Pos(t,0),Pos(r,getLine(o.doc,r).text.length));d.length>1&&h.length>1;)if(lst(d)==lst(h))d.pop(),h.pop(),r--;else if(d[0]==h[0])d.shift(),h.shift(),t++;else break;for(var f=0,g=0,m=d[0],v=h[0],y=Math.min(m.length,v.length);f<y&&m.charCodeAt(f)==v.charCodeAt(f);)++f;for(var C=lst(d),b=lst(h),S=Math.min(C.length-(1==d.length?f:0),b.length-(1==h.length?f:0));g<S&&C.charCodeAt(C.length-g-1)==b.charCodeAt(b.length-g-1);)++g;if(1==d.length&&1==h.length&&t==l.line)for(;f&&f>l.ch&&C.charCodeAt(C.length-g-1)==b.charCodeAt(b.length-g-1);)f--,g++;d[d.length-1]=C.slice(0,C.length-g).replace(/^\u200b+/,""),d[0]=d[0].slice(f).replace(/\u200b+$/,"");var x=Pos(t,f),w=Pos(r,h.length?lst(h).length-g:0);if(d.length>1||d[0]||cmp(x,w))return replaceRange(o.doc,d,x,w,"+input"),!0},ContentEditableInput.prototype.ensurePolled=function(){this.forceCompositionEnd()},ContentEditableInput.prototype.reset=function(){this.forceCompositionEnd()},ContentEditableInput.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},ContentEditableInput.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing)if(!e.composing.done)return;else e.composing=null;e.updateFromDOM()},80))},ContentEditableInput.prototype.updateFromDOM=function(){var e=this;(this.cm.isReadOnly()||!this.pollContent())&&runInOp(this.cm,function(){return regChange(e.cm)})},ContentEditableInput.prototype.setUneditable=function(e){e.contentEditable="false"},ContentEditableInput.prototype.onKeyPress=function(e){0!=e.charCode&&!this.composing&&(e.preventDefault(),this.cm.isReadOnly()||operation(this.cm,applyTextInput)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},ContentEditableInput.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},ContentEditableInput.prototype.onContextMenu=function(){},ContentEditableInput.prototype.resetPosition=function(){},ContentEditableInput.prototype.needsContentAttribute=!0;var TextareaInput=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new Delayed,this.hasSelection=!1,this.composing=null};function fromTextArea(e,t){if((t=t?copyObj(t):{}).value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var n,r=activeElt();t.autofocus=r==e||null!=e.getAttribute("autofocus")&&r==document.body}function save(){e.value=a.getValue()}if(e.form&&(on(e.form,"submit",save),!t.leaveSubmitMethodAlone)){var i=e.form;n=i.submit;try{var o=i.submit=function(){save(),i.submit=n,i.submit(),i.submit=o}}catch{}}t.finishInit=function(r){r.save=save,r.getTextArea=function(){return e},r.toTextArea=function(){r.toTextArea=isNaN,save(),e.parentNode.removeChild(r.getWrapperElement()),e.style.display="",e.form&&(off(e.form,"submit",save),t.leaveSubmitMethodAlone||"function"!=typeof e.form.submit||(e.form.submit=n))}},e.style.display="none";var a=CodeMirror(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return a}function addLegacyProps(e){e.off=off,e.on=on,e.wheelEventPixels=wheelEventPixels,e.Doc=Doc,e.splitLines=G,e.countColumn=countColumn,e.findColumn=findColumn,e.isWordChar=isWordCharBasic,e.Pass=N,e.signal=signal,e.Line=Line,e.changeEnd=changeEnd,e.scrollbarModel=er,e.Pos=Pos,e.cmpPos=cmp,e.modes=X,e.mimeModes=Y,e.resolveMode=resolveMode,e.getMode=getMode,e.modeExtensions=q,e.extendMode=extendMode,e.copyState=copyState,e.startState=startState,e.innerMode=innerMode,e.commands=em,e.keyMap=eg,e.keyName=keyName,e.isModifierKey=isModifierKey,e.lookupKey=lookupKey,e.normalizeKeyMap=normalizeKeyMap,e.StringStream=StringStream,e.SharedTextMarker=SharedTextMarker,e.TextMarker=TextMarker,e.LineWidget=LineWidget,e.e_preventDefault=e_preventDefault,e.e_stopPropagation=e_stopPropagation,e.e_stop=e_stop,e.addClass=addClass,e.contains=contains,e.rmClass=rmClass,e.keyNames=ed}TextareaInput.prototype.init=function(e){var t=this,n=this,r=this.cm;this.createField(e);var i=this.textarea;function prepareCopyCut(e){if(!signalDOMEvent(r,e)){if(r.somethingSelected())ew={lineWise:!1,text:r.getSelections()};else{if(!r.options.lineWiseCopyCut)return;var t=copyableRanges(r);ew={lineWise:!0,text:t.text},"cut"==e.type?r.setSelections(t.ranges,null,H):(n.prevInput="",i.value=t.text.join(`
`),selectInput(i))}"cut"==e.type&&(r.state.cutIncoming=+new Date)}}e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),w&&(i.style.width="0px"),on(i,"input",function(){f&&g>=9&&t.hasSelection&&(t.hasSelection=null),n.poll()}),on(i,"paste",function(e){signalDOMEvent(r,e)||handlePaste(e,r)||(r.state.pasteIncoming=+new Date,n.fastPoll())}),on(i,"cut",prepareCopyCut),on(i,"copy",prepareCopyCut),on(e.scroller,"paste",function(t){if(!(eventInWidget(e,t)||signalDOMEvent(r,t))){if(!i.dispatchEvent){r.state.pasteIncoming=+new Date,n.focus();return}var o=new Event("paste");o.clipboardData=t.clipboardData,i.dispatchEvent(o)}}),on(e.lineSpace,"selectstart",function(t){eventInWidget(e,t)||e_preventDefault(t)}),on(i,"compositionstart",function(){var e=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}}),on(i,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},TextareaInput.prototype.createField=function(e){this.wrapper=hiddenTextarea(),this.textarea=this.wrapper.firstChild},TextareaInput.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},TextareaInput.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc,r=prepareSelection(e);if(e.options.moveInputWithCursor){var i=cursorCoords(e,n.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+a.top-o.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+a.left-o.left))}return r},TextareaInput.prototype.showSelection=function(e){var t=this.cm.display;removeChildrenAndAdd(t.cursorDiv,e.cursors),removeChildrenAndAdd(t.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},TextareaInput.prototype.reset=function(e){if(!this.contextMenuPending&&!this.composing){var t=this.cm;if(t.somethingSelected()){this.prevInput="";var n=t.getSelection();this.textarea.value=n,t.state.focused&&selectInput(this.textarea),f&&g>=9&&(this.hasSelection=n)}else!e&&(this.prevInput=this.textarea.value="",f&&g>=9&&(this.hasSelection=null))}},TextareaInput.prototype.getField=function(){return this.textarea},TextareaInput.prototype.supportsTouch=function(){return!1},TextareaInput.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!k||activeElt()!=this.textarea))try{this.textarea.focus()}catch{}},TextareaInput.prototype.blur=function(){this.textarea.blur()},TextareaInput.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},TextareaInput.prototype.receivedFocus=function(){this.slowPoll()},TextareaInput.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},TextareaInput.prototype.fastPoll=function(){var e=!1,t=this;function p(){t.poll()||e?(t.pollingFast=!1,t.slowPoll()):(e=!0,t.polling.set(60,p))}t.pollingFast=!0,t.polling.set(20,p)},TextareaInput.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||_(n)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=n.value;if(i==r&&!t.somethingSelected())return!1;if(f&&g>=9&&this.hasSelection===i||M&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||r||(r="\u200B"),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var a=0,s=Math.min(r.length,i.length);a<s&&r.charCodeAt(a)==i.charCodeAt(a);)++a;return runInOp(t,function(){applyTextInput(t,i.slice(a),r.length-a,null,e.composing?"*compose":null),i.length>1e3||i.indexOf(`
`)>-1?n.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},TextareaInput.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},TextareaInput.prototype.onKeyPress=function(){f&&g>=9&&(this.hasSelection=null),this.fastPoll()},TextareaInput.prototype.onContextMenu=function(e){var t,n=this,r=n.cm,i=r.display,o=n.textarea;n.contextMenuPending&&n.contextMenuPending();var a=posFromMouse(r,e),s=i.scroller.scrollTop;if(a&&!C){r.options.resetSelectionOnContextMenu&&-1==r.doc.sel.contains(a)&&operation(r,setSelection)(r.doc,simpleSelection(a),H);var l=o.style.cssText,c=n.wrapper.style.cssText,u=n.wrapper.offsetParent.getBoundingClientRect();if(n.wrapper.style.cssText="position: static",o.style.cssText=`position: absolute; width: 30px; height: 30px;
      top: `+(e.clientY-u.top-5)+"px; left: "+(e.clientX-u.left-5)+`px;
      z-index: 1000; background: `+(f?"rgba(255, 255, 255, .05)":"transparent")+`;
      outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);`,m&&(t=window.scrollY),i.input.focus(),m&&window.scrollTo(null,t),i.input.reset(),r.somethingSelected()||(o.value=n.prevInput=" "),n.contextMenuPending=rehide,i.selForContextMenu=r.doc.sel,clearTimeout(i.detectingSelectAll),f&&g>=9&&prepareSelectAllHack(),A){e_stop(e);var mouseup=function(){off(window,"mouseup",mouseup),setTimeout(rehide,20)};on(window,"mouseup",mouseup)}else setTimeout(rehide,50)}function prepareSelectAllHack(){if(null!=o.selectionStart){var e=r.somethingSelected(),t="\u200B"+(e?o.value:"");o.value="\u21DA",o.value=t,n.prevInput=e?"":"\u200B",o.selectionStart=1,o.selectionEnd=t.length,i.selForContextMenu=r.doc.sel}}function rehide(){if(n.contextMenuPending==rehide&&(n.contextMenuPending=!1,n.wrapper.style.cssText=c,o.style.cssText=l,f&&g<9&&i.scrollbars.setScrollTop(i.scroller.scrollTop=s),null!=o.selectionStart)){(!f||f&&g<9)&&prepareSelectAllHack();var e=0,poll=function(){i.selForContextMenu==r.doc.sel&&0==o.selectionStart&&o.selectionEnd>0&&"\u200B"==n.prevInput?operation(r,selectAll)(r):e++<10?i.detectingSelectAll=setTimeout(poll,500):(i.selForContextMenu=null,i.input.reset())};i.detectingSelectAll=setTimeout(poll,200)}}},TextareaInput.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e,this.textarea.readOnly=!!e},TextareaInput.prototype.setUneditable=function(){},TextareaInput.prototype.needsContentAttribute=!1,defineOptions(CodeMirror),addEditorMethods(CodeMirror);var eL="iter insert remove copy getEditor constructor".split(" ");for(var ek in Doc.prototype)Doc.prototype.hasOwnProperty(ek)&&0>indexOf(eL,ek)&&(CodeMirror.prototype[ek]=function(e){return function(){return e.apply(this.doc,arguments)}}(Doc.prototype[ek]));return eventMixin(Doc),CodeMirror.inputStyles={textarea:TextareaInput,contenteditable:ContentEditableInput},CodeMirror.defineMode=function(e){CodeMirror.defaults.mode||"null"==e||(CodeMirror.defaults.mode=e),defineMode.apply(this,arguments)},CodeMirror.defineMIME=defineMIME,CodeMirror.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),CodeMirror.defineMIME("text/plain","null"),CodeMirror.defineExtension=function(e,t){CodeMirror.prototype[e]=t},CodeMirror.defineDocExtension=function(e,t){Doc.prototype[e]=t},CodeMirror.fromTextArea=fromTextArea,addLegacyProps(CodeMirror),CodeMirror.version="5.60.0",CodeMirror}()},0x148a6d2b4:(e,t,n)=>{"use strict";function _extends(){return(_extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(null,arguments)}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var r,i,o=(r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)});t.wN=t.xL=void 0;var a=n(0xbad225b5),s="u"<typeof window||void 0!==n.g&&!0===n.g.PREVENT_CODEMIRROR_RENDER;s||(i=n(0x2a32d92c));var l=function(){function Helper(){}return Helper.equals=function(e,t){var n=this,r=Object.keys,i=_typeof(e),o=_typeof(t);return e&&t&&"object"===i&&i===o?r(e).length===r(t).length&&r(e).every(function(r){return n.equals(e[r],t[r])}):e===t},Helper}(),c=function(){function Shared(e,t){this.editor=e,this.props=t}return Shared.prototype.delegateCursor=function(e,t,n){var r=this.editor.getDoc();n&&this.editor.focus(),t?r.setCursor(e):r.setCursor(e,null,{scroll:!1})},Shared.prototype.delegateScroll=function(e){this.editor.scrollTo(e.x,e.y)},Shared.prototype.delegateSelection=function(e,t){this.editor.getDoc().setSelections(e),t&&this.editor.focus()},Shared.prototype.apply=function(e){e&&e.selection&&e.selection.ranges&&this.delegateSelection(e.selection.ranges,e.selection.focus||!1),e&&e.cursor&&this.delegateCursor(e.cursor,e.autoScroll||!1,this.editor.getOption("autofocus")||!1),e&&e.scroll&&this.delegateScroll(e.scroll)},Shared.prototype.applyNext=function(e,t,n){e&&e.selection&&e.selection.ranges&&t&&t.selection&&t.selection.ranges&&!l.equals(e.selection.ranges,t.selection.ranges)&&this.delegateSelection(t.selection.ranges,t.selection.focus||!1),e&&e.cursor&&t&&t.cursor&&!l.equals(e.cursor,t.cursor)&&this.delegateCursor(n.cursor||t.cursor,t.autoScroll||!1,t.autoCursor||!1),e&&e.scroll&&t&&t.scroll&&!l.equals(e.scroll,t.scroll)&&this.delegateScroll(t.scroll)},Shared.prototype.applyUserDefined=function(e,t){t&&t.cursor&&this.delegateCursor(t.cursor,e.autoScroll||!1,this.editor.getOption("autofocus")||!1)},Shared.prototype.wire=function(e){var t=this;Object.keys(e||{}).filter(function(e){return/^on/.test(e)}).forEach(function(e){switch(e){case"onBlur":t.editor.on("blur",function(e,n){t.props.onBlur(t.editor,n)});break;case"onContextMenu":t.editor.on("contextmenu",function(e,n){t.props.onContextMenu(t.editor,n)});break;case"onCopy":t.editor.on("copy",function(e,n){t.props.onCopy(t.editor,n)});break;case"onCursor":t.editor.on("cursorActivity",function(e){t.props.onCursor(t.editor,t.editor.getDoc().getCursor())});break;case"onCursorActivity":t.editor.on("cursorActivity",function(e){t.props.onCursorActivity(t.editor)});break;case"onCut":t.editor.on("cut",function(e,n){t.props.onCut(t.editor,n)});break;case"onDblClick":t.editor.on("dblclick",function(e,n){t.props.onDblClick(t.editor,n)});break;case"onDragEnter":t.editor.on("dragenter",function(e,n){t.props.onDragEnter(t.editor,n)});break;case"onDragLeave":t.editor.on("dragleave",function(e,n){t.props.onDragLeave(t.editor,n)});break;case"onDragOver":t.editor.on("dragover",function(e,n){t.props.onDragOver(t.editor,n)});break;case"onDragStart":t.editor.on("dragstart",function(e,n){t.props.onDragStart(t.editor,n)});break;case"onDrop":t.editor.on("drop",function(e,n){t.props.onDrop(t.editor,n)});break;case"onFocus":t.editor.on("focus",function(e,n){t.props.onFocus(t.editor,n)});break;case"onGutterClick":t.editor.on("gutterClick",function(e,n,r,i){t.props.onGutterClick(t.editor,n,r,i)});break;case"onInputRead":t.editor.on("inputRead",function(e,n){t.props.onInputRead(t.editor,n)});break;case"onKeyDown":t.editor.on("keydown",function(e,n){t.props.onKeyDown(t.editor,n)});break;case"onKeyHandled":t.editor.on("keyHandled",function(e,n,r){t.props.onKeyHandled(t.editor,n,r)});break;case"onKeyPress":t.editor.on("keypress",function(e,n){t.props.onKeyPress(t.editor,n)});break;case"onKeyUp":t.editor.on("keyup",function(e,n){t.props.onKeyUp(t.editor,n)});break;case"onMouseDown":t.editor.on("mousedown",function(e,n){t.props.onMouseDown(t.editor,n)});break;case"onPaste":t.editor.on("paste",function(e,n){t.props.onPaste(t.editor,n)});break;case"onRenderLine":t.editor.on("renderLine",function(e,n,r){t.props.onRenderLine(t.editor,n,r)});break;case"onScroll":t.editor.on("scroll",function(e){t.props.onScroll(t.editor,t.editor.getScrollInfo())});break;case"onSelection":t.editor.on("beforeSelectionChange",function(e,n){t.props.onSelection(t.editor,n)});break;case"onTouchStart":t.editor.on("touchstart",function(e,n){t.props.onTouchStart(t.editor,n)});break;case"onUpdate":t.editor.on("update",function(e){t.props.onUpdate(t.editor)});break;case"onViewportChange":t.editor.on("viewportChange",function(e,n,r){t.props.onViewportChange(t.editor,n,r)})}})},Shared}();t.xL=function(e){function Controlled(t){var n=e.call(this,t)||this;return s||(n.applied=!1,n.appliedNext=!1,n.appliedUserDefined=!1,n.deferred=null,n.emulating=!1,n.hydrated=!1,n.initCb=function(){n.props.editorDidConfigure&&n.props.editorDidConfigure(n.editor)},n.mounted=!1),n}return o(Controlled,e),Controlled.prototype.hydrate=function(e){var t=this,n=e&&e.options?e.options:{},r=_extends({},i.defaults,this.editor.options,n);Object.keys(r).some(function(e){return t.editor.getOption(e)!==r[e]})&&Object.keys(r).forEach(function(e){n.hasOwnProperty(e)&&t.editor.getOption(e)!==r[e]&&(t.editor.setOption(e,r[e]),t.mirror.setOption(e,r[e]))}),this.hydrated||(this.deferred?this.resolveChange(e.value):this.initChange(e.value||"")),this.hydrated=!0},Controlled.prototype.initChange=function(e){this.emulating=!0;var t=this.editor.getDoc(),n=t.lastLine(),r=t.getLine(t.lastLine()).length;t.replaceRange(e||"",{line:0,ch:0},{line:n,ch:r}),this.mirror.setValue(e),t.clearHistory(),this.mirror.clearHistory(),this.emulating=!1},Controlled.prototype.resolveChange=function(e){this.emulating=!0;var t=this.editor.getDoc();if("undo"===this.deferred.origin?t.undo():"redo"===this.deferred.origin?t.redo():t.replaceRange(this.deferred.text,this.deferred.from,this.deferred.to,this.deferred.origin),e&&e!==t.getValue()){var n=t.getCursor();t.setValue(e),t.setCursor(n)}this.emulating=!1,this.deferred=null},Controlled.prototype.mirrorChange=function(e){var t=this.editor.getDoc();return"undo"===e.origin?(t.setHistory(this.mirror.getHistory()),this.mirror.undo()):"redo"===e.origin?(t.setHistory(this.mirror.getHistory()),this.mirror.redo()):this.mirror.replaceRange(e.text,e.from,e.to,e.origin),this.mirror.getValue()},Controlled.prototype.componentDidMount=function(){var e=this;!s&&(this.props.defineMode&&this.props.defineMode.name&&this.props.defineMode.fn&&i.defineMode(this.props.defineMode.name,this.props.defineMode.fn),this.editor=i(this.ref,this.props.options),this.shared=new c(this.editor,this.props),this.mirror=i(function(){},this.props.options),this.editor.on("electricInput",function(){e.mirror.setHistory(e.editor.getDoc().getHistory())}),this.editor.on("cursorActivity",function(){e.mirror.setCursor(e.editor.getDoc().getCursor())}),this.editor.on("beforeChange",function(t,n){if(!e.emulating){n.cancel(),e.deferred=n;var r=e.mirrorChange(e.deferred);e.props.onBeforeChange&&e.props.onBeforeChange(e.editor,e.deferred,r)}}),this.editor.on("change",function(t,n){e.mounted&&e.props.onChange&&e.props.onChange(e.editor,n,e.editor.getValue())}),this.hydrate(this.props),this.shared.apply(this.props),this.applied=!0,this.mounted=!0,this.shared.wire(this.props),this.editor.getOption("autofocus")&&this.editor.focus(),this.props.editorDidMount&&this.props.editorDidMount(this.editor,this.editor.getValue(),this.initCb))},Controlled.prototype.componentDidUpdate=function(e){if(!s){var t={cursor:null};this.props.value!==e.value&&(this.hydrated=!1),this.props.autoCursor||void 0===this.props.autoCursor||(t.cursor=this.editor.getDoc().getCursor()),this.hydrate(this.props),this.appliedNext||(this.shared.applyNext(e,this.props,t),this.appliedNext=!0),this.shared.applyUserDefined(e,t),this.appliedUserDefined=!0}},Controlled.prototype.componentWillUnmount=function(){s||(this.props.editorWillUnmount&&this.props.editorWillUnmount(i),this.hydrated=!1)},Controlled.prototype.shouldComponentUpdate=function(e,t){return!s},Controlled.prototype.render=function(){var e=this;if(s)return null;var t=this.props.className?"react-codemirror2 ".concat(this.props.className):"react-codemirror2";return a.createElement("div",{className:t,ref:function(t){return e.ref=t}})},Controlled}(a.Component),t.wN=function(e){function UnControlled(t){var n=e.call(this,t)||this;return s||(n.applied=!1,n.appliedUserDefined=!1,n.continueChange=!1,n.detached=!1,n.hydrated=!1,n.initCb=function(){n.props.editorDidConfigure&&n.props.editorDidConfigure(n.editor)},n.mounted=!1,n.onBeforeChangeCb=function(){n.continueChange=!0}),n}return o(UnControlled,e),UnControlled.prototype.hydrate=function(e){var t=this,n=e&&e.options?e.options:{},r=_extends({},i.defaults,this.editor.options,n);if(Object.keys(r).some(function(e){return t.editor.getOption(e)!==r[e]})&&Object.keys(r).forEach(function(e){n.hasOwnProperty(e)&&t.editor.getOption(e)!==r[e]&&t.editor.setOption(e,r[e])}),!this.hydrated){var o=this.editor.getDoc(),a=o.lastLine(),s=o.getLine(o.lastLine()).length;o.replaceRange(e.value||"",{line:0,ch:0},{line:a,ch:s})}this.hydrated=!0},UnControlled.prototype.componentDidMount=function(){var e=this;!s&&(this.detached=!0===this.props.detach,this.props.defineMode&&this.props.defineMode.name&&this.props.defineMode.fn&&i.defineMode(this.props.defineMode.name,this.props.defineMode.fn),this.editor=i(this.ref,this.props.options),this.shared=new c(this.editor,this.props),this.editor.on("beforeChange",function(t,n){e.props.onBeforeChange&&e.props.onBeforeChange(e.editor,n,e.editor.getValue(),e.onBeforeChangeCb)}),this.editor.on("change",function(t,n){e.mounted&&e.props.onChange&&(e.props.onBeforeChange?e.continueChange&&e.props.onChange(e.editor,n,e.editor.getValue()):e.props.onChange(e.editor,n,e.editor.getValue()))}),this.hydrate(this.props),this.shared.apply(this.props),this.applied=!0,this.mounted=!0,this.shared.wire(this.props),this.editor.getDoc().clearHistory(),this.props.editorDidMount&&this.props.editorDidMount(this.editor,this.editor.getValue(),this.initCb))},UnControlled.prototype.componentDidUpdate=function(e){if(this.detached&&!1===this.props.detach&&(this.detached=!1,e.editorDidAttach&&e.editorDidAttach(this.editor)),!this.detached&&!0===this.props.detach&&(this.detached=!0,e.editorDidDetach&&e.editorDidDetach(this.editor)),!s&&!this.detached){var t={cursor:null};this.props.value!==e.value&&(this.hydrated=!1,this.applied=!1,this.appliedUserDefined=!1),e.autoCursor||void 0===e.autoCursor||(t.cursor=this.editor.getDoc().getCursor()),this.hydrate(this.props),this.applied||(this.shared.apply(e),this.applied=!0),this.appliedUserDefined||(this.shared.applyUserDefined(e,t),this.appliedUserDefined=!0)}},UnControlled.prototype.componentWillUnmount=function(){s||(this.props.editorWillUnmount&&this.props.editorWillUnmount(i),this.hydrated=!1)},UnControlled.prototype.shouldComponentUpdate=function(e,t){var n=!0;return s&&(n=!1),this.detached&&e.detach&&(n=!1),n},UnControlled.prototype.render=function(){var e=this;if(s)return null;var t=this.props.className?"react-codemirror2 ".concat(this.props.className):"react-codemirror2";return a.createElement("div",{className:t,ref:function(t){return e.ref=t}})},UnControlled}(a.Component)}}]);
//# sourceMappingURL=https://slack.com/source-maps/bv1-13/gantry-v2-async-vendors-node_modules_react-codemirror2_index_js.984ed727973e50501e1b.min.js.mapØA
—Eoúô