4 lines
95 KiB
JavaScript
4 lines
95 KiB
JavaScript
window.CodeMirror=function(){"use strict";function w(a,c){if(!(this instanceof w))return new w(a,c);this.options=c=c||{};for(var d in Mc)!c.hasOwnProperty(d)&&Mc.hasOwnProperty(d)&&(c[d]=Mc[d]);I(c);var e="string"==typeof c.value?0:c.value.first,f=this.display=x(a,e);f.wrapper.CodeMirror=this,F(this),c.autofocus&&!o&&Db(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,draggingText:!1,highlight:new De},D(this),c.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");var g=c.value;"string"==typeof g&&(g=new Rd(c.value,c.mode)),vb(this,Vd)(this,g),b&&setTimeout(Ne(Cb,this,!0),20),Fb(this);var h;try{h=document.activeElement==f.input}catch(i){}h||c.autofocus&&!o?setTimeout(Ne(_b,this),20):ac(this),vb(this,function(){for(var a in Lc)Lc.propertyIsEnumerable(a)&&Lc[a](this,c[a],Oc);for(var b=0;b<Sc.length;++b)Sc[b](this)})()}function x(a,b){var d={},f=d.input=Se("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none;");e?f.style.width="1000px":f.setAttribute("wrap","off"),f.setAttribute("autocorrect","off"),f.setAttribute("autocapitalize","off"),d.inputDiv=Se("div",[f],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),d.scrollbarH=Se("div",[Se("div",null,null,"height: 1px")],"CodeMirror-hscrollbar"),d.scrollbarV=Se("div",[Se("div",null,null,"width: 1px")],"CodeMirror-vscrollbar"),d.scrollbarFiller=Se("div",null,"CodeMirror-scrollbar-filler"),d.lineDiv=Se("div"),d.selectionDiv=Se("div",null,null,"position: relative; z-index: 1"),d.cursor=Se("div","\xa0","CodeMirror-cursor"),d.otherCursor=Se("div","\xa0","CodeMirror-cursor CodeMirror-secondarycursor"),d.measure=Se("div",null,"CodeMirror-measure"),d.lineSpace=Se("div",[d.measure,d.selectionDiv,d.lineDiv,d.cursor,d.otherCursor],null,"position: relative; outline: none"),d.mover=Se("div",[Se("div",[d.lineSpace],"CodeMirror-lines")],null,"position: relative"),d.sizer=Se("div",[d.mover],"CodeMirror-sizer"),d.heightForcer=Se("div","\xa0",null,"position: absolute; height: "+Be+"px"),d.gutters=Se("div",null,"CodeMirror-gutters"),d.lineGutter=null;var g=Se("div",[d.sizer,d.heightForcer,d.gutters],null,"position: relative; min-height: 100%");return d.scroller=Se("div",[g],"CodeMirror-scroll"),d.scroller.setAttribute("tabIndex","-1"),d.wrapper=Se("div",[d.inputDiv,d.scrollbarH,d.scrollbarV,d.scrollbarFiller,d.scroller],"CodeMirror"),c&&(d.gutters.style.zIndex=-1,d.scroller.style.paddingRight=0),a.appendChild?a.appendChild(d.wrapper):a(d.wrapper),n&&(f.style.width="0px"),e||(d.scroller.draggable=!0),j?(d.inputDiv.style.height="1px",d.inputDiv.style.position="absolute"):c&&(d.scrollbarH.style.minWidth=d.scrollbarV.style.minWidth="18px"),d.viewOffset=d.lastSizeC=0,d.showingFrom=d.showingTo=b,d.lineNumWidth=d.lineNumInnerWidth=d.lineNumChars=null,d.prevInput="",d.alignWidgets=!1,d.pollingFast=!1,d.poll=new De,d.draggingText=!1,d.cachedCharWidth=d.cachedTextHeight=null,d.measureLineCache=[],d.measureLineCachePos=0,d.inaccurateSelection=!1,d.maxLine=null,d.maxLineLength=0,d.maxLineChanged=!1,d.wheelDX=d.wheelDY=d.wheelStartX=d.wheelStartY=null,d}function y(a){a.doc.mode=w.getMode(a.options,a.doc.modeOption),a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null),a.styles&&(a.styles=null)}),a.doc.frontier=a.doc.first,_(a,100),a.state.modeGen++,a.curOp&&yb(a)}function z(a){a.options.lineWrapping?(a.display.wrapper.className+=" CodeMirror-wrap",a.display.sizer.style.minWidth=""):(a.display.wrapper.className=a.display.wrapper.className.replace(" CodeMirror-wrap",""),H(a)),B(a),yb(a),ib(a),setTimeout(function(){J(a.display,a.doc.height)},100)}function A(a){var b=qb(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/rb(a.display)-3);return function(e){return qd(a.doc,e)?0:c?(Math.ceil(e.text.length/d)||1)*b:b}}function B(a){var b=a.doc,c=A(a);b.iter(function(a){var b=c(a);b!=a.height&&Zd(a,b)})}function C(a){var b=Wc[a.options.keyMap].style;a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-keymap-\S+/g,"")+(b?" cm-keymap-"+b:"")}function D(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-"),ib(a)}function E(a){F(a),yb(a)}function F(a){var b=a.display.gutters,c=a.options.gutters;Te(b);for(var d=0;d<c.length;++d){var e=c[d],f=b.appendChild(Se("div",null,"CodeMirror-gutter "+e));"CodeMirror-linenumbers"==e&&(a.display.lineGutter=f,f.style.width=(a.display.lineNumWidth||1)+"px")}b.style.display=d?"":"none"}function G(a,b){if(0==b.height)return 0;for(var d,c=b.text.length,e=b;d=nd(e);){var f=d.find();e=Wd(a,f.from.line),c+=f.from.ch-f.to.ch}for(e=b;d=od(e);){var f=d.find();c-=e.text.length-f.from.ch,e=Wd(a,f.to.line),c+=e.text.length-f.to.ch}return c}function H(a){var b=a.display,c=a.doc;b.maxLine=Wd(c,c.first),b.maxLineLength=G(c,b.maxLine),b.maxLineChanged=!0,c.iter(function(a){var d=G(c,a);d>b.maxLineLength&&(b.maxLineLength=d,b.maxLine=a)})}function I(a){for(var b=!1,c=0;c<a.gutters.length;++c)"CodeMirror-linenumbers"==a.gutters[c]&&(a.lineNumbers?b=!0:a.gutters.splice(c--,1));!b&&a.lineNumbers&&a.gutters.push("CodeMirror-linenumbers")}function J(a,b){var c=b+2*db(a);a.sizer.style.minHeight=a.heightForcer.style.top=c+"px";var d=Math.max(c,a.scroller.scrollHeight),e=a.scroller.scrollWidth>a.scroller.clientWidth,f=d>a.scroller.clientHeight;f?(a.scrollbarV.style.display="block",a.scrollbarV.style.bottom=e?$e(a.measure)+"px":"0",a.scrollbarV.firstChild.style.height=d-a.scroller.clientHeight+a.scrollbarV.clientHeight+"px"):a.scrollbarV.style.display="",e?(a.scrollbarH.style.display="block",a.scrollbarH.style.right=f?$e(a.measure)+"px":"0",a.scrollbarH.firstChild.style.width=a.scroller.scrollWidth-a.scroller.clientWidth+a.scrollbarH.clientWidth+"px"):a.scrollbarH.style.display="",e&&f?(a.scrollbarFiller.style.display="block",a.scrollbarFiller.style.height=a.scrollbarFiller.style.width=$e(a.measure)+"px"):a.scrollbarFiller.style.display="",k&&0===$e(a.measure)&&(a.scrollbarV.style.minWidth=a.scrollbarH.style.minHeight=l?"18px":"12px")}function K(a,b,c){var d=a.scroller.scrollTop,e=a.wrapper.clientHeight;"number"==typeof c?d=c:c&&(d=c.top,e=c.bottom-c.top),d=Math.floor(d-db(a));var f=Math.ceil(d+e);return{from:_d(b,d),to:_d(b,f)}}function L(a){var b=a.display;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var c=O(b)-b.scroller.scrollLeft+a.doc.scrollLeft,d=b.gutters.offsetWidth,e=c+"px",f=b.lineDiv.firstChild;f;f=f.nextSibling)if(f.alignable)for(var g=0,h=f.alignable;g<h.length;++g)h[g].style.left=e;a.options.fixedGutter&&(b.gutters.style.left=c+d+"px")}}function M(a){if(!a.options.lineNumbers)return!1;var b=a.doc,c=N(a.options,b.first+b.size-1),d=a.display;if(c.length!=d.lineNumChars){var e=d.measure.appendChild(Se("div",[Se("div",c)],"CodeMirror-linenumber CodeMirror-gutter-elt")),f=e.firstChild.offsetWidth,g=e.offsetWidth-f;return d.lineGutter.style.width="",d.lineNumInnerWidth=Math.max(f,d.lineGutter.offsetWidth-g),d.lineNumWidth=d.lineNumInnerWidth+g,d.lineNumChars=d.lineNumInnerWidth?c.length:-1,d.lineGutter.style.width=d.lineNumWidth+"px",!0}return!1}function N(a,b){return String(a.lineNumberFormatter(b+a.firstLineNumber))}function O(a){return We(a.scroller).left-We(a.sizer).left}function P(a,b,c){var d=a.display.showingFrom,e=a.display.showingTo,f=Q(a,b,c);return f&&(ye(a,"update",a),(a.display.showingFrom!=d||a.display.showingTo!=e)&&ye(a,"viewportChange",a,a.display.showingFrom,a.display.showingTo)),X(a),J(a.display,a.doc.height),f}function Q(a,b,d){var e=a.display,f=a.doc;if(!e.wrapper.clientWidth)return e.showingFrom=e.showingTo=f.first,e.viewOffset=0,void 0;var g=K(e,f,d);if(!(0==b.length&&g.from>e.showingFrom&&g.to<e.showingTo)){M(a)&&(b=[{from:f.first,to:f.first+f.size}]);var h=e.sizer.style.marginLeft=e.gutters.offsetWidth+"px";e.scrollbarH.style.left=a.options.fixedGutter?h:"0";var i=1/0;if(a.options.lineNumbers)for(var j=0;j<b.length;++j)if(b[j].diff){i=b[j].from;break}var k=f.first+f.size,l=Math.max(g.from-a.options.viewportMargin,f.first),m=Math.min(k,g.to+a.options.viewportMargin);if(e.showingFrom<l&&l-e.showingFrom<20&&(l=Math.max(f.first,e.showingFrom)),e.showingTo>m&&e.showingTo-m<20&&(m=Math.min(k,e.showingTo)),v)for(l=$d(pd(f,Wd(f,l)));k>m&&qd(f,Wd(f,m));)++m;var n=[{from:Math.max(e.showingFrom,f.first),to:Math.min(e.showingTo,k)}];if(n=n[0].from>=n[0].to?[]:S(n,b),v)for(var j=0;j<n.length;++j)for(var p,o=n[j];p=od(Wd(f,o.to-1));){var q=p.find().from.line;if(!(q>o.from)){n.splice(j--,1);break}o.to=q}for(var r=0,j=0;j<n.length;++j){var o=n[j];o.from<l&&(o.from=l),o.to>m&&(o.to=m),o.from>=o.to?n.splice(j--,1):r+=o.to-o.from}if(r==m-l&&l==e.showingFrom&&m==e.showingTo)return R(a),void 0;n.sort(function(a,b){return a.from-b.from});var s=document.activeElement;.7*(m-l)>r&&(e.lineDiv.style.display="none"),U(a,l,m,n,i),e.lineDiv.style.display="",document.activeElement!=s&&s.offsetHeight&&s.focus();var t=l!=e.showingFrom||m!=e.showingTo||e.lastSizeC!=e.wrapper.clientHeight;t&&(e.lastSizeC=e.wrapper.clientHeight),e.showingFrom=l,e.showingTo=m,_(a,100);for(var x,u=e.lineDiv.offsetTop,w=e.lineDiv.firstChild;w;w=w.nextSibling)if(w.lineObj){if(c){var y=w.offsetTop+w.offsetHeight;x=y-u,u=y}else{var z=We(w);x=z.bottom-z.top}var A=w.lineObj.height-x;if(2>x&&(x=qb(e)),A>.001||-.001>A){Zd(w.lineObj,x);var B=w.lineObj.widgets;if(B)for(var j=0;j<B.length;++j)B[j].height=B[j].node.offsetHeight}}return R(a),K(e,f,d).to>m&&Q(a,[],d),!0}}function R(a){var b=a.display.viewOffset=ae(a,Wd(a.doc,a.display.showingFrom));a.display.mover.style.top=b+"px"}function S(a,b){for(var c=0,d=b.length||0;d>c;++c){for(var e=b[c],f=[],g=e.diff||0,h=0,i=a.length;i>h;++h){var j=a[h];e.to<=j.from&&e.diff?f.push({from:j.from+g,to:j.to+g}):e.to<=j.from||e.from>=j.to?f.push(j):(e.from>j.from&&f.push({from:j.from,to:e.from}),e.to<j.to&&f.push({from:e.to+g,to:j.to+g}))}a=f}return a}function T(a){for(var b=a.display,c={},d={},e=b.gutters.firstChild,f=0;e;e=e.nextSibling,++f)c[a.options.gutters[f]]=e.offsetLeft,d[a.options.gutters[f]]=e.offsetWidth;return{fixedPos:O(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function U(a,b,c,d,f){function l(b){var c=b.nextSibling;return e&&p&&a.display.currentWheelTarget==b?(b.style.display="none",b.lineObj=null):b.parentNode.removeChild(b),c}var g=T(a),h=a.display,i=a.options.lineNumbers;d.length||e&&a.display.currentWheelTarget||Te(h.lineDiv);var j=h.lineDiv,k=j.firstChild,m=d.shift(),n=b;for(a.doc.iter(b,c,function(b){if(m&&m.to==n&&(m=d.shift()),qd(a.doc,b)){if(0!=b.height&&Zd(b,0),b.widgets&&k.previousSibling)for(var c=0;c<b.widgets.length;++c)if(b.widgets[c].showIfHidden){var e=k.previousSibling;if(/pre/i.test(e.nodeName)){var h=Se("div",null,null,"position: relative");e.parentNode.replaceChild(h,e),h.appendChild(e),e=h}var o=e.appendChild(Se("div",[b.widgets[c].node],"CodeMirror-linewidget"));W(b.widgets[c],o,e,g)}}else if(m&&m.from<=n&&m.to>n){for(;k.lineObj!=b;)k=l(k);i&&n>=f&&k.lineNumber&&Ve(k.lineNumber,N(a.options,n)),k=k.nextSibling}else{if(b.widgets)for(var r,p=0,q=k;q&&20>p;++p,q=q.nextSibling)if(q.lineObj==b&&/div/i.test(q.nodeName)){r=q;break}var s=V(a,b,n,g,r);if(s!=r)j.insertBefore(s,k);else{for(;k!=r;)k=l(k);k=k.nextSibling}s.lineObj=b}++n});k;)k=l(k)}function V(a,b,d,e,f){var j,g=Hd(a,b),h=b.gutterMarkers,i=a.display;if(!(a.options.lineNumbers||h||b.bgClass||b.wrapClass||b.widgets))return g;if(f){f.alignable=null;for(var n,k=!0,l=0,m=f.firstChild;m;m=n)if(n=m.nextSibling,/\bCodeMirror-linewidget\b/.test(m.className)){for(var o=0,p=!0;o<b.widgets.length;++o){var q=b.widgets[o],r=!1;if(q.above||(r=p,p=!1),q.node==m.firstChild){W(q,m,f,e),++l,r&&f.insertBefore(g,m);break}}if(o==b.widgets.length){k=!1;break}}else f.removeChild(m);k&&l==b.widgets.length&&(j=f,f.className=b.wrapClass||"")}if(j||(j=Se("div",null,b.wrapClass,"position: relative"),j.appendChild(g)),b.bgClass&&j.insertBefore(Se("div","\xa0",b.bgClass+" CodeMirror-linebackground"),j.firstChild),a.options.lineNumbers||h){var s=j.insertBefore(Se("div",null,null,"position: absolute; left: "+(a.options.fixedGutter?e.fixedPos:-e.gutterTotalWidth)+"px"),j.firstChild);if(a.options.fixedGutter&&(j.alignable||(j.alignable=[])).push(s),!a.options.lineNumbers||h&&h["CodeMirror-linenumbers"]||(j.lineNumber=s.appendChild(Se("div",N(a.options,d),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+e.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+i.lineNumInnerWidth+"px"))),h)for(var t=0;t<a.options.gutters.length;++t){var u=a.options.gutters[t],v=h.hasOwnProperty(u)&&h[u];v&&s.appendChild(Se("div",[v],"CodeMirror-gutter-elt","left: "+e.gutterLeft[u]+"px; width: "+e.gutterWidth[u]+"px"))}}if(c&&(j.style.zIndex=2),b.widgets&&j!=f)for(var o=0,w=b.widgets;o<w.length;++o){var q=w[o],x=Se("div",[q.node],"CodeMirror-linewidget");W(q,x,j,e),q.above?j.insertBefore(x,a.options.lineNumbers&&0!=b.height?s:g):j.appendChild(x),ye(q,"redraw")}return j}function W(a,b,c,d){if(a.noHScroll){(c.alignable||(c.alignable=[])).push(b);var e=d.wrapperWidth;b.style.left=d.fixedPos+"px",a.coverGutter||(e-=d.gutterTotalWidth,b.style.paddingLeft=d.gutterTotalWidth+"px"),b.style.width=e+"px"}a.coverGutter&&(b.style.zIndex=5,b.style.position="relative",a.noHScroll||(b.style.marginLeft=-d.gutterTotalWidth+"px"))}function X(a){var b=a.display,c=pc(a.doc.sel.from,a.doc.sel.to);c||a.options.showCursorWhenSelecting?Y(a):b.cursor.style.display=b.otherCursor.style.display="none",c?b.selectionDiv.style.display="none":Z(a);var d=lb(a,a.doc.sel.head,"div"),e=We(b.wrapper),f=We(b.lineDiv);b.inputDiv.style.top=Math.max(0,Math.min(b.wrapper.clientHeight-10,d.top+f.top-e.top))+"px",b.inputDiv.style.left=Math.max(0,Math.min(b.wrapper.clientWidth-10,d.left+f.left-e.left))+"px"}function Y(a){var b=a.display,c=lb(a,a.doc.sel.head,"div");b.cursor.style.left=c.left+"px",b.cursor.style.top=c.top+"px",b.cursor.style.height=Math.max(0,c.bottom-c.top)*a.options.cursorHeight+"px",b.cursor.style.display="",c.other?(b.otherCursor.style.display="",b.otherCursor.style.left=c.other.left+"px",b.otherCursor.style.top=c.other.top+"px",b.otherCursor.style.height=.85*(c.other.bottom-c.other.top)+"px"):b.otherCursor.style.display="none"}function Z(a){function h(a,b,c,d){0>b&&(b=0),e.appendChild(Se("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?f-a:c)+"px; height: "+(d-b)+"px"))}function i(b,d,e,i){function m(c){return kb(a,oc(b,c),"div",j)}var j=Wd(c,b),k=j.text.length,l=i?1/0:-1/0;return ff(be(j),d||0,null==e?k:e,function(a,b,c){var j=m("rtl"==c?b-1:a),n=m("rtl"==c?a:b-1),o=j.left,p=n.right;n.top-j.top>3&&(h(o,j.top,null,j.bottom),o=g,j.bottom<n.top&&h(o,j.bottom,null,n.top)),null==e&&b==k&&(p=f),null==d&&0==a&&(o=g),l=i?Math.min(n.top,l):Math.max(n.bottom,l),g+1>o&&(o=g),h(o,n.top,p-o,n.bottom)}),l}var b=a.display,c=a.doc,d=a.doc.sel,e=document.createDocumentFragment(),f=b.lineSpace.offsetWidth,g=eb(a.display);if(d.from.line==d.to.line)i(d.from.line,d.from.ch,d.to.ch);else{for(var l,n,j=Wd(c,d.from.line),k=j,m=[d.from.line,d.from.ch];l=od(k);){var o=l.find();if(m.push(o.from.ch,o.to.line,o.to.ch),o.to.line==d.to.line){m.push(d.to.ch),n=!0;break}k=Wd(c,o.to.line)}if(n)for(var p=0;p<m.length;p+=3)i(m[p],m[p+1],m[p+2]);else{var q,r,s=Wd(c,d.to.line);q=d.from.ch?i(d.from.line,d.from.ch,null,!1):ae(a,j)-b.viewOffset,r=d.to.ch?i(d.to.line,nd(s)?null:0,d.to.ch,!0):ae(a,s)-b.viewOffset,r>q&&h(g,q,null,r)}}Ue(b.selectionDiv,e),b.selectionDiv.style.display=""}function $(a){var b=a.display;clearInterval(b.blinker);var c=!0;b.cursor.style.visibility=b.otherCursor.style.visibility="",b.blinker=setInterval(function(){b.cursor.offsetHeight&&(b.cursor.style.visibility=b.otherCursor.style.visibility=(c=!c)?"":"hidden")},a.options.cursorBlinkRate)}function _(a,b){a.doc.mode.startState&&a.doc.frontier<a.display.showingTo&&a.state.highlight.set(b,Ne(ab,a))}function ab(a){var b=a.doc;if(b.frontier<b.first&&(b.frontier=b.first),!(b.frontier>=a.display.showingTo)){var f,c=+new Date+a.options.workTime,d=Tc(b.mode,cb(a,b.frontier)),e=[];b.iter(b.frontier,Math.min(b.first+b.size,a.display.showingTo+500),function(g){if(b.frontier>=a.display.showingFrom){var h=g.styles;g.styles=Cd(a,g,d);for(var i=!h||h.length!=g.styles.length,j=0;!i&&j<h.length;++j)i=h[j]!=g.styles[j];i&&(f&&f.end==b.frontier?f.end++:e.push(f={start:b.frontier,end:b.frontier+1})),g.stateAfter=Tc(b.mode,d)}else Ed(a,g,d),g.stateAfter=0==b.frontier%5?Tc(b.mode,d):null;return++b.frontier,+new Date>c?(_(a,a.options.workDelay),!0):void 0}),e.length&&vb(a,function(){for(var a=0;a<e.length;++a)yb(this,e[a].start,e[a].end)})()}}function bb(a,b){for(var c,d,e=a.doc,f=b,g=b-100;f>g;--f){if(f<=e.first)return e.first;var h=Wd(e,f-1);if(h.stateAfter)return f;var i=Ee(h.text,null,a.options.tabSize);(null==d||c>i)&&(d=f-1,c=i)}return d}function cb(a,b){var c=a.doc,d=a.display;if(!c.mode.startState)return!0;var e=bb(a,b),f=e>c.first&&Wd(c,e-1).stateAfter;return f=f?Tc(c.mode,f):Uc(c.mode),c.iter(e,b,function(g){Ed(a,g,f);var h=e==b-1||0==e%5||e>=d.showingFrom&&e<d.showingTo;g.stateAfter=h?Tc(c.mode,f):null,++e}),f}function db(a){return a.lineSpace.offsetTop}function eb(a){var b=Ue(a.measure,Se("pre",null,null,"text-align: left")).appendChild(Se("span","x"));return b.offsetLeft}function fb(a,b,c,d){var e=-1;d=d||gb(a,b);for(var f=c;;f+=e){var g=d[f];if(g)break;0>e&&0==f&&(e=1)}return{left:c>f?g.right:g.left,right:f>c?g.left:g.right,top:g.top,bottom:g.bottom}}function gb(a,b){for(var c=a.display,d=a.display.measureLineCache,e=0;e<d.length;++e){var f=d[e];if(f.text==b.text&&f.markedSpans==b.markedSpans&&c.scroller.clientWidth==f.width&&f.classes==b.textClass+"|"+b.bgClass+"|"+b.wrapClass)return f.measure}var g=hb(a,b),f={text:b.text,width:c.scroller.clientWidth,markedSpans:b.markedSpans,measure:g,classes:b.textClass+"|"+b.bgClass+"|"+b.wrapClass};return 16==d.length?d[++c.measureLineCachePos%16]=f:d.push(f),g}function hb(a,e){var f=a.display,g=Me(e.text.length),h=Hd(a,e,g);if(b&&!c&&!a.options.lineWrapping&&h.childNodes.length>100){for(var i=document.createDocumentFragment(),j=10,k=h.childNodes.length,l=0,m=Math.ceil(k/j);m>l;++l){for(var n=Se("div",null,null,"display: inline-block"),o=0;j>o&&k;++o)n.appendChild(h.firstChild),--k;i.appendChild(n)}h.appendChild(i)}Ue(f.measure,h);var p=We(f.lineDiv),q=[],r=Me(e.text.length),s=h.offsetHeight;d&&f.measure.first!=h&&Ue(f.measure,h);for(var t,l=0;l<g.length;++l)if(t=g[l]){for(var u=We(t),v=Math.max(0,u.top-p.top),w=Math.min(u.bottom-p.top,s),o=0;o<q.length;o+=2){var x=q[o],y=q[o+1];if(!(x>w||v>y)&&(v>=x&&y>=w||x>=v&&w>=y||Math.min(w,y)-Math.max(v,x)>=w-v>>1)){q[o]=Math.min(v,x),q[o+1]=Math.max(w,y);break}}o==q.length&&q.push(v,w);var z=u.right;t.measureRight&&(z=We(t.measureRight).left),r[l]={left:u.left-p.left,right:z-p.left,top:o}}for(var t,l=0;l<r.length;++l)if(t=r[l]){var A=t.top;t.top=q[A],t.bottom=q[A+1]}if(!a.options.lineWrapping){var B=h.lastChild;3==B.nodeType&&(B=h.appendChild(Se("span","\u200b"))),r.width=We(B).right-p.left}return r}function ib(a){a.display.measureLineCache.length=a.display.measureLineCachePos=0,a.display.cachedCharWidth=a.display.cachedTextHeight=null,a.display.maxLineChanged=!0,a.display.lineNumChars=null}function jb(a,b,c,d){if(b.widgets)for(var e=0;e<b.widgets.length;++e)if(b.widgets[e].above){var f=wd(b.widgets[e]);c.top+=f,c.bottom+=f}if("line"==d)return c;d||(d="local");var g=ae(a,b);if("local"!=d&&(g-=a.display.viewOffset),"page"==d){var h=We(a.display.lineSpace);g+=h.top+(window.pageYOffset||(document.documentElement||document.body).scrollTop);var i=h.left+(window.pageXOffset||(document.documentElement||document.body).scrollLeft);c.left+=i,c.right+=i}return c.top+=g,c.bottom+=g,c}function kb(a,b,c,d){return d||(d=Wd(a.doc,b.line)),jb(a,d,fb(a,d,b.ch),c)}function lb(a,b,c,d,e){function f(b,f){var g=fb(a,d,b,e);return f?g.left=g.right:g.right=g.left,jb(a,d,g,c)}d=d||Wd(a.doc,b.line),e||(e=gb(a,d));var g=be(d),h=b.ch;if(!g)return f(h);for(var i,j,k=g[0].level,l=0;l<g.length;++l){var o,p,m=g[l],n=m.level%2;if(m.from<h&&m.to>h)return f(h,n);var q=n?m.to:m.from,r=n?m.from:m.to;if(q==h)p=l&&m.level<(o=g[l-1]).level?f(o.level%2?o.from:o.to-1,!0):f(n&&m.from!=m.to?h-1:h),n==k?i=p:j=p;else if(r==h){var o=l<g.length-1&&g[l+1];if(!n&&o&&o.from==o.to)continue;p=o&&m.level<o.level?f(o.level%2?o.to-1:o.from):f(n?h:h-1,!0),n==k?i=p:j=p}}return k&&!h&&(j=f(g[0].to-1)),i?(j&&(i.other=j),i):j}function mb(a,b,c){var d=new oc(a,b);return c&&(d.outside=!0),d}function nb(a,b,c){var d=a.doc;if(c+=a.display.viewOffset,0>c)return mb(d.first,0,!0);var e=_d(d,c),f=d.first+d.size-1;if(e>f)return mb(d.first+d.size-1,Wd(d,f).text.length,!0);for(0>b&&(b=0);;){var g=Wd(d,e),h=ob(a,g,e,b,c),i=od(g),j=i&&i.find();if(!(i&&h.ch>=j.from.ch))return h;e=j.to.line}}function ob(a,b,c,d,e){function j(d){var e=lb(a,oc(c,d),"line",b,i);return g=!0,f>e.bottom?Math.max(0,e.left-h):f<e.top?e.left+h:(g=!1,e.left)}var f=e-ae(a,b),g=!1,h=a.display.wrapper.clientWidth,i=gb(a,b),k=be(b),l=b.text.length,m=jf(b),n=kf(b),o=j(m),p=g,q=j(n),r=g;if(d>q)return mb(c,n,r);for(;;){if(k?n==m||n==nf(b,m,1):1>=n-m){for(var s=q-d>d-o,t=s?m:n;Re.test(b.text.charAt(t));)++t;var u=mb(c,t,s?p:r);return u.after=s,u}var v=Math.ceil(l/2),w=m+v;if(k){w=m;for(var x=0;v>x;++x)w=nf(b,w,1)}var y=j(w);y>d?(n=w,q=y,(r=g)&&(q+=1e3),l-=v):(m=w,o=y,p=g,l=v)}}function qb(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==pb){pb=Se("pre");for(var b=0;49>b;++b)pb.appendChild(document.createTextNode("x")),pb.appendChild(Se("br"));pb.appendChild(document.createTextNode("x"))}Ue(a.measure,pb);var c=pb.offsetHeight/50;return c>3&&(a.cachedTextHeight=c),Te(a.measure),c||1}function rb(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=Se("span","x"),c=Se("pre",[b]);Ue(a.measure,c);var d=b.offsetWidth;return d>2&&(a.cachedCharWidth=d),d||10}function tb(a){a.curOp={changes:[],updateInput:null,userSelChange:null,textChanged:null,selectionChanged:!1,updateMaxLine:!1,updateScrollPos:!1,id:++sb},xe++||(we=[])}function ub(a){var b=a.curOp,c=a.doc,d=a.display;if(a.curOp=null,b.updateMaxLine&&H(a),d.maxLineChanged&&!a.options.lineWrapping){var e=gb(a,d.maxLine).width;d.sizer.style.minWidth=Math.max(0,e+3+Be)+"px",d.maxLineChanged=!1;var f=Math.max(0,d.sizer.offsetLeft+d.sizer.offsetWidth-d.scroller.clientWidth);f<c.scrollLeft&&!b.updateScrollPos&&Pb(a,Math.min(d.scroller.scrollLeft,f),!0)}var g,h;if(b.updateScrollPos)g=b.updateScrollPos;else if(b.selectionChanged&&d.scroller.clientHeight){var i=lb(a,c.sel.head);g=Ec(a,i.left,i.top,i.left,i.bottom)}(b.changes.length||g&&null!=g.scrollTop)&&(h=P(a,b.changes,g&&g.scrollTop)),!h&&b.selectionChanged&&X(a),b.updateScrollPos?(d.scroller.scrollTop=d.scrollbarV.scrollTop=c.scrollTop=g.scrollTop,d.scroller.scrollLeft=d.scrollbarH.scrollLeft=c.scrollLeft=g.scrollLeft,L(a)):g&&Bc(a),b.selectionChanged&&$(a),a.state.focused&&b.updateInput&&Cb(a,b.userSelChange);var j=b.maybeHiddenMarkers,k=b.maybeUnhiddenMarkers;if(j)for(var l=0;l<j.length;++l)j[l].lines.length||ve(j[l],"hide");if(k)for(var l=0;l<k.length;++l)k[l].lines.length&&ve(k[l],"unhide");var m;if(--xe||(m=we,we=null),b.textChanged&&ve(a,"change",a,b.textChanged),b.selectionChanged&&ve(a,"cursorActivity",a),m)for(var l=0;l<m.length;++l)m[l]()}function vb(a,b){return function(){var c=a||this,d=!c.curOp;d&&tb(c);try{var e=b.apply(c,arguments)}finally{d&&ub(c)}return e}}function wb(a){return function(){var c,b=this.cm&&!this.cm.curOp;b&&tb(this.cm);try{c=a.apply(this,arguments)}finally{b&&ub(this.cm)}return c}}function xb(a,b){var d,c=!a.curOp;c&&tb(a);try{d=b()}finally{c&&ub(a)}return d}function yb(a,b,c,d){null==b&&(b=a.doc.first),null==c&&(c=a.doc.first+a.doc.size),a.curOp.changes.push({from:b,to:c,diff:d})}function zb(a){a.display.pollingFast||a.display.poll.set(a.options.pollInterval,function(){Bb(a),a.state.focused&&zb(a)})}function Ab(a){function c(){var d=Bb(a);d||b?(a.display.pollingFast=!1,zb(a)):(b=!0,a.display.poll.set(60,c))}var b=!1;a.display.pollingFast=!0,a.display.poll.set(20,c)}function Bb(a){var c=a.display.input,d=a.display.prevInput,e=a.doc,f=e.sel;if(!a.state.focused||cf(c)||Eb(a))return!1;var g=c.value;if(g==d&&pc(f.from,f.to))return!1;if(b&&g&&0===c.selectionStart)return Cb(a,!0),!1;var h=!a.curOp;h&&tb(a),f.shift=!1;for(var i=0,j=Math.min(d.length,g.length);j>i&&d[i]==g[i];)++i;var k=f.from,l=f.to;i<d.length?k=oc(k.line,k.ch-(d.length-i)):a.state.overwrite&&pc(k,l)&&!a.state.pasteIncoming&&(l=oc(l.line,Math.min(Wd(e,l.line).text.length,l.ch+(g.length-i))));var m=a.curOp.updateInput;return hc(a.doc,{from:k,to:l,text:bf(g.slice(i)),origin:a.state.pasteIncoming?"paste":"+input"},"end"),a.curOp.updateInput=m,g.length>1e3?c.value=a.display.prevInput="":a.display.prevInput=g,h&&ub(a),a.state.pasteIncoming=!1,!0}function Cb(a,b){var c,d,e=a.doc;pc(e.sel.from,e.sel.to)?b&&(a.display.prevInput=a.display.input.value=""):(a.display.prevInput="",c=df&&(e.sel.to.line-e.sel.from.line>100||(d=a.getSelection()).length>1e3),a.display.input.value=c?"-":d||a.getSelection(),a.state.focused&&Ie(a.display.input)),a.display.inaccurateSelection=c}function Db(a){"nocursor"==a.options.readOnly||o&&document.activeElement==a.display.input||a.display.input.focus()}function Eb(a){return a.options.readOnly||a.doc.cantEdit}function Fb(a){function c(){a.state.focused&&setTimeout(Ne(Db,a),0)}function d(){b.cachedCharWidth=b.cachedTextHeight=null,ib(a),xb(a,Ne(yb,a))}function e(){for(var a=b.wrapper.parentNode;a&&a!=document.body;a=a.parentNode);a?setTimeout(e,5e3):ue(window,"resize",d)}function f(b){a.options.onDragEvent&&a.options.onDragEvent(a,ne(b))||qe(b)}function g(){b.inaccurateSelection&&(b.prevInput="",b.inaccurateSelection=!1,b.input.value=a.getSelection(),Ie(b.input))}var b=a.display;te(b.scroller,"mousedown",vb(a,Kb)),te(b.scroller,"dblclick",vb(a,oe)),te(b.lineSpace,"selectstart",function(a){Gb(b,a)||oe(a)}),t||te(b.scroller,"contextmenu",function(b){cc(a,b)}),te(b.scroller,"scroll",function(){Ob(a,b.scroller.scrollTop),Pb(a,b.scroller.scrollLeft,!0),ve(a,"scroll",a)}),te(b.scrollbarV,"scroll",function(){Ob(a,b.scrollbarV.scrollTop)}),te(b.scrollbarH,"scroll",function(){Pb(a,b.scrollbarH.scrollLeft)}),te(b.scroller,"mousewheel",function(b){Sb(a,b)}),te(b.scroller,"DOMMouseScroll",function(b){Sb(a,b)}),te(b.scrollbarH,"mousedown",c),te(b.scrollbarV,"mousedown",c),te(b.wrapper,"scroll",function(){b.wrapper.scrollTop=b.wrapper.scrollLeft=0}),te(window,"resize",d),setTimeout(e,5e3),te(b.input,"keyup",vb(a,function(b){a.options.onKeyEvent&&a.options.onKeyEvent(a,ne(b))||16==b.keyCode&&(a.doc.sel.shift=!1)})),te(b.input,"input",Ne(Ab,a)),te(b.input,"keydown",vb(a,Zb)),te(b.input,"keypress",vb(a,$b)),te(b.input,"focus",Ne(_b,a)),te(b.input,"blur",Ne(ac,a)),a.options.dragDrop&&(te(b.scroller,"dragstart",function(b){Nb(a,b)}),te(b.scroller,"dragenter",f),te(b.scroller,"dragover",f),te(b.scroller,"drop",vb(a,Lb))),te(b.scroller,"paste",function(c){Gb(b,c)||(Db(a),Ab(a))}),te(b.input,"paste",function(){a.state.pasteIncoming=!0,Ab(a)}),te(b.input,"cut",g),te(b.input,"copy",g),j&&te(b.sizer,"mouseup",function(){document.activeElement==b.input&&b.input.blur(),Db(a)})}function Gb(a,b){for(var c=re(b);c!=a.wrapper;c=c.parentNode){if(!c)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(c.className)||c.parentNode==a.sizer&&c!=a.mover)return!0}}function Hb(a,b,c){var d=a.display;if(!c){var e=re(b);if(e==d.scrollbarH||e==d.scrollbarH.firstChild||e==d.scrollbarV||e==d.scrollbarV.firstChild||e==d.scrollbarFiller)return null}var f,g,h=We(d.lineSpace);try{f=b.clientX,g=b.clientY}catch(b){return null}return nb(a,f-h.left,g-h.top)}function Kb(a){function p(a){if("single"==j)return wc(c.doc,tc(f,h),a),void 0;if(n=tc(f,n),o=tc(f,o),"double"==j){var b=Jc(Wd(f,a.line).text,a);qc(a,n)?wc(c.doc,b.from,o):wc(c.doc,n,b.to)}else"triple"==j&&(qc(a,n)?wc(c.doc,o,tc(f,oc(a.line,0))):wc(c.doc,n,tc(f,oc(a.line+1,0))))}function s(a){var b=++r,e=Hb(c,a,!0);if(e)if(pc(e,l)){var h=a.clientY<q.top?-20:a.clientY>q.bottom?20:0;h&&setTimeout(vb(c,function(){r==b&&(d.scroller.scrollTop+=h,s(a))}),50)}else{c.state.focused||_b(c),l=e,p(e);var g=K(d,f);(e.line>=g.to||e.line<g.from)&&setTimeout(vb(c,function(){r==b&&s(a)}),150)}}function u(a){r=1/0;var b=Hb(c,a);b&&p(b),oe(a),Db(c),ue(document,"mousemove",v),ue(document,"mouseup",w)}var c=this,d=c.display,f=c.doc,g=f.sel;if(g.shift=a.shiftKey,Gb(d,a))return e||(d.scroller.draggable=!1,setTimeout(function(){d.scroller.draggable=!0},100)),void 0;if(!Mb(c,a)){var h=Hb(c,a);switch(se(a)){case 3:return t&&cc.call(c,c,a),void 0;case 2:return h&&wc(c.doc,h),setTimeout(Ne(Db,c),20),oe(a),void 0}if(!h)return re(a)==d.scroller&&oe(a),void 0;c.state.focused||_b(c);var i=+new Date,j="single";if(Jb&&Jb.time>i-400&&pc(Jb.pos,h))j="triple",oe(a),setTimeout(Ne(Db,c),20),Kc(c,h.line);else if(Ib&&Ib.time>i-400&&pc(Ib.pos,h)){j="double",Jb={time:i,pos:h},oe(a);var k=Jc(Wd(f,h.line).text,h);wc(c.doc,k.from,k.to)}else Ib={time:i,pos:h};var l=h;if(c.options.dragDrop&&Xe&&!Eb(c)&&!pc(g.from,g.to)&&!qc(h,g.from)&&!qc(g.to,h)&&"single"==j){var m=vb(c,function(b){e&&(d.scroller.draggable=!1),c.state.draggingText=!1,ue(document,"mouseup",m),ue(d.scroller,"drop",m),Math.abs(a.clientX-b.clientX)+Math.abs(a.clientY-b.clientY)<10&&(oe(b),wc(c.doc,h),Db(c))});return e&&(d.scroller.draggable=!0),c.state.draggingText=m,d.scroller.dragDrop&&d.scroller.dragDrop(),te(document,"mouseup",m),te(d.scroller,"drop",m),void 0}oe(a),"single"==j&&wc(c.doc,tc(f,h));var n=g.from,o=g.to,q=We(d.wrapper),r=0,v=vb(c,function(a){b||se(a)?s(a):u(a)}),w=vb(c,u);te(document,"mousemove",v),te(document,"mouseup",w)}}function Lb(a){var b=this;if(!(Gb(b.display,a)||b.options.onDragEvent&&b.options.onDragEvent(b,ne(a)))){oe(a);var c=Hb(b,a,!0),d=a.dataTransfer.files;if(c&&!Eb(b))if(d&&d.length&&window.FileReader&&window.File)for(var e=d.length,f=Array(e),g=0,h=function(a,d){var h=new FileReader;h.onload=function(){f[d]=h.result,++g==e&&(c=tc(b.doc,c),nc(b.doc,f.join(""),c,"around","paste"))},h.readAsText(a)},i=0;e>i;++i)h(d[i],i);else{if(b.state.draggingText&&!qc(c,b.doc.sel.from)&&!qc(b.doc.sel.to,c))return b.state.draggingText(a),setTimeout(Ne(Db,b),20),void 0;try{var f=a.dataTransfer.getData("Text");if(f){var j=b.doc.sel.from,k=b.doc.sel.to;yc(b.doc,c,c),b.state.draggingText&&nc(b.doc,"",j,k,"paste"),b.replaceSelection(f,null,"paste"),Db(b),_b(b)}}catch(a){}}}}function Mb(a,b){var c=a.display;try{var d=b.clientX,e=b.clientY}catch(b){return!1}if(d>=Math.floor(We(c.gutters).right))return!1;if(oe(b),!Ae(a,"gutterClick"))return!0;var f=We(c.lineDiv);if(e>f.bottom)return!0;e-=f.top-c.viewOffset;for(var g=0;g<a.options.gutters.length;++g){var h=c.gutters.childNodes[g];if(h&&We(h).right>=d){var i=_d(a.doc,e),j=a.options.gutters[g];ye(a,"gutterClick",a,i,j,b);break}}return!0}function Nb(a,b){if(!Gb(a.display,b)){var c=a.getSelection();if(b.dataTransfer.setData("Text",c),b.dataTransfer.setDragImage&&!i){var d=Se("img",null,null,"position: fixed; left: 0; top: 0;");h&&(d.width=d.height=1,a.display.wrapper.appendChild(d),d._top=d.offsetTop),b.dataTransfer.setDragImage(d,0,0),h&&d.parentNode.removeChild(d)}}}function Ob(b,c){Math.abs(b.doc.scrollTop-c)<2||(b.doc.scrollTop=c,a||P(b,[],c),b.display.scroller.scrollTop!=c&&(b.display.scroller.scrollTop=c),b.display.scrollbarV.scrollTop!=c&&(b.display.scrollbarV.scrollTop=c),a&&P(b,[]))}function Pb(a,b,c){(c?b==a.doc.scrollLeft:Math.abs(a.doc.scrollLeft-b)<2)||(b=Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth),a.doc.scrollLeft=b,L(a),a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b),a.display.scrollbarH.scrollLeft!=b&&(a.display.scrollbarH.scrollLeft=b))}function Sb(b,c){var d=c.wheelDeltaX,f=c.wheelDeltaY;if(null==d&&c.detail&&c.axis==c.HORIZONTAL_AXIS&&(d=c.detail),null==f&&c.detail&&c.axis==c.VERTICAL_AXIS?f=c.detail:null==f&&(f=c.wheelDelta),f&&p&&e)for(var g=c.target;g!=j;g=g.parentNode)if(g.lineObj){b.display.currentWheelTarget=g;
|
|
break}var i=b.display,j=i.scroller;if(d&&!a&&!h&&null!=Rb)return f&&Ob(b,Math.max(0,Math.min(j.scrollTop+f*Rb,j.scrollHeight-j.clientHeight))),Pb(b,Math.max(0,Math.min(j.scrollLeft+d*Rb,j.scrollWidth-j.clientWidth))),oe(c),i.wheelStartX=null,void 0;if(f&&null!=Rb){var k=f*Rb,l=b.doc.scrollTop,m=l+i.wrapper.clientHeight;0>k?l=Math.max(0,l+k-50):m=Math.min(b.doc.height,m+k+50),P(b,[],{top:l,bottom:m})}20>Qb&&(null==i.wheelStartX?(i.wheelStartX=j.scrollLeft,i.wheelStartY=j.scrollTop,i.wheelDX=d,i.wheelDY=f,setTimeout(function(){if(null!=i.wheelStartX){var a=j.scrollLeft-i.wheelStartX,b=j.scrollTop-i.wheelStartY,c=b&&i.wheelDY&&b/i.wheelDY||a&&i.wheelDX&&a/i.wheelDX;i.wheelStartX=i.wheelStartY=null,c&&(Rb=(Rb*Qb+c)/(Qb+1),++Qb)}},200)):(i.wheelDX+=d,i.wheelDY+=f))}function Tb(a,b,c){if("string"==typeof b&&(b=Vc[b],!b))return!1;a.display.pollingFast&&Bb(a)&&(a.display.pollingFast=!1);var d=a.doc,e=d.sel.shift,f=!1;try{Eb(a)&&(a.state.suppressEdits=!0),c&&(d.sel.shift=!1),f=b(a)!=Ce}finally{d.sel.shift=e,a.state.suppressEdits=!1}return f}function Ub(a){var b=a.state.keyMaps.slice(0);return b.push(a.options.keyMap),a.options.extraKeys&&b.unshift(a.options.extraKeys),b}function Wb(a,b){var c=Xc(a.options.keyMap),e=c.auto;clearTimeout(Vb),e&&!Zc(b)&&(Vb=setTimeout(function(){Xc(a.options.keyMap)==c&&(a.options.keyMap=e.call?e.call(null,a):e)},50));var f=$c(b,!0),g=!1;if(!f)return!1;var h=Ub(a);return g=b.shiftKey?Yc("Shift-"+f,h,function(b){return Tb(a,b,!0)})||Yc(f,h,function(b){return"string"==typeof b&&/^go[A-Z]/.test(b)?Tb(a,b):void 0}):Yc(f,h,function(b){return Tb(a,b)}),"stop"==g&&(g=!1),g&&(oe(b),$(a),d&&(b.oldKeyCode=b.keyCode,b.keyCode=0)),g}function Xb(a,b,c){var d=Yc("'"+c+"'",Ub(a),function(b){return Tb(a,b,!0)});return d&&(oe(b),$(a)),d}function Zb(a){var c=this;if(c.state.focused||_b(c),b&&27==a.keyCode&&(a.returnValue=!1),!c.options.onKeyEvent||!c.options.onKeyEvent(c,ne(a))){var d=a.keyCode;c.doc.sel.shift=16==d||a.shiftKey;var e=Wb(c,a);h&&(Yb=e?d:null,!e&&88==d&&!df&&(p?a.metaKey:a.ctrlKey)&&c.replaceSelection(""))}}function $b(a){var b=this;if(!b.options.onKeyEvent||!b.options.onKeyEvent(b,ne(a))){var c=a.keyCode,d=a.charCode;if(h&&c==Yb)return Yb=null,oe(a),void 0;if(!(h&&(!a.which||a.which<10)||j)||!Wb(b,a)){var e=String.fromCharCode(null==d?c:d);this.options.electricChars&&this.doc.mode.electricChars&&this.options.smartIndent&&!Eb(this)&&this.doc.mode.electricChars.indexOf(e)>-1&&setTimeout(vb(b,function(){Fc(b,b.doc.sel.to.line,"smart")}),75),Xb(b,a,e)||Ab(b)}}}function _b(a){"nocursor"!=a.options.readOnly&&(a.state.focused||(ve(a,"focus",a),a.state.focused=!0,-1==a.display.wrapper.className.search(/\bCodeMirror-focused\b/)&&(a.display.wrapper.className+=" CodeMirror-focused"),Cb(a,!0)),zb(a),$(a))}function ac(a){a.state.focused&&(ve(a,"blur",a),a.state.focused=!1,a.display.wrapper.className=a.display.wrapper.className.replace(" CodeMirror-focused","")),clearInterval(a.display.blinker),setTimeout(function(){a.state.focused||(a.doc.sel.shift=!1)},150)}function cc(a,c){function k(){if(e.inputDiv.style.position="relative",e.input.style.cssText=j,d&&(e.scrollbarV.scrollTop=e.scroller.scrollTop=i),zb(a),null!=e.input.selectionStart&&(!b||d)){clearTimeout(bc);var c=e.input.value=" "+(pc(f.from,f.to)?"":e.input.value),g=0;e.prevInput=" ",e.input.selectionStart=1,e.input.selectionEnd=c.length;var h=function(){" "==e.prevInput&&0==e.input.selectionStart?vb(a,Vc.selectAll)(a):g++<10?bc=setTimeout(h,500):Cb(a)};bc=setTimeout(h,200)}}var e=a.display,f=a.doc.sel;if(!Gb(e,c)){var g=Hb(a,c),i=e.scroller.scrollTop;if(g&&!h){(pc(f.from,f.to)||qc(g,f.from)||!qc(g,f.to))&&vb(a,yc)(a.doc,g,g);var j=e.input.style.cssText;if(e.inputDiv.style.position="absolute",e.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(c.clientY-5)+"px; left: "+(c.clientX-5)+"px; z-index: 1000; background: white; outline: none;"+"border-width: 0; outline: none; overflow: hidden; opacity: .05; -ms-opacity: .05; filter: alpha(opacity=5);",Db(a),Cb(a,!0),pc(f.from,f.to)&&(e.input.value=e.prevInput=" "),t){qe(c);var l=function(){ue(window,"mouseup",l),setTimeout(k,20)};te(window,"mouseup",l)}else setTimeout(k,50)}}}function dc(a){return oc(a.from.line+a.text.length-1,He(a.text).length+(1==a.text.length?a.from.ch:0))}function ec(a,b,c){if(!qc(b.from,c))return tc(a,c);var d=b.text.length-1-(b.to.line-b.from.line);if(c.line>b.to.line+d){var e=c.line-d,f=a.first+a.size-1;return e>f?oc(f,Wd(a,f).text.length):uc(c,Wd(a,e).text.length)}if(c.line==b.to.line+d)return uc(c,He(b.text).length+(1==b.text.length?b.from.ch:0)+Wd(a,b.to.line).text.length-b.to.ch);var g=c.line-b.from.line;return uc(c,b.text[g].length+(g?0:b.from.ch))}function fc(a,b,c){if(c&&"object"==typeof c)return{anchor:ec(a,b,c.anchor),head:ec(a,b,c.head)};if("start"==c)return{anchor:b.from,head:b.from};var d=dc(b);if("around"==c)return{anchor:b.from,head:d};if("end"==c)return{anchor:d,head:d};var e=function(a){if(qc(a,b.from))return a;if(!qc(b.to,a))return d;var c=a.line+b.text.length-(b.to.line-b.from.line)-1,e=a.ch;return a.line==b.to.line&&(e+=d.ch-b.to.ch),oc(c,e)};return{anchor:e(a.sel.anchor),head:e(a.sel.head)}}function gc(a,b){var c={canceled:!1,from:b.from,to:b.to,text:b.text,origin:b.origin,update:function(b,c,d,e){b&&(this.from=tc(a,b)),c&&(this.to=tc(a,c)),d&&(this.text=d),void 0!==e&&(this.origin=e)},cancel:function(){this.canceled=!0}};return ve(a,"beforeChange",a,c),a.cm&&ve(a.cm,"beforeChange",a.cm,c),c.canceled?null:{from:c.from,to:c.to,text:c.text,origin:c.origin}}function hc(a,b,c,d){if(a.cm){if(!a.cm.curOp)return vb(a.cm,hc)(a,b,c,d);if(a.cm.state.suppressEdits)return}if(!(Ae(a,"beforeChange")||a.cm&&Ae(a.cm,"beforeChange"))||(b=gc(a,b))){var e=u&&!d&&ld(a,b.from,b.to);if(e){for(var f=e.length-1;f>=1;--f)ic(a,{from:e[f].from,to:e[f].to,text:[""]});e.length&&ic(a,{from:e[0].from,to:e[0].to,text:b.text},c)}else ic(a,b,c)}}function ic(a,b,c){var d=fc(a,b,c);fe(a,b,d,a.cm?a.cm.curOp.id:0/0),lc(a,b,d,jd(a,b));var e=[];Ud(a,function(a,c){c||-1!=Je(e,a.history)||(le(a.history,b),e.push(a.history)),lc(a,b,null,jd(a,b))})}function jc(a,b){var c=a.history,d=("undo"==b?c.done:c.undone).pop();if(d){c.dirtyCounter+="undo"==b?-1:1;var e={changes:[],anchorBefore:d.anchorAfter,headBefore:d.headAfter,anchorAfter:d.anchorBefore,headAfter:d.headBefore};("undo"==b?c.undone:c.done).push(e);for(var f=d.changes.length-1;f>=0;--f){var g=d.changes[f];g.origin=b,e.changes.push(ee(a,g));var h=f?fc(a,g,null):{anchor:d.anchorBefore,head:d.headBefore};lc(a,g,h,kd(a,g));var i=[];Ud(a,function(a,b){b||-1!=Je(i,a.history)||(le(a.history,g),i.push(a.history)),lc(a,g,null,kd(a,g))})}}}function kc(a,b){function c(a){return oc(a.line+b,a.ch)}a.first+=b,a.cm&&yb(a.cm,a.first,a.first,b),a.sel.head=c(a.sel.head),a.sel.anchor=c(a.sel.anchor),a.sel.from=c(a.sel.from),a.sel.to=c(a.sel.to)}function lc(a,b,c,d){if(a.cm&&!a.cm.curOp)return vb(a.cm,lc)(a,b,c,d);if(b.to.line<a.first)return kc(a,b.text.length-1-(b.to.line-b.from.line)),void 0;if(!(b.from.line>a.lastLine())){if(b.from.line<a.first){var e=b.text.length-1-(a.first-b.from.line);kc(a,e),b={from:oc(a.first,0),to:oc(b.to.line+e,b.to.ch),text:[He(b.text)],origin:b.origin}}var f=a.lastLine();b.to.line>f&&(b={from:b.from,to:oc(f,Wd(a,f).text.length),text:[b.text[0]],origin:b.origin}),c||(c=fc(a,b,null)),a.cm?mc(a.cm,b,d,c):Nd(a,b,d,c)}}function mc(a,b,c,d){var e=a.doc,f=a.display,g=b.from,h=b.to,i=!1,j=g.line;a.options.lineWrapping||(j=$d(pd(e,Wd(e,g.line))),e.iter(j,h.line+1,function(a){return a==f.maxLine?(i=!0,!0):void 0})),Nd(e,b,c,d,A(a)),a.options.lineWrapping||(e.iter(j,g.line+b.text.length,function(a){var b=G(e,a);b>f.maxLineLength&&(f.maxLine=a,f.maxLineLength=b,f.maxLineChanged=!0,i=!1)}),i&&(a.curOp.updateMaxLine=!0)),e.frontier=Math.min(e.frontier,g.line),_(a,400);var k=b.text.length-(h.line-g.line)-1;if(yb(a,g.line,h.line+1,k),Ae(a,"change")){var l={from:g,to:h,text:b.text,origin:b.origin};if(a.curOp.textChanged){for(var m=a.curOp.textChanged;m.next;m=m.next);m.next=l}else a.curOp.textChanged=l}}function nc(a,b,c,d,e){if(d||(d=c),qc(d,c)){var f=d;d=c,c=f}"string"==typeof b&&(b=bf(b)),hc(a,{from:c,to:d,text:b,origin:e},null)}function oc(a,b){return this instanceof oc?(this.line=a,this.ch=b,void 0):new oc(a,b)}function pc(a,b){return a.line==b.line&&a.ch==b.ch}function qc(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch}function rc(a){return oc(a.line,a.ch)}function sc(a,b){return Math.max(a.first,Math.min(b,a.first+a.size-1))}function tc(a,b){if(b.line<a.first)return oc(a.first,0);var c=a.first+a.size-1;return b.line>c?oc(c,Wd(a,c).text.length):uc(b,Wd(a,b.line).text.length)}function uc(a,b){var c=a.ch;return null==c||c>b?oc(a.line,b):0>c?oc(a.line,0):a}function vc(a,b){return b>=a.first&&b<a.first+a.size}function wc(a,b,c,d){if(a.sel.shift||a.sel.extend){var e=a.sel.anchor;if(c){var f=qc(b,e);f!=qc(c,e)?(e=b,b=c):f!=qc(b,c)&&(b=c)}yc(a,e,b,d)}else yc(a,b,c||b,d);a.cm&&(a.cm.curOp.userSelChange=!0)}function xc(a,b,c){var d={anchor:b,head:c};return ve(a,"beforeSelectionChange",a,d),a.cm&&ve(a.cm,"beforeSelectionChange",a.cm,d),d.anchor=tc(a,d.anchor),d.head=tc(a,d.head),d}function yc(a,b,c,d,e){if(!e&&Ae(a,"beforeSelectionChange")||a.cm&&Ae(a.cm,"beforeSelectionChange")){var f=xc(a,b,c);c=f.head,b=f.anchor}var g=a.sel;if(g.goalColumn=null,(e||!pc(b,g.anchor))&&(b=Ac(a,b,d,"push"!=e)),(e||!pc(c,g.head))&&(c=Ac(a,c,d,"push"!=e)),!pc(g.anchor,b)||!pc(g.head,c)){g.anchor=b,g.head=c;var h=qc(c,b);g.from=h?c:b,g.to=h?b:c,a.cm&&(a.cm.curOp.updateInput=a.cm.curOp.selectionChanged=!0),ye(a,"cursorActivity",a)}}function zc(a){yc(a.doc,a.doc.sel.from,a.doc.sel.to,null,"push")}function Ac(a,b,c,d){var e=!1,f=b,g=c||1;a.cantEdit=!1;a:for(;;){var i,h=Wd(a,f.line);if(h.markedSpans){for(var j=0;j<h.markedSpans.length;++j){var k=h.markedSpans[j],l=k.marker;if((null==k.from||(l.inclusiveLeft?k.from<=f.ch:k.from<f.ch))&&(null==k.to||(l.inclusiveRight?k.to>=f.ch:k.to>f.ch))){if(d&&l.clearOnEnter){(i||(i=[])).push(l);continue}if(!l.atomic)continue;var m=l.find()[0>g?"from":"to"];if(pc(m,f)&&(m.ch+=g,m.ch<0?m=m.line>a.first?tc(a,oc(m.line-1)):null:m.ch>h.text.length&&(m=m.line<a.first+a.size-1?oc(m.line+1,0):null),!m)){if(e)return d?(a.cantEdit=!0,oc(a.first,0)):Ac(a,b,c,!0);e=!0,m=b,g=-g}f=m;continue a}}if(i)for(var j=0;j<i.length;++j)i[j].clear()}return f}}function Bc(a){var b=Cc(a,a.doc.sel.head);if(a.state.focused){var c=a.display,d=We(c.sizer),e=null;if(b.top+d.top<0?e=!0:b.bottom+d.top>(window.innerHeight||document.documentElement.clientHeight)&&(e=!1),null!=e&&!m){var f="none"==c.cursor.style.display;f&&(c.cursor.style.display="",c.cursor.style.left=b.left+"px",c.cursor.style.top=b.top-c.viewOffset+"px"),c.cursor.scrollIntoView(e),f&&(c.cursor.style.display="none")}}}function Cc(a,b){for(;;){var c=!1,d=lb(a,b),e=Ec(a,d.left,d.top,d.left,d.bottom),f=a.doc.scrollTop,g=a.doc.scrollLeft;if(null!=e.scrollTop&&(Ob(a,e.scrollTop),Math.abs(a.doc.scrollTop-f)>1&&(c=!0)),null!=e.scrollLeft&&(Pb(a,e.scrollLeft),Math.abs(a.doc.scrollLeft-g)>1&&(c=!0)),!c)return d}}function Dc(a,b,c,d,e){var f=Ec(a,b,c,d,e);null!=f.scrollTop&&Ob(a,f.scrollTop),null!=f.scrollLeft&&Pb(a,f.scrollLeft)}function Ec(a,b,c,d,e){var f=a.display,g=db(f);c+=g,e+=g;var h=f.scroller.clientHeight-Be,i=f.scroller.scrollTop,j={},k=a.doc.height+2*g,l=g+10>c,m=e+g>k-10;i>c?j.scrollTop=l?0:Math.max(0,c):e>i+h&&(j.scrollTop=(m?k:e)-h);var n=f.scroller.clientWidth-Be,o=f.scroller.scrollLeft;b+=f.gutters.offsetWidth,d+=f.gutters.offsetWidth;var p=f.gutters.offsetWidth,q=p+10>b;return o+p>b||q?(q&&(b=0),j.scrollLeft=Math.max(0,b-10-p)):d>n+o-3&&(j.scrollLeft=d+10-n),j}function Fc(a,b,c,d){var e=a.doc;if(c||(c="add"),"smart"==c)if(a.doc.mode.indent)var f=cb(a,b);else c="prev";var k,g=a.options.tabSize,h=Wd(e,b),i=Ee(h.text,null,g),j=h.text.match(/^\s*/)[0];if("smart"==c&&(k=a.doc.mode.indent(f,h.text.slice(j.length),h.text),k==Ce)){if(!d)return;c="prev"}"prev"==c?k=b>e.first?Ee(Wd(e,b-1).text,null,g):0:"add"==c?k=i+a.options.indentUnit:"subtract"==c&&(k=i-a.options.indentUnit),k=Math.max(0,k);var l="",m=0;if(a.options.indentWithTabs)for(var n=Math.floor(k/g);n;--n)m+=g,l+=" ";k>m&&(l+=Ge(k-m)),l!=j&&nc(a.doc,l,oc(b,0),oc(b,j.length),"+input"),h.stateAfter=null}function Gc(a,b,c){var d=b,e=b,f=a.doc;return"number"==typeof b?e=Wd(f,sc(f,b)):d=$d(b),null==d?null:c(e,d)?(yb(a,d,d+1),e):null}function Hc(a,b,c,d,e){function j(){var b=f+c;return b<a.first||b>=a.first+a.size?i=!1:(f=b,h=Wd(a,b))}function k(a){var b=(e?nf:of)(h,g,c,!0);if(null==b){if(a||!j())return i=!1;g=e?(0>c?kf:jf)(h):0>c?h.text.length:0}else g=b;return!0}var f=b.line,g=b.ch,h=Wd(a,f),i=!0;if("char"==d)k();else if("column"==d)k(!0);else if("word"==d)for(var l=!1;!(0>c)||k();){if(Pe(h.text.charAt(g)))l=!0;else if(l){0>c&&(c=1,k());break}if(c>0&&!k())break}var m=Ac(a,oc(f,g),c,!0);return i||(m.hitSide=!0),m}function Ic(a,b,c,d){var g,e=a.doc,f=b.left;if("page"==d){var h=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);g=b.top+c*h}else"line"==d&&(g=c>0?b.bottom+3:b.top-3);for(;;){var i=nb(a,f,g);if(!i.outside)break;if(0>c?0>=g:g>=e.height){i.hitSide=!0;break}g+=5*c}return i}function Jc(a,b){var c=b.ch,d=b.ch;if(a){b.after===!1||d==a.length?--c:++d;for(var e=a.charAt(c),f=Pe(e)?Pe:/\s/.test(e)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!Pe(a)};c>0&&f(a.charAt(c-1));)--c;for(;d<a.length&&f(a.charAt(d));)++d}return{from:oc(b.line,c),to:oc(b.line,d)}}function Kc(a,b){wc(a.doc,oc(b,0),tc(a.doc,oc(b+1,0)))}function Nc(a,b,c,d){w.defaults[a]=b,c&&(Lc[a]=d?function(a,b,d){d!=Oc&&c(a,b,d)}:c)}function Tc(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c}function Uc(a,b,c){return a.startState?a.startState(b,c):!0}function Xc(a){return"string"==typeof a?Wc[a]:a}function Yc(a,b,c){function d(b){b=Xc(b);var e=b[a];if(e===!1)return"stop";if(null!=e&&c(e))return!0;if(b.nofallthrough)return"stop";var f=b.fallthrough;if(null==f)return!1;if("[object Array]"!=Object.prototype.toString.call(f))return d(f);for(var g=0,h=f.length;h>g;++g){var i=d(f[g]);if(i)return i}return!1}for(var e=0;e<b.length;++e){var f=d(b[e]);if(f)return f}}function Zc(a){var b=ef[a.keyCode];return"Ctrl"==b||"Alt"==b||"Shift"==b||"Mod"==b}function $c(a,b){var c=ef[a.keyCode];return null==c||a.altGraphKey?!1:(a.altKey&&(c="Alt-"+c),(s?a.metaKey:a.ctrlKey)&&(c="Ctrl-"+c),(s?a.ctrlKey:a.metaKey)&&(c="Cmd-"+c),!b&&a.shiftKey&&(c="Shift-"+c),c)}function _c(a,b){this.pos=this.start=0,this.string=a,this.tabSize=b||8}function ad(a,b){this.lines=[],this.type=b,this.doc=a}function bd(a,b,c,d,e){if(d&&d.shared)return dd(a,b,c,d,e);if(a.cm&&!a.cm.curOp)return vb(a.cm,bd)(a,b,c,d,e);var f=new ad(a,e);if("range"==e&&!qc(b,c))return f;d&&Le(d,f),f.replacedWith&&(f.collapsed=!0,f.replacedWith=Se("span",[f.replacedWith],"CodeMirror-widget")),f.collapsed&&(v=!0);var i,j,l,g=b.line,h=0,k=a.cm;if(a.iter(g,c.line+1,function(d){k&&f.collapsed&&!k.options.lineWrapping&&pd(a,d)==k.display.maxLine&&(l=!0);var e={from:null,to:null,marker:f};h+=d.text.length,g==b.line&&(e.from=b.ch,h-=b.ch),g==c.line&&(e.to=c.ch,h-=d.text.length-c.ch),f.collapsed&&(g==c.line&&(j=md(d,c.ch)),g==b.line?i=md(d,b.ch):Zd(d,0)),gd(d,e),++g}),f.collapsed&&a.iter(b.line,c.line+1,function(b){qd(a,b)&&Zd(b,0)}),f.readOnly&&(u=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory()),f.collapsed){if(i!=j)throw new Error("Inserting collapsed marker overlapping an existing one");f.size=h,f.atomic=!0}return k&&(l&&(k.curOp.updateMaxLine=!0),(f.className||f.startStyle||f.endStyle||f.collapsed)&&yb(k,b.line,c.line+1),f.atomic&&zc(k)),f}function cd(a,b){this.markers=a,this.primary=b;for(var c=0,d=this;c<a.length;++c)a[c].parent=this,te(a[c],"clear",function(){d.clear()})}function dd(a,b,c,d,e){d=Le(d),d.shared=!1;var f=[bd(a,b,c,d,e)],g=f[0];return Ud(a,function(a){f.push(bd(a,tc(a,b),tc(a,c),d,e));for(var h=0;h<a.linked.length;++h)if(a.linked[h].isParent)return;g=He(f)}),new cd(f,g)}function ed(a,b){if(a)for(var c=0;c<a.length;++c){var d=a[c];if(d.marker==b)return d}}function fd(a,b){for(var c,d=0;d<a.length;++d)a[d]!=b&&(c||(c=[])).push(a[d]);return c}function gd(a,b){a.markedSpans=a.markedSpans?a.markedSpans.concat([b]):[b],b.marker.attachLine(a)}function hd(a,b,c){if(a)for(var e,d=0;d<a.length;++d){var f=a[d],g=f.marker,h=null==f.from||(g.inclusiveLeft?f.from<=b:f.from<b);if(h||"bookmark"==g.type&&f.from==b&&(!c||!f.marker.insertLeft)){var i=null==f.to||(g.inclusiveRight?f.to>=b:f.to>b);(e||(e=[])).push({from:f.from,to:i?null:f.to,marker:g})}}return e}function id(a,b,c){if(a)for(var e,d=0;d<a.length;++d){var f=a[d],g=f.marker,h=null==f.to||(g.inclusiveRight?f.to>=b:f.to>b);if(h||"bookmark"==g.type&&f.from==b&&(!c||f.marker.insertLeft)){var i=null==f.from||(g.inclusiveLeft?f.from<=b:f.from<b);(e||(e=[])).push({from:i?null:f.from-b,to:null==f.to?null:f.to-b,marker:g})}}return e}function jd(a,b){var c=vc(a,b.from.line)&&Wd(a,b.from.line).markedSpans,d=vc(a,b.to.line)&&Wd(a,b.to.line).markedSpans;if(!c&&!d)return null;var e=b.from.ch,f=b.to.ch,g=pc(b.from,b.to),h=hd(c,e,g),i=id(d,f,g),j=1==b.text.length,k=He(b.text).length+(j?e:0);if(h)for(var l=0;l<h.length;++l){var m=h[l];if(null==m.to){var n=ed(i,m.marker);n?j&&(m.to=null==n.to?null:n.to+k):m.to=e}}if(i)for(var l=0;l<i.length;++l){var m=i[l];if(null!=m.to&&(m.to+=k),null==m.from){var n=ed(h,m.marker);n||(m.from=k,j&&(h||(h=[])).push(m))}else m.from+=k,j&&(h||(h=[])).push(m)}var o=[h];if(!j){var q,p=b.text.length-2;if(p>0&&h)for(var l=0;l<h.length;++l)null==h[l].to&&(q||(q=[])).push({from:null,to:null,marker:h[l].marker});for(var l=0;p>l;++l)o.push(q);o.push(i)}return o}function kd(a,b){var c=he(a,b),d=jd(a,b);if(!c)return d;if(!d)return c;for(var e=0;e<c.length;++e){var f=c[e],g=d[e];if(f&&g)a:for(var h=0;h<g.length;++h){for(var i=g[h],j=0;j<f.length;++j)if(f[j].marker==i.marker)continue a;f.push(i)}else g&&(c[e]=g)}return c}function ld(a,b,c){var d=null;if(a.iter(b.line,c.line+1,function(a){if(a.markedSpans)for(var b=0;b<a.markedSpans.length;++b){var c=a.markedSpans[b].marker;!c.readOnly||d&&-1!=Je(d,c)||(d||(d=[])).push(c)}}),!d)return null;for(var e=[{from:b,to:c}],f=0;f<d.length;++f)for(var g=d[f],h=g.find(),i=0;i<e.length;++i){var j=e[i];if(!qc(j.to,h.from)&&!qc(h.to,j.from)){var k=[i,1];(qc(j.from,h.from)||!g.inclusiveLeft&&pc(j.from,h.from))&&k.push({from:j.from,to:h.from}),(qc(h.to,j.to)||!g.inclusiveRight&&pc(j.to,h.to))&&k.push({from:h.to,to:j.to}),e.splice.apply(e,k),i+=k.length-1}}return e}function md(a,b){var d,c=v&&a.markedSpans;if(c)for(var e,f=0;f<c.length;++f)e=c[f],e.marker.collapsed&&(null==e.from||e.from<b)&&(null==e.to||e.to>b)&&(!d||d.width<e.marker.width)&&(d=e.marker);return d}function nd(a){return md(a,-1)}function od(a){return md(a,a.text.length+1)}function pd(a,b){for(var c;c=nd(b);)b=Wd(a,c.find().from.line);return b}function qd(a,b){var c=v&&b.markedSpans;if(c)for(var d,e=0;e<c.length;++e)if(d=c[e],d.marker.collapsed){if(null==d.from)return!0;if(0==d.from&&d.marker.inclusiveLeft&&rd(a,b,d))return!0}}function rd(a,b,c){if(null==c.to){var d=c.marker.find().to,e=Wd(a,d.line);return rd(a,e,ed(e.markedSpans,c.marker))}if(c.marker.inclusiveRight&&c.to==b.text.length)return!0;for(var f,g=0;g<b.markedSpans.length;++g)if(f=b.markedSpans[g],f.marker.collapsed&&f.from==c.to&&(f.marker.inclusiveLeft||c.marker.inclusiveRight)&&rd(a,b,f))return!0}function sd(a){var b=a.markedSpans;if(b){for(var c=0;c<b.length;++c)b[c].marker.detachLine(a);a.markedSpans=null}}function td(a,b){if(b){for(var c=0;c<b.length;++c)b[c].marker.attachLine(a);a.markedSpans=b}}function vd(a){return function(){var b=!this.cm.curOp;b&&tb(this.cm);try{var c=a.apply(this,arguments)}finally{b&&ub(this.cm)}return c}}function wd(a){return null!=a.height?a.height:(a.node.parentNode&&1==a.node.parentNode.nodeType||Ue(a.cm.display.measure,Se("div",[a.node],null,"position: relative")),a.height=a.node.offsetHeight)}function xd(a,b,c,d){var e=new ud(a,c,d);return e.noHScroll&&(a.display.alignWidgets=!0),Gc(a,b,function(b){if((b.widgets||(b.widgets=[])).push(e),e.line=b,!qd(a.doc,b)||e.showIfHidden){var c=ae(a,b)<a.display.scroller.scrollTop;Zd(b,b.height+wd(e)),c&&(a.curOp.updateScrollPos={scrollTop:a.doc.scrollTop+e.height,scrollLeft:a.doc.scrollLeft})}return!0}),e}function yd(a,b,c){var d={text:a};return td(d,b),d.height=c?c(d):1,d}function zd(a,b,c,d){a.text=b,a.stateAfter&&(a.stateAfter=null),a.styles&&(a.styles=null),null!=a.order&&(a.order=null),sd(a),td(a,c);var e=d?d(a):1;e!=a.height&&Zd(a,e),ye(a,"change")}function Ad(a){a.parent=null,sd(a)}function Bd(a,b,c,d,e){var f=a.options.flattenSpans,g="",h=null,i=new _c(b,a.options.tabSize);for(""==b&&c.blankLine&&c.blankLine(d);!i.eol();){var j=c.token(i,d);i.pos>5e3&&(f=!1,i.pos=Math.min(b.length,i.start+5e4),j=null);var k=i.current();i.start=i.pos,f&&h==j?g+=k:(g&&e(g,h),g=k,h=j)}g&&e(g,h)}function Cd(a,b,c){var d=[a.state.modeGen];Bd(a,b.text,a.doc.mode,c,function(a,b){d.push(a,b)});for(var e=0;e<a.state.overlays.length;++e){var f=a.state.overlays[e],g=1;Bd(a,b.text,f.mode,!0,function(a,b){for(var c=g,e=a.length;e;){var h=d[g],i=h.length;e>=i?e-=i:(d.splice(g,1,h.slice(0,e),d[g+1],h.slice(e)),e=0),g+=2}if(b)if(f.opaque)d.splice(c,g-c,a,b),g=c+2;else for(;g>c;c+=2){var h=d[c+1];d[c+1]=h?h+" "+b:b}})}return d}function Dd(a,b){return b.styles&&b.styles[0]==a.state.modeGen||(b.styles=Cd(a,b,b.stateAfter=cb(a,$d(b)))),b.styles}function Ed(a,b,c){var d=a.doc.mode,e=new _c(b.text,a.options.tabSize);for(""==b.text&&d.blankLine&&d.blankLine(c);!e.eol()&&e.pos<=5e3;)d.token(e,c),e.start=e.pos}function Gd(a){return a?Fd[a]||(Fd[a]="cm-"+a.replace(/ +/g," cm-")):null}function Hd(a,c,d){for(var e,g,h,f=c,i=!0;e=nd(f);)i=!1,f=Wd(a.doc,e.find().from.line),g||(g=f);var j={pre:Se("pre"),col:0,pos:0,display:!d,measure:null,addedOne:!1,cm:a};f.textClass&&(j.pre.className=f.textClass);do{j.measure=f==c&&d,j.pos=0,j.addToken=j.measure?Kd:Jd,d&&h&&f!=c&&!j.addedOne&&(d[0]=j.pre.appendChild(af(a.display.measure)),j.addedOne=!0);var k=Md(f,j,Dd(a,f));h=f==g,k&&(f=Wd(a.doc,k.to.line),i=!1)}while(k);d&&!j.addedOne&&(d[0]=j.pre.appendChild(i?Se("span","\xa0"):af(a.display.measure))),j.pre.firstChild||qd(a.doc,c)||j.pre.appendChild(document.createTextNode("\xa0"));var l;if(d&&b&&(l=be(f))){var m=l.length-1;l[m].from==l[m].to&&--m;var n=l[m],o=l[m-1];if(n.from+1==n.to&&o&&n.level<o.level){var p=d[j.pos-1];p&&p.parentNode.insertBefore(p.measureRight=af(a.display.measure),p.nextSibling)}}return j.pre}function Jd(a,b,c,d,e){if(b){if(Id.test(b))for(var f=document.createDocumentFragment(),g=0;;){Id.lastIndex=g;var h=Id.exec(b),i=h?h.index-g:b.length-g;if(i&&(f.appendChild(document.createTextNode(b.slice(g,g+i))),a.col+=i),!h)break;if(g+=i+1," "==h[0]){var j=a.cm.options.tabSize,k=j-a.col%j;f.appendChild(Se("span",Ge(k),"cm-tab")),a.col+=k}else{var l=Se("span","\u2022","cm-invalidchar");l.title="\\u"+h[0].charCodeAt(0).toString(16),f.appendChild(l),a.col+=1}}else{a.col+=b.length;var f=document.createTextNode(b)}if(c||d||e||a.measure){var m=c||"";return d&&(m+=d),e&&(m+=e),a.pre.appendChild(Se("span",[f],m))}a.pre.appendChild(f)}}function Kd(a,b,c,d,e){for(var f=0;f<b.length;++f){var g=b.charAt(f),h=0==f;g>="\ud800"&&"\udbff">g&&f<b.length-1?(g=b.slice(f,f+2),++f):f&&a.cm.options.lineWrapping&&Ye.test(b.slice(f-1,f+1))&&a.pre.appendChild(Se("wbr")),a.measure[a.pos]=Jd(a,g,c,h&&d,f==b.length-1&&e),a.pos+=g.length}b.length&&(a.addedOne=!0)}function Ld(a,b,c){c&&(a.display||(c=c.cloneNode(!0)),a.pre.appendChild(c),a.measure&&b&&(a.measure[a.pos]=c,a.addedOne=!0)),a.pos+=b}function Md(a,b,c){var d=a.markedSpans;if(d)for(var j,l,m,n,o,f=a.text,g=f.length,h=0,e=1,i="",k=0;;){if(k==h){l=m=n="",o=null,k=1/0;for(var p=null,q=0;q<d.length;++q){var r=d[q],s=r.marker;r.from<=h&&(null==r.to||r.to>h)?(null!=r.to&&k>r.to&&(k=r.to,m=""),s.className&&(l+=" "+s.className),s.startStyle&&r.from==h&&(n+=" "+s.startStyle),s.endStyle&&r.to==k&&(m+=" "+s.endStyle),s.collapsed&&(!o||o.marker.width<s.width)&&(o=r)):r.from>h&&k>r.from&&(k=r.from),"bookmark"==s.type&&r.from==h&&s.replacedWith&&(p=s.replacedWith)}if(o&&(o.from||0)==h&&(Ld(b,(null==o.to?g:o.to)-h,null!=o.from&&o.marker.replacedWith),null==o.to))return o.marker.find();p&&!o&&Ld(b,0,p)}if(h>=g)break;for(var t=Math.min(g,k);;){if(i){var u=h+i.length;if(!o){var v=u>t?i.slice(0,t-h):i;b.addToken(b,v,j?j+l:l,n,h+v.length==k?m:"")}if(u>=t){i=i.slice(t-h),h=t;break}h=u,n=""}i=c[e++],j=Gd(c[e++])}}else for(var e=1;e<c.length;e+=2)b.addToken(b,c[e],Gd(c[e+1]))}function Nd(a,b,c,d,e){function f(a){return c?c[a]:null}var g=b.from,h=b.to,i=b.text,j=Wd(a,g.line),k=Wd(a,h.line),l=He(i),m=f(i.length-1),n=h.line-g.line;if(0==g.ch&&0==h.ch&&""==l){for(var o=0,p=i.length-1,q=[];p>o;++o)q.push(yd(i[o],f(o),e));zd(k,k.text,m,e),n&&a.remove(g.line,n),q.length&&a.insert(g.line,q)}else if(j==k)if(1==i.length)zd(j,j.text.slice(0,g.ch)+l+j.text.slice(h.ch),m,e);else{for(var q=[],o=1,p=i.length-1;p>o;++o)q.push(yd(i[o],f(o),e));q.push(yd(l+j.text.slice(h.ch),m,e)),zd(j,j.text.slice(0,g.ch)+i[0],f(0),e),a.insert(g.line+1,q)}else if(1==i.length)zd(j,j.text.slice(0,g.ch)+i[0]+k.text.slice(h.ch),f(0),e),a.remove(g.line+1,n);else{zd(j,j.text.slice(0,g.ch)+i[0],f(0),e),zd(k,l+k.text.slice(h.ch),m,e);for(var o=1,p=i.length-1,q=[];p>o;++o)q.push(yd(i[o],f(o),e));n>1&&a.remove(g.line+1,n-1),a.insert(g.line+1,q)}ye(a,"change",a,b),yc(a,d.anchor,d.head,null,!0)}function Od(a){this.lines=a,this.parent=null;for(var b=0,c=a.length,d=0;c>b;++b)a[b].parent=this,d+=a[b].height;this.height=d}function Pd(a){this.children=a;for(var b=0,c=0,d=0,e=a.length;e>d;++d){var f=a[d];b+=f.chunkSize(),c+=f.height,f.parent=this}this.size=b,this.height=c,this.parent=null}function Ud(a,b,c){function d(a,e,f){if(a.linked)for(var g=0;g<a.linked.length;++g){var h=a.linked[g];if(h.doc!=e){var i=f&&h.sharedHist;(!c||i)&&(b(h.doc,i),d(h.doc,a,i))}}}d(a,null,!0)}function Vd(a,b){if(b.cm)throw new Error("This document is already in use.");a.doc=b,b.cm=a,B(a),y(a),a.options.lineWrapping||H(a),a.options.mode=b.modeOption,yb(a)}function Wd(a,b){for(b-=a.first;!a.lines;)for(var c=0;;++c){var d=a.children[c],e=d.chunkSize();if(e>b){a=d;break}b-=e}return a.lines[b]}function Xd(a,b,c){var d=[],e=b.line;return a.iter(b.line,c.line+1,function(a){var f=a.text;e==c.line&&(f=f.slice(0,c.ch)),e==b.line&&(f=f.slice(b.ch)),d.push(f),++e}),d}function Yd(a,b,c){var d=[];return a.iter(b,c,function(a){d.push(a.text)}),d}function Zd(a,b){for(var c=b-a.height,d=a;d;d=d.parent)d.height+=c}function $d(a){if(null==a.parent)return null;for(var b=a.parent,c=Je(b.lines,a),d=b.parent;d;b=d,d=d.parent)for(var e=0;d.children[e]!=b;++e)c+=d.children[e].chunkSize();return c+b.first}function _d(a,b){var c=a.first;a:do{for(var d=0,e=a.children.length;e>d;++d){var f=a.children[d],g=f.height;if(g>b){a=f;continue a}b-=g,c+=f.chunkSize()}return c}while(!a.lines);for(var d=0,e=a.lines.length;e>d;++d){var h=a.lines[d],i=h.height;if(i>b)break;b-=i}return c+d}function ae(a,b){b=pd(a.doc,b);for(var c=0,d=b.parent,e=0;e<d.lines.length;++e){var f=d.lines[e];if(f==b)break;c+=f.height}for(var g=d.parent;g;d=g,g=d.parent)for(var e=0;e<g.children.length;++e){var h=g.children[e];if(h==d)break;c+=h.height}return c}function be(a){var b=a.order;return null==b&&(b=a.order=pf(a.text)),b}function ce(){return{done:[],undone:[],undoDepth:1/0,lastTime:0,lastOp:null,lastOrigin:null,dirtyCounter:0}}function de(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,c),Math.min(a.first+a.size,d),function(c){c.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans),++f})}function ee(a,b){var c={from:b.from,to:dc(b),text:Xd(a,b.from,b.to)};return de(a,c,b.from.line,b.to.line+1),Ud(a,function(a){de(a,c,b.from.line,b.to.line+1)},!0),c}function fe(a,b,c,d){var e=a.history;e.undone.length=0;var f=+new Date,g=He(e.done);if(g&&(e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&e.lastTime>f-600||"*"==b.origin.charAt(0)))){var h=He(g.changes);pc(b.from,b.to)&&pc(b.from,h.to)?h.to=dc(b):g.changes.push(ee(a,b)),g.anchorAfter=c.anchor,g.headAfter=c.head}else{for(g={changes:[ee(a,b)],anchorBefore:a.sel.anchor,headBefore:a.sel.head,anchorAfter:c.anchor,headAfter:c.head},e.done.push(g);e.done.length>e.undoDepth;)e.done.shift();e.dirtyCounter<0?e.dirtyCounter=0/0:e.dirtyCounter++}e.lastTime=f,e.lastOp=d,e.lastOrigin=b.origin}function ge(a){if(!a)return null;for(var c,b=0;b<a.length;++b)a[b].marker.explicitlyCleared?c||(c=a.slice(0,b)):c&&c.push(a[b]);return c?c.length?c:null:a}function he(a,b){var c=b["spans_"+a.id];if(!c)return null;for(var d=0,e=[];d<b.text.length;++d)e.push(ge(c[d]));return e}function ie(a,b){for(var c=0,d=[];c<a.length;++c){var e=a[c],f=e.changes,g=[];d.push({changes:g,anchorBefore:e.anchorBefore,headBefore:e.headBefore,anchorAfter:e.anchorAfter,headAfter:e.headAfter});for(var h=0;h<f.length;++h){var j,i=f[h];if(g.push({from:i.from,to:i.to,text:i.text}),b)for(var k in i)(j=k.match(/^spans_(\d+)$/))&&Je(b,Number(j[1]))>-1&&(He(g)[k]=i[k],delete i[k])}}return d}function je(a,b,c,d){c<a.line?a.line+=d:b<a.line&&(a.line=b,a.ch=0)}function ke(a,b,c,d){for(var e=0;e<a.length;++e){for(var f=a[e],g=!0,h=0;h<f.changes.length;++h){var i=f.changes[h];if(f.copied||(i.from=rc(i.from),i.to=rc(i.to)),c<i.from.line)i.from.line+=d,i.to.line+=d;else if(b<=i.to.line){g=!1;break}}f.copied||(f.anchorBefore=rc(f.anchorBefore),f.headBefore=rc(f.headBefore),f.anchorAfter=rc(f.anchorAfter),f.readAfter=rc(f.headAfter),f.copied=!0),g?(je(f.anchorBefore),je(f.headBefore),je(f.anchorAfter),je(f.headAfter)):(a.splice(0,e+1),e=0)}}function le(a,b){var c=b.from.line,d=b.to.line,e=b.text.length-(d-c)-1;ke(a.done,c,d,e),ke(a.undone,c,d,e)}function me(){qe(this)}function ne(a){return a.stop||(a.stop=me),a}function oe(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function pe(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}function qe(a){oe(a),pe(a)}function re(a){return a.target||a.srcElement}function se(a){var b=a.which;return null==b&&(1&a.button?b=1:2&a.button?b=3:4&a.button&&(b=2)),p&&a.ctrlKey&&1==b&&(b=3),b}function te(a,b,c){if(a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent)a.attachEvent("on"+b,c);else{var d=a._handlers||(a._handlers={}),e=d[b]||(d[b]=[]);e.push(c)}}function ue(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,!1);else if(a.detachEvent)a.detachEvent("on"+b,c);else{var d=a._handlers&&a._handlers[b];if(!d)return;for(var e=0;e<d.length;++e)if(d[e]==c){d.splice(e,1);break}}}function ve(a,b){var c=a._handlers&&a._handlers[b];if(c)for(var d=Array.prototype.slice.call(arguments,2),e=0;e<c.length;++e)c[e].apply(null,d)}function ye(a,b){function e(a){return function(){a.apply(null,d)}}var c=a._handlers&&a._handlers[b];if(c){var d=Array.prototype.slice.call(arguments,2);we||(++xe,we=[],setTimeout(ze,0));for(var f=0;f<c.length;++f)we.push(e(c[f]))}}function ze(){--xe;var a=we;we=null;for(var b=0;b<a.length;++b)a[b]()}function Ae(a,b){var c=a._handlers&&a._handlers[b];return c&&c.length>0}function De(){this.id=null}function Ee(a,b,c){null==b&&(b=a.search(/[^\s\u00a0]/),-1==b&&(b=a.length));for(var d=0,e=0;b>d;++d)" "==a.charAt(d)?e+=c-e%c:++e;return e}function Ge(a){for(;Fe.length<=a;)Fe.push(He(Fe)+" ");return Fe[a]}function He(a){return a[a.length-1]}function Ie(a){n?(a.selectionStart=0,a.selectionEnd=a.value.length):a.select()}function Je(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;d>c;++c)if(a[c]==b)return c;return-1}function Ke(a,b){function c(){}c.prototype=a;var d=new c;return b&&Le(b,d),d}function Le(a,b){b||(b={});for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function Me(a){for(var b=[],c=0;a>c;++c)b.push(void 0);return b}function Ne(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(null,b)}}function Pe(a){return/\w/.test(a)||a>"\x80"&&(a.toUpperCase()!=a.toLowerCase()||Oe.test(a))}function Qe(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;
|
|
return!0}function Se(a,b,c,d){var e=document.createElement(a);if(c&&(e.className=c),d&&(e.style.cssText=d),"string"==typeof b)Ve(e,b);else if(b)for(var f=0;f<b.length;++f)e.appendChild(b[f]);return e}function Te(a){if(b)for(;a.firstChild;)a.removeChild(a.firstChild);else a.innerHTML="";return a}function Ue(a,b){return Te(a).appendChild(b)}function Ve(a,b){d?(a.innerHTML="",a.appendChild(document.createTextNode(b))):a.textContent=b}function We(a){return a.getBoundingClientRect()}function $e(a){if(null!=Ze)return Ze;var b=Se("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");return Ue(a,b),b.offsetWidth&&(Ze=b.offsetHeight-b.clientHeight),Ze||0}function af(a){if(null==_e){var b=Se("span","\u200b");Ue(a,Se("span",[b,document.createTextNode("x")])),0!=a.firstChild.offsetHeight&&(_e=b.offsetWidth<=1&&b.offsetHeight>2&&!c)}return _e?Se("span","\u200b"):Se("span","\xa0",null,"display: inline-block; width: 1px; margin-right: -1px")}function ff(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=0;e<a.length;++e){var f=a[e];(f.from<c&&f.to>b||b==c&&f.to==b)&&d(Math.max(f.from,b),Math.min(f.to,c),1==f.level?"rtl":"ltr")}}function gf(a){return a.level%2?a.to:a.from}function hf(a){return a.level%2?a.from:a.to}function jf(a){var b=be(a);return b?gf(b[0]):0}function kf(a){var b=be(a);return b?hf(He(b)):a.text.length}function lf(a,b){var c=Wd(a.doc,b),d=pd(a.doc,c);d!=c&&(b=$d(d));var e=be(d),f=e?e[0].level%2?kf(d):jf(d):0;return oc(b,f)}function mf(a,b){for(var c,d;c=od(d=Wd(a.doc,b));)b=c.find().to.line;var e=be(d),f=e?e[0].level%2?jf(d):kf(d):d.text.length;return oc(b,f)}function nf(a,b,c,d){var e=be(a);if(!e)return of(a,b,c,d);for(var f=d?function(b,c){do b+=c;while(b>0&&Re.test(a.text.charAt(b)));return b}:function(a,b){return a+b},g=e[0].level,h=0;h<e.length;++h){var i=e[h],j=i.level%2==g;if(i.from<b&&i.to>b||j&&(i.from==b||i.to==b))break}for(var k=f(b,i.level%2?-c:c);null!=k;)if(i.level%2==g){if(!(k<i.from||k>i.to))break;i=e[h+=c],k=i&&(c>0==i.level%2?f(i.to,-1):f(i.from,1))}else if(k==gf(i))i=e[--h],k=i&&hf(i);else{if(k!=hf(i))break;i=e[++h],k=i&&gf(i)}return 0>k||k>a.text.length?null:k}function of(a,b,c,d){var e=b+c;if(d)for(;e>0&&Re.test(a.text.charAt(e));)e+=c;return 0>e||e>a.text.length?null:e}var a=/gecko\/\d/i.test(navigator.userAgent),b=/MSIE \d/.test(navigator.userAgent),c=b&&(null==document.documentMode||document.documentMode<8),d=b&&(null==document.documentMode||document.documentMode<9),e=/WebKit\//.test(navigator.userAgent),f=e&&/Qt\/\d+\.\d+/.test(navigator.userAgent),g=/Chrome\//.test(navigator.userAgent),h=/Opera\//.test(navigator.userAgent),i=/Apple Computer/.test(navigator.vendor),j=/KHTML\//.test(navigator.userAgent),k=/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent),l=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),m=/PhantomJS/.test(navigator.userAgent),n=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),o=n||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),p=n||/Mac/.test(navigator.platform),q=/windows/i.test(navigator.platform),r=h&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);r&&(r=Number(r[1]));var pb,Ib,Jb,s=p&&(f||h&&(null==r||12.11>r)),t=a||b&&!d,u=!1,v=!1,sb=0,Qb=0,Rb=null;b?Rb=-.53:a?Rb=15:g?Rb=-.7:i&&(Rb=-1/3);var Vb,bc,Yb=null;w.Pos=oc,w.prototype={focus:function(){window.focus(),Db(this),_b(this),Ab(this)},setOption:function(a,b){var c=this.options,d=c[a];(c[a]!=b||"mode"==a)&&(c[a]=b,Lc.hasOwnProperty(a)&&vb(this,Lc[a])(this,b,d))},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a){this.state.keyMaps.push(a)},removeKeyMap:function(a){for(var b=this.state.keyMaps,c=0;c<b.length;++c)if(("string"==typeof a?b[c].name:b[c])==a)return b.splice(c,1),!0},addOverlay:vb(null,function(a,b){var c=a.token?a:w.getMode(this.options,a);if(c.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:c,modeSpec:a,opaque:b&&b.opaque}),this.state.modeGen++,yb(this)}),removeOverlay:vb(null,function(a){for(var b=this.state.overlays,c=0;c<b.length;++c)if(b[c].modeSpec==a)return b.splice(c,1),this.state.modeGen++,yb(this),void 0}),indentLine:vb(null,function(a,b,c){"string"!=typeof b&&(b=null==b?this.options.smartIndent?"smart":"prev":b?"add":"subtract"),vc(this.doc,a)&&Fc(this,a,b,c)}),indentSelection:vb(null,function(a){var b=this.doc.sel;if(pc(b.from,b.to))return Fc(this,b.from.line,a);for(var c=b.to.line-(b.to.ch?0:1),d=b.from.line;c>=d;++d)Fc(this,d,a)}),getTokenAt:function(a){var b=this.doc;a=tc(b,a);for(var c=cb(this,a.line),d=this.doc.mode,e=Wd(b,a.line),f=new _c(e.text,this.options.tabSize);f.pos<a.ch&&!f.eol();){f.start=f.pos;var g=d.token(f,c)}return{start:f.start,end:f.pos,string:f.current(),className:g||null,type:g||null,state:c}},getStateAfter:function(a){var b=this.doc;return a=sc(b,null==a?b.first+b.size-1:a),cb(this,a+1)},cursorCoords:function(a,b){var c,d=this.doc.sel;return c=null==a?d.head:"object"==typeof a?tc(this.doc,a):a?d.from:d.to,lb(this,c,b||"page")},charCoords:function(a,b){return kb(this,tc(this.doc,a),b||"page")},coordsChar:function(a){var b=We(this.display.lineSpace),c=window.pageYOffset||(document.documentElement||document.body).scrollTop,d=window.pageXOffset||(document.documentElement||document.body).scrollLeft;return nb(this,a.left-b.left-d,a.top-b.top-c)},defaultTextHeight:function(){return qb(this.display)},setGutterMarker:vb(null,function(a,b,c){return Gc(this,a,function(a){var d=a.gutterMarkers||(a.gutterMarkers={});return d[b]=c,!c&&Qe(d)&&(a.gutterMarkers=null),!0})}),clearGutter:vb(null,function(a){var b=this,c=b.doc,d=c.first;c.iter(function(c){c.gutterMarkers&&c.gutterMarkers[a]&&(c.gutterMarkers[a]=null,yb(b,d,d+1),Qe(c.gutterMarkers)&&(c.gutterMarkers=null)),++d})}),addLineClass:vb(null,function(a,b,c){return Gc(this,a,function(a){var d="text"==b?"textClass":"background"==b?"bgClass":"wrapClass";if(a[d]){if(new RegExp("\\b"+c+"\\b").test(a[d]))return!1;a[d]+=" "+c}else a[d]=c;return!0})}),removeLineClass:vb(null,function(a,b,c){return Gc(this,a,function(a){var d="text"==b?"textClass":"background"==b?"bgClass":"wrapClass",e=a[d];if(!e)return!1;if(null==c)a[d]=null;else{var f=e.replace(new RegExp("^"+c+"\\b\\s*|\\s*\\b"+c+"\\b"),"");if(f==e)return!1;a[d]=f||null}return!0})}),addLineWidget:vb(null,function(a,b,c){return xd(this,a,b,c)}),removeLineWidget:function(a){a.clear()},lineInfo:function(a){if("number"==typeof a){if(!vc(this.doc,a))return null;var b=a;if(a=Wd(this.doc,a),!a)return null}else{var b=$d(a);if(null==b)return null}return{line:b,handle:a,text:a.text,gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},getViewport:function(){return{from:this.display.showingFrom,to:this.display.showingTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=lb(this,tc(this.doc,a));var g=a.bottom,h=a.left;if(b.style.position="absolute",f.sizer.appendChild(b),"over"==d)g=a.top;else if("above"==d||"near"==d){var i=Math.max(f.wrapper.clientHeight,this.doc.height),j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);("above"==d||a.bottom+b.offsetHeight>i)&&a.top>b.offsetHeight?g=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=i&&(g=a.bottom),h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+db(f)+"px",b.style.left=b.style.right="","right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px"),c&&Dc(this,h,g,h+b.offsetWidth,g+b.offsetHeight)},triggerOnKeyDown:vb(null,Zb),execCommand:function(a){return Vc[a](this)},findPosH:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);for(var f=0,g=tc(this.doc,a);b>f&&(g=Hc(this.doc,g,e,c,d),!g.hitSide);++f);return g},moveH:vb(null,function(a,b){var d,c=this.doc.sel;d=c.shift||c.extend||pc(c.from,c.to)?Hc(this.doc,c.head,a,b,this.options.rtlMoveVisually):0>a?c.from:c.to,wc(this.doc,d,d,a)}),deleteH:vb(null,function(a,b){var c=this.doc.sel;pc(c.from,c.to)?nc(this.doc,"",c.from,Hc(this.doc,c.head,a,b,!1),"+delete"):nc(this.doc,"",c.from,c.to,"+delete"),this.curOp.userSelChange=!0}),findPosV:function(a,b,c,d){var e=1,f=d;0>b&&(e=-1,b=-b);for(var g=0,h=tc(this.doc,a);b>g;++g){var i=lb(this,h,"div");if(null==f?f=i.left:i.left=f,h=Ic(this,i,e,c),h.hitSide)break}return h},moveV:vb(null,function(a,b){var c=this.doc.sel,d=lb(this,c.head,"div");null!=c.goalColumn&&(d.left=c.goalColumn);var e=Ic(this,d,a,b);"page"==b&&(this.display.scrollbarV.scrollTop+=kb(this,e,"div").top-d.top),wc(this.doc,e,e,a),c.goalColumn=d.left}),toggleOverwrite:function(){(this.state.overwrite=!this.state.overwrite)?this.display.cursor.className+=" CodeMirror-overwrite":this.display.cursor.className=this.display.cursor.className.replace(" CodeMirror-overwrite","")},scrollTo:vb(null,function(a,b){this.curOp.updateScrollPos={scrollLeft:a,scrollTop:b}}),getScrollInfo:function(){var a=this.display.scroller,b=Be;return{left:a.scrollLeft,top:a.scrollTop,height:a.scrollHeight-b,width:a.scrollWidth-b,clientHeight:a.clientHeight-b,clientWidth:a.clientWidth-b}},scrollIntoView:function(a){"number"==typeof a&&(a=oc(a,0)),a&&null==a.line?Dc(this,a.left,a.top,a.right,a.bottom):(a=a?tc(this.doc,a):this.doc.sel.head,Cc(this,a))},setSize:function(a,b){function c(a){return"number"==typeof a||/^\d+$/.test(String(a))?a+"px":a}null!=a&&(this.display.wrapper.style.width=c(a)),null!=b&&(this.display.wrapper.style.height=c(b)),this.refresh()},on:function(a,b){te(this,a,b)},off:function(a,b){ue(this,a,b)},operation:function(a){return xb(this,a)},refresh:vb(null,function(){ib(this),this.curOp.updateScrollPos={scrollTop:this.doc.scrollTop,scrollLeft:this.doc.scrollLeft},yb(this)}),swapDoc:vb(null,function(a){var b=this.doc;return b.cm=null,Vd(this,a),ib(this),this.curOp.updateScrollPos={scrollTop:a.scrollTop,scrollLeft:a.scrollLeft},b}),getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};var Lc=w.optionHandlers={},Mc=w.defaults={},Oc=w.Init={toString:function(){return"CodeMirror.Init"}};Nc("value","",function(a,b){a.setValue(b)},!0),Nc("mode",null,function(a,b){a.doc.modeOption=b,y(a)},!0),Nc("indentUnit",2,y,!0),Nc("indentWithTabs",!1),Nc("smartIndent",!0),Nc("tabSize",4,function(a){y(a),ib(a),yb(a)},!0),Nc("electricChars",!0),Nc("rtlMoveVisually",!q),Nc("theme","default",function(a){D(a),E(a)},!0),Nc("keyMap","default",C),Nc("extraKeys",null),Nc("onKeyEvent",null),Nc("onDragEvent",null),Nc("lineWrapping",!1,z,!0),Nc("gutters",[],function(a){I(a.options),E(a)},!0),Nc("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?O(a.display)+"px":"0",a.refresh()},!0),Nc("lineNumbers",!1,function(a){I(a.options),E(a)},!0),Nc("firstLineNumber",1,E,!0),Nc("lineNumberFormatter",function(a){return a},E,!0),Nc("showCursorWhenSelecting",!1,X,!0),Nc("readOnly",!1,function(a,b){"nocursor"==b?(ac(a),a.display.input.blur()):b||Cb(a,!0)}),Nc("dragDrop",!0),Nc("cursorBlinkRate",530),Nc("cursorHeight",1),Nc("workTime",100),Nc("workDelay",100),Nc("flattenSpans",!0),Nc("pollInterval",100),Nc("undoDepth",40,function(a,b){a.doc.history.undoDepth=b}),Nc("viewportMargin",10,function(a){a.refresh()},!0),Nc("tabindex",null,function(a,b){a.display.input.tabIndex=b||""}),Nc("autofocus",null);var Pc=w.modes={},Qc=w.mimeModes={};w.defineMode=function(a,b){if(w.defaults.mode||"null"==a||(w.defaults.mode=a),arguments.length>2){b.dependencies=[];for(var c=2;c<arguments.length;++c)b.dependencies.push(arguments[c])}Pc[a]=b},w.defineMIME=function(a,b){Qc[a]=b},w.resolveMode=function(a){if("string"==typeof a&&Qc.hasOwnProperty(a))a=Qc[a];else if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return w.resolveMode("application/xml");return"string"==typeof a?{name:a}:a||{name:"null"}},w.getMode=function(a,b){b=w.resolveMode(b);var c=Pc[b.name];if(!c)return w.getMode(a,"text/plain");var d=c(a,b);if(Rc.hasOwnProperty(b.name)){var e=Rc[b.name];for(var f in e)e.hasOwnProperty(f)&&(d.hasOwnProperty(f)&&(d["_"+f]=d[f]),d[f]=e[f])}return d.name=b.name,d},w.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}}),w.defineMIME("text/plain","null");var Rc=w.modeExtensions={};w.extendMode=function(a,b){var c=Rc.hasOwnProperty(a)?Rc[a]:Rc[a]={};Le(b,c)},w.defineExtension=function(a,b){w.prototype[a]=b},w.defineOption=Nc;var Sc=[];w.defineInitHook=function(a){Sc.push(a)},w.copyState=Tc,w.startState=Uc,w.innerMode=function(a,b){for(;a.innerMode;){var c=a.innerMode(b);b=c.state,a=c.mode}return c||{mode:a,state:b}};var Vc=w.commands={selectAll:function(a){a.setSelection(oc(a.firstLine(),0),oc(a.lastLine()))},killLine:function(a){var b=a.getCursor(!0),c=a.getCursor(!1),d=!pc(b,c);d||a.getLine(b.line).length!=b.ch?a.replaceRange("",b,d?c:oc(b.line),"+delete"):a.replaceRange("",b,oc(b.line+1,0),"+delete")},deleteLine:function(a){var b=a.getCursor().line;a.replaceRange("",oc(b,0),oc(b),"+delete")},undo:function(a){a.undo()},redo:function(a){a.redo()},goDocStart:function(a){a.extendSelection(oc(a.firstLine(),0))},goDocEnd:function(a){a.extendSelection(oc(a.lastLine()))},goLineStart:function(a){a.extendSelection(lf(a,a.getCursor().line))},goLineStartSmart:function(a){var b=a.getCursor(),c=lf(a,b.line),d=a.getLineHandle(c.line),e=be(d);if(e&&0!=e[0].level)a.extendSelection(c);else{var f=Math.max(0,d.text.search(/\S/)),g=b.line==c.line&&b.ch<=f&&b.ch;a.extendSelection(oc(c.line,g?0:f))}},goLineEnd:function(a){a.extendSelection(mf(a,a.getCursor().line))},goLineUp:function(a){a.moveV(-1,"line")},goLineDown:function(a){a.moveV(1,"line")},goPageUp:function(a){a.moveV(-1,"page")},goPageDown:function(a){a.moveV(1,"page")},goCharLeft:function(a){a.moveH(-1,"char")},goCharRight:function(a){a.moveH(1,"char")},goColumnLeft:function(a){a.moveH(-1,"column")},goColumnRight:function(a){a.moveH(1,"column")},goWordLeft:function(a){a.moveH(-1,"word")},goWordRight:function(a){a.moveH(1,"word")},delCharBefore:function(a){a.deleteH(-1,"char")},delCharAfter:function(a){a.deleteH(1,"char")},delWordBefore:function(a){a.deleteH(-1,"word")},delWordAfter:function(a){a.deleteH(1,"word")},indentAuto:function(a){a.indentSelection("smart")},indentMore:function(a){a.indentSelection("add")},indentLess:function(a){a.indentSelection("subtract")},insertTab:function(a){a.replaceSelection(" ","end","+input")},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):a.replaceSelection(" ","end","+input")},transposeChars:function(a){var b=a.getCursor(),c=a.getLine(b.line);b.ch>0&&b.ch<c.length-1&&a.replaceRange(c.charAt(b.ch)+c.charAt(b.ch-1),oc(b.line,b.ch-1),oc(b.line,b.ch+1))},newlineAndIndent:function(a){vb(a,function(){a.replaceSelection("\n","end","+input"),a.indentLine(a.getCursor().line,null,!0)})()},toggleOverwrite:function(a){a.toggleOverwrite()}},Wc=w.keyMap={};Wc.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite"},Wc.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Alt-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ctrl-Left":"goWordLeft","Ctrl-Right":"goWordRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delWordBefore","Ctrl-Delete":"delWordAfter","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",fallthrough:"basic"},Wc.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goWordLeft","Alt-Right":"goWordRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","Alt-Backspace":"delWordBefore","Ctrl-Alt-Backspace":"delWordAfter","Alt-Delete":"delWordAfter","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",fallthrough:["basic","emacsy"]},Wc["default"]=p?Wc.macDefault:Wc.pcDefault,Wc.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"},w.lookupKey=Yc,w.isModifierKey=Zc,w.keyName=$c,w.fromTextArea=function(a,b){function e(){a.value=i.getValue()}if(b||(b={}),b.value=a.value,!b.tabindex&&a.tabindex&&(b.tabindex=a.tabindex),null==b.autofocus){var c=document.body;try{c=document.activeElement}catch(d){}b.autofocus=c==a||null!=a.getAttribute("autofocus")&&c==document.body}if(a.form){te(a.form,"submit",e);var f=a.form,g=f.submit;try{var h=f.submit=function(){e(),f.submit=g,f.submit(),f.submit=h}}catch(d){}}a.style.display="none";var i=w(function(b){a.parentNode.insertBefore(b,a.nextSibling)},b);return i.save=e,i.getTextArea=function(){return a},i.toTextArea=function(){e(),a.parentNode.removeChild(i.getWrapperElement()),a.style.display="",a.form&&(ue(a.form,"submit",e),"function"==typeof a.form.submit&&(a.form.submit=g))},i},_c.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return 0==this.pos},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(a){var b=this.string.charAt(this.pos);if("string"==typeof a)var c=b==a;else var c=b&&(a.test?a.test(b):a(b));return c?(++this.pos,b):void 0},eatWhile:function(a){for(var b=this.pos;this.eat(a););return this.pos>b},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){var b=this.string.indexOf(a,this.pos);return b>-1?(this.pos=b,!0):void 0},backUp:function(a){this.pos-=a},column:function(){return Ee(this.string,this.start,this.tabSize)},indentation:function(){return Ee(this.string,null,this.tabSize)},match:function(a,b,c){if("string"!=typeof a){var e=this.string.slice(this.pos).match(a);return e&&e.index>0?null:(e&&b!==!1&&(this.pos+=e[0].length),e)}var d=function(a){return c?a.toLowerCase():a};return d(this.string).indexOf(d(a),this.pos)==this.pos?(b!==!1&&(this.pos+=a.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)}},w.StringStream=_c,w.TextMarker=ad,ad.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;b&&tb(a);for(var c=null,d=null,e=0;e<this.lines.length;++e){var f=this.lines[e],g=ed(f.markedSpans,this);null!=g.to&&(d=$d(f)),f.markedSpans=fd(f.markedSpans,g),null!=g.from?c=$d(f):this.collapsed&&!qd(this.doc,f)&&a&&Zd(f,qb(a.display))}if(a&&this.collapsed&&!a.options.lineWrapping)for(var e=0;e<this.lines.length;++e){var h=pd(a.doc,this.lines[e]),i=G(a.doc,h);i>a.display.maxLineLength&&(a.display.maxLine=h,a.display.maxLineLength=i,a.display.maxLineChanged=!0)}null!=c&&a&&yb(a,c,d+1),this.lines.length=0,this.explicitlyCleared=!0,this.collapsed&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&zc(a)),b&&ub(a),ye(this,"clear")}},ad.prototype.find=function(){for(var a,b,c=0;c<this.lines.length;++c){var d=this.lines[c],e=ed(d.markedSpans,this);if(null!=e.from||null!=e.to){var f=$d(d);null!=e.from&&(a=oc(f,e.from)),null!=e.to&&(b=oc(f,e.to))}}return"bookmark"==this.type?a:a&&{from:a,to:b}},ad.prototype.getOptions=function(a){var b=this.replacedWith;return{className:this.className,inclusiveLeft:this.inclusiveLeft,inclusiveRight:this.inclusiveRight,atomic:this.atomic,collapsed:this.collapsed,clearOnEnter:this.clearOnEnter,replacedWith:a?b&&b.cloneNode(!0):b,readOnly:this.readOnly,startStyle:this.startStyle,endStyle:this.endStyle}},ad.prototype.attachLine=function(a){if(!this.lines.length&&this.doc.cm){var b=this.doc.cm.curOp;b.maybeHiddenMarkers&&-1!=Je(b.maybeHiddenMarkers,this)||(b.maybeUnhiddenMarkers||(b.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(a)},ad.prototype.detachLine=function(a){if(this.lines.splice(Je(this.lines,a),1),!this.lines.length&&this.doc.cm){var b=this.doc.cm.curOp;(b.maybeHiddenMarkers||(b.maybeHiddenMarkers=[])).push(this)}},w.SharedTextMarker=cd,cd.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var a=0;a<this.markers.length;++a)this.markers[a].clear();ye(this,"clear")}},cd.prototype.find=function(){return this.primary.find()},cd.prototype.getOptions=function(a){var b=this.primary.getOptions(a);return b.shared=!0,b};var ud=w.LineWidget=function(a,b,c){for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.cm=a,this.node=b};ud.prototype.clear=vd(function(){var a=this.line.widgets,b=$d(this.line);if(null!=b&&a){for(var c=0;c<a.length;++c)a[c]==this&&a.splice(c--,1);a.length||(this.line.widgets=null),Zd(this.line,Math.max(0,this.line.height-wd(this))),yb(this.cm,b,b+1)}}),ud.prototype.changed=vd(function(){var a=this.height;this.height=null;var b=wd(this)-a;if(b){Zd(this.line,this.line.height+b);var c=$d(this.line);yb(this.cm,c,c+1)}});var Fd={},Id=/[\t\u0000-\u0019\u200b\u2028\u2029\uFEFF]/g;Od.prototype={chunkSize:function(){return this.lines.length},removeInner:function(a,b){for(var c=a,d=a+b;d>c;++c){var e=this.lines[c];this.height-=e.height,Ad(e),ye(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.splice.apply(a,[a.length,0].concat(this.lines))},insertInner:function(a,b,c){this.height+=c,this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(var d=0,e=b.length;e>d;++d)b[d].parent=this},iterN:function(a,b,c){for(var d=a+b;d>a;++a)if(c(this.lines[a]))return!0}},Pd.prototype={chunkSize:function(){return this.size},removeInner:function(a,b){this.size-=b;for(var c=0;c<this.children.length;++c){var d=this.children[c],e=d.chunkSize();if(e>a){var f=Math.min(b,e-a),g=d.height;if(d.removeInner(a,f),this.height-=g-d.height,e==f&&(this.children.splice(c--,1),d.parent=null),0==(b-=f))break;a=0}else a-=e}if(this.size-b<25){var h=[];this.collapse(h),this.children=[new Od(h)],this.children[0].parent=this}},collapse:function(a){for(var b=0,c=this.children.length;c>b;++b)this.children[b].collapse(a)},insertInner:function(a,b,c){this.size+=b.length,this.height+=c;for(var d=0,e=this.children.length;e>d;++d){var f=this.children[d],g=f.chunkSize();if(g>=a){if(f.insertInner(a,b,c),f.lines&&f.lines.length>50){for(;f.lines.length>50;){var h=f.lines.splice(f.lines.length-25,25),i=new Od(h);f.height-=i.height,this.children.splice(d+1,0,i),i.parent=this}this.maybeSpill()}break}a-=g}},maybeSpill:function(){if(!(this.children.length<=10)){var a=this;do{var b=a.children.splice(a.children.length-5,5),c=new Pd(b);if(a.parent){a.size-=c.size,a.height-=c.height;var e=Je(a.parent.children,a);a.parent.children.splice(e+1,0,c)}else{var d=new Pd(a.children);d.parent=a,a.children=[d,c],a=d}c.parent=a.parent}while(a.children.length>10);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=0,e=this.children.length;e>d;++d){var f=this.children[d],g=f.chunkSize();if(g>a){var h=Math.min(b,g-a);if(f.iterN(a,h,c))return!0;if(0==(b-=h))break;a=0}else a-=g}}};var Qd=0,Rd=w.Doc=function(a,b,c){if(!(this instanceof Rd))return new Rd(a,b,c);null==c&&(c=0),Pd.call(this,[new Od([yd("",null)])]),this.first=c,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.history=ce(),this.frontier=c;var d=oc(c,0);this.sel={from:d,to:d,head:d,anchor:d,shift:!1,extend:!1,goalColumn:null},this.id=++Qd,this.modeOption=b,"string"==typeof a&&(a=bf(a)),Nd(this,{from:d,to:d,text:a},null,{head:d,anchor:d})};Rd.prototype=Ke(Pd.prototype,{iter:function(a,b,c){c?this.iterN(a-this.first,b-a,c):this.iterN(this.first,this.first+this.size,a)},insert:function(a,b){for(var c=0,d=0,e=b.length;e>d;++d)c+=b[d].height;this.insertInner(a-this.first,b,c)},remove:function(a,b){this.removeInner(a-this.first,b)},getValue:function(a){var b=Yd(this,this.first,this.first+this.size);return a===!1?b:b.join(a||"\n")},setValue:function(a){var b=oc(this.first,0),c=this.first+this.size-1;hc(this,{from:b,to:oc(c,Wd(this,c).text.length),text:bf(a),origin:"setValue"},{head:b,anchor:b},!0)},replaceRange:function(a,b,c,d){b=tc(this,b),c=c?tc(this,c):b,nc(this,a,b,c,d)},getRange:function(a,b,c){var d=Xd(this,tc(this,a),tc(this,b));return c===!1?d:d.join(c||"\n")},getLine:function(a){var b=this.getLineHandle(a);return b&&b.text},setLine:function(a,b){vc(this,a)&&nc(this,b,oc(a,0),tc(this,oc(a)))},removeLine:function(a){vc(this,a)&&nc(this,"",oc(a,0),tc(this,oc(a+1,0)))},getLineHandle:function(a){return vc(this,a)?Wd(this,a):void 0},getLineNumber:function(a){return $d(a)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(a){return tc(this,a)},getCursor:function(a){var c,b=this.sel;return c=null==a||"head"==a?b.head:"anchor"==a?b.anchor:"end"==a||a===!1?b.to:b.from,rc(c)},somethingSelected:function(){return!pc(this.sel.head,this.sel.anchor)},setCursor:wb(function(a,b,c){var d=tc(this,"number"==typeof a?oc(a,b||0):a);c?wc(this,d):yc(this,d,d)}),setSelection:wb(function(a,b){yc(this,tc(this,a),tc(this,b||a))}),extendSelection:wb(function(a,b){wc(this,tc(this,a),b&&tc(this,b))}),getSelection:function(a){return this.getRange(this.sel.from,this.sel.to,a)},replaceSelection:function(a,b,c){hc(this,{from:this.sel.from,to:this.sel.to,text:bf(a),origin:c},b||"around")},undo:wb(function(){jc(this,"undo")}),redo:wb(function(){jc(this,"redo")}),setExtending:function(a){this.sel.extend=a},historySize:function(){var a=this.history;return{undo:a.done.length,redo:a.undone.length}},clearHistory:function(){this.history=ce()},markClean:function(){this.history.dirtyCounter=0,this.history.lastOp=this.history.lastOrigin=null},isClean:function(){return 0==this.history.dirtyCounter},getHistory:function(){return{done:ie(this.history.done),undone:ie(this.history.undone)}},setHistory:function(a){var b=this.history=ce();b.done=a.done.slice(0),b.undone=a.undone.slice(0)},markText:function(a,b,c){return bd(this,tc(this,a),tc(this,b),c,"range")},setBookmark:function(a,b){var c={replacedWith:b&&(null==b.nodeType?b.widget:b),insertLeft:b&&b.insertLeft};return a=tc(this,a),bd(this,a,a,c,"bookmark")},findMarksAt:function(a){a=tc(this,a);var b=[],c=Wd(this,a.line).markedSpans;if(c)for(var d=0;d<c.length;++d){var e=c[d];(null==e.from||e.from<=a.ch)&&(null==e.to||e.to>=a.ch)&&b.push(e.marker.parent||e.marker)}return b},getAllMarks:function(){var a=[];return this.iter(function(b){var c=b.markedSpans;if(c)for(var d=0;d<c.length;++d)null!=c[d].from&&a.push(c[d].marker)}),a},posFromIndex:function(a){var b,c=this.first;return this.iter(function(d){var e=d.text.length+1;return e>a?(b=a,!0):(a-=e,++c,void 0)}),tc(this,oc(c,b))},indexFromPos:function(a){a=tc(this,a);var b=a.ch;return a.line<this.first||a.ch<0?0:(this.iter(this.first,a.line,function(a){b+=a.text.length+1}),b)},copy:function(a){var b=new Rd(Yd(this,this.first,this.first+this.size),this.modeOption,this.first);return b.scrollTop=this.scrollTop,b.scrollLeft=this.scrollLeft,b.sel={from:this.sel.from,to:this.sel.to,head:this.sel.head,anchor:this.sel.anchor,shift:this.sel.shift,extend:!1,goalColumn:this.sel.goalColumn},a&&(b.history.undoDepth=this.history.undoDepth,b.setHistory(this.getHistory())),b},linkedDoc:function(a){a||(a={});var b=this.first,c=this.first+this.size;null!=a.from&&a.from>b&&(b=a.from),null!=a.to&&a.to<c&&(c=a.to);var d=new Rd(Yd(this,b,c),a.mode||this.modeOption,b);return a.sharedHist&&(d.history=this.history),(this.linked||(this.linked=[])).push({doc:d,sharedHist:a.sharedHist}),d.linked=[{doc:this,isParent:!0,sharedHist:a.sharedHist}],d},unlinkDoc:function(a){if(a instanceof w&&(a=a.doc),this.linked)for(var b=0;b<this.linked.length;++b){var c=this.linked[b];if(c.doc==a){this.linked.splice(b,1),a.unlinkDoc(this);break}}if(a.history==this.history){var d=[a.id];Ud(a,function(a){d.push(a.id)},!0),a.history=ce(),a.history.done=ie(this.history.done,d),a.history.undone=ie(this.history.undone,d)}},iterLinkedDocs:function(a){Ud(this,a)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),Rd.prototype.eachLine=Rd.prototype.iter;var Sd="iter insert remove copy getEditor".split(" ");for(var Td in Rd.prototype)Rd.prototype.hasOwnProperty(Td)&&Je(Sd,Td)<0&&(w.prototype[Td]=function(a){return function(){return a.apply(this.doc,arguments)}}(Rd.prototype[Td]));w.e_stop=qe,w.e_preventDefault=oe,w.e_stopPropagation=pe;var we,xe=0;w.on=te,w.off=ue,w.signal=ve;var Be=30,Ce=w.Pass={toString:function(){return"CodeMirror.Pass"}};De.prototype={set:function(a,b){clearTimeout(this.id),this.id=setTimeout(b,a)}},w.countColumn=Ee;var Fe=[""],Oe=/[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc]/,Re=/[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\uA670-\uA672\uA674-\uA67D\uA69F\udc00-\udfff]/;w.replaceGetRect=function(a){We=a};var Xe=function(){if(d)return!1;var a=Se("div");return"draggable"in a||"dragDrop"in a}(),Ye=/^$/;a?Ye=/$'/:i?Ye=/\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/:g&&(Ye=/\-[^ \-\.?]|\?[^ \-\.?\]\}:;!'\"\),\/]|[\.!\"#&%\)*+,:;=>\]|\}~][\(\{\[<]|\$'/);var Ze,_e,bf=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;d>=b;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)};w.splitLines=bf;var cf=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},df=function(){var a=Se("div");return"oncopy"in a?!0:(a.setAttribute("oncopy","return;"),"function"==typeof a.oncopy)}(),ef={3:"Enter",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:";",91:"Mod",92:"Mod",93:"Mod",109:"-",107:"=",127:"Delete",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"Left",63232:"Up",63235:"Right",63233:"Down",63302:"Insert",63272:"Delete"};w.keyNames=ef,function(){for(var a=0;10>a;a++)ef[a+48]=String(a);for(var a=65;90>=a;a++)ef[a]=String.fromCharCode(a);for(var a=1;12>=a;a++)ef[a+111]=ef[a+63235]="F"+a}();var pf=function(){function c(c){return 255>=c?a.charAt(c):c>=1424&&1524>=c?"R":c>=1536&&1791>=c?b.charAt(c-1536):c>=1792&&2220>=c?"r":"L"}var a="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL",b="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr",d=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,f=/[LRr]/,g=/[Lb1n]/,h=/[1n]/,i="L";return function(a){if(!d.test(a))return!1;for(var l,b=a.length,j=[],k=0;b>k;++k)j.push(l=c(a.charCodeAt(k)));for(var k=0,m=i;b>k;++k){var l=j[k];"m"==l?j[k]=m:m=l}for(var k=0,n=i;b>k;++k){var l=j[k];
|
|
"1"==l&&"r"==n?j[k]="n":f.test(l)&&(n=l,"r"==l&&(j[k]="R"))}for(var k=1,m=j[0];b-1>k;++k){var l=j[k];"+"==l&&"1"==m&&"1"==j[k+1]?j[k]="1":","!=l||m!=j[k+1]||"1"!=m&&"n"!=m||(j[k]=m),m=l}for(var k=0;b>k;++k){var l=j[k];if(","==l)j[k]="N";else if("%"==l){for(var o=k+1;b>o&&"%"==j[o];++o);for(var p=k&&"!"==j[k-1]||b-1>o&&"1"==j[o]?"1":"N",q=k;o>q;++q)j[q]=p;k=o-1}}for(var k=0,n=i;b>k;++k){var l=j[k];"L"==n&&"1"==l?j[k]="L":f.test(l)&&(n=l)}for(var k=0;b>k;++k)if(e.test(j[k])){for(var o=k+1;b>o&&e.test(j[o]);++o);for(var r="L"==(k?j[k-1]:i),s="L"==(b-1>o?j[o]:i),p=r||s?"L":"R",q=k;o>q;++q)j[q]=p;k=o-1}for(var u,t=[],k=0;b>k;)if(g.test(j[k])){var v=k;for(++k;b>k&&g.test(j[k]);++k);t.push({from:v,to:k,level:0})}else{var w=k,x=t.length;for(++k;b>k&&"L"!=j[k];++k);for(var q=w;k>q;)if(h.test(j[q])){q>w&&t.splice(x,0,{from:w,to:q,level:1});var y=q;for(++q;k>q&&h.test(j[q]);++q);t.splice(x,0,{from:y,to:q,level:2}),w=q}else++q;k>w&&t.splice(x,0,{from:w,to:k,level:1})}return 1==t[0].level&&(u=a.match(/^\s+/))&&(t[0].from=u[0].length,t.unshift({from:0,to:u[0].length,level:0})),1==He(t).level&&(u=a.match(/\s+$/))&&(He(t).to-=u[0].length,t.push({from:b-u[0].length,to:b,level:0})),t[0].level!=He(t).level&&t.push({from:b,to:b,level:t[0].level}),t}}();return w.version="3.1",w}(); |