f.clientHeight+1;if(setTimeout((function(){w=a.getScrollInfo()})),x.bottom-_>0){var D=x.bottom-x.top,P=x.top-(y.bottom-y.top)-2;_-x.topP&&(f.style.height=(D=P)+"px"),f.style.top=(N=y.top-D)+O+"px",A=!1):f.style.height=_-x.top-2+"px"}var U,k=x.right-b;if(M&&(k+=a.display.nativeBarWidth),k>0&&(x.right-x.left>b&&(f.style.width=b-5+"px",k-=x.right-x.left-b),f.style.left=(R=Math.max(y.left-k-S,0))+"px"),M)for(var F=f.firstChild;F;F=F.nextSibling)F.style.paddingRight=a.display.nativeBarWidth+"px";a.addKeyMap(this.keyMap=l(n,{moveFocus:function(e,t){o.changeActive(o.selectedHint+e,t)},setFocus:function(e){o.changeActive(e)},menuSize:function(){return o.screenAmount()},length:p.length,close:function(){n.close()},pick:function(){o.pick()},data:i})),n.options.closeOnUnfocus&&(a.on("blur",this.onBlur=function(){U=setTimeout((function(){n.close()}),100)}),a.on("focus",this.onFocus=function(){clearTimeout(U)})),a.on("scroll",this.onScroll=function(){var e=a.getScrollInfo(),t=a.getWrapperElement().getBoundingClientRect();w||(w=a.getScrollInfo());var r=N+w.top-e.top,i=r-(d.pageYOffset||(u.documentElement||u.body).scrollTop);if(A||(i+=f.offsetHeight),i<=t.top||i>=t.bottom)return n.close();f.style.top=r+"px",f.style.left=R+w.left-e.left+"px"}),e.on(f,"dblclick",(function(e){var t=c(f,e.target||e.srcElement);t&&null!=t.hintId&&(o.changeActive(t.hintId),o.pick())})),e.on(f,"click",(function(e){var t=c(f,e.target||e.srcElement);t&&null!=t.hintId&&(o.changeActive(t.hintId),n.options.completeOnSingleClick&&o.pick())})),e.on(f,"mousedown",(function(){setTimeout((function(){a.focus()}),20)}));var H=this.getSelectedHintRange();return 0===H.from&&0===H.to||this.scrollToActive(),e.signal(i,"select",p[this.selectedHint],f.childNodes[this.selectedHint]),!0}function d(e,t){if(!e.somethingSelected())return t;for(var r=[],n=0;n0?t(e):o(i+1)}))}o(0)};return o.async=!0,o.supportsSelection=!0,o}return(n=t.getHelper(t.getCursor(),"hintWords"))?function(t){return e.hint.fromList(t,{words:n})}:e.hint.anyword?function(t,r){return e.hint.anyword(t,r)}:function(){}}n.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.options.updateOnCursorActivity&&this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.data&&e.signal(this.data,"close"),this.widget&&this.widget.close(),e.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(t,r){var n=t.list[r],i=this;this.cm.operation((function(){n.hint?n.hint(i.cm,t,n):i.cm.replaceRange(s(n),n.from||t.from,n.to||t.to,"complete"),e.signal(t,"pick",n),i.cm.scrollIntoView()})),this.options.closeOnPick&&this.close()},cursorActivity:function(){this.debounce&&(o(this.debounce),this.debounce=0);var e=this.startPos;this.data&&(e=this.data.from);var t=this.cm.getCursor(),r=this.cm.getLine(t.line);if(t.line!=this.startPos.line||r.length-t.ch!=this.startLen-this.startPos.ch||t.ch=this.data.list.length?t=n?this.data.list.length-1:0:t<0&&(t=n?0:this.data.list.length-1),this.selectedHint!=t){var i=this.hints.childNodes[this.selectedHint];i&&(i.className=i.className.replace(" "+r,""),i.removeAttribute("aria-selected")),(i=this.hints.childNodes[this.selectedHint=t]).className+=" "+r,i.setAttribute("aria-selected","true"),this.completion.cm.getInputField().setAttribute("aria-activedescendant",i.id),this.scrollToActive(),e.signal(this.data,"select",this.data.list[this.selectedHint],i)}},scrollToActive:function(){var e=this.getSelectedHintRange(),t=this.hints.childNodes[e.from],r=this.hints.childNodes[e.to],n=this.hints.firstChild;t.offsetTopthis.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=r.offsetTop+r.offsetHeight-this.hints.clientHeight+n.offsetTop)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1},getSelectedHintRange:function(){var e=this.completion.options.scrollMargin||0;return{from:Math.max(0,this.selectedHint-e),to:Math.min(this.data.list.length-1,this.selectedHint+e)}}},e.registerHelper("hint","auto",{resolve:h}),e.registerHelper("hint","fromList",(function(t,r){var n,i=t.getCursor(),o=t.getTokenAt(i),a=e.Pos(i.line,o.start),s=i;o.start,]/,closeOnPick:!0,closeOnUnfocus:!0,updateOnCursorActivity:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null,paddingForScrollbar:!0,moveOnOverlap:!0};e.defineOption("hintOptions",null)}(r(32973))},22159:function(e,t,r){!function(e){"use strict";var t,r,n,i,o={QUERY_DIV:";",ALIAS_KEYWORD:"AS"},a=e.Pos,s=e.cmpPos;function l(e){return"[object Array]"==Object.prototype.toString.call(e)}function c(t,r){return t.getModeAt(t.getCursor()).config[r]||e.resolveMode("text/x-sql")[r]}function u(e){return c(e,"keywords")||[]}function d(e){return c(e,"identifierQuote")||"`"}function f(e){return"string"==typeof e?e:e.text}function h(e,t){return l(t)&&(t={columns:t}),t.text||(t.text=e),t}function p(e){var t={};if(l(e))for(var r=e.length-1;r>=0;r--){var n=e[r];t[f(n).toUpperCase()]=h(f(n),n)}else if(e)for(var i in e)t[i.toUpperCase()]=h(i,e[i]);return t}function E(e){return t[e.toUpperCase()]}function m(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function g(e,t){var r=e.length,n=f(t).substr(0,r);return e.toUpperCase()===n.toUpperCase()}function v(e,t,r,n){if(l(r))for(var i=0;i0)&&s(p,u[m])<=0){d={start:h,end:u[m]};break}h=u[m]}if(d.start){var g=r.getRange(d.start,d.end,!1);for(m=0;mm.ch&&(T.end=m.ch,T.string=T.string.slice(0,m.ch-T.start)),T.string.match(/^[.`"'\w@][\w$#]*$/g)?(h=T.string,c=T.start,f=T.end):(c=f=m.ch,h=""),"."==h.charAt(0)||h.charAt(0)==i)c=R(m,T,g,e);else{var y=function(e,t){return"object"==typeof e?e.className=t:e={text:e,className:t},e};v(g,h,r,(function(e){return y(e,"CodeMirror-hint-table CodeMirror-hint-default-table")})),v(g,h,t,(function(e){return y(e,"CodeMirror-hint-table")})),l||v(g,h,n,(function(e){return y(e.toUpperCase(),"CodeMirror-hint-keyword")}))}return{list:g,from:a(m.line,c),to:a(m.line,f)}}))}(r(32973),r(38621))},75113:function(e,t,r){!function(e){"use strict";var t="CodeMirror-activeline",r="CodeMirror-activeline-background",n="CodeMirror-activeline-gutter";function i(e){for(var i=0;i2),g=/Android/.test(e),v=m||g||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),T=m||/Mac/.test(t),y=/\bCrOS\b/.test(e),R=/win/i.test(t),N=f&&e.match(/Version\/(\d*\.\d*)/);N&&(N=Number(N[1])),N&&N>=15&&(f=!1,l=!0);var A=T&&(c||f&&(null==N||N<12.11)),S=r||a&&s>=9;function O(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var L,I=function(e,t){var r=e.className,n=O(t).exec(r);if(n){var i=r.slice(n.index+n[0].length);e.className=r.slice(0,n.index)+(i?n[1]+i:"")}};function C(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function b(e,t){return C(e).appendChild(t)}function _(e,t,r,n){var i=document.createElement(e);if(r&&(i.className=r),n&&(i.style.cssText=n),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o=t)return a+(t-o);a+=s-o,a+=r-a%r,o=s+1}}m?U=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:a&&(U=function(e){try{e.select()}catch(e){}});var Y=function(){this.id=null,this.f=null,this.time=0,this.handler=G(this.onTimeout,this)};function z(e,t){for(var r=0;r=t)return n+Math.min(a,t-i);if(i+=o-n,n=o+1,(i+=r-i%r)>=t)return n}}var Z=[""];function $(e){for(;Z.length<=e;)Z.push(ee(Z)+" ");return Z[e]}function ee(e){return e[e.length-1]}function te(e,t){for(var r=[],n=0;n""&&(e.toUpperCase()!=e.toLowerCase()||oe.test(e))}function se(e,t){return t?!!(t.source.indexOf("\\w")>-1&&ae(e))||t.test(e):ae(e)}function le(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ce=/[\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]/;function ue(e){return e.charCodeAt(0)>=768&&ce.test(e)}function de(e,t,r){for(;(r<0?t>0:tr?-1:1;;){if(t==r)return t;var i=(t+r)/2,o=n<0?Math.ceil(i):Math.floor(i);if(o==t)return e(o)?t:r;e(o)?r=o:t=o+n}}function he(e,t,r,n){if(!e)return n(t,r,"ltr",0);for(var i=!1,o=0;ot||t==r&&a.to==t)&&(n(Math.max(a.from,t),Math.min(a.to,r),1==a.level?"rtl":"ltr",o),i=!0)}i||n(t,r,"ltr")}var pe=null;function Ee(e,t,r){var n;pe=null;for(var i=0;it)return i;o.to==t&&(o.from!=o.to&&"before"==r?n=i:pe=i),o.from==t&&(o.from!=o.to&&"before"!=r?n=i:pe=i)}return null!=n?n:pe}var me=function(){var e="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",t="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function r(r){return r<=247?e.charAt(r):1424<=r&&r<=1524?"R":1536<=r&&r<=1785?t.charAt(r-1536):1774<=r&&r<=2220?"r":8192<=r&&r<=8203?"w":8204==r?"b":"L"}var n=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,o=/[LRr]/,a=/[Lb1n]/,s=/[1n]/;function l(e,t,r){this.level=e,this.from=t,this.to=r}return function(e,t){var c="ltr"==t?"L":"R";if(0==e.length||"ltr"==t&&!n.test(e))return!1;for(var u=e.length,d=[],f=0;f-1&&(n[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function Ne(e,t){var r=ye(e,t);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i0}function Le(e){e.prototype.on=function(e,t){Te(this,e,t)},e.prototype.off=function(e,t){Re(this,e,t)}}function Ie(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Ce(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function be(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function _e(e){Ie(e),Ce(e)}function we(e){return e.target||e.srcElement}function xe(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),T&&e.ctrlKey&&1==t&&(t=3),t}var Me,De,Pe=function(){if(a&&s<9)return!1;var e=_("div");return"draggable"in e||"dragDrop"in e}();function Ue(e){if(null==Me){var t=_("span","");b(e,_("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Me=t.offsetWidth<=1&&t.offsetHeight>2&&!(a&&s<8))}var r=Me?_("span",""):_("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return r.setAttribute("cm-text",""),r}function ke(e){if(null!=De)return De;var t=b(e,document.createTextNode("AخA")),r=L(t,0,1).getBoundingClientRect(),n=L(t,1,2).getBoundingClientRect();return C(e),!(!r||r.left==r.right)&&(De=n.right-r.right<3)}var Fe,He=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,r=[],n=e.length;t<=n;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),a=o.indexOf("\r");-1!=a?(r.push(o.slice(0,a)),t+=a+1):(r.push(o),t=i+1)}return r}:function(e){return e.split(/\r\n?|\n/)},We=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(e){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(e){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},Ge="oncopy"in(Fe=_("div"))||(Fe.setAttribute("oncopy","return;"),"function"==typeof Fe.oncopy),Be=null;function Ve(e){if(null!=Be)return Be;var t=b(e,_("span","x")),r=t.getBoundingClientRect(),n=L(t,0,1).getBoundingClientRect();return Be=Math.abs(r.left-n.left)>1}var Ye={},ze={};function Xe(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Ye[e]=t}function je(e,t){ze[e]=t}function Ke(e){if("string"==typeof e&&ze.hasOwnProperty(e))e=ze[e];else if(e&&"string"==typeof e.name&&ze.hasOwnProperty(e.name)){var t=ze[e.name];"string"==typeof t&&(t={name:t}),(e=ie(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ke("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ke("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function qe(e,t){t=Ke(t);var r=Ye[t.name];if(!r)return qe(e,"text/plain");var n=r(e,t);if(Je.hasOwnProperty(t.name)){var i=Je[t.name];for(var o in i)i.hasOwnProperty(o)&&(n.hasOwnProperty(o)&&(n["_"+o]=n[o]),n[o]=i[o])}if(n.name=t.name,t.helperType&&(n.helperType=t.helperType),t.modeProps)for(var a in t.modeProps)n[a]=t.modeProps[a];return n}var Je={};function Qe(e,t){B(t,Je.hasOwnProperty(e)?Je[e]:Je[e]={})}function Ze(e,t){if(!0===t)return t;if(e.copyState)return e.copyState(t);var r={};for(var n in t){var i=t[n];i instanceof Array&&(i=i.concat([])),r[n]=i}return r}function $e(e,t){for(var r;e.innerMode&&(r=e.innerMode(t))&&r.mode!=e;)t=r.state,e=r.mode;return r||{mode:e,state:t}}function et(e,t,r){return!e.startState||e.startState(t,r)}var tt=function(e,t,r){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=r};function rt(e,t){if((t-=e.first)<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var r=e;!r.lines;)for(var n=0;;++n){var i=r.children[n],o=i.chunkSize();if(t=e.first&&tr?ut(r,rt(e,r).text.length):vt(t,rt(e,t.line).text.length)}function vt(e,t){var r=e.ch;return null==r||r>t?ut(e.line,t):r<0?ut(e.line,0):e}function Tt(e,t){for(var r=[],n=0;n=this.string.length},tt.prototype.sol=function(){return this.pos==this.lineStart},tt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},tt.prototype.next=function(){if(this.post},tt.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},tt.prototype.skipToEnd=function(){this.pos=this.string.length},tt.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},tt.prototype.backUp=function(e){this.pos-=e},tt.prototype.column=function(){return this.lastColumnPos0?null:(n&&!1!==t&&(this.pos+=n[0].length),n)}var i=function(e){return r?e.toLowerCase():e};if(i(this.string.substr(this.pos,e.length))==i(e))return!1!==t&&(this.pos+=e.length),!0},tt.prototype.current=function(){return this.string.slice(this.start,this.pos)},tt.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},tt.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},tt.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var yt=function(e,t){this.state=e,this.lookAhead=t},Rt=function(e,t,r,n){this.state=t,this.doc=e,this.line=r,this.maxLookAhead=n||0,this.baseTokens=null,this.baseTokenPos=1};function Nt(e,t,r,n){var i=[e.state.modeGen],o={};wt(e,t.text,e.doc.mode,r,(function(e,t){return i.push(e,t)}),o,n);for(var a=r.state,s=function(n){r.baseTokens=i;var s=e.state.overlays[n],l=1,c=0;r.state=!0,wt(e,t.text,s.mode,r,(function(e,t){for(var r=l;ce&&i.splice(l,1,e,i[l+1],n),l+=2,c=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,l-r,e,"overlay "+t),l=r+2;else for(;re.options.maxHighlightLength&&Ze(e.doc.mode,n.state),o=Nt(e,t,n);i&&(n.state=i),t.stateAfter=n.save(!i),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),r===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function St(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return new Rt(n,!0,t);var o=xt(e,t,r),a=o>n.first&&rt(n,o-1).stateAfter,s=a?Rt.fromSaved(n,a,o):new Rt(n,et(n.mode),o);return n.iter(o,t,(function(r){Ot(e,r.text,s);var n=s.line;r.stateAfter=n==t-1||n%5==0||n>=i.viewFrom&&nt.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}Rt.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Rt.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},Rt.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Rt.fromSaved=function(e,t,r){return t instanceof yt?new Rt(e,Ze(e.mode,t.state),r,t.lookAhead):new Rt(e,Ze(e.mode,t),r)},Rt.prototype.save=function(e){var t=!1!==e?Ze(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new yt(t,this.maxLookAhead):t};var Ct=function(e,t,r){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=r};function bt(e,t,r,n){var i,o,a=e.doc,s=a.mode,l=rt(a,(t=gt(a,t)).line),c=St(e,t.line,r),u=new tt(l.text,e.options.tabSize,c);for(n&&(o=[]);(n||u.pose.options.maxHighlightLength?(s=!1,a&&Ot(e,t,n,d.pos),d.pos=t.length,l=null):l=_t(It(r,d,n.state,f),o),f){var h=f[0].name;h&&(l="m-"+(l?h+" "+l:h))}if(!s||u!=l){for(;ca;--s){if(s<=o.first)return o.first;var l=rt(o,s-1),c=l.stateAfter;if(c&&(!r||s+(c instanceof yt?c.lookAhead:0)<=o.modeFrontier))return s;var u=V(l.text,null,e.options.tabSize);(null==i||n>u)&&(i=s-1,n=u)}return i}function Mt(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontierr;n--){var i=rt(e,n).stateAfter;if(i&&(!(i instanceof yt)||n+i.lookAhead=t:o.to>t);(n||(n=[])).push(new Ft(a,o.from,s?null:o.to))}}return n}function Vt(e,t,r){var n;if(e)for(var i=0;i=t:o.to>t)||o.from==t&&"bookmark"==a.type&&(!r||o.marker.insertLeft)){var s=null==o.from||(a.inclusiveLeft?o.from<=t:o.from0&&s)for(var T=0;T0)){var u=[l,1],d=dt(c.from,s.from),f=dt(c.to,s.to);(d<0||!a.inclusiveLeft&&!d)&&u.push({from:c.from,to:s.from}),(f>0||!a.inclusiveRight&&!f)&&u.push({from:s.to,to:c.to}),i.splice.apply(i,u),l+=u.length-3}}return i}function jt(e){var t=e.markedSpans;if(t){for(var r=0;rt)&&(!r||Qt(r,o.marker)<0)&&(r=o.marker)}return r}function rr(e,t,r,n,i){var o=rt(e,t),a=Pt&&o.markedSpans;if(a)for(var s=0;s=0&&d<=0||u<=0&&d>=0)&&(u<=0&&(l.marker.inclusiveRight&&i.inclusiveLeft?dt(c.to,r)>=0:dt(c.to,r)>0)||u>=0&&(l.marker.inclusiveRight&&i.inclusiveLeft?dt(c.from,n)<=0:dt(c.from,n)<0)))return!0}}}function nr(e){for(var t;t=$t(e);)e=t.find(-1,!0).line;return e}function ir(e){for(var t;t=er(e);)e=t.find(1,!0).line;return e}function or(e){for(var t,r;t=er(e);)e=t.find(1,!0).line,(r||(r=[])).push(e);return r}function ar(e,t){var r=rt(e,t),n=nr(r);return r==n?t:at(n)}function sr(e,t){if(t>e.lastLine())return t;var r,n=rt(e,t);if(!lr(e,n))return t;for(;r=er(n);)n=r.find(1,!0).line;return at(n)+1}function lr(e,t){var r=Pt&&t.markedSpans;if(r)for(var n=void 0,i=0;it.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)}))}var hr=function(e,t,r){this.text=e,Kt(this,t),this.height=r?r(this):1};function pr(e,t,r,n){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),jt(e),Kt(e,r);var i=n?n(e):1;i!=e.height&&ot(e,i)}function Er(e){e.parent=null,jt(e)}hr.prototype.lineNo=function(){return at(this)},Le(hr);var mr={},gr={};function vr(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?gr:mr;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function Tr(e,t){var r=w("span",null,null,l?"padding-right: .1px":null),n={pre:w("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o=i?t.rest[i-1]:t.line,a=void 0;n.pos=0,n.addToken=Rr,ke(e.display.measure)&&(a=ge(o,e.doc.direction))&&(n.addToken=Ar(n.addToken,a)),n.map=[],Or(o,n,At(e,o,t!=e.display.externalMeasured&&at(o))),o.styleClasses&&(o.styleClasses.bgClass&&(n.bgClass=P(o.styleClasses.bgClass,n.bgClass||"")),o.styleClasses.textClass&&(n.textClass=P(o.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Ue(e.display.measure))),0==i?(t.measure.map=n.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(n.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(l){var s=n.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(n.content.className="cm-tab-wrap-hack")}return Ne(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=P(n.pre.className,n.textClass||"")),n}function yr(e){var t=_("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Rr(e,t,r,n,i,o,l){if(t){var c,u=e.splitSpaces?Nr(t,e.trailingSpace):t,d=e.cm.state.specialChars,f=!1;if(d.test(t)){c=document.createDocumentFragment();for(var h=0;;){d.lastIndex=h;var p=d.exec(t),E=p?p.index-h:t.length-h;if(E){var m=document.createTextNode(u.slice(h,h+E));a&&s<9?c.appendChild(_("span",[m])):c.appendChild(m),e.map.push(e.pos,e.pos+E,m),e.col+=E,e.pos+=E}if(!p)break;h+=E+1;var g=void 0;if("\t"==p[0]){var v=e.cm.options.tabSize,T=v-e.col%v;(g=c.appendChild(_("span",$(T),"cm-tab"))).setAttribute("role","presentation"),g.setAttribute("cm-text","\t"),e.col+=T}else"\r"==p[0]||"\n"==p[0]?((g=c.appendChild(_("span","\r"==p[0]?"␍":"","cm-invalidchar"))).setAttribute("cm-text",p[0]),e.col+=1):((g=e.cm.options.specialCharPlaceholder(p[0])).setAttribute("cm-text",p[0]),a&&s<9?c.appendChild(_("span",[g])):c.appendChild(g),e.col+=1);e.map.push(e.pos,e.pos+1,g),e.pos++}}else e.col+=t.length,c=document.createTextNode(u),e.map.push(e.pos,e.pos+t.length,c),a&&s<9&&(f=!0),e.pos+=t.length;if(e.trailingSpace=32==u.charCodeAt(t.length-1),r||n||i||f||o||l){var y=r||"";n&&(y+=n),i&&(y+=i);var R=_("span",[c],y,o);if(l)for(var N in l)l.hasOwnProperty(N)&&"style"!=N&&"class"!=N&&R.setAttribute(N,l[N]);return e.content.appendChild(R)}e.content.appendChild(c)}}function Nr(e,t){if(e.length>1&&!/ /.test(e))return e;for(var r=t,n="",i=0;ic&&d.from<=c);f++);if(d.to>=u)return e(r,n,i,o,a,s,l);e(r,n.slice(0,d.to-c),i,o,null,s,l),o=null,n=n.slice(d.to-c),c=d.to}}}function Sr(e,t,r,n){var i=!n&&r.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!n&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",r.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function Or(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(n)for(var a,s,l,c,u,d,f,h=i.length,p=0,E=1,m="",g=0;;){if(g==p){l=c=u=s="",f=null,d=null,g=1/0;for(var v=[],T=void 0,y=0;yp||N.collapsed&&R.to==p&&R.from==p)){if(null!=R.to&&R.to!=p&&g>R.to&&(g=R.to,c=""),N.className&&(l+=" "+N.className),N.css&&(s=(s?s+";":"")+N.css),N.startStyle&&R.from==p&&(u+=" "+N.startStyle),N.endStyle&&R.to==g&&(T||(T=[])).push(N.endStyle,R.to),N.title&&((f||(f={})).title=N.title),N.attributes)for(var A in N.attributes)(f||(f={}))[A]=N.attributes[A];N.collapsed&&(!d||Qt(d.marker,N)<0)&&(d=R)}else R.from>p&&g>R.from&&(g=R.from)}if(T)for(var S=0;S=h)break;for(var L=Math.min(h,g);;){if(m){var I=p+m.length;if(!d){var C=I>L?m.slice(0,L-p):m;t.addToken(t,C,a?a+l:l,u,p+C.length==g?c:"",s,f)}if(I>=L){m=m.slice(L-p),p=L;break}p=I,u=""}m=i.slice(o,o=r[E++]),a=vr(r[E++],t.cm.options)}}else for(var b=1;b2&&o.push((l.bottom+c.top)/2-r.top)}}o.push(r.bottom-r.top)}}function rn(e,t,r){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};if(e.rest){for(var n=0;nr)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}}function nn(e,t){var r=at(t=nr(t)),n=e.display.externalMeasured=new Lr(e.doc,t,r);n.lineN=r;var i=n.built=Tr(e,n);return n.text=i.pre,b(e.display.lineMeasure,i.pre),n}function on(e,t,r,n){return ln(e,sn(e,t),r,n)}function an(e,t){if(t>=e.display.viewFrom&&t=r.lineN&&tt)&&(i=(o=l-s)-1,t>=l&&(a="right")),null!=i){if(n=e[c+2],s==l&&r==(n.insertLeft?"left":"right")&&(a=r),"left"==r&&0==i)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)n=e[2+(c-=3)],a="left";if("right"==r&&i==l-s)for(;c=0&&(r=e[i]).left==r.right;i--);return r}function hn(e,t,r,n){var i,o=dn(t.map,r,n),l=o.node,c=o.start,u=o.end,d=o.collapse;if(3==l.nodeType){for(var f=0;f<4;f++){for(;c&&ue(t.line.text.charAt(o.coverStart+c));)--c;for(;o.coverStart+u0&&(d=n="right"),i=e.options.lineWrapping&&(h=l.getClientRects()).length>1?h["right"==n?h.length-1:0]:l.getBoundingClientRect()}if(a&&s<9&&!c&&(!i||!i.left&&!i.right)){var p=l.parentNode.getClientRects()[0];i=p?{left:p.left,right:p.left+Pn(e.display),top:p.top,bottom:p.bottom}:un}for(var E=i.top-t.rect.top,m=i.bottom-t.rect.top,g=(E+m)/2,v=t.view.measure.heights,T=0;T=n.text.length?(l=n.text.length,c="before"):l<=0&&(l=0,c="after"),!s)return a("before"==c?l-1:l,"before"==c);function u(e,t,r){return a(r?e-1:e,1==s[t].level!=r)}var d=Ee(s,l,c),f=pe,h=u(l,d,"before"==c);return null!=f&&(h.other=u(l,f,"before"!=c)),h}function On(e,t){var r=0;t=gt(e.doc,t),e.options.lineWrapping||(r=Pn(e.display)*t.ch);var n=rt(e.doc,t.line),i=ur(n)+qr(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function Ln(e,t,r,n,i){var o=ut(e,t,r);return o.xRel=i,n&&(o.outside=n),o}function In(e,t,r){var n=e.doc;if((r+=e.display.viewOffset)<0)return Ln(n.first,0,null,-1,-1);var i=st(n,r),o=n.first+n.size-1;if(i>o)return Ln(n.first+n.size-1,rt(n,o).text.length,null,1,1);t<0&&(t=0);for(var a=rt(n,i);;){var s=wn(e,a,i,t,r),l=tr(a,s.ch+(s.xRel>0||s.outside>0?1:0));if(!l)return s;var c=l.find(1);if(c.line==i)return c;a=rt(n,i=c.line)}}function Cn(e,t,r,n){n-=yn(t);var i=t.text.length,o=fe((function(t){return ln(e,r,t-1).bottom<=n}),i,0);return{begin:o,end:i=fe((function(t){return ln(e,r,t).top>n}),o,i)}}function bn(e,t,r,n){return r||(r=sn(e,t)),Cn(e,t,r,Rn(e,t,ln(e,r,n),"line").top)}function _n(e,t,r,n){return!(e.bottom<=r)&&(e.top>r||(n?e.left:e.right)>t)}function wn(e,t,r,n,i){i-=ur(t);var o=sn(e,t),a=yn(t),s=0,l=t.text.length,c=!0,u=ge(t,e.doc.direction);if(u){var d=(e.options.lineWrapping?Mn:xn)(e,t,r,o,u,n,i);s=(c=1!=d.level)?d.from:d.to-1,l=c?d.to:d.from-1}var f,h,p=null,E=null,m=fe((function(t){var r=ln(e,o,t);return r.top+=a,r.bottom+=a,!!_n(r,n,i,!1)&&(r.top<=i&&r.left<=n&&(p=t,E=r),!0)}),s,l),g=!1;if(E){var v=n-E.left=y.bottom?1:0}return Ln(r,m=de(t.text,m,1),h,g,n-f)}function xn(e,t,r,n,i,o,a){var s=fe((function(s){var l=i[s],c=1!=l.level;return _n(Sn(e,ut(r,c?l.to:l.from,c?"before":"after"),"line",t,n),o,a,!0)}),0,i.length-1),l=i[s];if(s>0){var c=1!=l.level,u=Sn(e,ut(r,c?l.from:l.to,c?"after":"before"),"line",t,n);_n(u,o,a,!0)&&u.top>a&&(l=i[s-1])}return l}function Mn(e,t,r,n,i,o,a){var s=Cn(e,t,n,a),l=s.begin,c=s.end;/\s/.test(t.text.charAt(c-1))&&c--;for(var u=null,d=null,f=0;f=c||h.to<=l)){var p=ln(e,n,1!=h.level?Math.min(c,h.to)-1:Math.max(l,h.from)).right,E=pE)&&(u=h,d=E)}}return u||(u=i[i.length-1]),u.fromc&&(u={from:u.from,to:c,level:u.level}),u}function Dn(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==cn){cn=_("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)cn.appendChild(document.createTextNode("x")),cn.appendChild(_("br"));cn.appendChild(document.createTextNode("x"))}b(e.measure,cn);var r=cn.offsetHeight/50;return r>3&&(e.cachedTextHeight=r),C(e.measure),r||1}function Pn(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=_("span","xxxxxxxxxx"),r=_("pre",[t],"CodeMirror-line-like");b(e.measure,r);var n=t.getBoundingClientRect(),i=(n.right-n.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function Un(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,a=0;o;o=o.nextSibling,++a){var s=e.display.gutterSpecs[a].className;r[s]=o.offsetLeft+o.clientLeft+i,n[s]=o.clientWidth}return{fixedPos:kn(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function kn(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function Fn(e){var t=Dn(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/Pn(e.display)-3);return function(i){if(lr(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;a0&&(l=rt(e.doc,c.line).text).length==c.ch){var u=V(l,l.length,e.options.tabSize)-l.length;c=ut(c.line,Math.max(0,Math.round((o-Qr(e.display).left)/Pn(e.display))-u))}return c}function Gn(e,t){if(t>=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var r=e.display.view,n=0;nt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Pt&&ar(e.doc,t)i.viewFrom?Yn(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)Yn(e);else if(t<=i.viewFrom){var o=zn(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):Yn(e)}else if(r>=i.viewTo){var a=zn(e,t,t,-1);a?(i.view=i.view.slice(0,a.index),i.viewTo=a.lineN):Yn(e)}else{var s=zn(e,t,t,-1),l=zn(e,r,r+n,1);s&&l?(i.view=i.view.slice(0,s.index).concat(Ir(e,s.lineN,l.lineN)).concat(i.view.slice(l.index)),i.viewTo+=n):Yn(e)}var c=i.externalMeasured;c&&(r=i.lineN&&t=n.viewTo)){var o=n.view[Gn(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==z(a,r)&&a.push(r)}}}function Yn(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function zn(e,t,r,n){var i,o=Gn(e,t),a=e.display.view;if(!Pt||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=e.display.viewFrom,l=0;l0){if(o==a.length-1)return null;i=s+a[o].size-t,o++}else i=s-t;t+=i,r+=i}for(;ar(e.doc,r)!=r;){if(o==(n<0?0:a.length-1))return null;r+=n*a[o-(n<0?1:0)].size,o+=n}return{index:o,lineN:r}}function Xn(e,t,r){var n=e.display;0==n.view.length||t>=n.viewTo||r<=n.viewFrom?(n.view=Ir(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=Ir(e,t,n.viewFrom).concat(n.view):n.viewFromr&&(n.view=n.view.slice(0,Gn(e,r)))),n.viewTo=r}function jn(e){for(var t=e.display.view,r=0,n=0;n=e.display.viewTo||l.to().line0?a:e.defaultCharWidth())+"px"}if(n.other){var s=r.appendChild(_("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));s.style.display="",s.style.left=n.other.left+"px",s.style.top=n.other.top+"px",s.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function Qn(e,t){return e.top-t.top||e.left-t.left}function Zn(e,t,r){var n=e.display,i=e.doc,o=document.createDocumentFragment(),a=Qr(e.display),s=a.left,l=Math.max(n.sizerWidth,$r(e)-n.sizer.offsetLeft)-a.right,c="ltr"==i.direction;function u(e,t,r,n){t<0&&(t=0),t=Math.round(t),n=Math.round(n),o.appendChild(_("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(null==r?l-e:r)+"px;\n height: "+(n-t)+"px"))}function d(t,r,n){var o,a,d=rt(i,t),f=d.text.length;function h(r,n){return An(e,ut(t,r),"div",d,n)}function p(t,r,n){var i=bn(e,d,null,t),o="ltr"==r==("after"==n)?"left":"right";return h("after"==n?i.begin:i.end-(/\s/.test(d.text.charAt(i.end-1))?2:1),o)[o]}var E=ge(d,i.direction);return he(E,r||0,null==n?f:n,(function(e,t,i,d){var m="ltr"==i,g=h(e,m?"left":"right"),v=h(t-1,m?"right":"left"),T=null==r&&0==e,y=null==n&&t==f,R=0==d,N=!E||d==E.length-1;if(v.top-g.top<=3){var A=(c?y:T)&&N,S=(c?T:y)&&R?s:(m?g:v).left,O=A?l:(m?v:g).right;u(S,g.top,O-S,g.bottom)}else{var L,I,C,b;m?(L=c&&T&&R?s:g.left,I=c?l:p(e,i,"before"),C=c?s:p(t,i,"after"),b=c&&y&&N?l:v.right):(L=c?p(e,i,"before"):s,I=!c&&T&&R?l:g.right,C=!c&&y&&N?s:v.left,b=c?p(t,i,"after"):l),u(L,g.top,I-L,g.bottom),g.bottom0?t.blinker=setInterval((function(){e.hasFocus()||ni(e),t.cursorDiv.style.visibility=(r=!r)?"":"hidden"}),e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function ei(e){e.hasFocus()||(e.display.input.focus(),e.state.focused||ri(e))}function ti(e){e.state.delayingBlurEvent=!0,setTimeout((function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,e.state.focused&&ni(e))}),100)}function ri(e,t){e.state.delayingBlurEvent&&!e.state.draggingText&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Ne(e,"focus",e,t),e.state.focused=!0,D(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),l&&setTimeout((function(){return e.display.input.reset(!0)}),20)),e.display.input.receivedFocus()),$n(e))}function ni(e,t){e.state.delayingBlurEvent||(e.state.focused&&(Ne(e,"blur",e,t),e.state.focused=!1,I(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout((function(){e.state.focused||(e.display.shift=!1)}),150))}function ii(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=Math.max(0,t.scroller.getBoundingClientRect().top),i=t.lineDiv.getBoundingClientRect().top,o=0,l=0;l.005||E<-.005)&&(ie.display.sizerWidth){var g=Math.ceil(f/Pn(e.display));g>e.display.maxLineLength&&(e.display.maxLineLength=g,e.display.maxLine=c.line,e.display.maxLineChanged=!0)}}}Math.abs(o)>2&&(t.scroller.scrollTop+=o)}function oi(e){if(e.widgets)for(var t=0;t=a&&(o=st(t,ur(rt(t,l))-e.wrapper.clientHeight),a=l)}return{from:o,to:Math.max(a,o+1)}}function si(e,t){if(!Ae(e,"scrollCursorIntoView")){var r=e.display,n=r.sizer.getBoundingClientRect(),i=null,o=r.wrapper.ownerDocument;if(t.top+n.top<0?i=!0:t.bottom+n.top>(o.defaultView.innerHeight||o.documentElement.clientHeight)&&(i=!1),null!=i&&!E){var a=_("div","",null,"position: absolute;\n top: "+(t.top-r.viewOffset-qr(e.display))+"px;\n height: "+(t.bottom-t.top+Zr(e)+r.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(a),a.scrollIntoView(i),e.display.lineSpace.removeChild(a)}}}function li(e,t,r,n){var i;null==n&&(n=0),e.options.lineWrapping||t!=r||(r="before"==t.sticky?ut(t.line,t.ch+1,"before"):t,t=t.ch?ut(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t);for(var o=0;o<5;o++){var a=!1,s=Sn(e,t),l=r&&r!=t?Sn(e,r):s,c=ui(e,i={left:Math.min(s.left,l.left),top:Math.min(s.top,l.top)-n,right:Math.max(s.left,l.left),bottom:Math.max(s.bottom,l.bottom)+n}),u=e.doc.scrollTop,d=e.doc.scrollLeft;if(null!=c.scrollTop&&(gi(e,c.scrollTop),Math.abs(e.doc.scrollTop-u)>1&&(a=!0)),null!=c.scrollLeft&&(Ti(e,c.scrollLeft),Math.abs(e.doc.scrollLeft-d)>1&&(a=!0)),!a)break}return i}function ci(e,t){var r=ui(e,t);null!=r.scrollTop&&gi(e,r.scrollTop),null!=r.scrollLeft&&Ti(e,r.scrollLeft)}function ui(e,t){var r=e.display,n=Dn(e.display);t.top<0&&(t.top=0);var i=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:r.scroller.scrollTop,o=en(e),a={};t.bottom-t.top>o&&(t.bottom=t.top+o);var s=e.doc.height+Jr(r),l=t.tops-n;if(t.topi+o){var u=Math.min(t.top,(c?s:t.bottom)-o);u!=i&&(a.scrollTop=u)}var d=e.options.fixedGutter?0:r.gutters.offsetWidth,f=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:r.scroller.scrollLeft-d,h=$r(e)-r.gutters.offsetWidth,p=t.right-t.left>h;return p&&(t.right=t.left+h),t.left<10?a.scrollLeft=0:t.lefth+f-3&&(a.scrollLeft=t.right+(p?0:10)-h),a}function di(e,t){null!=t&&(Ei(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function fi(e){Ei(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function hi(e,t,r){null==t&&null==r||Ei(e),null!=t&&(e.curOp.scrollLeft=t),null!=r&&(e.curOp.scrollTop=r)}function pi(e,t){Ei(e),e.curOp.scrollToPos=t}function Ei(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,mi(e,On(e,t.from),On(e,t.to),t.margin))}function mi(e,t,r,n){var i=ui(e,{left:Math.min(t.left,r.left),top:Math.min(t.top,r.top)-n,right:Math.max(t.right,r.right),bottom:Math.max(t.bottom,r.bottom)+n});hi(e,i.scrollLeft,i.scrollTop)}function gi(e,t){Math.abs(e.doc.scrollTop-t)<2||(r||Ki(e,{top:t}),vi(e,t,!0),r&&Ki(e),Wi(e,100))}function vi(e,t,r){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),(e.display.scroller.scrollTop!=t||r)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function Ti(e,t,r,n){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(r?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!n||(e.doc.scrollLeft=t,Zi(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function yi(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+Jr(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?r:0,docHeight:n,scrollHeight:n+Zr(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}var Ri=function(e,t,r){this.cm=r;var n=this.vert=_("div",[_("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=_("div",[_("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");n.tabIndex=i.tabIndex=-1,e(n),e(i),Te(n,"scroll",(function(){n.clientHeight&&t(n.scrollTop,"vertical")})),Te(i,"scroll",(function(){i.clientWidth&&t(i.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,a&&s<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Ri.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,r=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(r){this.vert.style.display="block",this.vert.style.bottom=t?n+"px":"0";var i=e.viewHeight-(t?n: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=r?n+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(r?n: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==n&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:r?n:0,bottom:t?n:0}},Ri.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Ri.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Ri.prototype.zeroWidthHack=function(){var e=T&&!p?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.visibility=this.vert.style.visibility="hidden",this.disableHoriz=new Y,this.disableVert=new Y},Ri.prototype.enableZeroWidthBar=function(e,t,r){function n(){var i=e.getBoundingClientRect();("vert"==r?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,n)}e.style.visibility="",t.set(1e3,n)},Ri.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var Ni=function(){};function Ai(e,t){t||(t=yi(e));var r=e.display.barWidth,n=e.display.barHeight;Si(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&ii(e),Si(e,yi(e)),r=e.display.barWidth,n=e.display.barHeight}function Si(e,t){var r=e.display,n=r.scrollbars.update(t);r.sizer.style.paddingRight=(r.barWidth=n.right)+"px",r.sizer.style.paddingBottom=(r.barHeight=n.bottom)+"px",r.heightForcer.style.borderBottom=n.bottom+"px solid transparent",n.right&&n.bottom?(r.scrollbarFiller.style.display="block",r.scrollbarFiller.style.height=n.bottom+"px",r.scrollbarFiller.style.width=n.right+"px"):r.scrollbarFiller.style.display="",n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(r.gutterFiller.style.display="block",r.gutterFiller.style.height=n.bottom+"px",r.gutterFiller.style.width=t.gutterWidth+"px"):r.gutterFiller.style.display=""}Ni.prototype.update=function(){return{bottom:0,right:0}},Ni.prototype.setScrollLeft=function(){},Ni.prototype.setScrollTop=function(){},Ni.prototype.clear=function(){};var Oi={native:Ri,null:Ni};function Li(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&I(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Oi[e.options.scrollbarStyle]((function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Te(t,"mousedown",(function(){e.state.focused&&setTimeout((function(){return e.display.input.focus()}),0)})),t.setAttribute("cm-not-content","true")}),(function(t,r){"horizontal"==r?Ti(e,t):gi(e,t)}),e),e.display.scrollbars.addClass&&D(e.display.wrapper,e.display.scrollbars.addClass)}var Ii=0;function Ci(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:++Ii,markArrays:null},br(e.curOp)}function bi(e){var t=e.curOp;t&&wr(t,(function(e){for(var t=0;t=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Bi(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function xi(e){e.updatedDisplay=e.mustUpdate&&Xi(e.cm,e.update)}function Mi(e){var t=e.cm,r=t.display;e.updatedDisplay&&ii(t),e.barMeasure=yi(t),r.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=on(t,r.maxLine,r.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(r.scroller.clientWidth,r.sizer.offsetLeft+e.adjustWidthTo+Zr(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,r.sizer.offsetLeft+e.adjustWidthTo-$r(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=r.input.prepareSelection())}function Di(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft=e.display.viewTo)){var r=+new Date+e.options.workTime,n=St(e,t.highlightFrontier),i=[];t.iter(n.line,Math.min(t.first+t.size,e.display.viewTo+500),(function(o){if(n.line>=e.display.viewFrom){var a=o.styles,s=o.text.length>e.options.maxHighlightLength?Ze(t.mode,n.state):null,l=Nt(e,o,n,!0);s&&(n.state=s),o.styles=l.styles;var c=o.styleClasses,u=l.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var d=!a||a.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),f=0;!d&&fr)return Wi(e,e.options.workDelay),!0})),t.highlightFrontier=n.line,t.modeFrontier=Math.max(t.modeFrontier,n.line),i.length&&Ui(e,(function(){for(var t=0;t=r.viewFrom&&t.visible.to<=r.viewTo&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo)&&r.renderedView==r.view&&0==jn(e))return!1;$i(e)&&(Yn(e),t.dims=Un(e));var i=n.first+n.size,o=Math.max(t.visible.from-e.options.viewportMargin,n.first),a=Math.min(i,t.visible.to+e.options.viewportMargin);r.viewFroma&&r.viewTo-a<20&&(a=Math.min(i,r.viewTo)),Pt&&(o=ar(e.doc,o),a=sr(e.doc,a));var s=o!=r.viewFrom||a!=r.viewTo||r.lastWrapHeight!=t.wrapperHeight||r.lastWrapWidth!=t.wrapperWidth;Xn(e,o,a),r.viewOffset=ur(rt(e.doc,r.viewFrom)),e.display.mover.style.top=r.viewOffset+"px";var l=jn(e);if(!s&&0==l&&!t.force&&r.renderedView==r.view&&(null==r.updateLineNumbers||r.updateLineNumbers>=r.viewTo))return!1;var c=Yi(e);return l>4&&(r.lineDiv.style.display="none"),qi(e,r.updateLineNumbers,t.dims),l>4&&(r.lineDiv.style.display=""),r.renderedView=r.view,zi(c),C(r.cursorDiv),C(r.selectionDiv),r.gutters.style.height=r.sizer.style.minHeight=0,s&&(r.lastWrapHeight=t.wrapperHeight,r.lastWrapWidth=t.wrapperWidth,Wi(e,400)),r.updateLineNumbers=null,!0}function ji(e,t){for(var r=t.viewport,n=!0;;n=!1){if(n&&e.options.lineWrapping&&t.oldDisplayWidth!=$r(e))n&&(t.visible=ai(e.display,e.doc,r));else if(r&&null!=r.top&&(r={top:Math.min(e.doc.height+Jr(e.display)-en(e),r.top)}),t.visible=ai(e.display,e.doc,r),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!Xi(e,t))break;ii(e);var i=yi(e);Kn(e),Ai(e,i),Qi(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 r=new Bi(e,t);if(Xi(e,r)){ii(e),ji(e,r);var n=yi(e);Kn(e),Ai(e,n),Qi(e,n),r.finish()}}function qi(e,t,r){var n=e.display,i=e.options.lineNumbers,o=n.lineDiv,a=o.firstChild;function s(t){var r=t.nextSibling;return l&&T&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}for(var c=n.view,u=n.viewFrom,d=0;d-1&&(h=!1),Pr(e,f,u,r)),h&&(C(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(ct(e.options,u)))),a=f.node.nextSibling}else{var p=Vr(e,f,u,r);o.insertBefore(p,a)}u+=f.size}for(;a;)a=s(a)}function Ji(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",Mr(e,"gutterChanged",e)}function Qi(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+Zr(e)+"px"}function Zi(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=kn(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"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||r&&v||(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),n.init(o)}Bi.prototype.signal=function(e,t){Oe(e,t)&&this.events.push(arguments)},Bi.prototype.finish=function(){for(var e=0;ec.clientWidth,p=c.scrollHeight>c.clientHeight;if(i&&h||o&&p){if(o&&T&&l)e:for(var E=t.target,m=s.view;E!=c;E=E.parentNode)for(var g=0;g=0&&dt(e,n.to())<=0)return r}return-1};var uo=function(e,t){this.anchor=e,this.head=t};function fo(e,t,r){var n=e&&e.options.selectionsMayTouch,i=t[r];t.sort((function(e,t){return dt(e.from(),t.from())})),r=z(t,i);for(var o=1;o0:l>=0){var c=Et(s.from(),a.from()),u=pt(s.to(),a.to()),d=s.empty()?a.from()==a.head:s.from()==s.head;o<=r&&--r,t.splice(--o,2,new uo(d?u:c,d?c:u))}}return new co(t,r)}function ho(e,t){return new co([new uo(e,t||e)],0)}function po(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 Eo(e,t){if(dt(e,t.from)<0)return e;if(dt(e,t.to)<=0)return po(t);var r=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;return e.line==t.to.line&&(n+=po(t).ch-t.to.ch),ut(r,n)}function mo(e,t){for(var r=[],n=0;n1&&e.remove(s.line+1,p-1),e.insert(s.line+1,g)}Mr(e,"change",e,t)}function Ao(e,t,r){function n(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 wo(e,t,r,n){var i=e.history;i.undone.length=0;var o,a,s=+new Date;if((i.lastOp==n||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=_o(i,i.lastOp==n)))a=ee(o.changes),0==dt(t.from,t.to)&&0==dt(t.from,a.to)?a.to=po(t):o.changes.push(Co(e,t));else{var l=ee(i.done);for(l&&l.ranges||Do(e.sel,i.done),o={changes:[Co(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(r),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=s,i.lastOp=i.lastSelOp=n,i.lastOrigin=i.lastSelOrigin=t.origin,a||Ne(e,"historyAdded")}function xo(e,t,r,n){var i=t.charAt(0);return"*"==i||"+"==i&&r.ranges.length==n.ranges.length&&r.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function Mo(e,t,r,n){var i=e.history,o=n&&n.origin;r==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||xo(e,o,ee(i.done),t))?i.done[i.done.length-1]=t:Do(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&!1!==n.clearRedo&&bo(i.undone)}function Do(e,t){var r=ee(t);r&&r.ranges&&r.equals(e)||t.push(e)}function Po(e,t,r,n){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,r),Math.min(e.first+e.size,n),(function(r){r.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=r.markedSpans),++o}))}function Uo(e){if(!e)return null;for(var t,r=0;r-1&&(ee(s)[d]=c[d],delete c[d])}}}return n}function Wo(e,t,r,n){if(n){var i=e.anchor;if(r){var o=dt(t,i)<0;o!=dt(r,i)<0?(i=t,t=r):o!=dt(t,r)<0&&(t=r)}return new uo(i,t)}return new uo(r||t,t)}function Go(e,t,r,n,i){null==i&&(i=e.cm&&(e.cm.display.shift||e.extend)),jo(e,new co([Wo(e.sel.primary(),t,r,i)],0),n)}function Bo(e,t,r){for(var n=[],i=e.cm&&(e.cm.display.shift||e.extend),o=0;o=t.ch:s.to>t.ch))){if(i&&(Ne(l,"beforeCursorEnter"),l.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!l.atomic)continue;if(r){var d=l.find(n<0?1:-1),f=void 0;if((n<0?u:c)&&(d=ea(e,d,-n,d&&d.line==t.line?o:null)),d&&d.line==t.line&&(f=dt(d,r))&&(n<0?f<0:f>0))return Zo(e,d,t,n,i)}var h=l.find(n<0?-1:1);return(n<0?c:u)&&(h=ea(e,h,n,h.line==t.line?o:null)),h?Zo(e,h,t,n,i):null}}return t}function $o(e,t,r,n,i){var o=n||1,a=Zo(e,t,r,o,i)||!i&&Zo(e,t,r,o,!0)||Zo(e,t,r,-o,i)||!i&&Zo(e,t,r,-o,!0);return a||(e.cantEdit=!0,ut(e.first,0))}function ea(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?gt(e,ut(t.line-1)):null:r>0&&t.ch==(n||rt(e,t.line)).text.length?t.line=0;--i)ia(e,{from:n[i].from,to:n[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!=dt(t.from,t.to)){var r=mo(e,t);wo(e,t,r,e.cm?e.cm.curOp.id:NaN),sa(e,t,r,Yt(e,t));var n=[];Ao(e,(function(e,r){r||-1!=z(n,e.history)||(fa(e.history,t),n.push(e.history)),sa(e,t,null,Yt(e,t))}))}}function oa(e,t,r){var n=e.cm&&e.cm.state.suppressEdits;if(!n||r){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;--h){var p=f(h);if(p)return p.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)){Bn(e.cm,e.first,e.first-t,t);for(var r=e.cm.display,n=r.viewFrom;ne.lastLine())){if(t.from.lineo&&(t={from:t.from,to:ut(o,rt(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=nt(e,t.from,t.to),r||(r=mo(e,t)),e.cm?la(e.cm,t,n):No(e,t,n),Ko(e,r,K),e.cantEdit&&$o(e,ut(e.firstLine(),0))&&(e.cantEdit=!1)}}function la(e,t,r){var n=e.doc,i=e.display,o=t.from,a=t.to,s=!1,l=o.line;e.options.lineWrapping||(l=at(nr(rt(n,o.line))),n.iter(l,a.line+1,(function(e){if(e==i.maxLine)return s=!0,!0}))),n.sel.contains(t.from,t.to)>-1&&Se(e),No(n,t,r,Fn(e)),e.options.lineWrapping||(n.iter(l,o.line+t.text.length,(function(e){var t=dr(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)})),s&&(e.curOp.updateMaxLine=!0)),Mt(n,o.line),Wi(e,400);var c=t.text.length-(a.line-o.line)-1;t.full?Bn(e):o.line!=a.line||1!=t.text.length||Ro(e.doc,t)?Bn(e,o.line,a.line+1,c):Vn(e,o.line,"text");var u=Oe(e,"changes"),d=Oe(e,"change");if(d||u){var f={from:o,to:a,text:t.text,removed:t.removed,origin:t.origin};d&&Mr(e,"change",e,f),u&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(f)}e.display.selForContextMenu=null}function ca(e,t,r,n,i){var o;n||(n=r),dt(n,r)<0&&(r=(o=[n,r])[0],n=o[1]),"string"==typeof t&&(t=e.splitLines(t)),na(e,{from:r,to:n,text:t,origin:i})}function ua(e,t,r,n){r1||!(this.children[0]instanceof pa))){var s=[];this.collapse(s),this.children=[new pa(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,r){for(var n=0;n0||0==a&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=w("span",[o.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(rr(e,t.line,t,r,o)||t.line!=r.line&&rr(e,r.line,t,r,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");kt()}o.addToHistory&&wo(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var s,l=t.line,c=e.cm;if(e.iter(l,r.line+1,(function(n){c&&o.collapsed&&!c.options.lineWrapping&&nr(n)==c.display.maxLine&&(s=!0),o.collapsed&&l!=t.line&&ot(n,0),Gt(n,new Ft(o,l==t.line?t.ch:null,l==r.line?r.ch:null),e.cm&&e.cm.curOp),++l})),o.collapsed&&e.iter(t.line,r.line+1,(function(t){lr(e,t)&&ot(t,0)})),o.clearOnEnter&&Te(o,"beforeCursorEnter",(function(){return o.clear()})),o.readOnly&&(Ut(),(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++Ta,o.atomic=!0),c){if(s&&(c.curOp.updateMaxLine=!0),o.collapsed)Bn(c,t.line,r.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(var u=t.line;u<=r.line;u++)Vn(c,u,"text");o.atomic&&Jo(c.doc),Mr(c,"markerAdded",c,o)}return o}ya.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&Ci(e),Oe(this,"clear")){var r=this.find();r&&Mr(this,"clear",r.from,r.to)}for(var n=null,i=null,o=0;oe.display.maxLineLength&&(e.display.maxLine=c,e.display.maxLineLength=u,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&Bn(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Jo(e.doc)),e&&Mr(e,"markerCleared",e,this,n,i),t&&bi(e),this.parent&&this.parent.clear()}},ya.prototype.find=function(e,t){var r,n;null==e&&"bookmark"==this.type&&(e=1);for(var i=0;i=0;l--)na(this,n[l]);s?Xo(this,s):this.cm&&fi(this.cm)})),undo:Hi((function(){oa(this,"undo")})),redo:Hi((function(){oa(this,"redo")})),undoSelection:Hi((function(){oa(this,"undo",!0)})),redoSelection:Hi((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,r=0,n=0;n=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,r){e=gt(this,e),t=gt(this,t);var n=[],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||r&&!r(l.marker)||n.push(l.marker.parent||l.marker)}++i})),n},getAllMarks:function(){var e=[];return this.iter((function(t){var r=t.markedSpans;if(r)for(var n=0;ne)return t=e,!0;e-=o,++r})),gt(this,ut(r,t))},indexFromPos:function(e){var t=(e=gt(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 d=e.dataTransfer.getData("Text");if(d){var f;if(t.state.draggingText&&!t.state.draggingText.copy&&(f=t.listSelections()),Ko(t.doc,ho(r,r)),f)for(var h=0;h=0;t--)ca(e.doc,"",n[t].from,n[t].to,"+delete");fi(e)}))}function Za(e,t,r){var n=de(e.text,t+r,r);return n<0||n>e.text.length?null:n}function $a(e,t,r){var n=Za(e,t.ch,r);return null==n?null:new ut(t.line,n,r<0?"after":"before")}function es(e,t,r,n,i){if(e){"rtl"==t.doc.direction&&(i=-i);var o=ge(r,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=sn(t,r);a=i<0?r.text.length-1:0;var u=ln(t,c,a).top;a=fe((function(e){return ln(t,c,e).top==u}),i<0==(1==s.level)?s.from:s.to-1,a),"before"==l&&(a=Za(r,a,1))}else a=i<0?s.to:s.from;return new ut(n,a,l)}}return new ut(n,i<0?r.text.length:0,i<0?"before":"after")}function ts(e,t,r,n){var i=ge(t,e.doc.direction);if(!i)return $a(t,r,n);r.ch>=t.text.length?(r.ch=t.text.length,r.sticky="before"):r.ch<=0&&(r.ch=0,r.sticky="after");var o=Ee(i,r.ch,r.sticky),a=i[o];if("ltr"==e.doc.direction&&a.level%2==0&&(n>0?a.to>r.ch:a.from=a.from&&f>=u.begin)){var h=d?"before":"after";return new ut(r.line,f,h)}}var p=function(e,t,n){for(var o=function(e,t){return t?new ut(r.line,l(e,1),"before"):new ut(r.line,e,"after")};e>=0&&e0==(1!=a.level),c=s?n.begin:l(n.end,-1);if(a.from<=c&&c0?u.end:l(u.begin,-1);return null==m||n>0&&m==t.text.length||!(E=p(n>0?0:i.length-1,n,c(m)))?null:E}Va.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"},Va.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"},Va.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"},Va.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"]},Va.default=T?Va.macDefault:Va.pcDefault;var rs={selectAll:ta,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),K)},killLine:function(e){return Qa(e,(function(t){if(t.empty()){var r=rt(e.doc,t.head.line).text.length;return t.head.ch==r&&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=rt(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"))}r.push(new uo(i,i))}e.setSelections(r)}))},newlineAndIndent:function(e){return Ui(e,(function(){for(var t=e.listSelections(),r=t.length-1;r>=0;r--)e.replaceRange(e.doc.lineSeparator(),t[r].anchor,t[r].head,"+input");t=e.listSelections();for(var n=0;n-1&&(dt((i=s.ranges[i]).from(),t)<0||t.xRel>0)&&(dt(i.to(),t)>0||t.xRel<0)?Is(e,n,t,o):bs(e,n,t,o)}function Is(e,t,r,n){var i=e.display,o=!1,c=ki(e,(function(t){l&&(i.scroller.draggable=!1),e.state.draggingText=!1,e.state.delayingBlurEvent&&(e.hasFocus()?e.state.delayingBlurEvent=!1:ti(e)),Re(i.wrapper.ownerDocument,"mouseup",c),Re(i.wrapper.ownerDocument,"mousemove",u),Re(i.scroller,"dragstart",d),Re(i.scroller,"drop",c),o||(Ie(t),n.addNew||Go(e.doc,r,null,null,n.extend),l&&!h||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},d=function(){return o=!0};l&&(i.scroller.draggable=!0),e.state.draggingText=c,c.copy=!n.moveOnDrag,Te(i.wrapper.ownerDocument,"mouseup",c),Te(i.wrapper.ownerDocument,"mousemove",u),Te(i.scroller,"dragstart",d),Te(i.scroller,"drop",c),e.state.delayingBlurEvent=!0,setTimeout((function(){return i.input.focus()}),20),i.scroller.dragDrop&&i.scroller.dragDrop()}function Cs(e,t,r){if("char"==r)return new uo(t,t);if("word"==r)return e.findWordAt(t);if("line"==r)return new uo(ut(t.line,0),gt(e.doc,ut(t.line+1,0)));var n=r(e,t);return new uo(n.from,n.to)}function bs(e,t,r,n){a&&ti(e);var i=e.display,o=e.doc;Ie(t);var s,l,c=o.sel,u=c.ranges;if(n.addNew&&!n.extend?(l=o.sel.contains(r),s=l>-1?u[l]:new uo(r,r)):(s=o.sel.primary(),l=o.sel.primIndex),"rectangle"==n.unit)n.addNew||(s=new uo(r,r)),r=Wn(e,t,!0,!0),l=-1;else{var d=Cs(e,r,n.unit);s=n.extend?Wo(s,d.anchor,d.head,n.extend):d}n.addNew?-1==l?(l=u.length,jo(o,fo(e,u.concat([s]),l),{scroll:!1,origin:"*mouse"})):u.length>1&&u[l].empty()&&"char"==n.unit&&!n.extend?(jo(o,fo(e,u.slice(0,l).concat(u.slice(l+1)),0),{scroll:!1,origin:"*mouse"}),c=o.sel):Vo(o,l,s,q):(l=0,jo(o,new co([s],0),q),c=o.sel);var f=r;function h(t){if(0!=dt(f,t))if(f=t,"rectangle"==n.unit){for(var i=[],a=e.options.tabSize,u=V(rt(o,r.line).text,r.ch,a),d=V(rt(o,t.line).text,t.ch,a),h=Math.min(u,d),p=Math.max(u,d),E=Math.min(r.line,t.line),m=Math.min(e.lastLine(),Math.max(r.line,t.line));E<=m;E++){var g=rt(o,E).text,v=Q(g,h,a);h==p?i.push(new uo(ut(E,v),ut(E,v))):g.length>v&&i.push(new uo(ut(E,v),ut(E,Q(g,p,a))))}i.length||i.push(new uo(r,r)),jo(o,fo(e,c.ranges.slice(0,l).concat(i),l),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var T,y=s,R=Cs(e,t,n.unit),N=y.anchor;dt(R.anchor,N)>0?(T=R.head,N=Et(y.from(),R.anchor)):(T=R.anchor,N=pt(y.to(),R.head));var A=c.ranges.slice(0);A[l]=_s(e,new uo(gt(o,N),T)),jo(o,fo(e,A,l),q)}}var p=i.wrapper.getBoundingClientRect(),E=0;function m(t){var r=++E,a=Wn(e,t,!0,"rectangle"==n.unit);if(a)if(0!=dt(a,f)){e.curOp.focus=M(F(e)),h(a);var s=ai(i,o);(a.line>=s.to||a.linep.bottom?20:0;l&&setTimeout(ki(e,(function(){E==r&&(i.scroller.scrollTop+=l,m(t))})),50)}}function g(t){e.state.selectingText=!1,E=1/0,t&&(Ie(t),i.input.focus()),Re(i.wrapper.ownerDocument,"mousemove",v),Re(i.wrapper.ownerDocument,"mouseup",T),o.history.lastSelOrigin=null}var v=ki(e,(function(e){0!==e.buttons&&xe(e)?m(e):g(e)})),T=ki(e,g);e.state.selectingText=T,Te(i.wrapper.ownerDocument,"mousemove",v),Te(i.wrapper.ownerDocument,"mouseup",T)}function _s(e,t){var r=t.anchor,n=t.head,i=rt(e.doc,r.line);if(0==dt(r,n)&&r.sticky==n.sticky)return t;var o=ge(i);if(!o)return t;var a=Ee(o,r.ch,r.sticky),s=o[a];if(s.from!=r.ch&&s.to!=r.ch)return t;var l,c=a+(s.from==r.ch==(1!=s.level)?0:1);if(0==c||c==o.length)return t;if(n.line!=r.line)l=(n.line-r.line)*("ltr"==e.doc.direction?1:-1)>0;else{var u=Ee(o,n.ch,n.sticky),d=u-a||(n.ch-r.ch)*(1==s.level?-1:1);l=u==c-1||u==c?d<0:d>0}var f=o[c+(l?-1:0)],h=l==(1==f.level),p=h?f.from:f.to,E=h?"after":"before";return r.ch==p&&r.sticky==E?t:new uo(new ut(r.line,p,E),n)}function ws(e,t,r,n){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;n&&Ie(t);var a=e.display,s=a.lineDiv.getBoundingClientRect();if(o>s.bottom||!Oe(e,r))return be(t);o-=s.top-a.viewOffset;for(var l=0;l=i)return Ne(e,r,e,st(e.doc,o),e.display.gutterSpecs[l].className,t),be(t)}}function xs(e,t){return ws(e,t,"gutterClick",!0)}function Ms(e,t){Kr(e.display,t)||Ds(e,t)||Ae(e,t,"contextmenu")||S||e.display.input.onContextMenu(t)}function Ds(e,t){return!!Oe(e,"gutterContextMenu")&&ws(e,t,"gutterContextMenu",!1)}function Ps(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),gn(e)}Rs.prototype.compare=function(e,t,r){return this.time+ys>e&&0==dt(t,this.pos)&&r==this.button};var Us={toString:function(){return"CodeMirror.Init"}},ks={},Fs={};function Hs(e){var t=e.optionHandlers;function r(r,n,i,o){e.defaults[r]=n,i&&(t[r]=o?function(e,t,r){r!=Us&&i(e,t,r)}:i)}e.defineOption=r,e.Init=Us,r("value","",(function(e,t){return e.setValue(t)}),!0),r("mode",null,(function(e,t){e.doc.modeOption=t,To(e)}),!0),r("indentUnit",2,To,!0),r("indentWithTabs",!1),r("smartIndent",!0),r("tabSize",4,(function(e){yo(e),gn(e),Bn(e)}),!0),r("lineSeparator",null,(function(e,t){if(e.doc.lineSep=t,t){var r=[],n=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,r.push(ut(n,o))}n++}));for(var i=r.length-1;i>=0;i--)ca(e.doc,t,r[i],ut(r[i].line,r[i].ch+t.length))}})),r("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]/g,(function(e,t,r){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),r!=Us&&e.refresh()})),r("specialCharPlaceholder",yr,(function(e){return e.refresh()}),!0),r("electricChars",!0),r("inputStyle",v?"contenteditable":"textarea",(function(){throw new Error("inputStyle can not (yet) be changed in a running editor")}),!0),r("spellcheck",!1,(function(e,t){return e.getInputField().spellcheck=t}),!0),r("autocorrect",!1,(function(e,t){return e.getInputField().autocorrect=t}),!0),r("autocapitalize",!1,(function(e,t){return e.getInputField().autocapitalize=t}),!0),r("rtlMoveVisually",!R),r("wholeLineUpdateBefore",!0),r("theme","default",(function(e){Ps(e),ro(e)}),!0),r("keyMap","default",(function(e,t,r){var n=Ja(t),i=r!=Us&&Ja(r);i&&i.detach&&i.detach(e,n),n.attach&&n.attach(e,i||null)})),r("extraKeys",null),r("configureMouse",null),r("lineWrapping",!1,Gs,!0),r("gutters",[],(function(e,t){e.display.gutterSpecs=eo(t,e.options.lineNumbers),ro(e)}),!0),r("fixedGutter",!0,(function(e,t){e.display.gutters.style.left=t?kn(e.display)+"px":"0",e.refresh()}),!0),r("coverGutterNextToScrollbar",!1,(function(e){return Ai(e)}),!0),r("scrollbarStyle","native",(function(e){Li(e),Ai(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)}),!0),r("lineNumbers",!1,(function(e,t){e.display.gutterSpecs=eo(e.options.gutters,t),ro(e)}),!0),r("firstLineNumber",1,ro,!0),r("lineNumberFormatter",(function(e){return e}),ro,!0),r("showCursorWhenSelecting",!1,Kn,!0),r("resetSelectionOnContextMenu",!0),r("lineWiseCopyCut",!0),r("pasteLinesPerSelection",!0),r("selectionsMayTouch",!1),r("readOnly",!1,(function(e,t){"nocursor"==t&&(ni(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)})),r("screenReaderLabel",null,(function(e,t){t=""===t?null:t,e.display.input.screenReaderLabelChanged(t)})),r("disableInput",!1,(function(e,t){t||e.display.input.reset()}),!0),r("dragDrop",!0,Ws),r("allowDropFileTypes",null),r("cursorBlinkRate",530),r("cursorScrollMargin",0),r("cursorHeight",1,Kn,!0),r("singleCursorHeightPerLine",!0,Kn,!0),r("workTime",100),r("workDelay",100),r("flattenSpans",!0,yo,!0),r("addModeClass",!1,yo,!0),r("pollInterval",100),r("undoDepth",200,(function(e,t){return e.doc.history.undoDepth=t})),r("historyEventDelay",1250),r("viewportMargin",10,(function(e){return e.refresh()}),!0),r("maxHighlightLength",1e4,yo,!0),r("moveInputWithCursor",!0,(function(e,t){t||e.display.input.resetPosition()})),r("tabindex",null,(function(e,t){return e.display.input.getField().tabIndex=t||""})),r("autofocus",null),r("direction","ltr",(function(e,t){return e.doc.setDirection(t)}),!0),r("phrases",null)}function Ws(e,t,r){if(!t!=!(r&&r!=Us)){var n=e.display.dragFunctions,i=t?Te:Re;i(e.display.scroller,"dragstart",n.start),i(e.display.scroller,"dragenter",n.enter),i(e.display.scroller,"dragover",n.over),i(e.display.scroller,"dragleave",n.leave),i(e.display.scroller,"drop",n.drop)}}function Gs(e){e.options.lineWrapping?(D(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(I(e.display.wrapper,"CodeMirror-wrap"),fr(e)),Hn(e),Bn(e),gn(e),setTimeout((function(){return Ai(e)}),100)}function Bs(e,t){var r=this;if(!(this instanceof Bs))return new Bs(e,t);this.options=t=t?B(t):{},B(ks,t,!1);var n=t.value;"string"==typeof n?n=new Ca(n,t.mode,null,t.lineSeparator,t.direction):t.mode&&(n.modeOption=t.mode),this.doc=n;var i=new Bs.inputStyles[t.inputStyle](this),o=this.display=new no(e,n,i,t);for(var c in o.wrapper.CodeMirror=this,Ps(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Li(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 Y,keySeq:null,specialChars:null},t.autofocus&&!v&&o.input.focus(),a&&s<11&&setTimeout((function(){return r.display.input.reset(!0)}),20),Vs(this),Ua(),Ci(this),this.curOp.forceUpdate=!0,So(this,n),t.autofocus&&!v||this.hasFocus()?setTimeout((function(){r.hasFocus()&&!r.state.focused&&ri(r)}),20):ni(this),Fs)Fs.hasOwnProperty(c)&&Fs[c](this,t[c],Us);$i(this),t.finishInit&&t.finishInit(this);for(var u=0;u400}Te(t.scroller,"touchstart",(function(i){if(!Ae(e,i)&&!o(i)&&!xs(e,i)){t.input.ensurePolled(),clearTimeout(r);var a=+new Date;t.activeTouch={start:a,moved:!1,prev:a-n.end<=300?n:null},1==i.touches.length&&(t.activeTouch.left=i.touches[0].pageX,t.activeTouch.top=i.touches[0].pageY)}})),Te(t.scroller,"touchmove",(function(){t.activeTouch&&(t.activeTouch.moved=!0)})),Te(t.scroller,"touchend",(function(r){var n=t.activeTouch;if(n&&!Kr(t,r)&&null!=n.left&&!n.moved&&new Date-n.start<300){var o,a=e.coordsChar(t.activeTouch,"page");o=!n.prev||l(n,n.prev)?new uo(a,a):!n.prev.prev||l(n,n.prev.prev)?e.findWordAt(a):new uo(ut(a.line,0),gt(e.doc,ut(a.line+1,0))),e.setSelection(o.anchor,o.head),e.focus(),Ie(r)}i()})),Te(t.scroller,"touchcancel",i),Te(t.scroller,"scroll",(function(){t.scroller.clientHeight&&(gi(e,t.scroller.scrollTop),Ti(e,t.scroller.scrollLeft,!0),Ne(e,"scroll",e))})),Te(t.scroller,"mousewheel",(function(t){return lo(e,t)})),Te(t.scroller,"DOMMouseScroll",(function(t){return lo(e,t)})),Te(t.wrapper,"scroll",(function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0})),t.dragFunctions={enter:function(t){Ae(e,t)||_e(t)},over:function(t){Ae(e,t)||(xa(e,t),_e(t))},start:function(t){return wa(e,t)},drop:ki(e,_a),leave:function(t){Ae(e,t)||Ma(e)}};var c=t.input.getField();Te(c,"keyup",(function(t){return ms.call(e,t)})),Te(c,"keydown",ki(e,ps)),Te(c,"keypress",ki(e,gs)),Te(c,"focus",(function(t){return ri(e,t)})),Te(c,"blur",(function(t){return ni(e,t)}))}Bs.defaults=ks,Bs.optionHandlers=Fs;var Ys=[];function zs(e,t,r,n){var i,o=e.doc;null==r&&(r="add"),"smart"==r&&(o.mode.indent?i=St(e,t).state:r="prev");var a=e.options.tabSize,s=rt(o,t),l=V(s.text,null,a);s.stateAfter&&(s.stateAfter=null);var c,u=s.text.match(/^\s*/)[0];if(n||/\S/.test(s.text)){if("smart"==r&&((c=o.mode.indent(i,s.text.slice(u.length),s.text))==j||c>150)){if(!n)return;r="prev"}}else c=0,r="not";"prev"==r?c=t>o.first?V(rt(o,t-1).text,null,a):0:"add"==r?c=l+e.options.indentUnit:"subtract"==r?c=l-e.options.indentUnit:"number"==typeof r&&(c=l+r),c=Math.max(0,c);var d="",f=0;if(e.options.indentWithTabs)for(var h=Math.floor(c/a);h;--h)f+=a,d+="\t";if(fa,l=He(t),c=null;if(s&&n.ranges.length>1)if(Xs&&Xs.text.join("\n")==t){if(n.ranges.length%Xs.text.length==0){c=[];for(var u=0;u=0;f--){var h=n.ranges[f],p=h.from(),E=h.to();h.empty()&&(r&&r>0?p=ut(p.line,p.ch-r):e.state.overwrite&&!s?E=ut(E.line,Math.min(rt(o,E.line).text.length,E.ch+ee(l).length)):s&&Xs&&Xs.lineWise&&Xs.text.join("\n")==l.join("\n")&&(p=E=ut(p.line,0)));var m={from:p,to:E,text:c?c[f%c.length]:l,origin:i||(s?"paste":e.state.cutIncoming>a?"cut":"+input")};na(e.doc,m),Mr(e,"inputRead",e,m)}t&&!s&&Js(e,t),fi(e),e.curOp.updateInput<2&&(e.curOp.updateInput=d),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function qs(e,t){var r=e.clipboardData&&e.clipboardData.getData("Text");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||!t.hasFocus()||Ui(t,(function(){return Ks(t,r,0,null,"paste")})),!0}function Js(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var r=e.doc.sel,n=r.ranges.length-1;n>=0;n--){var i=r.ranges[n];if(!(i.head.ch>100||n&&r.ranges[n-1].head.line==i.head.line)){var o=e.getModeAt(i.head),a=!1;if(o.electricChars){for(var s=0;s-1){a=zs(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(rt(e.doc,i.head.line).text.slice(0,i.head.ch))&&(a=zs(e,i.head.line,"smart"));a&&Mr(e,"electricInput",e,i.head.line)}}}function Qs(e){for(var t=[],r=[],n=0;nr&&(zs(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&fi(this));else{var o=i.from(),a=i.to(),s=Math.max(r,o.line);r=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var l=s;l0&&Vo(this.doc,n,new uo(o,c[n].to()),K)}}})),getTokenAt:function(e,t){return bt(this,e,t)},getLineTokens:function(e,t){return bt(this,ut(e),t,!0)},getTokenTypeAt:function(e){e=gt(this.doc,e);var t,r=At(this,rt(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var a=n+i>>1;if((a?r[2*a-1]:0)>=o)i=a;else{if(!(r[2*a+1]o&&(e=o,i=!0),n=rt(this.doc,e)}else n=e;return Rn(this,n,{top:0,left:0},t||"page",r||i).top+(i?this.doc.height-ur(n):0)},defaultTextHeight:function(){return Dn(this.display)},defaultCharWidth:function(){return Pn(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display,a=(e=Sn(this,gt(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"==n)a=e.top;else if("above"==n||"near"==n){var l=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||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"),r&&ci(this,{left:s,top:a,right:s+t.offsetWidth,bottom:a+t.offsetHeight})},triggerOnKeyDown:Fi(ps),triggerOnKeyPress:Fi(gs),triggerOnKeyUp:ms,triggerOnMouseDown:Fi(As),execCommand:function(e){if(rs.hasOwnProperty(e))return rs[e].call(null,this)},triggerElectric:Fi((function(e){Js(this,e)})),findPosH:function(e,t,r,n){var i=1;t<0&&(i=-1,t=-t);for(var o=gt(this.doc,e),a=0;a0&&a(t.charAt(r-1));)--r;for(;n.5||this.options.lineWrapping)&&Hn(this),Ne(this,"refresh",this)})),swapDoc:Fi((function(e){var t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),So(this,e),gn(this),this.display.input.reset(),hi(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,Mr(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}},Le(e),e.registerHelper=function(t,n,i){r.hasOwnProperty(t)||(r[t]=e[t]={_global:[]}),r[t][n]=i},e.registerGlobalHelper=function(t,n,i,o){e.registerHelper(t,n,o),r[t]._global.push({pred:i,val:o})}}function tl(e,t,r,n,i){var o=t,a=r,s=rt(e,t.line),l=i&&"rtl"==e.direction?-r:r;function c(){var r=t.line+l;return!(r=e.first+e.size)&&(t=new ut(r,t.ch,t.sticky),s=rt(e,r))}function u(o){var a;if("codepoint"==n){var u=s.text.charCodeAt(t.ch+(r>0?0:-1));if(isNaN(u))a=null;else{var d=r>0?u>=55296&&u<56320:u>=56320&&u<57343;a=new ut(t.line,Math.max(0,Math.min(s.text.length,t.ch+r*(d?2:1))),-r)}}else a=i?ts(e.cm,s,t,r):$a(s,t,r);if(null==a){if(o||!c())return!1;t=es(i,e.cm,s,t.line,l)}else t=a;return!0}if("char"==n||"codepoint"==n)u();else if("column"==n)u(!0);else if("word"==n||"group"==n)for(var d=null,f="group"==n,h=e.cm&&e.cm.getHelper(t,"wordChars"),p=!0;!(r<0)||u(!p);p=!1){var E=s.text.charAt(t.ch)||"\n",m=se(E,h)?"w":f&&"\n"==E?"n":!f||/\s/.test(E)?null:"p";if(!f||p||m||(m="s"),d&&d!=m){r<0&&(r=1,u(),t.sticky="after");break}if(m&&(d=m),r>0&&!u(!p))break}var g=$o(e,t,o,a,!0);return ft(o,g)&&(g.hitSide=!0),g}function rl(e,t,r,n){var i,o,a=e.doc,s=t.left;if("page"==n){var l=Math.min(e.display.wrapper.clientHeight,W(e).innerHeight||a(e).documentElement.clientHeight),c=Math.max(l-.5*Dn(e.display),3);i=(r>0?t.bottom:t.top)+r*c}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(;(o=In(e,s,i)).outside;){if(r<0?i<=0:i>=a.height){o.hitSide=!0;break}i+=5*r}return o}var nl=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new Y,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function il(e,t){var r=an(e,t.line);if(!r||r.hidden)return null;var n=rt(e.doc,t.line),i=rn(r,n,t.line),o=ge(n,e.doc.direction),a="left";o&&(a=Ee(o,t.ch)%2?"right":"left");var s=dn(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,r,n,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 d(e){e&&(u(),o+=e)}function f(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(r)return void d(r);var o,h=t.getAttribute("cm-marker");if(h){var p=e.findMarks(ut(n,0),ut(i+1,0),c(+h));return void(p.length&&(o=p[0].find(0))&&d(nt(e.doc,o.from,o.to).join(s)))}if("false"==t.getAttribute("contenteditable"))return;var E=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;E&&u();for(var m=0;m=t.display.viewTo||o.line=t.display.viewFrom&&il(t,i)||{node:l[0].measure.map[2],offset:0},u=o.line