'use strict';var $jscomp={scope:{},findInternal:function(y,H,D){y instanceof String&&(y=String(y));for(var r=y.length,V=0;Vf||f>=b)return e+(b-d);e+=f-d;e+=c-e%c;d=f+1}}function Ea(){this.id=null}function M(a,b){for(var c=0;c=b)return d+Math.min(g,b-e);e+=f-d;e+=c-e%c;d=f+1;if(e>=b)return d}}function Lc(a){for(;Xb.length<=a;)Xb.push(x(Xb)+" ");return Xb[a]}function x(a){return a[a.length-1]}function Yb(a,b){for(var c=[],d=0;dF&&(this.gutters.style.zIndex=-1,this.scroller.style.paddingRight=0);N||wa&&pb||(this.scroller.draggable=!0);a&&(a.appendChild?a.appendChild(this.wrapper):a(this.wrapper));this.reportedViewFrom=this.reportedViewTo=this.viewFrom=this.viewTo=b.first;this.view=[];this.externalMeasured=this.renderedView=null;this.lastWrapHeight=this.lastWrapWidth=this.viewOffset=0;this.updateLineNumbers=null;this.nativeBarWidth=this.barHeight=this.barWidth=0;this.scrollbarsClipped=!1; this.lineNumWidth=this.lineNumInnerWidth=this.lineNumChars=null;this.alignWidgets=!1;this.maxLine=this.cachedCharWidth=this.cachedTextHeight=this.cachedPaddingH=null;this.maxLineLength=0;this.maxLineChanged=!1;this.wheelDX=this.wheelDY=this.wheelStartX=this.wheelStartY=null;this.shift=!1;this.activeTouch=this.selForContextMenu=null;c.init(this)}function v(a,b){b-=a.first;if(0>b||b>=a.size)throw Error("There is no line "+(b+a.first)+" in the document.");for(;!a.lines;)for(var c=0;;++c){var d=a.children[c], e=d.chunkSize();if(b=a.first&&bu(a,b)?b:a}function ac(a,b){return 0>u(a,b)?a:b}function z(a,b){if(b.linec)return q(c,v(a,c).text.length);a=v(a,b.line).text.length;c=b.ch;b=null==c||c>a?q(b.line,a):0>c?q(b.line,0):b;return b}function Rd(a,b){for(var c=[],d=0;d=a:k.to>a); (g||(g=[])).push(new bc(l,k.from,m?null:k.to))}}var c=g,n;if(d)for(g=0;g=e:h.to>e)||h.from==e&&"bookmark"==k.type&&(!f||h.marker.insertLeft))l=null==h.from||(k.inclusiveLeft?h.from<=e:h.fromu(g.to,e.from)||0k||!c.inclusiveLeft&&!k)&&h.push({from:g.from,to:e.from});(0Vd(c,d.marker))&&(c=d.marker);return c}function Wd(a,b,c,d,e){a=v(a,b);if(a=xa&&a.markedSpans)for(b=0;b=k||0>=h&&0<=k)&&(0>=h&&(f.marker.inclusiveRight&& e.inclusiveLeft?0<=u(g.to,c):0=u(g.from,d):0>u(g.from,d))))return!0}}}function ka(a){for(var b;b=Ha(a,!0);)a=b.find(-1,!0).line;return a}function Rc(a,b){a=v(a,b);var c=ka(a);return a==c?b:C(c)}function Xd(a,b){if(b>a.lastLine())return b;var c=v(a,b);if(!Ia(a,c))return b;for(;a=Ha(c,!1);)c=a.find(1,!0).line;return C(c)+1}function Ia(a,b){var c=xa&&b.markedSpans;if(c)for(var d,e=0;eb.maxLineLength&&(b.maxLineLength=d,b.maxLine=a)})}function Sf(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=!1,f=0;fb||b==c&&g.to==b)d(Math.max(g.from,b),Math.min(g.to,c),1==g.level?"rtl":"ltr"),e=!0}e||d(b,c,"ltr")}function Uc(a){return a.level%2?a.to:a.from}function Vc(a){return a.level%2?a.from:a.to}function dc(a){return(a=ea(a))?Uc(a[0]):0}function ec(a){var b=ea(a);return b?Vc(x(b)):a.text.length} function fc(a,b){var c;sb=null;for(var d=0;db)return d;if(e.from==b||e.to==b)if(null==c)c=d;else{b=e.level;var f=a[c].level;a=a[0].level;a=b==a?!0:f==a?!1:bg.from&&bb||b>a.text.length?null:b}function ea(a){var b=a.order;null==b&&(b=a.order=Tf(a.text));return b}function fa(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,!1);else if(a.detachEvent)a.detachEvent("on"+b,c);else{var d=(a=a._handlers)&&a[b];d&&(c=M(d, c),-1=b.offsetWidth&&2F))}a=Zc?r("span","\u200b"):r("span","\u00a0",null,"display: inline-block; width: 1px; margin-right: -1px");a.setAttribute("cm-text","");return a}function Vf(a,b){2a&&e.splice(g,1,a,e[g+1],f);g+=2;l=Math.min(a,f)}if(b)if(c.opaque)e.splice(d,g-d,a,"overlay "+b),g=d+2;else for(;da.options.maxHighlightLength?qa(a.doc.mode,d):d);b.stateAfter=d;b.styles=e.styles;e.classes?b.styleClasses=e.classes:b.styleClasses&&(b.styleClasses=null);c===a.doc.frontier&&a.doc.frontier++}return b.styles}function ub(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return!0; var f=Xf(a,b,c),g=f>d.first&&v(d,f-1).stateAfter,g=g?qa(d.mode,g):be(d.mode);d.iter(f,b,function(c){cd(a,c.text,g);c.stateAfter=f==b-1||0==f%5||f>=e.viewFrom&&fe;e++){d&&(d[0]=bd(a,c).mode);var f=a.token(b,c);if(b.pos>b.start)return f}throw Error("Mode "+a.name+" failed to advance stream.");}function ge(a,b,c,d){var e=function(a){return{start:m.start,end:m.pos,string:m.current(),type:h||null,state:a?qa(f.mode,l):l}},f=a.doc,g=f.mode,h;b=z(f,b);var k=v(f,b.line),l=ub(a,b.line,c),m=new vb(k.text,a.options.tabSize),n;for(d&&(n=[]);(d||m.posa.options.maxHighlightLength?(h=!1,g&&cd(a,b,d,m.pos),m.pos= b.length,n=null):n=he(dd(c,m,d,p),f);if(p){var t=p[0].name;t&&(n="m-"+(n?t+" "+n:t))}if(!h||l!=n){for(;kg;--b){if(b<=f.first)return f.first;var h=v(f,b-1);if(h.stateAfter&&(!c||b<=f.frontier))return b;h=ca(h.text,null,a.options.tabSize);if(null==e||d>h)e=b-1,d=h}return e}function Wa(a,b,c){this.text=a;Ud(this, b);this.height=c?c(this):1}function ie(a,b){if(!a||/^\s*$/.test(a))return null;b=b.addModeClass?Yf:Zf;return b[a]||(b[a]=a.replace(/\S+/g,"cm-$&"))}function je(a,b){var c=r("span",null,null,N?"padding-right: .1px":null),c={pre:r("pre",[c],"CodeMirror-line"),content:c,col:0,pos:0,cm:a,trailingSpace:!1,splitSpaces:(B||N)&&a.getOption("lineWrapping")};b.measure={};for(var d=0;d<=(b.rest?b.rest.length:0);d++){var e=d?b.rest[d-1]:b.line,f=void 0;c.pos=0;c.addToken=$f;var g;g=a.display.measure;if(null!= ed)g=ed;else{var h=D(g,document.createTextNode("A\u062eA")),k=Xa(h,0,1).getBoundingClientRect(),h=Xa(h,1,2).getBoundingClientRect();H(g);g=k&&k.left!=k.right?ed=3>h.right-k.right:!1}g&&(f=ea(e))&&(c.addToken=ag(c.addToken,f));c.map=[];var l=b!=a.display.externalMeasured&&C(e);a:{var m=h=k=g=void 0,n=void 0,p=void 0,t=void 0,f=c,l=ee(a,e,l),q=e.markedSpans,fd=e.text,v=0;if(q)for(var w=fd.length,u=0,z=1,Ja="",na=0;;){if(na==u){n=m=h=k=p="";g=null;for(var na=Infinity,ra=[],W=void 0,y=0;yu||A.collapsed&&x.to==u&&x.from==u)?(null!=x.to&&x.to!=u&&na>x.to&&(na=x.to,m=""),A.className&&(n+=" "+A.className),A.css&&(p=(p?p+";":"")+A.css),A.startStyle&&x.from==u&&(h+=" "+A.startStyle),A.endStyle&&x.to==na&&(W||(W=[])).push(A.endStyle,x.to),A.title&&!k&&(k=A.title),A.collapsed&&(!g||0>Vd(g.marker,A))&&(g=x)):x.from>u&&na>x.from&&(na=x.from)}if(W)for(y=0;y=w)break;for(ra=Math.min(w,na);;){if(Ja){W=u+Ja.length;g||(y=W>ra?Ja.slice(0,ra-u):Ja,f.addToken(f,y,t?t+n:n,h,u+y.length==na?m:"",k,p));if(W>=ra){Ja=Ja.slice(ra-u);u=ra;break}u=W;h=""}Ja=fd.slice(v,v=l[z++]);t=ie(l[z++],f.cm.options)}}else for(g=1;gF?h.appendChild(r("span",[q])):h.appendChild(q);a.map.push(a.pos,a.pos+t,q);a.col+=t;a.pos+=t}if(!p)break;n+=t+1;"\t"==p[0]?(p=a.cm.options.tabSize,p-=a.col%p,t=h.appendChild(r("span",Lc(p),"cm-tab")),t.setAttribute("role","presentation"),t.setAttribute("cm-text", "\t"),a.col+=p):("\r"==p[0]||"\n"==p[0]?(t=h.appendChild(r("span","\r"==p[0]?"\u240d":"\u2424","cm-invalidchar")),t.setAttribute("cm-text",p[0])):(t=a.cm.options.specialCharPlaceholder(p[0]),t.setAttribute("cm-text",p[0]),B&&9>F?h.appendChild(r("span",[t])):h.appendChild(t)),a.col+=1);a.map.push(a.pos,a.pos+1,t);a.pos++}}else a.col+=b.length,h=document.createTextNode(k),a.map.push(a.pos,a.pos+b.length,h),B&&9>F&&(m=!0),a.pos+=b.length;a.trailingSpace=32==k.charCodeAt(b.length-1);if(c||d||e||m||g)return b= c||"",d&&(b+=d),e&&(b+=e),d=r("span",[h],b,g),f&&(d.title=f),a.content.appendChild(d);a.content.appendChild(h)}}function ag(a,b){return function(c,d,e,f,g,h,k){e=e?e+" cm-force-border":"cm-force-border";for(var l=c.pos,m=l+d.length;;){for(var n=void 0,p=0;pl&&n.from<=l);p++);if(n.to>=m)return a(c,d,e,f,g,h,k);a(c,d.slice(0,n.to-l),e,f,null,h,k);f=null;d=d.slice(n.to-l);l=n.to}}}function ke(a,b,c,d){var e=!d&&c.widgetNode;e&&a.map.push(a.pos,a.pos+b,e);!d&&a.cm.display.input.needsContentAttribute&& (e||(e=a.content.appendChild(document.createElement("span"))),e.setAttribute("cm-marker",c.id));e&&(a.cm.display.input.setUneditable(e),a.content.appendChild(e));a.pos+=b;a.trailingSpace=!1}function le(a,b,c){for(var d=this.line=b,e;d=Ha(d,!1);)d=d.find(1,!0).line,(e||(e=[])).push(d);this.size=(this.rest=e)?C(x(this.rest))-c+1:1;this.node=this.text=null;this.hidden=Ia(a,b)}function ic(a,b,c){var d=[],e;for(e=b;eF&&(a.node.style.zIndex=2));return a.node}function ne(a,b){var c=a.display.externalMeasured;return c&&c.line==b.line?(a.display.externalMeasured= null,b.measure=c.measure,c.built):je(a,b)}function gd(a){var b=a.bgClass?a.bgClass+" "+(a.line.bgClass||""):a.line.bgClass;b&&(b+=" CodeMirror-linebackground");if(a.background)b?a.background.className=b:(a.background.parentNode.removeChild(a.background),a.background=null);else if(b){var c=xb(a);a.background=c.insertBefore(r("div",null,b),c.firstChild)}a.line.wrapClass?xb(a).className=a.line.wrapClass:a.node!=a.text&&(a.node.className="");a.text.className=(a.textClass?a.textClass+" "+(a.line.textClass|| ""):a.line.textClass)||""}function oe(a,b,c,d){b.gutter&&(b.node.removeChild(b.gutter),b.gutter=null);b.gutterBackground&&(b.node.removeChild(b.gutterBackground),b.gutterBackground=null);if(b.line.gutterClass){var e=xb(b);b.gutterBackground=r("div",null,"CodeMirror-gutter-background "+b.line.gutterClass,"left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px; width: "+d.gutterTotalWidth+"px");e.insertBefore(b.gutterBackground,b.text)}e=b.line.gutterMarkers;if(a.options.lineNumbers||e){var f= xb(b),g=b.gutter=r("div",null,"CodeMirror-gutter-wrapper","left: "+(a.options.fixedGutter?d.fixedPos:-d.gutterTotalWidth)+"px");a.display.input.setUneditable(g);f.insertBefore(g,b.text);b.line.gutterClass&&(g.className+=" "+b.line.gutterClass);!a.options.lineNumbers||e&&e["CodeMirror-linenumbers"]||(b.lineNumber=g.appendChild(r("div",Oc(a.options,c),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+d.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+a.display.lineNumInnerWidth+"px")));if(e)for(b= 0;bc)return{map:a.measure.maps[b],cache:a.measure.caches[b], before:!0}}function jd(a,b){if(b>=a.display.viewFrom&&b=a.lineN&&bt;t++){for(;h&&ob(b.line.text.charAt(g.coverStart+h));)--h;for(;g.coverStart+kF&&0==h&&k==g.coverEnd-g.coverStart)p=d.parentNode.getBoundingClientRect();else{p=Xa(d,h,k).getClientRects();k=ue;if("left"==m)for(l=0;lF&&((t=!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI)||(null!=ld?t=ld:(m=D(a.display.measure,r("span","x")),t=m.getBoundingClientRect(),m=Xa(m,0,1).getBoundingClientRect(),t=ld=1F)||h||p&&(p.left||p.right)||(p=(p=d.parentNode.getClientRects()[0])?{left:p.left,right:p.left+zb(a.display),top:p.top,bottom:p.bottom}:ue);d=p.top-b.rect.top;h=p.bottom-b.rect.top;t=(d+h)/2;m=b.view.measure.heights;for(g=0;gb)f=k-h,e=f-1,b>=k&&(g="right");if(null!=e){d=a[l+2];h==k&&c==(d.insertLeft?"left":"right")&&(g=c);if("left"==c&&0==e)for(;l&&a[l-2]==a[l-3]&&a[l-1].insertLeft;)d=a[(l-=3)+2],g="left";if("right"==c&&e==k-h)for(;l< a.length-3&&a[l+3]==a[l+4]&&!a[l+5].insertLeft;)d=a[(l+=3)+2],g="right";break}}return{node:d,start:e,end:f,collapse:g,coverStart:h,coverEnd:k}}function ve(a){if(a.measure&&(a.measure.cache={},a.measure.heights=null,a.rest))for(var b=0;bd.from?g(a-1):g(a,c)}d=d||v(a.doc,b.line);e|| (e=jc(a,d));var k=ea(d);b=b.ch;if(!k)return g(b);var l=fc(k,b),l=h(b,l);null!=sb&&(l.other=h(b,sb));return l}function ye(a,b){var c=0;b=z(a.doc,b);a.options.lineWrapping||(c=zb(a.display)*b.ch);b=v(a.doc,b.line);a=la(b)+a.display.lineSpace.offsetTop;return{left:c,right:c,top:a,bottom:a+b.height}}function mc(a,b,c,d){a=q(a,b);a.xRel=d;c&&(a.outside=!0);return a}function nd(a,b,c){var d=a.doc;c+=a.display.viewOffset;if(0>c)return mc(d.first,0,!0,-1);var e=Ga(d,c),f=d.first+d.size-1;if(e>f)return mc(d.first+ d.size-1,v(d,f).text.length,!0,1);0>b&&(b=0);for(d=v(d,e);;)if(e=fg(a,d,e,b,c),f=(d=Ha(d,!1))&&d.find(0,!0),d&&(e.ch>f.from.ch||e.ch==f.from.ch&&0d.bottom)return d.left-k;if(gu)return mc(c,p,r,1);for(;;){if(e?p== n||p==Xc(b,n,1):1>=p-n){m=d=e.top&&Math.abs(d-e.right)n?-1:1d){p=w;u=x;if(r=h)u+=1E3;m=v}else n=w,t=x,ma=h,m-=v}}function Ma(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight; if(null==Na){Na=r("pre");for(var b=0;49>b;++b)Na.appendChild(document.createTextNode("x")),Na.appendChild(r("br"));Na.appendChild(document.createTextNode("x"))}D(a.measure,Na);b=Na.offsetHeight/50;3=a.display.viewTo)return null;b-=a.display.viewFrom;if(0>b)return null;a=a.display.view;for(var c=0;cb)return c}function Bb(a){a.display.input.showSelection(a.display.input.prepareSelection())}function Ae(a,b){for(var c= a.doc,d={},e=d.cursors=document.createDocumentFragment(),f=d.selection=document.createDocumentFragment(),g=0;g=a.display.viewTo||h.to().lineb&&(b=0);b=Math.round(b);c=Math.round(c);h.appendChild(r("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px;\n top: "+ b+"px; width: "+(null==d?m-a:d)+"px;\n height: "+(c-b)+"px"))}function e(b,c,e){var f=v(g,b),h=f.text.length,k,n;Sf(ea(f),c||0,null==e?h:e,function(g,p,t){var u=lc(a,q(b,g),"div",f,"left"),r,ma;g==p?(r=u,t=ma=u.left):(r=lc(a,q(b,p-1),"div",f,"right"),"rtl"==t&&(t=u,u=r,r=t),t=u.left,ma=r.right);null==c&&0==g&&(t=l);3n.bottom||r.bottom==n.bottom&&r.right>n.right)n=r;ta.options.cursorBlinkRate&&(b.cursorDiv.style.visibility="hidden")}}function Ce(a){a.state.focused||(a.display.input.focus(), rd(a))}function hg(a){a.state.delayingBlurEvent=!0;setTimeout(function(){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1,Cb(a))},100)}function rd(a,b){a.state.delayingBlurEvent&&(a.state.delayingBlurEvent=!1);"nocursor"!=a.options.readOnly&&(a.state.focused||(I(a,"focus",a,b),a.state.focused=!0,Sa(a.display.wrapper,"CodeMirror-focused"),a.curOp||a.display.selForContextMenu==a.doc.sel||(a.display.input.reset(),N&&setTimeout(function(){return a.display.input.reset(!0)},20)),a.display.input.receivedFocus()), qd(a))}function Cb(a,b){a.state.delayingBlurEvent||(a.state.focused&&(I(a,"blur",a,b),a.state.focused=!1,Za(a.display.wrapper,"CodeMirror-focused")),clearInterval(a.display.blinker),setTimeout(function(){a.state.focused||(a.display.shift=!1)},150))}function sd(a){var b=a.display,c=b.view;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var d=od(b)-b.scroller.scrollLeft+a.doc.scrollLeft,e=b.gutters.offsetWidth,f=d+"px",g=0;gF){var f=d.node.offsetTop+d.node.offsetHeight;e=f-b;b=f}else e=d.node.getBoundingClientRect(),e=e.bottom-e.top;f=d.line.height-e;2>e&&(e=Ma(a));if(.001f)if(ja(d.line, e),Ee(d.line),d.rest)for(e=0;e=e&&(d=Ga(b,la(v(b,c))-a.wrapper.clientHeight),e=c)}return{from:d,to:Math.max(e,d+1)}}function Db(a,b){2>Math.abs(a.doc.scrollTop-b)||(a.doc.scrollTop=b,wa||vd(a,{top:b}),a.display.scroller.scrollTop!=b&&(a.display.scroller.scrollTop=b),a.display.scrollbars.setScrollTop(b),wa&&vd(a),Eb(a,100))}function $a(a,b,c){(c?b==a.doc.scrollLeft:2>Math.abs(a.doc.scrollLeft-b))||(b=Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth),a.doc.scrollLeft=b,sd(a),a.display.scroller.scrollLeft!= b&&(a.display.scroller.scrollLeft=b),a.display.scrollbars.setScrollLeft(b))}function Fe(a){var b=a.wheelDeltaX,c=a.wheelDeltaY;null==b&&a.detail&&a.axis==a.HORIZONTAL_AXIS&&(b=a.detail);null==c&&a.detail&&a.axis==a.VERTICAL_AXIS?c=a.detail:null==c&&(c=a.wheelDelta);return{x:b,y:c}}function ig(a){a=Fe(a);a.x*=Z;a.y*=Z;return a}function Ge(a,b){var c=Fe(b),d=c.x,c=c.y,e=a.display,f=e.scroller,g=f.scrollWidth>f.clientWidth,h=f.scrollHeight>f.clientHeight;if(d&&g||c&&h){if(c&&ga&&N){var g=b.target,k= e.view;a:for(;g!=f;g=g.parentNode)for(var l=0;lb?h=Math.max(0,h+b-50):g=Math.min(a.doc.height,g+b+50),vd(a,{top:h,bottom:g})),20>oc&&(null==e.wheelStartX?(e.wheelStartX=f.scrollLeft,e.wheelStartY=f.scrollTop,e.wheelDX=d,e.wheelDY=c,setTimeout(function(){if(null!=e.wheelStartX){var a=f.scrollLeft-e.wheelStartX,b=f.scrollTop-e.wheelStartY,a=b&& e.wheelDY&&b/e.wheelDY||a&&e.wheelDX&&a/e.wheelDX;e.wheelStartX=e.wheelStartY=null;a&&(Z=(Z*oc+a)/(oc+1),++oc)}},200)):(e.wheelDX+=d,e.wheelDY+=c))):(c&&h&&Db(a,Math.max(0,Math.min(f.scrollTop+c*Z,f.scrollHeight-f.clientHeight))),$a(a,Math.max(0,Math.min(f.scrollLeft+d*Z,f.scrollWidth-f.clientWidth))),(!c||c&&h)&&Q(b),e.wheelStartX=null)}}function Fb(a){var b=a.display,c=b.gutters.offsetWidth,d=Math.round(a.doc.height+hd(a.display));return{clientHeight:b.scroller.clientHeight,viewHeight:b.wrapper.clientHeight, scrollWidth:b.scroller.scrollWidth,clientWidth:b.scroller.clientWidth,viewWidth:b.wrapper.clientWidth,barLeft:a.options.fixedGutter?c:0,docHeight:d,scrollHeight:d+oa(a)+b.barHeight,nativeBarWidth:b.nativeBarWidth,gutterWidth:c}}function ab(a,b){b||(b=Fb(a));var c=a.display.barWidth,d=a.display.barHeight;He(a,b);for(b=0;4>b&&c!=a.display.barWidth||d!=a.display.barHeight;b++)c!=a.display.barWidth&&a.options.lineWrapping&&nc(a),He(a,Fb(a)),c=a.display.barWidth,d=a.display.barHeight}function He(a,b){var c= a.display,d=c.scrollbars.update(b);c.sizer.style.paddingRight=(c.barWidth=d.right)+"px";c.sizer.style.paddingBottom=(c.barHeight=d.bottom)+"px";c.heightForcer.style.borderBottom=d.bottom+"px solid transparent";d.right&&d.bottom?(c.scrollbarFiller.style.display="block",c.scrollbarFiller.style.height=d.bottom+"px",c.scrollbarFiller.style.width=d.right+"px"):c.scrollbarFiller.style.display="";d.bottom&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(c.gutterFiller.style.display="block", c.gutterFiller.style.height=d.bottom+"px",c.gutterFiller.style.width=b.gutterWidth+"px"):c.gutterFiller.style.display=""}function Ie(a){a.display.scrollbars&&(a.display.scrollbars.clear(),a.display.scrollbars.addClass&&Za(a.display.wrapper,a.display.scrollbars.addClass));a.display.scrollbars=new Je[a.options.scrollbarStyle](function(b){a.display.wrapper.insertBefore(b,a.display.scrollbarFiller);w(b,"mousedown",function(){a.state.focused&&setTimeout(function(){return a.display.input.focus()},0)}); b.setAttribute("cm-not-content","true")},function(b,c){"horizontal"==c?$a(a,b):Db(a,b)},a);a.display.scrollbars.addClass&&Sa(a.display.wrapper,a.display.scrollbars.addClass)}function pc(a,b,c,d,e){var f=a.display,g=Ma(a.display);0>c&&(c=0);var h=a.curOp&&null!=a.curOp.scrollTop?a.curOp.scrollTop:f.scroller.scrollTop,k=id(a),l={};e-c>k&&(e=c+k);var m=a.doc.height+hd(f),n=cm-g;ch+k&&(c=Math.min(c,(g?m:e)-k),c!=h&&(l.scrollTop=c));h=a.curOp&&null!=a.curOp.scrollLeft?a.curOp.scrollLeft: f.scroller.scrollLeft;a=Ka(a)-(a.options.fixedGutter?f.gutters.offsetWidth:0);(f=d-b>a)&&(d=b+a);10>b?l.scrollLeft=0:ba+h-3&&(l.scrollLeft=d+(f?0:10)-a);return l}function qc(a,b,c){null==b&&null==c||rc(a);null!=b&&(a.curOp.scrollLeft=(null==a.curOp.scrollLeft?a.doc.scrollLeft:a.curOp.scrollLeft)+b);null!=c&&(a.curOp.scrollTop=(null==a.curOp.scrollTop?a.doc.scrollTop:a.curOp.scrollTop)+c)}function bb(a){rc(a);var b=a.getCursor(),c=b,d=b;a.options.lineWrapping|| (c=b.ch?q(b.line,b.ch-1):b,d=q(b.line,b.ch+1));a.curOp.scrollToPos={from:c,to:d,margin:a.options.cursorScrollMargin,isCursor:!0}}function rc(a){var b=a.curOp.scrollToPos;if(b){a.curOp.scrollToPos=null;var c=ye(a,b.from),d=ye(a,b.to),b=pc(a,Math.min(c.left,d.left),Math.min(c.top,d.top)-b.margin,Math.max(c.right,d.right),Math.max(c.bottom,d.bottom)+b.margin);a.scrollTo(b.scrollLeft,b.scrollTop)}}function cb(a){a.curOp={cm:a,viewChanged:!1,startHeight:a.doc.height,forceUpdate:!1,updateInput:null,typing:!1, changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++jg};a=a.curOp;Ya?Ya.ops.push(a):a.ownsGroup=Ya={ops:[a],delayedCallbacks:[]}}function db(a){cg(a.curOp,function(a){for(var b=0;b=f.viewTo)||f.maxLineChanged&&e.options.lineWrapping;d.update=d.mustUpdate&&new sc(e,d.mustUpdate&&{top:d.scrollTop,ensure:d.scrollToPos},d.forceUpdate)}for(b=0;bn;n++){var p=!1,h=ta(e,k),t=l&&l!=k?ta(e,l):h,t=pc(e, Math.min(h.left,t.left),Math.min(h.top,t.top)-m,Math.max(h.left,t.left),Math.max(h.bottom,t.bottom)+m),q=e.doc.scrollTop,u=e.doc.scrollLeft;null!=t.scrollTop&&(Db(e,t.scrollTop),1k.top+m.top?h=!0:k.bottom+m.top>(window.innerHeight||document.documentElement.clientHeight)&& (h=!1),null==h||kg||(k=r("div","\u200b",null,"position: absolute;\n top: "+(k.top-l.viewOffset-e.display.lineSpace.offsetTop)+"px;\n height: "+(k.bottom-k.top+oa(e)+l.barHeight)+"px;\n left: "+k.left+"px; width: 2px;"),e.display.lineSpace.appendChild(k),k.scrollIntoView(h),e.display.lineSpace.removeChild(k))))}k=d.maybeHiddenMarkers;h=d.maybeUnhiddenMarkers;if(k)for(l=0;lb)&&(e.updateLineNumbers=b);a.curOp.viewChanged=!0;if(b>=e.viewTo)xa&&Rc(a.doc,b)e.viewFrom?ya(a): (e.viewFrom+=d,e.viewTo+=d);else if(b<=e.viewFrom&&c>=e.viewTo)ya(a);else if(b<=e.viewFrom){var f=tc(a,c,c+d,1);f?(e.view=e.view.slice(f.index),e.viewFrom=f.lineN,e.viewTo+=d):ya(a)}else if(c>=e.viewTo)(f=tc(a,b,b,-1))?(e.view=e.view.slice(0,f.index),e.viewTo=f.lineN):ya(a);else{var f=tc(a,b,b,-1),g=tc(a,c,c+d,1);f&&g?(e.view=e.view.slice(0,f.index).concat(ic(a,f.lineN,g.lineN)).concat(e.view.slice(g.index)),e.viewTo+=d):ya(a)}if(a=e.externalMeasured)c=e.lineN&&b=d.viewTo||(a=d.view[La(a,b)],null!=a.node&&(a=a.changes||(a.changes=[]),-1==M(a,c)&&a.push(c)))}function ya(a){a.display.viewFrom=a.display.viewTo=a.doc.first;a.display.view=[];a.display.viewOffset=0}function tc(a,b,c,d){var e=La(a,b),f=a.display.view;if(!xa||c==a.doc.first+a.doc.size)return{index:e,lineN:c};for(var g=a.display.viewFrom, h=0;hd?0:f.length-1))return null;c+=d*f[e-(0>d?1:0)].size;e+=d}return{index:e,lineN:c}}function Le(a){a=a.display.view;for(var b=0,c=0;c=a.display.viewTo)){var c=+new Date+a.options.workTime,d=qa(b.mode,ub(a,b.frontier)),e=[];b.iter(b.frontier,Math.min(b.first+b.size,a.display.viewTo+500),function(f){if(b.frontier>=a.display.viewFrom){var g=f.styles,h=f.text.length>a.options.maxHighlightLength,k=ce(a,f,h?qa(b.mode,d):d,!0);f.styles=k.styles;var l=f.styleClasses;(k=k.classes)?f.styleClasses=k:l&&(f.styleClasses=null);l=!g||g.length!=f.styles.length||l!=k&&(!l||!k||l.bgClass!=k.bgClass||l.textClass!=k.textClass); for(k=0;!l&&kc)return Eb(a,a.options.workDelay),!0});e.length&&aa(a,function(){for(var b=0;b=c.viewFrom&&b.visible.to<=c.viewTo&&(null==c.updateLineNumbers|| c.updateLineNumbers>=c.viewTo)&&c.renderedView==c.view&&0==Le(a))return!1;De(a)&&(ya(a),b.dims=kd(a));var e=d.first+d.size,f=Math.max(b.visible.from-a.options.viewportMargin,d.first),g=Math.min(e,b.visible.to+a.options.viewportMargin);c.viewFromf-c.viewFrom&&(f=Math.max(d.first,c.viewFrom));c.viewTo>g&&20>c.viewTo-g&&(g=Math.min(e,c.viewTo));xa&&(f=Rc(a.doc,f),g=Xd(a.doc,g));d=f!=c.viewFrom||g!=c.viewTo||c.lastWrapHeight!=b.wrapperHeight||c.lastWrapWidth!=b.wrapperWidth;e=a.display;0==e.view.length|| f>=e.viewTo||g<=e.viewFrom?(e.view=ic(a,f,g),e.viewFrom=f):(e.viewFrom>f?e.view=ic(a,f,e.viewFrom).concat(e.view):e.viewFromg&&(e.view=e.view.slice(0,La(a,g))));e.viewTo=g;c.viewOffset=la(v(a.doc,c.viewFrom));a.display.mover.style.top=c.viewOffset+"px";g=Le(a);if(!d&&0==g&&!b.force&&c.renderedView==c.view&&(null==c.updateLineNumbers||c.updateLineNumbers>=c.viewTo))return!1;f=ba();4=a.display.viewFrom&&b.visible.to<=a.display.viewTo)break;if(!wd(a,b))break;nc(a);d=Fb(a);Bb(a);ab(a,d);xd(a,d)}b.signal(a,"update",a);if(a.display.viewFrom!=a.display.reportedViewFrom||a.display.viewTo!=a.display.reportedViewTo)b.signal(a,"viewportChange",a,a.display.viewFrom,a.display.viewTo),a.display.reportedViewFrom=a.display.viewFrom,a.display.reportedViewTo=a.display.viewTo}function vd(a,b){b=new sc(a,b);if(wd(a,b)){nc(a);Ke(a,b);var c= Fb(a);Bb(a);ab(a,c);xd(a,c);b.finish()}}function mg(a,b,c){function d(b){var d=b.nextSibling;N&&ga&&a.display.currentWheelTarget==b?b.style.display="none":b.parentNode.removeChild(b);return d}for(var e=a.display,f=a.options.lineNumbers,g=e.lineDiv,h=g.firstChild,k=e.view,e=e.viewFrom,l=0;lu(a,b.from))return a;if(0>=u(a,b.to))return Aa(b);var c=a.line+ b.text.length-(b.to.line-b.from.line)-1,d=a.ch;a.line==b.to.line&&(d+=Aa(b).ch-b.to.ch);return q(c,d)}function zd(a,b){for(var c=[],d=0;df-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))e.lastOp==d?(Se(e.done),g=x(e.done)):e.done.length&&!x(e.done).ranges?g=x(e.done):1e.undoDepth;)e.done.shift(),e.done[0].ranges||e.done.shift();e.done.push(c);e.generation=++e.maxGeneration;e.lastModTime=e.lastSelTime=f;e.lastOp=e.lastSelOp=d;e.lastOrigin=e.lastSelOrigin=b.origin;h||I(a,"historyAdded")}function vc(a,b){var c=x(b);c&&c.ranges&&c.equals(a)||b.push(a)}function Re(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(d){d.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]= d.markedSpans);++f})}function ng(a){if(!a)return null;for(var b,c=0;cu(c,a),b!=0>u(d,a)?(a=c,c=d):b!=0>u(c,d)&&(c=d)),new A(a, c)):new A(d||c,c)}function wc(a,b,c,d){P(a,new ua([Hb(a,a.sel.primary(),b,c)],0),d)}function Ve(a,b,c){for(var d=[],e=0;eu(b.primary().head,a.sel.primary().head)?-1:1);Xe(a,Ye(a,b,d,!0));c&&!1===c.scroll||!a.cm||bb(a.cm)}function Xe(a,b){b.equals(a.sel)||(a.sel=b,a.cm&& (a.cm.curOp.updateInput=a.cm.curOp.selectionChanged=!0,Zd(a.cm)),X(a,"cursorActivity",a))}function Ze(a){Xe(a,Ye(a,a.sel,null,!1),pa)}function Ye(a,b,c,d){for(var e,f=0;f=b.ch:h.to>b.ch))){if(e&&(I(k,"beforeCursorEnter"),k.explicitlyCleared))if(f.markedSpans){--g;continue}else break;if(k.atomic){if(c){g=k.find(0>d?1:-1);h=void 0;if(0>d?k.inclusiveRight:k.inclusiveLeft)g=$e(a,g,-d,g&&g.line==b.line?f:null);if(g&&g.line==b.line&&(h=u(g,c))&&(0>d?0>h:0d?-1:1);if(0>d?k.inclusiveLeft: k.inclusiveRight)c=$e(a,c,d,c.line==b.line?f:null);return c?fb(a,c,b,d,e):null}}}return b}function Ed(a,b,c,d,e){d=d||1;b=fb(a,b,c,d,e)||!e&&fb(a,b,c,d,!0)||fb(a,b,c,-d,e)||!e&&fb(a,b,c,-d,!0);return b?b:(a.cantEdit=!0,q(a.first,0))}function $e(a,b,c,d){return 0>c&&0==b.ch?b.line>a.first?z(a,q(b.line-1)):null:0a.lastLine())){if(b.from.linee&&(b={from:b.from,to:q(e,v(a,e).text.length),text:[b.text[0]],origin:b.origin});b.removed=Fa(a,b.from, b.to);c||(c=zd(a,b));a.cm?pg(a.cm,b,d):Bd(a,b,d);xc(a,c,pa)}}function pg(a,b,c){var d=a.doc,e=a.display,f=b.from,g=b.to,h=!1,k=f.line;a.options.lineWrapping||(k=C(ka(v(d,f.line))),d.iter(k,g.line+1,function(a){if(a==e.maxLine)return h=!0}));-1e.maxLineLength&&(e.maxLine=a,e.maxLineLength=b,e.maxLineChanged=!0,h=!1)}),h&&(a.curOp.updateMaxLine=!0));d.frontier=Math.min(d.frontier, f.line);Eb(a,400);c=b.text.length-(g.line-f.line)-1;b.full?R(a):f.line!=g.line||1!=b.text.length||Pe(a.doc,b)?R(a,f.line,g.line+1,c):za(a,f.line,"text");c=da(a,"changes");if((d=da(a,"change"))||c)b={from:f,to:g,text:b.text,removed:b.removed,origin:b.origin},d&&X(a,"change",a,b),c&&(a.curOp.changeObjs||(a.curOp.changeObjs=[])).push(b);a.display.selForContextMenu=null}function hb(a,b,c,d,e){d||(d=c);if(0>u(d,c)){var f=d;d=c;c=f}"string"==typeof b&&(b=a.splitLines(b));gb(a,{from:c,to:d,text:b,origin:e})} function gf(a,b,c,d){c=u(f.from,x(d).to);){var g=d.pop();if(0>u(g.from,f.from)){f.from=g.from; break}}d.push(f)}aa(a,function(){for(var b=d.length-1;0<=b;b--)hb(a.doc,"",d[b].from,d[b].to,"+delete");bb(a)})}function rf(a,b){var c=v(a.doc,b);a=ka(c);a!=c&&(b=C(a));a=(c=ea(a))?c[0].level%2?ec(a):dc(a):0;return q(b,a)}function sf(a,b){var c=rf(a,b.line);a=v(a.doc,c.line);var d=ea(a);return d&&0!=d[0].level?c:(a=Math.max(0,a.text.search(/\S/)),q(c.line,b.line==c.line&&b.ch<=a&&b.ch?0:a))}function Ac(a,b,c){if("string"==typeof b&&(b=Bc[b],!b))return!1;a.display.input.ensurePolled();var d=a.display.shift, e=!1;try{a.isReadOnly()&&(a.state.suppressEdits=!0),c&&(a.display.shift=!1),e=b(a)!=Fd}finally{a.display.shift=d,a.state.suppressEdits=!1}return e}function yg(a,b,c){for(var d=0;dF&&27==a.keyCode&&(a.returnValue=!1);var b=a.keyCode;this.display.shift=16==b||a.shiftKey;var c=tf(this,a);ha&&(Gd=c?b:null,!c&&88==b&&!vf&&(ga?a.metaKey:a.ctrlKey)&&this.replaceSelection("",null,"cut"));18!=b||/\bCodeMirror-crosshair\b/.test(this.display.lineDiv.className)||Bg(this)}}function Bg(a){function b(a){18!=a.keyCode&&a.altKey||(Za(c,"CodeMirror-crosshair"),fa(document,"keyup",b),fa(document,"mouseover",b))}var c=a.display.lineDiv;Sa(c,"CodeMirror-crosshair");w(document, "keyup",b);w(document,"mouseover",b)}function wf(a){16==a.keyCode&&(this.doc.sel.shift=!1);K(this,a)}function xf(a){if(!(sa(this.display,a)||K(this,a)||a.ctrlKey&&!a.altKey||ga&&a.metaKey)){var b=a.keyCode,c=a.charCode;if(ha&&b==Gd)Gd=null,Q(a);else if(!ha||a.which&&!(10>a.which)||!tf(this,a))if(b=String.fromCharCode(null==c?b:c),"\b"!=b&&!Ag(this,a,b))this.display.input.onKeyPress(a)}}function Cg(a){var b=this.display;if(!(K(this,a)||b.activeTouch&&b.input.supportsTouch()))if(b.input.ensurePolled(), b.shift=a.shiftKey,sa(b,a))N||(b.scroller.draggable=!1,setTimeout(function(){return b.scroller.draggable=!0},100));else if(!Hd(this,a,"gutterClick",!0)){var c=Oa(this,a);window.focus();switch(ae(a)){case 1:this.state.selectingText?this.state.selectingText(a):c?Dg(this,a,c):(a.target||a.srcElement)==b.scroller&&Q(a);break;case 2:N&&(this.state.lastMiddleDown=+new Date);c&&wc(this.doc,c);setTimeout(function(){return b.input.focus()},20);Q(a);break;case 3:Id?yf(this,a):hg(this)}}}function Dg(a,b,c){B? setTimeout(Jc(Ce,a),0):a.curOp.focus=ba();var d=+new Date,e;Dc&&Dc.time>d-400&&0==u(Dc.pos,c)?e="triple":Ec&&Ec.time>d-400&&0==u(Ec.pos,c)?(e="double",Dc={time:d,pos:c}):(e="single",Ec={time:d,pos:c});var d=a.doc.sel,f=ga?b.metaKey:b.ctrlKey,g;a.options.dragDrop&&Eg&&!a.isReadOnly()&&"single"==e&&-1<(g=d.contains(c))&&(0>u((g=d.ranges[g]).from(),c)||0c.xRel)?Fg(a,b,c,f):Gg(a,b,c,e,f)}function Fg(a,b,c,d){var e=a.display,f=+new Date,g=L(a,function(h){N&&(e.scroller.draggable= !1);a.state.draggingText=!1;fa(document,"mouseup",g);fa(e.scroller,"drop",g);10>Math.abs(b.clientX-h.clientX)+Math.abs(b.clientY-h.clientY)&&(Q(h),!d&&+new Date-200w&&e.push(new A(q(h,w),q(h,Kc(r,g,f))))}e.length||e.push(new A(c,c));P(l,ia(p.ranges.slice(0,n).concat(e),n),{origin:"*mouse",scroll:!1});a.scrollIntoView(b)}else k=m,e=k.anchor,f=b,"single"!=d&&(b="double"== d?a.findWordAt(b):new A(q(b.line,0),z(l,q(b.line+1,0))),0=h.to||e.liney.bottom?20:0;m&&setTimeout(L(a,function(){B==c&&(k.scroller.scrollTop+=m,g(b))}),50)}} function h(b){a.state.selectingText=!1;B=Infinity;Q(b);k.input.focus();fa(document,"mousemove",D);fa(document,"mouseup",C);l.history.lastSelOrigin=null}var k=a.display,l=a.doc;Q(b);var m,n,p=l.sel,t=p.ranges;e&&!b.shiftKey?(n=l.sel.contains(c),m=-1=Math.floor(a.display.gutters.getBoundingClientRect().right))return!1;d&&Q(b);d=a.display;var g=d.lineDiv.getBoundingClientRect();if(f>g.bottom||!da(a,c))return Yc(b);f-=g.top-d.viewOffset;for(g=0;g=e)return e=Ga(a.doc,f),I(a,c,a,e,a.options.gutters[g],b),Yc(b)}}function yf(a,b){var c;(c=sa(a.display, b))||(c=da(a,"gutterContextMenu")?Hd(a,b,"gutterContextMenu",!1):!1);if(!c&&!K(a,b,"contextmenu"))a.display.input.onContextMenu(b)}function zf(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-");Ab(a)}function Pb(a){Me(a);R(a);sd(a)}function Ig(a,b,c){!b!=!(c&&c!=lb)&&(c=a.display.dragFunctions,b=b?w:fa,b(a.display.scroller,"dragstart",c.start),b(a.display.scroller,"dragenter",c.enter),b(a.display.scroller,"dragover", c.over),b(a.display.scroller,"dragleave",c.leave),b(a.display.scroller,"drop",c.drop))}function Jg(a){a.options.lineWrapping?(Sa(a.display.wrapper,"CodeMirror-wrap"),a.display.sizer.style.minWidth="",a.display.sizerWidth=null):(Za(a.display.wrapper,"CodeMirror-wrap"),Tc(a));pd(a);R(a);Ab(a);setTimeout(function(){return ab(a)},100)}function G(a,b){var c=this;if(!(this instanceof G))return new G(a,b);this.options=b=b?Da(b):{};Da(Af,b,!1);yd(b);var d=b.value;"string"==typeof d&&(d=new T(d,b.mode,null, b.lineSeparator));this.doc=d;var e=new G.inputStyles[b.inputStyle](this);a=this.display=new Qf(a,d,e);a.wrapper.CodeMirror=this;Me(this);zf(this);b.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");Ie(this);this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,cutIncoming:!1,selectingText:!1,draggingText:!1,highlight:new Ea,keySeq:null,specialChars:null};b.autofocus&&!pb&&a.input.focus();B&&11>F&&setTimeout(function(){return c.display.input.reset(!0)}, 20);Kg(this);Bf||(ug(),Bf=!0);cb(this);this.curOp.forceUpdate=!0;Qe(this,d);b.autofocus&&!pb||this.hasFocus()?setTimeout(Jc(rd,this),20):Cb(this);for(var f in Fc)if(Fc.hasOwnProperty(f))Fc[f](c,b[f],lb);De(this);b.finishInit&&b.finishInit(this);for(d=0;dF?w(d.scroller,"dblclick",L(a,function(b){if(!K(a,b)){var d=Oa(a,b);!d||Hd(a,b,"gutterClick",!0)||sa(a.display,b)||(Q(b),b=a.findWordAt(d),wc(a.doc,b.anchor,b.head))}})):w(d.scroller,"dblclick",function(b){return K(a,b)||Q(b)});Id||w(d.scroller,"contextmenu",function(b){return yf(a,b)});var e,f={end:0};w(d.scroller, "touchstart",function(b){var c;if(c=!K(a,b))1!=b.touches.length?c=!1:(c=b.touches[0],c=1>=c.radiusX&&1>=c.radiusY),c=!c;c&&(d.input.ensurePolled(),clearTimeout(e),c=+new Date,d.activeTouch={start:c,moved:!1,prev:300>=c-f.end?f:null},1==b.touches.length&&(d.activeTouch.left=b.touches[0].pageX,d.activeTouch.top=b.touches[0].pageY))});w(d.scroller,"touchmove",function(){d.activeTouch&&(d.activeTouch.moved=!0)});w(d.scroller,"touchend",function(e){var f=d.activeTouch;if(f&&!sa(d,e)&&null!=f.left&&!f.moved&& 300>new Date-f.start){var g=a.coordsChar(d.activeTouch,"page"),f=!f.prev||c(f,f.prev)?new A(g,g):!f.prev.prev||c(f,f.prev.prev)?a.findWordAt(g):new A(q(g.line,0),z(a.doc,q(g.line+1,0)));a.setSelection(f.anchor,f.head);a.focus();Q(e)}b()});w(d.scroller,"touchcancel",b);w(d.scroller,"scroll",function(){d.scroller.clientHeight&&(Db(a,d.scroller.scrollTop),$a(a,d.scroller.scrollLeft,!0),I(a,"scroll",a))});w(d.scroller,"mousewheel",function(b){return Ge(a,b)});w(d.scroller,"DOMMouseScroll",function(b){return Ge(a, b)});w(d.wrapper,"scroll",function(){return d.wrapper.scrollTop=d.wrapper.scrollLeft=0});d.dragFunctions={enter:function(b){K(a,b)||tb(b)},over:function(b){if(!K(a,b)){var d=Oa(a,b);if(d){var c=document.createDocumentFragment();Be(a,d,c);a.display.dragCursor||(a.display.dragCursor=r("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),a.display.lineSpace.insertBefore(a.display.dragCursor,a.display.cursorDiv));D(a.display.dragCursor,c)}tb(b)}},start:function(b){if(B&&(!a.state.draggingText||100> +new Date-mf))tb(b);else if(!K(a,b)&&!sa(a.display,b)&&(b.dataTransfer.setData("Text",a.getSelection()),b.dataTransfer.effectAllowed="copyMove",b.dataTransfer.setDragImage&&!Cf)){var d=r("img",null,null,"position: fixed; left: 0; top: 0;");d.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";ha&&(d.width=d.height=1,a.display.wrapper.appendChild(d),d._top=d.offsetTop);b.dataTransfer.setDragImage(d,0,0);ha&&d.parentNode.removeChild(d)}},drop:L(a,tg),leave:function(b){K(a, b)||lf(a)}};var g=d.input.getField();w(g,"keyup",function(b){return wf.call(a,b)});w(g,"keydown",L(a,uf));w(g,"keypress",L(a,xf));w(g,"focus",function(b){return rd(a,b)});w(g,"blur",function(b){return Cb(a,b)})}function Qb(a,b,c,d){var e=a.doc,f;null==c&&(c="add");"smart"==c&&(e.mode.indent?f=ub(a,b):c="prev");var g=a.options.tabSize,h=v(e,b),k=ca(h.text,null,g);h.stateAfter&&(h.stateAfter=null);var l=h.text.match(/^\s*/)[0],m;if(!d&&!/\S/.test(h.text))m=0,c="not";else if("smart"==c&&(m=e.mode.indent(f, h.text.slice(l.length),h.text),m==Fd||150e.first?ca(v(e,b-1).text,null,g):0:"add"==c?m=k+a.options.indentUnit:"subtract"==c?m=k-a.options.indentUnit:"number"==typeof c&&(m=k+c);m=Math.max(0,m);c="";d=0;if(a.options.indentWithTabs)for(a=Math.floor(m/g);a;--a)d+=g,c+="\t";d=a.first+a.size?b=!1:(g=b,b=l=v(a,b));if(b)h=e?(0>c?ec:dc)(l):0>c?l.text.length:0;else return!1}else h=d;return!0}var g=b.line,h=b.ch,k=c,l=v(a,g);if("char"==d)f();else if("column"==d)f(!0);else if("word"== d||"group"==d){var m=null;d="group"==d;for(var n=a.cm&&a.cm.getHelper(b,"wordChars"),p=!0;!(0>c)||f(!p);p=!1){var t=l.text.charAt(h)||"\n",t=Zb(t,n)?"w":d&&"\n"==t?"n":!d||/\s/.test(t)?null:"p";!d||p||t||(t="s");if(m&&m!=t){0>c&&(c=1,f());break}t&&(m=t);if(0c?0>=g:g>=e.height){b.hitSide=!0;break}g+=5*c}return b}function Jf(a,b){var c=jd(a,b.line);if(!c||c.hidden)return null;a=v(a.doc,b.line);c=se(c,a,b.line);a=ea(a);var d="left";a&&(d=fc(a,b.ch)%2?"right":"left");b=te(c.map,b.ch,d);b.offset="right"==b.collapse?b.end:b.start;return b}function mb(a,b){b&&(a.bad=!0);return a}function Lg(a,b,c,d,e){function f(a){return function(b){return b.id== a}}function g(b){if(1==b.nodeType){var c=b.getAttribute("cm-text");if(null!=c)h=""==c?h+b.textContent.replace(/\u200b/g,""):h+c;else{var c=b.getAttribute("cm-marker"),m;if(c)b=a.findMarks(q(d,0),q(e+1,0),f(+c)),b.length&&(m=b[0].find())&&(h+=Fa(a.doc,m.from,m.to).join(l));else if("false"!=b.getAttribute("contenteditable")){for(m=0;me?k.map:l[e],g=0;ge?a.line:a.rest[e]);e=f[g]+c;if(0>c||h!=b)e=f[g+(c?1:0)];return q(d,e)}}}var e=a.text.firstChild,f=!1;if(!b||!V(e,b))return mb(q(C(a.line),0),!0);if(b==e&&(f=!0,b=e.childNodes[c],c=0,!b))return c=a.rest?x(a.rest):a.line,mb(q(C(c),c.text.length),f);var g=3==b.nodeType?b:null,h=b;g||1!=b.childNodes.length||3!=b.firstChild.nodeType||(g=b.firstChild,c&&(c=g.nodeValue.length));for(;h.parentNode!=e;)h=h.parentNode;var k= a.measure,l=k.maps;if(b=d(g,h,c))return mb(b,f);e=h.nextSibling;for(g=g?g.nodeValue.length-c:0;e;e=e.nextSibling){if(b=d(e,e.firstChild,0))return mb(q(b.line,b.ch-g),f);g+=e.textContent.length}for(h=h.previousSibling;h;h=h.previousSibling){if(b=d(h,h.firstChild,-1))return mb(q(b.line,b.ch+c),f);c+=h.textContent.length}}var Y=navigator.userAgent,Kf=navigator.platform,wa=/gecko\/\d/i.test(Y),Lf=/MSIE \d/.test(Y),Mf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Y),B=Lf||Mf,F=B&&(Lf?document.documentMode|| 6:Mf[1]),N=/WebKit\//.test(Y),Ng=N&&/Qt\/\d+\.\d+/.test(Y),Og=/Chrome\//.test(Y),ha=/Opera\//.test(Y),Cf=/Apple Computer/.test(navigator.vendor),Pg=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(Y),kg=/PhantomJS/.test(Y),Rb=/AppleWebKit/.test(Y)&&/Mobile\/\w+/.test(Y),pb=Rb||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(Y),ga=Rb||/Mac/.test(Kf),Hg=/\bCrOS\b/.test(Y),Qg=/win/i.test(Kf),Qa=ha&&Y.match(/Version\/(\d*\.\d*)/);Qa&&(Qa=Number(Qa[1]));Qa&&15<=Qa&&(ha=!1,N=!0);var qf=ga&&(Ng||ha&& (null==Qa||12.11>Qa)),Id=wa||B&&9<=F,Za=function(a,b){var c=a.className;if(b=y(b).exec(c)){var d=c.slice(b.index+b[0].length);a.className=c.slice(0,b.index)+(d?b[1]+d:"")}},Xa;Xa=document.createRange?function(a,b,c,d){var e=document.createRange();e.setEnd(d||a,c);e.setStart(a,b);return e}:function(a,b,c){var d=document.body.createTextRange();try{d.moveToElementText(a.parentNode)}catch(e){return d}d.collapse(!0);d.moveEnd("character",c);d.moveStart("character",b);return d};var nb=function(a){a.select()}; Rb?nb=function(a){a.selectionStart=0;a.selectionEnd=a.value.length}:B&&(nb=function(a){try{a.select()}catch(b){}});Ea.prototype.set=function(a,b){clearTimeout(this.id);this.id=setTimeout(b,a)};var Fd={toString:function(){return"CodeMirror.Pass"}},pa={scroll:!1},Jd={origin:"*mouse"},Sb={origin:"+move"},Xb=[""],Of=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Pf=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/, cf=!1,xa=!1,sb=null,Tf=function(){function a(a){return 247>=a?"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(a):1424<=a&&1524>=a?"R":1536<=a&&1785>=a?"nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111".charAt(a- 1536):1774<=a&&2220>=a?"r":8192<=a&&8203>=a?"w":8204==a?"b":"L"}function b(a,b,d){this.level=a;this.from=b;this.to=d}var c=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,d=/[stwN]/,e=/[LRr]/,f=/[Lb1n]/,g=/[1n]/;return function(h){if(!c.test(h))return!1;for(var k=h.length,l=[],m=0;mF)return!1;var a=r("div");return"draggable"in a||"dragDrop"in a}(),Zc,ed,Md=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;b<=d;){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/)},Rg=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){var b;try{b=a.ownerDocument.selection.createRange()}catch(c){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},vf=function(){var a=r("div");if("oncopy"in a)return!0;a.setAttribute("oncopy","return;");return"function"==typeof a.oncopy}(),ld=null,$c={},Ua={},Va={},vb=function(a,b){this.pos= this.start=0;this.string=a;this.tabSize=b||8;this.lineStart=this.lastColumnPos=this.lastColumnValue=0};vb.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){if(this.posb},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){a=this.string.indexOf(a,this.pos);if(-1F&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Ra.prototype.update=function(a){var b=a.scrollWidth>a.clientWidth+1,c=a.scrollHeight>a.clientHeight+1,d=a.nativeBarWidth;c?(this.vert.style.display="block",this.vert.style.bottom=b?d+"px":"0",this.vert.firstChild.style.height= Math.max(0,a.scrollHeight-a.clientHeight+(a.viewHeight-(b?d:0)))+"px"):(this.vert.style.display="",this.vert.firstChild.style.height="0");b?(this.horiz.style.display="block",this.horiz.style.right=c?d+"px":"0",this.horiz.style.left=a.barLeft+"px",this.horiz.firstChild.style.width=a.scrollWidth-a.clientWidth+(a.viewWidth-a.barLeft-(c?d:0))+"px"):(this.horiz.style.display="",this.horiz.firstChild.style.width="0");!this.checkedZeroWidth&&0=u(a,d.to()))return c}return-1}};A.prototype={from:function(){return ac(this.anchor,this.head)},to:function(){return $b(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};Kb.prototype={chunkSize:function(){return this.lines.length},removeInner:function(a, b){for(var c=a,d=a+b;cthis.size-b&&(1=this.children.length)){var a=this;do{var b=a.children.splice(a.children.length-5,5),b=new Lb(b); if(a.parent){a.size-=b.size;a.height-=b.height;var c=M(a.parent.children,a);a.parent.children.splice(c+1,0,b)}else c=new Lb(a.children),c.parent=a,a.children=[c,b],a=c;b.parent=a.parent}while(10a.display.maxLineLength&&(a.display.maxLine=f,a.display.maxLineLength=g,a.display.maxLineChanged=!0);null!=c&&a&&this.collapsed&&R(a,c,d+1);this.lines.length=0;this.explicitlyCleared=!0;this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&Ze(a.doc));a&&X(a,"markerCleared",a,this);b&&db(a);this.parent&&this.parent.clear()}};Ba.prototype.find= function(a,b){null==a&&"bookmark"==this.type&&(a=1);for(var c,d,e=0;eu(h.head,h.anchor),a[f]=new A(h?k:g,h?g:k)):a[f]=new A(g,g)}a=new ua(a,this.sel.primIndex)}b=a;for(a=d.length-1;0<=a;a--)gb(this,d[a]);b?We(this,b):this.cm&&bb(this.cm)}),undo:O(function(){yc(this,"undo")}),redo:O(function(){yc(this,"redo")}),undoSelection:O(function(){yc(this,"undo",!0)}),redoSelection:O(function(){yc(this,"redo",!0)}),setExtending:function(a){this.extend=a},getExtending:function(){return this.extend},historySize:function(){for(var a= this.history,b=0,c=0,d=0;d=a.ch)&&b.push(e.marker.parent||e.marker)}return b},findMarks:function(a,b,c){a=z(this,a);b=z(this,b);var d=[],e=a.line;this.iter(a.line,b.line+1,function(f){if(f=f.markedSpans)for(var g=0;g=h.to||null==h.from&&e!=a.line||null!=h.from&&e==b.line&&h.from>=b.ch||c&&!c(h.marker)||d.push(h.marker.parent||h.marker)}++e});return d},getAllMarks:function(){var a= [];this.iter(function(b){if(b=b.markedSpans)for(var c=0;ca)return b=a,!0;a-=e;++c});return z(this,q(c,b))},indexFromPos:function(a){a=z(this,a);var b=a.ch;if(a.linea.ch)return 0;var c=this.lineSeparator().length;this.iter(this.first,a.line,function(a){b+=a.text.length+c});return b},copy:function(a){var b= new T(Nc(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep);b.scrollTop=this.scrollTop;b.scrollLeft=this.scrollLeft;b.sel=this.sel;b.extend=!1;a&&(b.history.undoDepth=this.history.undoDepth,b.setHistory(this.getHistory()));return 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.toUb;Ub++)Ca[Ub+48]=Ca[Ub+96]=String(Ub);for(var Hc=65;90>=Hc;Hc++)Ca[Hc]=String.fromCharCode(Hc);for(var Vb=1;12>=Vb;Vb++)Ca[Vb+111]=Ca[Vb+63235]="F"+Vb;var Ob={basic:{Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite", Esc:"singleSelection"},pcDefault:{"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll", "Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},emacsy:{"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars", "Ctrl-O":"openLine"},macDefault:{"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace", "Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]}};Ob["default"]=ga?Ob.macDefault:Ob.pcDefault;var Bc={selectAll:af,singleSelection:function(a){return a.setSelection(a.getCursor("anchor"),a.getCursor("head"),pa)},killLine:function(a){return kb(a,function(b){if(b.empty()){var c= v(a.doc,b.head.line).text.length;return b.head.ch==c&&b.head.linea.doc.first){var g=v(a.doc,e.line-1).text;g&&(e=new q(e.line,1),a.replaceRange(f.charAt(0)+a.doc.lineSeparator()+g.charAt(g.length-1),q(e.line-1,g.length-1),e,"+transpose"))}c.push(new A(e,e))}a.setSelections(c)})},newlineAndIndent:function(a){return aa(a,function(){for(var b=a.listSelections(), c=b.length-1;0<=c;c--)a.replaceRange(a.doc.lineSeparator(),b[c].anchor,b[c].head,"+input");b=a.listSelections();for(c=0;c=F&&setTimeout(L(e,function(){d.pollContent()||R(e)}),20)});w(f,"compositionstart",function(a){c.composing={data:a.data,done:!1}});w(f,"compositionupdate",function(a){c.composing||(c.composing={data:a.data,done:!1})});w(f,"compositionend",function(a){c.composing&&(a.data!=c.composing.data&&c.readFromDOMSoon(),c.composing.done=!0)});w(f,"touchstart",function(){return d.forceCompositionEnd()});w(f,"input",function(){c.composing||c.readFromDOMSoon()}); w(f,"copy",b);w(f,"cut",b)};E.prototype.prepareSelection=function(){var a=Ae(this.cm,!1);a.focus=this.cm.state.focused;return a};E.prototype.showSelection=function(a,b){a&&this.cm.display.view.length&&((a.focus||b)&&this.showPrimarySelection(),this.showMultipleSelections(a))};E.prototype.showPrimarySelection=function(){var a=window.getSelection(),b=this.cm.doc.sel.primary(),c=Gc(this.cm,a.anchorNode,a.anchorOffset),d=Gc(this.cm,a.focusNode,a.focusOffset);if(!c||c.bad||!d||d.bad||0!=u(ac(c,d),b.from())|| 0!=u($b(c,d),b.to()))if(c=Jf(this.cm,b.from()),d=Jf(this.cm,b.to()),c||d){var e=this.cm.display.view,b=a.rangeCount&&a.getRangeAt(0);c?d||(d=e[e.length-1].measure,d=d.maps?d.maps[d.maps.length-1]:d.map,d={node:d[d.length-1],offset:d[d.length-2]-d[d.length-3]}):c={node:e[0].measure.map[2],offset:0};var f;try{f=Xa(c.node,c.offset,d.offset,d.node)}catch(g){}f&&(!wa&&this.cm.state.focused?(a.collapse(c.node,c.offset),f.collapsed||(a.removeAllRanges(),a.addRange(f))):(a.removeAllRanges(),a.addRange(f)), b&&null==a.anchorNode?a.addRange(b):wa&&this.startGracePeriod());this.rememberSelection()}};E.prototype.startGracePeriod=function(){var a=this;clearTimeout(this.gracePeriod);this.gracePeriod=setTimeout(function(){a.gracePeriod=!1;a.selectionChanged()&&a.cm.operation(function(){return a.cm.curOp.selectionChanged=!0})},20)};E.prototype.showMultipleSelections=function(a){D(this.cm.display.cursorDiv,a.cursors);D(this.cm.display.selectionDiv,a.selection)};E.prototype.rememberSelection=function(){var a= window.getSelection();this.lastAnchorNode=a.anchorNode;this.lastAnchorOffset=a.anchorOffset;this.lastFocusNode=a.focusNode;this.lastFocusOffset=a.focusOffset};E.prototype.selectionInEditor=function(){var a=window.getSelection();if(!a.rangeCount)return!1;a=a.getRangeAt(0).commonAncestorContainer;return V(this.div,a)};E.prototype.focus=function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()||this.showSelection(this.prepareSelection(),!0),this.div.focus())};E.prototype.blur=function(){this.div.blur()}; E.prototype.getField=function(){return this.div};E.prototype.supportsTouch=function(){return!0};E.prototype.receivedFocus=function(){function a(){b.cm.state.focused&&(b.pollSelection(),b.polling.set(b.cm.options.pollInterval,a))}var b=this;this.selectionInEditor()?this.pollSelection():aa(this.cm,function(){return b.cm.curOp.selectionChanged=!0});this.polling.set(this.cm.options.pollInterval,a)};E.prototype.selectionChanged=function(){var a=window.getSelection();return a.anchorNode!=this.lastAnchorNode|| a.anchorOffset!=this.lastAnchorOffset||a.focusNode!=this.lastFocusNode||a.focusOffset!=this.lastFocusOffset};E.prototype.pollSelection=function(){if(!this.composing&&null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var a=window.getSelection(),b=this.cm;this.rememberSelection();var c=Gc(b,a.anchorNode,a.anchorOffset),d=Gc(b,a.focusNode,a.focusOffset);c&&d&&aa(b,function(){P(b.doc,va(c,d),pa);if(c.bad||d.bad)b.curOp.selectionChanged=!0})}};E.prototype.pollContent=function(){null!= this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var a=this.cm,b=a.display,c=a.doc.sel.primary(),d=c.from(),c=c.to();0==d.ch&&d.line>a.firstLine()&&(d=q(d.line-1,v(a.doc,d.line-1).length));c.ch==v(a.doc,c.line).text.length&&c.lineb.viewTo-1)return!1;var e;d.line==b.viewFrom||0==(e=La(a,d.line))?(d=C(b.view[0].line),e=b.view[0].node):(d=C(b.view[e].line),e=b.view[e-1].node.nextSibling);var f=La(a,c.line); f==b.view.length-1?(c=b.viewTo-1,b=b.lineDiv.lastChild):(c=C(b.view[f+1].line)-1,b=b.view[f+1].node.previousSibling);if(!e)return!1;b=a.doc.splitLines(Lg(a,e,b,d,c));for(e=Fa(a.doc,q(d,0),q(c,v(a.doc,c).text.length));1F&&f.scrollbars.setScrollTop(f.scroller.scrollTop=k);if(null!=g.selectionStart){(!B||B&&9>F)&&b();var a=0,c=function(){f.selForContextMenu==e.doc.sel&&0==g.selectionStart&&0a++?f.detectingSelectAll=setTimeout(c, 500):f.input.reset()};f.detectingSelectAll=setTimeout(c,200)}}var d=this,e=d.cm,f=e.display,g=d.textarea,h=Oa(e,a),k=f.scroller.scrollTop;if(h&&!ha){e.options.resetSelectionOnContextMenu&&-1==e.doc.sel.contains(h)&&L(e,P)(e.doc,va(h),pa);var l=g.style.cssText,m=d.wrapper.style.cssText;d.wrapper.style.cssText="position: absolute";h=d.wrapper.getBoundingClientRect();g.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(a.clientY-h.top-5)+"px; left: "+(a.clientX-h.left-5)+"px;\n z-index: 1000; background: "+ (B?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var n;N&&(n=window.scrollY);f.input.focus();N&&window.scrollTo(null,n);f.input.reset();e.somethingSelected()||(g.value=d.prevInput=" ");d.contextMenuPending=!0;f.selForContextMenu=e.doc.sel;clearTimeout(f.detectingSelectAll);B&&9<=F&&b();if(Id){tb(a);var p=function(){fa(window,"mouseup",p);setTimeout(c,20)};w(window,"mouseup",p)}else setTimeout(c, 50)}};J.prototype.readOnlyChanged=function(a){a||this.reset()};J.prototype.setUneditable=function(){};J.prototype.needsContentAttribute=!1;(function(a){function b(b,e,f,g){a.defaults[b]=e;f&&(c[b]=g?function(a,b,d){d!=lb&&f(a,b,d)}:f)}var c=a.optionHandlers;a.defineOption=b;a.Init=lb;b("value","",function(a,b){return a.setValue(b)},!0);b("mode",null,function(a,b){a.doc.modeOption=b;Ad(a)},!0);b("indentUnit",2,Ad,!0);b("indentWithTabs",!1);b("smartIndent",!0);b("tabSize",4,function(a){Gb(a);Ab(a); R(a)},!0);b("lineSeparator",null,function(a,b){if(a.doc.lineSep=b){var d=[],c=a.doc.first;a.doc.iter(function(a){for(var e=0;;){var f=a.text.indexOf(b,e);if(-1==f)break;e=f+b.length;d.push(q(c,f))}c++});for(var e=d.length-1;0<=e;e--)hb(a.doc,b,d[e],q(d[e].line,d[e].ch+b.length))}});b("specialChars",/[\u0000-\u001f\u007f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,function(a,b,c){a.state.specialChars=new RegExp(b.source+(b.test("\t")?"":"|\t"),"g");c!=lb&&a.refresh()});b("specialCharPlaceholder", bg,function(a){return a.refresh()},!0);b("electricChars",!0);b("inputStyle",pb?"contenteditable":"textarea",function(){throw Error("inputStyle can not (yet) be changed in a running editor");},!0);b("spellcheck",!1,function(a,b){return a.getInputField().spellcheck=b},!0);b("rtlMoveVisually",!Qg);b("wholeLineUpdateBefore",!0);b("theme","default",function(a){zf(a);Pb(a)},!0);b("keyMap","default",function(a,b,c){b=zc(b);(c=c!=lb&&zc(c))&&c.detach&&c.detach(a,b);b.attach&&b.attach(a,c||null)});b("extraKeys", null);b("lineWrapping",!1,Jg,!0);b("gutters",[],function(a){yd(a.options);Pb(a)},!0);b("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?od(a.display)+"px":"0";a.refresh()},!0);b("coverGutterNextToScrollbar",!1,function(a){return ab(a)},!0);b("scrollbarStyle","native",function(a){Ie(a);ab(a);a.display.scrollbars.setScrollTop(a.doc.scrollTop);a.display.scrollbars.setScrollLeft(a.doc.scrollLeft)},!0);b("lineNumbers",!1,function(a){yd(a.options);Pb(a)},!0);b("firstLineNumber",1,Pb,!0);b("lineNumberFormatter", function(a){return a},Pb,!0);b("showCursorWhenSelecting",!1,Bb,!0);b("resetSelectionOnContextMenu",!0);b("lineWiseCopyCut",!0);b("readOnly",!1,function(a,b){"nocursor"==b?(Cb(a),a.display.input.blur(),a.display.disabled=!0):a.display.disabled=!1;a.display.input.readOnlyChanged(b)});b("disableInput",!1,function(a,b){b||a.display.input.reset()},!0);b("dragDrop",!0,Ig);b("allowDropFileTypes",null);b("cursorBlinkRate",530);b("cursorScrollMargin",0);b("cursorHeight",1,Bb,!0);b("singleCursorHeightPerLine", !0,Bb,!0);b("workTime",100);b("workDelay",100);b("flattenSpans",!0,Gb,!0);b("addModeClass",!1,Gb,!0);b("pollInterval",100);b("undoDepth",200,function(a,b){return a.doc.history.undoDepth=b});b("historyEventDelay",1250);b("viewportMargin",10,function(a){return a.refresh()},!0);b("maxHighlightLength",1E4,Gb,!0);b("moveInputWithCursor",!0,function(a,b){b||a.display.input.resetPosition()});b("tabindex",null,function(a,b){return a.display.input.getField().tabIndex=b||""});b("autofocus",null)})(G);(function(a){var b= a.optionHandlers,c=a.helpers={};a.prototype={constructor:a,focus:function(){window.focus();this.display.input.focus()},setOption:function(a,c){var d=this.options,e=d[a];if(d[a]!=c||"mode"==a)d[a]=c,b.hasOwnProperty(a)&&L(this,b[a])(this,c,e),I(this,"optionChange",this,a)},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](zc(a))},removeKeyMap:function(a){for(var b=this.state.keyMaps,d=0;dd&&(Qb(this,h.head.line,a,!0),d=h.head.line,c==this.doc.sel.primIndex&&bb(this));else{for(var k=h.from(),h=h.to(),l=Math.max(d,k.line),d=Math.min(this.lastLine(),h.line-(h.ch?0:1))+1,h=l;h>1;if((h?b[2*h-1]:0)>=a)c=h;else if(b[2*h+1]d?b:0==d?null:b.slice(0,d-1)}, getModeAt:function(b){var d=this.doc.mode;return d.innerMode?a.innerMode(d,this.getTokenAt(b).state).mode:d},getHelper:function(a,b){return this.getHelpers(a,b)[0]},getHelpers:function(a,b){var d=[];if(!c.hasOwnProperty(b))return d;var e=c[b];a=this.getModeAt(a);if("string"==typeof a[b])e[a[b]]&&d.push(e[a[b]]);else if(a[b])for(var h=0;he&&(a=e,d=!0);a=v(this.doc,a)}return md(this,a,{top:0,left:0},b||"page",c).top+(d?this.doc.height-la(a):0)},defaultTextHeight:function(){return Ma(this.display)},defaultCharWidth:function(){return zb(this.display)},getViewport:function(){return{from:this.display.viewFrom, to:this.display.viewTo}},addWidget:function(a,b,c,g,h){var d=this.display;a=ta(this,z(this.doc,a));var e=a.bottom,f=a.left;b.style.position="absolute";b.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(b);d.sizer.appendChild(b);if("over"==g)e=a.top;else if("above"==g||"near"==g){var n=Math.max(d.wrapper.clientHeight,this.doc.height),p=Math.max(d.sizer.clientWidth,d.lineSpace.clientWidth);("above"==g||a.bottom+b.offsetHeight>n)&&a.top>b.offsetHeight?e=a.top-b.offsetHeight:a.bottom+ b.offsetHeight<=n&&(e=a.bottom);f+b.offsetWidth>p&&(f=p-b.offsetWidth)}b.style.top=e+"px";b.style.left=b.style.right="";"right"==h?(f=d.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==h?f=0:"middle"==h&&(f=(d.sizer.clientWidth-b.offsetWidth)/2),b.style.left=f+"px");c&&(a=pc(this,f,e,f+b.offsetWidth,e+b.offsetHeight),null!=a.scrollTop&&Db(this,a.scrollTop),null!=a.scrollLeft&&$a(this,a.scrollLeft))},triggerOnKeyDown:S(uf),triggerOnKeyPress:S(xf),triggerOnKeyUp:wf,execCommand:function(a){if(Bc.hasOwnProperty(a))return Bc[a].call(null, this)},triggerElectric:S(function(a){Df(this,a)}),findPosH:function(a,b,c,g){var d=1;0>b&&(d=-1,b=-b);a=z(this.doc,a);for(var e=0;ea?d.from():d.to()},Sb)}),deleteH:S(function(a,b){var c=this.doc;this.doc.sel.somethingSelected()?c.replaceSelection("",null,"+delete"):kb(this,function(d){var e= Nd(c,d.head,a,b,!1);return 0>a?{from:e,to:d.head}:{from:d.head,to:e}})}),findPosV:function(a,b,c,g){var d=1;0>b&&(d=-1,b=-b);var e=z(this.doc,a);for(a=0;aa?f.from():f.to();var g=ta(c,f.head,"div");null!=f.goalColumn&&(g.left=f.goalColumn);e.push(g.left); var h=If(c,g,a,b);"page"==b&&f==d.sel.primary()&&qc(c,null,lc(c,h,"div").top-g.top);return h},Sb);if(e.length)for(var l=0;la.xRel||d==b.length)&&c?--c:++d;for(var k=b.charAt(c),k=Zb(k,h)?function(a){return Zb(a,h)}:/\s/.test(k)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!Zb(a)};0M(Tg,Wb)&&(G.prototype[Wb]=function(a){return function(){return a.apply(this.doc,arguments)}}(T.prototype[Wb]));Ta(T);G.inputStyles={textarea:J,contenteditable:E};G.defineMode= function(a){G.defaults.mode||"null"==a||(G.defaults.mode=a);Vf.apply(this,arguments)};G.defineMIME=function(a,b){Ua[a]=b};G.defineMode("null",function(){return{token:function(a){return a.skipToEnd()}}});G.defineMIME("text/plain","null");G.defineExtension=function(a,b){G.prototype[a]=b};G.defineDocExtension=function(a,b){T.prototype[a]=b};G.fromTextArea=function(a,b){function c(){a.value=h.getValue()}b=b?Da(b):{};b.value=a.value;!b.tabindex&&a.tabIndex&&(b.tabindex=a.tabIndex);!b.placeholder&&a.placeholder&& (b.placeholder=a.placeholder);if(null==b.autofocus){var d=ba();b.autofocus=d==a||null!=a.getAttribute("autofocus")&&d==document.body}var e;if(a.form&&(w(a.form,"submit",c),!b.leaveSubmitMethodAlone)){var f=a.form;e=f.submit;try{var g=f.submit=function(){c();f.submit=e;f.submit();f.submit=g}}catch(k){}}b.finishInit=function(b){b.save=c;b.getTextArea=function(){return a};b.toTextArea=function(){b.toTextArea=isNaN;c();a.parentNode.removeChild(b.getWrapperElement());a.style.display="";a.form&&(fa(a.form, "submit",c),"function"==typeof a.form.submit&&(a.form.submit=e))}};a.style.display="none";var h=G(function(b){return a.parentNode.insertBefore(b,a.nextSibling)},b);return h};(function(a){a.off=fa;a.on=w;a.wheelEventPixels=ig;a.Doc=T;a.splitLines=Md;a.countColumn=ca;a.findColumn=Kc;a.isWordChar=Mc;a.Pass=Fd;a.signal=I;a.Line=Wa;a.changeEnd=Aa;a.scrollbarModel=Je;a.Pos=q;a.cmpPos=u;a.modes=$c;a.mimeModes=Ua;a.resolveMode=hc;a.getMode=ad;a.modeExtensions=Va;a.extendMode=Wf;a.copyState=qa;a.startState= be;a.innerMode=bd;a.commands=Bc;a.keyMap=Ob;a.keyName=pf;a.isModifierKey=of;a.lookupKey=jb;a.normalizeKeyMap=xg;a.StringStream=vb;a.SharedTextMarker=Nb;a.TextMarker=Ba;a.LineWidget=Mb;a.e_preventDefault=Q;a.e_stopPropagation=$d;a.e_stop=tb;a.addClass=Sa;a.contains=V;a.rmClass=Za;a.keyNames=Ca})(G);G.version="5.22.0";return G});