s-r;if(t.topi+o){var u=Math.min(t.top,(c?s:t.bottom)-o);u!=i&&(a.scrollTop=u)}var f=e.options.fixedGutter?0:n.gutters.offsetWidth,p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft-f,d=er(e)-n.gutters.offsetWidth,h=t.right-t.left>d;return h&&(t.right=t.left+d),t.left<10?a.scrollLeft=0:t.leftd+p-3&&(a.scrollLeft=t.right+(h?0:10)-d),a}function fi(e,t){null!=t&&(vi(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function pi(e){vi(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function di(e,t,n){null==t&&null==n||vi(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function hi(e,t){vi(e),e.curOp.scrollToPos=t}function vi(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,gi(e,Sr(e,t.from),Sr(e,t.to),t.margin))}function gi(e,t,n,r){var i=ui(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-r,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+r});di(e,i.scrollLeft,i.scrollTop)}function mi(e,t){Math.abs(e.doc.scrollTop-t)<2||(n||Ki(e,{top:t}),yi(e,t,!0),n&&Ki(e),Bi(e,100))}function yi(e,t,n){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),(e.display.scroller.scrollTop!=t||n)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function bi(e,t,n,r){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r||(e.doc.scrollLeft=t,Zi(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function xi(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+Jn(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+Qn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}var wi=function(e,t,n){this.cm=n;var r=this.vert=A("div",[A("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=A("div",[A("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=i.tabIndex=-1,e(r),e(i),be(r,"scroll",(function(){r.clientHeight&&t(r.scrollTop,"vertical")})),be(i,"scroll",(function(){i.clientWidth&&t(i.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,a&&s<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};wi.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.scrollTop=0,this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+o)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==r&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?r:0,bottom:t?r:0}},wi.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},wi.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},wi.prototype.zeroWidthHack=function(){var e=b&&!h?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.visibility=this.vert.style.visibility="hidden",this.disableHoriz=new U,this.disableVert=new U},wi.prototype.enableZeroWidthBar=function(e,t,n){function r(){var i=e.getBoundingClientRect();("vert"==n?document.elementFromPoint(i.right-1,(i.top+i.bottom)/2):document.elementFromPoint((i.right+i.left)/2,i.bottom-1))!=e?e.style.visibility="hidden":t.set(1e3,r)}e.style.visibility="",t.set(1e3,r)},wi.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var ki=function(){};function Ci(e,t){t||(t=xi(e));var n=e.display.barWidth,r=e.display.barHeight;_i(e,t);for(var i=0;i<4&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&ii(e),_i(e,xi(e)),n=e.display.barWidth,r=e.display.barHeight}function _i(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}ki.prototype.update=function(){return{bottom:0,right:0}},ki.prototype.setScrollLeft=function(){},ki.prototype.setScrollTop=function(){},ki.prototype.clear=function(){};var Si={native:wi,null:ki};function Oi(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&L(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Si[e.options.scrollbarStyle]((function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),be(t,"mousedown",(function(){e.state.focused&&setTimeout((function(){return e.display.input.focus()}),0)})),t.setAttribute("cm-not-content","true")}),(function(t,n){"horizontal"==n?bi(e,t):mi(e,t)}),e),e.display.scrollbars.addClass&&P(e.display.wrapper,e.display.scrollbars.addClass)}var Li=0;function Ti(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Li,markArrays:null},An(e.curOp)}function Ei(e){var t=e.curOp;t&&Nn(t,(function(e){for(var t=0;t=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new zi(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Ni(e){e.updatedDisplay=e.mustUpdate&&Gi(e.cm,e.update)}function Ri(e){var t=e.cm,n=t.display;e.updatedDisplay&&ii(t),e.barMeasure=xi(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=or(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+Qn(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-er(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function Pi(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft=e.display.viewTo)){var n=+new Date+e.options.workTime,r=_t(e,t.highlightFrontier),i=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),(function(o){if(r.line>=e.display.viewFrom){var a=o.styles,s=o.text.length>e.options.maxHighlightLength?Ze(t.mode,r.state):null,l=kt(e,o,r,!0);s&&(r.state=s),o.styles=l.styles;var c=o.styleClasses,u=l.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var f=!a||a.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),p=0;!f&&pn)return Bi(e,e.options.workDelay),!0})),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),i.length&&Ii(e,(function(){for(var t=0;t=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==qr(e))return!1;Qi(e)&&(Ur(e),t.dims=Ir(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),a=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFroma&&n.viewTo-a<20&&(a=Math.min(i,n.viewTo)),$t&&(o=sn(e.doc,o),a=ln(e.doc,a));var s=o!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;Gr(e,o,a),n.viewOffset=fn(nt(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var l=qr(e);if(!s&&0==l&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var c=Ui(e);return l>4&&(n.lineDiv.style.display="none"),Xi(e,n.updateLineNumbers,t.dims),l>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,Vi(c),T(n.cursorDiv),T(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,s&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,Bi(e,400)),n.updateLineNumbers=null,!0}function qi(e,t){for(var n=t.viewport,r=!0;;r=!1){if(r&&e.options.lineWrapping&&t.oldDisplayWidth!=er(e))r&&(t.visible=ai(e.display,e.doc,n));else if(n&&null!=n.top&&(n={top:Math.min(e.doc.height+Jn(e.display)-tr(e),n.top)}),t.visible=ai(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!Gi(e,t))break;ii(e);var i=xi(e);Kr(e),Ci(e,i),Ji(e,i),t.force=!1}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function Ki(e,t){var n=new zi(e,t);if(Gi(e,n)){ii(e),qi(e,n);var r=xi(e);Kr(e),Ci(e,r),Ji(e,r),n.finish()}}function Xi(e,t,n){var r=e.display,i=e.options.lineNumbers,o=r.lineDiv,a=o.firstChild;function s(t){var n=t.nextSibling;return l&&b&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}for(var c=r.view,u=r.viewFrom,f=0;f-1&&(d=!1),In(e,p,u,n)),d&&(T(p.lineNumber),p.lineNumber.appendChild(document.createTextNode(ct(e.options,u)))),a=p.node.nextSibling}else{var h=Un(e,p,u,n);o.insertBefore(h,a)}u+=p.size}for(;a;)a=s(a)}function Yi(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",Pn(e,"gutterChanged",e)}function Ji(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Qn(e)+"px"}function Zi(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=Fr(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",a=0;a=105&&(o.wrapper.style.clipPath="inset(0px)"),o.wrapper.setAttribute("translate","no"),a&&s<8&&(o.gutters.style.zIndex=-1,o.scroller.style.paddingRight=0),l||n&&y||(o.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(o.wrapper):e(o.wrapper)),o.viewFrom=o.viewTo=t.first,o.reportedViewFrom=o.reportedViewTo=t.first,o.view=[],o.renderedView=null,o.externalMeasured=null,o.viewOffset=0,o.lastWrapHeight=o.lastWrapWidth=0,o.updateLineNumbers=null,o.nativeBarWidth=o.barHeight=o.barWidth=0,o.scrollbarsClipped=!1,o.lineNumWidth=o.lineNumInnerWidth=o.lineNumChars=null,o.alignWidgets=!1,o.cachedCharWidth=o.cachedTextHeight=o.cachedPaddingH=null,o.maxLine=null,o.maxLineLength=0,o.maxLineChanged=!1,o.wheelDX=o.wheelDY=o.wheelStartX=o.wheelStartY=null,o.shift=!1,o.selForContextMenu=null,o.activeTouch=null,o.gutterSpecs=eo(i.gutters,i.lineNumbers),to(o),r.init(o)}zi.prototype.signal=function(e,t){Se(e,t)&&this.events.push(arguments)},zi.prototype.finish=function(){for(var e=0;ec.clientWidth,h=c.scrollHeight>c.clientHeight;if(i&&d||o&&h){if(o&&b&&l)e:for(var v=t.target,g=s.view;v!=c;v=v.parentNode)for(var m=0;m=0&&ft(e,r.to())<=0)return n}return-1};var uo=function(e,t){this.anchor=e,this.head=t};function fo(e,t,n){var r=e&&e.options.selectionsMayTouch,i=t[n];t.sort((function(e,t){return ft(e.from(),t.from())})),n=V(t,i);for(var o=1;o0:l>=0){var c=vt(s.from(),a.from()),u=ht(s.to(),a.to()),f=s.empty()?a.from()==a.head:s.from()==s.head;o<=n&&--n,t.splice(--o,2,new uo(f?u:c,f?c:u))}}return new co(t,n)}function po(e,t){return new co([new uo(e,t||e)],0)}function ho(e){return e.text?ut(e.from.line+e.text.length-1,ee(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function vo(e,t){if(ft(e,t.from)<0)return e;if(ft(e,t.to)<=0)return ho(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=ho(t).ch-t.to.ch),ut(n,r)}function go(e,t){for(var n=[],r=0;r1&&e.remove(s.line+1,h-1),e.insert(s.line+1,m)}Pn(e,"change",e,t)}function Co(e,t,n){function r(e,i,o){if(e.linked)for(var a=0;a1&&!e.done[e.done.length-2].ranges?(e.done.pop(),ee(e.done)):void 0}function Mo(e,t,n,r){var i=e.history;i.undone.length=0;var o,a,s=+new Date;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&i.lastModTime>s-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(o=Ao(i,i.lastOp==r)))a=ee(o.changes),0==ft(t.from,t.to)&&0==ft(t.from,a.to)?a.to=ho(t):o.changes.push(To(e,t));else{var l=ee(i.done);for(l&&l.ranges||Po(e.sel,i.done),o={changes:[To(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=s,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,a||ke(e,"historyAdded")}function No(e,t,n,r){var i=t.charAt(0);return"*"==i||"+"==i&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Ro(e,t,n,r){var i=e.history,o=r&&r.origin;n==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||No(e,o,ee(i.done),t))?i.done[i.done.length-1]=t:Po(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=n,r&&!1!==r.clearRedo&&Eo(i.undone)}function Po(e,t){var n=ee(t);n&&n.ranges&&n.equals(e)||t.push(e)}function $o(e,t,n,r){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),(function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=n.markedSpans),++o}))}function Io(e){if(!e)return null;for(var t,n=0;n-1&&(ee(s)[f]=c[f],delete c[f])}}}return r}function Bo(e,t,n,r){if(r){var i=e.anchor;if(n){var o=ft(t,i)<0;o!=ft(n,i)<0?(i=t,t=n):o!=ft(t,n)<0&&(t=n)}return new uo(i,t)}return new uo(n||t,t)}function Ho(e,t,n,r,i){null==i&&(i=e.cm&&(e.cm.display.shift||e.extend)),qo(e,new co([Bo(e.sel.primary(),t,n,i)],0),r)}function zo(e,t,n){for(var r=[],i=e.cm&&(e.cm.display.shift||e.extend),o=0;o=t.ch:s.to>t.ch))){if(i&&(ke(l,"beforeCursorEnter"),l.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!l.atomic)continue;if(n){var f=l.find(r<0?1:-1),p=void 0;if((r<0?u:c)&&(f=ea(e,f,-r,f&&f.line==t.line?o:null)),f&&f.line==t.line&&(p=ft(f,n))&&(r<0?p<0:p>0))return Zo(e,f,t,r,i)}var d=l.find(r<0?-1:1);return(r<0?c:u)&&(d=ea(e,d,r,d.line==t.line?o:null)),d?Zo(e,d,t,r,i):null}}return t}function Qo(e,t,n,r,i){var o=r||1,a=Zo(e,t,n,o,i)||!i&&Zo(e,t,n,o,!0)||Zo(e,t,n,-o,i)||!i&&Zo(e,t,n,-o,!0);return a||(e.cantEdit=!0,ut(e.first,0))}function ea(e,t,n,r){return n<0&&0==t.ch?t.line>e.first?mt(e,ut(t.line-1)):null:n>0&&t.ch==(r||nt(e,t.line)).text.length?t.line=0;--i)ia(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text,origin:t.origin});else ia(e,t)}}function ia(e,t){if(1!=t.text.length||""!=t.text[0]||0!=ft(t.from,t.to)){var n=go(e,t);Mo(e,t,n,e.cm?e.cm.curOp.id:NaN),sa(e,t,n,Ut(e,t));var r=[];Co(e,(function(e,n){n||-1!=V(r,e.history)||(pa(e.history,t),r.push(e.history)),sa(e,t,null,Ut(e,t))}))}}function oa(e,t,n){var r=e.cm&&e.cm.state.suppressEdits;if(!r||n){for(var i,o=e.history,a=e.sel,s="undo"==t?o.done:o.undone,l="undo"==t?o.undone:o.done,c=0;c=0;--d){var h=p(d);if(h)return h.v}}}}function aa(e,t){if(0!=t&&(e.first+=t,e.sel=new co(te(e.sel.ranges,(function(e){return new uo(ut(e.anchor.line+t,e.anchor.ch),ut(e.head.line+t,e.head.ch))})),e.sel.primIndex),e.cm)){zr(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;re.lastLine())){if(t.from.lineo&&(t={from:t.from,to:ut(o,nt(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=rt(e,t.from,t.to),n||(n=go(e,t)),e.cm?la(e.cm,t,r):ko(e,t,r),Ko(e,n,K),e.cantEdit&&Qo(e,ut(e.firstLine(),0))&&(e.cantEdit=!1)}}function la(e,t,n){var r=e.doc,i=e.display,o=t.from,a=t.to,s=!1,l=o.line;e.options.lineWrapping||(l=at(rn(nt(r,o.line))),r.iter(l,a.line+1,(function(e){if(e==i.maxLine)return s=!0,!0}))),r.sel.contains(t.from,t.to)>-1&&_e(e),ko(r,t,n,Dr(e)),e.options.lineWrapping||(r.iter(l,o.line+t.text.length,(function(e){var t=pn(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)})),s&&(e.curOp.updateMaxLine=!0)),Rt(r,o.line),Bi(e,400);var c=t.text.length-(a.line-o.line)-1;t.full?zr(e):o.line!=a.line||1!=t.text.length||wo(e.doc,t)?zr(e,o.line,a.line+1,c):Wr(e,o.line,"text");var u=Se(e,"changes"),f=Se(e,"change");if(f||u){var p={from:o,to:a,text:t.text,removed:t.removed,origin:t.origin};f&&Pn(e,"change",e,p),u&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function ca(e,t,n,r,i){var o;r||(r=n),ft(r,n)<0&&(n=(o=[r,n])[0],r=o[1]),"string"==typeof t&&(t=e.splitLines(t)),ra(e,{from:n,to:r,text:t,origin:i})}function ua(e,t,n,r){n1||!(this.children[0]instanceof ha))){var s=[];this.collapse(s),this.children=[new ha(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var a=i.lines.length%25+25,s=a;s10);e.parent.maybeSpill()}},iterN:function(e,t,n){for(var r=0;r0||0==a&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=M("span",[o.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(nn(e,t.line,t,n,o)||t.line!=n.line&&nn(e,n.line,t,n,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ft()}o.addToHistory&&Mo(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var s,l=t.line,c=e.cm;if(e.iter(l,n.line+1,(function(r){c&&o.collapsed&&!c.options.lineWrapping&&rn(r)==c.display.maxLine&&(s=!0),o.collapsed&&l!=t.line&&ot(r,0),Ht(r,new Dt(o,l==t.line?t.ch:null,l==n.line?n.ch:null),e.cm&&e.cm.curOp),++l})),o.collapsed&&e.iter(t.line,n.line+1,(function(t){cn(e,t)&&ot(t,0)})),o.clearOnEnter&&be(o,"beforeCursorEnter",(function(){return o.clear()})),o.readOnly&&(It(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++ba,o.atomic=!0),c){if(s&&(c.curOp.updateMaxLine=!0),o.collapsed)zr(c,t.line,n.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(var u=t.line;u<=n.line;u++)Wr(c,u,"text");o.atomic&&Yo(c.doc),Pn(c,"markerAdded",c,o)}return o}xa.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&Ti(e),Se(this,"clear")){var n=this.find();n&&Pn(this,"clear",n.from,n.to)}for(var r=null,i=null,o=0;oe.display.maxLineLength&&(e.display.maxLine=c,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&zr(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Yo(e.doc)),e&&Pn(e,"markerCleared",e,this,r,i),t&&Ei(e),this.parent&&this.parent.clear()}},xa.prototype.find=function(e,t){var n,r;null==e&&"bookmark"==this.type&&(e=1);for(var i=0;i=0;l--)ra(this,r[l]);s?Go(this,s):this.cm&&pi(this.cm)})),undo:ji((function(){oa(this,"undo")})),redo:ji((function(){oa(this,"redo")})),undoSelection:ji((function(){oa(this,"undo",!0)})),redoSelection:ji((function(){oa(this,"redo",!0)})),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,r=0;r=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=mt(this,e),t=mt(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,(function(o){var a=o.markedSpans;if(a)for(var s=0;s=l.to||null==l.from&&i!=e.line||null!=l.from&&i==t.line&&l.from>=t.ch||n&&!n(l.marker)||r.push(l.marker.parent||l.marker)}++i})),r},getAllMarks:function(){var e=[];return this.iter((function(t){var n=t.markedSpans;if(n)for(var r=0;re)return t=e,!0;e-=o,++n})),mt(this,ut(n,t))},indexFromPos:function(e){var t=(e=mt(this,e)).ch;if(e.linet&&(t=e.from),null!=e.to&&e.to-1)return t.state.draggingText(e),void setTimeout((function(){return t.display.input.focus()}),20);try{var f=e.dataTransfer.getData("Text");if(f){var p;if(t.state.draggingText&&!t.state.draggingText.copy&&(p=t.listSelections()),Ko(t.doc,po(n,n)),p)for(var d=0;d=0;t--)ca(e.doc,"",r[t].from,r[t].to,"+delete");pi(e)}))}function Za(e,t,n){var r=fe(e.text,t+n,n);return r<0||r>e.text.length?null:r}function Qa(e,t,n){var r=Za(e,t.ch,n);return null==r?null:new ut(t.line,r,n<0?"after":"before")}function es(e,t,n,r,i){if(e){"rtl"==t.doc.direction&&(i=-i);var o=me(n,t.doc.direction);if(o){var a,s=i<0?ee(o):o[0],l=i<0==(1==s.level)?"after":"before";if(s.level>0||"rtl"==t.doc.direction){var c=sr(t,n);a=i<0?n.text.length-1:0;var u=lr(t,c,a).top;a=pe((function(e){return lr(t,c,e).top==u}),i<0==(1==s.level)?s.from:s.to-1,a),"before"==l&&(a=Za(n,a,1))}else a=i<0?s.to:s.from;return new ut(r,a,l)}}return new ut(r,i<0?n.text.length:0,i<0?"before":"after")}function ts(e,t,n,r){var i=me(t,e.doc.direction);if(!i)return Qa(t,n,r);n.ch>=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var o=ve(i,n.ch,n.sticky),a=i[o];if("ltr"==e.doc.direction&&a.level%2==0&&(r>0?a.to>n.ch:a.from=a.from&&p>=u.begin)){var d=f?"before":"after";return new ut(n.line,p,d)}}var h=function(e,t,r){for(var o=function(e,t){return t?new ut(n.line,l(e,1),"before"):new ut(n.line,e,"after")};e>=0&&e0==(1!=a.level),c=s?r.begin:l(r.end,-1);if(a.from<=c&&c0?u.end:l(u.begin,-1);return null==g||r>0&&g==t.text.length||!(v=h(r>0?0:i.length-1,r,c(g)))?null:v}Wa.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"},Wa.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"},Wa.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},Wa.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"]},Wa.default=b?Wa.macDefault:Wa.pcDefault;var ns={selectAll:ta,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),K)},killLine:function(e){return Ja(e,(function(t){if(t.empty()){var n=nt(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line0)i=new ut(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),ut(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var a=nt(e.doc,i.line-1).text;a&&(i=new ut(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),ut(i.line-1,a.length-1),i,"+transpose"))}n.push(new uo(i,i))}e.setSelections(n)}))},newlineAndIndent:function(e){return Ii(e,(function(){for(var t=e.listSelections(),n=t.length-1;n>=0;n--)e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input");t=e.listSelections();for(var r=0;r-1&&(ft((i=s.ranges[i]).from(),t)<0||t.xRel>0)&&(ft(i.to(),t)>0||t.xRel<0)?Ls(e,r,t,o):Es(e,r,t,o)}function Ls(e,t,n,r){var i=e.display,o=!1,c=Fi(e,(function(t){l&&(i.scroller.draggable=!1),e.state.draggingText=!1,e.state.delayingBlurEvent&&(e.hasFocus()?e.state.delayingBlurEvent=!1:ti(e)),we(i.wrapper.ownerDocument,"mouseup",c),we(i.wrapper.ownerDocument,"mousemove",u),we(i.scroller,"dragstart",f),we(i.scroller,"drop",c),o||(Le(t),r.addNew||Ho(e.doc,n,null,null,r.extend),l&&!d||a&&9==s?setTimeout((function(){i.wrapper.ownerDocument.body.focus({preventScroll:!0}),i.input.focus()}),20):i.input.focus())})),u=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},f=function(){return o=!0};l&&(i.scroller.draggable=!0),e.state.draggingText=c,c.copy=!r.moveOnDrag,be(i.wrapper.ownerDocument,"mouseup",c),be(i.wrapper.ownerDocument,"mousemove",u),be(i.scroller,"dragstart",f),be(i.scroller,"drop",c),e.state.delayingBlurEvent=!0,setTimeout((function(){return i.input.focus()}),20),i.scroller.dragDrop&&i.scroller.dragDrop()}function Ts(e,t,n){if("char"==n)return new uo(t,t);if("word"==n)return e.findWordAt(t);if("line"==n)return new uo(ut(t.line,0),mt(e.doc,ut(t.line+1,0)));var r=n(e,t);return new uo(r.from,r.to)}function Es(e,t,n,r){a&&ti(e);var i=e.display,o=e.doc;Le(t);var s,l,c=o.sel,u=c.ranges;if(r.addNew&&!r.extend?(l=o.sel.contains(n),s=l>-1?u[l]:new uo(n,n)):(s=o.sel.primary(),l=o.sel.primIndex),"rectangle"==r.unit)r.addNew||(s=new uo(n,n)),n=Br(e,t,!0,!0),l=-1;else{var f=Ts(e,n,r.unit);s=r.extend?Bo(s,f.anchor,f.head,r.extend):f}r.addNew?-1==l?(l=u.length,qo(o,fo(e,u.concat([s]),l),{scroll:!1,origin:"*mouse"})):u.length>1&&u[l].empty()&&"char"==r.unit&&!r.extend?(qo(o,fo(e,u.slice(0,l).concat(u.slice(l+1)),0),{scroll:!1,origin:"*mouse"}),c=o.sel):Wo(o,l,s,X):(l=0,qo(o,new co([s],0),X),c=o.sel);var p=n;function d(t){if(0!=ft(p,t))if(p=t,"rectangle"==r.unit){for(var i=[],a=e.options.tabSize,u=W(nt(o,n.line).text,n.ch,a),f=W(nt(o,t.line).text,t.ch,a),d=Math.min(u,f),h=Math.max(u,f),v=Math.min(n.line,t.line),g=Math.min(e.lastLine(),Math.max(n.line,t.line));v<=g;v++){var m=nt(o,v).text,y=J(m,d,a);d==h?i.push(new uo(ut(v,y),ut(v,y))):m.length>y&&i.push(new uo(ut(v,y),ut(v,J(m,h,a))))}i.length||i.push(new uo(n,n)),qo(o,fo(e,c.ranges.slice(0,l).concat(i),l),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var b,x=s,w=Ts(e,t,r.unit),k=x.anchor;ft(w.anchor,k)>0?(b=w.head,k=vt(x.from(),w.anchor)):(b=w.anchor,k=ht(x.to(),w.head));var C=c.ranges.slice(0);C[l]=As(e,new uo(mt(o,k),b)),qo(o,fo(e,C,l),X)}}var h=i.wrapper.getBoundingClientRect(),v=0;function g(t){var n=++v,a=Br(e,t,!0,"rectangle"==r.unit);if(a)if(0!=ft(a,p)){e.curOp.focus=R(D(e)),d(a);var s=ai(i,o);(a.line>=s.to||a.lineh.bottom?20:0;l&&setTimeout(Fi(e,(function(){v==n&&(i.scroller.scrollTop+=l,g(t))})),50)}}function m(t){e.state.selectingText=!1,v=1/0,t&&(Le(t),i.input.focus()),we(i.wrapper.ownerDocument,"mousemove",y),we(i.wrapper.ownerDocument,"mouseup",b),o.history.lastSelOrigin=null}var y=Fi(e,(function(e){0!==e.buttons&&Ne(e)?g(e):m(e)})),b=Fi(e,m);e.state.selectingText=b,be(i.wrapper.ownerDocument,"mousemove",y),be(i.wrapper.ownerDocument,"mouseup",b)}function As(e,t){var n=t.anchor,r=t.head,i=nt(e.doc,n.line);if(0==ft(n,r)&&n.sticky==r.sticky)return t;var o=me(i);if(!o)return t;var a=ve(o,n.ch,n.sticky),s=o[a];if(s.from!=n.ch&&s.to!=n.ch)return t;var l,c=a+(s.from==n.ch==(1!=s.level)?0:1);if(0==c||c==o.length)return t;if(r.line!=n.line)l=(r.line-n.line)*("ltr"==e.doc.direction?1:-1)>0;else{var u=ve(o,r.ch,r.sticky),f=u-a||(r.ch-n.ch)*(1==s.level?-1:1);l=u==c-1||u==c?f<0:f>0}var p=o[c+(l?-1:0)],d=l==(1==p.level),h=d?p.from:p.to,v=d?"after":"before";return n.ch==h&&n.sticky==v?t:new uo(new ut(n.line,h,v),r)}function Ms(e,t,n,r){var i,o;if(t.touches)i=t.touches[0].clientX,o=t.touches[0].clientY;else try{i=t.clientX,o=t.clientY}catch(e){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Le(t);var a=e.display,s=a.lineDiv.getBoundingClientRect();if(o>s.bottom||!Se(e,n))return Ee(t);o-=s.top-a.viewOffset;for(var l=0;l=i)return ke(e,n,e,st(e.doc,o),e.display.gutterSpecs[l].className,t),Ee(t)}}function Ns(e,t){return Ms(e,t,"gutterClick",!0)}function Rs(e,t){Xn(e.display,t)||Ps(e,t)||Ce(e,t,"contextmenu")||_||e.display.input.onContextMenu(t)}function Ps(e,t){return!!Se(e,"gutterContextMenu")&&Ms(e,t,"gutterContextMenu",!1)}function $s(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),mr(e)}ws.prototype.compare=function(e,t,n){return this.time+xs>e&&0==ft(t,this.pos)&&n==this.button};var Is={toString:function(){return"CodeMirror.Init"}},Fs={},Ds={};function js(e){var t=e.optionHandlers;function n(n,r,i,o){e.defaults[n]=r,i&&(t[n]=o?function(e,t,n){n!=Is&&i(e,t,n)}:i)}e.defineOption=n,e.Init=Is,n("value","",(function(e,t){return e.setValue(t)}),!0),n("mode",null,(function(e,t){e.doc.modeOption=t,bo(e)}),!0),n("indentUnit",2,bo,!0),n("indentWithTabs",!1),n("smartIndent",!0),n("tabSize",4,(function(e){xo(e),mr(e),zr(e)}),!0),n("lineSeparator",null,(function(e,t){if(e.doc.lineSep=t,t){var n=[],r=e.doc.first;e.doc.iter((function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(-1==o)break;i=o+t.length,n.push(ut(r,o))}r++}));for(var i=n.length-1;i>=0;i--)ca(e.doc,t,n[i],ut(n[i].line,n[i].ch+t.length))}})),n("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]/g,(function(e,t,n){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),n!=Is&&e.refresh()})),n("specialCharPlaceholder",wn,(function(e){return e.refresh()}),!0),n("electricChars",!0),n("inputStyle",y?"contenteditable":"textarea",(function(){throw new Error("inputStyle can not (yet) be changed in a running editor")}),!0),n("spellcheck",!1,(function(e,t){return e.getInputField().spellcheck=t}),!0),n("autocorrect",!1,(function(e,t){return e.getInputField().autocorrect=t}),!0),n("autocapitalize",!1,(function(e,t){return e.getInputField().autocapitalize=t}),!0),n("rtlMoveVisually",!w),n("wholeLineUpdateBefore",!0),n("theme","default",(function(e){$s(e),no(e)}),!0),n("keyMap","default",(function(e,t,n){var r=Ya(t),i=n!=Is&&Ya(n);i&&i.detach&&i.detach(e,r),r.attach&&r.attach(e,i||null)})),n("extraKeys",null),n("configureMouse",null),n("lineWrapping",!1,Hs,!0),n("gutters",[],(function(e,t){e.display.gutterSpecs=eo(t,e.options.lineNumbers),no(e)}),!0),n("fixedGutter",!0,(function(e,t){e.display.gutters.style.left=t?Fr(e.display)+"px":"0",e.refresh()}),!0),n("coverGutterNextToScrollbar",!1,(function(e){return Ci(e)}),!0),n("scrollbarStyle","native",(function(e){Oi(e),Ci(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)}),!0),n("lineNumbers",!1,(function(e,t){e.display.gutterSpecs=eo(e.options.gutters,t),no(e)}),!0),n("firstLineNumber",1,no,!0),n("lineNumberFormatter",(function(e){return e}),no,!0),n("showCursorWhenSelecting",!1,Kr,!0),n("resetSelectionOnContextMenu",!0),n("lineWiseCopyCut",!0),n("pasteLinesPerSelection",!0),n("selectionsMayTouch",!1),n("readOnly",!1,(function(e,t){"nocursor"==t&&(ri(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)})),n("screenReaderLabel",null,(function(e,t){t=""===t?null:t,e.display.input.screenReaderLabelChanged(t)})),n("disableInput",!1,(function(e,t){t||e.display.input.reset()}),!0),n("dragDrop",!0,Bs),n("allowDropFileTypes",null),n("cursorBlinkRate",530),n("cursorScrollMargin",0),n("cursorHeight",1,Kr,!0),n("singleCursorHeightPerLine",!0,Kr,!0),n("workTime",100),n("workDelay",100),n("flattenSpans",!0,xo,!0),n("addModeClass",!1,xo,!0),n("pollInterval",100),n("undoDepth",200,(function(e,t){return e.doc.history.undoDepth=t})),n("historyEventDelay",1250),n("viewportMargin",10,(function(e){return e.refresh()}),!0),n("maxHighlightLength",1e4,xo,!0),n("moveInputWithCursor",!0,(function(e,t){t||e.display.input.resetPosition()})),n("tabindex",null,(function(e,t){return e.display.input.getField().tabIndex=t||""})),n("autofocus",null),n("direction","ltr",(function(e,t){return e.doc.setDirection(t)}),!0),n("phrases",null)}function Bs(e,t,n){if(!t!=!(n&&n!=Is)){var r=e.display.dragFunctions,i=t?be:we;i(e.display.scroller,"dragstart",r.start),i(e.display.scroller,"dragenter",r.enter),i(e.display.scroller,"dragover",r.over),i(e.display.scroller,"dragleave",r.leave),i(e.display.scroller,"drop",r.drop)}}function Hs(e){e.options.lineWrapping?(P(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(L(e.display.wrapper,"CodeMirror-wrap"),dn(e)),jr(e),zr(e),mr(e),setTimeout((function(){return Ci(e)}),100)}function zs(e,t){var n=this;if(!(this instanceof zs))return new zs(e,t);this.options=t=t?z(t):{},z(Fs,t,!1);var r=t.value;"string"==typeof r?r=new Ta(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var i=new zs.inputStyles[t.inputStyle](this),o=this.display=new ro(e,r,i,t);for(var c in o.wrapper.CodeMirror=this,$s(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Oi(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 U,keySeq:null,specialChars:null},t.autofocus&&!y&&o.input.focus(),a&&s<11&&setTimeout((function(){return n.display.input.reset(!0)}),20),Ws(this),Ia(),Ti(this),this.curOp.forceUpdate=!0,_o(this,r),t.autofocus&&!y||this.hasFocus()?setTimeout((function(){n.hasFocus()&&!n.state.focused&&ni(n)}),20):ri(this),Ds)Ds.hasOwnProperty(c)&&Ds[c](this,t[c],Is);Qi(this),t.finishInit&&t.finishInit(this);for(var u=0;u400}be(t.scroller,"touchstart",(function(i){if(!Ce(e,i)&&!o(i)&&!Ns(e,i)){t.input.ensurePolled(),clearTimeout(n);var a=+new Date;t.activeTouch={start:a,moved:!1,prev:a-r.end<=300?r:null},1==i.touches.length&&(t.activeTouch.left=i.touches[0].pageX,t.activeTouch.top=i.touches[0].pageY)}})),be(t.scroller,"touchmove",(function(){t.activeTouch&&(t.activeTouch.moved=!0)})),be(t.scroller,"touchend",(function(n){var r=t.activeTouch;if(r&&!Xn(t,n)&&null!=r.left&&!r.moved&&new Date-r.start<300){var o,a=e.coordsChar(t.activeTouch,"page");o=!r.prev||l(r,r.prev)?new uo(a,a):!r.prev.prev||l(r,r.prev.prev)?e.findWordAt(a):new uo(ut(a.line,0),mt(e.doc,ut(a.line+1,0))),e.setSelection(o.anchor,o.head),e.focus(),Le(n)}i()})),be(t.scroller,"touchcancel",i),be(t.scroller,"scroll",(function(){t.scroller.clientHeight&&(mi(e,t.scroller.scrollTop),bi(e,t.scroller.scrollLeft,!0),ke(e,"scroll",e))})),be(t.scroller,"mousewheel",(function(t){return lo(e,t)})),be(t.scroller,"DOMMouseScroll",(function(t){return lo(e,t)})),be(t.wrapper,"scroll",(function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0})),t.dragFunctions={enter:function(t){Ce(e,t)||Ae(t)},over:function(t){Ce(e,t)||(Na(e,t),Ae(t))},start:function(t){return Ma(e,t)},drop:Fi(e,Aa),leave:function(t){Ce(e,t)||Ra(e)}};var c=t.input.getField();be(c,"keyup",(function(t){return gs.call(e,t)})),be(c,"keydown",Fi(e,hs)),be(c,"keypress",Fi(e,ms)),be(c,"focus",(function(t){return ni(e,t)})),be(c,"blur",(function(t){return ri(e,t)}))}zs.defaults=Fs,zs.optionHandlers=Ds;var Us=[];function Vs(e,t,n,r){var i,o=e.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?i=_t(e,t).state:n="prev");var a=e.options.tabSize,s=nt(o,t),l=W(s.text,null,a);s.stateAfter&&(s.stateAfter=null);var c,u=s.text.match(/^\s*/)[0];if(r||/\S/.test(s.text)){if("smart"==n&&((c=o.mode.indent(i,s.text.slice(u.length),s.text))==q||c>150)){if(!r)return;n="prev"}}else c=0,n="not";"prev"==n?c=t>o.first?W(nt(o,t-1).text,null,a):0:"add"==n?c=l+e.options.indentUnit:"subtract"==n?c=l-e.options.indentUnit:"number"==typeof n&&(c=l+n),c=Math.max(0,c);var f="",p=0;if(e.options.indentWithTabs)for(var d=Math.floor(c/a);d;--d)p+=a,f+="\t";if(pa,l=je(t),c=null;if(s&&r.ranges.length>1)if(Gs&&Gs.text.join("\n")==t){if(r.ranges.length%Gs.text.length==0){c=[];for(var u=0;u=0;p--){var d=r.ranges[p],h=d.from(),v=d.to();d.empty()&&(n&&n>0?h=ut(h.line,h.ch-n):e.state.overwrite&&!s?v=ut(v.line,Math.min(nt(o,v.line).text.length,v.ch+ee(l).length)):s&&Gs&&Gs.lineWise&&Gs.text.join("\n")==l.join("\n")&&(h=v=ut(h.line,0)));var g={from:h,to:v,text:c?c[p%c.length]:l,origin:i||(s?"paste":e.state.cutIncoming>a?"cut":"+input")};ra(e.doc,g),Pn(e,"inputRead",e,g)}t&&!s&&Ys(e,t),pi(e),e.curOp.updateInput<2&&(e.curOp.updateInput=f),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Xs(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");if(n)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||!t.hasFocus()||Ii(t,(function(){return Ks(t,n,0,null,"paste")})),!0}function Ys(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(!(i.head.ch>100||r&&n.ranges[r-1].head.line==i.head.line)){var o=e.getModeAt(i.head),a=!1;if(o.electricChars){for(var s=0;s-1){a=Vs(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(nt(e.doc,i.head.line).text.slice(0,i.head.ch))&&(a=Vs(e,i.head.line,"smart"));a&&Pn(e,"electricInput",e,i.head.line)}}}function Js(e){for(var t=[],n=[],r=0;rn&&(Vs(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&pi(this));else{var o=i.from(),a=i.to(),s=Math.max(n,o.line);n=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var l=s;l0&&Wo(this.doc,r,new uo(o,c[r].to()),K)}}})),getTokenAt:function(e,t){return Et(this,e,t)},getLineTokens:function(e,t){return Et(this,ut(e),t,!0)},getTokenTypeAt:function(e){e=mt(this.doc,e);var t,n=Ct(this,nt(this.doc,e.line)),r=0,i=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var a=r+i>>1;if((a?n[2*a-1]:0)>=o)i=a;else{if(!(n[2*a+1]o&&(e=o,i=!0),r=nt(this.doc,e)}else r=e;return wr(this,r,{top:0,left:0},t||"page",n||i).top+(i?this.doc.height-fn(r):0)},defaultTextHeight:function(){return Pr(this.display)},defaultCharWidth:function(){return $r(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var o=this.display,a=(e=_r(this,mt(this.doc,e))).bottom,s=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==r)a=e.top;else if("above"==r||"near"==r){var l=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>l)&&e.top>t.offsetHeight?a=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=l&&(a=e.bottom),s+t.offsetWidth>c&&(s=c-t.offsetWidth)}t.style.top=a+"px",t.style.left=t.style.right="","right"==i?(s=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=s+"px"),n&&ci(this,{left:s,top:a,right:s+t.offsetWidth,bottom:a+t.offsetHeight})},triggerOnKeyDown:Di(hs),triggerOnKeyPress:Di(ms),triggerOnKeyUp:gs,triggerOnMouseDown:Di(Cs),execCommand:function(e){if(ns.hasOwnProperty(e))return ns[e].call(null,this)},triggerElectric:Di((function(e){Ys(this,e)})),findPosH:function(e,t,n,r){var i=1;t<0&&(i=-1,t=-t);for(var o=mt(this.doc,e),a=0;a0&&a(t.charAt(n-1));)--n;for(;r.5||this.options.lineWrapping)&&jr(this),ke(this,"refresh",this)})),swapDoc:Di((function(e){var t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),_o(this,e),mr(this),this.display.input.reset(),di(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,Pn(this,"swapDoc",this,t),t})),phrase:function(e){var t=this.options.phrases;return t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:e},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Oe(e),e.registerHelper=function(t,r,i){n.hasOwnProperty(t)||(n[t]=e[t]={_global:[]}),n[t][r]=i},e.registerGlobalHelper=function(t,r,i,o){e.registerHelper(t,r,o),n[t]._global.push({pred:i,val:o})}}function tl(e,t,n,r,i){var o=t,a=n,s=nt(e,t.line),l=i&&"rtl"==e.direction?-n:n;function c(){var n=t.line+l;return!(n=e.first+e.size)&&(t=new ut(n,t.ch,t.sticky),s=nt(e,n))}function u(o){var a;if("codepoint"==r){var u=s.text.charCodeAt(t.ch+(n>0?0:-1));if(isNaN(u))a=null;else{var f=n>0?u>=55296&&u<56320:u>=56320&&u<57343;a=new ut(t.line,Math.max(0,Math.min(s.text.length,t.ch+n*(f?2:1))),-n)}}else a=i?ts(e.cm,s,t,n):Qa(s,t,n);if(null==a){if(o||!c())return!1;t=es(i,e.cm,s,t.line,l)}else t=a;return!0}if("char"==r||"codepoint"==r)u();else if("column"==r)u(!0);else if("word"==r||"group"==r)for(var f=null,p="group"==r,d=e.cm&&e.cm.getHelper(t,"wordChars"),h=!0;!(n<0)||u(!h);h=!1){var v=s.text.charAt(t.ch)||"\n",g=se(v,d)?"w":p&&"\n"==v?"n":!p||/\s/.test(v)?null:"p";if(!p||h||g||(g="s"),f&&f!=g){n<0&&(n=1,u(),t.sticky="after");break}if(g&&(f=g),n>0&&!u(!h))break}var m=Qo(e,t,o,a,!0);return pt(o,m)&&(m.hitSide=!0),m}function nl(e,t,n,r){var i,o,a=e.doc,s=t.left;if("page"==r){var l=Math.min(e.display.wrapper.clientHeight,B(e).innerHeight||a(e).documentElement.clientHeight),c=Math.max(l-.5*Pr(e.display),3);i=(n>0?t.bottom:t.top)+n*c}else"line"==r&&(i=n>0?t.bottom+3:t.top-3);for(;(o=Lr(e,s,i)).outside;){if(n<0?i<=0:i>=a.height){o.hitSide=!0;break}i+=5*n}return o}var rl=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new U,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function il(e,t){var n=ar(e,t.line);if(!n||n.hidden)return null;var r=nt(e.doc,t.line),i=rr(n,r,t.line),o=me(r,e.doc.direction),a="left";o&&(a=ve(o,t.ch)%2?"right":"left");var s=fr(i.map,t.ch,a);return s.offset="right"==s.collapse?s.end:s.start,s}function ol(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 sl(e,t,n,r,i){var o="",a=!1,s=e.doc.lineSeparator(),l=!1;function c(e){return function(t){return t.id==e}}function u(){a&&(o+=s,l&&(o+=s),a=l=!1)}function f(e){e&&(u(),o+=e)}function p(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(n)return void f(n);var o,d=t.getAttribute("cm-marker");if(d){var h=e.findMarks(ut(r,0),ut(i+1,0),c(+d));return void(h.length&&(o=h[0].find(0))&&f(rt(e.doc,o.from,o.to).join(s)))}if("false"==t.getAttribute("contenteditable"))return;var v=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;v&&u();for(var g=0;g=t.display.viewTo||o.line=t.display.viewFrom&&il(t,i)||{node:l[0].measure.map[2],offset:0},u=o.liner.firstLine()&&(a=ut(a.line-1,nt(r.doc,a.line-1).length)),s.ch==nt(r.doc,s.line).text.length&&s.linei.viewTo-1)return!1;a.line==i.viewFrom||0==(e=Hr(r,a.line))?(t=at(i.view[0].line),n=i.view[0].node):(t=at(i.view[e].line),n=i.view[e-1].node.nextSibling);var l,c,u=Hr(r,s.line);if(u==i.view.length-1?(l=i.viewTo-1,c=i.lineDiv.lastChild):(l=at(i.view[u+1].line)-1,c=i.view[u+1].node.previousSibling),!n)return!1;for(var f=r.doc.splitLines(sl(r,n,c,t,l)),p=rt(r.doc,ut(t,0),ut(l,nt(r.doc,l).text.length));f.length>1&&p.length>1;)if(ee(f)==ee(p))f.pop(),p.pop(),l--;else{if(f[0]!=p[0])break;f.shift(),p.shift(),t++}for(var d=0,h=0,v=f[0],g=p[0],m=Math.min(v.length,g.length);da.ch&&y.charCodeAt(y.length-h-1)==b.charCodeAt(b.length-h-1);)d--,h++;f[f.length-1]=y.slice(0,y.length-h).replace(/^\u200b+/,""),f[0]=f[0].slice(d).replace(/\u200b+$/,"");var w=ut(t,d),k=ut(l,p.length?ee(p).length-h:0);return f.length>1||f[0]||ft(w,k)?(ca(r.doc,f,w,k,"+input"),!0):void 0},rl.prototype.ensurePolled=function(){this.forceCompositionEnd()},rl.prototype.reset=function(){this.forceCompositionEnd()},rl.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},rl.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout((function(){if(e.readDOMTimeout=null,e.composing){if(!e.composing.done)return;e.composing=null}e.updateFromDOM()}),80))},rl.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||Ii(this.cm,(function(){return zr(e.cm)}))},rl.prototype.setUneditable=function(e){e.contentEditable="false"},rl.prototype.onKeyPress=function(e){0==e.charCode||this.composing||(e.preventDefault(),this.cm.isReadOnly()||Fi(this.cm,Ks)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},rl.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},rl.prototype.onContextMenu=function(){},rl.prototype.resetPosition=function(){},rl.prototype.needsContentAttribute=!0;var ul=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new U,this.hasSelection=!1,this.composing=null,this.resetting=!1};function fl(e,t){if((t=t?z(t):{}).value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var n=R(j(e));t.autofocus=n==e||null!=e.getAttribute("autofocus")&&n==document.body}function r(){e.value=s.getValue()}var i;if(e.form&&(be(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var o=e.form;i=o.submit;try{var a=o.submit=function(){r(),o.submit=i,o.submit(),o.submit=a}}catch(e){}}t.finishInit=function(n){n.save=r,n.getTextArea=function(){return e},n.toTextArea=function(){n.toTextArea=isNaN,r(),e.parentNode.removeChild(n.getWrapperElement()),e.style.display="",e.form&&(we(e.form,"submit",r),t.leaveSubmitMethodAlone||"function"!=typeof e.form.submit||(e.form.submit=i))}},e.style.display="none";var s=zs((function(t){return e.parentNode.insertBefore(t,e.nextSibling)}),t);return s}function pl(e){e.off=we,e.on=be,e.wheelEventPixels=so,e.Doc=Ta,e.splitLines=je,e.countColumn=W,e.findColumn=J,e.isWordChar=ae,e.Pass=q,e.signal=ke,e.Line=hn,e.changeEnd=ho,e.scrollbarModel=Si,e.Pos=ut,e.cmpPos=ft,e.modes=Ue,e.mimeModes=Ve,e.resolveMode=Ke,e.getMode=Xe,e.modeExtensions=Ye,e.extendMode=Je,e.copyState=Ze,e.startState=et,e.innerMode=Qe,e.commands=ns,e.keyMap=Wa,e.keyName=Xa,e.isModifierKey=qa,e.lookupKey=Ga,e.normalizeKeyMap=Va,e.StringStream=tt,e.SharedTextMarker=ka,e.TextMarker=xa,e.LineWidget=ga,e.e_preventDefault=Le,e.e_stopPropagation=Te,e.e_stop=Ae,e.addClass=P,e.contains=N,e.rmClass=L,e.keyNames=ja}ul.prototype.init=function(e){var t=this,n=this,r=this.cm;this.createField(e);var i=this.textarea;function o(e){if(!Ce(r,e)){if(r.somethingSelected())qs({lineWise:!1,text:r.getSelections()});else{if(!r.options.lineWiseCopyCut)return;var t=Js(r);qs({lineWise:!0,text:t.text}),"cut"==e.type?r.setSelections(t.ranges,null,K):(n.prevInput="",i.value=t.text.join("\n"),I(i))}"cut"==e.type&&(r.state.cutIncoming=+new Date)}}e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),g&&(i.style.width="0px"),be(i,"input",(function(){a&&s>=9&&t.hasSelection&&(t.hasSelection=null),n.poll()})),be(i,"paste",(function(e){Ce(r,e)||Xs(e,r)||(r.state.pasteIncoming=+new Date,n.fastPoll())})),be(i,"cut",o),be(i,"copy",o),be(e.scroller,"paste",(function(t){if(!Xn(e,t)&&!Ce(r,t)){if(!i.dispatchEvent)return r.state.pasteIncoming=+new Date,void n.focus();var o=new Event("paste");o.clipboardData=t.clipboardData,i.dispatchEvent(o)}})),be(e.lineSpace,"selectstart",(function(t){Xn(e,t)||Le(t)})),be(i,"compositionstart",(function(){var e=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}})),be(i,"compositionend",(function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)}))},ul.prototype.createField=function(e){this.wrapper=Qs(),this.textarea=this.wrapper.firstChild;var t=this.cm.options;Zs(this.textarea,t.spellcheck,t.autocorrect,t.autocapitalize)},ul.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},ul.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc,r=Xr(e);if(e.options.moveInputWithCursor){var i=_r(e,n.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+a.top-o.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+a.left-o.left))}return r},ul.prototype.showSelection=function(e){var t=this.cm.display;E(t.cursorDiv,e.cursors),E(t.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},ul.prototype.reset=function(e){if(!(this.contextMenuPending||this.composing&&e)){var t=this.cm;if(this.resetting=!0,t.somethingSelected()){this.prevInput="";var n=t.getSelection();this.textarea.value=n,t.state.focused&&I(this.textarea),a&&s>=9&&(this.hasSelection=n)}else e||(this.prevInput=this.textarea.value="",a&&s>=9&&(this.hasSelection=null));this.resetting=!1}},ul.prototype.getField=function(){return this.textarea},ul.prototype.supportsTouch=function(){return!1},ul.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!y||R(j(this.textarea))!=this.textarea))try{this.textarea.focus()}catch(e){}},ul.prototype.blur=function(){this.textarea.blur()},ul.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},ul.prototype.receivedFocus=function(){this.slowPoll()},ul.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,(function(){e.poll(),e.cm.state.focused&&e.slowPoll()}))},ul.prototype.fastPoll=function(){var e=!1,t=this;function n(){t.poll()||e?(t.pollingFast=!1,t.slowPoll()):(e=!0,t.polling.set(60,n))}t.pollingFast=!0,t.polling.set(20,n)},ul.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||this.resetting||!t.state.focused||Be(n)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=n.value;if(i==r&&!t.somethingSelected())return!1;if(a&&s>=9&&this.hasSelection===i||b&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||r||(r=""),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var l=0,c=Math.min(r.length,i.length);l1e3||i.indexOf("\n")>-1?n.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))})),!0},ul.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},ul.prototype.onKeyPress=function(){a&&s>=9&&(this.hasSelection=null),this.fastPoll()},ul.prototype.onContextMenu=function(e){var t=this,n=t.cm,r=n.display,i=t.textarea;t.contextMenuPending&&t.contextMenuPending();var o=Br(n,e),c=r.scroller.scrollTop;if(o&&!p){n.options.resetSelectionOnContextMenu&&-1==n.doc.sel.contains(o)&&Fi(n,qo)(n.doc,po(o),K);var u,f=i.style.cssText,d=t.wrapper.style.cssText,h=t.wrapper.offsetParent.getBoundingClientRect();if(t.wrapper.style.cssText="position: static",i.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-h.top-5)+"px; left: "+(e.clientX-h.left-5)+"px;\n z-index: 1000; background: "+(a?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",l&&(u=i.ownerDocument.defaultView.scrollY),r.input.focus(),l&&i.ownerDocument.defaultView.scrollTo(null,u),r.input.reset(),n.somethingSelected()||(i.value=t.prevInput=" "),t.contextMenuPending=m,r.selForContextMenu=n.doc.sel,clearTimeout(r.detectingSelectAll),a&&s>=9&&g(),_){Ae(e);var v=function(){we(window,"mouseup",v),setTimeout(m,20)};be(window,"mouseup",v)}else setTimeout(m,50)}function g(){if(null!=i.selectionStart){var e=n.somethingSelected(),o=""+(e?i.value:"");i.value="⇚",i.value=o,t.prevInput=e?"":"",i.selectionStart=1,i.selectionEnd=o.length,r.selForContextMenu=n.doc.sel}}function m(){if(t.contextMenuPending==m&&(t.contextMenuPending=!1,t.wrapper.style.cssText=d,i.style.cssText=f,a&&s<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=c),null!=i.selectionStart)){(!a||a&&s<9)&&g();var e=0,o=function(){r.selForContextMenu==n.doc.sel&&0==i.selectionStart&&i.selectionEnd>0&&""==t.prevInput?Fi(n,ta)(n):e++<10?r.detectingSelectAll=setTimeout(o,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(o,200)}}},ul.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e,this.textarea.readOnly=!!e},ul.prototype.setUneditable=function(){},ul.prototype.needsContentAttribute=!1,js(zs),el(zs);var dl="iter insert remove copy getEditor constructor".split(" ");for(var hl in Ta.prototype)Ta.prototype.hasOwnProperty(hl)&&V(dl,hl)<0&&(zs.prototype[hl]=function(e){return function(){return e.apply(this.doc,arguments)}}(Ta.prototype[hl]));return Oe(Ta),zs.inputStyles={textarea:ul,contenteditable:rl},zs.defineMode=function(e){zs.defaults.mode||"null"==e||(zs.defaults.mode=e),Ge.apply(this,arguments)},zs.defineMIME=qe,zs.defineMode("null",(function(){return{token:function(e){return e.skipToEnd()}}})),zs.defineMIME("text/plain","null"),zs.defineExtension=function(e,t){zs.prototype[e]=t},zs.defineDocExtension=function(e,t){Ta.prototype[e]=t},zs.fromTextArea=fl,pl(zs),zs.version="5.65.19",zs}()},5262:function(e){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=89)}([function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,n){var r=n(35),i=Function.prototype,o=i.call,a=r&&i.bind.bind(o,o);e.exports=r?a:function(e){return function(){return o.apply(e,arguments)}}},function(e,t,n){var r=n(59),i=r.all;e.exports=r.IS_HTMLDDA?function(e){return"function"==typeof e||e===i}:function(e){return"function"==typeof e}},function(e,t,n){var r=n(4),i=n(43).f,o=n(30),a=n(11),s=n(33),l=n(95),c=n(66);e.exports=function(e,t){var n,u,f,p,d,h=e.target,v=e.global,g=e.stat;if(n=v?r:g?r[h]||s(h,{}):(r[h]||{}).prototype)for(u in t){if(p=t[u],f=e.dontCallGetSet?(d=i(n,u))&&d.value:n[u],!c(v?u:h+(g?".":"#")+u,e.forced)&&void 0!==f){if(typeof p==typeof f)continue;l(p,f)}(e.sham||f&&f.sham)&&o(p,"sham",!0),a(n,u,p,e)}}},function(e,t,n){(function(t){var n=function(e){return e&&e.Math==Math&&e};e.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||function(){return this}()||Function("return this")()}).call(t,n(139))},function(e,t,n){var r=n(0);e.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},function(e,t,n){var r=n(8),i=String,o=TypeError;e.exports=function(e){if(r(e))return e;throw o(i(e)+" is not an object")}},function(e,t,n){var r=n(1),i=n(14),o=r({}.hasOwnProperty);e.exports=Object.hasOwn||function(e,t){return o(i(e),t)}},function(e,t,n){var r=n(2),i=n(59),o=i.all;e.exports=i.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:r(e)||e===o}:function(e){return"object"==typeof e?null!==e:r(e)}},function(e,t,n){var r=n(4),i=n(47),o=n(7),a=n(75),s=n(72),l=n(76),c=i("wks"),u=r.Symbol,f=u&&u.for,p=l?u:u&&u.withoutSetter||a;e.exports=function(e){if(!o(c,e)||!s&&"string"!=typeof c[e]){var t="Symbol."+e;s&&o(u,e)?c[e]=u[e]:c[e]=l&&f?f(t):p(t)}return c[e]}},function(e,t,n){var r=n(123);e.exports=function(e){return r(e.length)}},function(e,t,n){var r=n(2),i=n(13),o=n(104),a=n(33);e.exports=function(e,t,n,s){s||(s={});var l=s.enumerable,c=void 0!==s.name?s.name:t;if(r(n)&&o(n,c,s),s.global)l?e[t]=n:a(t,n);else{try{s.unsafe?e[t]&&(l=!0):delete e[t]}catch(e){}l?e[t]=n:i.f(e,t,{value:n,enumerable:!1,configurable:!s.nonConfigurable,writable:!s.nonWritable})}return e}},function(e,t,n){var r=n(35),i=Function.prototype.call;e.exports=r?i.bind(i):function(){return i.apply(i,arguments)}},function(e,t,n){var r=n(5),i=n(62),o=n(77),a=n(6),s=n(50),l=TypeError,c=Object.defineProperty,u=Object.getOwnPropertyDescriptor;t.f=r?o?function(e,t,n){if(a(e),t=s(t),a(n),"function"==typeof e&&"prototype"===t&&"value"in n&&"writable"in n&&!n.writable){var r=u(e,t);r&&r.writable&&(e[t]=n.value,n={configurable:"configurable"in n?n.configurable:r.configurable,enumerable:"enumerable"in n?n.enumerable:r.enumerable,writable:!1})}return c(e,t,n)}:c:function(e,t,n){if(a(e),t=s(t),a(n),i)try{return c(e,t,n)}catch(e){}if("get"in n||"set"in n)throw l("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(24),i=Object;e.exports=function(e){return i(r(e))}},function(e,t,n){var r=n(1),i=r({}.toString),o=r("".slice);e.exports=function(e){return o(i(e),8,-1)}},function(e,t,n){var r=n(0),i=n(9),o=n(23),a=i("species");e.exports=function(e){return o>=51||!r((function(){var t=[];return(t.constructor={})[a]=function(){return{foo:1}},1!==t[e](Boolean).foo}))}},function(e,t,n){var r=n(4),i=n(2),o=function(e){return i(e)?e:void 0};e.exports=function(e,t){return arguments.length<2?o(r[e]):r[e]&&r[e][t]}},function(e,t,n){var r=n(15);e.exports=Array.isArray||function(e){return"Array"==r(e)}},function(e,t,n){var r=n(39),i=n(24);e.exports=function(e){return r(i(e))}},function(e,t,n){var r=n(29),i=String;e.exports=function(e){if("Symbol"===r(e))throw TypeError("Cannot convert a Symbol value to a string");return i(e)}},function(e,t,n){var r=n(100),i=n(1),o=n(39),a=n(14),s=n(10),l=n(28),c=i([].push),u=function(e){var t=1==e,n=2==e,i=3==e,u=4==e,f=6==e,p=7==e,d=5==e||f;return function(h,v,g,m){for(var y,b,x=a(h),w=o(x),k=r(v,g),C=s(w),_=0,S=m||l,O=t?S(h,C):n||p?S(h,0):void 0;C>_;_++)if((d||_ in w)&&(b=k(y=w[_],_,x),e))if(t)O[_]=b;else if(b)switch(e){case 3:return!0;case 5:return y;case 6:return _;case 2:c(O,y)}else switch(e){case 4:return!1;case 7:c(O,y)}return f?-1:i||u?u:O}};e.exports={forEach:u(0),map:u(1),filter:u(2),some:u(3),every:u(4),find:u(5),findIndex:u(6),filterReject:u(7)}},function(e,t){var n=TypeError;e.exports=function(e){if(e>9007199254740991)throw n("Maximum allowed index exceeded");return e}},function(e,t,n){var r,i,o=n(4),a=n(97),s=o.process,l=o.Deno,c=s&&s.versions||l&&l.version,u=c&&c.v8;u&&(i=(r=u.split("."))[0]>0&&r[0]<4?1:+(r[0]+r[1])),!i&&a&&(!(r=a.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=a.match(/Chrome\/(\d+)/))&&(i=+r[1]),e.exports=i},function(e,t,n){var r=n(40),i=TypeError;e.exports=function(e){if(r(e))throw i("Can't call method on "+e);return e}},function(e,t,n){var r=n(2),i=n(74),o=TypeError;e.exports=function(e){if(r(e))return e;throw o(i(e)+" is not a function")}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){var n=[][e];return!!n&&r((function(){n.call(null,t||function(){return 1},1)}))}},function(e,t,n){"use strict";var r=n(5),i=n(18),o=TypeError,a=Object.getOwnPropertyDescriptor,s=r&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}();e.exports=s?function(e,t){if(i(e)&&!a(e,"length").writable)throw o("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t}},function(e,t,n){var r=n(94);e.exports=function(e,t){return new(r(e))(0===t?0:t)}},function(e,t,n){var r=n(51),i=n(2),o=n(15),a=n(9)("toStringTag"),s=Object,l="Arguments"==o(function(){return arguments}()),c=function(e,t){try{return e[t]}catch(e){}};e.exports=r?o:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=c(t=s(e),a))?n:l?o(t):"Object"==(r=o(t))&&i(t.callee)?"Arguments":r}},function(e,t,n){var r=n(5),i=n(13),o=n(31);e.exports=r?function(e,t,n){return i.f(e,t,o(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){"use strict";var r=n(50),i=n(13),o=n(31);e.exports=function(e,t,n){var a=r(t);a in e?i.f(e,a,o(0,n)):e[a]=n}},function(e,t,n){var r=n(4),i=Object.defineProperty;e.exports=function(e,t){try{i(r,e,{value:t,configurable:!0,writable:!0})}catch(n){r[e]=t}return t}},function(e,t){e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},function(e,t,n){var r=n(0);e.exports=!r((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))},function(e,t,n){var r=n(5),i=n(7),o=Function.prototype,a=r&&Object.getOwnPropertyDescriptor,s=i(o,"name"),l=s&&"something"===function(){}.name,c=s&&(!r||r&&a(o,"name").configurable);e.exports={EXISTS:s,PROPER:l,CONFIGURABLE:c}},function(e,t,n){var r=n(15),i=n(1);e.exports=function(e){if("Function"===r(e))return i(e)}},function(e,t){e.exports={}},function(e,t,n){var r=n(1),i=n(0),o=n(15),a=Object,s=r("".split);e.exports=i((function(){return!a("z").propertyIsEnumerable(0)}))?function(e){return"String"==o(e)?s(e,""):a(e)}:a},function(e,t){e.exports=function(e){return null==e}},function(e,t,n){var r=n(17),i=n(2),o=n(44),a=n(76),s=Object;e.exports=a?function(e){return"symbol"==typeof e}:function(e){var t=r("Symbol");return i(t)&&o(t.prototype,s(e))}},function(e,t,n){var r,i=n(6),o=n(107),a=n(34),s=n(38),l=n(101),c=n(60),u=n(70)("IE_PROTO"),f=function(){},p=function(e){return"