(function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.CodeMirror=t()})(this,function(){"use strict";function e(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function t(t){for(var e=t.childNodes.length;0n||n>=t)return i+(t-s);i+=n-s,i+=o-i%o,s=n+1}}function g(e,t){for(var n=0;n=t)return n+xl(l,t-o);if(o+=r-n,o+=i-o%i,n=r+1,o>=t)return n}}function f(e){for(;Zl.length<=e;)Zl.push(y(Zl)+" ");return Zl[e]}function y(e){return e[e.length-1]}function m(e,t){for(var n=[],o=0;oi?0i?-1:1;;){if(t==i)return t;var o=(t+i)/2,r=0>n?vl(o):yl(o);if(r==t)return e(r)?t:i;e(r)?i=r:t=r+n}}function N(e,t,i){var n=this;this.input=i,n.scrollbarFiller=o("div",null,"CodeMirror-scrollbar-filler"),n.scrollbarFiller.setAttribute("cm-not-content","true"),n.gutterFiller=o("div",null,"CodeMirror-gutter-filler"),n.gutterFiller.setAttribute("cm-not-content","true"),n.lineDiv=r("div",null,"CodeMirror-code"),n.selectionDiv=o("div",null,null,"position: relative; z-index: 1"),n.cursorDiv=o("div",null,"CodeMirror-cursors"),n.measure=o("div",null,"CodeMirror-measure"),n.lineMeasure=o("div",null,"CodeMirror-measure"),n.lineSpace=r("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var l=r("div",[n.lineSpace],"CodeMirror-lines");n.mover=o("div",[l],null,"position: relative"),n.sizer=o("div",[n.mover],"CodeMirror-sizer"),n.sizerWidth=null,n.heightForcer=o("div",null,null,"position: absolute; height: 30px; width: 1px;"),n.gutters=o("div",null,"CodeMirror-gutters"),n.lineGutter=null,n.scroller=o("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll"),n.scroller.setAttribute("tabIndex","-1"),n.wrapper=o("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror"),Tl&&8>ie&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),Nl||wl&&zl||(n.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(n.wrapper):e(n.wrapper)),n.viewFrom=n.viewTo=t.first,n.reportedViewFrom=n.reportedViewTo=t.first,n.view=[],n.renderedView=null,n.externalMeasured=null,n.viewOffset=0,n.lastWrapHeight=n.lastWrapWidth=0,n.updateLineNumbers=null,n.nativeBarWidth=n.barHeight=n.barWidth=0,n.scrollbarsClipped=!1,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.alignWidgets=!1,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null,n.activeTouch=null,i.init(n)}function O(e,t){if(t-=e.first,0>t||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var o=0;;++o){var i=n.children[o],r=i.chunkSize();if(t=e.first&&tI(e,t)?t:e}function G(e,t){return 0>I(e,t)?e:t}function $(e,t){return ml(e.first,xl(t,e.first+e.size-1))}function U(e,t){if(t.linei?z(i,O(e,i).text.length):j(t,O(e,t.line).text.length)}function j(e,t){var i=e.ch;return null==i||i>t?z(e.line,t):0>i?z(e.line,0):e}function V(e,t){for(var n=[],o=0;o=t:i.to>t);(o||(o=[])).push(new Y(l,i.from,d?null:i.to))}}return o}function J(e,t,n){var o;if(e)for(var r=0;r=t:i.to>t);if(s||i.from==t&&"bookmark"==l.type&&(!n||i.marker.insertLeft)){var d=null==i.from||(l.inclusiveLeft?i.from<=t:i.fromI(a.to,s.from)||0c)&&(i.inclusiveLeft||c)||p.push({from:a.from,to:s.from}),!(0de(o,r.marker))&&(o=r.marker);return o}function pe(e){return ae(e,!0)}function ce(e){return ae(e,!1)}function he(e,t,n,o,r){var l=O(e,t),s=ts&&l.markedSpans;if(s)for(var d=0,i;d=c||0>=p&&0<=c)&&(0>=p&&(i.marker.inclusiveRight&&r.inclusiveLeft?0<=I(a.to,n):0=I(a.from,o):0>I(a.from,o))))return!0}}function ge(e){for(var t;t=pe(e);)e=t.find(-1,!0).line;return e}function ue(e){for(var t;t=ce(e);)e=t.find(1,!0).line;return e}function fe(e){for(var t,i;t=ce(e);)e=t.find(1,!0).line,(i||(i=[])).push(e);return i}function me(e,t){var i=O(e,t),n=ge(i);return i==n?t:D(n)}function ye(e,t){if(t>e.lastLine())return t;var i=O(e,t),n;if(!ve(e,i))return t;for(;n=ce(i);)i=n.find(1,!0).line;return D(i)+1}function ve(e,t){var n=ts&&t.markedSpans;if(n)for(var o=void 0,r=0;rt.maxLineLength&&(t.maxLineLength=i,t.maxLine=e)})}function Se(e,t,n,o){if(!e)return o(t,n,"ltr",0);for(var r=!1,l=0,i;lt||t==n&&i.to==t)&&(o(ml(i.from,t),xl(i.to,n),1==i.level?"rtl":"ltr",l),r=!0);r||o(t,n,"ltr")}function Le(e,t,n){var o;is=null;for(var r=0,i;rt)return r;i.to==t&&(i.from!=i.to&&"before"==n?o=r:is=r),i.from==t&&(i.from!=i.to&&"before"!=n?o=r:is=r)}return null==o?is:o}function ke(e,t){var i=e.order;return null==i&&(i=e.order=ns(e.text,t)),i}function Te(e,t){return e._handlers&&e._handlers[t]||os}function Ne(e,t,i){if(e.removeEventListener)e.removeEventListener(t,i,!1);else if(e.detachEvent)e.detachEvent("on"+t,i);else{var n=e._handlers,o=n&&n[t];if(o){var r=g(o,i);-1=t.offsetWidth&&2ie))}var i=us?o("span","\u200B"):o("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}function Be(e){if(null!=fs)return fs;var i=n(e,document.createTextNode("A\u062EA")),o=jl(i,0,1).getBoundingClientRect(),r=jl(i,1,2).getBoundingClientRect();return t(e),!!(o&&o.left!=o.right)&&(fs=3>r.right-o.right)}function Ge(e){if(null!=as)return as;var t=n(e,o("span","x")),i=t.getBoundingClientRect(),r=jl(t,0,1).getBoundingClientRect();return as=1e&&r.splice(a,1,e,r[a+1],l),a+=2,i=xl(e,l);if(t)if(o.opaque)r.splice(n,a-n,e,"overlay "+t),a=n+2;else for(;ne.options.maxHighlightLength&&Ke(e.doc.mode,n.state),r=_e(e,t,n);o&&(n.state=o),t.stateAfter=n.save(!o),t.styles=r.styles,r.classes?t.styleClasses=r.classes:t.styleClasses&&(t.styleClasses=null),i===e.doc.highlightFrontier&&(e.doc.modeFrontier=ml(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function Ze(e,t,i){var n=e.doc,o=e.display;if(!n.mode.startState)return new ys(n,!0,t);var r=ot(e,t,i),l=r>n.first&&O(n,r-1).stateAfter,s=l?ys.fromSaved(n,l,r):new ys(n,Ye(n.mode),r);return n.iter(r,t,function(i){Qe(e,i.text,s);var n=s.line;i.stateAfter=n==t-1||0==n%5||n>=o.viewFrom&&nr;r++){o&&(o[0]=Xe(e,n).mode);var i=e.token(t,n);if(t.pos>t.start)return i}throw new Error("Mode "+e.name+" failed to advance stream.")}function tt(e,t,i,n){var o=e.doc,r=o.mode,l;t=U(o,t);var s=O(o,t.line),d=Ze(e,t.line,i),a=new gs(s.text,e.options.tabSize,d),p;for(n&&(p=[]);(n||a.pose.options.maxHighlightLength?(s=!1,l&&Qe(e,t,n,p.pos),p.pos=t.length,h=null):h=it(et(i,p,n.state,c),r),c){var g=c[0].name;g&&(h="m-"+(h?g+" "+h:g))}if(!s||a!=h){for(;do;--r){if(r<=n.first)return n.first;var d=O(n,r-1),a=d.stateAfter;if(a&&(!i||r+(a instanceof ms?a.lookAhead:0)<=n.modeFrontier))return r;var p=h(d.text,null,e.options.tabSize);(null==s||l>p)&&(s=r-1,l=p)}return s}function rt(e,t){if(e.modeFrontier=xl(e.modeFrontier,t),!(e.highlightFrontieri;n--)if(o=O(e,n).stateAfter,o&&(!(o instanceof ms)||n+o.lookAheadie&&(p=!0),e.pos+=t.length;else{c=document.createDocumentFragment();for(var h=0;;){a.lastIndex=h;var g=a.exec(t),u=g?g.index-h:t.length-h;if(u){var m=document.createTextNode(d.slice(h,h+u));Tl&&9>ie?c.appendChild(o("span",[m])):c.appendChild(m),e.map.push(e.pos,e.pos+u,m),e.col+=u,e.pos+=u}if(!g)break;h+=u+1;var y=void 0;if("\t"==g[0]){var v=e.cm.options.tabSize,x=v-e.col%v;y=c.appendChild(o("span",f(x),"cm-tab")),y.setAttribute("role","presentation"),y.setAttribute("cm-text","\t"),e.col+=x}else"\r"==g[0]||"\n"==g[0]?(y=c.appendChild(o("span","\r"==g[0]?"\u240D":"\u2424","cm-invalidchar")),y.setAttribute("cm-text",g[0]),e.col+=1):(y=e.cm.options.specialCharPlaceholder(g[0]),y.setAttribute("cm-text",g[0]),Tl&&9>ie?c.appendChild(o("span",[y])):c.appendChild(y),e.col+=1);e.map.push(e.pos,e.pos+1,y),e.pos++}}if(e.trailingSpace=32==d.charCodeAt(t.length-1),i||n||r||p||s){var b=i||"";n&&(b+=n),r&&(b+=r);var C=o("span",[c],b,s);return l&&(C.title=l),e.content.appendChild(C)}e.content.appendChild(c)}}function ht(e,t){if(1p&&h.from<=p));g++);if(h.to>=c)return e(n,o,r,l,s,d,a);e(n,o.slice(0,h.to-p),r,l,null,d,a),l=null,o=o.slice(h.to-p),p=h.to}}}function ut(e,t,i,n){var o=!n&&i.widgetNode;o&&e.map.push(e.pos,e.pos+t,o),!n&&e.cm.display.input.needsContentAttribute&&(!o&&(o=e.content.appendChild(document.createElement("span"))),o.setAttribute("cm-marker",i.id)),o&&(e.cm.display.input.setUneditable(o),e.content.appendChild(o)),e.pos+=t,e.trailingSpace=!1}function ft(e,t,n){var o=e.markedSpans,r=e.text,l=0;if(!o){for(var s=1;sa||L.collapsed&&S.to==a&&S.from==a)?(null!=S.to&&S.to!=a&&c>S.to&&(c=S.to,f=""),L.className&&(u+=" "+L.className),L.css&&(g=(g?g+";":"")+L.css),L.startStyle&&S.from==a&&(y+=" "+L.startStyle),L.endStyle&&S.to==c&&(C||(C=[])).push(L.endStyle,S.to),L.title&&!v&&(v=L.title),L.collapsed&&(!x||0>de(x.marker,L))&&(x=S)):S.from>a&&c>S.from&&(c=S.from)}if(C)for(var m=0;m=d)break;for(var T=xl(d,c);;){if(i){var N=a+i.length;if(!x){var O=N>T?i.slice(0,T-a):i;t.addToken(t,O,h?h+u:u,y,a+O.length==c?f:"",v,g)}if(N>=T){i=i.slice(T-a),a=T;break}a=N,y=""}i=r.slice(l,l=n[p++]),h=dt(n[p++],t.cm.options)}}}function mt(e,t,i){this.line=t,this.rest=fe(t),this.size=this.rest?D(y(this.rest))-i+1:1,this.node=this.text=null,this.hidden=ve(e,t)}function yt(e,t,i){for(var n=[],o=t,r,l;oie&&(e.node.style.zIndex=2)),e.node}function kt(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i&&(i+=" CodeMirror-linebackground"),t.background)i?t.background.className=i:(t.background.parentNode.removeChild(t.background),t.background=null);else if(i){var n=Lt(t);t.background=n.insertBefore(o("div",null,i),n.firstChild),e.display.input.setUneditable(t.background)}}function Tt(e,t){var i=e.display.externalMeasured;return i&&i.line==t.line?(e.display.externalMeasured=null,t.measure=i.measure,i.built):at(e,t)}function Nt(e,t){var i=t.text.className,n=Tt(e,t);t.text==t.node&&(t.node=n.pre),t.text.parentNode.replaceChild(n.pre,t.text),t.text=n.pre,n.bgClass!=t.bgClass||n.textClass!=t.textClass?(t.bgClass=n.bgClass,t.textClass=n.textClass,Ot(e,t)):i&&(t.text.className=i)}function Ot(e,t){kt(e,t),t.line.wrapClass?Lt(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function At(e,t,i,n){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var r=Lt(t);t.gutterBackground=o("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),r.insertBefore(t.gutterBackground,t.text)}var l=t.line.gutterMarkers;if(e.options.lineNumbers||l){var s=Lt(t),d=t.gutter=o("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px");if(e.display.input.setUneditable(d),s.insertBefore(d,t.text),t.line.gutterClass&&(d.className+=" "+t.line.gutterClass),!e.options.lineNumbers||l&&l["CodeMirror-linenumbers"]||(t.lineNumber=d.appendChild(o("div",P(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),l)for(var a=0;an)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Vt(e,t){t=ge(t);var i=D(t),o=e.display.externalMeasured=new mt(e.doc,t,i);o.lineN=i;var r=o.built=at(e,o);return o.text=r.pre,n(e.display.lineMeasure,r.pre),o}function Kt(e,t,i,n){return _t(e,Yt(e,t),i,n)}function Xt(e,t){if(t>=e.display.viewFrom&&t=i.lineN&&tt)&&(l=a-d,r=l-1,t>=a&&(s="right")),null!=r){if(i=e[o+2],d==a&&n==(i.insertLeft?"left":"right")&&(s=n),"left"==n&&0==r)for(;o&&e[o-2]==e[o-3]&&e[o-1].insertLeft;)i=e[(o-=3)+2],s="left";if("right"==n&&r==a-d)for(;oc;c++){for(;s&&L(t.line.text.charAt(r.coverStart+s));)--s;for(;r.coverStart+die&&0==s&&d==r.coverEnd-r.coverStart?l.parentNode.getBoundingClientRect():Zt(jl(l,s,d).getClientRects(),o),p.left||p.right||0==s)break;d=s,--s,a="right"}Tl&&11>ie&&(p=Jt(e.display.measure,p))}else{0ie&&!s&&(!p||!p.left&&!p.right)){var g=l.parentNode.getClientRects()[0];p=g?{left:g.left,right:g.left+bi(e.display),top:g.top,bottom:g.bottom}:Ls}for(var u=p.top-t.rect.top,f=p.bottom-t.rect.top,m=t.view.measure.heights,y=0;y=n.text.length?(a=n.text.length,p="before"):0>=a&&(a=0,p="after"),!d)return l("before"==p?a-1:a,"before"==p);var c=Le(d,a,p),h=is,g=s(a,c,"before"==p);return null!=h&&(g.other=s(a,h,"before"!=p)),g}function pi(e,t){var i=0;t=U(e.doc,t),e.options.lineWrapping||(i=bi(e.display)*t.ch);var n=O(e.doc,t.line),o=be(n)+It(e.display);return{left:i,right:i,top:o,bottom:o+n.height}}function ci(e,t,i,n,o){var r=z(e,t,i);return r.xRel=o,n&&(r.outside=!0),r}function hi(e,t,i){var n=e.doc;if(i+=e.display.viewOffset,0>i)return ci(n.first,0,null,!0,-1);var o=H(n,i),r=n.first+n.size-1;if(o>r)return ci(n.first+n.size-1,O(n,r).text.length,null,!0,1);0>t&&(t=0);for(var l=O(n,o);;){var s=mi(e,l,o,t,i),d=ce(l),a=d&&d.find(0,!0);if(d&&(s.ch>a.from.ch||s.ch==a.from.ch&&0n},r,o),{begin:r,end:o}}function ui(e,t,i,n){i||(i=Yt(e,t));var o=li(e,t,_t(e,i,n),"line").top;return gi(e,t,i,o)}function fi(e,t,i,n){return!(e.bottom<=i)&&(!!(e.top>i)||(n?e.left:e.right)>t)}function mi(e,t,i,n,o){o-=be(t);var r=Yt(e,t),l=ri(t),s=0,d=t.text.length,a=!0,p=ke(t,e.doc.direction);if(p){var c=(e.options.lineWrapping?vi:yi)(e,t,i,r,p,n,o);a=1!=c.level,s=a?c.from:c.to-1,d=a?c.to:c.from-1}var h=null,g=null,u=T(function(t){var i=_t(e,r,t);return(i.top+=l,i.bottom+=l,!!fi(i,n,o,!1))&&(i.top<=o&&i.left<=n&&(h=t,g=i),!0)},s,d),f=!1,m,y;if(g){var v=n-g.left=b.bottom}return u=k(t.text,u,1),ci(i,u,y,f,n-m)}function yi(e,t,n,o,r,l,s){var i=T(function(d){var i=r[d],a=1!=i.level;return fi(ai(e,z(n,a?i.to:i.from,a?"before":"after"),"line",t,o),l,s,!0)},0,r.length-1),d=r[i];if(0s&&(d=r[i-1])}return d}function vi(e,t,n,o,r,l,s){var d=gi(e,t,o,s),a=d.begin,c=d.end;/\s/.test(t.text.charAt(c-1))&&c--;for(var h=null,g=null,u=0,i;u=c||i.to<=a)){var p=1!=i.level,f=_t(e,o,p?xl(c,i.to)-1:ml(a,i.from)).right,m=fm)&&(h=i,g=m)}return h||(h=r[r.length-1]),h.fromc&&(h={from:h.from,to:c,level:h.level}),h}function xi(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Ts){Ts=o("pre");for(var r=0;49>r;++r)Ts.appendChild(document.createTextNode("x")),Ts.appendChild(o("br"));Ts.appendChild(document.createTextNode("x"))}n(e.measure,Ts);var i=Ts.offsetHeight/50;return 3=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var n=e.display.view,o=0;ot)return o}function Ni(e){e.display.input.showSelection(e.display.input.prepareSelection())}function Oi(e,t){void 0===t&&(t=!0);for(var n=e.doc,o={},r=o.cursors=document.createDocumentFragment(),l=o.selection=document.createDocumentFragment(),s=0;s=e.display.viewTo||i.to().linet&&(t=0),t=ul(t),n=ul(n),d.appendChild(o("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(null==i?c-e:i)+"px;\n height: "+(n-t)+"px"))}function r(t,o,r){function l(i,n){return di(e,z(t,i),"div",d,n)}function i(t,i,n){var o=ui(e,d,null,t),r="ltr"==i==("after"==n)?"left":"right",s="after"==n?o.begin:o.end-(/\s/.test(d.text.charAt(o.end-1))?2:1);return l(s,r)[r]}var d=O(s,t),a=d.text.length,g=ke(d,s.direction),u,f;return Se(g,o||0,null==r?a:r,function(e,t,s,d){var m="ltr"==s,y=l(e,m?"left":"right"),v=l(t-1,m?"right":"left"),x=null==o&&0==e,b=null==r&&t==a,C=0==d,w=!g||d==g.length-1;if(3>=v.top-y.top){var S=(h?x:b)&&C,L=(h?b:x)&&w,k=S?p:(m?y:v).left,T=L?c:(m?v:y).right;n(k,y.top,T-k,y.bottom)}else{var N,O,A,M;m?(N=h&&x&&C?p:y.left,O=h?c:i(e,s,"before"),A=h?p:i(t,s,"after"),M=h&&b&&w?c:v.right):(N=h?i(e,s,"before"):p,O=!h&&x&&C?c:y.right,A=!h&&b&&w?p:v.left,M=h?i(t,s,"after"):c),n(N,y.top,O-N,y.bottom),y.bottomMi(y,u))&&(u=y),0>Mi(v,u)&&(u=v),(!f||0>Mi(y,f))&&(f=y),0>Mi(v,f)&&(f=v)}),{start:u,end:f}}var l=e.display,s=e.doc,d=document.createDocumentFragment(),a=Rt(e.display),p=a.left,c=ml(l.sizerWidth,Gt(e)-l.sizer.offsetLeft)-a.right,h="ltr"==s.direction,g=t.from(),u=t.to();if(g.line==u.line)r(g.line,g.ch,u.ch);else{var f=O(s,g.line),m=O(s,u.line),y=ge(f)==ge(m),v=r(g.line,g.ch,y?f.text.length+1:null).end,x=r(u.line,y?0:null,u.ch).start;y&&(v.tope.options.cursorBlinkRate&&(t.cursorDiv.style.visibility="hidden")}}function Hi(e){e.state.focused||(e.display.input.focus(),Pi(e))}function Fi(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,zi(e))},100)}function Pi(t,i){t.state.delayingBlurEvent&&(t.state.delayingBlurEvent=!1),"nocursor"==t.options.readOnly||(!t.state.focused&&(Oe(t,"focus",t,i),t.state.focused=!0,d(t.display.wrapper,"CodeMirror-focused"),!t.curOp&&t.display.selForContextMenu!=t.doc.sel&&(t.display.input.reset(),Nl&&setTimeout(function(){return t.display.input.reset(!0)},20)),t.display.input.receivedFocus()),Di(t))}function zi(t,i){t.state.delayingBlurEvent||(t.state.focused&&(Oe(t,"blur",t,i),t.state.focused=!1,Ul(t.display.wrapper,"CodeMirror-focused")),clearInterval(t.display.blinker),setTimeout(function(){t.state.focused||(t.display.shift=!1)},150))}function Ii(e){for(var t=e.display,n=t.lineDiv.offsetTop,o=0;oie){var l=i.node.offsetTop+i.node.offsetHeight;r=l-n,n=l}else{var s=i.node.getBoundingClientRect();r=s.bottom-s.top}var d=i.line.height-r;if(2>r&&(r=xi(t)),(.005d)&&(W(i.line,r),Ei(i.line),i.rest))for(var a=0;a=l&&(r=H(t,be(O(t,d))-e.wrapper.clientHeight),l=d)}return{from:r,to:ml(l,r+1)}}function Bi(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var o=wi(t)-t.scroller.scrollLeft+e.doc.scrollLeft,r=t.gutters.offsetWidth,l=o+"px",s=0;st.top+n.top?r=!0:t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)&&(r=!1),null!=r&&!Hl){var l=o("div","\u200B",null,"position: absolute;\n top: "+(t.top-i.viewOffset-It(e.display))+"px;\n height: "+(t.bottom-t.top+Bt(e)+i.barHeight)+"px;\n left: "+t.left+"px; width: "+ml(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(l),l.scrollIntoView(r),e.display.lineSpace.removeChild(l)}}}function Ui(e,t,i,n){null==n&&(n=0);var o;e.options.lineWrapping||t!=i||(t=t.ch?z(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t,i="before"==t.sticky?z(t.line,t.ch+1,"before"):t);for(var r=0;5>r;r++){var l=!1,s=ai(e,t),d=i&&i!=t?ai(e,i):s;o={left:xl(s.left,d.left),top:xl(s.top,d.top)-n,right:ml(s.left,d.left),bottom:ml(s.bottom,d.bottom)+n};var a=Vi(e,o),p=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop&&(Qi(e,a.scrollTop),1t.top&&(t.top=0);var o=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:i.scroller.scrollTop,r=$t(e),l={};t.bottom-t.top>r&&(t.bottom=t.top+r);var s=e.doc.height+Et(i),d=t.tops-n;if(t.topo+r){var p=xl(t.top,(a?s:t.bottom)-r);p!=o&&(l.scrollTop=p)}var c=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:i.scroller.scrollLeft,h=Gt(e)-(e.options.fixedGutter?i.gutters.offsetWidth:0),g=t.right-t.left>h;return g&&(t.right=t.left+h),10>t.left?l.scrollLeft=0:t.lefth+c-3&&(l.scrollLeft=t.right+(g?0:10)-h),l}function Ki(e,t){null==t||(qi(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Xi(e){qi(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Yi(e,t,i){(null!=t||null!=i)&&qi(e),null!=t&&(e.curOp.scrollLeft=t),null!=i&&(e.curOp.scrollTop=i)}function _i(e,t){qi(e),e.curOp.scrollToPos=t}function qi(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=pi(e,t.from),n=pi(e,t.to);Zi(e,i,n,t.margin)}}function Zi(e,t,i,n){var o=Vi(e,{left:xl(t.left,i.left),top:xl(t.top,i.top)-n,right:ml(t.right,i.right),bottom:ml(t.bottom,i.bottom)+n});Yi(e,o.scrollLeft,o.scrollTop)}function Qi(e,t){2>fl(e.doc.scrollTop-t)||(!wl&&Dn(e,{top:t}),Ji(e,t,!0),wl&&Dn(e),kn(e,100))}function Ji(e,t,i){t=xl(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t),(e.display.scroller.scrollTop!=t||i)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function en(e,t,i,n){t=xl(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth),(i?t==e.doc.scrollLeft:2>fl(e.doc.scrollLeft-t))&&!n||(e.doc.scrollLeft=t,Bi(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function tn(e){var t=e.display,i=t.gutters.offsetWidth,n=ul(e.doc.height+Et(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:n,scrollHeight:n+Bt(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}function nn(e,t){t||(t=tn(e));var n=e.display.barWidth,o=e.display.barHeight;rn(e,t);for(var r=0;4>r&&n!=e.display.barWidth||o!=e.display.barHeight;r++)n!=e.display.barWidth&&e.options.lineWrapping&&Ii(e),rn(e,tn(e)),n=e.display.barWidth,o=e.display.barHeight}function rn(e,t){var i=e.display,n=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=n.right)+"px",i.sizer.style.paddingBottom=(i.barHeight=n.bottom)+"px",i.heightForcer.style.borderBottom=n.bottom+"px solid transparent",n.right&&n.bottom?(i.scrollbarFiller.style.display="block",i.scrollbarFiller.style.height=n.bottom+"px",i.scrollbarFiller.style.width=n.right+"px"):i.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(i.gutterFiller.style.display="block",i.gutterFiller.style.height=n.bottom+"px",i.gutterFiller.style.width=t.gutterWidth+"px"):i.gutterFiller.style.display=""}function ln(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&Ul(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Os[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),rs(t,"mousedown",function(){e.state.focused&&setTimeout(function(){return e.display.input.focus()},0)}),t.setAttribute("cm-not-content","true")},function(t,i){"horizontal"==i?en(e,t):Qi(e,t)},e),e.display.scrollbars.addClass&&d(e.display.wrapper,e.display.scrollbars.addClass)}function sn(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.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:++As},vt(e.curOp)}function dn(e){var t=e.curOp;bt(t,function(e){for(var t=0;t=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Ms(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function cn(e){e.updatedDisplay=e.mustUpdate&&Mn(e.cm,e.update)}function hn(e){var t=e.cm,i=t.display;e.updatedDisplay&&Ii(t),e.barMeasure=tn(t),i.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Kt(t,i.maxLine,i.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=ml(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+Bt(t)+t.display.barWidth),e.maxScrollLeft=ml(0,i.sizer.offsetLeft+e.adjustWidthTo-Gt(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=i.input.prepareSelection())}function gn(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeftt)&&(o.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=o.viewTo)ts&&me(e.doc,t)o.viewFrom?Cn(e):(o.viewFrom+=n,o.viewTo+=n);else if(t<=o.viewFrom&&i>=o.viewTo)Cn(e);else if(t<=o.viewFrom){var r=wn(e,i,i+n,1);r?(o.view=o.view.slice(r.index),o.viewFrom=r.lineN,o.viewTo+=n):Cn(e)}else if(i>=o.viewTo){var l=wn(e,t,t,-1);l?(o.view=o.view.slice(0,l.index),o.viewTo=l.lineN):Cn(e)}else{var s=wn(e,t,t,-1),d=wn(e,i,i+n,1);s&&d?(o.view=o.view.slice(0,s.index).concat(yt(e,s.lineN,d.lineN)).concat(o.view.slice(d.index)),o.viewTo+=n):Cn(e)}var a=o.externalMeasured;a&&(i=o.lineN&&t=n.viewTo)){var r=n.view[Ti(e,t)];if(null!=r.node){var l=r.changes||(r.changes=[]);-1==g(l,i)&&l.push(i)}}}function Cn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function wn(e,t,o,r){var l=Ti(e,t),s=e.display.view,d;if(!ts||o==e.doc.first+e.doc.size)return{index:l,lineN:o};for(var a=e.display.viewFrom,n=0;nr?0:s.length-1))return null;o+=r*s[l-(0>r?1:0)].size,l+=r}return{index:l,lineN:o}}function Sn(e,t,i){var n=e.display,o=n.view;0==o.length||t>=n.viewTo||i<=n.viewFrom?(n.view=yt(e,t,i),n.viewFrom=t):(n.viewFrom>t?n.view=yt(e,t,n.viewFrom).concat(n.view):n.viewFromi&&(n.view=n.view.slice(0,Ti(e,i)))),n.viewTo=i}function Ln(e){for(var t=e.display.view,n=0,o=0,i;o=e.display.viewTo)){var n=+new Date+e.options.workTime,o=Ze(e,t.highlightFrontier),r=[];t.iter(o.line,xl(t.first+t.size,e.display.viewTo+500),function(l){if(o.line>=e.display.viewFrom){var s=l.styles,d=l.text.length>e.options.maxHighlightLength?Ke(t.mode,o.state):null,a=_e(e,l,o,!0);d&&(o.state=d),l.styles=a.styles;var p=l.styleClasses,c=a.classes;c?l.styleClasses=c:p&&(l.styleClasses=null);for(var h=!s||s.length!=l.styles.length||p!=c&&(!p||!c||p.bgClass!=c.bgClass||p.textClass!=c.textClass),g=0;!h&&gn?(kn(e,e.options.workDelay),!0):void 0}),t.highlightFrontier=o.line,t.modeFrontier=ml(t.modeFrontier,o.line),r.length&&fn(e,function(){for(var t=0;t=n.viewFrom&&i.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==Ln(e))return!1;Gi(e)&&(Cn(e),i.dims=Ci(e));var r=o.first+o.size,l=ml(i.visible.from-e.options.viewportMargin,o.first),s=xl(r,i.visible.to+e.options.viewportMargin);n.viewFroml-n.viewFrom&&(l=ml(o.first,n.viewFrom)),n.viewTo>s&&20>n.viewTo-s&&(s=xl(r,n.viewTo)),ts&&(l=me(e.doc,l),s=ye(e.doc,s));var d=l!=n.viewFrom||s!=n.viewTo||n.lastWrapHeight!=i.wrapperHeight||n.lastWrapWidth!=i.wrapperWidth;Sn(e,l,s),n.viewOffset=be(O(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var a=Ln(e);if(!d&&0==a&&!i.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var p=On(e);return 4=e.display.viewFrom&&t.visible.to<=e.display.viewTo))break;if(!Mn(e,t))break;Ii(e);var o=tn(e);Ni(e),nn(e,o),Pn(e,o),t.force=!1}t.signal(e,"update",e),(e.display.viewFrom!=e.display.reportedViewFrom||e.display.viewTo!=e.display.reportedViewTo)&&(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Dn(e,t){var i=new Ms(e,t);if(Mn(e,i)){Ii(e),Wn(e,i);var n=tn(e);Ni(e),nn(e,n),Pn(e,n),i.finish()}}function Hn(e,n,o){function r(t){var i=t.nextSibling;return Nl&&Il&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),i}for(var l=e.display,s=e.options.lineNumbers,d=l.lineDiv,a=d.firstChild,p=l.view,c=l.viewFrom,h=0,i;hs.clientWidth,a=s.scrollHeight>s.clientHeight;if(o&&d||r&&a){if(r&&Il&&Nl)outer:for(var p=n.target,c=l.view;p!=s;p=p.parentNode)for(var h=0;hi?g=ml(0,g+i-50):u=xl(t.doc.height,u+i+50),Dn(t,{top:g,bottom:u})}20>Ws&&(null==l.wheelStartX?(l.wheelStartX=s.scrollLeft,l.wheelStartY=s.scrollTop,l.wheelDX=o,l.wheelDY=r,setTimeout(function(){if(null!=l.wheelStartX){var e=s.scrollLeft-l.wheelStartX,t=s.scrollTop-l.wheelStartY,i=t&&l.wheelDY&&t/l.wheelDY||e&&l.wheelDX&&e/l.wheelDX;l.wheelStartX=l.wheelStartY=null,i&&(Ds=(Ds*Ws+i)/(Ws+1),++Ws)}},200)):(l.wheelDX+=o,l.wheelDY+=r))}}function Gn(e,t){var n=e[t];e.sort(function(e,t){return I(e.from(),t.from())}),t=g(e,n);for(var o=1;oI(e,t.from))return e;if(0>=I(e,t.to))return Un(t);var i=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=Un(t).ch-t.to.ch),z(i,n)}function Vn(e,t){for(var n=[],o=0,i;oI(p.head,p.anchor);o[s]=new Fs(c?a:d,c?d:a)}else o[s]=new Fs(d,d)}return new Hs(o,e.sel.primIndex)}function Yn(e){e.doc.mode=je(e.options,e.doc.modeOption),_n(e)}function _n(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,kn(e,100),e.state.modeGen++,e.curOp&&xn(e)}function qn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==y(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Zn(e,t,i,n){function o(e){return i?i[e]:null}function r(e,i,o){lt(e,i,o,n),Ct(e,"change",e,t)}function l(e,t){for(var r=[],l=e;lr-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(l=ro(o,o.lastOp==n)))s=y(l.changes),0==I(t.from,t.to)&&0==I(t.from,s.to)?s.to=Un(t):l.changes.push(no(e,t));else{var d=y(o.done);for(d&&d.ranges||po(e.sel,o.done),l={changes:[no(e,t)],generation:o.generation},o.done.push(l);o.done.length>o.undoDepth;)o.done.shift(),o.done[0].ranges||o.done.shift()}o.done.push(i),o.generation=++o.maxGeneration,o.lastModTime=o.lastSelTime=r,o.lastOp=o.lastSelOp=n,o.lastOrigin=o.lastSelOrigin=t.origin,s||Oe(e,"historyAdded")}function so(e,t,i,n){var o=t.charAt(0);return"*"==o||"+"==o&&i.ranges.length==n.ranges.length&&i.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function ao(e,t,i,n){var o=e.history,r=n&&n.origin;i==o.lastSelOp||r&&o.lastSelOrigin==r&&(o.lastModTime==o.lastSelTime&&o.lastOrigin==r||so(e,r,y(o.done),t))?o.done[o.done.length-1]=t:po(t,o.done),o.lastSelTime=+new Date,o.lastSelOrigin=r,o.lastSelOp=i,n&&!1!==n.clearRedo&&oo(o.undone)}function po(e,t){var i=y(t);i&&i.ranges&&i.equals(e)||t.push(e)}function co(e,t,i,o){var r=t["spans_"+e.id],l=0;e.iter(ml(e.first,i),xl(e.first+e.size,o),function(i){i.markedSpans&&((r||(r=t["spans_"+e.id]={}))[l]=i.markedSpans),++l})}function ho(e){if(!e)return null;for(var t=0,i;tI(t,o);r==0>I(i,o)?r!=0>I(t,i)&&(t=i):(o=t,t=i)}return new Fs(o,t)}return new Fs(i||t,t)}function yo(e,t,i,n,o){null==o&&(o=e.cm&&(e.cm.display.shift||e.extend)),So(e,new Hs([mo(e.sel.primary(),t,i,o)],0),n)}function vo(e,t,n){for(var o=[],r=e.cm&&(e.cm.display.shift||e.extend),l=0;lI(t.primary().head,e.sel.primary().head)?-1:1);ko(e,No(e,t,n,!0)),!(i&&!1===i.scroll)&&e.cm&&Xi(e.cm)}function ko(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0,Me(e.cm)),Ct(e,"cursorActivity",e))}function To(e){ko(e,No(e,e.sel,null,!1))}function No(e,t,n,o){for(var r=0,i;r=t.ch:i.to>t.ch))){if(r&&(Oe(d,"beforeCursorEnter"),d.explicitlyCleared))if(!l.markedSpans)break;else{--s;continue}if(!d.atomic)continue;if(n){var a=d.find(0>o?1:-1),p=void 0;if((0>o?d.inclusiveRight:d.inclusiveLeft)&&(a=Mo(e,a,-o,a&&a.line==t.line?l:null)),a&&a.line==t.line&&(p=I(a,n))&&(0>o?0>p:0o?-1:1);return(0>o?d.inclusiveLeft:d.inclusiveRight)&&(c=Mo(e,c,o,c.line==t.line?l:null)),c?Oo(e,c,t,o,r):null}}return t}function Ao(e,t,i,n,o){var r=n||1,l=Oo(e,t,i,r,o)||!o&&Oo(e,t,i,r,!0)||Oo(e,t,i,-r,o)||!o&&Oo(e,t,i,-r,!0);return l?l:(e.cantEdit=!0,z(e.first,0))}function Mo(e,t,i,n){return 0>i&&0==t.ch?t.line>e.first?U(e,z(t.line-1)):null:0e.lastLine())){if(t.from.liner&&(t={from:t.from,to:z(r,O(e,r).text.length),text:[t.text[0]],origin:t.origin}),t.removed=A(e,t.from,t.to),i||(i=Vn(e,t)),e.cm?Eo(e.cm,t,n):Zn(e,t,n),Lo(e,i,Yl)}}function Eo(e,t,i){var n=e.doc,o=e.display,r=t.from,l=t.to,s=!1,d=r.line;e.options.lineWrapping||(d=D(ge(O(n,r.line))),n.iter(d,l.line+1,function(e){if(e==o.maxLine)return s=!0,!0})),-1o.maxLineLength&&(o.maxLine=e,o.maxLineLength=t,o.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),rt(n,r.line),kn(e,400);var a=t.text.length-(l.line-r.line)-1;t.full?xn(e):r.line!=l.line||1!=t.text.length||qn(e.doc,t)?xn(e,r.line,l.line+1,a):bn(e,r.line,"text");var p=We(e,"changes"),c=We(e,"change");if(c||p){var h={from:r,to:l,text:t.text,removed:t.removed,origin:t.origin};c&&Ct(e,"change",e,h),p&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}e.display.selForContextMenu=null}function Ro(e,t,i,n,o){if(n||(n=i),0>I(n,i)){var r;r=[n,i],i=r[0],n=r[1],r}"string"==typeof t&&(t=e.splitLines(t)),Ho(e,{from:i,to:n,text:t,origin:o})}function Bo(e,t,i,n){i+new Date-Gs))return void ze(i);if(!(Ae(t,i)||zt(t.display,i))&&(i.dataTransfer.setData("Text",t.getSelection()),i.dataTransfer.effectAllowed="copyMove",i.dataTransfer.setDragImage&&!Wl)){var e=o("img",null,null,"position: fixed; left: 0; top: 0;");e.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",Ml&&(e.width=e.height=1,t.display.wrapper.appendChild(e),e._top=e.offsetTop),i.dataTransfer.setDragImage(e,0,0),Ml&&e.parentNode.removeChild(e)}}function tr(t,i){var e=ki(t,i);if(e){var r=document.createDocumentFragment();Ai(t,e,r),t.display.dragCursor||(t.display.dragCursor=o("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),t.display.lineSpace.insertBefore(t.display.dragCursor,t.display.cursorDiv)),n(t.display.dragCursor,r)}}function ir(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function nr(e){if(document.getElementsByClassName)for(var t=document.getElementsByClassName("CodeMirror"),n=0,i;n=I(i.from,y(o).to);){var l=o.pop();if(0>I(l.from,i.from)){i.from=l.from;break}}o.push(i)}fn(e,function(){for(var t=o.length-1;0<=t;t--)Ro(e.doc,"",o[t].from,o[t].to,"+delete");Xi(e)})}function fr(e,t,i){var n=k(e.text,t+i,i);return 0>n||n>e.text.length?null:n}function mr(e,t,i){var n=fr(e,t.ch,i);return null==n?null:new z(t.line,n,0>i?"after":"before")}function yr(e,t,i,n,o){if(e){var r=ke(i,t.doc.direction);if(r){var l=0>o?y(r):r[0],s=0>o==(1==l.level),d=s?"after":"before",a;if(0o?i.text.length-1:0;var c=_t(t,p,a).top;a=T(function(e){return _t(t,p,e).top==c},0>o==(1==l.level)?l.from:l.to-1,a),"before"==d&&(a=fr(i,a,1))}else a=0>o?l.to:l.from;return new z(n,a,d)}}return new z(n,0>o?i.text.length:0,0>o?"before":"after")}function vr(e,t,i,n){var o=ke(t,e.doc.direction);if(!o)return mr(t,i,n);i.ch>=t.text.length?(i.ch=t.text.length,i.sticky="before"):0>=i.ch&&(i.ch=0,i.sticky="after");var r=Le(o,i.ch,i.sticky),l=o[r];if("ltr"==e.doc.direction&&0==l.level%2&&(0i.ch:l.fromn,h=s(i,c?1:-1);if(null!=h&&(c?h<=l.to&&h<=a.end:h>=l.from&&h>=a.begin)){var g=c?"before":"after";return new z(i.line,h,g)}}var u=function(e,t,n){for(var r=function(e,t){return t?new z(i.line,s(e,1),"before"):new z(i.line,e,"after")};0<=e&&eie&&27==t.keyCode&&(t.returnValue=!1);var i=t.keyCode;e.display.shift=16==i||t.shiftKey;var n=Tr(e,t);Ml&&(_s=n?i:null,!n&&88==i&&!ds&&(Il?t.metaKey:t.ctrlKey)&&e.replaceSelection("",null,"cut")),18!=i||/\bCodeMirror-crosshair\b/.test(e.display.lineDiv.className)||Ar(e)}}function Ar(e){function t(n){18!=n.keyCode&&n.altKey||(Ul(i,"CodeMirror-crosshair"),Ne(document,"keyup",t),Ne(document,"mouseover",t))}var i=e.display.lineDiv;d(i,"CodeMirror-crosshair"),rs(document,"keyup",t),rs(document,"mouseover",t)}function Mr(t){16==t.keyCode&&(this.doc.sel.shift=!1),Ae(this,t)}function Wr(t){var e=this;if(!(zt(e.display,t)||Ae(e,t)||t.ctrlKey&&!t.altKey||Il&&t.metaKey)){var i=t.keyCode,n=t.charCode;if(Ml&&i==_s)return _s=null,void He(t);if(!(Ml&&(!t.which||10>t.which)&&Tr(e,t))){var o=gl(null==n?i:n);"\b"==o||Nr(e,t,o)||e.display.input.onKeyPress(t)}}}function Dr(e,t){var i=+new Date;return td&&td.compare(i,e,t)?(ed=td=null,"triple"):ed&&ed.compare(i,e,t)?(td=new qs(i,e,t),ed=null,"double"):(ed=new qs(i,e,t),td=null,"single")}function Hr(t){var e=this,i=e.display;if(!(Ae(e,t)||i.activeTouch&&i.input.supportsTouch())){if(i.input.ensurePolled(),i.shift=t.shiftKey,zt(i,t))return void(Nl||(i.scroller.draggable=!1,setTimeout(function(){return i.scroller.draggable=!0},100)));if(!$r(e,t)){var n=ki(e,t),o=Ee(t),r=n?Dr(n,o):"single";window.focus(),1==o&&e.state.selectingText&&e.state.selectingText(t),n&&Fr(e,o,n,r,t)||(1==o?n?zr(e,n,r,t):Ie(t)==i.scroller&&He(t):2==o?(n&&yo(e.doc,n),setTimeout(function(){return i.input.focus()},20)):3==o&&($l?Ur(e,t):Fi(e)))}}}function Fr(e,t,i,n,o){var r="Click";return"double"==n?r="Double"+r:"triple"==n&&(r="Triple"+r),r=(1==t?"Left":2==t?"Middle":"Right")+r,Lr(e,cr(r,o),o,function(t){if("string"==typeof t&&(t=Xs[t]),!t)return!1;var n=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),n=t(e,i)!=Xl}finally{e.state.suppressEdits=!1}return n})}function Pr(e,t,i){var n=e.getOption("configureMouse"),o=n?n(e,t,i):{};if(null==o.unit){var r=El?i.shiftKey&&i.metaKey:i.altKey;o.unit=r?"rectangle":"single"==t?"char":"double"==t?"word":"line"}return(null==o.extend||e.doc.extend)&&(o.extend=e.doc.extend||i.shiftKey),null==o.addNew&&(o.addNew=Il?i.metaKey:i.ctrlKey),null==o.moveOnDrag&&(o.moveOnDrag=Il?!i.altKey:!i.ctrlKey),o}function zr(e,t,i,n){Tl?setTimeout(p(Hi,e),0):e.curOp.focus=s();var o=Pr(e,i,n),r=e.doc.sel,l;e.options.dragDrop&&on&&!e.isReadOnly()&&"single"==i&&-1<(l=r.contains(t))&&(0>I((l=r.ranges[l]).from(),t)||0t.xRel)?Ir(e,n,t,o):Rr(e,n,t,o)}function Ir(t,e,i,n){var o=t.display,r=!1,l=mn(t,function(a){Nl&&(o.scroller.draggable=!1),t.state.draggingText=!1,Ne(o.wrapper.ownerDocument,"mouseup",l),Ne(o.wrapper.ownerDocument,"mousemove",s),Ne(o.scroller,"dragstart",d),Ne(o.scroller,"drop",l),r||(He(a),!n.addNew&&yo(t.doc,i,null,null,n.extend),Nl||Tl&&9==ie?setTimeout(function(){o.wrapper.ownerDocument.body.focus(),o.input.focus()},20):o.input.focus())}),s=function(t){r=r||10<=fl(e.clientX-t.clientX)+fl(e.clientY-t.clientY)},d=function(){return r=!0};Nl&&(o.scroller.draggable=!0),t.state.draggingText=l,l.copy=!n.moveOnDrag,o.scroller.dragDrop&&o.scroller.dragDrop(),rs(o.wrapper.ownerDocument,"mouseup",l),rs(o.wrapper.ownerDocument,"mousemove",s),rs(o.scroller,"dragstart",d),rs(o.scroller,"drop",l),Fi(t),setTimeout(function(){return o.input.focus()},20)}function Er(e,t,i){if("char"==i)return new Fs(t,t);if("word"==i)return e.findWordAt(t);if("line"==i)return new Fs(z(t.line,0),U(e.doc,z(t.line+1,0)));var n=i(e,t);return new Fs(n.from,n.to)}function Rr(t,e,i,n){function o(e){if(0!=I(y,e))if(y=e,"rectangle"==n.unit){for(var o=[],r=t.options.tabSize,l=h(O(a,i.line).text,i.ch,r),s=h(O(a,e.line).text,e.ch,r),d=xl(l,s),c=ml(l,s),m=xl(i.line,e.line),v=xl(t.lastLine(),ml(i.line,e.line));m<=v;m++){var x=O(a,m).text,b=u(x,d,r);d==c?o.push(new Fs(z(m,b),z(m,b))):x.length>b&&o.push(new Fs(z(m,b),z(m,u(x,c,r))))}o.length||o.push(new Fs(i,i)),So(a,Gn(p.ranges.slice(0,f).concat(o),f),{origin:"*mouse",scroll:!1}),t.scrollIntoView(e)}else{var C=g,w=Er(t,e,n.unit),S=C.anchor,L;0=p.to||l.linev.bottom?20:0;c&&setTimeout(mn(t,function(){x!=e||(d.scroller.scrollTop+=c,r(i))}),50)}}function l(i){t.state.selectingText=!1,x=Infinity,He(i),d.input.focus(),Ne(d.wrapper.ownerDocument,"mousemove",b),Ne(d.wrapper.ownerDocument,"mouseup",C),a.history.lastSelOrigin=null}var d=t.display,a=t.doc;He(e);var p=a.sel,c=p.ranges,g,f;if(n.addNew&&!n.extend?(f=a.sel.contains(i),g=-1c:0=yl(t.display.gutters.getBoundingClientRect().right))return!1;o&&He(n);var s=t.display,d=s.lineDiv.getBoundingClientRect();if(l>d.bottom||!We(t,e))return Pe(n);l-=d.top-s.viewOffset;for(var a=0,i;a=r){var p=H(t.doc,l),c=t.options.gutters[a];return Oe(t,e,t,p,c,n),Pe(n)}}function $r(t,i){return Gr(t,i,"gutterClick",!0)}function Ur(t,i){zt(t.display,i)||jr(t,i)||Ae(t,i,"contextmenu")||t.display.input.onContextMenu(i)}function jr(t,i){return!!We(t,"gutterContextMenu")&&Gr(t,i,"gutterContextMenu",!1)}function Vr(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),ii(e)}function Kr(e){zn(e),xn(e),Bi(e)}function Xr(e,t,i){if(!t!=!(i&&i!=Zs)){var n=e.display.dragFunctions,o=t?rs:Ne;o(e.display.scroller,"dragstart",n.start),o(e.display.scroller,"dragenter",n.enter),o(e.display.scroller,"dragover",n.over),o(e.display.scroller,"dragleave",n.leave),o(e.display.scroller,"drop",n.drop)}}function Yr(e){e.options.lineWrapping?(d(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Ul(e.display.wrapper,"CodeMirror-wrap"),we(e)),Li(e),xn(e),ii(e),setTimeout(function(){return nn(e)},100)}function _r(e,t){var n=this;if(!(this instanceof _r))return new _r(e,t);this.options=t=t?c(t):{},c(Qs,t,!1),In(t);var o=t.value;"string"==typeof o&&(o=new Bs(o,t.mode,null,t.lineSeparator,t.direction)),this.doc=o;var r=new _r.inputStyles[t.inputStyle](this),l=this.display=new N(e,o,r);for(var s in l.wrapper.CodeMirror=this,zn(this),Vr(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),ln(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 Kl,keySeq:null,specialChars:null},t.autofocus&&!zl&&l.input.focus(),Tl&&11>ie&&setTimeout(function(){return n.display.input.reset(!0)},20),qr(this),or(),sn(this),this.curOp.forceUpdate=!0,Jn(this,o),t.autofocus&&!zl||this.hasFocus()?setTimeout(p(Pi,this),20):zi(this),Js)Js.hasOwnProperty(s)&&Js[s](n,t[s],Zs);Gi(this),t.finishInit&&t.finishInit(this);for(var d=0;d=e.radiusX&&1>=e.radiusY}function o(e,t){if(null==t.left)return!0;var i=t.left-e.left,n=t.top-e.top;return 400ie?rs(r.scroller,"dblclick",mn(t,function(i){if(!Ae(t,i)){var e=ki(t,i);if(!(!e||$r(t,i)||zt(t.display,i))){He(i);var n=t.findWordAt(e);yo(t.doc,n.anchor,n.head)}}})):rs(r.scroller,"dblclick",function(i){return Ae(t,i)||He(i)}),$l||rs(r.scroller,"contextmenu",function(i){return Ur(t,i)});var l={end:0},s;rs(r.scroller,"touchstart",function(i){if(!Ae(t,i)&&!n(i)&&!$r(t,i)){r.input.ensurePolled(),clearTimeout(s);var e=+new Date;r.activeTouch={start:e,moved:!1,prev:300>=e-l.end?l:null},1==i.touches.length&&(r.activeTouch.left=i.touches[0].pageX,r.activeTouch.top=i.touches[0].pageY)}}),rs(r.scroller,"touchmove",function(){r.activeTouch&&(r.activeTouch.moved=!0)}),rs(r.scroller,"touchend",function(n){var e=r.activeTouch;if(e&&!zt(r,n)&&null!=e.left&&!e.moved&&300>new Date-e.start){var l=t.coordsChar(r.activeTouch,"page"),s;s=!e.prev||o(e,e.prev)?new Fs(l,l):!e.prev.prev||o(e,e.prev.prev)?t.findWordAt(l):new Fs(z(l.line,0),U(t.doc,z(l.line+1,0))),t.setSelection(s.anchor,s.head),t.focus(),He(n)}i()}),rs(r.scroller,"touchcancel",i),rs(r.scroller,"scroll",function(){r.scroller.clientHeight&&(Qi(t,r.scroller.scrollTop),en(t,r.scroller.scrollLeft,!0),Oe(t,"scroll",t))}),rs(r.scroller,"mousewheel",function(i){return Bn(t,i)}),rs(r.scroller,"DOMMouseScroll",function(i){return Bn(t,i)}),rs(r.wrapper,"scroll",function(){return r.wrapper.scrollTop=r.wrapper.scrollLeft=0}),r.dragFunctions={enter:function(i){Ae(t,i)||ze(i)},over:function(i){Ae(t,i)||(tr(t,i),ze(i))},start:function(i){return er(t,i)},drop:mn(t,Jo),leave:function(i){Ae(t,i)||ir(t)}};var e=r.input.getField();rs(e,"keyup",function(i){return Mr.call(t,i)}),rs(e,"keydown",mn(t,Or)),rs(e,"keypress",mn(t,Wr)),rs(e,"focus",function(i){return Pi(t,i)}),rs(e,"blur",function(i){return zi(t,i)})}function Zr(e,t,n,o){var r=e.doc,l;null==n&&(n="add"),"smart"==n&&(r.mode.indent?l=Ze(e,t).state:n="prev");var s=e.options.tabSize,d=O(r,t),a=h(d.text,null,s);d.stateAfter&&(d.stateAfter=null);var p=d.text.match(/^\s*/)[0],c;if(!o&&!/\S/.test(d.text))c=0,n="not";else if("smart"==n&&(c=r.mode.indent(l,d.text.slice(p.length),d.text),c==Xl||150r.first?c=h(O(r,t-1).text,null,s):c=0:"add"==n?c=a+e.options.indentUnit:"subtract"==n?c=a-e.options.indentUnit:"number"==typeof n&&(c=a+n),c=ml(0,c);var g="",u=0;if(e.options.indentWithTabs)for(var m=yl(c/s);m;--m)u+=s,g+="\t";if(u=e.first+e.size)&&(t=new z(n,t.ch,t.sticky),a=O(e,n))}function l(n){var l;if(l=o?vr(e.cm,a,t,i):mr(a,t,i),null!=l)t=l;else if(!n&&r())t=yr(o,e.cm,a,t.line,i);else return!1;return!0}var s=t,d=i,a=O(e,t.line);if("char"==n)l();else if("column"==n)l(!0);else if("word"==n||"group"==n)for(var p=null,c="group"==n,h=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;;g=!1){if(0>i&&!l(!g))break;var u=a.text.charAt(t.ch)||"\n",f=w(u,h)?"w":c&&"\n"==u?"n":!c||/\s/.test(u)?null:"p";if(!c||g||f||(f="s"),p&&p!=f){0>i&&(i=1,l(),t.sticky="after");break}if(f&&(p=f),0i?0>=l:l>=o.height){a.hitSide=!0;break}l+=5*i}return a}function sl(e,t){var i=Xt(e,t.line);if(!i||i.hidden)return null;var n=O(e.doc,t.line),o=jt(i,n,t.line),r=ke(n,e.doc.direction),l="left";if(r){var s=Le(r,t.ch);l=s%2?"right":"left"}var d=qt(o.map,t.ch,l);return d.offset="right"==d.collapse?d.end:d.start,d}function dl(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}function al(e,t){return t&&(e.bad=!0),e}function pl(e,t,i,n,o){function r(e){return function(t){return t.id==e}}function l(){p&&(a+=c,p=!1)}function s(e){e&&(l(),a+=e)}function d(t){if(1==t.nodeType){var a=t.getAttribute("cm-text");if(null!=a)return void s(a||t.textContent.replace(/\u200b/g,""));var h=t.getAttribute("cm-marker"),g;if(h){var u=e.findMarks(z(n,0),z(o+1,0),r(+h));return void(u.length&&(g=u[0].find(0))&&s(A(e.doc,g.from,g.to).join(c)))}if("false"==t.getAttribute("contenteditable"))return;var f=/^(pre|div|p)$/i.test(t.nodeName);f&&l();for(var m=0;mr?p.map:c[r];for(var l=0,s;lr?e.line:e.rest[r]),a=i[l]+o;return(0>o||s!=t)&&(a=i[l+(o?1:0)]),z(d,a)}}}var o=e.text.firstChild,r=!1;if(!t||!l(o,t))return al(z(D(e.line),0),!0);if(t==o&&(r=!0,t=o.childNodes[i],i=0,!t)){var s=e.rest?y(e.rest):e.line;return al(z(D(s),s.text.length),r)}var d=3==t.nodeType?t:null,a=t;for(d||1!=t.childNodes.length||3!=t.firstChild.nodeType||(d=t.firstChild,i&&(i=d.nodeValue.length));a.parentNode!=o;)a=a.parentNode;var p=e.measure,c=p.maps,h=n(d,a,i);if(h)return al(h,r);for(var g=a.nextSibling,u=d?d.nodeValue.length-i:0;g;g=g.nextSibling){if(h=n(g,g.firstChild,0),h)return al(z(h.line,h.ch-u),r);u+=g.textContent.length}for(var f=a.previousSibling,m=i;f;f=f.previousSibling){if(h=n(f,f.firstChild,-1),h)return al(z(h.line,h.ch+m),r);m+=f.textContent.length}}var gl=String.fromCharCode,ul=Math.round,fl=Math.abs,ml=Math.max,yl=Math.floor,vl=Math.ceil,xl=Math.min,bl=navigator.userAgent,Cl=navigator.platform,wl=/gecko\/\d/i.test(bl),Sl=/MSIE \d/.test(bl),Ll=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(bl),kl=/Edge\/(\d+)/.exec(bl),Tl=Sl||Ll||kl,ie=Tl&&(Sl?document.documentMode||6:+(kl||Ll)[1]),Nl=!kl&&/WebKit\//.test(bl),Ol=Nl&&/Qt\/\d+\.\d+/.test(bl),Al=!kl&&/Chrome\//.test(bl),Ml=/Opera\//.test(bl),Wl=/Apple Computer/.test(navigator.vendor),Dl=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(bl),Hl=/PhantomJS/.test(bl),Fl=!kl&&/AppleWebKit/.test(bl)&&/Mobile\/\w+/.test(bl),Pl=/Android/.test(bl),zl=Fl||Pl||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(bl),Il=Fl||/Mac/.test(Cl),El=/\bCrOS\b/.test(bl),Rl=/win/i.test(Cl),Bl=Ml&&bl.match(/Version\/(\d*\.\d*)/);Bl&&(Bl=+Bl[1]),Bl&&15<=Bl&&(Ml=!1,Nl=!0);var Gl=Il&&(Ol||Ml&&(null==Bl||12.11>Bl)),$l=wl||Tl&&9<=ie,Ul=function(t,i){var n=t.className,o=e(i).exec(n);if(o){var r=n.slice(o.index+o[0].length);t.className=n.slice(0,o.index)+(r?o[1]+r:"")}},jl;jl=document.createRange?function(e,t,i,n){var o=document.createRange();return o.setEnd(n||e,i),o.setStart(e,t),o}:function(e,t,i){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(t){return n}return n.collapse(!0),n.moveEnd("character",i),n.moveStart("character",t),n};var Vl=function(e){e.select()};Fl?Vl=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:Tl&&(Vl=function(e){try{e.select()}catch(e){}});var Kl=function(){this.id=null};Kl.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var Xl={toString:function(){return"CodeMirror.Pass"}},Yl={scroll:!1},_l={origin:"*mouse"},ql={origin:"+move"},Zl=[""],Ql=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Jl=/[\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]/,es=!1,ts=!1,is=null,ns=function(){function e(e){return 247>=e?"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(e):1424<=e&&1524>=e?"R":1536<=e&&1785>=e?"nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111".charAt(e-1536):1774<=e&&2220>=e?"r":8192<=e&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,i){this.level=e,this.from=t,this.to=i}var n=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,o=/[LRr]/,r=/[Lb1n]/,l=/[1n]/;return function(s,d){var a="ltr"==d?"L":"R";if(0==s.length||"ltr"==d&&!n.test(s))return!1;for(var p=s.length,c=[],h=0;hie)return!1;var e=o("div");return"draggable"in e||"dragDrop"in e}(),ls=3=="\n\nb".split(/\n/).length?function(e){return e.split(/\r\n?|\n/)}:function(e){for(var t=0,i=[],n=e.length,o;t<=n;){o=e.indexOf("\n",t),-1==o&&(o=e.length);var r=e.slice(t,"\r"==e.charAt(o-1)?o-1:o),l=r.indexOf("\r");-1==l?(i.push(r),t=o+1):(i.push(r.slice(0,l)),t+=l+1)}return i},ss=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(t){}return!!(t&&t.parentElement()==e)&&0!=t.compareEndPoints("StartToEnd",t)},ds=function(){var t=o("div");return!!("oncopy"in t)||(t.setAttribute("oncopy","return;"),"function"==typeof t.oncopy)}(),as=null,ps={},cs={},hs={},gs=function(e,t,i){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=i},us,fs;gs.prototype.eol=function(){return this.pos>=this.string.length},gs.prototype.sol=function(){return this.pos==this.lineStart},gs.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},gs.prototype.next=function(){if(this.post},gs.prototype.eatSpace=function(){for(var e=this,t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++e.pos;return this.pos>t},gs.prototype.skipToEnd=function(){this.pos=this.string.length},gs.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(-1this.maxLookAhead&&(this.maxLookAhead=e),t},ys.prototype.baseToken=function(e){var t=this;if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)t.baseTokenPos+=2;var i=this.baseTokens[this.baseTokenPos+1];return{type:i&&i.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},ys.prototype.nextLine=function(){this.line++,0ie&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")},Ts;ks.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(i){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var o=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=ml(0,e.scrollHeight-e.clientHeight+o)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=i?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var r=e.viewWidth-e.barLeft-(i?n:0);this.horiz.firstChild.style.width=ml(0,e.scrollWidth-e.clientWidth+r)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&0=I(e,i.to()))return o;return-1};var Fs=function(e,t){this.anchor=e,this.head=t};Fs.prototype.from=function(){return G(this.anchor,this.head)},Fs.prototype.to=function(){return B(this.anchor,this.head)},Fs.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},jo.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n=this,o=e,i;othis.size-t&&(1=this.children.length)){var e=this;do{var t=e.children.splice(e.children.length-5,5),i=new Vo(t);if(!e.parent){var n=new Vo(e.children);n.parent=e,e.children=[n,i],e=n}else{e.size-=i.size,e.height-=i.height;var o=g(e.parent.children,e);e.parent.children.splice(o+1,0,i)}i.parent=e.parent}while(10t.display.maxLineLength&&(t.display.maxLine=p,t.display.maxLineLength=c,t.display.maxLineChanged=!0)}null!=r&&t&&this.collapsed&&xn(t,r,l+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&To(t.doc)),t&&Ct(t,"markerCleared",t,this,r,l),n&&dn(t),this.parent&&this.parent.clear()}},Is.prototype.find=function(e,t){var n=this;null==e&&"bookmark"==this.type&&(e=1);for(var o=0,i,r;o=e.ch)&&t.push(i.marker.parent||i.marker);return t},findMarks:function(e,t,n){e=U(this,e),t=U(this,t);var o=[],r=e.line;return this.iter(e.line,t.line+1,function(l){var s=l.markedSpans;if(s)for(var d=0,i;d=i.to||null==i.from&&r!=e.line||null!=i.from&&r==t.line&&i.from>=t.ch||n&&!n(i.marker)||o.push(i.marker.parent||i.marker);++r}),o},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var o=0;oe?(n=e,!0):void(e-=r,++t)}),U(this,z(t,n))},indexFromPos:function(e){e=U(this,e);var t=e.ch;if(e.linee.ch)return 0;var i=this.lineSeparator().length;return this.iter(this.first,e.line,function(e){t+=e.text.length+i}),t},copy:function(e){var t=new Bs(M(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e||(e={});var t=this.first,i=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.tojs;js++)Us[js+48]=Us[js+96]=js+"";for(var i=65;90>=i;i++)Us[i]=gl(i);for(var Vs=1;12>=Vs;Vs++)Us[Vs+111]=Us[Vs+63235]="F"+Vs;var Ks={};Ks.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"},Ks.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"},Ks.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"},Ks.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"]},Ks["default"]=Il?Ks.macDefault:Ks.pcDefault;var Xs={selectAll:Wo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Yl)},killLine:function(e){return ur(e,function(t){if(t.empty()){var i=O(e.doc,t.head.line).text.length;return t.head.ch==i&&t.head.linee.doc.first){var l=O(e.doc,i.line-1).text;l&&(i=new z(i.line,1),e.replaceRange(r.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),z(i.line-1,l.length-1),i,"+transpose"))}n.push(new Fs(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){return fn(e,function(){for(var t=e.listSelections(),n=t.length-1;0<=n;n--)e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input");t=e.listSelections();for(var i=0;ie&&0==I(t,this.pos)&&i==this.button};var Zs={toString:function(){return"CodeMirror.Init"}},Qs={},Js={},ed,td;_r.defaults=Qs,_r.optionHandlers=Js;var id=[];_r.defineInitHook=function(e){return id.push(e)};var nd=null,od=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Kl,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};od.prototype.init=function(e){function t(t){if(!Ae(o,t)){if(o.somethingSelected())Qr({lineWise:!1,text:o.getSelections()}),"cut"==t.type&&o.replaceSelection("",null,"cut");else{if(!o.options.lineWiseCopyCut)return;var e=il(o);Qr({lineWise:!0,text:e.text}),"cut"==t.type&&o.operation(function(){o.setSelections(e.ranges,0,Yl),o.replaceSelection("",null,"cut")})}if(t.clipboardData){t.clipboardData.clearData();var i=nd.text.join("\n");if(t.clipboardData.setData("Text",i),t.clipboardData.getData("Text")==i)return void t.preventDefault()}var l=ol(),s=l.firstChild;o.display.lineSpace.insertBefore(l,o.display.lineSpace.firstChild),s.value=nd.text.join("\n");var d=document.activeElement;Vl(s),setTimeout(function(){o.display.lineSpace.removeChild(l),d.focus(),d==r&&n.showPrimarySelection()},50)}}var i=this,n=this,o=n.cm,r=n.div=e.lineDiv;nl(r,o.options.spellcheck),rs(r,"paste",function(t){Ae(o,t)||el(t,o)||11>=ie&&setTimeout(mn(o,function(){return i.updateFromDOM()}),20)}),rs(r,"compositionstart",function(t){i.composing={data:t.data,done:!1}}),rs(r,"compositionupdate",function(t){i.composing||(i.composing={data:t.data,done:!1})}),rs(r,"compositionend",function(t){i.composing&&(t.data!=i.composing.data&&i.readFromDOMSoon(),i.composing.done=!0)}),rs(r,"touchstart",function(){return n.forceCompositionEnd()}),rs(r,"input",function(){i.composing||i.readFromDOMSoon()}),rs(r,"copy",t),rs(r,"cut",t)},od.prototype.prepareSelection=function(){var e=Oi(this.cm,!1);return e.focus=this.cm.state.focused,e},od.prototype.showSelection=function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},od.prototype.showPrimarySelection=function(){var e=window.getSelection(),t=this.cm,i=t.doc.sel.primary(),n=i.from(),o=i.to();if(t.display.viewTo==t.display.viewFrom||n.line>=t.display.viewTo||o.line=t.display.viewFrom&&sl(t,n)||{node:s[0].measure.map[2],offset:0},a=o.linee.firstLine()&&(n=z(n.line-1,O(e.doc,n.line-1).length)),o.ch==O(e.doc,o.line).text.length&&o.linet.viewTo-1)return!1;var r,l,s;n.line==t.viewFrom||0==(r=Ti(e,n.line))?(l=D(t.view[0].line),s=t.view[0].node):(l=D(t.view[r].line),s=t.view[r-1].node.nextSibling);var d=Ti(e,o.line),a,p;if(d==t.view.length-1?(a=t.viewTo-1,p=t.lineDiv.lastChild):(a=D(t.view[d+1].line)-1,p=t.view[d+1].node.previousSibling),!s)return!1;for(var c=e.doc.splitLines(pl(e,s,p,l,a)),h=A(e.doc,z(l,0),z(a,O(e.doc,a).text.length));1n.ch&&x.charCodeAt(x.length-u-1)==b.charCodeAt(b.length-u-1);)g--,u++;c[c.length-1]=x.slice(0,x.length-u).replace(/^\u200b+/,""),c[0]=c[0].slice(g).replace(/\u200b+$/,"");var w=z(l,g),S=z(a,h.length?y(h).length-u:0);if(1ie&&r.scrollbars.setScrollTop(r.scroller.scrollTop=d),null!=l.selectionStart){(!Tl||Tl&&9>ie)&&e();var t=0,i=function(){r.selForContextMenu==o.doc.sel&&0==l.selectionStart&&0t++?r.detectingSelectAll=setTimeout(i,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(i,200)}}var n=this,o=n.cm,r=o.display,l=n.textarea,s=ki(o,t),d=r.scroller.scrollTop;if(s&&!Ml){var a=o.options.resetSelectionOnContextMenu;a&&-1==o.doc.sel.contains(s)&&mn(o,So)(o.doc,$n(s),Yl);var p=l.style.cssText,c=n.wrapper.style.cssText;n.wrapper.style.cssText="position: absolute";var h=n.wrapper.getBoundingClientRect();l.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(t.clientY-h.top-5)+"px; left: "+(t.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(Tl?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var g;if(Nl&&(g=window.scrollY),r.input.focus(),Nl&&window.scrollTo(null,g),r.input.reset(),o.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=!0,r.selForContextMenu=o.doc.sel,clearTimeout(r.detectingSelectAll),Tl&&9<=ie&&e(),$l){ze(t);var u=function(){Ne(window,"mouseup",u),setTimeout(i,20)};rs(window,"mouseup",u)}else setTimeout(i,50)}},rd.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e},rd.prototype.setUneditable=function(){},rd.prototype.needsContentAttribute=!1,function(e){function t(t,n,o,r){e.defaults[t]=n,o&&(i[t]=r?function(e,t,i){i!=Zs&&o(e,t,i)}:o)}var i=e.optionHandlers;e.defineOption=t,e.Init=Zs,t("value","",function(e,t){return e.setValue(t)},!0),t("mode",null,function(e,t){e.doc.modeOption=t,Yn(e)},!0),t("indentUnit",2,Yn,!0),t("indentWithTabs",!1),t("smartIndent",!0),t("tabSize",4,function(e){_n(e),ii(e),xn(e)},!0),t("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,!!t){var n=[],o=e.doc.first;e.doc.iter(function(e){for(var i=0,r;;){if(r=e.text.indexOf(t,i),-1==r)break;i=r+t.length,n.push(z(o,r))}o++});for(var r=n.length-1;0<=r;r--)Ro(e.doc,t,n[r],z(n[r].line,n[r].ch+t.length))}}),t("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t,i){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),i!=Zs&&e.refresh()}),t("specialCharPlaceholder",pt,function(e){return e.refresh()},!0),t("electricChars",!0),t("inputStyle",zl?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),t("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),t("rtlMoveVisually",!Rl),t("wholeLineUpdateBefore",!0),t("theme","default",function(e){Vr(e),Kr(e)},!0),t("keyMap","default",function(e,t,i){var n=gr(t),o=i!=Zs&&gr(i);o&&o.detach&&o.detach(e,n),n.attach&&n.attach(e,o||null)}),t("extraKeys",null),t("configureMouse",null),t("lineWrapping",!1,Yr,!0),t("gutters",[],function(e){In(e.options),Kr(e)},!0),t("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?wi(e.display)+"px":"0",e.refresh()},!0),t("coverGutterNextToScrollbar",!1,function(e){return nn(e)},!0),t("scrollbarStyle","native",function(e){ln(e),nn(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),t("lineNumbers",!1,function(e){In(e.options),Kr(e)},!0),t("firstLineNumber",1,Kr,!0),t("lineNumberFormatter",function(e){return e},Kr,!0),t("showCursorWhenSelecting",!1,Ni,!0),t("resetSelectionOnContextMenu",!0),t("lineWiseCopyCut",!0),t("pasteLinesPerSelection",!0),t("readOnly",!1,function(e,t){"nocursor"==t&&(zi(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)}),t("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),t("dragDrop",!0,Xr),t("allowDropFileTypes",null),t("cursorBlinkRate",530),t("cursorScrollMargin",0),t("cursorHeight",1,Ni,!0),t("singleCursorHeightPerLine",!0,Ni,!0),t("workTime",100),t("workDelay",100),t("flattenSpans",!0,_n,!0),t("addModeClass",!1,_n,!0),t("pollInterval",100),t("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),t("historyEventDelay",1250),t("viewportMargin",10,function(e){return e.refresh()},!0),t("maxHighlightLength",1e4,_n,!0),t("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),t("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),t("autofocus",null),t("direction","ltr",function(e,t){return e.doc.setDirection(t)},!0)}(_r),function(e){var t=e.optionHandlers,n=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,i){var n=this.options,o=n[e];n[e]==i&&"mode"!=e||(n[e]=i,t.hasOwnProperty(e)&&mn(this,t[e])(this,i,o),Oe(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](gr(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;no&&(Zr(t,i.head.line,e,!0),o=i.head.line,r==t.doc.sel.primIndex&&Xi(t))}),getTokenAt:function(e,t){return tt(this,e,t)},getLineTokens:function(e,t){return tt(this,z(e),t,!0)},getTokenTypeAt:function(e){e=U(this.doc,e);var t=qe(this,O(this.doc,e.line)),i=0,n=(t.length-1)/2,o=e.ch,r;if(0==o)r=t[2];else for(;;){var l=i+n>>1;if((l?t[2*l-1]:0)>=o)n=l;else if(t[2*l+1]s?r:0==s?null:r.slice(0,s-1)},getModeAt:function(t){var i=this.doc.mode;return i.innerMode?e.innerMode(i,this.getTokenAt(t).state).mode:i},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var o=this,r=[];if(!n.hasOwnProperty(t))return r;var l=n[t],s=this.getModeAt(e);if("string"==typeof s[t])l[s[t]]&&r.push(l[s[t]]);else if(s[t])for(var d=0,i;dr&&(e=r,n=!0),o=O(this.doc,e)}else o=e;return li(this,o,{top:0,left:0},t||"page",i||n).top+(n?this.doc.height-be(o):0)},defaultTextHeight:function(){return xi(this.display)},defaultCharWidth:function(){return bi(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,i,n,o){var r=this.display;e=ai(this,U(this.doc,e));var l=e.bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),r.sizer.appendChild(t),"over"==n)l=e.top;else if("above"==n||"near"==n){var d=ml(r.wrapper.clientHeight,this.doc.height),a=ml(r.sizer.clientWidth,r.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>d)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=d&&(l=e.bottom),s+t.offsetWidth>a&&(s=a-t.offsetWidth)}t.style.top=l+"px",t.style.left=t.style.right="","right"==o?(s=r.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==o?s=0:"middle"==o&&(s=(r.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),i&&ji(this,{left:s,top:l,right:s+t.offsetWidth,bottom:l+t.offsetHeight})},triggerOnKeyDown:yn(Or),triggerOnKeyPress:yn(Wr),triggerOnKeyUp:Mr,triggerOnMouseDown:yn(Hr),execCommand:function(e){if(Xs.hasOwnProperty(e))return Xs[e].call(null,this)},triggerElectric:yn(function(e){tl(this,e)}),findPosH:function(e,t,n,o){var r=this,l=1;0>t&&(l=-1,t=-t);for(var s=U(this.doc,e),d=0;de?n.from():n.to()},ql)}),deleteH:yn(function(e,t){var i=this.doc.sel,n=this.doc;i.somethingSelected()?n.replaceSelection("",null,"+delete"):ur(this,function(i){var o=rl(n,i.head,e,t,!1);return 0>e?{from:o,to:i.head}:{from:i.head,to:o}})}),findPosV:function(e,t,n,o){var r=this,l=1,s=o;0>t&&(l=-1,t=-t);for(var d=U(this.doc,e),a=0,i;ae?i.from():i.to();var s=ai(n,i.head,"div");null!=i.goalColumn&&(s.left=i.goalColumn),r.push(s.left);var d=ll(n,s,e,t);return"page"==t&&i==o.sel.primary()&&Ki(n,di(n,d,"div").top-s.top),d},ql),r.length)for(var s=0;sg(ld,sd)&&(_r.prototype[sd]=function(e){return function(){return e.apply(this.doc,arguments)}}(Bs.prototype[sd]));return De(Bs),_r.inputStyles={textarea:rd,contenteditable:od},_r.defineMode=function(e){_r.defaults.mode||"null"==e||(_r.defaults.mode=e),$e.apply(this,arguments)},_r.defineMIME=function(e,t){cs[e]=t},_r.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),_r.defineMIME("text/plain","null"),_r.defineExtension=function(e,t){_r.prototype[e]=t},_r.defineDocExtension=function(e,t){Bs.prototype[e]=t},_r.fromTextArea=function(e,t){function i(){e.value=d.getValue()}if(t=t?c(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var n=s();t.autofocus=n==e||null!=e.getAttribute("autofocus")&&n==document.body}var o;if(e.form&&(rs(e.form,"submit",i),!t.leaveSubmitMethodAlone)){var r=e.form;o=r.submit;try{var l=r.submit=function(){i(),r.submit=o,r.submit(),r.submit=l}}catch(t){}}t.finishInit=function(t){t.save=i,t.getTextArea=function(){return e},t.toTextArea=function(){t.toTextArea=isNaN,i(),e.parentNode.removeChild(t.getWrapperElement()),e.style.display="",e.form&&(Ne(e.form,"submit",i),"function"==typeof e.form.submit&&(e.form.submit=o))}},e.style.display="none";var d=_r(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return d},function(e){e.off=Ne,e.on=rs,e.wheelEventPixels=Rn,e.Doc=Bs,e.splitLines=ls,e.countColumn=h,e.findColumn=u,e.isWordChar=C,e.Pass=Xl,e.signal=Oe,e.Line=xs,e.changeEnd=Un,e.scrollbarModel=Os,e.Pos=z,e.cmpPos=I,e.modes=ps,e.mimeModes=cs,e.resolveMode=Ue,e.getMode=je,e.modeExtensions=hs,e.extendMode=Ve,e.copyState=Ke,e.startState=Ye,e.innerMode=Xe,e.commands=Xs,e.keyMap=Ks,e.keyName=hr,e.isModifierKey=pr,e.lookupKey=ar,e.normalizeKeyMap=dr,e.StringStream=gs,e.SharedTextMarker=Es,e.TextMarker=Is,e.LineWidget=Ps,e.e_preventDefault=He,e.e_stopPropagation=Fe,e.e_stop=ze,e.addClass=d,e.contains=l,e.rmClass=Ul,e.keyNames=Us}(_r),_r.version="5.36.1",_r});