!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self,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,r){var n;Lo=null;for(var i=0;it)return i;o.to==t&&(o.from!=o.to&&"before"==r?n=i:Lo=i),o.from==t&&(o.from!=o.to&&"before"!=r?n=i:Lo=i)}return null!=n?n:Lo}function T(e,t){var r=e.order;return null==r&&(r=e.order=ko(e.text,t)),r}function M(e,t){return e._handlers&&e._handlers[t]||To}function N(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 A(e,t){var r=M(e,t);if(r.length)for(var n=Array.prototype.slice.call(arguments,2),i=0;i0}function H(e){e.prototype.on=function(e,t){Mo(this,e,t)},e.prototype.off=function(e,t){N(this,e,t)}}function F(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function P(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function E(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function I(e){F(e),P(e)}function R(e){return e.target||e.srcElement}function z(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 B(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 G(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 U(e){if("string"==typeof e&&Fo.hasOwnProperty(e))e=Fo[e];else if(e&&"string"==typeof e.name&&Fo.hasOwnProperty(e.name)){var t=Fo[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 U("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return U("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function V(e,t){t=U(t);var r=Ho[t.name];if(!r)return V(e,"text/plain");var n=r(e,t);if(Po.hasOwnProperty(t.name)){var i=Po[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 K(e,t){c(t,Po.hasOwnProperty(e)?Po[e]:Po[e]={})}function j(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 X(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 Y(e,t,r){return!e.startState||e.startState(t,r)}function _(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?re(r,_(e,r).text.length):function(e,t){var r=e.ch;return null==r||r>t?re(e.line,t):r<0?re(e.line,0):e}(t,_(e,t.line).text.length)}function ce(e,t){for(var r=[],n=0;ne&&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&&j(e.doc.mode,n.state),o=he(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 de(e,t,r){var n=e.doc,i=e.display;if(!n.mode.startState)return new Ro(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=_(o,s-1),u=a.stateAfter;if(u&&(!r||s+(u instanceof Io?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&&_(n,o-1).stateAfter,s=l?Ro.fromSaved(n,l,o):new Ro(n,Y(n.mode),o);return n.iter(o,t,function(r){pe(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 me(e,t,r,n){var i,o,l=e.doc,s=l.mode,a=_(l,(t=ue(l,t)).line),u=de(e,t.line,r),c=new Eo(a.text,e.options.tabSize,u);for(n&&(o=[]);(n||c.pose.options.maxHighlightLength?(s=!1,l&&pe(e,t,n,h.pos),h.pos=t.length,a=null):a=ye(ve(r,h,n.state,f),o),f){var d=f[0].name;d&&(a="m-"+(a?d+" "+a:d))}if(!s||c!=a){for(;u=t:o.to>t);(n||(n=[])).push(new we(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||Ae(r,o.marker)<0)&&(r=o.marker)}return r}function Fe(e,t,r,n,i){var o=_(e,t),l=Go&&o.markedSpans;if(l)for(var s=0;s=0&&h<=0||c<=0&&h>=0)&&(c<=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?ne(u.to,r)>=0:ne(u.to,r)>0)||c>=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?ne(u.from,n)<=0:ne(u.from,n)<0)))return!0}}}function Pe(e){for(var t;t=De(e);)e=t.find(-1,!0).line;return e}function Ee(e,t){var r=_(e,t),n=Pe(r);return r==n?t:Q(n)}function Ie(e,t){if(t>e.lastLine())return t;var r,n=_(e,t);if(!Re(e,n))return t;for(;r=We(n);)n=r.find(1,!0).line;return Q(n)+1}function Re(e,t){var r=Go&&t.markedSpans;if(r)for(var n=void 0,i=0;it.maxLineLength&&(t.maxLineLength=r,t.maxLine=e)})}function Ve(e){e.parent=null,ke(e)}function Ke(e,t){if(!e||/^\s*$/.test(e))return null;var r=t.addModeClass?jo:Ko;return r[e]||(r[e]=e.replace(/\S+/g,"cm-$&"))}function je(e,t){var r=i("span",null,null,Yi?"padding-right: .1px":null),n={pre:i("pre",[r],"CodeMirror-line"),content:r,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var o=0;o<=(t.rest?t.rest.length:0);o++){var l=o?t.rest[o-1]:t.line,s=void 0;n.pos=0,n.addToken=Ye,G(e.display.measure)&&(s=T(l,e.doc.direction))&&(n.addToken=function(e,t){return function(r,n,i,o,l,s,a){i=i?i+" cm-force-border":"cm-force-border";for(var u=r.pos,c=u+n.length;;){for(var h=void 0,f=0;fu&&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||Ae(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 A=N>M?m.slice(0,M-g):m;t.addToken(t,A,s?s+u:u,h,g+A.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,fe(e,l,t!=e.display.externalMeasured&&Q(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(B(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 A(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+zt(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=k(a,u,c),f=Lo,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=ue(e.doc,t),e.options.lineWrapping||(r=zt(e.display)*t.ch);var n=_(e.doc,t.line),i=Be(n)+ut(e.display);return{left:r,right:r,top:i,bottom:i+n.height}}function Ht(e,t,r,n,i){var o=re(e,t,r);return o.xRel=i,n&&(o.outside=n),o}function Ft(e,t,r){var n=e.doc;if((r+=e.display.viewOffset)<0)return Ht(n.first,0,null,-1,-1);var i=J(n,r),o=n.first+n.size-1;if(i>o)return Ht(n.first+n.size-1,_(n,o).text.length,null,1,1);t<0&&(t=0);for(var l=_(n,i);;){var s=function(e,t,r,n,i){i-=Be(t);var o=yt(e,t),l=Mt(t),s=0,a=t.text.length,u=!0,c=T(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,re(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,re(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?1:0}return v=S(t.text,v,1),Ht(r,v,d,m,n-f)}(e,l,i,t,r),a=He(l,s.ch+(s.xRel>0||s.outside>0?1:0));if(!a)return s;var u=a.find(1);if(u.line==i)return u;l=_(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 Rt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Vo){Vo=n("pre",null,"CodeMirror-line-like");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 zt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=n("span","xxxxxxxxxx"),i=n("pre",[t],"CodeMirror-line-like");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){var s=e.display.gutterSpecs[l].className;r[s]=o.offsetLeft+o.clientLeft+i,n[s]=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=Rt(e.display),r=e.options.lineWrapping,n=r&&Math.max(5,e.display.scroller.clientWidth/zt(e.display)-3);return function(i){if(Re(e.doc,i))return 0;var o=0;if(i.widgets)for(var l=0;l0&&(a=_(e.doc,u.line).text).length==u.ch){var c=h(a,a.length,e.options.tabSize)-a.length;u=re(u.line,Math.max(0,Math.round((o-ht(e.display).left)/zt(e.display))-c))}return u}function jt(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)Go&&Ee(e.doc,t)i.viewFrom?_t(e):(i.viewFrom+=n,i.viewTo+=n);else if(t<=i.viewFrom&&r>=i.viewTo)_t(e);else if(t<=i.viewFrom){var o=$t(e,r,r+n,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=n):_t(e)}else if(r>=i.viewTo){var l=$t(e,t,t,-1);l?(i.view=i.view.slice(0,l.index),i.viewTo=l.lineN):_t(e)}else{var s=$t(e,t,t,-1),a=$t(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):_t(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 _t(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function $t(e,t,r,n){var i,o=jt(e,t),l=e.display.view;if(!Go||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(;Ee(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 qt(e){for(var t=e.display.view,r=0,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,A,O;v?(M=f&&b&&x?c:m.left,N=f?h:l(e,s,"before"),A=f?c:l(t,s,"after"),O=f&&w&&C?h:y.right):(M=f?l(e,s,"before"):c,N=!f&&b&&x?h:m.right,A=!f&&w&&C?c:y.left,O=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 rr(e){e.state.focused||(e.display.input.focus(),ir(e))}function nr(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,or(e))},100)}function ir(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(A(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()),tr(e))}function or(e,t){e.state.delayingBlurEvent||(e.state.focused&&(A(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 lr(e){for(var t=e.display,r=t.lineDiv.offsetTop,n=0;n.005||c<-.005)&&(Z(i.line,l),sr(i.line),i.rest))for(var h=0;he.display.sizerWidth){var f=Math.ceil(s/zt(e.display));f>e.display.maxLineLength&&(e.display.maxLineLength=f,e.display.maxLine=i.line,e.display.maxLineChanged=!0)}}}}function sr(e){if(e.widgets)for(var t=0;t=l&&(o=J(t,Be(_(t,a))-e.wrapper.clientHeight),l=a)}return{from:o,to:Math.max(l,o+1)}}function ur(e,t){var r=e.display,n=Rt(e.display);t.top<0&&(t.top=0);var i=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:r.scroller.scrollTop,o=pt(e),l={};t.bottom-t.top>o&&(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 cr(e,t){null!=t&&(dr(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function hr(e){dr(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function fr(e,t,r){null==t&&null==r||dr(e),null!=t&&(e.curOp.scrollLeft=t),null!=r&&(e.curOp.scrollTop=r)}function dr(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;pr(e,Wt(e,t.from),Wt(e,t.to),t.margin)}}function pr(e,t,r,n){var i=ur(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});fr(e,i.scrollLeft,i.scrollTop)}function gr(e,t){Math.abs(e.doc.scrollTop-t)<2||(Gi||Wr(e,{top:t}),vr(e,t,!0),Gi&&Wr(e),Nr(e,100))}function vr(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 mr(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,Pr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function yr(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 br(e,t){t||(t=yr(e));var r=e.display.barWidth,n=e.display.barHeight;wr(e,t);for(var i=0;i<4&&r!=e.display.barWidth||n!=e.display.barHeight;i++)r!=e.display.barWidth&&e.options.lineWrapping&&lr(e),wr(e,yr(e)),r=e.display.barWidth,n=e.display.barHeight}function wr(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 xr(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),Mo(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?mr(e,t):gr(e,t)},e),e.display.scrollbars.addClass&&s(e.display.wrapper,e.display.scrollbars.addClass)}function Cr(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 Sr(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&&(mr(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-h)>1&&(l=!0)),!l)break}return i}(t,ue(i,e.scrollToPos.from),ue(i,e.scrollToPos.to),e.scrollToPos.margin);!function(e,t){if(!O(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;a=e.display.viewTo)){var r=+new Date+e.options.workTime,n=de(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?j(t.mode,n.state):null,a=he(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 Nr(e,e.options.workDelay),!0}),t.highlightFrontier=n.line,t.modeFrontier=Math.max(t.modeFrontier,n.line),i.length&&Lr(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==qt(e))return!1;Er(e)&&(_t(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)),Go&&(a=Ee(e.doc,a),u=Ie(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=Be(_(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var h=qt(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(te(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(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&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,Nr(e,400)),n.updateLineNumbers=null,!0}function Dr(e,t){for(var r=t.viewport,n=!0;;n=!1){if(n&&e.options.lineWrapping&&t.oldDisplayWidth!=dt(e))n&&(t.visible=ar(e.display,e.doc,r));else if(r&&null!=r.top&&(r={top:Math.min(e.doc.height+ct(e.display)-pt(e),r.top)}),t.visible=ar(e.display,e.doc,r),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!Or(e,t))break;lr(e);var i=yr(e);Zt(e),br(e,i),Fr(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 Wr(e,t){var r=new Jo(e,t);if(Or(e,r)){lr(e),Dr(e,r);var n=yr(e);Zt(e),br(e,n),Fr(e,n),r.finish()}}function Hr(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Fr(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 Pr(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;ll.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=se(s.from(),l.from()),c=le(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 Kr(e,t){return new rl([new nl(e,t||e)],0)}function jr(e){return e.text?re(e.from.line+e.text.length-1,g(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function Xr(e,t){if(ne(e,t.from)<0)return e;if(ne(e,t.to)<=0)return jr(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+=jr(t).ch-t.to.ch),re(r,n)}function Yr(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 Jr(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?(on(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==ne(t.from,t.to)&&0==ne(t.from,l.to)?l.to=jr(t):o.changes.push(nn(e,t));else{var a=g(i.done);for(a&&a.ranges||an(e.sel,i.done),o={changes:[nn(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||A(e,"historyAdded")}function sn(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:an(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=r,n&&!1!==n.clearRedo&&on(i.undone)}function an(e,t){var r=g(t);r&&r.ranges&&r.equals(e)||t.push(e)}function un(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 cn(e){if(!e)return null;for(var t,r=0;r-1&&(g(s)[h]=u[h],delete u[h])}}}return n}function dn(e,t,r,n){if(n){var i=e.anchor;if(r){var o=ne(t,i)<0;o!=ne(r,i)<0?(i=t,t=r):o!=ne(t,r)<0&&(t=r)}return new nl(i,t)}return new nl(r||t,t)}function pn(e,t,r,n,i){null==i&&(i=e.cm&&(e.cm.display.shift||e.extend)),bn(e,new rl([dn(e.sel.primary(),t,r,i)],0),n)}function gn(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&&(A(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(r){var h=a.find(n<0?1:-1),f=void 0;if((n<0?c:u)&&(h=Tn(e,h,-n,h&&h.line==t.line?o:null)),h&&h.line==t.line&&(f=ne(h,r))&&(n<0?f<0:f>0))return Ln(e,h,t,n,i)}var d=a.find(n<0?-1:1);return(n<0?u:c)&&(d=Tn(e,d,n,d.line==t.line?o:null)),d?Ln(e,d,t,n,i):null}}return t}function kn(e,t,r,n,i){var o=n||1,l=Ln(e,t,r,o,i)||!i&&Ln(e,t,r,o,!0)||Ln(e,t,r,-o,i)||!i&&Ln(e,t,r,-o,!0);return l||(e.cantEdit=!0,re(e.first,0))}function Tn(e,t,r,n){return r<0&&0==t.ch?t.line>e.first?ue(e,re(t.line-1)):null:r>0&&t.ch==(n||_(e,t.line)).text.length?t.line0)){var c=[a,1],h=ne(u.from,s.from),d=ne(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!=ne(t.from,t.to)){var r=Yr(e,t);ln(e,t,r,e.cm?e.cm.curOp.id:NaN),Hn(e,t,r,Se(e,t));var n=[];Jr(e,function(e,r){r||-1!=f(n,e.history)||(In(e.history,t),n.push(e.history)),Hn(e,t,null,Se(e,t))})}}function Dn(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 Wn(e,t){if(0!=t&&(e.first+=t,e.sel=new rl(v(e.sel.ranges,function(e){return new nl(re(e.anchor.line+t,e.anchor.ch),re(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Xt(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:re(o,_(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=$(e,t.from,t.to),r||(r=Yr(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=Q(Pe(_(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&&D(e);Qr(n,t,r,Ut(e)),e.options.lineWrapping||(n.iter(a,o.line+t.text.length,function(e){var t=Ge(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=_(e,n).stateAfter;if(i&&(!(i instanceof Io)||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(Fe(e,t.line,t,r,l)||t.line!=r.line&&Fe(e,r.line,t,r,l))throw new Error("Inserting collapsed marker partially overlapping an existing one");Go=!0}l.addToHistory&&ln(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&&Pe(e)==h.display.maxLine&&(a=!0),l.collapsed&&u!=t.line&&Z(e,0),function(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}(e,new we(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){Re(e,t)&&Z(t,0)}),l.clearOnEnter&&Mo(l,"beforeCursorEnter",function(){return l.clear()}),l.readOnly&&(Bo=!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)Xt(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++)Yt(h,f,"text");l.atomic&&Cn(h.doc),Ze(h,"markerAdded",h,l)}return l}function Vn(e){return e.findMarks(re(e.first,0),e.clipPos(re(e.lastLine())),function(e){return e.parent})}function Kn(e){for(var t=function(t){var r=e[t],n=[r.primary.doc];Jr(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 c=e.dataTransfer.getData("Text");if(c){var h;if(t.state.draggingText&&!t.state.draggingText.copy&&(h=t.listSelections()),wn(t.doc,Kr(r,r)),h)for(var d=0;d=0;t--)Fn(e.doc,"",n[t].from,n[t].to,"+delete");hr(e)})}function ii(e,t,r){var n=S(e.text,t+r,r);return n<0||n>e.text.length?null:n}function oi(e,t,r){var n=ii(e,t.ch,r);return null==n?null:new re(t.line,n,r<0?"after":"before")}function li(e,t,r,n,i){if(e){"rtl"==t.doc.direction&&(i=-i);var o=T(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=ii(r,l,1))}else l=i<0?s.to:s.from;return new re(n,l,a)}}return new re(n,i<0?r.text.length:0,i<0?"before":"after")}function si(e,t){var r=_(e.doc,t),n=Pe(r);return n!=r&&(t=Q(n)),li(!0,e,n,t,1)}function ai(e,t){var r=_(e.doc,t),n=function(e){for(var t;t=We(e);)e=t.find(1,!0).line;return e}(r);return n!=r&&(t=Q(n)),li(!0,e,r,t,-1)}function ui(e,t){var r=si(e,t.line),n=_(e.doc,r.line),i=T(n,e.doc.direction);if(!i||0==i[0].level){var o=Math.max(r.ch,n.text.search(/\S/)),l=t.line==r.line&&t.ch<=o&&t.ch;return re(r.line,l?0:o,r.sticky)}return r}function ci(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 hi(e,t,r,n){var i=e.state.keySeq;if(i){if(Jn(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())}),fi(e,i+" "+t,r,n))return!0}return fi(e,t,r,n)}function fi(e,t,r,n){var i=function(e,t,r){for(var n=0;n-1&&(ne((i=s.ranges[i]).from(),t)<0||t.xRel>0)&&(ne(i.to(),t)>0||t.xRel<0)?function(e,t,r,n){var i=e.display,o=!1,l=kr(e,function(t){Yi&&(i.scroller.draggable=!1),e.state.draggingText=!1,N(i.wrapper.ownerDocument,"mouseup",l),N(i.wrapper.ownerDocument,"mousemove",s),N(i.scroller,"dragstart",a),N(i.scroller,"drop",l),o||(F(t),n.addNew||pn(e.doc,r,null,null,n.extend),Yi&&!Zi||ji&&9==Xi?setTimeout(function(){i.wrapper.ownerDocument.body.focus({preventScroll:!0}),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();Mo(i.wrapper.ownerDocument,"mouseup",l),Mo(i.wrapper.ownerDocument,"mousemove",s),Mo(i.scroller,"dragstart",a),Mo(i.scroller,"drop",l),nr(e),setTimeout(function(){return i.input.focus()},20)}(e,n,t,o):function(e,t,r,n){function i(t){if(0!=ne(m,t))if(m=t,"rectangle"==n.unit){for(var i=[],o=e.options.tabSize,l=h(_(u,r.line).text,r.ch,o),s=h(_(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=_(u,v).text,w=d(b,a,o);a==g?i.push(new nl(re(v,w),re(v,w))):b.length>w&&i.push(new nl(re(v,w),re(v,d(b,g,o))))}i.length||i.push(new nl(r,r)),bn(u,Vr(e,p.ranges.slice(0,f).concat(i),f),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var x,C=c,S=yi(e,t,n.unit),L=C.anchor;ne(S.anchor,L)>0?(x=S.head,L=se(C.from(),S.anchor)):(x=S.anchor,L=le(C.to(),S.head));var M=p.ranges.slice(0);M[f]=function(e,t){var r=t.anchor,n=t.head,i=_(e.doc,r.line);if(0==ne(r,n)&&r.sticky==n.sticky)return t;var o=T(i);if(!o)return t;var l=k(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=k(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 re(r.line,p,g),n)}(e,new nl(ue(u,L),x)),bn(u,Vr(e,M,f),bo)}}function o(t){var r=++b,s=Kt(e,t,!0,"rectangle"==n.unit);if(s)if(0!=ne(s,m)){e.curOp.focus=l(),i(s);var c=ar(a,u);(s.line>=c.to||s.liney.bottom?20:0;h&&setTimeout(kr(e,function(){b==r&&(a.scroller.scrollTop+=h,o(t))}),50)}}function s(t){e.state.selectingText=!1,b=1/0,t&&(F(t),a.input.focus()),N(a.wrapper.ownerDocument,"mousemove",w),N(a.wrapper.ownerDocument,"mouseup",x),u.history.lastSelOrigin=null}var a=e.display,u=e.doc;F(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=yi(e,r,n.unit);c=n.extend?dn(c,v.anchor,v.head,n.extend):v}n.addNew?-1==f?(f=g.length,bn(u,Vr(e,g.concat([c]),f),{scroll:!1,origin:"*mouse"})):g.length>1&&g[f].empty()&&"char"==n.unit&&!n.extend?(bn(u,Vr(e,g.slice(0,f).concat(g.slice(f+1)),0),{scroll:!1,origin:"*mouse"}),p=u.sel):vn(u,f,c,bo):(f=0,bn(u,new rl([c],0),bo),p=u.sel);var m=r;var y=a.wrapper.getBoundingClientRect(),b=0;var w=kr(e,function(e){0!==e.buttons&&z(e)?o(e):s(e)}),x=kr(e,s);e.state.selectingText=x,Mo(a.wrapper.ownerDocument,"mousemove",w),Mo(a.wrapper.ownerDocument,"mouseup",x)}(e,n,t,o)}(this,r,i,e):R(e)==t.scroller&&F(e):2==n?(r&&pn(this.doc,r),setTimeout(function(){return t.input.focus()},20)):3==n&&(uo?this.display.input.onContextMenu(e):nr(this)))}}function yi(e,t,r){if("char"==r)return new nl(t,t);if("word"==r)return e.findWordAt(t);if("line"==r)return new nl(re(t.line,0),ue(e.doc,re(t.line+1,0)));var n=r(e,t);return new nl(n.from,n.to)}function bi(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&&F(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!W(e,r))return E(t);o-=s.top-l.viewOffset;for(var a=0;a=i){return A(e,r,e,J(e.doc,o),e.display.gutterSpecs[a].className,t),E(t)}}}function wi(e,t){return bi(e,t,"gutterClick",!0)}function xi(e,t){at(e.display,t)||function(e,t){if(!W(e,"gutterContextMenu"))return!1;return bi(e,t,"gutterContextMenu",!1)}(e,t)||O(e,t,"contextmenu")||uo||e.display.input.onContextMenu(t)}function Ci(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 Si(e,t,r){if(!t!=!(r&&r!=Sl)){var n=e.display.dragFunctions,i=t?Mo:N;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"),Ue(e)),Vt(e),Xt(e),Lt(e),setTimeout(function(){return br(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);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,o){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 l=i("div",[this.lineSpace],"CodeMirror-lines");this.mover=n("div",[l],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,this.gutterSpecs=Ir(o.gutters,o.lineNumbers),Rr(this),r.init(this)}(e,l,s,t);a.wrapper.CodeMirror=this,Ci(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),xr(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;Mo(o.scroller,"mousedown",kr(e,mi)),Mo(o.scroller,"dblclick",ji&&Xi<11?kr(e,function(t){if(!O(e,t)){var r=Kt(e,t);if(r&&!wi(e,t)&&!at(e.display,t)){F(t);var n=e.findWordAt(r);pn(e.doc,n.anchor,n.head)}}}):function(t){return O(e,t)||F(t)});Mo(o.scroller,"contextmenu",function(t){return xi(e,t)}),Mo(o.input.getField(),"contextmenu",function(t){o.scroller.contains(t.target)||xi(e,t)});var l,s={end:0};Mo(o.scroller,"touchstart",function(t){if(!O(e,t)&&!function(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}(t)&&!wi(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)}}),Mo(o.scroller,"touchmove",function(){o.activeTouch&&(o.activeTouch.moved=!0)}),Mo(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(re(s.line,0),ue(e.doc,re(s.line+1,0))),e.setSelection(l.anchor,l.head),e.focus(),F(r)}t()}),Mo(o.scroller,"touchcancel",t),Mo(o.scroller,"scroll",function(){o.scroller.clientHeight&&(gr(e,o.scroller.scrollTop),mr(e,o.scroller.scrollLeft,!0),A(e,"scroll",e))}),Mo(o.scroller,"mousewheel",function(t){return Ur(e,t)}),Mo(o.scroller,"DOMMouseScroll",function(t){return Ur(e,t)}),Mo(o.wrapper,"scroll",function(){return o.wrapper.scrollTop=o.wrapper.scrollLeft=0}),o.dragFunctions={enter:function(t){O(e,t)||I(t)},over:function(t){O(e,t)||(!function(e,t){var i=Kt(e,t);if(i){var o=document.createDocumentFragment();Jt(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),I(t))},start:function(t){return function(e,t){if(ji&&(!e.state.draggingText||+new Date-cl<100))I(t);else if(!O(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:kr(e,jn),leave:function(t){O(e,t)||Xn(e)}};var a=o.input.getField();Mo(a,"keyup",function(t){return gi.call(e,t)}),Mo(a,"keydown",kr(e,pi)),Mo(a,"keypress",kr(e,vi)),Mo(a,"focus",function(t){return ir(e,t)}),Mo(a,"blur",function(t){return or(e,t)})}(this),_n(),Cr(this),this.curOp.forceUpdate=!0,en(this,l),t.autofocus&&!ro||this.hasFocus()?setTimeout(u(ir,this),20):or(this);for(var h in kl)kl.hasOwnProperty(h)&&kl[h](this,t[h],Sl);Er(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(_(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(dl,a=Ao(t),u=null;if(s&&n.ranges.length>1)if(Ml&&Ml.text.join("\n")==t){if(n.ranges.length%Ml.text.length==0){u=[];for(var c=0;c=0;f--){var d=n.ranges[f],p=d.from(),m=d.to();d.empty()&&(r&&r>0?p=re(p.line,p.ch-r):e.state.overwrite&&!s?m=re(m.line,Math.min(_(o,m.line).text.length,m.ch+g(a).length)):s&&Ml&&Ml.lineWise&&Ml.text.join("\n")==a.join("\n")&&(p=m=re(p.line,0)));var y={from:p,to:m,text:u?u[f%u.length]:a,origin:i||(s?"paste":e.state.cutIncoming>l?"cut":"+input")};An(e.doc,y),Ze(e,"inputRead",e,y)}t&&!s&&Oi(e,t),hr(e),e.curOp.updateInput<2&&(e.curOp.updateInput=h),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Ai(e,t){var r=e.clipboardData&&e.clipboardData.getData("Text");if(r)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||Lr(t,function(){return Ni(t,r,0,null,"paste")}),!0}function Oi(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(_(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=k(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 re(r.line,f,d)}}var p=function(e,t,n){for(var o=function(e,t){return t?new re(r.line,a(e,1),"before"):new re(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):oi(a,t,r))){if(n||!function(){var r=t.line+u;return!(r=e.first+e.size)&&(t=new re(r,t.ch,t.sticky),a=_(e,r))}())return!1;t=li(i,e.cm,a,t.line,u)}else t=o;return!0}var l=t,s=r,a=_(e,t.line),u=i&&"rtl"==e.direction?-r:r;if("char"==n)o();else if("column"==n)o(!0);else if("word"==n||"group"==n)for(var c=null,h="group"==n,f=e.cm&&e.cm.getHelper(t,"wordChars"),d=!0;!(r<0)||o(!d);d=!1){var p=a.text.charAt(t.ch)||"\n",g=w(p,f)?"w":h&&"\n"==p?"n":!h||/\s/.test(p)?null:"p";if(!h||d||g||(g="s"),c&&c!=g){r<0&&(r=1,o(),t.sticky="after");break}if(g&&(c=g),r>0&&!o(!d))break}var v=kn(e,t,l,s,!0);return ie(l,v)&&(v.hitSide=!0),v}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*Rt(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=_(e.doc,t.line),i=gt(r,n,t.line),o=T(n,e.doc.direction),l="left";if(o){l=k(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 Ri(e,t,r){var n;if(t==e.display.lineDiv){if(!(n=e.display.lineDiv.childNodes[r]))return Ii(e.clipPos(re(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,this.f=null,this.time=0,this.handler=u(this.onTimeout,this)};fo.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-+new Date)},fo.prototype.set=function(e,t){this.f=t;var r=+new Date+e;(!this.id||r=this.string.length},Eo.prototype.sol=function(){return this.pos==this.lineStart},Eo.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Eo.prototype.next=function(){if(this.post},Eo.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Eo.prototype.skipToEnd=function(){this.pos=this.string.length},Eo.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},Eo.prototype.backUp=function(e){this.pos-=e},Eo.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},Eo.prototype.current=function(){return this.string.slice(this.start,this.pos)},Eo.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Eo.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Eo.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var Io=function(e,t){this.state=e,this.lookAhead=t},Ro=function(e,t,r,n){this.state=t,this.doc=e,this.line=r,this.maxLookAhead=n||0,this.baseTokens=null,this.baseTokenPos=1};Ro.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},Ro.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}},Ro.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},Ro.fromSaved=function(e,t,r){return t instanceof Io?new Ro(e,j(e.mode,t.state),r,t.lookAhead):new Ro(e,j(e.mode,t),r)},Ro.prototype.save=function(e){var t=!1!==e?j(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new Io(t,this.maxLookAhead):t};var zo=function(e,t,r){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=r},Bo=!1,Go=!1,Uo=function(e,t,r){this.text=e,Te(this,t),this.height=r?r(this):1};Uo.prototype.lineNo=function(){return Q(this)},H(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),Mo(i,"scroll",function(){i.clientHeight&&t(i.scrollTop,"vertical")}),Mo(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=ar(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){W(e,t)&&this.events.push(arguments)},Jo.prototype.finish=function(){for(var e=0;e=0&&ne(e,n.to())<=0)return r}return-1};var nl=function(e,t){this.anchor=e,this.head=t};nl.prototype.from=function(){return se(this.anchor,this.head)},nl.prototype.to=function(){return le(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&&Xt(e,n,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Cn(e.doc)),e&&Ze(e,"markerCleared",e,this,n,i),t&&Sr(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--)An(this,n[a]);s?yn(this,s):this.cm&&hr(this.cm)}),undo:Mr(function(){Dn(this,"undo")}),redo:Mr(function(){Dn(this,"redo")}),undoSelection:Mr(function(){Dn(this,"undo",!0)}),redoSelection:Mr(function(){Dn(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=ue(this,e),t=ue(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}),ue(this,re(r,t))},indexFromPos:function(e){var t=(e=ue(this,e)).ch;if(e.linet&&(t=e.from),null!=e.to&&e.to0)i=new re(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),re(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var l=_(e.doc,i.line-1).text;l&&(i=new re(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+l.charAt(l.length-1),re(i.line-1,l.length-1),i,"+transpose"))}r.push(new nl(i,i))}e.setSelections(r)})},newlineAndIndent:function(e){return Lr(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==ne(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){for(var t=e.target;t;t=t.parentNode){if(t==l)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(t.className))break}return!1}function r(e){if(t(e)&&!O(o,e)){if(o.somethingSelected())Mi({lineWise:!1,text:o.getSelections()}),"cut"==e.type&&o.replaceSelection("",null,"cut");else{if(!o.options.lineWiseCopyCut)return;var r=Di(o);Mi({lineWise:!0,text:r.text}),"cut"==e.type&&o.operation(function(){o.setSelections(r.ranges,0,yo),o.replaceSelection("",null,"cut")})}if(e.clipboardData){e.clipboardData.clearData();var n=Ml.text.join("\n");if(e.clipboardData.setData("Text",n),e.clipboardData.getData("Text")==n)return void e.preventDefault()}var s=Hi(),a=s.firstChild;o.display.lineSpace.insertBefore(s,o.display.lineSpace.firstChild),a.value=Ml.text.join("\n");var u=document.activeElement;ho(a),setTimeout(function(){o.display.lineSpace.removeChild(s),u.focus(),u==l&&i.showPrimarySelection()},50)}}var n=this,i=this,o=i.cm,l=i.div=e.lineDiv;Wi(l,o.options.spellcheck,o.options.autocorrect,o.options.autocapitalize),Mo(l,"paste",function(e){!t(e)||O(o,e)||Ai(e,o)||Xi<=11&&setTimeout(kr(o,function(){return n.updateFromDOM()}),20)}),Mo(l,"compositionstart",function(e){n.composing={data:e.data,done:!1}}),Mo(l,"compositionupdate",function(e){n.composing||(n.composing={data:e.data,done:!1})}),Mo(l,"compositionend",function(e){n.composing&&(e.data!=n.composing.data&&n.readFromDOMSoon(),n.composing.done=!0)}),Mo(l,"touchstart",function(){return i.forceCompositionEnd()}),Mo(l,"input",function(){n.composing||n.readFromDOMSoon()}),Mo(l,"copy",r),Mo(l,"cut",r)},Nl.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Nl.prototype.prepareSelection=function(){var e=Qt(this.cm,!1);return e.focus=document.activeElement==this.div,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=re(n.line-1,_(e.doc,n.line-1).length)),i.ch==_(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=Q(t.view[0].line),s=t.view[0].node):(l=Q(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=Q(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(re(n,0),re(i+1,0),function(e){return function(t){return t.id==e}}(+f));return void(d.length&&(a=d[0].find(0))&&l($(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=re(l,d),S=re(a,f.length?g(f).length-p:0);return h.length>1||h[0]||ne(C,S)?(Fn(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()||Lr(this.cm,function(){return Xt(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()||kr(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 Al=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new fo,this.hasSelection=!1,this.composing=null};Al.prototype.init=function(e){function t(e){if(!O(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=+new Date)}}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"),Mo(o,"input",function(){ji&&Xi>=9&&r.hasSelection&&(r.hasSelection=null),n.poll()}),Mo(o,"paste",function(e){O(i,e)||Ai(e,i)||(i.state.pasteIncoming=+new Date,n.fastPoll())}),Mo(o,"cut",t),Mo(o,"copy",t),Mo(e.scroller,"paste",function(t){if(!at(e,t)&&!O(i,t)){if(!o.dispatchEvent)return i.state.pasteIncoming=+new Date,void n.focus();var r=new Event("paste");r.clipboardData=t.clipboardData,o.dispatchEvent(r)}}),Mo(e.lineSpace,"selectstart",function(t){at(e,t)||F(t)}),Mo(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"})}}),Mo(o,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},Al.prototype.createField=function(e){this.wrapper=Hi(),this.textarea=this.wrapper.firstChild},Al.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},Al.prototype.prepareSelection=function(){var e=this.cm,t=e.display,r=e.doc,n=Qt(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},Al.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")},Al.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))}},Al.prototype.getField=function(){return this.textarea},Al.prototype.supportsTouch=function(){return!1},Al.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!ro||l()!=this.textarea))try{this.textarea.focus()}catch(e){}},Al.prototype.blur=function(){this.textarea.blur()},Al.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Al.prototype.receivedFocus=function(){this.slowPoll()},Al.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},Al.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)},Al.prototype.poll=function(){var e=this,t=this.cm,r=this.textarea,n=this.prevInput;if(this.contextMenuPending||!t.state.focused||Oo(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},Al.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Al.prototype.onKeyPress=function(){ji&&Xi>=9&&(this.hasSelection=null),this.fastPoll()},Al.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?kr(i,Mn)(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)&&kr(i,bn)(i.doc,Kr(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){I(e);var d=function(){N(window,"mouseup",d),setTimeout(r,20)};Mo(window,"mouseup",d)}else setTimeout(r,50)}},Al.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e},Al.prototype.setUneditable=function(){},Al.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){qr(e),Lt(e),Xt(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(re(n,o))}n++});for(var i=r.length-1;i>=0;i--)Fn(e.doc,t,r[i],re(r[i].line,r[i].ch+t.length))}}),t("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/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("autocorrect",!1,function(e,t){return e.getInputField().autocorrect=t},!0),t("autocapitalize",!1,function(e,t){return e.getInputField().autocapitalize=t},!0),t("rtlMoveVisually",!oo),t("wholeLineUpdateBefore",!0),t("theme","default",function(e){Ci(e),zr(e)},!0),t("keyMap","default",function(e,t,r){var n=ri(t),i=r!=Sl&&ri(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,t){e.display.gutterSpecs=Ir(t,e.options.lineNumbers),zr(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 br(e)},!0),t("scrollbarStyle","native",function(e){xr(e),br(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),t("lineNumbers",!1,function(e,t){e.display.gutterSpecs=Ir(e.options.gutters,t),zr(e)},!0),t("firstLineNumber",1,zr,!0),t("lineNumberFormatter",function(e){return e},zr,!0),t("showCursorWhenSelecting",!1,Zt,!0),t("resetSelectionOnContextMenu",!0),t("lineWiseCopyCut",!0),t("pasteLinesPerSelection",!0),t("selectionsMayTouch",!1),t("readOnly",!1,function(e,t){"nocursor"==t&&(or(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)}),t("screenReaderLabel",null,function(e,t){t=""===t?null:t,e.display.input.screenReaderLabelChanged(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,Zt,!0),t("singleCursorHeightPerLine",!0,Zt,!0),t("workTime",100),t("workDelay",100),t("flattenSpans",!0,qr,!0),t("addModeClass",!1,qr,!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,qr,!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)&&kr(this,t[e])(this,r,i),A(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"](ri(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&&hr(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&&vn(this.doc,n,new nl(o,u[n].to()),yo)}}}),getTokenAt:function(e,t){return me(this,e,t)},getLineTokens:function(e,t){return me(this,re(e),t,!0)},getTokenTypeAt:function(e){e=ue(this.doc,e);var t,r=fe(this,_(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=_(this.doc,e)}else n=e;return Nt(this,n,{top:0,left:0},t||"page",r||i).top+(i?this.doc.height-Be(n):0)},defaultTextHeight:function(){return Rt(this.display)},defaultCharWidth:function(){return zt(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,ue(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=ur(e,t);null!=r.scrollTop&&gr(e,r.scrollTop),null!=r.scrollLeft&&mr(e,r.scrollLeft)}(this,{left:s,top:l,right:s+t.offsetWidth,bottom:l+t.offsetHeight})},triggerOnKeyDown:Tr(pi),triggerOnKeyPress:Tr(vi),triggerOnKeyUp:gi,triggerOnMouseDown:Tr(mi),execCommand:function(e){if(ml.hasOwnProperty(e))return ml[e].call(null,this)},triggerElectric:Tr(function(e){Oi(this,e)}),findPosH:function(e,t,r,n){var i=1;t<0&&(i=-1,t=-t);for(var o=ue(this.doc,e),l=0;l0&&l(t.charAt(r-1));)--r;for(;n.5||this.options.lineWrapping)&&Vt(this),A(this,"refresh",this)}),swapDoc:Tr(function(e){var t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),en(this,e),Lt(this),this.display.input.reset(),fr(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}},H(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 Ol="iter insert remove copy getEditor constructor".split(" ");for(var Dl in ul.prototype)ul.prototype.hasOwnProperty(Dl)&&f(Ol,Dl)<0&&(ki.prototype[Dl]=function(e){return function(){return e.apply(this.doc,arguments)}}(ul.prototype[Dl]));return H(ul),ki.inputStyles={textarea:Al,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)),Ho[e]=t}.apply(this,arguments)},ki.defineMIME=function(e,t){Fo[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&&(Mo(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(n){n.save=r,n.getTextArea=function(){return e},n.toTextArea=function(){n.toTextArea=isNaN,r(),e.parentNode.removeChild(n.getWrapperElement()),e.style.display="",e.form&&(N(e.form,"submit",r),t.leaveSubmitMethodAlone||"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=N,e.on=Mo,e.wheelEventPixels=Gr,e.Doc=ul,e.splitLines=Ao,e.countColumn=h,e.findColumn=d,e.isWordChar=b,e.Pass=mo,e.signal=A,e.Line=Uo,e.changeEnd=jr,e.scrollbarModel=Zo,e.Pos=re,e.cmpPos=ne,e.modes=Ho,e.mimeModes=Fo,e.resolveMode=U,e.getMode=V,e.modeExtensions=Po,e.extendMode=K,e.copyState=j,e.startState=Y,e.innerMode=X,e.commands=ml,e.keyMap=vl,e.keyName=ti,e.isModifierKey=Jn,e.lookupKey=Qn,e.normalizeKeyMap=Zn,e.StringStream=Eo,e.SharedTextMarker=sl,e.TextMarker=ll,e.LineWidget=il,e.e_preventDefault=F,e.e_stopPropagation=P,e.e_stop=I,e.addClass=s,e.contains=o,e.rmClass=co,e.keyNames=fl}(ki),ki.version="5.57.0",ki});