!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.CodeMirror=t()}(this,function(){"use strict";function e(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function t(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function r(e,r){return t(e).appendChild(r)}function n(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 l+(t-o);l+=s-o,l+=r-l%r,o=s+1}}function f(e,t){for(var r=0;r=t)return n+Math.min(l,t-i);if(i+=o-n,i+=r-i%r,n=o+1,i>=t)return n}}function p(e){for(;xo.length<=e;)xo.push(g(xo)+" ");return xo[e]}function g(e){return e[e.length-1]}function v(e,t){for(var r=[],n=0;n"€"&&(e.toUpperCase()!=e.toLowerCase()||Co.test(e))}function w(e,t){return t?!!(t.source.indexOf("\\w")>-1&&b(e))||t.test(e):b(e)}function x(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function C(e){return e.charCodeAt(0)>=768&&So.test(e)}function S(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 k(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?H(r,k(e,r).text.length):function(e,t){var r=e.ch;return null==r||r>t?H(e.line,t):r<0?H(e.line,0):e}(t,k(e,t.line).text.length)}function G(e,t){for(var r=[],n=0;n=t:o.to>t);(n||(n=[])).push(new U(l,o.from,s?null:o.to))}}return n}(r,i,l),a=function(e,t,r){var n;if(e)for(var i=0;i=t:o.to>t)||o.from==t&&"bookmark"==l.type&&(!r||o.marker.insertLeft)){var s=null==o.from||(l.inclusiveLeft?o.from<=t:o.from0&&s)for(var w=0;wt)&&(!r||Z(r,o.marker)<0)&&(r=o.marker)}return r}function re(e,t,r,n,i){var o=k(e,t),l=ko&&o.markedSpans;if(l)for(var s=0;s=0&&h<=0||c<=0&&h>=0)&&(c<=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?F(u.to,r)>=0:F(u.to,r)>0)||c>=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?F(u.from,n)<=0:F(u.from,n)<0)))return!0}}}function ne(e){for(var t;t=J(e);)e=t.find(-1,!0).line;return e}function ie(e,t){var r=k(e,t),n=ne(r);return r==n?t:O(n)}function oe(e,t){if(t>e.lastLine())return t;var r,n=k(e,t);if(!le(e,n))return t;for(;r=ee(n);)n=r.find(1,!0).line;return O(n)+1}function le(e,t){var r=ko&&t.markedSpans;if(r)for(var n=void 0,i=0;it.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function he(e,t,r){var n;To=null;for(var i=0;it)return i;o.to==t&&(o.from!=o.to&&"before"==r?n=i:To=i),o.from==t&&(o.from!=o.to&&"before"!=r?n=i:To=i)}return null!=n?n:To}function fe(e,t){var r=e.order;return null==r&&(r=e.order=Mo(e.text,t)),r}function de(e,t){return e._handlers&&e._handlers[t]||No}function pe(e,t,r){if(e.removeEventListener)e.removeEventListener(t,r,!1);else if(e.detachEvent)e.detachEvent("on"+t,r);else{var n=e._handlers,i=n&&n[t];if(i){var o=f(i,r);o>-1&&(n[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function ge(e,t){var r=de(e,t);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i0}function be(e){e.prototype.on=function(e,t){Oo(this,e,t)},e.prototype.off=function(e,t){pe(this,e,t)}}function we(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function xe(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function Ce(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function Se(e){we(e),xe(e)}function Le(e){return e.target||e.srcElement}function ke(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),no&&e.ctrlKey&&1==t&&(t=3),t}function Te(e){if(null==po){var t=n("span","​");r(e,n("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(po=t.offsetWidth<=1&&t.offsetHeight>2&&!(ji&&Xi<8))}var i=po?n("span","​"):n("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return i.setAttribute("cm-text",""),i}function Me(e){if(null!=go)return go;var n=r(e,document.createTextNode("AخA")),i=so(n,0,1).getBoundingClientRect(),o=so(n,1,2).getBoundingClientRect();return t(e),!(!i||i.left==i.right)&&(go=o.right-i.right<3)}function Ne(e){if("string"==typeof e&&Eo.hasOwnProperty(e))e=Eo[e];else if(e&&"string"==typeof e.name&&Eo.hasOwnProperty(e.name)){var t=Eo[e.name];"string"==typeof t&&(t={name:t}),(e=y(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ne("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ne("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Oe(e,t){t=Ne(t);var r=Po[t.name];if(!r)return Oe(e,"text/plain");var n=r(e,t);if(Io.hasOwnProperty(t.name)){var i=Io[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 l in t.modeProps)n[l]=t.modeProps[l];return n}function Ae(e,t){c(t,Io.hasOwnProperty(e)?Io[e]:Io[e]={})}function De(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 We(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 He(e,t,r){return!e.startState||e.startState(t,r)}function Fe(e,t,r,n){var i=[e.state.modeGen],o={};Ue(e,t.text,e.doc.mode,r,function(e,t){return i.push(e,t)},o,n);for(var l=r.state,s=function(n){r.baseTokens=i;var s=e.state.overlays[n],a=1,u=0;r.state=!0,Ue(e,t.text,s.mode,r,function(e,t){for(var r=a;ue&&i.splice(a,1,e,i[a+1],n),a+=2,u=Math.min(e,n)}if(t)if(s.opaque)i.splice(r,a-r,e,"overlay "+t),a=r+2;else for(;re.options.maxHighlightLength&&De(e.doc.mode,n.state),o=Fe(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 Ee(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return new Bo(n,!0,t);var o=function(e,t,r){for(var n,i,o=e.doc,l=r?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=o.first)return o.first;var a=k(o,s-1),u=a.stateAfter;if(u&&(!r||s+(u instanceof Ro?u.lookAhead:0)<=o.modeFrontier))return s;var c=h(a.text,null,e.options.tabSize);(null==i||n>c)&&(i=s-1,n=c)}return i}(e,t,r),l=o>n.first&&k(n,o-1).stateAfter,s=l?Bo.fromSaved(n,l,o):new Bo(n,He(n.mode),o);return n.iter(o,t,function(r){Ie(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.")}function Be(e,t,r,n){var i,o,l=e.doc,s=l.mode,a=k(l,(t=B(l,t)).line),u=Ee(e,t.line,r),c=new zo(a.text,e.options.tabSize,u);for(n&&(o=[]);(n||c.pose.options.maxHighlightLength?(s=!1,l&&Ie(e,t,n,h.pos),h.pos=t.length,a=null):a=Ge(Re(r,h,n.state,f),o),f){var d=f[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;uu&&h.from<=u);f++);if(h.to>=c)return e(r,n,i,o,l,s,a);e(r,n.slice(0,h.to-u),i,o,null,s,a),o=null,n=n.slice(h.to-u),u=h.to}}}(n.addToken,s)),n.map=[];!function(e,t,r){var n=e.markedSpans,i=e.text,o=0;if(!n){for(var l=1;lg||S.collapsed&&C.to==g&&C.from==g)){if(null!=C.to&&C.to!=g&&y>C.to&&(y=C.to,c=""),S.className&&(u+=" "+S.className),S.css&&(a=(a?a+";":"")+S.css),S.startStyle&&C.from==g&&(h+=" "+S.startStyle),S.endStyle&&C.to==y&&(w||(w=[])).push(S.endStyle,C.to),S.title&&((d||(d={})).title=S.title),S.attributes)for(var L in S.attributes)(d||(d={}))[L]=S.attributes[L];S.collapsed&&(!f||Z(f.marker,S)<0)&&(f=C)}else C.from>g&&y>C.from&&(y=C.from)}if(w)for(var k=0;k=p)break;for(var M=Math.min(p,y);;){if(m){var N=g+m.length;if(!f){var O=N>M?m.slice(0,M-g):m;t.addToken(t,O,s?s+u:u,h,g+O.length==y?c:"",a,d)}if(N>=M){m=m.slice(M-g),g=M;break}g=N,h=""}m=i.slice(o,o=r[v++]),s=Ke(r[v++],t.cm.options)}}}(l,n,Pe(e,l,t!=e.display.externalMeasured&&O(l))),l.styleClasses&&(l.styleClasses.bgClass&&(n.bgClass=a(l.styleClasses.bgClass,n.bgClass||"")),l.styleClasses.textClass&&(n.textClass=a(l.styleClasses.textClass,n.textClass||""))),0==n.map.length&&n.map.push(0,0,n.content.appendChild(Te(e.display.measure))),0==o?(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(Yi){var u=n.content.lastChild;(/\bcm-tab\b/.test(u.className)||u.querySelector&&u.querySelector(".cm-tab"))&&(n.content.className="cm-tab-wrap-hack")}return ge(e,"renderLine",e,t.line,n.pre),n.pre.className&&(n.textClass=a(n.pre.className,n.textClass||"")),n}function Xe(e){var t=n("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Ye(e,t,r,i,o,l,s){if(t){var a,u=e.splitSpaces?function(e,t){if(e.length>1&&!/ /.test(e))return e;for(var r=t,n="",i=0;ir)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function vt(e,t,r,n){return bt(e,yt(e,t),r,n)}function mt(e,t){if(t>=e.display.viewFrom&&t=r.lineN&&t2&&o.push((a.bottom+u.top)/2-r.top)}}o.push(r.bottom-r.top)}}(e,t.view,t.rect),t.hasHeights=!0),(s=function(e,t,i,o){var l,s=wt(t.map,i,o),a=s.node,u=s.start,c=s.end,h=s.collapse;if(3==a.nodeType){for(var f=0;f<4;f++){for(;u&&C(t.line.text.charAt(s.coverStart+u));)--u;for(;s.coverStart+c1}(e))return t;var i=screen.logicalXDPI/screen.deviceXDPI,o=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*o,bottom:t.bottom*o}}(e.display.measure,l))}else{u>0&&(h=o="right");var d;l=e.options.lineWrapping&&(d=a.getClientRects()).length>1?d["right"==o?d.length-1:0]:a.getBoundingClientRect()}if(ji&&Xi<9&&!u&&(!l||!l.left&&!l.right)){var p=a.parentNode.getClientRects()[0];l=p?{left:p.left,right:p.left+Rt(e.display),top:p.top,bottom:p.bottom}:_o}for(var g=l.top-t.rect.top,v=l.bottom-t.rect.top,m=(g+v)/2,y=t.view.measure.heights,b=0;bt)&&(i=(o=a-s)-1,t>=a&&(l="right")),null!=i){if(n=e[u+2],s==a&&r==(n.insertLeft?"left":"right")&&(l=r),"left"==r&&0==i)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)n=e[2+(u-=3)],l="left";if("right"==r&&i==a-s)for(;u=0&&(r=e[i]).left==r.right;i--);return r}function Ct(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t=n.text.length?(u=n.text.length,c="before"):u<=0&&(u=0,c="after"),!a)return l("before"==c?u-1:u,"before"==c);var h=he(a,u,c),f=To,d=s(u,h,"before"==c);return null!=f&&(d.other=s(u,f,"before"!=c)),d}function Wt(e,t){var r=0;t=B(e.doc,t),e.options.lineWrapping||(r=Rt(e.display)*t.ch);var n=k(e.doc,t.line),i=ae(n)+ut(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function Ht(e,t,r,n,i){var o=H(e,t,r);return o.xRel=i,n&&(o.outside=!0),o}function Ft(e,t,r){var n=e.doc;if((r+=e.display.viewOffset)<0)return Ht(n.first,0,null,!0,-1);var i=A(n,r),o=n.first+n.size-1;if(i>o)return Ht(n.first+n.size-1,k(n,o).text.length,null,!0,1);t<0&&(t=0);for(var l=k(n,i);;){var s=function(e,t,r,n,i){i-=ae(t);var o=yt(e,t),l=Mt(t),s=0,a=t.text.length,u=!0,c=fe(t,e.doc.direction);if(c){var h=(e.options.lineWrapping?function(e,t,r,n,i,o,l){var s=Pt(e,t,n,l),a=s.begin,u=s.end;/\s/.test(t.text.charAt(u-1))&&u--;for(var c=null,h=null,f=0;f=u||d.to<=a)){var p=1!=d.level,g=bt(e,n,p?Math.min(u,d.to)-1:Math.max(a,d.from)).right,v=gv)&&(c=d,h=v)}}c||(c=i[i.length-1]);c.fromu&&(c={from:c.from,to:u,level:c.level});return c}:function(e,t,r,n,i,o,l){var s=L(function(s){var a=i[s],u=1!=a.level;return It(Dt(e,H(r,u?a.to:a.from,u?"before":"after"),"line",t,n),o,l,!0)},0,i.length-1),a=i[s];if(s>0){var u=1!=a.level,c=Dt(e,H(r,u?a.from:a.to,u?"after":"before"),"line",t,n);It(c,o,l,!0)&&c.top>l&&(a=i[s-1])}return a})(e,t,r,o,c,n,i);u=1!=h.level,s=u?h.from:h.to-1,a=u?h.to:h.from-1}var f,d,p=null,g=null,v=L(function(t){var r=bt(e,o,t);return r.top+=l,r.bottom+=l,!!It(r,n,i,!1)&&(r.top<=i&&r.left<=n&&(p=t,g=r),!0)},s,a),m=!1;if(g){var y=n-g.left=w.bottom}return v=S(t.text,v,1),Ht(r,v,d,m,n-f)}(e,l,i,t,r),a=te(l,s.ch+(s.xRel>0?1:0));if(!a)return s;var u=a.find(1);if(u.line==i)return u;l=k(n,i=u.line)}}function Pt(e,t,r,n){n-=Mt(t);var i=t.text.length,o=L(function(t){return bt(e,r,t-1).bottom<=n},i,0);return i=L(function(t){return bt(e,r,t).top>n},o,i),{begin:o,end:i}}function Et(e,t,r,n){r||(r=yt(e,t));return Pt(e,t,r,Nt(e,t,bt(e,r,n),"line").top)}function It(e,t,r,n){return!(e.bottom<=r)&&(e.top>r||(n?e.left:e.right)>t)}function zt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Vo){Vo=n("pre");for(var i=0;i<49;++i)Vo.appendChild(document.createTextNode("x")),Vo.appendChild(n("br"));Vo.appendChild(document.createTextNode("x"))}r(e.measure,Vo);var o=Vo.offsetHeight/50;return o>3&&(e.cachedTextHeight=o),t(e.measure),o||1}function Rt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=n("span","xxxxxxxxxx"),i=n("pre",[t]);r(e.measure,i);var o=t.getBoundingClientRect(),l=(o.right-o.left)/10;return l>2&&(e.cachedCharWidth=l),l||10}function Bt(e){for(var t=e.display,r={},n={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l)r[e.options.gutters[l]]=o.offsetLeft+o.clientLeft+i,n[e.options.gutters[l]]=o.clientWidth;return{fixedPos:Gt(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:r,gutterWidth:n,wrapperWidth:t.wrapper.clientWidth}}function Gt(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function Ut(e){var t=zt(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/Rt(e.display)-3);return function(i){if(le(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var r=e.display.view,n=0;n=e.display.viewTo||a.to().linet||t==r&&l.to==t)&&(n(Math.max(l.from,t),Math.min(l.to,r),1==l.level?"rtl":"ltr",o),i=!0)}i||n(t,r,"ltr")}(g,r||0,null==n?p:n,function(e,t,s,d){var v="ltr"==s,m=o(e,v?"left":"right"),y=o(t-1,v?"right":"left"),b=null==r&&0==e,w=null==n&&t==p,x=0==d,C=!g||d==g.length-1;if(y.top-m.top<=3){var S=(f?b:w)&&x,L=(f?w:b)&&C,k=S?c:(v?m:y).left,T=L?h:(v?y:m).right;i(k,m.top,T-k,m.bottom)}else{var M,N,O,A;v?(M=f&&b&&x?c:m.left,N=f?h:l(e,s,"before"),O=f?c:l(t,s,"after"),A=f&&w&&C?h:y.right):(M=f?l(e,s,"before"):c,N=!f&&b&&x?h:m.right,O=!f&&w&&C?c:y.left,A=f?l(t,s,"after"):h),i(M,m.top,N-M,m.bottom),m.bottom0?t.blinker=setInterval(function(){return t.cursorDiv.style.visibility=(r=!r)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Zt(e){e.state.focused||(e.display.input.focus(),Jt(e))}function Qt(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,er(e))},100)}function Jt(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(ge(e,"focus",e,t),e.state.focused=!0,s(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),Yi&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),qt(e))}function er(e,t){e.state.delayingBlurEvent||(e.state.focused&&(ge(e,"blur",e,t),e.state.focused=!1,co(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function tr(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n.005||c<-.005)&&(N(i.line,l),rr(i.line),i.rest))for(var h=0;he.display.sizerWidth){var f=Math.ceil(s/Rt(e.display));f>e.display.maxLineLength&&(e.display.maxLineLength=f,e.display.maxLine=i.line,e.display.maxLineChanged=!0)}}}}function rr(e){if(e.widgets)for(var t=0;t=l&&(o=A(t,ae(k(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function ir(e){var t=e.display,r=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var n=Gt(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=n+"px",l=0;lo&&(t.bottom=t.top+o);var s=e.doc.height+ct(r),a=t.tops-n;if(t.topi+o){var c=Math.min(t.top,(u?s:t.bottom)-o);c!=i&&(l.scrollTop=c)}var h=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:r.scroller.scrollLeft,f=dt(e)-(e.options.fixedGutter?r.gutters.offsetWidth:0),d=t.right-t.left>f;return d&&(t.right=t.left+f),t.left<10?l.scrollLeft=0:t.leftf+h-3&&(l.scrollLeft=t.right+(d?0:10)-f),l}function sr(e,t){null!=t&&(cr(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function ar(e){cr(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function ur(e,t,r){null==t&&null==r||cr(e),null!=t&&(e.curOp.scrollLeft=t),null!=r&&(e.curOp.scrollTop=r)}function cr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;hr(e,Wt(e,t.from),Wt(e,t.to),t.margin)}}function hr(e,t,r,n){var i=lr(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});ur(e,i.scrollLeft,i.scrollTop)}function fr(e,t){Math.abs(e.doc.scrollTop-t)<2||(Gi||Fr(e,{top:t}),dr(e,t,!0),Gi&&Fr(e),Ar(e,100))}function dr(e,t,r){t=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 pr(e,t,r,n){t=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,ir(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function gr(e){var t=e.display,r=t.gutters.offsetWidth,n=Math.round(e.doc.height+ct(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+ft(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:r}}function vr(e,t){t||(t=gr(e));var r=e.display.barWidth,n=e.display.barHeight;mr(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&tr(e),mr(e,gr(e)),r=e.display.barWidth,n=e.display.barHeight}function mr(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=""}function yr(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&co(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new Zo[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),Oo(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?pr(e,t):fr(e,t)},e),e.display.scrollbars.addClass&&s(e.display.wrapper,e.display.scrollbars.addClass)}function br(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:++Qo},function(e){Xo?Xo.ops.push(e):e.ownsGroup=Xo={ops:[e],delayedCallbacks:[]}}(e.curOp)}function wr(e){var t=e.curOp;t&&function(e,t){var r=e.ownsGroup;if(r)try{!function(e){var t=e.delayedCallbacks,r=0;do{for(;r=r.viewTo)||r.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Jo(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}(t[r]);for(var i=0;i1&&(l=!0)),null!=u.scrollLeft&&(pr(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-h)>1&&(l=!0)),!l)break}return i}(t,B(i,e.scrollToPos.from),B(i,e.scrollToPos.to),e.scrollToPos.margin);!function(e,t){if(!ve(e,"scrollCursorIntoView")){var r=e.display,i=r.sizer.getBoundingClientRect(),o=null;if(t.top+i.top<0?o=!0:t.bottom+i.top>(window.innerHeight||document.documentElement.clientHeight)&&(o=!1),null!=o&&!Ji){var l=n("div","​",null,"position: absolute;\n top: "+(t.top-r.viewOffset-ut(e.display))+"px;\n height: "+(t.bottom-t.top+ft(e)+r.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(l),l.scrollIntoView(o),e.display.lineSpace.removeChild(l)}}}(t,o)}var l=e.maybeHiddenMarkers,s=e.maybeUnhiddenMarkers;if(l)for(var a=0;at)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)ko&&ie(e.doc,t)i.viewFrom?Mr(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)Mr(e);else if(t<=i.viewFrom){var o=Nr(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):Mr(e)}else if(r>=i.viewTo){var l=Nr(e,t,t,-1);l?(i.view=i.view.slice(0,l.index),i.viewTo=l.lineN):Mr(e)}else{var s=Nr(e,t,t,-1),a=Nr(e,r,r+n,1);s&&a?(i.view=i.view.slice(0,s.index).concat(qe(e,s.lineN,a.lineN)).concat(i.view.slice(a.index)),i.viewTo+=n):Mr(e)}var u=i.externalMeasured;u&&(r=i.lineN&&t=n.viewTo)){var o=n.view[jt(e,t)];if(null!=o.node){var l=o.changes||(o.changes=[]);-1==f(l,r)&&l.push(r)}}}function Mr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Nr(e,t,r,n){var i,o=jt(e,t),l=e.display.view;if(!ko||r==e.doc.first+e.doc.size)return{index:o,lineN:r};for(var s=e.display.viewFrom,a=0;a0){if(o==l.length-1)return null;i=s+l[o].size-t,o++}else i=s-t;t+=i,r+=i}for(;ie(e.doc,r)!=r;){if(o==(n<0?0:l.length-1))return null;r+=n*l[o-(n<0?1:0)].size,o+=n}return{index:o,lineN:r}}function Or(e){for(var t=e.display.view,r=0,n=0;n=e.display.viewTo)){var r=+new Date+e.options.workTime,n=Ee(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 l=o.styles,s=o.text.length>e.options.maxHighlightLength?De(t.mode,n.state):null,a=Fe(e,o,n,!0);s&&(n.state=s),o.styles=a.styles;var u=o.styleClasses,c=a.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var h=!l||l.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),f=0;!h&&fr)return Ar(e,e.options.workDelay),!0}),t.highlightFrontier=n.line,t.modeFrontier=Math.max(t.modeFrontier,n.line),i.length&&xr(e,function(){for(var t=0;t=n.viewFrom&&r.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==Or(e))return!1;or(e)&&(Mr(e),r.dims=Bt(e));var s=i.first+i.size,a=Math.max(r.visible.from-e.options.viewportMargin,i.first),u=Math.min(s,r.visible.to+e.options.viewportMargin);n.viewFromu&&n.viewTo-u<20&&(u=Math.min(s,n.viewTo)),ko&&(a=ie(e.doc,a),u=oe(e.doc,u));var c=a!=n.viewFrom||u!=n.viewTo||n.lastWrapHeight!=r.wrapperHeight||n.lastWrapWidth!=r.wrapperWidth;!function(e,t,r){var n=e.display;0==n.view.length||t>=n.viewTo||r<=n.viewFrom?(n.view=qe(e,t,r),n.viewFrom=t):(n.viewFrom>t?n.view=qe(e,t,n.viewFrom).concat(n.view):n.viewFromr&&(n.view=n.view.slice(0,jt(e,r)))),n.viewTo=r}(e,a,u),n.viewOffset=ae(k(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var h=Or(e);if(!c&&0==h&&!r.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var d=function(e){if(e.hasFocus())return null;var t=l();if(!t||!o(e.display.lineDiv,t))return null;var r={activeElt:t};if(window.getSelection){var n=window.getSelection();n.anchorNode&&n.extend&&o(e.display.lineDiv,n.anchorNode)&&(r.anchorNode=n.anchorNode,r.anchorOffset=n.anchorOffset,r.focusNode=n.focusNode,r.focusOffset=n.focusOffset)}return r}(e);return h>4&&(n.lineDiv.style.display="none"),function(e,r,n){function i(t){var r=t.nextSibling;return Yi&&no&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),r}var o=e.display,l=e.options.lineNumbers,s=o.lineDiv,a=s.firstChild;for(var u=o.view,c=o.viewFrom,h=0;h-1&&(p=!1),Je(e,d,c,n)),p&&(t(d.lineNumber),d.lineNumber.appendChild(document.createTextNode(W(e.options,c)))),a=d.node.nextSibling}else{var g=it(e,d,c,n);s.insertBefore(g,a)}c+=d.size}for(;a;)a=i(a)}(e,n.updateLineNumbers,r.dims),h>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,function(e){if(e&&e.activeElt&&e.activeElt!=l()&&(e.activeElt.focus(),e.anchorNode&&o(document.body,e.anchorNode)&&o(document.body,e.focusNode))){var t=window.getSelection(),r=document.createRange();r.setEnd(e.anchorNode,e.anchorOffset),r.collapse(!1),t.removeAllRanges(),t.addRange(r),t.extend(e.focusNode,e.focusOffset)}}(d),t(n.cursorDiv),t(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,c&&(n.lastWrapHeight=r.wrapperHeight,n.lastWrapWidth=r.wrapperWidth,Ar(e,400)),n.updateLineNumbers=null,!0}function Hr(e,t){for(var r=t.viewport,n=!0;(n&&e.options.lineWrapping&&t.oldDisplayWidth!=dt(e)||(r&&null!=r.top&&(r={top:Math.min(e.doc.height+ct(e.display)-pt(e),r.top)}),t.visible=nr(e.display,e.doc,r),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&Wr(e,t);n=!1){tr(e);var i=gr(e);Xt(e),vr(e,i),Er(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 Fr(e,t){var r=new Jo(e,t);if(Wr(e,r)){tr(e),Hr(e,r);var n=gr(e);Xt(e),vr(e,n),Er(e,n),r.finish()}}function Pr(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function Er(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+ft(e)+"px"}function Ir(e){var r=e.display.gutters,i=e.options.gutters;t(r);for(var o=0;o-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function Rr(e){var t=e.wheelDeltaX,r=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==r&&e.detail&&e.axis==e.VERTICAL_AXIS?r=e.detail:null==r&&(r=e.wheelDelta),{x:t,y:r}}function Br(e){var t=Rr(e);return t.x*=tl,t.y*=tl,t}function Gr(e,t){var r=Rr(t),n=r.x,i=r.y,o=e.display,l=o.scroller,s=l.scrollWidth>l.clientWidth,a=l.scrollHeight>l.clientHeight;if(n&&s||i&&a){if(i&&no&&Yi)e:for(var u=t.target,c=o.view;u!=l;u=u.parentNode)for(var h=0;h0:a>=0){var u=z(s.from(),l.from()),c=I(s.to(),l.to()),h=s.empty()?l.from()==l.head:s.from()==s.head;o<=r&&--r,t.splice(--o,2,new nl(h?c:u,h?u:c))}}return new rl(t,r)}function Vr(e,t){return new rl([new nl(e,t||e)],0)}function Kr(e){return e.text?H(e.from.line+e.text.length-1,g(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function jr(e,t){if(F(e,t.from)<0)return e;if(F(e,t.to)<=0)return Kr(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+=Kr(t).ch-t.to.ch),H(r,n)}function Xr(e,t){for(var r=[],n=0;n1&&e.remove(s.line+1,p-1),e.insert(s.line+1,y)}Ze(e,"change",e,t)}function Qr(e,t,r){function n(e,i,o){if(e.linked)for(var l=0;ls-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(o=function(e,t){return t?(nn(e.done),g(e.done)):e.done.length&&!g(e.done).ranges?g(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),g(e.done)):void 0}(i,i.lastOp==n)))l=g(o.changes),0==F(t.from,t.to)&&0==F(t.from,l.to)?l.to=Kr(t):o.changes.push(rn(e,t));else{var a=g(i.done);for(a&&a.ranges||sn(e.sel,i.done),o={changes:[rn(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,l||ge(e,"historyAdded")}function ln(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||function(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)}(e,o,g(i.done),t))?i.done[i.done.length-1]=t:sn(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&!1!==n.clearRedo&&nn(i.undone)}function sn(e,t){var r=g(t);r&&r.ranges&&r.equals(e)||t.push(e)}function an(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 un(e){if(!e)return null;for(var t,r=0;r-1&&(g(s)[h]=u[h],delete u[h])}}}return n}function fn(e,t,r,n){if(n){var i=e.anchor;if(r){var o=F(t,i)<0;o!=F(r,i)<0?(i=t,t=r):o!=F(t,r)<0&&(t=r)}return new nl(i,t)}return new nl(r||t,t)}function dn(e,t,r,n,i){null==i&&(i=e.cm&&(e.cm.display.shift||e.extend)),yn(e,new rl([fn(e.sel.primary(),t,r,i)],0),n)}function pn(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&&(ge(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(r){var u=a.find(n<0?1:-1),c=void 0;if((n<0?a.inclusiveRight:a.inclusiveLeft)&&(u=kn(e,u,-n,u&&u.line==t.line?o:null)),u&&u.line==t.line&&(c=F(u,r))&&(n<0?c<0:c>0))return Sn(e,u,t,n,i)}var h=a.find(n<0?-1:1);return(n<0?a.inclusiveLeft:a.inclusiveRight)&&(h=kn(e,h,n,h.line==t.line?o:null)),h?Sn(e,h,t,n,i):null}}return t}function Ln(e,t,r,n,i){var o=n||1,l=Sn(e,t,r,o,i)||!i&&Sn(e,t,r,o,!0)||Sn(e,t,r,-o,i)||!i&&Sn(e,t,r,-o,!0);return l||(e.cantEdit=!0,H(e.first,0))}function kn(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?B(e,H(t.line-1)):null:r>0&&t.ch==(n||k(e,t.line)).text.length?t.line0)){var c=[a,1],h=F(u.from,s.from),d=F(u.to,s.to);(h<0||!l.inclusiveLeft&&!h)&&c.push({from:u.from,to:s.from}),(d>0||!l.inclusiveRight&&!d)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),a+=c.length-3}}return i}(e,t.from,t.to);if(n)for(var i=n.length-1;i>=0;--i)On(e,{from:n[i].from,to:n[i].to,text:i?[""]:t.text,origin:t.origin});else On(e,t)}}function On(e,t){if(1!=t.text.length||""!=t.text[0]||0!=F(t.from,t.to)){var r=Xr(e,t);on(e,t,r,e.cm?e.cm.curOp.id:NaN),Wn(e,t,r,j(e,t));var n=[];Qr(e,function(e,r){r||-1!=f(n,e.history)||(En(e.history,t),n.push(e.history)),Wn(e,t,null,j(e,t))})}}function An(e,t,r){var n=e.cm&&e.cm.state.suppressEdits;if(!n||r){for(var i,o=e.history,l=e.sel,s="undo"==t?o.done:o.undone,a="undo"==t?o.undone:o.done,u=0;u=0;--p){var v=d(p);if(v)return v.v}}}}function Dn(e,t){if(0!=t&&(e.first+=t,e.sel=new rl(v(e.sel.ranges,function(e){return new nl(H(e.anchor.line+t,e.anchor.ch),H(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){kr(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:H(o,k(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=T(e,t.from,t.to),r||(r=Xr(e,t)),e.cm?function(e,t,r){var n=e.doc,i=e.display,o=t.from,l=t.to,s=!1,a=o.line;e.options.lineWrapping||(a=O(ne(k(n,o.line))),n.iter(a,l.line+1,function(e){if(e==i.maxLine)return s=!0,!0}));n.sel.contains(t.from,t.to)>-1&&me(e);Zr(n,t,r,Ut(e)),e.options.lineWrapping||(n.iter(a,o.line+t.text.length,function(e){var t=ue(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0));(function(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontierr;n--){var i=k(e,n).stateAfter;if(i&&(!(i instanceof Ro)||n+i.lookAhead0||0==s&&!1!==l.clearWhenEmpty)return l;if(l.replacedWith&&(l.collapsed=!0,l.widgetNode=i("span",[l.replacedWith],"CodeMirror-widget"),n.handleMouseEvents||l.widgetNode.setAttribute("cm-ignore-events","true"),n.insertLeft&&(l.widgetNode.insertLeft=!0)),l.collapsed){if(re(e,t.line,t,r,l)||t.line!=r.line&&re(e,r.line,t,r,l))throw new Error("Inserting collapsed marker partially overlapping an existing one");ko=!0}l.addToHistory&&on(e,{from:t,to:r,origin:"markText"},e.sel,NaN);var a,u=t.line,h=e.cm;if(e.iter(u,r.line+1,function(e){h&&l.collapsed&&!h.options.lineWrapping&&ne(e)==h.display.maxLine&&(a=!0),l.collapsed&&u!=t.line&&N(e,0),function(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}(e,new U(l,u==t.line?t.ch:null,u==r.line?r.ch:null)),++u}),l.collapsed&&e.iter(t.line,r.line+1,function(t){le(e,t)&&N(t,0)}),l.clearOnEnter&&Oo(l,"beforeCursorEnter",function(){return l.clear()}),l.readOnly&&(Lo=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),l.collapsed&&(l.id=++ol,l.atomic=!0),h){if(a&&(h.curOp.updateMaxLine=!0),l.collapsed)kr(h,t.line,r.line+1);else if(l.className||l.startStyle||l.endStyle||l.css||l.attributes||l.title)for(var f=t.line;f<=r.line;f++)Tr(h,f,"text");l.atomic&&xn(h.doc),Ze(h,"markerAdded",h,l)}return l}function Un(e){return e.findMarks(H(e.first,0),e.clipPos(H(e.lastLine())),function(e){return e.parent})}function Vn(e){for(var t=function(t){var r=e[t],n=[r.primary.doc];Qr(r.primary.doc,function(e){return n.push(e)});for(var i=0;i-1)return t.state.draggingText(e),void setTimeout(function(){return t.display.input.focus()},20);try{var u=e.dataTransfer.getData("Text");if(u){var c;if(t.state.draggingText&&!t.state.draggingText.copy&&(c=t.listSelections()),bn(t.doc,Vr(r,r)),c)for(var h=0;h=0;t--)Hn(e.doc,"",n[t].from,n[t].to,"+delete");ar(e)})}function ni(e,t,r){var n=S(e.text,t+r,r);return n<0||n>e.text.length?null:n}function ii(e,t,r){var n=ni(e,t.ch,r);return null==n?null:new H(t.line,n,r<0?"after":"before")}function oi(e,t,r,n,i){if(e){var o=fe(r,t.doc.direction);if(o){var l,s=i<0?g(o):o[0],a=i<0==(1==s.level)?"after":"before";if(s.level>0||"rtl"==t.doc.direction){var u=yt(t,r);l=i<0?r.text.length-1:0;var c=bt(t,u,l).top;l=L(function(e){return bt(t,u,e).top==c},i<0==(1==s.level)?s.from:s.to-1,l),"before"==a&&(l=ni(r,l,1))}else l=i<0?s.to:s.from;return new H(n,l,a)}}return new H(n,i<0?r.text.length:0,i<0?"before":"after")}function li(e,t){var r=k(e.doc,t),n=ne(r);return n!=r&&(t=O(n)),oi(!0,e,n,t,1)}function si(e,t){var r=k(e.doc,t),n=function(e){for(var t;t=ee(e);)e=t.find(1,!0).line;return e}(r);return n!=r&&(t=O(n)),oi(!0,e,r,t,-1)}function ai(e,t){var r=li(e,t.line),n=k(e.doc,r.line),i=fe(n,e.doc.direction);if(!i||0==i[0].level){var o=Math.max(0,n.text.search(/\S/)),l=t.line==r.line&&t.ch<=o&&t.ch;return H(r.line,l?0:o,r.sticky)}return r}function ui(e,t,r){if("string"==typeof t&&!(t=ml[t]))return!1;e.display.input.ensurePolled();var n=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),r&&(e.display.shift=!1),i=t(e)!=mo}finally{e.display.shift=n,e.state.suppressEdits=!1}return i}function ci(e,t,r,n){var i=e.state.keySeq;if(i){if(Qn(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:yl.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),hi(e,i+" "+t,r,n))return!0}return hi(e,t,r,n)}function hi(e,t,r,n){var i=function(e,t,r){for(var n=0;n-1&&(F((i=s.ranges[i]).from(),t)<0||t.xRel>0)&&(F(i.to(),t)>0||t.xRel<0)?function(e,t,r,n){var i=e.display,o=!1,l=Cr(e,function(t){Yi&&(i.scroller.draggable=!1),e.state.draggingText=!1,pe(i.wrapper.ownerDocument,"mouseup",l),pe(i.wrapper.ownerDocument,"mousemove",s),pe(i.scroller,"dragstart",a),pe(i.scroller,"drop",l),o||(we(t),n.addNew||dn(e.doc,r,null,null,n.extend),Yi||ji&&9==Xi?setTimeout(function(){i.wrapper.ownerDocument.body.focus(),i.input.focus()},20):i.input.focus())}),s=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},a=function(){return o=!0};Yi&&(i.scroller.draggable=!0);e.state.draggingText=l,l.copy=!n.moveOnDrag,i.scroller.dragDrop&&i.scroller.dragDrop();Oo(i.wrapper.ownerDocument,"mouseup",l),Oo(i.wrapper.ownerDocument,"mousemove",s),Oo(i.scroller,"dragstart",a),Oo(i.scroller,"drop",l),Qt(e),setTimeout(function(){return i.input.focus()},20)}(e,n,t,o):function(e,t,r,n){function i(t){if(0!=F(m,t))if(m=t,"rectangle"==n.unit){for(var i=[],o=e.options.tabSize,l=h(k(u,r.line).text,r.ch,o),s=h(k(u,t.line).text,t.ch,o),a=Math.min(l,s),g=Math.max(l,s),v=Math.min(r.line,t.line),y=Math.min(e.lastLine(),Math.max(r.line,t.line));v<=y;v++){var b=k(u,v).text,w=d(b,a,o);a==g?i.push(new nl(H(v,w),H(v,w))):b.length>w&&i.push(new nl(H(v,w),H(v,d(b,g,o))))}i.length||i.push(new nl(r,r)),yn(u,Ur(e,p.ranges.slice(0,f).concat(i),f),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var x,C=c,S=mi(e,t,n.unit),L=C.anchor;F(S.anchor,L)>0?(x=S.head,L=z(C.from(),S.anchor)):(x=S.anchor,L=I(C.to(),S.head));var T=p.ranges.slice(0);T[f]=function(e,t){var r=t.anchor,n=t.head,i=k(e.doc,r.line);if(0==F(r,n)&&r.sticky==n.sticky)return t;var o=fe(i);if(!o)return t;var l=he(o,r.ch,r.sticky),s=o[l];if(s.from!=r.ch&&s.to!=r.ch)return t;var a=l+(s.from==r.ch==(1!=s.level)?0:1);if(0==a||a==o.length)return t;var u;if(n.line!=r.line)u=(n.line-r.line)*("ltr"==e.doc.direction?1:-1)>0;else{var c=he(o,n.ch,n.sticky),h=c-l||(n.ch-r.ch)*(1==s.level?-1:1);u=c==a-1||c==a?h<0:h>0}var f=o[a+(u?-1:0)],d=u==(1==f.level),p=d?f.from:f.to,g=d?"after":"before";return r.ch==p&&r.sticky==g?t:new nl(new H(r.line,p,g),n)}(e,new nl(B(u,L),x)),yn(u,Ur(e,T,f),bo)}}function o(t){var r=++b,s=Kt(e,t,!0,"rectangle"==n.unit);if(s)if(0!=F(s,m)){e.curOp.focus=l(),i(s);var c=nr(a,u);(s.line>=c.to||s.liney.bottom?20:0;h&&setTimeout(Cr(e,function(){b==r&&(a.scroller.scrollTop+=h,o(t))}),50)}}function s(t){e.state.selectingText=!1,b=1/0,we(t),a.input.focus(),pe(a.wrapper.ownerDocument,"mousemove",w),pe(a.wrapper.ownerDocument,"mouseup",x),u.history.lastSelOrigin=null}var a=e.display,u=e.doc;we(t);var c,f,p=u.sel,g=p.ranges;n.addNew&&!n.extend?(f=u.sel.contains(r),c=f>-1?g[f]:new nl(r,r)):(c=u.sel.primary(),f=u.sel.primIndex);if("rectangle"==n.unit)n.addNew||(c=new nl(r,r)),r=Kt(e,t,!0,!0),f=-1;else{var v=mi(e,r,n.unit);c=n.extend?fn(c,v.anchor,v.head,n.extend):v}n.addNew?-1==f?(f=g.length,yn(u,Ur(e,g.concat([c]),f),{scroll:!1,origin:"*mouse"})):g.length>1&&g[f].empty()&&"char"==n.unit&&!n.extend?(yn(u,Ur(e,g.slice(0,f).concat(g.slice(f+1)),0),{scroll:!1,origin:"*mouse"}),p=u.sel):gn(u,f,c,bo):(f=0,yn(u,new rl([c],0),bo),p=u.sel);var m=r;var y=a.wrapper.getBoundingClientRect(),b=0;var w=Cr(e,function(e){0!==e.buttons&&ke(e)?o(e):s(e)}),x=Cr(e,s);e.state.selectingText=x,Oo(a.wrapper.ownerDocument,"mousemove",w),Oo(a.wrapper.ownerDocument,"mouseup",x)}(e,n,t,o)}(this,r,i,e):Le(e)==t.scroller&&we(e):2==n?(r&&dn(this.doc,r),setTimeout(function(){return t.input.focus()},20)):3==n&&(uo?this.display.input.onContextMenu(e):Qt(this)))}}function mi(e,t,r){if("char"==r)return new nl(t,t);if("word"==r)return e.findWordAt(t);if("line"==r)return new nl(H(t.line,0),B(e.doc,H(t.line+1,0)));var n=r(e,t);return new nl(n.from,n.to)}function yi(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(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;n&&we(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!ye(e,r))return Ce(t);o-=s.top-l.viewOffset;for(var a=0;a=i){return ge(e,r,e,A(e.doc,o),e.options.gutters[a],t),Ce(t)}}}function bi(e,t){return yi(e,t,"gutterClick",!0)}function wi(e,t){at(e.display,t)||function(e,t){if(!ye(e,"gutterContextMenu"))return!1;return yi(e,t,"gutterContextMenu",!1)}(e,t)||ve(e,t,"contextmenu")||uo||e.display.input.onContextMenu(t)}function xi(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),Lt(e)}function Ci(e){Ir(e),kr(e),ir(e)}function Si(e,t,r){if(!t!=!(r&&r!=Sl)){var n=e.display.dragFunctions,i=t?Oo:pe;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 Li(e){e.options.lineWrapping?(s(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(co(e.display.wrapper,"CodeMirror-wrap"),ce(e)),Vt(e),kr(e),Lt(e),setTimeout(function(){return vr(e)},100)}function ki(e,t){var o=this;if(!(this instanceof ki))return new ki(e,t);this.options=t=t?c(t):{},c(Ll,t,!1),zr(t);var l=t.value;"string"==typeof l?l=new ul(l,t.mode,null,t.lineSeparator,t.direction):t.mode&&(l.modeOption=t.mode),this.doc=l;var s=new ki.inputStyles[t.inputStyle](this),a=this.display=new function(e,t,r){this.input=r,this.scrollbarFiller=n("div",null,"CodeMirror-scrollbar-filler"),this.scrollbarFiller.setAttribute("cm-not-content","true"),this.gutterFiller=n("div",null,"CodeMirror-gutter-filler"),this.gutterFiller.setAttribute("cm-not-content","true"),this.lineDiv=i("div",null,"CodeMirror-code"),this.selectionDiv=n("div",null,null,"position: relative; z-index: 1"),this.cursorDiv=n("div",null,"CodeMirror-cursors"),this.measure=n("div",null,"CodeMirror-measure"),this.lineMeasure=n("div",null,"CodeMirror-measure"),this.lineSpace=i("div",[this.measure,this.lineMeasure,this.selectionDiv,this.cursorDiv,this.lineDiv],null,"position: relative; outline: none");var o=i("div",[this.lineSpace],"CodeMirror-lines");this.mover=n("div",[o],null,"position: relative"),this.sizer=n("div",[this.mover],"CodeMirror-sizer"),this.sizerWidth=null,this.heightForcer=n("div",null,null,"position: absolute; height: "+vo+"px; width: 1px;"),this.gutters=n("div",null,"CodeMirror-gutters"),this.lineGutter=null,this.scroller=n("div",[this.sizer,this.heightForcer,this.gutters],"CodeMirror-scroll"),this.scroller.setAttribute("tabIndex","-1"),this.wrapper=n("div",[this.scrollbarFiller,this.gutterFiller,this.scroller],"CodeMirror"),ji&&Xi<8&&(this.gutters.style.zIndex=-1,this.scroller.style.paddingRight=0),Yi||Gi&&ro||(this.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(this.wrapper):e(this.wrapper)),this.viewFrom=this.viewTo=t.first,this.reportedViewFrom=this.reportedViewTo=t.first,this.view=[],this.renderedView=null,this.externalMeasured=null,this.viewOffset=0,this.lastWrapHeight=this.lastWrapWidth=0,this.updateLineNumbers=null,this.nativeBarWidth=this.barHeight=this.barWidth=0,this.scrollbarsClipped=!1,this.lineNumWidth=this.lineNumInnerWidth=this.lineNumChars=null,this.alignWidgets=!1,this.cachedCharWidth=this.cachedTextHeight=this.cachedPaddingH=null,this.maxLine=null,this.maxLineLength=0,this.maxLineChanged=!1,this.wheelDX=this.wheelDY=this.wheelStartX=this.wheelStartY=null,this.shift=!1,this.selForContextMenu=null,this.activeTouch=null,r.init(this)}(e,l,s);a.wrapper.CodeMirror=this,Ir(this),xi(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),yr(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 fo,keySeq:null,specialChars:null},t.autofocus&&!ro&&a.input.focus(),ji&&Xi<11&&setTimeout(function(){return o.display.input.reset(!0)},20),function(e){function t(){o.activeTouch&&(l=setTimeout(function(){return o.activeTouch=null},1e3),(s=o.activeTouch).end=+new Date)}function i(e,t){if(null==t.left)return!0;var r=t.left-e.left,n=t.top-e.top;return r*r+n*n>400}var o=e.display;Oo(o.scroller,"mousedown",Cr(e,vi)),Oo(o.scroller,"dblclick",ji&&Xi<11?Cr(e,function(t){if(!ve(e,t)){var r=Kt(e,t);if(r&&!bi(e,t)&&!at(e.display,t)){we(t);var n=e.findWordAt(r);dn(e.doc,n.anchor,n.head)}}}):function(t){return ve(e,t)||we(t)});Oo(o.scroller,"contextmenu",function(t){return wi(e,t)});var l,s={end:0};Oo(o.scroller,"touchstart",function(t){if(!ve(e,t)&&!function(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}(t)&&!bi(e,t)){o.input.ensurePolled(),clearTimeout(l);var r=+new Date;o.activeTouch={start:r,moved:!1,prev:r-s.end<=300?s:null},1==t.touches.length&&(o.activeTouch.left=t.touches[0].pageX,o.activeTouch.top=t.touches[0].pageY)}}),Oo(o.scroller,"touchmove",function(){o.activeTouch&&(o.activeTouch.moved=!0)}),Oo(o.scroller,"touchend",function(r){var n=o.activeTouch;if(n&&!at(o,r)&&null!=n.left&&!n.moved&&new Date-n.start<300){var l,s=e.coordsChar(o.activeTouch,"page");l=!n.prev||i(n,n.prev)?new nl(s,s):!n.prev.prev||i(n,n.prev.prev)?e.findWordAt(s):new nl(H(s.line,0),B(e.doc,H(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),we(r)}t()}),Oo(o.scroller,"touchcancel",t),Oo(o.scroller,"scroll",function(){o.scroller.clientHeight&&(fr(e,o.scroller.scrollTop),pr(e,o.scroller.scrollLeft,!0),ge(e,"scroll",e))}),Oo(o.scroller,"mousewheel",function(t){return Gr(e,t)}),Oo(o.scroller,"DOMMouseScroll",function(t){return Gr(e,t)}),Oo(o.wrapper,"scroll",function(){return o.wrapper.scrollTop=o.wrapper.scrollLeft=0}),o.dragFunctions={enter:function(t){ve(e,t)||Se(t)},over:function(t){ve(e,t)||(!function(e,t){var i=Kt(e,t);if(i){var o=document.createDocumentFragment();_t(e,i,o),e.display.dragCursor||(e.display.dragCursor=n("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),r(e.display.dragCursor,o)}}(e,t),Se(t))},start:function(t){return function(e,t){if(ji&&(!e.state.draggingText||+new Date-cl<100))Se(t);else if(!ve(e,t)&&!at(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!Zi)){var r=n("img",null,null,"position: fixed; left: 0; top: 0;");r.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",qi&&(r.width=r.height=1,e.display.wrapper.appendChild(r),r._top=r.offsetTop),t.dataTransfer.setDragImage(r,0,0),qi&&r.parentNode.removeChild(r)}}(e,t)},drop:Cr(e,Kn),leave:function(t){ve(e,t)||jn(e)}};var a=o.input.getField();Oo(a,"keyup",function(t){return pi.call(e,t)}),Oo(a,"keydown",Cr(e,di)),Oo(a,"keypress",Cr(e,gi)),Oo(a,"focus",function(t){return Jt(e,t)}),Oo(a,"blur",function(t){return er(e,t)})}(this),Yn(),br(this),this.curOp.forceUpdate=!0,Jr(this,l),t.autofocus&&!ro||this.hasFocus()?setTimeout(u(Jt,this),20):er(this);for(var h in kl)kl.hasOwnProperty(h)&&kl[h](o,t[h],Sl);or(this),t.finishInit&&t.finishInit(this);for(var f=0;f150)){if(!n)return;r="prev"}}else u=0,r="not";"prev"==r?u=t>o.first?h(k(o,t-1).text,null,l):0:"add"==r?u=a+e.options.indentUnit:"subtract"==r?u=a-e.options.indentUnit:"number"==typeof r&&(u=a+r),u=Math.max(0,u);var f="",d=0;if(e.options.indentWithTabs)for(var g=Math.floor(u/l);g;--g)d+=l,f+="\t";if(d1)if(Ml&&Ml.text.join("\n")==t){if(n.ranges.length%Ml.text.length==0){a=[];for(var u=0;u=0;h--){var f=n.ranges[h],d=f.from(),p=f.to();f.empty()&&(r&&r>0?d=H(d.line,d.ch-r):e.state.overwrite&&!l?p=H(p.line,Math.min(k(o,p.line).text.length,p.ch+g(s).length)):l&&Ml&&Ml.lineWise&&Ml.text.join("\n")==t&&(d=p=H(d.line,0)));var m={from:d,to:p,text:a?a[h%a.length]:s,origin:i||(l?"paste":e.state.cutIncoming?"cut":"+input")};Nn(e.doc,m),Ze(e,"inputRead",e,m)}t&&!l&&Ai(e,t),ar(e),e.curOp.updateInput<2&&(e.curOp.updateInput=c),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function Oi(e,t){var r=e.clipboardData&&e.clipboardData.getData("Text");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||xr(t,function(){return Ni(t,r,0,null,"paste")}),!0}function Ai(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),l=!1;if(o.electricChars){for(var s=0;s-1){l=Ti(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(k(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=Ti(e,i.head.line,"smart"));l&&Ze(e,"electricInput",e,i.head.line)}}}function Di(e){for(var t=[],r=[],n=0;n=t.text.length?(r.ch=t.text.length,r.sticky="before"):r.ch<=0&&(r.ch=0,r.sticky="after");var o=he(i,r.ch,r.sticky),l=i[o];if("ltr"==e.doc.direction&&l.level%2==0&&(n>0?l.to>r.ch:l.from=l.from&&f>=c.begin)){var d=h?"before":"after";return new H(r.line,f,d)}}var p=function(e,t,n){for(var o=function(e,t){return t?new H(r.line,a(e,1),"before"):new H(r.line,e,"after")};e>=0&&e0==(1!=l.level),u=s?n.begin:a(n.end,-1);if(l.from<=u&&u0?c.end:a(c.begin,-1);return null==v||n>0&&v==t.text.length||!(g=p(n>0?0:i.length-1,n,u(v)))?null:g}(e.cm,a,t,r):ii(a,t,r))){if(n||!function(){var n=t.line+r;return!(n=e.first+e.size)&&(t=new H(n,t.ch,t.sticky),a=k(e,n))}())return!1;t=oi(i,e.cm,a,t.line,r)}else t=o;return!0}var l=t,s=r,a=k(e,t.line);if("char"==n)o();else if("column"==n)o(!0);else if("word"==n||"group"==n)for(var u=null,c="group"==n,h=e.cm&&e.cm.getHelper(t,"wordChars"),f=!0;!(r<0)||o(!f);f=!1){var d=a.text.charAt(t.ch)||"\n",p=w(d,h)?"w":c&&"\n"==d?"n":!c||/\s/.test(d)?null:"p";if(!c||f||p||(p="s"),u&&u!=p){r<0&&(r=1,o(),t.sticky="after");break}if(p&&(u=p),r>0&&!o(!f))break}var g=Ln(e,t,l,s,!0);return P(l,g)&&(g.hitSide=!0),g}function Pi(e,t,r,n){var i,o=e.doc,l=t.left;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),a=Math.max(s-.5*zt(e.display),3);i=(r>0?t.bottom:t.top)+r*a}else"line"==n&&(i=r>0?t.bottom+3:t.top-3);for(var u;(u=Ft(e,l,i)).outside;){if(r<0?i<=0:i>=o.height){u.hitSide=!0;break}i+=5*r}return u}function Ei(e,t){var r=mt(e,t.line);if(!r||r.hidden)return null;var n=k(e.doc,t.line),i=gt(r,n,t.line),o=fe(n,e.doc.direction),l="left";if(o){l=he(o,t.ch)%2?"right":"left"}var s=wt(i.map,t.ch,l);return s.offset="right"==s.collapse?s.end:s.start,s}function Ii(e,t){return t&&(e.bad=!0),e}function zi(e,t,r){var n;if(t==e.display.lineDiv){if(!(n=e.display.lineDiv.childNodes[r]))return Ii(e.clipPos(H(e.display.viewTo-1)),!0);t=null,r=0}else for(n=t;;n=n.parentNode){if(!n||n==e.display.lineDiv)return null;if(n.parentNode&&n.parentNode==e.display.lineDiv)break}for(var i=0;i=15&&(qi=!1,Yi=!0);var so,ao=no&&(_i||qi&&(null==lo||lo<12.11)),uo=Gi||ji&&Xi>=9,co=function(t,r){var n=t.className,i=e(r).exec(n);if(i){var o=n.slice(i.index+i[0].length);t.className=n.slice(0,i.index)+(o?i[1]+o:"")}};so=document.createRange?function(e,t,r,n){var i=document.createRange();return i.setEnd(n||e,r),i.setStart(e,t),i}:function(e,t,r){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(e){return n}return n.collapse(!0),n.moveEnd("character",r),n.moveStart("character",t),n};var ho=function(e){e.select()};eo?ho=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:ji&&(ho=function(e){try{e.select()}catch(e){}});var fo=function(){this.id=null};fo.prototype.set=function(e,t){clearTimeout(this.id),this.id=setTimeout(t,e)};var po,go,vo=30,mo={toString:function(){return"CodeMirror.Pass"}},yo={scroll:!1},bo={origin:"*mouse"},wo={origin:"+move"},xo=[""],Co=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,So=/[\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]/,Lo=!1,ko=!1,To=null,Mo=function(){function e(e){return e<=247?r.charAt(e):1424<=e&&e<=1524?"R":1536<=e&&e<=1785?n.charAt(e-1536):1774<=e&&e<=2220?"r":8192<=e&&e<=8203?"w":8204==e?"b":"L"}function t(e,t,r){this.level=e,this.from=t,this.to=r}var r="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",n="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,l=/[LRr]/,s=/[Lb1n]/,a=/[1n]/;return function(r,n){var u="ltr"==n?"L":"R";if(0==r.length||"ltr"==n&&!i.test(r))return!1;for(var c=r.length,h=[],f=0;f=this.string.length},zo.prototype.sol=function(){return this.pos==this.lineStart},zo.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},zo.prototype.next=function(){if(this.post},zo.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},zo.prototype.skipToEnd=function(){this.pos=this.string.length},zo.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},zo.prototype.backUp=function(e){this.pos-=e},zo.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},zo.prototype.current=function(){return this.string.slice(this.start,this.pos)},zo.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},zo.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},zo.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var Ro=function(e,t){this.state=e,this.lookAhead=t},Bo=function(e,t,r,n){this.state=t,this.doc=e,this.line=r,this.maxLookAhead=n||0,this.baseTokens=null,this.baseTokenPos=1};Bo.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Bo.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}},Bo.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Bo.fromSaved=function(e,t,r){return t instanceof Ro?new Bo(e,De(e.mode,t.state),r,t.lookAhead):new Bo(e,De(e.mode,t),r)},Bo.prototype.save=function(e){var t=!1!==e?De(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Ro(t,this.maxLookAhead):t};var Go=function(e,t,r){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=r},Uo=function(e,t,r){this.text=e,_(this,t),this.height=r?r(this):1};Uo.prototype.lineNo=function(){return O(this)},be(Uo);var Vo,Ko={},jo={},Xo=null,Yo=null,_o={left:0,right:0,top:0,bottom:0},$o=function(e,t,r){this.cm=r;var i=this.vert=n("div",[n("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),o=this.horiz=n("div",[n("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");i.tabIndex=o.tabIndex=-1,e(i),e(o),Oo(i,"scroll",function(){i.clientHeight&&t(i.scrollTop,"vertical")}),Oo(o,"scroll",function(){o.clientWidth&&t(o.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,ji&&Xi<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};$o.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.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}},$o.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},$o.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},$o.prototype.zeroWidthHack=function(){var e=no&&!Qi?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new fo,this.disableVert=new fo},$o.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.pointerEvents="none":t.set(1e3,n)}e.style.pointerEvents="auto",t.set(1e3,n)},$o.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var qo=function(){};qo.prototype.update=function(){return{bottom:0,right:0}},qo.prototype.setScrollLeft=function(){},qo.prototype.setScrollTop=function(){},qo.prototype.clear=function(){};var Zo={native:$o,null:qo},Qo=0,Jo=function(e,t,r){var n=e.display;this.viewport=t,this.visible=nr(n,e.doc,t),this.editorIsHidden=!n.wrapper.offsetWidth,this.wrapperHeight=n.wrapper.clientHeight,this.wrapperWidth=n.wrapper.clientWidth,this.oldDisplayWidth=dt(e),this.force=r,this.dims=Bt(e),this.events=[]};Jo.prototype.signal=function(e,t){ye(e,t)&&this.events.push(arguments)},Jo.prototype.finish=function(){for(var e=0;e=0&&F(e,n.to())<=0)return r}return-1};var nl=function(e,t){this.anchor=e,this.head=t};nl.prototype.from=function(){return z(this.anchor,this.head)},nl.prototype.to=function(){return I(this.anchor,this.head)},nl.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},zn.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var r=e,n=e+t;r1||!(this.children[0]instanceof zn))){var s=[];this.collapse(s),this.children=[new zn(s)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var l=i.lines.length%25+25,s=l;s10);e.parent.maybeSpill()}},iterN:function(e,t,r){for(var n=0;ne.display.maxLineLength&&(e.display.maxLine=u,e.display.maxLineLength=c,e.display.maxLineChanged=!0)}null!=n&&e&&this.collapsed&&kr(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&xn(e.doc)),e&&Ze(e,"markerCleared",e,this,n,i),t&&wr(e),this.parent&&this.parent.clear()}},ll.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var r,n,i=0;i=0;a--)Nn(this,n[a]);s?mn(this,s):this.cm&&ar(this.cm)}),undo:Lr(function(){An(this,"undo")}),redo:Lr(function(){An(this,"redo")}),undoSelection:Lr(function(){An(this,"undo",!0)}),redoSelection:Lr(function(){An(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=B(this,e),t=B(this,t);var n=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var l=o.markedSpans;if(l)for(var s=0;s=a.to||null==a.from&&i!=e.line||null!=a.from&&i==t.line&&a.from>=t.ch||r&&!r(a.marker)||n.push(a.marker.parent||a.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}),B(this,H(r,t))},indexFromPos:function(e){var t=(e=B(this,e)).ch;if(e.linet&&(t=e.from),null!=e.to&&e.to0)i=new H(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),H(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=k(e.doc,i.line-1).text;l&&(i=new H(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),H(i.line-1,l.length-1),i,"+transpose"))}r.push(new nl(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){return xr(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;ne&&0==F(t,this.pos)&&r==this.button};var xl,Cl,Sl={toString:function(){return"CodeMirror.Init"}},Ll={},kl={};ki.defaults=Ll,ki.optionHandlers=kl;var Tl=[];ki.defineInitHook=function(e){return Tl.push(e)};var Ml=null,Nl=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new fo,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};Nl.prototype.init=function(e){function t(e){if(!ve(i,e)){if(i.somethingSelected())Mi({lineWise:!1,text:i.getSelections()}),"cut"==e.type&&i.replaceSelection("",null,"cut");else{if(!i.options.lineWiseCopyCut)return;var t=Di(i);Mi({lineWise:!0,text:t.text}),"cut"==e.type&&i.operation(function(){i.setSelections(t.ranges,0,yo),i.replaceSelection("",null,"cut")})}if(e.clipboardData){e.clipboardData.clearData();var r=Ml.text.join("\n");if(e.clipboardData.setData("Text",r),e.clipboardData.getData("Text")==r)return void e.preventDefault()}var l=Hi(),s=l.firstChild;i.display.lineSpace.insertBefore(l,i.display.lineSpace.firstChild),s.value=Ml.text.join("\n");var a=document.activeElement;ho(s),setTimeout(function(){i.display.lineSpace.removeChild(l),a.focus(),a==o&&n.showPrimarySelection()},50)}}var r=this,n=this,i=n.cm,o=n.div=e.lineDiv;Wi(o,i.options.spellcheck),Oo(o,"paste",function(e){ve(i,e)||Oi(e,i)||Xi<=11&&setTimeout(Cr(i,function(){return r.updateFromDOM()}),20)}),Oo(o,"compositionstart",function(e){r.composing={data:e.data,done:!1}}),Oo(o,"compositionupdate",function(e){r.composing||(r.composing={data:e.data,done:!1})}),Oo(o,"compositionend",function(e){r.composing&&(e.data!=r.composing.data&&r.readFromDOMSoon(),r.composing.done=!0)}),Oo(o,"touchstart",function(){return n.forceCompositionEnd()}),Oo(o,"input",function(){r.composing||r.readFromDOMSoon()}),Oo(o,"copy",t),Oo(o,"cut",t)},Nl.prototype.prepareSelection=function(){var e=Yt(this.cm,!1);return e.focus=this.cm.state.focused,e},Nl.prototype.showSelection=function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},Nl.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Nl.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,r=t.doc.sel.primary(),n=r.from(),i=r.to();if(t.display.viewTo==t.display.viewFrom||n.line>=t.display.viewTo||i.line=t.display.viewFrom&&Ei(t,n)||{node:s[0].measure.map[2],offset:0},u=i.linee.firstLine()&&(n=H(n.line-1,k(e.doc,n.line-1).length)),i.ch==k(e.doc,i.line).text.length&&i.linet.viewTo-1)return!1;var o,l,s;n.line==t.viewFrom||0==(o=jt(e,n.line))?(l=O(t.view[0].line),s=t.view[0].node):(l=O(t.view[o].line),s=t.view[o-1].node.nextSibling);var a,u,c=jt(e,i.line);if(c==t.view.length-1?(a=t.viewTo-1,u=t.lineDiv.lastChild):(a=O(t.view[c+1].line)-1,u=t.view[c+1].node.previousSibling),!s)return!1;for(var h=e.doc.splitLines(function(e,t,r,n,i){function o(){u&&(a+=c,h&&(a+=c),u=h=!1)}function l(e){e&&(o(),a+=e)}function s(t){if(1==t.nodeType){var r=t.getAttribute("cm-text");if(r)return void l(r);var a,f=t.getAttribute("cm-marker");if(f){var d=e.findMarks(H(n,0),H(i+1,0),function(e){return function(t){return t.id==e}}(+f));return void(d.length&&(a=d[0].find(0))&&l(T(e.doc,a.from,a.to).join(c)))}if("false"==t.getAttribute("contenteditable"))return;var p=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;p&&o();for(var g=0;g1&&f.length>1;)if(g(h)==g(f))h.pop(),f.pop(),a--;else{if(h[0]!=f[0])break;h.shift(),f.shift(),l++}for(var d=0,p=0,v=h[0],m=f[0],y=Math.min(v.length,m.length);dn.ch&&b.charCodeAt(b.length-p-1)==w.charCodeAt(w.length-p-1);)d--,p++;h[h.length-1]=b.slice(0,b.length-p).replace(/^\u200b+/,""),h[0]=h[0].slice(d).replace(/\u200b+$/,"");var C=H(l,d),S=H(a,f.length?g(f).length-p:0);return h.length>1||h[0]||F(C,S)?(Hn(e.doc,h,C,S,"+input"),!0):void 0},Nl.prototype.ensurePolled=function(){this.forceCompositionEnd()},Nl.prototype.reset=function(){this.forceCompositionEnd()},Nl.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Nl.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))},Nl.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||xr(this.cm,function(){return kr(e.cm)})},Nl.prototype.setUneditable=function(e){e.contentEditable="false"},Nl.prototype.onKeyPress=function(e){0==e.charCode||this.composing||(e.preventDefault(),this.cm.isReadOnly()||Cr(this.cm,Ni)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},Nl.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},Nl.prototype.onContextMenu=function(){},Nl.prototype.resetPosition=function(){},Nl.prototype.needsContentAttribute=!0;var Ol=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new fo,this.hasSelection=!1,this.composing=null};Ol.prototype.init=function(e){function t(e){if(!ve(i,e)){if(i.somethingSelected())Mi({lineWise:!1,text:i.getSelections()});else{if(!i.options.lineWiseCopyCut)return;var t=Di(i);Mi({lineWise:!0,text:t.text}),"cut"==e.type?i.setSelections(t.ranges,null,yo):(n.prevInput="",o.value=t.text.join("\n"),ho(o))}"cut"==e.type&&(i.state.cutIncoming=!0)}}var r=this,n=this,i=this.cm;this.createField(e);var o=this.textarea;e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),eo&&(o.style.width="0px"),Oo(o,"input",function(){ji&&Xi>=9&&r.hasSelection&&(r.hasSelection=null),n.poll()}),Oo(o,"paste",function(e){ve(i,e)||Oi(e,i)||(i.state.pasteIncoming=!0,n.fastPoll())}),Oo(o,"cut",t),Oo(o,"copy",t),Oo(e.scroller,"paste",function(t){at(e,t)||ve(i,t)||(i.state.pasteIncoming=!0,n.focus())}),Oo(e.lineSpace,"selectstart",function(t){at(e,t)||we(t)}),Oo(o,"compositionstart",function(){var e=i.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:i.markText(e,i.getCursor("to"),{className:"CodeMirror-composing"})}}),Oo(o,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},Ol.prototype.createField=function(e){this.wrapper=Hi(),this.textarea=this.wrapper.firstChild},Ol.prototype.prepareSelection=function(){var e=this.cm,t=e.display,r=e.doc,n=Yt(e);if(e.options.moveInputWithCursor){var i=Dt(e,r.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+l.top-o.top)),n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+l.left-o.left))}return n},Ol.prototype.showSelection=function(e){var t=this.cm.display;r(t.cursorDiv,e.cursors),r(t.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Ol.prototype.reset=function(e){if(!this.contextMenuPending&&!this.composing){var t=this.cm;if(t.somethingSelected()){this.prevInput="";var r=t.getSelection();this.textarea.value=r,t.state.focused&&ho(this.textarea),ji&&Xi>=9&&(this.hasSelection=r)}else e||(this.prevInput=this.textarea.value="",ji&&Xi>=9&&(this.hasSelection=null))}},Ol.prototype.getField=function(){return this.textarea},Ol.prototype.supportsTouch=function(){return!1},Ol.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!ro||l()!=this.textarea))try{this.textarea.focus()}catch(e){}},Ol.prototype.blur=function(){this.textarea.blur()},Ol.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Ol.prototype.receivedFocus=function(){this.slowPoll()},Ol.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},Ol.prototype.fastPoll=function(){function e(){r.poll()||t?(r.pollingFast=!1,r.slowPoll()):(t=!0,r.polling.set(60,e))}var t=!1,r=this;r.pollingFast=!0,r.polling.set(20,e)},Ol.prototype.poll=function(){var e=this,t=this.cm,r=this.textarea,n=this.prevInput;if(this.contextMenuPending||!t.state.focused||Wo(r)&&!n&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=r.value;if(i==n&&!t.somethingSelected())return!1;if(ji&&Xi>=9&&this.hasSelection===i||no&&/[\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||n||(n="​"),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var l=0,s=Math.min(n.length,i.length);l1e3||i.indexOf("\n")>-1?r.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},Ol.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Ol.prototype.onKeyPress=function(){ji&&Xi>=9&&(this.hasSelection=null),this.fastPoll()},Ol.prototype.onContextMenu=function(e){function t(){if(null!=l.selectionStart){var e=i.somethingSelected(),t="​"+(e?l.value:"");l.value="⇚",l.value=t,n.prevInput=e?"":"​",l.selectionStart=1,l.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function r(){if(n.contextMenuPending==r&&(n.contextMenuPending=!1,n.wrapper.style.cssText=c,l.style.cssText=u,ji&&Xi<9&&o.scrollbars.setScrollTop(o.scroller.scrollTop=a),null!=l.selectionStart)){(!ji||ji&&Xi<9)&&t();var e=0,s=function(){o.selForContextMenu==i.doc.sel&&0==l.selectionStart&&l.selectionEnd>0&&"​"==n.prevInput?Cr(i,Tn)(i):e++<10?o.detectingSelectAll=setTimeout(s,500):(o.selForContextMenu=null,o.input.reset())};o.detectingSelectAll=setTimeout(s,200)}}var n=this,i=n.cm,o=i.display,l=n.textarea;n.contextMenuPending&&n.contextMenuPending();var s=Kt(i,e),a=o.scroller.scrollTop;if(s&&!qi){i.options.resetSelectionOnContextMenu&&-1==i.doc.sel.contains(s)&&Cr(i,yn)(i.doc,Vr(s),yo);var u=l.style.cssText,c=n.wrapper.style.cssText,h=n.wrapper.offsetParent.getBoundingClientRect();n.wrapper.style.cssText="position: static",l.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: "+(ji?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var f;if(Yi&&(f=window.scrollY),o.input.focus(),Yi&&window.scrollTo(null,f),o.input.reset(),i.somethingSelected()||(l.value=n.prevInput=" "),n.contextMenuPending=r,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),ji&&Xi>=9&&t(),uo){Se(e);var d=function(){pe(window,"mouseup",d),setTimeout(r,20)};Oo(window,"mouseup",d)}else setTimeout(r,50)}},Ol.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e},Ol.prototype.setUneditable=function(){},Ol.prototype.needsContentAttribute=!1,function(e){function t(t,n,i,o){e.defaults[t]=n,i&&(r[t]=o?function(e,t,r){r!=Sl&&i(e,t,r)}:i)}var r=e.optionHandlers;e.defineOption=t,e.Init=Sl,t("value","",function(e,t){return e.setValue(t)},!0),t("mode",null,function(e,t){e.doc.modeOption=t,_r(e)},!0),t("indentUnit",2,_r,!0),t("indentWithTabs",!1),t("smartIndent",!0),t("tabSize",4,function(e){$r(e),Lt(e),kr(e)},!0),t("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(H(n,o))}n++});for(var i=r.length-1;i>=0;i--)Hn(e.doc,t,r[i],H(r[i].line,r[i].ch+t.length))}}),t("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t,r){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),r!=Sl&&e.refresh()}),t("specialCharPlaceholder",Xe,function(e){return e.refresh()},!0),t("electricChars",!0),t("inputStyle",ro?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),t("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),t("rtlMoveVisually",!oo),t("wholeLineUpdateBefore",!0),t("theme","default",function(e){xi(e),Ci(e)},!0),t("keyMap","default",function(e,t,r){var n=ti(t),i=r!=Sl&&ti(r);i&&i.detach&&i.detach(e,n),n.attach&&n.attach(e,i||null)}),t("extraKeys",null),t("configureMouse",null),t("lineWrapping",!1,Li,!0),t("gutters",[],function(e){zr(e.options),Ci(e)},!0),t("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?Gt(e.display)+"px":"0",e.refresh()},!0),t("coverGutterNextToScrollbar",!1,function(e){return vr(e)},!0),t("scrollbarStyle","native",function(e){yr(e),vr(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),t("lineNumbers",!1,function(e){zr(e.options),Ci(e)},!0),t("firstLineNumber",1,Ci,!0),t("lineNumberFormatter",function(e){return e},Ci,!0),t("showCursorWhenSelecting",!1,Xt,!0),t("resetSelectionOnContextMenu",!0),t("lineWiseCopyCut",!0),t("pasteLinesPerSelection",!0),t("selectionsMayTouch",!1),t("readOnly",!1,function(e,t){"nocursor"==t&&(er(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)}),t("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),t("dragDrop",!0,Si),t("allowDropFileTypes",null),t("cursorBlinkRate",530),t("cursorScrollMargin",0),t("cursorHeight",1,Xt,!0),t("singleCursorHeightPerLine",!0,Xt,!0),t("workTime",100),t("workDelay",100),t("flattenSpans",!0,$r,!0),t("addModeClass",!1,$r,!0),t("pollInterval",100),t("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),t("historyEventDelay",1250),t("viewportMargin",10,function(e){return e.refresh()},!0),t("maxHighlightLength",1e4,$r,!0),t("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),t("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),t("autofocus",null),t("direction","ltr",function(e,t){return e.doc.setDirection(t)},!0),t("phrases",null)}(ki),function(e){var t=e.optionHandlers,r=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,r){var n=this.options,i=n[e];n[e]==r&&"mode"!=e||(n[e]=r,t.hasOwnProperty(e)&&Cr(this,t[e])(this,r,i),ge(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](ti(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,r=0;rr&&(Ti(this,i.head.line,e,!0),r=i.head.line,n==this.doc.sel.primIndex&&ar(this));else{var o=i.from(),l=i.to(),s=Math.max(r,o.line);r=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1;for(var a=s;a0&&gn(this.doc,n,new nl(o,u[n].to()),yo)}}}),getTokenAt:function(e,t){return Be(this,e,t)},getLineTokens:function(e,t){return Be(this,H(e),t,!0)},getTokenTypeAt:function(e){e=B(this.doc,e);var t,r=Pe(this,k(this.doc,e.line)),n=0,i=(r.length-1)/2,o=e.ch;if(0==o)t=r[2];else for(;;){var l=n+i>>1;if((l?r[2*l-1]:0)>=o)i=l;else{if(!(r[2*l+1]o&&(e=o,i=!0),n=k(this.doc,e)}else n=e;return Nt(this,n,{top:0,left:0},t||"page",r||i).top+(i?this.doc.height-ae(n):0)},defaultTextHeight:function(){return zt(this.display)},defaultCharWidth:function(){return Rt(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,r,n,i){var o=this.display,l=(e=Dt(this,B(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)l=e.top;else if("above"==n||"near"==n){var a=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==n||e.bottom+t.offsetHeight>a)&&e.top>t.offsetHeight?l=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=a&&(l=e.bottom),s+t.offsetWidth>u&&(s=u-t.offsetWidth)}t.style.top=l+"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&&function(e,t){var r=lr(e,t);null!=r.scrollTop&&fr(e,r.scrollTop),null!=r.scrollLeft&&pr(e,r.scrollLeft)}(this,{left:s,top:l,right:s+t.offsetWidth,bottom:l+t.offsetHeight})},triggerOnKeyDown:Sr(di),triggerOnKeyPress:Sr(gi),triggerOnKeyUp:pi,triggerOnMouseDown:Sr(vi),execCommand:function(e){if(ml.hasOwnProperty(e))return ml[e].call(null,this)},triggerElectric:Sr(function(e){Ai(this,e)}),findPosH:function(e,t,r,n){var i=1;t<0&&(i=-1,t=-t);for(var o=B(this.doc,e),l=0;l0&&l(t.charAt(r-1));)--r;for(;n.5)&&Vt(this),ge(this,"refresh",this)}),swapDoc:Sr(function(e){var t=this.doc;return t.cm=null,Jr(this,e),Lt(this),this.display.input.reset(),ur(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,Ze(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}},be(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})}}(ki);var Al="iter insert remove copy getEditor constructor".split(" ");for(var Dl in ul.prototype)ul.prototype.hasOwnProperty(Dl)&&f(Al,Dl)<0&&(ki.prototype[Dl]=function(e){return function(){return e.apply(this.doc,arguments)}}(ul.prototype[Dl]));return be(ul),ki.inputStyles={textarea:Ol,contenteditable:Nl},ki.defineMode=function(e){ki.defaults.mode||"null"==e||(ki.defaults.mode=e),function(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Po[e]=t}.apply(this,arguments)},ki.defineMIME=function(e,t){Eo[e]=t},ki.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),ki.defineMIME("text/plain","null"),ki.defineExtension=function(e,t){ki.prototype[e]=t},ki.defineDocExtension=function(e,t){ul.prototype[e]=t},ki.fromTextArea=function(e,t){function r(){e.value=a.getValue()}if(t=t?c(t):{},t.value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var n=l();t.autofocus=n==e||null!=e.getAttribute("autofocus")&&n==document.body}var i;if(e.form&&(Oo(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var o=e.form;i=o.submit;try{var s=o.submit=function(){r(),o.submit=i,o.submit(),o.submit=s}}catch(e){}}t.finishInit=function(t){t.save=r,t.getTextArea=function(){return e},t.toTextArea=function(){t.toTextArea=isNaN,r(),e.parentNode.removeChild(t.getWrapperElement()),e.style.display="",e.form&&(pe(e.form,"submit",r),"function"==typeof e.form.submit&&(e.form.submit=i))}},e.style.display="none";var a=ki(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return a},function(e){e.off=pe,e.on=Oo,e.wheelEventPixels=Br,e.Doc=ul,e.splitLines=Do,e.countColumn=h,e.findColumn=d,e.isWordChar=b,e.Pass=mo,e.signal=ge,e.Line=Uo,e.changeEnd=Kr,e.scrollbarModel=Zo,e.Pos=H,e.cmpPos=F,e.modes=Po,e.mimeModes=Eo,e.resolveMode=Ne,e.getMode=Oe,e.modeExtensions=Io,e.extendMode=Ae,e.copyState=De,e.startState=He,e.innerMode=We,e.commands=ml,e.keyMap=vl,e.keyName=ei,e.isModifierKey=Qn,e.lookupKey=Zn,e.normalizeKeyMap=qn,e.StringStream=zo,e.SharedTextMarker=sl,e.TextMarker=ll,e.LineWidget=il,e.e_preventDefault=we,e.e_stopPropagation=xe,e.e_stop=Se,e.addClass=s,e.contains=o,e.rmClass=co,e.keyNames=fl}(ki),ki.version="5.42.2",ki});