Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

function _typeof(e){if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(e){return typeof e}}else{_typeof=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return _typeof(e)}(function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define ("block_configurable_reports/codemirror",t):e.CodeMirror=t()})(this,function(){'use strict';var fl=navigator.userAgent,ml=navigator.platform,yl=/gecko\/\d/i.test(fl),xl=/MSIE \d/.test(fl),vl=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(fl),bl=/Edge\/(\d+)/.exec(fl),Cl=xl||vl||bl,ie=Cl&&(xl?document.documentMode||6:+(bl||vl)[1]),wl=!bl&&/WebKit\//.test(fl),Sl=wl&&/Qt\/\d+\.\d+/.test(fl),Ll=!bl&&/Chrome\//.test(fl),kl=/Opera\//.test(fl),Tl=/Apple Computer/.test(navigator.vendor),Nl=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(fl),Ol=/PhantomJS/.test(fl),Al=!bl&&/AppleWebKit/.test(fl)&&/Mobile\/\w+/.test(fl),Ml=/Android/.test(fl),Wl=Al||Ml||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(fl),Dl=Al||/Mac/.test(ml),Hl=/\bCrOS\b/.test(fl),Fl=/win/i.test(ml),Pl=kl&&fl.match(/Version\/(\d*\.\d*)/);if(Pl){Pl=+Pl[1]}if(Pl&&15<=Pl){kl=!1;wl=!0}var Il=Dl&&(Sl||kl&&(null==Pl||12.11>Pl)),zl=yl||Cl&&9<=ie;function e(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var El=function(t,i){var n=t.className,o=e(i).exec(n);if(o){var r=n.slice(o.index+o[0].length);t.className=n.slice(0,o.index)+(r?o[1]+r:"")}};function t(t){for(var e=t.childNodes.length;0<e;--e){t.removeChild(t.firstChild)}return t}function n(i,n){return t(i).appendChild(n)}function o(t,n,o,r){var l=document.createElement(t);if(o){l.className=o}if(r){l.style.cssText=r}if("string"==typeof n){l.appendChild(document.createTextNode(n))}else if(n){for(var e=0;e<n.length;++e){l.appendChild(n[e])}}return l}function r(t,i,n,r){var l=o(t,i,n,r);l.setAttribute("role","presentation");return l}var Rl;if(document.createRange){Rl=function(e,t,i,n){var o=document.createRange();o.setEnd(n||e,i);o.setStart(e,t);return o}}else{Rl=function(e,t,i){var n=document.body.createTextRange();try{n.moveToElementText(e.parentNode)}catch(t){return n}n.collapse(!0);n.moveEnd("character",i);n.moveStart("character",t);return n}}function l(e,t){if(3==t.nodeType){t=t.parentNode}if(e.contains){return e.contains(t)}do{if(11==t.nodeType){t=t.host}if(t==e){return!0}}while(t=t.parentNode)}function s(){var t;try{t=document.activeElement}catch(i){t=document.body||null}while(t&&t.shadowRoot&&t.shadowRoot.activeElement){t=t.shadowRoot.activeElement}return t}function d(t,i){var n=t.className;if(!e(i).test(n)){t.className+=(n?" ":"")+i}}function a(t,n){for(var o=t.split(" "),r=0;r<o.length;r++){if(o[r]&&!e(o[r]).test(n)){n+=" "+o[r]}}return n}var Bl=function(e){e.select()};if(Al){Bl=function(e){e.selectionStart=0;e.selectionEnd=e.value.length}}else if(Cl){Bl=function(e){try{e.select()}catch(e){}}}function p(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function c(e,t,i){if(!t){t={}}for(var n in e){if(e.hasOwnProperty(n)&&(!1!==i||!t.hasOwnProperty(n))){t[n]=e[n]}}return t}function h(e,t,o,r,l){if(null==t){t=e.search(/[^\s\u00a0]/);if(-1==t){t=e.length}}for(var s=r||0,d=l||0,a;;){a=e.indexOf("\t",s);if(0>a||a>=t){return d+(t-s)}d+=a-s;d+=o-d%o;s=a+1}}var Gl=function(){this.id=null};Gl.prototype.set=function(e,t){clearTimeout(this.id);this.id=setTimeout(t,e)};function g(e,t){for(var n=0;n<e.length;++n){if(e[n]==t){return n}}return-1}var $l={toString:function toString(){return"CodeMirror.Pass"}},Ul={scroll:!1},jl={origin:"*mouse"},Vl={origin:"+move"};function u(e,t,i){for(var n=0,o=0,r;;){r=e.indexOf("\t",n);if(-1==r){r=e.length}var l=r-n;if(r==e.length||o+l>=t){return n+Math.min(l,t-o)}o+=r-n;o+=i-o%i;n=r+1;if(o>=t){return n}}}var Kl=[""];function f(e){while(Kl.length<=e){Kl.push(y(Kl)+" ")}return Kl[e]}function y(e){return e[e.length-1]}function x(e,t){for(var n=[],o=0;o<e.length;o++){n[o]=t(e[o],o)}return n}function v(e,t,i){var n=0,o=i(t);while(n<e.length&&i(e[n])<=o){n++}e.splice(n,0,t)}function b(){}function C(e,t){var i;if(Object.create){i=Object.create(e)}else{b.prototype=e;i=new b}if(t){c(t,i)}return i}var Xl=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function w(e){return /\w/.test(e)||"\x80"<e&&(e.toUpperCase()!=e.toLowerCase()||Xl.test(e))}function S(e,t){if(!t){return w(e)}if(-1<t.source.indexOf("\\w")&&w(e)){return!0}return t.test(e)}function L(e){for(var t in e){if(e.hasOwnProperty(t)&&e[t]){return!1}}return!0}var Yl=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function k(e){return 768<=e.charCodeAt(0)&&Yl.test(e)}function T(e,t,i){while((0>i?0<t:t<e.length)&&k(e.charAt(t))){t+=i}return t}function N(e,t,i){var n=t>i?-1:1;for(;;){if(t==i){return t}var o=(t+i)/2,r=0>n?Math.ceil(o):Math.floor(o);if(r==t){return e(r)?t:i}if(e(r)){i=r}else{t=r+n}}}function O(e,t,i){var n=this;this.input=i;n.scrollbarFiller=o("div",null,"CodeMirror-scrollbar-filler");n.scrollbarFiller.setAttribute("cm-not-content","true");n.gutterFiller=o("div",null,"CodeMirror-gutter-filler");n.gutterFiller.setAttribute("cm-not-content","true");n.lineDiv=r("div",null,"CodeMirror-code");n.selectionDiv=o("div",null,null,"position: relative; z-index: 1");n.cursorDiv=o("div",null,"CodeMirror-cursors");n.measure=o("div",null,"CodeMirror-measure");n.lineMeasure=o("div",null,"CodeMirror-measure");n.lineSpace=r("div",[n.measure,n.lineMeasure,n.selectionDiv,n.cursorDiv,n.lineDiv],null,"position: relative; outline: none");var l=r("div",[n.lineSpace],"CodeMirror-lines");n.mover=o("div",[l],null,"position: relative");n.sizer=o("div",[n.mover],"CodeMirror-sizer");n.sizerWidth=null;n.heightForcer=o("div",null,null,"position: absolute; height: 30px; width: 1px;");n.gutters=o("div",null,"CodeMirror-gutters");n.lineGutter=null;n.scroller=o("div",[n.sizer,n.heightForcer,n.gutters],"CodeMirror-scroll");n.scroller.setAttribute("tabIndex","-1");n.wrapper=o("div",[n.scrollbarFiller,n.gutterFiller,n.scroller],"CodeMirror");if(Cl&&8>ie){n.gutters.style.zIndex=-1;n.scroller.style.paddingRight=0}if(!wl&&!(yl&&Wl)){n.scroller.draggable=!0}if(e){if(e.appendChild){e.appendChild(n.wrapper)}else{e(n.wrapper)}}n.viewFrom=n.viewTo=t.first;n.reportedViewFrom=n.reportedViewTo=t.first;n.view=[];n.renderedView=null;n.externalMeasured=null;n.viewOffset=0;n.lastWrapHeight=n.lastWrapWidth=0;n.updateLineNumbers=null;n.nativeBarWidth=n.barHeight=n.barWidth=0;n.scrollbarsClipped=!1;n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null;n.alignWidgets=!1;n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null;n.maxLine=null;n.maxLineLength=0;n.maxLineChanged=!1;n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null;n.shift=!1;n.selForContextMenu=null;n.activeTouch=null;i.init(n)}function A(e,t){t-=e.first;if(0>t||t>=e.size){throw new Error("There is no line "+(t+e.first)+" in the document.")}var o=e;while(!o.lines){for(var r=0;;++r){var l=o.children[r],s=l.chunkSize();if(t<s){o=l;break}t-=s}}return o.lines[t]}function M(e,t,i){var o=[],r=t.line;e.iter(t.line,i.line+1,function(e){var n=e.text;if(r==i.line){n=n.slice(0,i.ch)}if(r==t.line){n=n.slice(t.ch)}o.push(n);++r});return o}function W(e,t,i){var n=[];e.iter(t,i,function(e){n.push(e.text)});return n}function D(e,t){var i=t-e.height;if(i){for(var o=e;o;o=o.parent){o.height+=i}}}function H(e){if(null==e.parent){return null}for(var t=e.parent,n=g(t.lines,e),o=t.parent;o;t=o,o=o.parent){for(var r=0;;++r){if(o.children[r]==t){break}n+=o.children[r].chunkSize()}}return n+t.first}function F(e,t){var o=e.first;outer:do{for(var r=0;r<e.children.length;++r){var l=e.children[r],s=l.height;if(t<s){e=l;continue outer}t-=s;o+=l.chunkSize()}return o}while(!e.lines);var d=0;for(;d<e.lines.length;++d){var a=e.lines[d],p=a.height;if(t<p){break}t-=p}return o+d}function P(e,t){return t>=e.first&&t<e.first+e.size}function I(e,t){return e.lineNumberFormatter(t+e.firstLineNumber)+""}function z(e,t,i){if(void 0===i)i=null;if(!(this instanceof z)){return new z(e,t,i)}this.line=e;this.ch=t;this.sticky=i}function E(e,t){return e.line-t.line||e.ch-t.ch}function R(e,t){return e.sticky==t.sticky&&0==E(e,t)}function B(e){return z(e.line,e.ch)}function G(e,t){return 0>E(e,t)?t:e}function $(e,t){return 0>E(e,t)?e:t}function U(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function j(e,t){if(t.line<e.first){return z(e.first,0)}var i=e.first+e.size-1;if(t.line>i){return z(i,A(e,i).text.length)}return V(t,A(e,t.line).text.length)}function V(e,t){var i=e.ch;if(null==i||i>t){return z(e.line,t)}else if(0>i){return z(e.line,0)}else{return e}}function K(e,t){for(var n=[],o=0;o<t.length;o++){n[o]=j(e,t[o])}return n}var _l=!1,ql=!1;function X(){_l=!0}function Y(){ql=!0}function _(e,t,i){this.marker=e;this.from=t;this.to=i}function q(e,t){if(e){for(var n=0,o;n<e.length;++n){o=e[n];if(o.marker==t){return o}}}}function Z(e,t){for(var n,o=0;o<e.length;++o){if(e[o]!=t){(n||(n=[])).push(e[o])}}return n}function Q(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t];t.marker.attachLine(e)}function J(e,t,n){var o;if(e){for(var r=0;r<e.length;++r){var l=e[r],s=l.marker,d=null==l.from||(s.inclusiveLeft?l.from<=t:l.from<t);if(d||l.from==t&&"bookmark"==s.type&&(!n||!l.marker.insertLeft)){var a=null==l.to||(s.inclusiveRight?l.to>=t:l.to>t);(o||(o=[])).push(new _(s,l.from,a?null:l.to))}}}return o}function ee(e,t,n){var o;if(e){for(var r=0;r<e.length;++r){var l=e[r],s=l.marker,d=null==l.to||(s.inclusiveRight?l.to>=t:l.to>t);if(d||l.from==t&&"bookmark"==s.type&&(!n||l.marker.insertLeft)){var a=null==l.from||(s.inclusiveLeft?l.from<=t:l.from<t);(o||(o=[])).push(new _(s,a?null:l.from-t,null==l.to?null:l.to-t))}}}return o}function te(e,t){if(t.full){return null}var n=P(e,t.from.line)&&A(e,t.from.line).markedSpans,o=P(e,t.to.line)&&A(e,t.to.line).markedSpans;if(!n&&!o){return null}var r=t.from.ch,l=t.to.ch,s=0==E(t.from,t.to),d=J(n,r,s),a=ee(o,l,s),p=1==t.text.length,c=y(t.text).length+(p?r:0);if(d){for(var h=0,g;h<d.length;++h){g=d[h];if(null==g.to){var u=q(a,g.marker);if(!u){g.to=r}else if(p){g.to=null==u.to?null:u.to+c}}}}if(a){for(var f=0,m;f<a.length;++f){m=a[f];if(null!=m.to){m.to+=c}if(null==m.from){var x=q(d,m.marker);if(!x){m.from=c;if(p){(d||(d=[])).push(m)}}}else{m.from+=c;if(p){(d||(d=[])).push(m)}}}}if(d){d=ne(d)}if(a&&a!=d){a=ne(a)}var v=[d];if(!p){var b=t.text.length-2,C;if(0<b&&d){for(var w=0;w<d.length;++w){if(null==d[w].to){(C||(C=[])).push(new _(d[w].marker,null,null))}}}for(var S=0;S<b;++S){v.push(C)}v.push(a)}return v}function ne(e){for(var t=0,n;t<e.length;++t){n=e[t];if(null!=n.from&&n.from==n.to&&!1!==n.marker.clearWhenEmpty){e.splice(t--,1)}}if(!e.length){return null}return e}function oe(e,t,n){var o=null;e.iter(t.line,n.line+1,function(e){if(e.markedSpans){for(var t=0,n;t<e.markedSpans.length;++t){n=e.markedSpans[t].marker;if(n.readOnly&&(!o||-1==g(o,n))){(o||(o=[])).push(n)}}}});if(!o){return null}for(var r=[{from:t,to:n}],l=0;l<o.length;++l){for(var s=o[l],d=s.find(0),a=0,c;a<r.length;++a){c=r[a];if(0>E(c.to,d.from)||0<E(c.from,d.to)){continue}var h=[a,1],u=E(c.from,d.from),f=E(c.to,d.to);if(0>u||!s.inclusiveLeft&&!u){h.push({from:c.from,to:d.from})}if(0<f||!s.inclusiveRight&&!f){h.push({from:d.to,to:c.to})}r.splice.apply(r,h);a+=h.length-3}}return r}function re(e){var t=e.markedSpans;if(!t){return}for(var n=0;n<t.length;++n){t[n].marker.detachLine(e)}e.markedSpans=null}function le(e,t){if(!t){return}for(var n=0;n<t.length;++n){t[n].marker.attachLine(e)}e.markedSpans=t}function se(e){return e.inclusiveLeft?-1:0}function de(e){return e.inclusiveRight?1:0}function ae(e,t){var i=e.lines.length-t.lines.length;if(0!=i){return i}var n=e.find(),o=t.find(),r=E(n.from,o.from)||se(e)-se(t);if(r){return-r}var l=E(n.to,o.to)||de(e)-de(t);if(l){return l}return t.id-e.id}function pe(e,t){var n=ql&&e.markedSpans,o;if(n){for(var r=void 0,l=0;l<n.length;++l){r=n[l];if(r.marker.collapsed&&null==(t?r.from:r.to)&&(!o||0>ae(o,r.marker))){o=r.marker}}}return o}function ce(e){return pe(e,!0)}function he(e){return pe(e,!1)}function ge(e,t){var n=ql&&e.markedSpans,o;if(n){for(var r=0,l;r<n.length;++r){l=n[r];if(l.marker.collapsed&&(null==l.from||l.from<t)&&(null==l.to||l.to>t)&&(!o||0>ae(o,l.marker))){o=l.marker}}}return o}function ue(e,t,n,o,r){var l=A(e,t),s=ql&&l.markedSpans;if(s){for(var d=0,a;d<s.length;++d){a=s[d];if(!a.marker.collapsed){continue}var p=a.marker.find(0),c=E(p.from,n)||se(a.marker)-se(r),h=E(p.to,o)||de(a.marker)-de(r);if(0<=c&&0>=h||0>=c&&0<=h){continue}if(0>=c&&(a.marker.inclusiveRight&&r.inclusiveLeft?0<=E(p.to,n):0<E(p.to,n))||0<=c&&(a.marker.inclusiveRight&&r.inclusiveLeft?0>=E(p.from,o):0>E(p.from,o))){return!0}}}}function fe(e){var t;while(t=ce(e)){e=t.find(-1,!0).line}return e}function me(e){var t;while(t=he(e)){e=t.find(1,!0).line}return e}function ye(e){var t,i;while(t=he(e)){e=t.find(1,!0).line;(i||(i=[])).push(e)}return i}function xe(e,t){var i=A(e,t),n=fe(i);if(i==n){return t}return H(n)}function ve(e,t){if(t>e.lastLine()){return t}var i=A(e,t),n;if(!be(e,i)){return t}while(n=he(i)){i=n.find(1,!0).line}return H(i)+1}function be(e,t){var n=ql&&t.markedSpans;if(n){for(var o=void 0,r=0;r<n.length;++r){o=n[r];if(!o.marker.collapsed){continue}if(null==o.from){return!0}if(o.marker.widgetNode){continue}if(0==o.from&&o.marker.inclusiveLeft&&Ce(e,t,o)){return!0}}}}function Ce(e,t,n){if(null==n.to){var o=n.marker.find(1,!0);return Ce(e,o.line,q(o.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==t.text.length){return!0}for(var r=void 0,l=0;l<t.markedSpans.length;++l){r=t.markedSpans[l];if(r.marker.collapsed&&!r.marker.widgetNode&&r.from==n.to&&(null==r.to||r.to!=n.from)&&(r.marker.inclusiveLeft||n.marker.inclusiveRight)&&Ce(e,t,r)){return!0}}}function we(e){e=fe(e);for(var t=0,n=e.parent,o=0,r;o<n.lines.length;++o){r=n.lines[o];if(r==e){break}else{t+=r.height}}for(var l=n.parent;l;n=l,l=n.parent){for(var s=0,d;s<l.children.length;++s){d=l.children[s];if(d==n){break}else{t+=d.height}}}return t}function Se(e){if(0==e.height){return 0}var t=e.text.length,i,n=e;while(i=ce(n)){var o=i.find(0,!0);n=o.from.line;t+=o.from.ch-o.to.ch}n=e;while(i=he(n)){var r=i.find(0,!0);t-=n.text.length-r.from.ch;n=r.to.line;t+=n.text.length-r.to.ch}return t}function Le(e){var t=e.display,i=e.doc;t.maxLine=A(i,i.first);t.maxLineLength=Se(t.maxLine);t.maxLineChanged=!0;i.iter(function(e){var i=Se(e);if(i>t.maxLineLength){t.maxLineLength=i;t.maxLine=e}})}function ke(e,t,n,o){if(!e){return o(t,n,"ltr",0)}for(var r=!1,l=0,s;l<e.length;++l){s=e[l];if(s.from<n&&s.to>t||t==n&&s.to==t){o(Math.max(s.from,t),Math.min(s.to,n),1==s.level?"rtl":"ltr",l);r=!0}}if(!r){o(t,n,"ltr")}}var Zl=null;function Te(e,t,n){var o;Zl=null;for(var r=0,l;r<e.length;++r){l=e[r];if(l.from<t&&l.to>t){return r}if(l.to==t){if(l.from!=l.to&&"before"==n){o=r}else{Zl=r}}if(l.from==t){if(l.from!=l.to&&"before"!=n){o=r}else{Zl=r}}}return null!=o?o:Zl}var Ql=function(){function e(e){if(247>=e){return"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(e)}else if(1424<=e&&1524>=e){return"R"}else if(1536<=e&&1785>=e){return"nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111".charAt(e-1536)}else if(1774<=e&&2220>=e){return"r"}else if(8192<=e&&8203>=e){return"w"}else if(8204==e){return"b"}else{return"L"}}var n=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,r=/[LRr]/,l=/[Lb1n]/,s=/[1n]/;function t(e,t,i){this.level=e;this.from=t;this.to=i}return function(d,a){var p="ltr"==a?"L":"R";if(0==d.length||"ltr"==a&&!n.test(d)){return!1}for(var c=d.length,h=[],g=0;g<c;++g){h.push(e(d.charCodeAt(g)))}for(var u=0,f=p,x;u<c;++u){x=h[u];if("m"==x){h[u]=f}else{f=x}}for(var v=0,b=p,C;v<c;++v){C=h[v];if("1"==C&&"r"==b){h[v]="n"}else if(r.test(C)){b=C;if("r"==C){h[v]="R"}}}for(var w=1,S=h[0],L;w<c-1;++w){L=h[w];if("+"==L&&"1"==S&&"1"==h[w+1]){h[w]="1"}else if(","==L&&S==h[w+1]&&("1"==S||"n"==S)){h[w]=S}S=L}for(var k=0,T;k<c;++k){T=h[k];if(","==T){h[k]="N"}else if("%"==T){var N=void 0;for(N=k+1;N<c&&"%"==h[N];++N){}for(var O=k&&"!"==h[k-1]||N<c&&"1"==h[N]?"1":"N",A=k;A<N;++A){h[A]=O}k=N-1}}for(var M=0,W=p,D;M<c;++M){D=h[M];if("L"==W&&"1"==D){h[M]="L"}else if(r.test(D)){W=D}}for(var H=0;H<c;++H){if(o.test(h[H])){var F=void 0;for(F=H+1;F<c&&o.test(h[F]);++F){}for(var P="L"==(H?h[H-1]:p),I="L"==(F<c?h[F]:p),z=P==I?P?"L":"R":p,E=H;E<F;++E){h[E]=z}H=F-1}}for(var R=[],B,G=0;G<c;){if(l.test(h[G])){var $=G;for(++G;G<c&&l.test(h[G]);++G){}R.push(new t(0,$,G))}else{var U=G,V=R.length;for(++G;G<c&&"L"!=h[G];++G){}for(var K=U;K<G;){if(s.test(h[K])){if(U<K){R.splice(V,0,new t(1,U,K))}var X=K;for(++K;K<G&&s.test(h[K]);++K){}R.splice(V,0,new t(2,X,K));U=K}else{++K}}if(U<G){R.splice(V,0,new t(1,U,G))}}}if("ltr"==a){if(1==R[0].level&&(B=d.match(/^\s+/))){R[0].from=B[0].length;R.unshift(new t(0,0,B[0].length))}if(1==y(R).level&&(B=d.match(/\s+$/))){y(R).to-=B[0].length;R.push(new t(0,c-B[0].length,c))}}return"rtl"==a?R.reverse():R}}();function Ne(e,t){var i=e.order;if(null==i){i=e.order=Ql(e.text,t)}return i}var Jl=[],es=function(e,t,i){if(e.addEventListener){e.addEventListener(t,i,!1)}else if(e.attachEvent){e.attachEvent("on"+t,i)}else{var n=e._handlers||(e._handlers={});n[t]=(n[t]||Jl).concat(i)}};function Oe(e,t){return e._handlers&&e._handlers[t]||Jl}function Ae(e,t,i){if(e.removeEventListener){e.removeEventListener(t,i,!1)}else if(e.detachEvent){e.detachEvent("on"+t,i)}else{var n=e._handlers,o=n&&n[t];if(o){var r=g(o,i);if(-1<r){n[t]=o.slice(0,r).concat(o.slice(r+1))}}}}function Me(e,t){var n=Oe(e,t);if(!n.length){return}for(var o=Array.prototype.slice.call(arguments,2),r=0;r<n.length;++r){n[r].apply(null,o)}}function We(t,i,n){if("string"==typeof i){i={type:i,preventDefault:function preventDefault(){this.defaultPrevented=!0}}}Me(t,n||i.type,t,i);return ze(i)||i.codemirrorIgnore}function De(e){var t=e._handlers&&e._handlers.cursorActivity;if(!t){return}for(var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),o=0;o<t.length;++o){if(-1==g(n,t[o])){n.push(t[o])}}}function He(e,t){return 0<Oe(e,t).length}function Fe(e){e.prototype.on=function(e,t){es(this,e,t)};e.prototype.off=function(e,t){Ae(this,e,t)}}function Pe(t){if(t.preventDefault){t.preventDefault()}else{t.returnValue=!1}}function Ie(t){if(t.stopPropagation){t.stopPropagation()}else{t.cancelBubble=!0}}function ze(t){return null!=t.defaultPrevented?t.defaultPrevented:!1==t.returnValue}function Ee(t){Pe(t);Ie(t)}function Re(t){return t.target||t.srcElement}function Be(t){var e=t.which;if(null==e){if(1&t.button){e=1}else if(2&t.button){e=3}else if(4&t.button){e=2}}if(Dl&&t.ctrlKey&&1==e){e=3}return e}var m=function(){if(Cl&&9>ie){return!1}var e=o("div");return"draggable"in e||"dragDrop"in e}(),on;function Ge(e){if(null==on){var t=o("span","\u200B");n(e,o("span",[t,document.createTextNode("x")]));if(0!=e.firstChild.offsetHeight){on=1>=t.offsetWidth&&2<t.offsetHeight&&!(Cl&&8>ie)}}var i=on?o("span","\u200B"):o("span","\xA0",null,"display: inline-block; width: 1px; margin-right: -1px");i.setAttribute("cm-text","");return i}var ts;function $e(e){if(null!=ts){return ts}var i=n(e,document.createTextNode("A\u062EA")),o=Rl(i,0,1).getBoundingClientRect(),r=Rl(i,1,2).getBoundingClientRect();t(e);if(!o||o.left==o.right){return!1}return ts=3>r.right-o.right}var is=3!="\n\nb".split(/\n/).length?function(e){var t=0,i=[],n=e.length;while(t<=n){var o=e.indexOf("\n",t);if(-1==o){o=e.length}var r=e.slice(t,"\r"==e.charAt(o-1)?o-1:o),l=r.indexOf("\r");if(-1!=l){i.push(r.slice(0,l));t+=l+1}else{i.push(r);t=o+1}}return i}:function(e){return e.split(/\r\n?|\n/)},ns=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(t){}if(!t||t.parentElement()!=e){return!1}return 0!=t.compareEndPoints("StartToEnd",t)},os=function(){var t=o("div");if("oncopy"in t){return!0}t.setAttribute("oncopy","return;");return"function"==typeof t.oncopy}(),rs=null;function Ue(e){if(null!=rs){return rs}var t=n(e,o("span","x")),i=t.getBoundingClientRect(),r=Rl(t,0,1).getBoundingClientRect();return rs=1<Math.abs(i.left-r.left)}var ls={},ss={};function je(e,t){if(2<arguments.length){t.dependencies=Array.prototype.slice.call(arguments,2)}ls[e]=t}function Ve(e){if("string"==typeof e&&ss.hasOwnProperty(e)){e=ss[e]}else if(e&&"string"==typeof e.name&&ss.hasOwnProperty(e.name)){var t=ss[e.name];if("string"==typeof t){t={name:t}}e=C(t,e);e.name=t.name}else if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e)){return Ve("application/xml")}else if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e)){return Ve("application/json")}if("string"==typeof e){return{name:e}}else{return e||{name:"null"}}}function Ke(e,t){t=Ve(t);var i=ls[t.name];if(!i){return Ke(e,"text/plain")}var n=i(e,t);if(ds.hasOwnProperty(t.name)){var o=ds[t.name];for(var r in o){if(!o.hasOwnProperty(r)){continue}if(n.hasOwnProperty(r)){n["_"+r]=n[r]}n[r]=o[r]}}n.name=t.name;if(t.helperType){n.helperType=t.helperType}if(t.modeProps){for(var l in t.modeProps){n[l]=t.modeProps[l]}}return n}var ds={};function Xe(e,t){var i=ds.hasOwnProperty(e)?ds[e]:ds[e]={};c(t,i)}function Ye(e,t){if(!0===t){return t}if(e.copyState){return e.copyState(t)}var i={};for(var o in t){var n=t[o];if(n instanceof Array){n=n.concat([])}i[o]=n}return i}function _e(e,t){var i;while(e.innerMode){i=e.innerMode(t);if(!i||i.mode==e){break}t=i.state;e=i.mode}return i||{mode:e,state:t}}function qe(e,t,i){return e.startState?e.startState(t,i):!0}var as=function(e,t,i){this.pos=this.start=0;this.string=e;this.tabSize=t||8;this.lastColumnPos=this.lastColumnValue=0;this.lineStart=0;this.lineOracle=i};as.prototype.eol=function(){return this.pos>=this.string.length};as.prototype.sol=function(){return this.pos==this.lineStart};as.prototype.peek=function(){return this.string.charAt(this.pos)||void 0};as.prototype.next=function(){if(this.pos<this.string.length){return this.string.charAt(this.pos++)}};as.prototype.eat=function(e){var t=this.string.charAt(this.pos),i;if("string"==typeof e){i=t==e}else{i=t&&(e.test?e.test(t):e(t))}if(i){++this.pos;return t}};as.prototype.eatWhile=function(e){var t=this.pos;while(this.eat(e)){}return this.pos>t};as.prototype.eatSpace=function(){var e=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos))){++this.pos}return this.pos>e};as.prototype.skipToEnd=function(){this.pos=this.string.length};as.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(-1<t){this.pos=t;return!0}};as.prototype.backUp=function(e){this.pos-=e};as.prototype.column=function(){if(this.lastColumnPos<this.start){this.lastColumnValue=h(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue);this.lastColumnPos=this.start}return this.lastColumnValue-(this.lineStart?h(this.string,this.lineStart,this.tabSize):0)};as.prototype.indentation=function(){return h(this.string,null,this.tabSize)-(this.lineStart?h(this.string,this.lineStart,this.tabSize):0)};as.prototype.match=function(e,t,i){if("string"==typeof e){var n=function(e){return i?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);if(n(o)==n(e)){if(!1!==t){this.pos+=e.length}return!0}}else{var r=this.string.slice(this.pos).match(e);if(r&&0<r.index){return null}if(r&&!1!==t){this.pos+=r[0].length}return r}};as.prototype.current=function(){return this.string.slice(this.start,this.pos)};as.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}};as.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)};as.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var ps=function(e,t){this.state=e;this.lookAhead=t},cs=function(e,t,i,n){this.state=t;this.doc=e;this.line=i;this.maxLookAhead=n||0;this.baseTokens=null;this.baseTokenPos=1};cs.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);if(null!=t&&e>this.maxLookAhead){this.maxLookAhead=e}return t};cs.prototype.baseToken=function(e){if(!this.baseTokens){return null}while(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}};cs.prototype.nextLine=function(){this.line++;if(0<this.maxLookAhead){this.maxLookAhead--}};cs.fromSaved=function(e,t,i){if(t instanceof ps){return new cs(e,Ye(e.mode,t.state),i,t.lookAhead)}else{return new cs(e,Ye(e.mode,t),i)}};cs.prototype.save=function(e){var t=!1!==e?Ye(this.doc.mode,this.state):this.state;return 0<this.maxLookAhead?new ps(t,this.maxLookAhead):t};function Ze(e,t,n,r){var l=[e.state.modeGen],s={};rt(e,t.text,e.doc.mode,n,function(e,t){return l.push(e,t)},s,r);for(var d=n.state,a=function(r){n.baseTokens=l;var o=e.state.overlays[r],a=1,p=0;n.state=!0;rt(e,t.text,o.mode,n,function(e,t){var i=a;while(p<e){var n=l[a];if(n>e){l.splice(a,1,e,l[a+1],n)}a+=2;p=Math.min(e,n)}if(!t){return}if(o.opaque){l.splice(i,a-i,e,"overlay "+t);a=i+2}else{for(;i<a;i+=2){var r=l[i+1];l[i+1]=(r?r+" ":"")+"overlay "+t}}},s);n.state=d;n.baseTokens=null;n.baseTokenPos=1},p=0;p<e.state.overlays.length;++p){a(p)}return{styles:l,classes:s.bgClass||s.textClass?s:null}}function Qe(e,t,i){if(!t.styles||t.styles[0]!=e.state.modeGen){var n=Je(e,H(t)),o=t.text.length>e.options.maxHighlightLength&&Ye(e.doc.mode,n.state),r=Ze(e,t,n);if(o){n.state=o}t.stateAfter=n.save(!o);t.styles=r.styles;if(r.classes){t.styleClasses=r.classes}else if(t.styleClasses){t.styleClasses=null}if(i===e.doc.highlightFrontier){e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier)}}return t.styles}function Je(e,t,i){var n=e.doc,o=e.display;if(!n.mode.startState){return new cs(n,!0,t)}var r=lt(e,t,i),l=r>n.first&&A(n,r-1).stateAfter,s=l?cs.fromSaved(n,l,r):new cs(n,qe(n.mode),r);n.iter(r,t,function(i){et(e,i.text,s);var n=s.line;i.stateAfter=n==t-1||0==n%5||n>=o.viewFrom&&n<o.viewTo?s.save():null;s.nextLine()});if(i){n.modeFrontier=s.line}return s}function et(e,t,i,n){var o=e.doc.mode,r=new as(t,e.options.tabSize,i);r.start=r.pos=n||0;if(""==t){tt(o,i.state)}while(!r.eol()){it(o,r,i.state);r.start=r.pos}}function tt(e,t){if(e.blankLine){return e.blankLine(t)}if(!e.innerMode){return}var i=_e(e,t);if(i.mode.blankLine){return i.mode.blankLine(i.state)}}function it(e,t,n,o){for(var r=0;10>r;r++){if(o){o[0]=_e(e,n).mode}var l=e.token(t,n);if(t.pos>t.start){return l}}throw new Error("Mode "+e.name+" failed to advance stream.")}var hs=function(e,t,i){this.start=e.start;this.end=e.pos;this.string=e.current();this.type=t||null;this.state=i};function nt(e,t,i,n){var o=e.doc,r=o.mode,l;t=j(o,t);var s=A(o,t.line),d=Je(e,t.line,i),a=new as(s.text,e.options.tabSize,d),p;if(n){p=[]}while((n||a.pos<t.ch)&&!a.eol()){a.start=a.pos;l=it(r,a,d.state);if(n){p.push(new hs(a,l,Ye(o.mode,d.state)))}}return n?p:new hs(a,l,d.state)}function ot(e,t){if(e){for(;;){var i=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!i){break}e=e.slice(0,i.index)+e.slice(i.index+i[0].length);var n=i[1]?"bgClass":"textClass";if(null==t[n]){t[n]=i[2]}else if(!new RegExp("(?:^|s)"+i[2]+"(?:$|s)").test(t[n])){t[n]+=" "+i[2]}}}return e}function rt(e,t,i,n,o,r,l){var s=i.flattenSpans;if(null==s){s=e.options.flattenSpans}var d=0,a=null,p=new as(t,e.options.tabSize,n),c,h=e.options.addModeClass&&[null];if(""==t){ot(tt(i,n.state),r)}while(!p.eol()){if(p.pos>e.options.maxHighlightLength){s=!1;if(l){et(e,t,n,p.pos)}p.pos=t.length;c=null}else{c=ot(it(i,p,n.state,h),r)}if(h){var g=h[0].name;if(g){c="m-"+(c?g+" "+c:g)}}if(!s||a!=c){while(d<p.start){d=Math.min(p.start,d+5e3);o(d,a)}a=c}p.start=p.pos}while(d<p.pos){var u=Math.min(p.pos,d+5e3);o(u,a);d=u}}function lt(e,t,i){for(var n,o,r=e.doc,l=i?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;s>l;--s){if(s<=r.first){return r.first}var d=A(r,s-1),a=d.stateAfter;if(a&&(!i||s+(a instanceof ps?a.lookAhead:0)<=r.modeFrontier)){return s}var p=h(d.text,null,e.options.tabSize);if(null==o||n>p){o=s-1;n=p}}return o}function st(e,t){e.modeFrontier=Math.min(e.modeFrontier,t);if(e.highlightFrontier<t-10){return}for(var i=e.first,n=t-1,o;n>i;n--){o=A(e,n).stateAfter;if(o&&(!(o instanceof ps)||n+o.lookAhead<t)){i=n+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,i)}var gs=function(e,t,i){this.text=e;le(this,t);this.height=i?i(this):1};gs.prototype.lineNo=function(){return H(this)};Fe(gs);function dt(e,t,i,n){e.text=t;if(e.stateAfter){e.stateAfter=null}if(e.styles){e.styles=null}if(null!=e.order){e.order=null}re(e);le(e,i);var o=n?n(e):1;if(o!=e.height){D(e,o)}}function at(e){e.parent=null;re(e)}var us={},fs={};function pt(e,t){if(!e||/^\s*$/.test(e)){return null}var i=t.addModeClass?fs:us;return i[e]||(i[e]=e.replace(/\S+/g,"cm-$&"))}function ct(e,t){var n=r("span",null,null,wl?"padding-right: .1px":null),o={pre:r("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var l=0;l<=(t.rest?t.rest.length:0);l++){var s=l?t.rest[l-1]:t.line,d=void 0;o.pos=0;o.addToken=gt;if($e(e.display.measure)&&(d=Ne(s,e.doc.direction))){o.addToken=ft(o.addToken,d)}o.map=[];var p=t!=e.display.externalMeasured&&H(s);yt(s,o,Qe(e,s,p));if(s.styleClasses){if(s.styleClasses.bgClass){o.bgClass=a(s.styleClasses.bgClass,o.bgClass||"")}if(s.styleClasses.textClass){o.textClass=a(s.styleClasses.textClass,o.textClass||"")}}if(0==o.map.length){o.map.push(0,0,o.content.appendChild(Ge(e.display.measure)))}if(0==l){t.measure.map=o.map;t.measure.cache={}}else{(t.measure.maps||(t.measure.maps=[])).push(o.map);(t.measure.caches||(t.measure.caches=[])).push({})}}if(wl){var c=o.content.lastChild;if(/\bcm-tab\b/.test(c.className)||c.querySelector&&c.querySelector(".cm-tab")){o.content.className="cm-tab-wrap-hack"}}Me(e,"renderLine",e,t.line,o.pre);if(o.pre.className){o.textClass=a(o.pre.className,o.textClass||"")}return o}function ht(e){var t=o("span","\u2022","cm-invalidchar");t.title="\\u"+e.charCodeAt(0).toString(16);t.setAttribute("aria-label",t.title);return t}function gt(e,t,i,n,r,l,s){if(!t){return}var d=e.splitSpaces?ut(t,e.trailingSpace):t,a=e.cm.state.specialChars,p=!1,c;if(!a.test(t)){e.col+=t.length;c=document.createTextNode(d);e.map.push(e.pos,e.pos+t.length,c);if(Cl&&9>ie){p=!0}e.pos+=t.length}else{c=document.createDocumentFragment();var h=0;while(!0){a.lastIndex=h;var g=a.exec(t),u=g?g.index-h:t.length-h;if(u){var m=document.createTextNode(d.slice(h,h+u));if(Cl&&9>ie){c.appendChild(o("span",[m]))}else{c.appendChild(m)}e.map.push(e.pos,e.pos+u,m);e.col+=u;e.pos+=u}if(!g){break}h+=u+1;var y=void 0;if("\t"==g[0]){var x=e.cm.options.tabSize,v=x-e.col%x;y=c.appendChild(o("span",f(v),"cm-tab"));y.setAttribute("role","presentation");y.setAttribute("cm-text","\t");e.col+=v}else if("\r"==g[0]||"\n"==g[0]){y=c.appendChild(o("span","\r"==g[0]?"\u240D":"\u2424","cm-invalidchar"));y.setAttribute("cm-text",g[0]);e.col+=1}else{y=e.cm.options.specialCharPlaceholder(g[0]);y.setAttribute("cm-text",g[0]);if(Cl&&9>ie){c.appendChild(o("span",[y]))}else{c.appendChild(y)}e.col+=1}e.map.push(e.pos,e.pos+1,y);e.pos++}}e.trailingSpace=32==d.charCodeAt(t.length-1);if(i||n||r||p||s){var b=i||"";if(n){b+=n}if(r){b+=r}var C=o("span",[c],b,s);if(l){C.title=l}return e.content.appendChild(C)}e.content.appendChild(c)}function ut(e,t){if(1<e.length&&!/  /.test(e)){return e}for(var n=t,o="",r=0,l;r<e.length;r++){l=e.charAt(r);if(" "==l&&n&&(r==e.length-1||32==e.charCodeAt(r+1))){l="\xA0"}o+=l;n=" "==l}return o}function ft(e,t){return function(n,o,r,l,s,d,a){r=r?r+" cm-force-border":"cm-force-border";var p=n.pos,c=p+o.length;for(;;){for(var h=void 0,g=0;g<t.length;g++){h=t[g];if(h.to>p&&h.from<=p){break}}if(h.to>=c){return e(n,o,r,l,s,d,a)}e(n,o.slice(0,h.to-p),r,l,null,d,a);l=null;o=o.slice(h.to-p);p=h.to}}}function mt(e,t,i,n){var o=!n&&i.widgetNode;if(o){e.map.push(e.pos,e.pos+t,o)}if(!n&&e.cm.display.input.needsContentAttribute){if(!o){o=e.content.appendChild(document.createElement("span"))}o.setAttribute("cm-marker",i.id)}if(o){e.cm.display.input.setUneditable(o);e.content.appendChild(o)}e.pos+=t;e.trailingSpace=!1}function yt(e,t,n){var o=e.markedSpans,r=e.text,l=0;if(!o){for(var s=1;s<n.length;s+=2){t.addToken(t,r.slice(l,l=n[s]),pt(n[s+1],t.cm.options))}return}var d=r.length,a=0,p=1,c="",h,g,u=0,f,y,x,v,b;for(;;){if(u==a){f=y=x=v=g="";b=null;u=1/0;for(var C=[],w=void 0,S=0;S<o.length;++S){var L=o[S],k=L.marker;if("bookmark"==k.type&&L.from==a&&k.widgetNode){C.push(k)}else if(L.from<=a&&(null==L.to||L.to>a||k.collapsed&&L.to==a&&L.from==a)){if(null!=L.to&&L.to!=a&&u>L.to){u=L.to;y=""}if(k.className){f+=" "+k.className}if(k.css){g=(g?g+";":"")+k.css}if(k.startStyle&&L.from==a){x+=" "+k.startStyle}if(k.endStyle&&L.to==u){(w||(w=[])).push(k.endStyle,L.to)}if(k.title&&!v){v=k.title}if(k.collapsed&&(!b||0>ae(b.marker,k))){b=L}}else if(L.from>a&&u>L.from){u=L.from}}if(w){for(var m=0;m<w.length;m+=2){if(w[m+1]==u){y+=" "+w[m]}}}if(!b||b.from==a){for(var T=0;T<C.length;++T){mt(t,0,C[T])}}if(b&&(b.from||0)==a){mt(t,(null==b.to?d+1:b.to)-a,b.marker,null==b.from);if(null==b.to){return}if(b.to==a){b=!1}}}if(a>=d){break}var N=Math.min(d,u);while(!0){if(c){var O=a+c.length;if(!b){var A=O>N?c.slice(0,N-a):c;t.addToken(t,A,h?h+f:f,x,a+A.length==u?y:"",v,g)}if(O>=N){c=c.slice(N-a);a=N;break}a=O;x=""}c=r.slice(l,l=n[p++]);h=pt(n[p++],t.cm.options)}}}function xt(e,t,i){this.line=t;this.rest=ye(t);this.size=this.rest?H(y(this.rest))-i+1:1;this.node=this.text=null;this.hidden=be(e,t)}function vt(e,t,i){for(var n=[],o,r=t,l;r<i;r=o){l=new xt(e.doc,A(e.doc,r),r);o=r+l.size;n.push(l)}return n}var ms=null;function bt(e){if(ms){ms.ops.push(e)}else{e.ownsGroup=ms={ops:[e],delayedCallbacks:[]}}}function Ct(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++){t[n].call(null)}for(var o=0,r;o<e.ops.length;o++){r=e.ops[o];if(r.cursorActivityHandlers){while(r.cursorActivityCalled<r.cursorActivityHandlers.length){r.cursorActivityHandlers[r.cursorActivityCalled++].call(null,r.cm)}}}}while(n<t.length)}function wt(e,t){var i=e.ownsGroup;if(!i){return}try{Ct(i)}finally{ms=null;t(i)}}var ys=null;function St(e,t){var n=Oe(e,t);if(!n.length){return}var o=Array.prototype.slice.call(arguments,2),r;if(ms){r=ms.delayedCallbacks}else if(ys){r=ys}else{r=ys=[];setTimeout(Lt,0)}for(var l=function(e){r.push(function(){return n[e].apply(null,o)})},s=0;s<n.length;++s){l(s)}}function Lt(){var e=ys;ys=null;for(var t=0;t<e.length;++t){e[t]()}}function kt(e,t,i,n){for(var o=0,r;o<t.changes.length;o++){r=t.changes[o];if("text"==r){At(e,t)}else if("gutter"==r){Wt(e,t,i,n)}else if("class"==r){Mt(e,t)}else if("widget"==r){Dt(e,t,n)}}t.changes=null}function Tt(e){if(e.node==e.text){e.node=o("div",null,null,"position: relative");if(e.text.parentNode){e.text.parentNode.replaceChild(e.node,e.text)}e.node.appendChild(e.text);if(Cl&&8>ie){e.node.style.zIndex=2}}return e.node}function Nt(e,t){var i=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(i){i+=" CodeMirror-linebackground"}if(t.background){if(i){t.background.className=i}else{t.background.parentNode.removeChild(t.background);t.background=null}}else if(i){var n=Tt(t);t.background=n.insertBefore(o("div",null,i),n.firstChild);e.display.input.setUneditable(t.background)}}function Ot(e,t){var i=e.display.externalMeasured;if(i&&i.line==t.line){e.display.externalMeasured=null;t.measure=i.measure;return i.built}return ct(e,t)}function At(e,t){var i=t.text.className,n=Ot(e,t);if(t.text==t.node){t.node=n.pre}t.text.parentNode.replaceChild(n.pre,t.text);t.text=n.pre;if(n.bgClass!=t.bgClass||n.textClass!=t.textClass){t.bgClass=n.bgClass;t.textClass=n.textClass;Mt(e,t)}else if(i){t.text.className=i}}function Mt(e,t){Nt(e,t);if(t.line.wrapClass){Tt(t).className=t.line.wrapClass}else if(t.node!=t.text){t.node.className=""}var i=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=i||""}function Wt(e,t,i,n){if(t.gutter){t.node.removeChild(t.gutter);t.gutter=null}if(t.gutterBackground){t.node.removeChild(t.gutterBackground);t.gutterBackground=null}if(t.line.gutterClass){var r=Tt(t);t.gutterBackground=o("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px; width: "+n.gutterTotalWidth+"px");e.display.input.setUneditable(t.gutterBackground);r.insertBefore(t.gutterBackground,t.text)}var l=t.line.gutterMarkers;if(e.options.lineNumbers||l){var s=Tt(t),d=t.gutter=o("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?n.fixedPos:-n.gutterTotalWidth)+"px");e.display.input.setUneditable(d);s.insertBefore(d,t.text);if(t.line.gutterClass){d.className+=" "+t.line.gutterClass}if(e.options.lineNumbers&&(!l||!l["CodeMirror-linenumbers"])){t.lineNumber=d.appendChild(o("div",I(e.options,i),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+n.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))}if(l){for(var a=0;a<e.options.gutters.length;++a){var p=e.options.gutters[a],c=l.hasOwnProperty(p)&&l[p];if(c){d.appendChild(o("div",[c],"CodeMirror-gutter-elt","left: "+n.gutterLeft[p]+"px; width: "+n.gutterWidth[p]+"px"))}}}}}function Dt(e,t,i){if(t.alignable){t.alignable=null}for(var n=t.node.firstChild,o=void 0;n;n=o){o=n.nextSibling;if("CodeMirror-linewidget"==n.className){t.node.removeChild(n)}}Ft(e,t,i)}function Ht(e,t,i,n){var o=Ot(e,t);t.text=t.node=o.pre;if(o.bgClass){t.bgClass=o.bgClass}if(o.textClass){t.textClass=o.textClass}Mt(e,t);Wt(e,t,i,n);Ft(e,t,n);return t.node}function Ft(e,t,n){Pt(e,t.line,t,n,!0);if(t.rest){for(var o=0;o<t.rest.length;o++){Pt(e,t.rest[o],t,n,!1)}}}function Pt(e,t,n,r,l){if(!t.widgets){return}for(var s=Tt(n),d=0,a=t.widgets;d<a.length;++d){var p=a[d],c=o("div",[p.node],"CodeMirror-linewidget");if(!p.handleMouseEvents){c.setAttribute("cm-ignore-events","true")}It(p,c,n,r);e.display.input.setUneditable(c);if(l&&p.above){s.insertBefore(c,n.gutter||n.text)}else{s.appendChild(c)}St(p,"redraw")}}function It(e,t,i,n){if(e.noHScroll){(i.alignable||(i.alignable=[])).push(t);var o=n.wrapperWidth;t.style.left=n.fixedPos+"px";if(!e.coverGutter){o-=n.gutterTotalWidth;t.style.paddingLeft=n.gutterTotalWidth+"px"}t.style.width=o+"px"}if(e.coverGutter){t.style.zIndex=5;t.style.position="relative";if(!e.noHScroll){t.style.marginLeft=-n.gutterTotalWidth+"px"}}}function zt(e){if(null!=e.height){return e.height}var t=e.doc.cm;if(!t){return 0}if(!l(document.body,e.node)){var i="position: relative;";if(e.coverGutter){i+="margin-left: -"+t.display.gutters.offsetWidth+"px;"}if(e.noHScroll){i+="width: "+t.display.wrapper.clientWidth+"px;"}n(t.display.measure,o("div",[e.node],null,i))}return e.height=e.node.parentNode.offsetHeight}function Et(t,i){for(var e=Re(i);e!=t.wrapper;e=e.parentNode){if(!e||1==e.nodeType&&"true"==e.getAttribute("cm-ignore-events")||e.parentNode==t.sizer&&e!=t.mover){return!0}}}function Rt(e){return e.lineSpace.offsetTop}function Bt(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Gt(t){if(t.cachedPaddingH){return t.cachedPaddingH}var i=n(t.measure,o("pre","x")),e=window.getComputedStyle?window.getComputedStyle(i):i.currentStyle,r={left:parseInt(e.paddingLeft),right:parseInt(e.paddingRight)};if(!isNaN(r.left)&&!isNaN(r.right)){t.cachedPaddingH=r}return r}function $t(e){return 30-e.display.nativeBarWidth}function Ut(e){return e.display.scroller.clientWidth-$t(e)-e.display.barWidth}function jt(e){return e.display.scroller.clientHeight-$t(e)-e.display.barHeight}function Vt(e,t,n){var o=e.options.lineWrapping,r=o&&Ut(e);if(!t.measure.heights||o&&t.measure.width!=r){var l=t.measure.heights=[];if(o){t.measure.width=r;for(var s=t.text.firstChild.getClientRects(),d=0;d<s.length-1;d++){var a=s[d],p=s[d+1];if(2<Math.abs(a.bottom-p.bottom)){l.push((a.bottom+p.top)/2-n.top)}}}l.push(n.bottom-n.top)}}function Kt(e,t,n){if(e.line==t){return{map:e.measure.map,cache:e.measure.cache}}for(var o=0;o<e.rest.length;o++){if(e.rest[o]==t){return{map:e.measure.maps[o],cache:e.measure.caches[o]}}}for(var r=0;r<e.rest.length;r++){if(H(e.rest[r])>n){return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}}}function Xt(e,t){t=fe(t);var i=H(t),o=e.display.externalMeasured=new xt(e.doc,t,i);o.lineN=i;var r=o.built=ct(e,o);o.text=r.pre;n(e.display.lineMeasure,r.pre);return o}function Yt(e,t,i,n){return Zt(e,qt(e,t),i,n)}function _t(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo){return e.display.view[Oi(e,t)]}var i=e.display.externalMeasured;if(i&&t>=i.lineN&&t<i.lineN+i.size){return i}}function qt(e,t){var i=H(t),n=_t(e,i);if(n&&!n.text){n=null}else if(n&&n.changes){kt(e,n,i,Si(e));e.curOp.forceUpdate=!0}if(!n){n=Xt(e,t)}var o=Kt(n,t,i);return{line:t,view:n,rect:null,map:o.map,cache:o.cache,before:o.before,hasHeights:!1}}function Zt(e,t,i,n,o){if(t.before){i=-1}var r=i+(n||""),l;if(t.cache.hasOwnProperty(r)){l=t.cache[r]}else{if(!t.rect){t.rect=t.view.text.getBoundingClientRect()}if(!t.hasHeights){Vt(e,t.view,t.rect);t.hasHeights=!0}l=ei(e,t,i,n);if(!l.bogus){t.cache[r]=l}}return{left:l.left,right:l.right,top:o?l.rtop:l.top,bottom:o?l.rbottom:l.bottom}}var xs={left:0,right:0,top:0,bottom:0};function Qt(e,t,n){for(var o,r,l,s,d,a,p=0;p<e.length;p+=3){d=e[p];a=e[p+1];if(t<d){r=0;l=1;s="left"}else if(t<a){r=t-d;l=r+1}else if(p==e.length-3||t==a&&e[p+3]>t){l=a-d;r=l-1;if(t>=a){s="right"}}if(null!=r){o=e[p+2];if(d==a&&n==(o.insertLeft?"left":"right")){s=n}if("left"==n&&0==r){while(p&&e[p-2]==e[p-3]&&e[p-1].insertLeft){o=e[(p-=3)+2];s="left"}}if("right"==n&&r==a-d){while(p<e.length-3&&e[p+3]==e[p+4]&&!e[p+5].insertLeft){o=e[(p+=3)+2];s="right"}}break}}return{node:o,start:r,end:l,collapse:s,coverStart:d,coverEnd:a}}function Jt(e,t){var n=xs;if("left"==t){for(var o=0;o<e.length;o++){if((n=e[o]).left!=n.right){break}}}else{for(var r=e.length-1;0<=r;r--){if((n=e[r]).left!=n.right){break}}}return n}function ei(e,t,n,o){var r=Qt(t.map,n,o),l=r.node,s=r.start,d=r.end,a=r.collapse,p;if(3==l.nodeType){for(var c=0;4>c;c++){while(s&&k(t.line.text.charAt(r.coverStart+s))){--s}while(r.coverStart+d<r.coverEnd&&k(t.line.text.charAt(r.coverStart+d))){++d}if(Cl&&9>ie&&0==s&&d==r.coverEnd-r.coverStart){p=l.parentNode.getBoundingClientRect()}else{p=Jt(Rl(l,s,d).getClientRects(),o)}if(p.left||p.right||0==s){break}d=s;s=s-1;a="right"}if(Cl&&11>ie){p=ti(e.display.measure,p)}}else{if(0<s){a=o="right"}var h;if(e.options.lineWrapping&&1<(h=l.getClientRects()).length){p=h["right"==o?h.length-1:0]}else{p=l.getBoundingClientRect()}}if(Cl&&9>ie&&!s&&(!p||!p.left&&!p.right)){var g=l.parentNode.getClientRects()[0];if(g){p={left:g.left,right:g.left+wi(e.display),top:g.top,bottom:g.bottom}}else{p=xs}}var u=p.top-t.rect.top,f=p.bottom-t.rect.top,m=t.view.measure.heights,y=0;for(;y<m.length-1;y++){if((u+f)/2<m[y]){break}}var x=y?m[y-1]:0,v=m[y],b={left:("right"==a?p.right:p.left)-t.rect.left,right:("left"==a?p.left:p.right)-t.rect.left,top:x,bottom:v};if(!p.left&&!p.right){b.bogus=!0}if(!e.options.singleCursorHeightPerLine){b.rtop=u;b.rbottom=f}return b}function ti(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Ue(e)){return t}var i=screen.logicalXDPI/screen.deviceXDPI,n=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*i,right:t.right*i,top:t.top*n,bottom:t.bottom*n}}function ii(e){if(e.measure){e.measure.cache={};e.measure.heights=null;if(e.rest){for(var t=0;t<e.rest.length;t++){e.measure.caches[t]={}}}}}function ni(e){e.display.externalMeasure=null;t(e.display.lineMeasure);for(var n=0;n<e.display.view.length;n++){ii(e.display.view[n])}}function oi(e){ni(e);e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null;if(!e.options.lineWrapping){e.display.maxLineChanged=!0}e.display.lineNumChars=null}function ri(){if(Ll&&Ml){return-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft))}return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function li(){if(Ll&&Ml){return-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop))}return window.pageYOffset||(document.documentElement||document.body).scrollTop}function si(e){var t=0;if(e.widgets){for(var n=0;n<e.widgets.length;++n){if(e.widgets[n].above){t+=zt(e.widgets[n])}}}return t}function di(e,t,i,n,o){if(!o){var r=si(t);i.top+=r;i.bottom+=r}if("line"==n){return i}if(!n){n="local"}var l=we(t);if("local"==n){l+=Rt(e.display)}else{l-=e.display.viewOffset}if("page"==n||"window"==n){var s=e.display.lineSpace.getBoundingClientRect();l+=s.top+("window"==n?0:li());var d=s.left+("window"==n?0:ri());i.left+=d;i.right+=d}i.top+=l;i.bottom+=l;return i}function ai(e,t,i){if("div"==i){return t}var n=t.left,o=t.top;if("page"==i){n-=ri();o-=li()}else if("local"==i||!i){var r=e.display.sizer.getBoundingClientRect();n+=r.left;o+=r.top}var l=e.display.lineSpace.getBoundingClientRect();return{left:n-l.left,top:o-l.top}}function pi(e,t,i,n,o){if(!n){n=A(e.doc,t.line)}return di(e,n,Yt(e,n,t.ch,o),i)}function ci(e,t,i,n,o,r){n=n||A(e.doc,t.line);if(!o){o=qt(e,n)}function l(t,l){var s=Zt(e,o,t,l?"right":"left",r);if(l){s.left=s.right}else{s.right=s.left}return di(e,n,s,i)}var d=Ne(n,e.doc.direction),a=t.ch,p=t.sticky;if(a>=n.text.length){a=n.text.length;p="before"}else if(0>=a){a=0;p="after"}if(!d){return l("before"==p?a-1:a,"before"==p)}function s(e,t,i){var n=d[t],o=1==n.level;return l(i?e-1:e,o!=i)}var c=Te(d,a,p),h=Zl,g=s(a,c,"before"==p);if(null!=h){g.other=s(a,h,"before"!=p)}return g}function hi(e,t){var i=0;t=j(e.doc,t);if(!e.options.lineWrapping){i=wi(e.display)*t.ch}var n=A(e.doc,t.line),o=we(n)+Rt(e.display);return{left:i,right:i,top:o,bottom:o+n.height}}function gi(e,t,i,n,o){var r=z(e,t,i);r.xRel=o;if(n){r.outside=!0}return r}function ui(e,t,i){var n=e.doc;i+=e.display.viewOffset;if(0>i){return gi(n.first,0,null,!0,-1)}var o=F(n,i),r=n.first+n.size-1;if(o>r){return gi(n.first+n.size-1,A(n,r).text.length,null,!0,1)}if(0>t){t=0}var l=A(n,o);for(;;){var s=xi(e,l,o,t,i),d=ge(l,s.ch+(0<s.xRel?1:0));if(!d){return s}var a=d.find(1);if(a.line==o){return a}l=A(n,o=a.line)}}function fi(e,t,i,n){n-=si(t);var o=t.text.length,r=N(function(t){return Zt(e,i,t-1).bottom<=n},o,0);o=N(function(t){return Zt(e,i,t).top>n},r,o);return{begin:r,end:o}}function mi(e,t,i,n){if(!i){i=qt(e,t)}var o=di(e,t,Zt(e,i,n),"line").top;return fi(e,t,i,o)}function yi(e,t,i,n){return e.bottom<=i?!1:e.top>i?!0:(n?e.left:e.right)>t}function xi(e,t,i,n,o){o-=we(t);var r=qt(e,t),l=si(t),s=0,d=t.text.length,a=!0,p=Ne(t,e.doc.direction);if(p){var c=(e.options.lineWrapping?bi:vi)(e,t,i,r,p,n,o);a=1!=c.level;s=a?c.from:c.to-1;d=a?c.to:c.from-1}var h=null,g=null,u=N(function(t){var i=Zt(e,r,t);i.top+=l;i.bottom+=l;if(!yi(i,n,o,!1)){return!1}if(i.top<=o&&i.left<=n){h=t;g=i}return!0},s,d),f,m,x=!1;if(g){var v=n-g.left<g.right-n,b=v==a;u=h+(b?0:1);m=b?"after":"before";f=v?g.left:g.right}else{if(!a&&(u==d||u==s)){u++}m=0==u?"after":u==t.text.length?"before":Zt(e,r,u-(a?1:0)).bottom+l<=o==a?"after":"before";var C=ci(e,z(i,u,m),"line",t,r);f=C.left;x=o<C.top||o>=C.bottom}u=T(t.text,u,1);return gi(i,u,m,x,n-f)}function vi(e,t,n,o,r,l,s){var i=N(function(d){var i=r[d],a=1!=i.level;return yi(ci(e,z(n,a?i.to:i.from,a?"before":"after"),"line",t,o),l,s,!0)},0,r.length-1),d=r[i];if(0<i){var a=1!=d.level,p=ci(e,z(n,a?d.from:d.to,a?"after":"before"),"line",t,o);if(yi(p,l,s,!0)&&p.top>s){d=r[i-1]}}return d}function bi(e,t,n,o,r,l,s){var d=fi(e,t,o,s),a=d.begin,c=d.end;if(/\s/.test(t.text.charAt(c-1))){c--}for(var h=null,g=null,u=0,f;u<r.length;u++){f=r[u];if(f.from>=c||f.to<=a){continue}var m=1!=f.level,y=Zt(e,o,m?Math.min(c,f.to)-1:Math.max(a,f.from)).right,x=y<l?l-y+1e9:y-l;if(!h||g>x){h=f;g=x}}if(!h){h=r[r.length-1]}if(h.from<a){h={from:a,to:h.to,level:h.level}}if(h.to>c){h={from:h.from,to:c,level:h.level}}return h}var vs;function Ci(e){if(null!=e.cachedTextHeight){return e.cachedTextHeight}if(null==vs){vs=o("pre");for(var r=0;49>r;++r){vs.appendChild(document.createTextNode("x"));vs.appendChild(o("br"))}vs.appendChild(document.createTextNode("x"))}n(e.measure,vs);var l=vs.offsetHeight/50;if(3<l){e.cachedTextHeight=l}t(e.measure);return l||1}function wi(e){if(null!=e.cachedCharWidth){return e.cachedCharWidth}var t=o("span","xxxxxxxxxx"),i=o("pre",[t]);n(e.measure,i);var r=t.getBoundingClientRect(),l=(r.right-r.left)/10;if(2<l){e.cachedCharWidth=l}return l||10}function Si(e){for(var t=e.display,o={},r={},l=t.gutters.clientLeft,s=t.gutters.firstChild,d=0;s;s=s.nextSibling,++d){o[e.options.gutters[d]]=s.offsetLeft+s.clientLeft+l;r[e.options.gutters[d]]=s.clientWidth}return{fixedPos:Li(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:o,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Li(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function ki(e){var t=Ci(e.display),n=e.options.lineWrapping,o=n&&Math.max(5,e.display.scroller.clientWidth/wi(e.display)-3);return function(r){if(be(e.doc,r)){return 0}var l=0;if(r.widgets){for(var s=0;s<r.widgets.length;s++){if(r.widgets[s].height){l+=r.widgets[s].height}}}if(n){return l+(Math.ceil(r.text.length/o)||1)*t}else{return l+t}}}function Ti(e){var t=e.doc,i=ki(e);t.iter(function(e){var t=i(e);if(t!=e.height){D(e,t)}})}function Ni(t,i,e,n){var o=t.display;if(!e&&"true"==Re(i).getAttribute("cm-not-content")){return null}var r,l,s=o.lineSpace.getBoundingClientRect();try{r=i.clientX-s.left;l=i.clientY-s.top}catch(t){return null}var d=ui(t,r,l),a;if(n&&1==d.xRel&&(a=A(t.doc,d.line).text).length==d.ch){var p=h(a,a.length,t.options.tabSize)-a.length;d=z(d.line,Math.max(0,Math.round((r-Gt(t.display).left)/wi(t.display))-p))}return d}function Oi(e,t){if(t>=e.display.viewTo){return null}t-=e.display.viewFrom;if(0>t){return null}for(var o=e.display.view,r=0;r<o.length;r++){t-=o[r].size;if(0>t){return r}}}function Ai(e){e.display.input.showSelection(e.display.input.prepareSelection())}function Mi(e,t){if(void 0===t)t=!0;for(var n=e.doc,o={},r=o.cursors=document.createDocumentFragment(),l=o.selection=document.createDocumentFragment(),s=0;s<n.sel.ranges.length;s++){if(!t&&s==n.sel.primIndex){continue}var d=n.sel.ranges[s];if(d.from().line>=e.display.viewTo||d.to().line<e.display.viewFrom){continue}var a=d.empty();if(a||e.options.showCursorWhenSelecting){Wi(e,d.head,r)}if(!a){Hi(e,d,l)}}return o}function Wi(e,t,i){var n=ci(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),r=i.appendChild(o("div","\xA0","CodeMirror-cursor"));r.style.left=n.left+"px";r.style.top=n.top+"px";r.style.height=Math.max(0,n.bottom-n.top)*e.options.cursorHeight+"px";if(n.other){var l=i.appendChild(o("div","\xA0","CodeMirror-cursor CodeMirror-secondarycursor"));l.style.display="";l.style.left=n.other.left+"px";l.style.top=n.other.top+"px";l.style.height=.85*(n.other.bottom-n.other.top)+"px"}}function Di(e,t){return e.top-t.top||e.left-t.left}function Hi(e,t,i){var l=e.display,s=e.doc,d=document.createDocumentFragment(),a=Gt(e.display),p=a.left,c=Math.max(l.sizerWidth,Ut(e)-l.sizer.offsetLeft)-a.right,h="ltr"==s.direction;function n(e,t,i,n){if(0>t){t=0}t=Math.round(t);n=Math.round(n);d.appendChild(o("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n                             top: "+t+"px; width: "+(null==i?c-e:i)+"px;\n                             height: "+(n-t)+"px"))}function r(t,o,r){var a=A(s,t),g=a.text.length,u,f;function l(i,n){return pi(e,z(t,i),"div",a,n)}function d(t,i,n){var o=mi(e,a,null,t),r="ltr"==i==("after"==n)?"left":"right",s="after"==n?o.begin:o.end-(/\s/.test(a.text.charAt(o.end-1))?2:1);return l(s,r)[r]}var m=Ne(a,s.direction);ke(m,o||0,null==r?g:r,function(e,t,s,a){var i="ltr"==s,y=l(e,i?"left":"right"),x=l(t-1,i?"right":"left"),v=null==o&&0==e,b=null==r&&t==g,C=0==a,w=!m||a==m.length-1;if(3>=x.top-y.top){var S=(h?v:b)&&C,L=(h?b:v)&&w,k=S?p:(i?y:x).left,T=L?c:(i?x:y).right;n(k,y.top,T-k,y.bottom)}else{var N,O,A,M;if(i){N=h&&v&&C?p:y.left;O=h?c:d(e,s,"before");A=h?p:d(t,s,"after");M=h&&b&&w?c:x.right}else{N=!h?p:d(e,s,"before");O=!h&&v&&C?c:y.right;A=!h&&b&&w?p:x.left;M=!h?c:d(t,s,"after")}n(N,y.top,O-N,y.bottom);if(y.bottom<x.top){n(p,y.bottom,null,x.top)}n(A,x.top,M-A,x.bottom)}if(!u||0>Di(y,u)){u=y}if(0>Di(x,u)){u=x}if(!f||0>Di(y,f)){f=y}if(0>Di(x,f)){f=x}});return{start:u,end:f}}var g=t.from(),u=t.to();if(g.line==u.line){r(g.line,g.ch,u.ch)}else{var f=A(s,g.line),m=A(s,u.line),y=fe(f)==fe(m),x=r(g.line,g.ch,y?f.text.length+1:null).end,v=r(u.line,y?0:null,u.ch).start;if(y){if(x.top<v.top-2){n(x.right,x.top,null,x.bottom);n(p,v.top,v.left,v.bottom)}else{n(x.right,x.top,v.left-x.right,x.bottom)}}if(x.bottom<v.top){n(p,x.bottom,null,v.top)}}i.appendChild(d)}function Fi(e){if(!e.state.focused){return}var t=e.display;clearInterval(t.blinker);var i=!0;t.cursorDiv.style.visibility="";if(0<e.options.cursorBlinkRate){t.blinker=setInterval(function(){return t.cursorDiv.style.visibility=(i=!i)?"":"hidden"},e.options.cursorBlinkRate)}else if(0>e.options.cursorBlinkRate){t.cursorDiv.style.visibility="hidden"}}function Pi(e){if(!e.state.focused){e.display.input.focus();zi(e)}}function Ii(e){e.state.delayingBlurEvent=!0;setTimeout(function(){if(e.state.delayingBlurEvent){e.state.delayingBlurEvent=!1;Ei(e)}},100)}function zi(t,i){if(t.state.delayingBlurEvent){t.state.delayingBlurEvent=!1}if("nocursor"==t.options.readOnly){return}if(!t.state.focused){Me(t,"focus",t,i);t.state.focused=!0;d(t.display.wrapper,"CodeMirror-focused");if(!t.curOp&&t.display.selForContextMenu!=t.doc.sel){t.display.input.reset();if(wl){setTimeout(function(){return t.display.input.reset(!0)},20)}}t.display.input.receivedFocus()}Fi(t)}function Ei(t,i){if(t.state.delayingBlurEvent){return}if(t.state.focused){Me(t,"blur",t,i);t.state.focused=!1;El(t.display.wrapper,"CodeMirror-focused")}clearInterval(t.display.blinker);setTimeout(function(){if(!t.state.focused){t.display.shift=!1}},150)}function Ri(e){for(var t=e.display,n=t.lineDiv.offsetTop,o=0;o<t.view.length;o++){var r=t.view[o],l=void 0;if(r.hidden){continue}if(Cl&&8>ie){var s=r.node.offsetTop+r.node.offsetHeight;l=s-n;n=s}else{var d=r.node.getBoundingClientRect();l=d.bottom-d.top}var a=r.line.height-l;if(2>l){l=Ci(t)}if(.005<a||-.005>a){D(r.line,l);Bi(r.line);if(r.rest){for(var p=0;p<r.rest.length;p++){Bi(r.rest[p])}}}}}function Bi(e){if(e.widgets){for(var t=0;t<e.widgets.length;++t){var n=e.widgets[t],o=n.node.parentNode;if(o){n.height=o.offsetHeight}}}}function Gi(e,t,i){var n=i&&null!=i.top?Math.max(0,i.top):e.scroller.scrollTop;n=Math.floor(n-Rt(e));var o=i&&null!=i.bottom?i.bottom:n+e.wrapper.clientHeight,r=F(t,n),l=F(t,o);if(i&&i.ensure){var s=i.ensure.from.line,d=i.ensure.to.line;if(s<r){r=s;l=F(t,we(A(t,s))+e.wrapper.clientHeight)}else if(Math.min(d,t.lastLine())>=l){r=F(t,we(A(t,d))-e.wrapper.clientHeight);l=d}}return{from:r,to:Math.max(l,r+1)}}function $i(e){var t=e.display,n=t.view;if(!t.alignWidgets&&(!t.gutters.firstChild||!e.options.fixedGutter)){return}for(var o=Li(t)-t.scroller.scrollLeft+e.doc.scrollLeft,r=t.gutters.offsetWidth,l=o+"px",s=0;s<n.length;s++){if(!n[s].hidden){if(e.options.fixedGutter){if(n[s].gutter){n[s].gutter.style.left=l}if(n[s].gutterBackground){n[s].gutterBackground.style.left=l}}var d=n[s].alignable;if(d){for(var a=0;a<d.length;a++){d[a].style.left=l}}}}if(e.options.fixedGutter){t.gutters.style.left=o+r+"px"}}function Ui(e){if(!e.options.lineNumbers){return!1}var t=e.doc,i=I(e.options,t.first+t.size-1),n=e.display;if(i.length!=n.lineNumChars){var r=n.measure.appendChild(o("div",[o("div",i)],"CodeMirror-linenumber CodeMirror-gutter-elt")),l=r.firstChild.offsetWidth,s=r.offsetWidth-l;n.lineGutter.style.width="";n.lineNumInnerWidth=Math.max(l,n.lineGutter.offsetWidth-s)+1;n.lineNumWidth=n.lineNumInnerWidth+s;n.lineNumChars=n.lineNumInnerWidth?i.length:-1;n.lineGutter.style.width=n.lineNumWidth+"px";In(e);return!0}return!1}function ji(e,t){if(We(e,"scrollCursorIntoView")){return}var i=e.display,n=i.sizer.getBoundingClientRect(),r=null;if(0>t.top+n.top){r=!0}else if(t.bottom+n.top>(window.innerHeight||document.documentElement.clientHeight)){r=!1}if(null!=r&&!Ol){var l=o("div","\u200B",null,"position: absolute;\n                         top: "+(t.top-i.viewOffset-Rt(e.display))+"px;\n                         height: "+(t.bottom-t.top+$t(e)+i.barHeight)+"px;\n                         left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(l);l.scrollIntoView(r);e.display.lineSpace.removeChild(l)}}function Vi(e,t,i,n){if(null==n){n=0}var o;if(!e.options.lineWrapping&&t==i){t=t.ch?z(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t;i="before"==t.sticky?z(t.line,t.ch+1,"before"):t}for(var r=0;5>r;r++){var l=!1,s=ci(e,t),d=!i||i==t?s:ci(e,i);o={left:Math.min(s.left,d.left),top:Math.min(s.top,d.top)-n,right:Math.max(s.left,d.left),bottom:Math.max(s.bottom,d.bottom)+n};var a=Xi(e,o),p=e.doc.scrollTop,c=e.doc.scrollLeft;if(null!=a.scrollTop){en(e,a.scrollTop);if(1<Math.abs(e.doc.scrollTop-p)){l=!0}}if(null!=a.scrollLeft){nn(e,a.scrollLeft);if(1<Math.abs(e.doc.scrollLeft-c)){l=!0}}if(!l){break}}return o}function Ki(e,t){var i=Xi(e,t);if(null!=i.scrollTop){en(e,i.scrollTop)}if(null!=i.scrollLeft){nn(e,i.scrollLeft)}}function Xi(e,t){var i=e.display,n=Ci(e.display);if(0>t.top){t.top=0}var o=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:i.scroller.scrollTop,r=jt(e),l={};if(t.bottom-t.top>r){t.bottom=t.top+r}var s=e.doc.height+Bt(i),d=t.top<n,a=t.bottom>s-n;if(t.top<o){l.scrollTop=d?0:t.top}else if(t.bottom>o+r){var p=Math.min(t.top,(a?s:t.bottom)-r);if(p!=o){l.scrollTop=p}}var c=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:i.scroller.scrollLeft,h=Ut(e)-(e.options.fixedGutter?i.gutters.offsetWidth:0),g=t.right-t.left>h;if(g){t.right=t.left+h}if(10>t.left){l.scrollLeft=0}else if(t.left<c){l.scrollLeft=Math.max(0,t.left-(g?0:10))}else if(t.right>h+c-3){l.scrollLeft=t.right+(g?0:10)-h}return l}function Yi(e,t){if(null==t){return}Qi(e);e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t}function _i(e){Qi(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function qi(e,t,i){if(null!=t||null!=i){Qi(e)}if(null!=t){e.curOp.scrollLeft=t}if(null!=i){e.curOp.scrollTop=i}}function Zi(e,t){Qi(e);e.curOp.scrollToPos=t}function Qi(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var i=hi(e,t.from),n=hi(e,t.to);Ji(e,i,n,t.margin)}}function Ji(e,t,i,n){var o=Xi(e,{left:Math.min(t.left,i.left),top:Math.min(t.top,i.top)-n,right:Math.max(t.right,i.right),bottom:Math.max(t.bottom,i.bottom)+n});qi(e,o.scrollLeft,o.scrollTop)}function en(e,t){if(2>Math.abs(e.doc.scrollTop-t)){return}if(!yl){Fn(e,{top:t})}tn(e,t,!0);if(yl){Fn(e)}Nn(e,100)}function tn(e,t,i){t=Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t);if(e.display.scroller.scrollTop==t&&!i){return}e.doc.scrollTop=t;e.display.scrollbars.setScrollTop(t);if(e.display.scroller.scrollTop!=t){e.display.scroller.scrollTop=t}}function nn(e,t,i,n){t=Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth);if((i?t==e.doc.scrollLeft:2>Math.abs(e.doc.scrollLeft-t))&&!n){return}e.doc.scrollLeft=t;$i(e);if(e.display.scroller.scrollLeft!=t){e.display.scroller.scrollLeft=t}e.display.scrollbars.setScrollLeft(t)}function rn(e){var t=e.display,i=t.gutters.offsetWidth,n=Math.round(e.doc.height+Bt(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?i:0,docHeight:n,scrollHeight:n+$t(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:i}}var bs=function(e,t,i){this.cm=i;var n=this.vert=o("div",[o("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),r=this.horiz=o("div",[o("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");n.tabIndex=r.tabIndex=-1;e(n);e(r);es(n,"scroll",function(){if(n.clientHeight){t(n.scrollTop,"vertical")}});es(r,"scroll",function(){if(r.clientWidth){t(r.scrollLeft,"horizontal")}});this.checkedZeroWidth=!1;if(Cl&&8>ie){this.horiz.style.minHeight=this.vert.style.minWidth="18px"}};bs.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,n=e.nativeBarWidth;if(i){this.vert.style.display="block";this.vert.style.bottom=t?n+"px":"0";var o=e.viewHeight-(t?n:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+o)+"px"}else{this.vert.style.display="";this.vert.firstChild.style.height="0"}if(t){this.horiz.style.display="block";this.horiz.style.right=i?n+"px":"0";this.horiz.style.left=e.barLeft+"px";var r=e.viewWidth-e.barLeft-(i?n:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+r)+"px"}else{this.horiz.style.display="";this.horiz.firstChild.style.width="0"}if(!this.checkedZeroWidth&&0<e.clientHeight){if(0==n){this.zeroWidthHack()}this.checkedZeroWidth=!0}return{right:i?n:0,bottom:t?n:0}};bs.prototype.setScrollLeft=function(e){if(this.horiz.scrollLeft!=e){this.horiz.scrollLeft=e}if(this.disableHoriz){this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")}};bs.prototype.setScrollTop=function(e){if(this.vert.scrollTop!=e){this.vert.scrollTop=e}if(this.disableVert){this.enableZeroWidthBar(this.vert,this.disableVert,"vert")}};bs.prototype.zeroWidthHack=function(){var e=Dl&&!Nl?"12px":"18px";this.horiz.style.height=this.vert.style.width=e;this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none";this.disableHoriz=new Gl;this.disableVert=new Gl};bs.prototype.enableZeroWidthBar=function(e,t,i){e.style.pointerEvents="auto";function n(){var o=e.getBoundingClientRect(),r="vert"==i?document.elementFromPoint(o.right-1,(o.top+o.bottom)/2):document.elementFromPoint((o.right+o.left)/2,o.bottom-1);if(r!=e){e.style.pointerEvents="none"}else{t.set(1e3,n)}}t.set(1e3,n)};bs.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz);e.removeChild(this.vert)};var Cs=function(){};Cs.prototype.update=function(){return{bottom:0,right:0}};Cs.prototype.setScrollLeft=function(){};Cs.prototype.setScrollTop=function(){};Cs.prototype.clear=function(){};function ln(e,t){if(!t){t=rn(e)}var n=e.display.barWidth,o=e.display.barHeight;sn(e,t);for(var r=0;4>r&&n!=e.display.barWidth||o!=e.display.barHeight;r++){if(n!=e.display.barWidth&&e.options.lineWrapping){Ri(e)}sn(e,rn(e));n=e.display.barWidth;o=e.display.barHeight}}function sn(e,t){var i=e.display,n=i.scrollbars.update(t);i.sizer.style.paddingRight=(i.barWidth=n.right)+"px";i.sizer.style.paddingBottom=(i.barHeight=n.bottom)+"px";i.heightForcer.style.borderBottom=n.bottom+"px solid transparent";if(n.right&&n.bottom){i.scrollbarFiller.style.display="block";i.scrollbarFiller.style.height=n.bottom+"px";i.scrollbarFiller.style.width=n.right+"px"}else{i.scrollbarFiller.style.display=""}if(n.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter){i.gutterFiller.style.display="block";i.gutterFiller.style.height=n.bottom+"px";i.gutterFiller.style.width=t.gutterWidth+"px"}else{i.gutterFiller.style.display=""}}var ws={native:bs,null:Cs};function dn(e){if(e.display.scrollbars){e.display.scrollbars.clear();if(e.display.scrollbars.addClass){El(e.display.wrapper,e.display.scrollbars.addClass)}}e.display.scrollbars=new ws[e.options.scrollbarStyle](function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller);es(t,"mousedown",function(){if(e.state.focused){setTimeout(function(){return e.display.input.focus()},0)}});t.setAttribute("cm-not-content","true")},function(t,i){if("horizontal"==i){nn(e,t)}else{en(e,t)}},e);if(e.display.scrollbars.addClass){d(e.display.wrapper,e.display.scrollbars.addClass)}}var Ss=0;function an(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Ss};bt(e.curOp)}function pn(e){var t=e.curOp;if(t){wt(t,function(e){for(var t=0;t<e.ops.length;t++){e.ops[t].cm.curOp=null}cn(e)})}}function cn(e){for(var t=e.ops,n=0;n<t.length;n++){hn(t[n])}for(var o=0;o<t.length;o++){gn(t[o])}for(var r=0;r<t.length;r++){un(t[r])}for(var l=0;l<t.length;l++){fn(t[l])}for(var s=0;s<t.length;s++){mn(t[s])}}function hn(e){var t=e.cm,i=t.display;An(t);if(e.updateMaxLine){Le(t)}e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<i.viewFrom||e.scrollToPos.to.line>=i.viewTo)||i.maxLineChanged&&t.options.lineWrapping;e.update=e.mustUpdate&&new Ls(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function gn(e){e.updatedDisplay=e.mustUpdate&&Dn(e.cm,e.update)}function un(e){var t=e.cm,i=t.display;if(e.updatedDisplay){Ri(t)}e.barMeasure=rn(t);if(i.maxLineChanged&&!t.options.lineWrapping){e.adjustWidthTo=Yt(t,i.maxLine,i.maxLine.text.length).left+3;t.display.sizerWidth=e.adjustWidthTo;e.barMeasure.scrollWidth=Math.max(i.scroller.clientWidth,i.sizer.offsetLeft+e.adjustWidthTo+$t(t)+t.display.barWidth);e.maxScrollLeft=Math.max(0,i.sizer.offsetLeft+e.adjustWidthTo-Ut(t))}if(e.updatedDisplay||e.selectionChanged){e.preparedSelection=i.input.prepareSelection()}}function fn(e){var t=e.cm;if(null!=e.adjustWidthTo){t.display.sizer.style.minWidth=e.adjustWidthTo+"px";if(e.maxScrollLeft<t.doc.scrollLeft){nn(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0)}t.display.maxLineChanged=!1}var i=e.focus&&e.focus==s();if(e.preparedSelection){t.display.input.showSelection(e.preparedSelection,i)}if(e.updatedDisplay||e.startHeight!=t.doc.height){ln(t,e.barMeasure)}if(e.updatedDisplay){zn(t,e.barMeasure)}if(e.selectionChanged){Fi(t)}if(t.state.focused&&e.updateInput){t.display.input.reset(e.typing)}if(i){Pi(e.cm)}}function mn(e){var t=e.cm,n=t.display,o=t.doc;if(e.updatedDisplay){Hn(t,e.update)}if(null!=n.wheelStartX&&(null!=e.scrollTop||null!=e.scrollLeft||e.scrollToPos)){n.wheelStartX=n.wheelStartY=null}if(null!=e.scrollTop){tn(t,e.scrollTop,e.forceScroll)}if(null!=e.scrollLeft){nn(t,e.scrollLeft,!0,!0)}if(e.scrollToPos){var r=Vi(t,j(o,e.scrollToPos.from),j(o,e.scrollToPos.to),e.scrollToPos.margin);ji(t,r)}var l=e.maybeHiddenMarkers,s=e.maybeUnhiddenMarkers;if(l){for(var d=0;d<l.length;++d){if(!l[d].lines.length){Me(l[d],"hide")}}}if(s){for(var a=0;a<s.length;++a){if(s[a].lines.length){Me(s[a],"unhide")}}}if(n.wrapper.offsetHeight){o.scrollTop=t.display.scroller.scrollTop}if(e.changeObjs){Me(t,"changes",t,e.changeObjs)}if(e.update){e.update.finish()}}function yn(e,t){if(e.curOp){return t()}an(e);try{return t()}finally{pn(e)}}function xn(e,t){return function(){if(e.curOp){return t.apply(e,arguments)}an(e);try{return t.apply(e,arguments)}finally{pn(e)}}}function vn(e){return function(){if(this.curOp){return e.apply(this,arguments)}an(this);try{return e.apply(this,arguments)}finally{pn(this)}}}function bn(e){return function(){var t=this.cm;if(!t||t.curOp){return e.apply(this,arguments)}an(t);try{return e.apply(this,arguments)}finally{pn(t)}}}function Cn(e,t,i,n){if(null==t){t=e.doc.first}if(null==i){i=e.doc.first+e.doc.size}if(!n){n=0}var o=e.display;if(n&&i<o.viewTo&&(null==o.updateLineNumbers||o.updateLineNumbers>t)){o.updateLineNumbers=t}e.curOp.viewChanged=!0;if(t>=o.viewTo){if(ql&&xe(e.doc,t)<o.viewTo){Sn(e)}}else if(i<=o.viewFrom){if(ql&&ve(e.doc,i+n)>o.viewFrom){Sn(e)}else{o.viewFrom+=n;o.viewTo+=n}}else if(t<=o.viewFrom&&i>=o.viewTo){Sn(e)}else if(t<=o.viewFrom){var r=Ln(e,i,i+n,1);if(r){o.view=o.view.slice(r.index);o.viewFrom=r.lineN;o.viewTo+=n}else{Sn(e)}}else if(i>=o.viewTo){var l=Ln(e,t,t,-1);if(l){o.view=o.view.slice(0,l.index);o.viewTo=l.lineN}else{Sn(e)}}else{var s=Ln(e,t,t,-1),d=Ln(e,i,i+n,1);if(s&&d){o.view=o.view.slice(0,s.index).concat(vt(e,s.lineN,d.lineN)).concat(o.view.slice(d.index));o.viewTo+=n}else{Sn(e)}}var a=o.externalMeasured;if(a){if(i<a.lineN){a.lineN+=n}else if(t<a.lineN+a.size){o.externalMeasured=null}}}function wn(e,t,i){e.curOp.viewChanged=!0;var n=e.display,o=e.display.externalMeasured;if(o&&t>=o.lineN&&t<o.lineN+o.size){n.externalMeasured=null}if(t<n.viewFrom||t>=n.viewTo){return}var r=n.view[Oi(e,t)];if(null==r.node){return}var l=r.changes||(r.changes=[]);if(-1==g(l,i)){l.push(i)}}function Sn(e){e.display.viewFrom=e.display.viewTo=e.doc.first;e.display.view=[];e.display.viewOffset=0}function Ln(e,t,o,r){var l=Oi(e,t),s,d=e.display.view;if(!ql||o==e.doc.first+e.doc.size){return{index:l,lineN:o}}for(var a=e.display.viewFrom,p=0;p<l;p++){a+=d[p].size}if(a!=t){if(0<r){if(l==d.length-1){return null}s=a+d[l].size-t;l++}else{s=a-t}t+=s;o+=s}while(xe(e.doc,o)!=o){if(l==(0>r?0:d.length-1)){return null}o+=r*d[l-(0>r?1:0)].size;l+=r}return{index:l,lineN:o}}function kn(e,t,i){var n=e.display,o=n.view;if(0==o.length||t>=n.viewTo||i<=n.viewFrom){n.view=vt(e,t,i);n.viewFrom=t}else{if(n.viewFrom>t){n.view=vt(e,t,n.viewFrom).concat(n.view)}else if(n.viewFrom<t){n.view=n.view.slice(Oi(e,t))}n.viewFrom=t;if(n.viewTo<i){n.view=n.view.concat(vt(e,n.viewTo,i))}else if(n.viewTo>i){n.view=n.view.slice(0,Oi(e,i))}}n.viewTo=i}function Tn(e){for(var t=e.display.view,n=0,o=0,r;o<t.length;o++){r=t[o];if(!r.hidden&&(!r.node||r.changes)){++n}}return n}function Nn(e,t){if(e.doc.highlightFrontier<e.display.viewTo){e.state.highlight.set(t,p(On,e))}}function On(e){var t=e.doc;if(t.highlightFrontier>=e.display.viewTo){return}var n=+new Date+e.options.workTime,o=Je(e,t.highlightFrontier),r=[];t.iter(o.line,Math.min(t.first+t.size,e.display.viewTo+500),function(l){if(o.line>=e.display.viewFrom){var s=l.styles,d=l.text.length>e.options.maxHighlightLength?Ye(t.mode,o.state):null,a=Ze(e,l,o,!0);if(d){o.state=d}l.styles=a.styles;var p=l.styleClasses,c=a.classes;if(c){l.styleClasses=c}else if(p){l.styleClasses=null}for(var h=!s||s.length!=l.styles.length||p!=c&&(!p||!c||p.bgClass!=c.bgClass||p.textClass!=c.textClass),g=0;!h&&g<s.length;++g){h=s[g]!=l.styles[g]}if(h){r.push(o.line)}l.stateAfter=o.save();o.nextLine()}else{if(l.text.length<=e.options.maxHighlightLength){et(e,l.text,o)}l.stateAfter=0==o.line%5?o.save():null;o.nextLine()}if(+new Date>n){Nn(e,e.options.workDelay);return!0}});t.highlightFrontier=o.line;t.modeFrontier=Math.max(t.modeFrontier,o.line);if(r.length){yn(e,function(){for(var t=0;t<r.length;t++){wn(e,r[t],"text")}})}}var Ls=function(e,t,i){var n=e.display;this.viewport=t;this.visible=Gi(n,e.doc,t);this.editorIsHidden=!n.wrapper.offsetWidth;this.wrapperHeight=n.wrapper.clientHeight;this.wrapperWidth=n.wrapper.clientWidth;this.oldDisplayWidth=Ut(e);this.force=i;this.dims=Si(e);this.events=[]};Ls.prototype.signal=function(e,t){if(He(e,t)){this.events.push(arguments)}};Ls.prototype.finish=function(){for(var e=0;e<this.events.length;e++){Me.apply(null,this.events[e])}};function An(e){var t=e.display;if(!t.scrollbarsClipped&&t.scroller.offsetWidth){t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth;t.heightForcer.style.height=$t(e)+"px";t.sizer.style.marginBottom=-t.nativeBarWidth+"px";t.sizer.style.borderRightWidth=$t(e)+"px";t.scrollbarsClipped=!0}}function Mn(e){if(e.hasFocus()){return null}var t=s();if(!t||!l(e.display.lineDiv,t)){return null}var i={activeElt:t};if(window.getSelection){var n=window.getSelection();if(n.anchorNode&&n.extend&&l(e.display.lineDiv,n.anchorNode)){i.anchorNode=n.anchorNode;i.anchorOffset=n.anchorOffset;i.focusNode=n.focusNode;i.focusOffset=n.focusOffset}}return i}function Wn(e){if(!e||!e.activeElt||e.activeElt==s()){return}e.activeElt.focus();if(e.anchorNode&&l(document.body,e.anchorNode)&&l(document.body,e.focusNode)){var t=window.getSelection(),i=document.createRange();i.setEnd(e.anchorNode,e.anchorOffset);i.collapse(!1);t.removeAllRanges();t.addRange(i);t.extend(e.focusNode,e.focusOffset)}}function Dn(e,i){var n=e.display,o=e.doc;if(i.editorIsHidden){Sn(e);return!1}if(!i.force&&i.visible.from>=n.viewFrom&&i.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==Tn(e)){return!1}if(Ui(e)){Sn(e);i.dims=Si(e)}var r=o.first+o.size,l=Math.max(i.visible.from-e.options.viewportMargin,o.first),s=Math.min(r,i.visible.to+e.options.viewportMargin);if(n.viewFrom<l&&20>l-n.viewFrom){l=Math.max(o.first,n.viewFrom)}if(n.viewTo>s&&20>n.viewTo-s){s=Math.min(r,n.viewTo)}if(ql){l=xe(e.doc,l);s=ve(e.doc,s)}var d=l!=n.viewFrom||s!=n.viewTo||n.lastWrapHeight!=i.wrapperHeight||n.lastWrapWidth!=i.wrapperWidth;kn(e,l,s);n.viewOffset=we(A(e.doc,n.viewFrom));e.display.mover.style.top=n.viewOffset+"px";var a=Tn(e);if(!d&&0==a&&!i.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)){return!1}var p=Mn(e);if(4<a){n.lineDiv.style.display="none"}Pn(e,n.updateLineNumbers,i.dims);if(4<a){n.lineDiv.style.display=""}n.renderedView=n.view;Wn(p);t(n.cursorDiv);t(n.selectionDiv);n.gutters.style.height=n.sizer.style.minHeight=0;if(d){n.lastWrapHeight=i.wrapperHeight;n.lastWrapWidth=i.wrapperWidth;Nn(e,400)}n.updateLineNumbers=null;return!0}function Hn(e,t){for(var i=t.viewport,n=!0;;n=!1){if(!n||!e.options.lineWrapping||t.oldDisplayWidth==Ut(e)){if(i&&null!=i.top){i={top:Math.min(e.doc.height+Bt(e.display)-jt(e),i.top)}}t.visible=Gi(e.display,e.doc,i);if(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo){break}}if(!Dn(e,t)){break}Ri(e);var o=rn(e);Ai(e);ln(e,o);zn(e,o);t.force=!1}t.signal(e,"update",e);if(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 Fn(e,t){var i=new Ls(e,t);if(Dn(e,i)){Ri(e);Hn(e,i);var n=rn(e);Ai(e);ln(e,n);zn(e,n);i.finish()}}function Pn(e,n,o){var l=e.display,s=e.options.lineNumbers,d=l.lineDiv,a=d.firstChild;function r(t){var i=t.nextSibling;if(wl&&Dl&&e.display.currentWheelTarget==t){t.style.display="none"}else{t.parentNode.removeChild(t)}return i}for(var p=l.view,c=l.viewFrom,h=0,u;h<p.length;h++){u=p[h];if(u.hidden);else if(!u.node||u.node.parentNode!=d){var f=Ht(e,u,c,o);d.insertBefore(f,a)}else{while(a!=u.node){a=r(a)}var m=s&&null!=n&&n<=c&&u.lineNumber;if(u.changes){if(-1<g(u.changes,"gutter")){m=!1}kt(e,u,c,o)}if(m){t(u.lineNumber);u.lineNumber.appendChild(document.createTextNode(I(e.options,c)))}a=u.node.nextSibling}c+=u.size}while(a){a=r(a)}}function In(e){var t=e.display.gutters.offsetWidth;e.display.sizer.style.marginLeft=t+"px"}function zn(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+$t(e)+"px"}function En(e){var n=e.display.gutters,r=e.options.gutters;t(n);var l=0;for(;l<r.length;++l){var s=r[l],d=n.appendChild(o("div",null,"CodeMirror-gutter "+s));if("CodeMirror-linenumbers"==s){e.display.lineGutter=d;d.style.width=(e.display.lineNumWidth||1)+"px"}}n.style.display=l?"":"none";In(e)}function Rn(e){var t=g(e.gutters,"CodeMirror-linenumbers");if(-1==t&&e.lineNumbers){e.gutters=e.gutters.concat(["CodeMirror-linenumbers"])}else if(-1<t&&!e.lineNumbers){e.gutters=e.gutters.slice(0);e.gutters.splice(t,1)}}var ks=0,Ts=null;if(Cl){Ts=-.53}else if(yl){Ts=15}else if(Ll){Ts=-.7}else if(Tl){Ts=-1/3}function Bn(t){var e=t.wheelDeltaX,i=t.wheelDeltaY;if(null==e&&t.detail&&t.axis==t.HORIZONTAL_AXIS){e=t.detail}if(null==i&&t.detail&&t.axis==t.VERTICAL_AXIS){i=t.detail}else if(null==i){i=t.wheelDelta}return{x:e,y:i}}function Gn(t){var e=Bn(t);e.x*=Ts;e.y*=Ts;return e}function $n(t,n){var e=Bn(n),o=e.x,r=e.y,l=t.display,s=l.scroller,d=s.scrollWidth>s.clientWidth,a=s.scrollHeight>s.clientHeight;if(!(o&&d||r&&a)){return}if(r&&Dl&&wl){outer:for(var p=n.target,c=l.view;p!=s;p=p.parentNode){for(var h=0;h<c.length;h++){if(c[h].node==p){t.display.currentWheelTarget=p;break outer}}}}if(o&&!yl&&!kl&&null!=Ts){if(r&&a){en(t,Math.max(0,s.scrollTop+r*Ts))}nn(t,Math.max(0,s.scrollLeft+o*Ts));if(!r||r&&a){Pe(n)}l.wheelStartX=null;return}if(r&&null!=Ts){var g=r*Ts,u=t.doc.scrollTop,f=u+l.wrapper.clientHeight;if(0>g){u=Math.max(0,u+g-50)}else{f=Math.min(t.doc.height,f+g+50)}Fn(t,{top:u,bottom:f})}if(20>ks){if(null==l.wheelStartX){l.wheelStartX=s.scrollLeft;l.wheelStartY=s.scrollTop;l.wheelDX=o;l.wheelDY=r;setTimeout(function(){if(null==l.wheelStartX){return}var e=s.scrollLeft-l.wheelStartX,t=s.scrollTop-l.wheelStartY,i=t&&l.wheelDY&&t/l.wheelDY||e&&l.wheelDX&&e/l.wheelDX;l.wheelStartX=l.wheelStartY=null;if(!i){return}Ts=(Ts*ks+i)/(ks+1);++ks},200)}else{l.wheelDX+=o;l.wheelDY+=r}}}var Ns=function(e,t){this.ranges=e;this.primIndex=t};Ns.prototype.primary=function(){return this.ranges[this.primIndex]};Ns.prototype.equals=function(e){if(e==this){return!0}if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length){return!1}for(var t=0;t<this.ranges.length;t++){var n=this.ranges[t],o=e.ranges[t];if(!R(n.anchor,o.anchor)||!R(n.head,o.head)){return!1}}return!0};Ns.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++){e[t]=new Os(B(this.ranges[t].anchor),B(this.ranges[t].head))}return new Ns(e,this.primIndex)};Ns.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++){if(!this.ranges[e].empty()){return!0}}return!1};Ns.prototype.contains=function(e,t){if(!t){t=e}for(var n=0,o;n<this.ranges.length;n++){o=this.ranges[n];if(0<=E(t,o.from())&&0>=E(e,o.to())){return n}}return-1};var Os=function(e,t){this.anchor=e;this.head=t};Os.prototype.from=function(){return $(this.anchor,this.head)};Os.prototype.to=function(){return G(this.anchor,this.head)};Os.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch};function Un(e,t,n){var o=e&&e.options.selectionsMayTouch,r=t[n];t.sort(function(e,t){return E(e.from(),t.from())});n=g(t,r);for(var l=1;l<t.length;l++){var s=t[l],d=t[l-1],a=E(d.to(),s.from());if(o&&!s.empty()?0<a:0<=a){var p=$(d.from(),s.from()),c=G(d.to(),s.to()),h=d.empty()?s.from()==s.head:d.from()==d.head;if(l<=n){--n}t.splice(--l,2,new Os(h?c:p,h?p:c))}}return new Ns(t,n)}function jn(e,t){return new Ns([new Os(e,t||e)],0)}function Vn(e){if(!e.text){return e.to}return z(e.from.line+e.text.length-1,y(e.text).length+(1==e.text.length?e.from.ch:0))}function Kn(e,t){if(0>E(e,t.from)){return e}if(0>=E(e,t.to)){return Vn(t)}var i=e.line+t.text.length-(t.to.line-t.from.line)-1,n=e.ch;if(e.line==t.to.line){n+=Vn(t).ch-t.to.ch}return z(i,n)}function Xn(e,t){for(var n=[],o=0,r;o<e.sel.ranges.length;o++){r=e.sel.ranges[o];n.push(new Os(Kn(r.anchor,t),Kn(r.head,t)))}return Un(e.cm,n,e.sel.primIndex)}function Yn(e,t,i){if(e.line==t.line){return z(i.line,e.ch-t.ch+i.ch)}else{return z(i.line+(e.line-t.line),e.ch)}}function _n(e,t,n){for(var o=[],r=z(e.first,0),l=r,s=0;s<t.length;s++){var d=t[s],a=Yn(d.from,r,l),p=Yn(Vn(d),r,l);r=d.to;l=p;if("around"==n){var c=e.sel.ranges[s],h=0>E(c.head,c.anchor);o[s]=new Os(h?p:a,h?a:p)}else{o[s]=new Os(a,a)}}return new Ns(o,e.sel.primIndex)}function qn(e){e.doc.mode=Ke(e.options,e.doc.modeOption);Zn(e)}function Zn(e){e.doc.iter(function(e){if(e.stateAfter){e.stateAfter=null}if(e.styles){e.styles=null}});e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first;Nn(e,100);e.state.modeGen++;if(e.curOp){Cn(e)}}function Qn(e,t){return 0==t.from.ch&&0==t.to.ch&&""==y(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function Jn(e,t,i,n){function o(e){return i?i[e]:null}function r(e,i,o){dt(e,i,o,n);St(e,"change",e,t)}function l(e,t){for(var r=[],l=e;l<t;++l){r.push(new gs(a[l],o(l),n))}return r}var s=t.from,d=t.to,a=t.text,p=A(e,s.line),c=A(e,d.line),h=y(a),g=o(a.length-1),u=d.line-s.line;if(t.full){e.insert(0,l(0,a.length));e.remove(a.length,e.size-a.length)}else if(Qn(e,t)){var f=l(0,a.length-1);r(c,c.text,g);if(u){e.remove(s.line,u)}if(f.length){e.insert(s.line,f)}}else if(p==c){if(1==a.length){r(p,p.text.slice(0,s.ch)+h+p.text.slice(d.ch),g)}else{var m=l(1,a.length-1);m.push(new gs(h+p.text.slice(d.ch),g,n));r(p,p.text.slice(0,s.ch)+a[0],o(0));e.insert(s.line+1,m)}}else if(1==a.length){r(p,p.text.slice(0,s.ch)+a[0]+c.text.slice(d.ch),o(0));e.remove(s.line+1,u)}else{r(p,p.text.slice(0,s.ch)+a[0],o(0));r(c,h+c.text.slice(d.ch),g);var x=l(1,a.length-1);if(1<u){e.remove(s.line+1,u-1)}e.insert(s.line+1,x)}St(e,"change",e,t)}function eo(e,t,n){function o(e,r,l){if(e.linked){for(var s=0,d;s<e.linked.length;++s){d=e.linked[s];if(d.doc==r){continue}var a=l&&d.sharedHist;if(n&&!a){continue}t(d.doc,a);o(d.doc,e,a)}}}o(e,null,!0)}function to(e,t){if(t.cm){throw new Error("This document is already in use.")}e.doc=t;t.cm=e;Ti(e);qn(e);io(e);if(!e.options.lineWrapping){Le(e)}e.options.mode=t.modeOption;Cn(e)}function io(e){("rtl"==e.doc.direction?d:El)(e.display.lineDiv,"CodeMirror-rtl")}function no(e){yn(e,function(){io(e);Cn(e)})}function oo(e){this.done=[];this.undone=[];this.undoDepth=1/0;this.lastModTime=this.lastSelTime=0;this.lastOp=this.lastSelOp=null;this.lastOrigin=this.lastSelOrigin=null;this.generation=this.maxGeneration=e||1}function ro(e,t){var i={from:B(t.from),to:Vn(t),text:M(e,t.from,t.to)};go(e,i,t.from.line,t.to.line+1);eo(e,function(e){return go(e,i,t.from.line,t.to.line+1)},!0);return i}function lo(e){while(e.length){var t=y(e);if(t.ranges){e.pop()}else{break}}}function so(e,t){if(t){lo(e.done);return y(e.done)}else if(e.done.length&&!y(e.done).ranges){return y(e.done)}else if(1<e.done.length&&!e.done[e.done.length-2].ranges){e.done.pop();return y(e.done)}}function ao(e,t,i,n){var o=e.history;o.undone.length=0;var r=+new Date,l,s;if((o.lastOp==n||o.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&o.lastModTime>r-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(l=so(o,o.lastOp==n))){s=y(l.changes);if(0==E(t.from,t.to)&&0==E(t.from,s.to)){s.to=Vn(t)}else{l.changes.push(ro(e,t))}}else{var d=y(o.done);if(!d||!d.ranges){ho(e.sel,o.done)}l={changes:[ro(e,t)],generation:o.generation};o.done.push(l);while(o.done.length>o.undoDepth){o.done.shift();if(!o.done[0].ranges){o.done.shift()}}}o.done.push(i);o.generation=++o.maxGeneration;o.lastModTime=o.lastSelTime=r;o.lastOp=o.lastSelOp=n;o.lastOrigin=o.lastSelOrigin=t.origin;if(!s){Me(e,"historyAdded")}}function po(e,t,i,n){var o=t.charAt(0);return"*"==o||"+"==o&&i.ranges.length==n.ranges.length&&i.somethingSelected()==n.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function co(e,t,i,n){var o=e.history,r=n&&n.origin;if(i==o.lastSelOp||r&&o.lastSelOrigin==r&&(o.lastModTime==o.lastSelTime&&o.lastOrigin==r||po(e,r,y(o.done),t))){o.done[o.done.length-1]=t}else{ho(t,o.done)}o.lastSelTime=+new Date;o.lastSelOrigin=r;o.lastSelOp=i;if(n&&!1!==n.clearRedo){lo(o.undone)}}function ho(e,t){var i=y(t);if(!(i&&i.ranges&&i.equals(e))){t.push(e)}}function go(e,t,i,o){var r=t["spans_"+e.id],l=0;e.iter(Math.max(e.first,i),Math.min(e.first+e.size,o),function(i){if(i.markedSpans){(r||(r=t["spans_"+e.id]={}))[l]=i.markedSpans}++l})}function uo(e){if(!e){return null}for(var t,n=0;n<e.length;++n){if(e[n].marker.explicitlyCleared){if(!t){t=e.slice(0,n)}}else if(t){t.push(e[n])}}return!t?e:t.length?t:null}function fo(e,t){var n=t["spans_"+e.id];if(!n){return null}for(var o=[],r=0;r<t.text.length;++r){o.push(uo(n[r]))}return o}function mo(e,t){var n=fo(e,t),o=te(e,t);if(!n){return o}if(!o){return n}for(var r=0;r<n.length;++r){var l=n[r],s=o[r];if(l&&s){spans:for(var d=0,a;d<s.length;++d){a=s[d];for(var p=0;p<l.length;++p){if(l[p].marker==a.marker){continue spans}}l.push(a)}}else if(s){n[r]=s}}return n}function yo(e,t,n){for(var o=[],r=0,l;r<e.length;++r){l=e[r];if(l.ranges){o.push(n?Ns.prototype.deepCopy.call(l):l);continue}var s=l.changes,d=[];o.push({changes:d});for(var a=0;a<s.length;++a){var p=s[a],c=void 0;d.push({from:p.from,to:p.to,text:p.text});if(t){for(var h in p){if(c=h.match(/^spans_(\d+)$/)){if(-1<g(t,+c[1])){y(d)[h]=p[h];delete p[h]}}}}}}return o}function xo(e,t,i,n){if(n){var o=e.anchor;if(i){var r=0>E(t,o);if(r!=0>E(i,o)){o=t;t=i}else if(r!=0>E(t,i)){t=i}}return new Os(o,t)}else{return new Os(i||t,t)}}function vo(e,t,i,n,o){if(null==o){o=e.cm&&(e.cm.display.shift||e.extend)}ko(e,new Ns([xo(e.sel.primary(),t,i,o)],0),n)}function bo(e,t,n){for(var o=[],r=e.cm&&(e.cm.display.shift||e.extend),l=0;l<e.sel.ranges.length;l++){o[l]=xo(e.sel.ranges[l],t[l],null,r)}var s=Un(e.cm,o,e.sel.primIndex);ko(e,s,n)}function Co(e,t,i,n){var o=e.sel.ranges.slice(0);o[t]=i;ko(e,Un(e.cm,o,e.sel.primIndex),n)}function wo(e,t,i,n){ko(e,jn(t,i),n)}function So(e,t,i){var n={ranges:t.ranges,update:function update(t){this.ranges=[];for(var n=0;n<t.length;n++){this.ranges[n]=new Os(j(e,t[n].anchor),j(e,t[n].head))}},origin:i&&i.origin};Me(e,"beforeSelectionChange",e,n);if(e.cm){Me(e.cm,"beforeSelectionChange",e.cm,n)}if(n.ranges!=t.ranges){return Un(e.cm,n.ranges,n.ranges.length-1)}else{return t}}function Lo(e,t,i){var n=e.history.done,o=y(n);if(o&&o.ranges){n[n.length-1]=t;To(e,t,i)}else{ko(e,t,i)}}function ko(e,t,i){To(e,t,i);co(e,e.sel,e.cm?e.cm.curOp.id:NaN,i)}function To(e,t,i){if(He(e,"beforeSelectionChange")||e.cm&&He(e.cm,"beforeSelectionChange")){t=So(e,t,i)}var n=i&&i.bias||(0>E(t.primary().head,e.sel.primary().head)?-1:1);No(e,Ao(e,t,n,!0));if(!(i&&!1===i.scroll)&&e.cm){_i(e.cm)}}function No(e,t){if(t.equals(e.sel)){return}e.sel=t;if(e.cm){e.cm.curOp.updateInput=e.cm.curOp.selectionChanged=!0;De(e.cm)}St(e,"cursorActivity",e)}function Oo(e){No(e,Ao(e,e.sel,null,!1))}function Ao(e,t,n,o){for(var r,l=0;l<t.ranges.length;l++){var s=t.ranges[l],d=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[l],a=Wo(e,s.anchor,d&&d.anchor,n,o),p=Wo(e,s.head,d&&d.head,n,o);if(r||a!=s.anchor||p!=s.head){if(!r){r=t.ranges.slice(0,l)}r[l]=new Os(a,p)}}return r?Un(e.cm,r,t.primIndex):t}function Mo(e,t,n,o,r){var l=A(e,t.line);if(l.markedSpans){for(var s=0;s<l.markedSpans.length;++s){var d=l.markedSpans[s],a=d.marker;if((null==d.from||(a.inclusiveLeft?d.from<=t.ch:d.from<t.ch))&&(null==d.to||(a.inclusiveRight?d.to>=t.ch:d.to>t.ch))){if(r){Me(a,"beforeCursorEnter");if(a.explicitlyCleared){if(!l.markedSpans){break}else{--s;continue}}}if(!a.atomic){continue}if(n){var p=a.find(0>o?1:-1),c=void 0;if(0>o?a.inclusiveRight:a.inclusiveLeft){p=Do(e,p,-o,p&&p.line==t.line?l:null)}if(p&&p.line==t.line&&(c=E(p,n))&&(0>o?0>c:0<c)){return Mo(e,p,t,o,r)}}var h=a.find(0>o?-1:1);if(0>o?a.inclusiveLeft:a.inclusiveRight){h=Do(e,h,o,h.line==t.line?l:null)}return h?Mo(e,h,t,o,r):null}}}return t}function Wo(e,t,i,n,o){var r=n||1,l=Mo(e,t,i,r,o)||!o&&Mo(e,t,i,r,!0)||Mo(e,t,i,-r,o)||!o&&Mo(e,t,i,-r,!0);if(!l){e.cantEdit=!0;return z(e.first,0)}return l}function Do(e,t,i,n){if(0>i&&0==t.ch){if(t.line>e.first){return j(e,z(t.line-1))}else{return null}}else if(0<i&&t.ch==(n||A(e,t.line)).text.length){if(t.line<e.first+e.size-1){return z(t.line+1,0)}else{return null}}else{return new z(t.line,t.ch+i)}}function Ho(e){e.setSelection(z(e.firstLine(),0),z(e.lastLine()),Ul)}function Fo(e,t,i){var n={canceled:!1,from:t.from,to:t.to,text:t.text,origin:t.origin,cancel:function cancel(){return n.canceled=!0}};if(i){n.update=function(t,i,o,r){if(t){n.from=j(e,t)}if(i){n.to=j(e,i)}if(o){n.text=o}if(r!==void 0){n.origin=r}}}Me(e,"beforeChange",e,n);if(e.cm){Me(e.cm,"beforeChange",e.cm,n)}if(n.canceled){return null}return{from:n.from,to:n.to,text:n.text,origin:n.origin}}function Po(e,t,n){if(e.cm){if(!e.cm.curOp){return xn(e.cm,Po)(e,t,n)}if(e.cm.state.suppressEdits){return}}if(He(e,"beforeChange")||e.cm&&He(e.cm,"beforeChange")){t=Fo(e,t,!0);if(!t){return}}var o=_l&&!n&&oe(e,t.from,t.to);if(o){for(var r=o.length-1;0<=r;--r){Io(e,{from:o[r].from,to:o[r].to,text:r?[""]:t.text,origin:t.origin})}}else{Io(e,t)}}function Io(e,t){if(1==t.text.length&&""==t.text[0]&&0==E(t.from,t.to)){return}var i=Xn(e,t);ao(e,t,i,e.cm?e.cm.curOp.id:NaN);Ro(e,t,i,te(e,t));var n=[];eo(e,function(e,i){if(!i&&-1==g(n,e.history)){jo(e.history,t);n.push(e.history)}Ro(e,t,null,te(e,t))})}function zo(e,t,n){var o=e.cm&&e.cm.state.suppressEdits;if(o&&!n){return}var r=e.history,l,s=e.sel,d="undo"==t?r.done:r.undone,a="undo"==t?r.undone:r.done,p=0;for(;p<d.length;p++){l=d[p];if(n?l.ranges&&!l.equals(e.sel):!l.ranges){break}}if(p==d.length){return}r.lastOrigin=r.lastSelOrigin=null;for(;;){l=d.pop();if(l.ranges){ho(l,a);if(n&&!l.equals(e.sel)){ko(e,l,{clearRedo:!1});return}s=l}else if(o){d.push(l);return}else{break}}var c=[];ho(s,a);a.push({changes:c,generation:r.generation});r.generation=l.generation||++r.maxGeneration;for(var h=He(e,"beforeChange")||e.cm&&He(e.cm,"beforeChange"),u=function(n){var i=l.changes[n];i.origin=t;if(h&&!Fo(e,i,!1)){d.length=0;return{}}c.push(ro(e,i));var o=n?Xn(e,i):y(d);Ro(e,i,o,mo(e,i));if(!n&&e.cm){e.cm.scrollIntoView({from:i.from,to:Vn(i)})}var r=[];eo(e,function(e,t){if(!t&&-1==g(r,e.history)){jo(e.history,i);r.push(e.history)}Ro(e,i,null,mo(e,i))})},f=l.changes.length-1,m;0<=f;--f){m=u(f);if(m)return m.v}}function Eo(e,t){if(0==t){return}e.first+=t;e.sel=new Ns(x(e.sel.ranges,function(e){return new Os(z(e.anchor.line+t,e.anchor.ch),z(e.head.line+t,e.head.ch))}),e.sel.primIndex);if(e.cm){Cn(e.cm,e.first,e.first-t,t);for(var i=e.cm.display,n=i.viewFrom;n<i.viewTo;n++){wn(e.cm,n,"gutter")}}}function Ro(e,t,i,n){if(e.cm&&!e.cm.curOp){return xn(e.cm,Ro)(e,t,i,n)}if(t.to.line<e.first){Eo(e,t.text.length-1-(t.to.line-t.from.line));return}if(t.from.line>e.lastLine()){return}if(t.from.line<e.first){var o=t.text.length-1-(e.first-t.from.line);Eo(e,o);t={from:z(e.first,0),to:z(t.to.line+o,t.to.ch),text:[y(t.text)],origin:t.origin}}var r=e.lastLine();if(t.to.line>r){t={from:t.from,to:z(r,A(e,r).text.length),text:[t.text[0]],origin:t.origin}}t.removed=M(e,t.from,t.to);if(!i){i=Xn(e,t)}if(e.cm){Bo(e.cm,t,n)}else{Jn(e,t,n)}To(e,i,Ul)}function Bo(e,t,i){var n=e.doc,o=e.display,r=t.from,l=t.to,s=!1,d=r.line;if(!e.options.lineWrapping){d=H(fe(A(n,r.line)));n.iter(d,l.line+1,function(e){if(e==o.maxLine){s=!0;return!0}})}if(-1<n.sel.contains(t.from,t.to)){De(e)}Jn(n,t,i,ki(e));if(!e.options.lineWrapping){n.iter(d,r.line+t.text.length,function(e){var t=Se(e);if(t>o.maxLineLength){o.maxLine=e;o.maxLineLength=t;o.maxLineChanged=!0;s=!1}});if(s){e.curOp.updateMaxLine=!0}}st(n,r.line);Nn(e,400);var a=t.text.length-(l.line-r.line)-1;if(t.full){Cn(e)}else if(r.line==l.line&&1==t.text.length&&!Qn(e.doc,t)){wn(e,r.line,"text")}else{Cn(e,r.line,l.line+1,a)}var p=He(e,"changes"),c=He(e,"change");if(c||p){var h={from:r,to:l,text:t.text,removed:t.removed,origin:t.origin};if(c){St(e,"change",e,h)}if(p){(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(h)}}e.display.selForContextMenu=null}function Go(e,t,i,n,o){var r;if(!n){n=i}if(0>E(n,i)){r=[n,i],i=r[0],n=r[1]}if("string"==typeof t){t=e.splitLines(t)}Po(e,{from:i,to:n,text:t,origin:o})}function $o(e,t,i,n){if(i<e.line){e.line+=n}else if(t<e.line){e.line=t;e.ch=0}}function Uo(e,t,n,o){for(var r=0;r<e.length;++r){var l=e[r],s=!0;if(l.ranges){if(!l.copied){l=e[r]=l.deepCopy();l.copied=!0}for(var d=0;d<l.ranges.length;d++){$o(l.ranges[d].anchor,t,n,o);$o(l.ranges[d].head,t,n,o)}continue}for(var a=0,p;a<l.changes.length;++a){p=l.changes[a];if(n<p.from.line){p.from=z(p.from.line+o,p.from.ch);p.to=z(p.to.line+o,p.to.ch)}else if(t<=p.to.line){s=!1;break}}if(!s){e.splice(0,r+1);r=0}}}function jo(e,t){var i=t.from.line,n=t.to.line,o=t.text.length-(n-i)-1;Uo(e.done,i,n,o);Uo(e.undone,i,n,o)}function Vo(e,t,i,n){var o=t,r=t;if("number"==typeof t){r=A(e,U(e,t))}else{o=H(t)}if(null==o){return null}if(n(r,o)&&e.cm){wn(e.cm,o,i)}return r}function Ko(e){this.lines=e;this.parent=null;for(var t=0,n=0;n<e.length;++n){e[n].parent=this;t+=e[n].height}this.height=t}Ko.prototype={chunkSize:function chunkSize(){return this.lines.length},removeInner:function removeInner(e,t){for(var n=e,o;n<e+t;++n){o=this.lines[n];this.height-=o.height;at(o);St(o,"delete")}this.lines.splice(e,t)},collapse:function collapse(e){e.push.apply(e,this.lines)},insertInner:function insertInner(e,t,n){this.height+=n;this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var o=0;o<t.length;++o){t[o].parent=this}},iterN:function iterN(t,i,n){for(var o=t+i;t<o;++t){if(n(this.lines[t])){return!0}}}};function Xo(e){this.children=e;for(var t=0,n=0,o=0,r;o<e.length;++o){r=e[o];t+=r.chunkSize();n+=r.height;r.parent=this}this.size=t;this.height=n;this.parent=null}Xo.prototype={chunkSize:function chunkSize(){return this.size},removeInner:function removeInner(e,t){this.size-=t;for(var o=0;o<this.children.length;++o){var r=this.children[o],l=r.chunkSize();if(e<l){var s=Math.min(t,l-e),d=r.height;r.removeInner(e,s);this.height-=d-r.height;if(l==s){this.children.splice(o--,1);r.parent=null}if(0==(t-=s)){break}e=0}else{e-=l}}if(25>this.size-t&&(1<this.children.length||!(this.children[0]instanceof Ko))){var a=[];this.collapse(a);this.children=[new Ko(a)];this.children[0].parent=this}},collapse:function collapse(e){for(var t=0;t<this.children.length;++t){this.children[t].collapse(e)}},insertInner:function insertInner(e,t,n){this.size+=t.length;this.height+=n;for(var o=0;o<this.children.length;++o){var r=this.children[o],l=r.chunkSize();if(e<=l){r.insertInner(e,t,n);if(r.lines&&50<r.lines.length){for(var s=r.lines.length%25+25,d=s,a;d<r.lines.length;){a=new Ko(r.lines.slice(d,d+=25));r.height-=a.height;this.children.splice(++o,0,a);a.parent=this}r.lines=r.lines.slice(0,s);this.maybeSpill()}break}e-=l}},maybeSpill:function maybeSpill(){if(10>=this.children.length){return}var e=this;do{var t=e.children.splice(e.children.length-5,5),i=new Xo(t);if(!e.parent){var n=new Xo(e.children);n.parent=e;e.children=[n,i];e=n}else{e.size-=i.size;e.height-=i.height;var o=g(e.parent.children,e);e.parent.children.splice(o+1,0,i)}i.parent=e.parent}while(10<e.children.length);e.parent.maybeSpill()},iterN:function iterN(e,t,o){for(var r=0;r<this.children.length;++r){var l=this.children[r],s=l.chunkSize();if(e<s){var d=Math.min(t,s-e);if(l.iterN(e,d,o)){return!0}if(0==(t-=d)){break}e=0}else{e-=s}}}};var As=function(e,t,i){if(i){for(var n in i){if(i.hasOwnProperty(n)){this[n]=i[n]}}}this.doc=e;this.node=t};As.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,n=this.line,o=H(n);if(null==o||!t){return}for(var r=0;r<t.length;++r){if(t[r]==this){t.splice(r--,1)}}if(!t.length){n.widgets=null}var l=zt(this);D(n,Math.max(0,n.height-l));if(e){yn(e,function(){Yo(e,n,-l);wn(e,o,"widget")});St(e,"lineWidgetCleared",e,this,o)}};As.prototype.changed=function(){var e=this,t=this.height,i=this.doc.cm,n=this.line;this.height=null;var o=zt(this)-t;if(!o){return}if(!be(this.doc,n)){D(n,n.height+o)}if(i){yn(i,function(){i.curOp.forceUpdate=!0;Yo(i,n,o);St(i,"lineWidgetChanged",i,e,H(n))})}};Fe(As);function Yo(e,t,i){if(we(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)){Yi(e,i)}}function _o(e,t,i,n){var o=new As(e,i,n),r=e.cm;if(r&&o.noHScroll){r.display.alignWidgets=!0}Vo(e,t,"widget",function(t){var i=t.widgets||(t.widgets=[]);if(null==o.insertAt){i.push(o)}else{i.splice(Math.min(i.length-1,Math.max(0,o.insertAt)),0,o)}o.line=t;if(r&&!be(e,t)){var n=we(t)<e.scrollTop;D(t,t.height+zt(o));if(n){Yi(r,o.height)}r.curOp.forceUpdate=!0}return!0});if(r){St(r,"lineWidgetAdded",r,o,"number"==typeof t?t:H(t))}return o}var Ms=0,Ws=function(e,t){this.lines=[];this.type=t;this.doc=e;this.id=++Ms};Ws.prototype.clear=function(){if(this.explicitlyCleared){return}var e=this.doc.cm,t=e&&!e.curOp;if(t){an(e)}if(He(this,"clear")){var n=this.find();if(n){St(this,"clear",n.from,n.to)}}for(var o=null,r=null,l=0;l<this.lines.length;++l){var s=this.lines[l],d=q(s.markedSpans,this);if(e&&!this.collapsed){wn(e,H(s),"text")}else if(e){if(null!=d.to){r=H(s)}if(null!=d.from){o=H(s)}}s.markedSpans=Z(s.markedSpans,d);if(null==d.from&&this.collapsed&&!be(this.doc,s)&&e){D(s,Ci(e.display))}}if(e&&this.collapsed&&!e.options.lineWrapping){for(var a=0;a<this.lines.length;++a){var p=fe(this.lines[a]),c=Se(p);if(c>e.display.maxLineLength){e.display.maxLine=p;e.display.maxLineLength=c;e.display.maxLineChanged=!0}}}if(null!=o&&e&&this.collapsed){Cn(e,o,r+1)}this.lines.length=0;this.explicitlyCleared=!0;if(this.atomic&&this.doc.cantEdit){this.doc.cantEdit=!1;if(e){Oo(e.doc)}}if(e){St(e,"markerCleared",e,this,o,r)}if(t){pn(e)}if(this.parent){this.parent.clear()}};Ws.prototype.find=function(e,t){if(null==e&&"bookmark"==this.type){e=1}for(var n,o,r=0;r<this.lines.length;++r){var l=this.lines[r],s=q(l.markedSpans,this);if(null!=s.from){n=z(t?l:H(l),s.from);if(-1==e){return n}}if(null!=s.to){o=z(t?l:H(l),s.to);if(1==e){return o}}}return n&&{from:n,to:o}};Ws.prototype.changed=function(){var e=this,t=this.find(-1,!0),i=this,n=this.doc.cm;if(!t||!n){return}yn(n,function(){var o=t.line,r=H(t.line),l=_t(n,r);if(l){ii(l);n.curOp.selectionChanged=n.curOp.forceUpdate=!0}n.curOp.updateMaxLine=!0;if(!be(i.doc,o)&&null!=i.height){var s=i.height;i.height=null;var d=zt(i)-s;if(d){D(o,o.height+d)}}St(n,"markerChanged",n,e)})};Ws.prototype.attachLine=function(e){if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;if(!t.maybeHiddenMarkers||-1==g(t.maybeHiddenMarkers,this)){(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)}}this.lines.push(e)};Ws.prototype.detachLine=function(e){this.lines.splice(g(this.lines,e),1);if(!this.lines.length&&this.doc.cm){var t=this.doc.cm.curOp;(t.maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)}};Fe(Ws);function qo(e,t,n,o,l){if(o&&o.shared){return Zo(e,t,n,o,l)}if(e.cm&&!e.cm.curOp){return xn(e.cm,qo)(e,t,n,o,l)}var s=new Ws(e,l),d=E(t,n);if(o){c(o,s,!1)}if(0<d||0==d&&!1!==s.clearWhenEmpty){return s}if(s.replacedWith){s.collapsed=!0;s.widgetNode=r("span",[s.replacedWith],"CodeMirror-widget");if(!o.handleMouseEvents){s.widgetNode.setAttribute("cm-ignore-events","true")}if(o.insertLeft){s.widgetNode.insertLeft=!0}}if(s.collapsed){if(ue(e,t.line,t,n,s)||t.line!=n.line&&ue(e,n.line,t,n,s)){throw new Error("Inserting collapsed marker partially overlapping an existing one")}Y()}if(s.addToHistory){ao(e,{from:t,to:n,origin:"markText"},e.sel,NaN)}var a=t.line,p=e.cm,h;e.iter(a,n.line+1,function(e){if(p&&s.collapsed&&!p.options.lineWrapping&&fe(e)==p.display.maxLine){h=!0}if(s.collapsed&&a!=t.line){D(e,0)}Q(e,new _(s,a==t.line?t.ch:null,a==n.line?n.ch:null));++a});if(s.collapsed){e.iter(t.line,n.line+1,function(t){if(be(e,t)){D(t,0)}})}if(s.clearOnEnter){es(s,"beforeCursorEnter",function(){return s.clear()})}if(s.readOnly){X();if(e.history.done.length||e.history.undone.length){e.clearHistory()}}if(s.collapsed){s.id=++Ms;s.atomic=!0}if(p){if(h){p.curOp.updateMaxLine=!0}if(s.collapsed){Cn(p,t.line,n.line+1)}else if(s.className||s.title||s.startStyle||s.endStyle||s.css){for(var g=t.line;g<=n.line;g++){wn(p,g,"text")}}if(s.atomic){Oo(p.doc)}St(p,"markerAdded",p,s)}return s}var Ds=function(e,t){this.markers=e;this.primary=t;for(var n=0;n<e.length;++n){e[n].parent=this}};Ds.prototype.clear=function(){if(this.explicitlyCleared){return}this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e){this.markers[e].clear()}St(this,"clear")};Ds.prototype.find=function(e,t){return this.primary.find(e,t)};Fe(Ds);function Zo(e,t,n,o,r){o=c(o);o.shared=!1;var l=[qo(e,t,n,o,r)],s=l[0],d=o.widgetNode;eo(e,function(e){if(d){o.widgetNode=d.cloneNode(!0)}l.push(qo(e,j(e,t),j(e,n),o,r));for(var a=0;a<e.linked.length;++a){if(e.linked[a].isParent){return}}s=y(l)});return new Ds(l,s)}function Qo(e){return e.findMarks(z(e.first,0),e.clipPos(z(e.lastLine())),function(e){return e.parent})}function Jo(e,t){for(var n=0;n<t.length;n++){var o=t[n],r=o.find(),l=e.clipPos(r.from),s=e.clipPos(r.to);if(E(l,s)){var d=qo(e,l,s,o.primary,o.primary.type);o.markers.push(d);d.parent=o}}}function er(e){for(var t=function(t){var i=e[t],n=[i.primary.doc];eo(i.primary.doc,function(e){return n.push(e)});for(var o=0,r;o<i.markers.length;o++){r=i.markers[o];if(-1==g(n,r.doc)){r.parent=null;i.markers.splice(o--,1)}}},n=0;n<e.length;n++){t(n)}}var Hs=0,Fs=function(e,t,i,n,o){if(!(this instanceof Fs)){return new Fs(e,t,i,n,o)}if(null==i){i=0}Xo.call(this,[new Ko([new gs("",null)])]);this.first=i;this.scrollTop=this.scrollLeft=0;this.cantEdit=!1;this.cleanGeneration=1;this.modeFrontier=this.highlightFrontier=i;var r=z(i,0);this.sel=jn(r);this.history=new oo(null);this.id=++Hs;this.modeOption=t;this.lineSep=n;this.direction="rtl"==o?"rtl":"ltr";this.extend=!1;if("string"==typeof e){e=this.splitLines(e)}Jn(this,{from:r,to:r,text:e});ko(this,jn(r),Ul)};Fs.prototype=C(Xo.prototype,{constructor:Fs,iter:function iter(e,t,i){if(i){this.iterN(e-this.first,t-e,i)}else{this.iterN(this.first,this.first+this.size,e)}},insert:function insert(e,t){for(var n=0,o=0;o<t.length;++o){n+=t[o].height}this.insertInner(e-this.first,t,n)},remove:function remove(e,t){this.removeInner(e-this.first,t)},getValue:function getValue(e){var t=W(this,this.first,this.first+this.size);if(!1===e){return t}return t.join(e||this.lineSeparator())},setValue:bn(function(e){var t=z(this.first,0),i=this.first+this.size-1;Po(this,{from:t,to:z(i,A(this,i).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0);if(this.cm){qi(this.cm,0,0)}ko(this,jn(t),Ul)}),replaceRange:function replaceRange(e,t,i,n){t=j(this,t);i=i?j(this,i):t;Go(this,e,t,i,n)},getRange:function getRange(e,t,i){var n=M(this,j(this,e),j(this,t));if(!1===i){return n}return n.join(i||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function getLineHandle(e){if(P(this,e)){return A(this,e)}},getLineNumber:function getLineNumber(e){return H(e)},getLineHandleVisualStart:function getLineHandleVisualStart(e){if("number"==typeof e){e=A(this,e)}return fe(e)},lineCount:function lineCount(){return this.size},firstLine:function firstLine(){return this.first},lastLine:function lastLine(){return this.first+this.size-1},clipPos:function clipPos(e){return j(this,e)},getCursor:function getCursor(e){var t=this.sel.primary(),i;if(null==e||"head"==e){i=t.head}else if("anchor"==e){i=t.anchor}else if("end"==e||"to"==e||!1===e){i=t.to()}else{i=t.from()}return i},listSelections:function listSelections(){return this.sel.ranges},somethingSelected:function somethingSelected(){return this.sel.somethingSelected()},setCursor:bn(function(e,t,i){wo(this,j(this,"number"==typeof e?z(e,t||0):e),null,i)}),setSelection:bn(function(e,t,i){wo(this,j(this,e),j(this,t||e),i)}),extendSelection:bn(function(e,t,i){vo(this,j(this,e),t&&j(this,t),i)}),extendSelections:bn(function(e,t){bo(this,K(this,e),t)}),extendSelectionsBy:bn(function(e,t){var i=x(this.sel.ranges,e);bo(this,K(this,i),t)}),setSelections:bn(function(e,t,n){if(!e.length){return}for(var o=[],r=0;r<e.length;r++){o[r]=new Os(j(this,e[r].anchor),j(this,e[r].head))}if(null==t){t=Math.min(e.length-1,this.sel.primIndex)}ko(this,Un(this.cm,o,t),n)}),addSelection:bn(function(e,t,i){var n=this.sel.ranges.slice(0);n.push(new Os(j(this,e),j(this,t||e)));ko(this,Un(this.cm,n,n.length-1),i)}),getSelection:function getSelection(e){for(var t=this.sel.ranges,n,o=0,r;o<t.length;o++){r=M(this,t[o].from(),t[o].to());n=n?n.concat(r):r}if(!1===e){return n}else{return n.join(e||this.lineSeparator())}},getSelections:function getSelections(e){for(var t=[],n=this.sel.ranges,o=0,r;o<n.length;o++){r=M(this,n[o].from(),n[o].to());if(!1!==e){r=r.join(e||this.lineSeparator())}t[o]=r}return t},replaceSelection:function replaceSelection(e,t,n){for(var o=[],r=0;r<this.sel.ranges.length;r++){o[r]=e}this.replaceSelections(o,t,n||"+input")},replaceSelections:bn(function(e,t,n){for(var o=[],r=this.sel,l=0,s;l<r.ranges.length;l++){s=r.ranges[l];o[l]={from:s.from(),to:s.to(),text:this.splitLines(e[l]),origin:n}}for(var d=t&&"end"!=t&&_n(this,o,t),a=o.length-1;0<=a;a--){Po(this,o[a])}if(d){Lo(this,d)}else if(this.cm){_i(this.cm)}}),undo:bn(function(){zo(this,"undo")}),redo:bn(function(){zo(this,"redo")}),undoSelection:bn(function(){zo(this,"undo",!0)}),redoSelection:bn(function(){zo(this,"redo",!0)}),setExtending:function setExtending(e){this.extend=e},getExtending:function getExtending(){return this.extend},historySize:function historySize(){for(var e=this.history,t=0,n=0,o=0;o<e.done.length;o++){if(!e.done[o].ranges){++t}}for(var r=0;r<e.undone.length;r++){if(!e.undone[r].ranges){++n}}return{undo:t,redo:n}},clearHistory:function clearHistory(){this.history=new oo(this.history.maxGeneration)},markClean:function markClean(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function changeGeneration(e){if(e){this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null}return this.history.generation},isClean:function isClean(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function getHistory(){return{done:yo(this.history.done),undone:yo(this.history.undone)}},setHistory:function setHistory(e){var t=this.history=new oo(this.history.maxGeneration);t.done=yo(e.done.slice(0),null,!0);t.undone=yo(e.undone.slice(0),null,!0)},setGutterMarker:bn(function(e,t,i){return Vo(this,e,"gutter",function(e){var n=e.gutterMarkers||(e.gutterMarkers={});n[t]=i;if(!i&&L(n)){e.gutterMarkers=null}return!0})}),clearGutter:bn(function(e){var t=this;this.iter(function(i){if(i.gutterMarkers&&i.gutterMarkers[e]){Vo(t,i,"gutter",function(){i.gutterMarkers[e]=null;if(L(i.gutterMarkers)){i.gutterMarkers=null}return!0})}})}),lineInfo:function lineInfo(e){var t;if("number"==typeof e){if(!P(this,e)){return null}t=e;e=A(this,e);if(!e){return null}}else{t=H(e);if(null==t){return null}}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},addLineClass:bn(function(t,i,n){return Vo(this,t,"gutter"==i?"gutter":"class",function(t){var o="text"==i?"textClass":"background"==i?"bgClass":"gutter"==i?"gutterClass":"wrapClass";if(!t[o]){t[o]=n}else if(e(n).test(t[o])){return!1}else{t[o]+=" "+n}return!0})}),removeLineClass:bn(function(t,i,n){return Vo(this,t,"gutter"==i?"gutter":"class",function(t){var o="text"==i?"textClass":"background"==i?"bgClass":"gutter"==i?"gutterClass":"wrapClass",r=t[o];if(!r){return!1}else if(null==n){t[o]=null}else{var l=r.match(e(n));if(!l){return!1}var s=l.index+l[0].length;t[o]=r.slice(0,l.index)+(!l.index||s==r.length?"":" ")+r.slice(s)||null}return!0})}),addLineWidget:bn(function(e,t,i){return _o(this,e,t,i)}),removeLineWidget:function removeLineWidget(e){e.clear()},markText:function markText(e,t,i){return qo(this,j(this,e),j(this,t),i,i&&i.type||"range")},setBookmark:function setBookmark(e,t){var i={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};e=j(this,e);return qo(this,e,e,i,"bookmark")},findMarksAt:function findMarksAt(e){e=j(this,e);var t=[],n=A(this,e.line).markedSpans;if(n){for(var o=0,r;o<n.length;++o){r=n[o];if((null==r.from||r.from<=e.ch)&&(null==r.to||r.to>=e.ch)){t.push(r.marker.parent||r.marker)}}}return t},findMarks:function findMarks(e,t,n){e=j(this,e);t=j(this,t);var o=[],r=e.line;this.iter(e.line,t.line+1,function(l){var s=l.markedSpans;if(s){for(var d=0,a;d<s.length;d++){a=s[d];if(!(null!=a.to&&r==e.line&&e.ch>=a.to||null==a.from&&r!=e.line||null!=a.from&&r==t.line&&a.from>=t.ch)&&(!n||n(a.marker))){o.push(a.marker.parent||a.marker)}}}++r});return o},getAllMarks:function getAllMarks(){var e=[];this.iter(function(t){var n=t.markedSpans;if(n){for(var o=0;o<n.length;++o){if(null!=n[o].from){e.push(n[o].marker)}}}});return e},posFromIndex:function posFromIndex(e){var t,i=this.first,n=this.lineSeparator().length;this.iter(function(o){var r=o.text.length+n;if(r>e){t=e;return!0}e-=r;++i});return j(this,z(i,t))},indexFromPos:function indexFromPos(e){e=j(this,e);var t=e.ch;if(e.line<this.first||0>e.ch){return 0}var i=this.lineSeparator().length;this.iter(this.first,e.line,function(e){t+=e.text.length+i});return t},copy:function copy(e){var t=new Fs(W(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);t.scrollTop=this.scrollTop;t.scrollLeft=this.scrollLeft;t.sel=this.sel;t.extend=!1;if(e){t.history.undoDepth=this.history.undoDepth;t.setHistory(this.getHistory())}return t},linkedDoc:function linkedDoc(e){if(!e){e={}}var t=this.first,i=this.first+this.size;if(null!=e.from&&e.from>t){t=e.from}if(null!=e.to&&e.to<i){i=e.to}var n=new Fs(W(this,t,i),e.mode||this.modeOption,t,this.lineSep,this.direction);if(e.sharedHist){n.history=this.history}(this.linked||(this.linked=[])).push({doc:n,sharedHist:e.sharedHist});n.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}];Jo(n,Qo(this));return n},unlinkDoc:function unlinkDoc(e){if(e instanceof Zr){e=e.doc}if(this.linked){for(var t=0,n;t<this.linked.length;++t){n=this.linked[t];if(n.doc!=e){continue}this.linked.splice(t,1);e.unlinkDoc(this);er(Qo(this));break}}if(e.history==this.history){var o=[e.id];eo(e,function(e){return o.push(e.id)},!0);e.history=new oo(null);e.history.done=yo(this.history.done,o);e.history.undone=yo(this.history.undone,o)}},iterLinkedDocs:function iterLinkedDocs(e){eo(this,e)},getMode:function(){return this.mode},getEditor:function getEditor(){return this.cm},splitLines:function splitLines(e){if(this.lineSep){return e.split(this.lineSep)}return is(e)},lineSeparator:function lineSeparator(){return this.lineSep||"\n"},setDirection:bn(function(e){if("rtl"!=e){e="ltr"}if(e==this.direction){return}this.direction=e;this.iter(function(e){return e.order=null});if(this.cm){no(this.cm)}})});Fs.prototype.eachLine=Fs.prototype.iter;var Ps=0;function tr(t){var e=this;or(e);if(We(e,t)||Et(e.display,t)){return}Pe(t);if(Cl){Ps=+new Date}var o=Ni(e,t,!0),r=t.dataTransfer.files;if(!o||e.isReadOnly()){return}if(r&&r.length&&window.FileReader&&window.File){for(var l=r.length,n=Array(l),s=0,d=function(t,r){if(e.options.allowDropFileTypes&&-1==g(e.options.allowDropFileTypes,t.type)){return}var i=new FileReader;i.onload=xn(e,function(){var t=i.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(t)){t=""}n[r]=t;if(++s==l){o=j(e.doc,o);var d={from:o,to:o,text:e.doc.splitLines(n.join(e.doc.lineSeparator())),origin:"paste"};Po(e.doc,d);Lo(e.doc,jn(o,Vn(d)))}});i.readAsText(t)},a=0;a<l;++a){d(r[a],a)}}else{if(e.state.draggingText&&-1<e.doc.sel.contains(o)){e.state.draggingText(t);setTimeout(function(){return e.display.input.focus()},20);return}try{var p=t.dataTransfer.getData("Text");if(p){var c;if(e.state.draggingText&&!e.state.draggingText.copy){c=e.listSelections()}To(e.doc,jn(o,o));if(c){for(var h=0;h<c.length;++h){Go(e.doc,"",c[h].anchor,c[h].head,"drag")}}e.replaceSelection(p,"around","paste");e.display.input.focus()}}catch(t){}}}function ir(t,i){if(Cl&&(!t.state.draggingText||100>+new Date-Ps)){Ee(i);return}if(We(t,i)||Et(t.display,i)){return}i.dataTransfer.setData("Text",t.getSelection());i.dataTransfer.effectAllowed="copyMove";if(i.dataTransfer.setDragImage&&!Tl){var e=o("img",null,null,"position: fixed; left: 0; top: 0;");e.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";if(kl){e.width=e.height=1;t.display.wrapper.appendChild(e);e._top=e.offsetTop}i.dataTransfer.setDragImage(e,0,0);if(kl){e.parentNode.removeChild(e)}}}function nr(t,i){var e=Ni(t,i);if(!e){return}var r=document.createDocumentFragment();Wi(t,e,r);if(!t.display.dragCursor){t.display.dragCursor=o("div",null,"CodeMirror-cursors CodeMirror-dragcursors");t.display.lineSpace.insertBefore(t.display.dragCursor,t.display.cursorDiv)}n(t.display.dragCursor,r)}function or(e){if(e.display.dragCursor){e.display.lineSpace.removeChild(e.display.dragCursor);e.display.dragCursor=null}}function rr(e){if(!document.getElementsByClassName){return}for(var t=document.getElementsByClassName("CodeMirror"),n=0,o;n<t.length;n++){o=t[n].CodeMirror;if(o){e(o)}}}var Is=!1;function lr(){if(Is){return}sr();Is=!0}function sr(){var e;es(window,"resize",function(){if(null==e){e=setTimeout(function(){e=null;rr(dr)},100)}});es(window,"blur",function(){return rr(Ei)})}function dr(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null;t.scrollbarsClipped=!1;e.setSize()}for(var zs={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},Es=0;10>Es;Es++){zs[Es+48]=zs[Es+96]=Es+""}for(var Rs=65;90>=Rs;Rs++){zs[Rs]=String.fromCharCode(Rs)}for(var Bs=1;12>=Bs;Bs++){zs[Bs+111]=zs[Bs+63235]="F"+Bs}var Gs={basic:{Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},pcDefault:{"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},emacsy:{"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},macDefault:{"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]}};Gs["default"]=Dl?Gs.macDefault:Gs.pcDefault;function ar(e){var t=e.split(/-(?!$)/);e=t[t.length-1];for(var n,o,r,l,s=0,d;s<t.length-1;s++){d=t[s];if(/^(cmd|meta|m)$/i.test(d)){l=!0}else if(/^a(lt)?$/i.test(d)){n=!0}else if(/^(c|ctrl|control)$/i.test(d)){o=!0}else if(/^s(hift)?$/i.test(d)){r=!0}else{throw new Error("Unrecognized modifier name: "+d)}}if(n){e="Alt-"+e}if(o){e="Ctrl-"+e}if(l){e="Cmd-"+e}if(r){e="Shift-"+e}return e}function pr(e){var t={};for(var n in e){if(e.hasOwnProperty(n)){var o=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n)){continue}if("..."==o){delete e[n];continue}for(var r=x(n.split(" "),ar),l=0;l<r.length;l++){var s=void 0,d=void 0;if(l==r.length-1){d=r.join(" ");s=o}else{d=r.slice(0,l+1).join(" ");s="..."}var a=t[d];if(!a){t[d]=s}else if(a!=s){throw new Error("Inconsistent bindings for "+d)}}delete e[n]}}for(var p in t){e[p]=t[p]}return e}function cr(e,t,n,o){t=fr(t);var r=t.call?t.call(e,o):t[e];if(!1===r){return"nothing"}if("..."===r){return"multi"}if(null!=r&&n(r)){return"handled"}if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough)){return cr(e,t.fallthrough,n,o)}for(var l=0,s;l<t.fallthrough.length;l++){s=cr(e,t.fallthrough[l],n,o);if(s){return s}}}}function hr(e){var t="string"==typeof e?e:zs[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t}function gr(e,t,i){var n=e;if(t.altKey&&"Alt"!=n){e="Alt-"+e}if((Il?t.metaKey:t.ctrlKey)&&"Ctrl"!=n){e="Ctrl-"+e}if((Il?t.ctrlKey:t.metaKey)&&"Cmd"!=n){e="Cmd-"+e}if(!i&&t.shiftKey&&"Shift"!=n){e="Shift-"+e}return e}function ur(e,t){if(kl&&34==e.keyCode&&e.char){return!1}var i=zs[e.keyCode];if(null==i||e.altGraphKey){return!1}if(3==e.keyCode&&e.code){i=e.code}return gr(i,e,t)}function fr(e){return"string"==typeof e?Gs[e]:e}function mr(e,t){for(var n=e.doc.sel.ranges,o=[],r=0,l;r<n.length;r++){l=t(n[r]);while(o.length&&0>=E(l.from,y(o).to)){var s=o.pop();if(0>E(s.from,l.from)){l.from=s.from;break}}o.push(l)}yn(e,function(){for(var t=o.length-1;0<=t;t--){Go(e.doc,"",o[t].from,o[t].to,"+delete")}_i(e)})}function yr(e,t,i){var n=T(e.text,t+i,i);return 0>n||n>e.text.length?null:n}function xr(e,t,i){var n=yr(e,t.ch,i);return null==n?null:new z(t.line,n,0>i?"after":"before")}function vr(e,t,i,n,o){if(e){var r=Ne(i,t.doc.direction);if(r){var l=0>o?y(r):r[0],s=0>o==(1==l.level),d=s?"after":"before",a;if(0<l.level||"rtl"==t.doc.direction){var p=qt(t,i);a=0>o?i.text.length-1:0;var c=Zt(t,p,a).top;a=N(function(e){return Zt(t,p,e).top==c},0>o==(1==l.level)?l.from:l.to-1,a);if("before"==d){a=yr(i,a,1)}}else{a=0>o?l.to:l.from}return new z(n,a,d)}}return new z(n,0>o?i.text.length:0,0>o?"before":"after")}function br(e,t,i,n){var o=Ne(t,e.doc.direction);if(!o){return xr(t,i,n)}if(i.ch>=t.text.length){i.ch=t.text.length;i.sticky="before"}else if(0>=i.ch){i.ch=0;i.sticky="after"}var r=Te(o,i.ch,i.sticky),l=o[r];if("ltr"==e.doc.direction&&0==l.level%2&&(0<n?l.to>i.ch:l.from<i.ch)){return xr(t,i,n)}var s=function(e,i){return yr(t,e instanceof z?e.ch:e,i)},d,a=function(i){if(!e.options.lineWrapping){return{begin:0,end:t.text.length}}d=d||qt(e,t);return mi(e,t,d,i)},p=a("before"==i.sticky?s(i,-1):i.ch);if("rtl"==e.doc.direction||1==l.level){var c=1==l.level==0>n,h=s(i,c?1:-1);if(null!=h&&(!c?h>=l.from&&h>=p.begin:h<=l.to&&h<=p.end)){var g=c?"before":"after";return new z(i.line,h,g)}}var u=function(e,t,n){var r=function(e,t){return t?new z(i.line,s(e,1),"before"):new z(i.line,e,"after")};for(;0<=e&&e<o.length;e+=t){var l=o[e],d=0<t==(1!=l.level),a=d?n.begin:s(n.end,-1);if(l.from<=a&&a<l.to){return r(a,d)}a=d?l.from:s(l.to,-1);if(n.begin<=a&&a<n.end){return r(a,d)}}},f=u(r+n,n,p);if(f){return f}var m=0<n?p.end:s(p.begin,-1);if(null!=m&&!(0<n&&m==t.text.length)){f=u(0<n?0:o.length-1,n,a(m));if(f){return f}}return null}var $s={selectAll:Ho,singleSelection:function singleSelection(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Ul)},killLine:function killLine(e){return mr(e,function(t){if(t.empty()){var i=A(e.doc,t.head.line).text.length;if(t.head.ch==i&&t.head.line<e.lastLine()){return{from:t.head,to:z(t.head.line+1,0)}}else{return{from:t.head,to:z(t.head.line,i)}}}else{return{from:t.from(),to:t.to()}}})},deleteLine:function deleteLine(e){return mr(e,function(t){return{from:z(t.from().line,0),to:j(e.doc,z(t.to().line+1,0))}})},delLineLeft:function delLineLeft(e){return mr(e,function(e){return{from:z(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function delWrappedLineLeft(e){return mr(e,function(t){var i=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:i},"div");return{from:n,to:t.from()}})},delWrappedLineRight:function delWrappedLineRight(e){return mr(e,function(t){var i=e.charCoords(t.head,"div").top+5,n=e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div");return{from:t.from(),to:n}})},undo:function undo(e){return e.undo()},redo:function redo(e){return e.redo()},undoSelection:function undoSelection(e){return e.undoSelection()},redoSelection:function redoSelection(e){return e.redoSelection()},goDocStart:function goDocStart(e){return e.extendSelection(z(e.firstLine(),0))},goDocEnd:function goDocEnd(e){return e.extendSelection(z(e.lastLine()))},goLineStart:function goLineStart(e){return e.extendSelectionsBy(function(t){return Cr(e,t.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function goLineStartSmart(e){return e.extendSelectionsBy(function(t){return Sr(e,t.head)},{origin:"+move",bias:1})},goLineEnd:function goLineEnd(e){return e.extendSelectionsBy(function(t){return wr(e,t.head.line)},{origin:"+move",bias:-1})},goLineRight:function goLineRight(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:e.display.lineDiv.offsetWidth+100,top:i},"div")},Vl)},goLineLeft:function goLineLeft(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5;return e.coordsChar({left:0,top:i},"div")},Vl)},goLineLeftSmart:function goLineLeftSmart(e){return e.extendSelectionsBy(function(t){var i=e.cursorCoords(t.head,"div").top+5,n=e.coordsChar({left:0,top:i},"div");if(n.ch<e.getLine(n.line).search(/\S/)){return Sr(e,t.head)}return n},Vl)},goLineUp:function goLineUp(e){return e.moveV(-1,"line")},goLineDown:function goLineDown(e){return e.moveV(1,"line")},goPageUp:function goPageUp(e){return e.moveV(-1,"page")},goPageDown:function goPageDown(e){return e.moveV(1,"page")},goCharLeft:function goCharLeft(e){return e.moveH(-1,"char")},goCharRight:function goCharRight(e){return e.moveH(1,"char")},goColumnLeft:function goColumnLeft(e){return e.moveH(-1,"column")},goColumnRight:function goColumnRight(e){return e.moveH(1,"column")},goWordLeft:function goWordLeft(e){return e.moveH(-1,"word")},goGroupRight:function goGroupRight(e){return e.moveH(1,"group")},goGroupLeft:function goGroupLeft(e){return e.moveH(-1,"group")},goWordRight:function goWordRight(e){return e.moveH(1,"word")},delCharBefore:function delCharBefore(e){return e.deleteH(-1,"char")},delCharAfter:function delCharAfter(e){return e.deleteH(1,"char")},delWordBefore:function delWordBefore(e){return e.deleteH(-1,"word")},delWordAfter:function delWordAfter(e){return e.deleteH(1,"word")},delGroupBefore:function delGroupBefore(e){return e.deleteH(-1,"group")},delGroupAfter:function delGroupAfter(e){return e.deleteH(1,"group")},indentAuto:function indentAuto(e){return e.indentSelection("smart")},indentMore:function indentMore(e){return e.indentSelection("add")},indentLess:function indentLess(e){return e.indentSelection("subtract")},insertTab:function insertTab(e){return e.replaceSelection("\t")},insertSoftTab:function insertSoftTab(e){for(var t=[],n=e.listSelections(),o=e.options.tabSize,r=0;r<n.length;r++){var l=n[r].from(),s=h(e.getLine(l.line),l.ch,o);t.push(f(o-s%o))}e.replaceSelections(t)},defaultTab:function defaultTab(e){if(e.somethingSelected()){e.indentSelection("add")}else{e.execCommand("insertTab")}},transposeChars:function transposeChars(e){return yn(e,function(){for(var t=e.listSelections(),n=[],o=0;o<t.length;o++){if(!t[o].empty()){continue}var r=t[o].head,l=A(e.doc,r.line).text;if(l){if(r.ch==l.length){r=new z(r.line,r.ch-1)}if(0<r.ch){r=new z(r.line,r.ch+1);e.replaceRange(l.charAt(r.ch-1)+l.charAt(r.ch-2),z(r.line,r.ch-2),r,"+transpose")}else if(r.line>e.doc.first){var s=A(e.doc,r.line-1).text;if(s){r=new z(r.line,1);e.replaceRange(l.charAt(0)+e.doc.lineSeparator()+s.charAt(s.length-1),z(r.line-1,s.length-1),r,"+transpose")}}}n.push(new Os(r,r))}e.setSelections(n)})},newlineAndIndent:function newlineAndIndent(e){return yn(e,function(){for(var t=e.listSelections(),n=t.length-1;0<=n;n--){e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input")}t=e.listSelections();for(var o=0;o<t.length;o++){e.indentLine(t[o].from().line,null,!0)}_i(e)})},openLine:function openLine(e){return e.replaceSelection("\n","start")},toggleOverwrite:function toggleOverwrite(e){return e.toggleOverwrite()}};function Cr(e,t){var i=A(e.doc,t),n=fe(i);if(n!=i){t=H(n)}return vr(!0,e,n,t,1)}function wr(e,t){var i=A(e.doc,t),n=me(i);if(n!=i){t=H(n)}return vr(!0,e,i,t,-1)}function Sr(e,t){var i=Cr(e,t.line),n=A(e.doc,i.line),o=Ne(n,e.doc.direction);if(!o||0==o[0].level){var r=Math.max(0,n.text.search(/\S/)),l=t.line==i.line&&t.ch<=r&&t.ch;return z(i.line,l?0:r,i.sticky)}return i}function Lr(e,t,i){if("string"==typeof t){t=$s[t];if(!t){return!1}}e.display.input.ensurePolled();var n=e.display.shift,o=!1;try{if(e.isReadOnly()){e.state.suppressEdits=!0}if(i){e.display.shift=!1}o=t(e)!=$l}finally{e.display.shift=n;e.state.suppressEdits=!1}return o}function kr(e,t,n){for(var o=0,r;o<e.state.keyMaps.length;o++){r=cr(t,e.state.keyMaps[o],n,e);if(r){return r}}return e.options.extraKeys&&cr(t,e.options.extraKeys,n,e)||cr(t,e.options.keyMap,n,e)}var Us=new Gl;function Tr(t,i,n,e){var o=t.state.keySeq;if(o){if(hr(i)){return"handled"}if(/\'$/.test(i)){t.state.keySeq=null}else{Us.set(50,function(){if(t.state.keySeq==o){t.state.keySeq=null;t.display.input.reset()}})}if(Nr(t,o+" "+i,n,e)){return!0}}return Nr(t,i,n,e)}function Nr(t,i,n,e){var o=kr(t,i,e);if("multi"==o){t.state.keySeq=i}if("handled"==o){St(t,"keyHandled",t,i,n)}if("handled"==o||"multi"==o){Pe(n);Fi(t)}return!!o}function Or(t,i){var e=ur(i,!0);if(!e){return!1}if(i.shiftKey&&!t.state.keySeq){return Tr(t,"Shift-"+e,i,function(e){return Lr(t,e,!0)})||Tr(t,e,i,function(e){if("string"==typeof e?/^go[A-Z]/.test(e):e.motion){return Lr(t,e)}})}else{return Tr(t,e,i,function(e){return Lr(t,e)})}}function Ar(t,i,e){return Tr(t,"'"+e+"'",i,function(e){return Lr(t,e,!0)})}var js=null;function Mr(t){var e=this;e.curOp.focus=s();if(We(e,t)){return}if(Cl&&11>ie&&27==t.keyCode){t.returnValue=!1}var i=t.keyCode;e.display.shift=16==i||t.shiftKey;var n=Or(e,t);if(kl){js=n?i:null;if(!n&&88==i&&!os&&(Dl?t.metaKey:t.ctrlKey)){e.replaceSelection("",null,"cut")}}if(18==i&&!/\bCodeMirror-crosshair\b/.test(e.display.lineDiv.className)){Wr(e)}}function Wr(e){var i=e.display.lineDiv;d(i,"CodeMirror-crosshair");function t(n){if(18==n.keyCode||!n.altKey){El(i,"CodeMirror-crosshair");Ae(document,"keyup",t);Ae(document,"mouseover",t)}}es(document,"keyup",t);es(document,"mouseover",t)}function Dr(t){if(16==t.keyCode){this.doc.sel.shift=!1}We(this,t)}function Hr(t){var e=this;if(Et(e.display,t)||We(e,t)||t.ctrlKey&&!t.altKey||Dl&&t.metaKey){return}var i=t.keyCode,n=t.charCode;if(kl&&i==js){js=null;Pe(t);return}if(kl&&(!t.which||10>t.which)&&Or(e,t)){return}var o=String.fromCharCode(null==n?i:n);if("\b"==o){return}if(Ar(e,t,o)){return}e.display.input.onKeyPress(t)}var Vs=function(e,t,i){this.time=e;this.pos=t;this.button=i};Vs.prototype.compare=function(e,t,i){return this.time+400>e&&0==E(t,this.pos)&&i==this.button};var Ks,Xs;function Fr(e,t){var i=+new Date;if(Xs&&Xs.compare(i,e,t)){Ks=Xs=null;return"triple"}else if(Ks&&Ks.compare(i,e,t)){Xs=new Vs(i,e,t);Ks=null;return"double"}else{Ks=new Vs(i,e,t);Xs=null;return"single"}}function Pr(t){var e=this,i=e.display;if(We(e,t)||i.activeTouch&&i.input.supportsTouch()){return}i.input.ensurePolled();i.shift=t.shiftKey;if(Et(i,t)){if(!wl){i.scroller.draggable=!1;setTimeout(function(){return i.scroller.draggable=!0},100)}return}if(jr(e,t)){return}var n=Ni(e,t),o=Be(t),r=n?Fr(n,o):"single";window.focus();if(1==o&&e.state.selectingText){e.state.selectingText(t)}if(n&&Ir(e,o,n,r,t)){return}if(1==o){if(n){Er(e,n,r,t)}else if(Re(t)==i.scroller){Pe(t)}}else if(2==o){if(n){vo(e.doc,n)}setTimeout(function(){return i.input.focus()},20)}else if(3==o){if(zl){e.display.input.onContextMenu(t)}else{Ii(e)}}}function Ir(e,t,i,n,o){var r="Click";if("double"==n){r="Double"+r}else if("triple"==n){r="Triple"+r}r=(1==t?"Left":2==t?"Middle":"Right")+r;return Tr(e,gr(r,o),o,function(t){if("string"==typeof t){t=$s[t]}if(!t){return!1}var n=!1;try{if(e.isReadOnly()){e.state.suppressEdits=!0}n=t(e,i)!=$l}finally{e.state.suppressEdits=!1}return n})}function zr(e,t,i){var n=e.getOption("configureMouse"),o=n?n(e,t,i):{};if(null==o.unit){var r=Hl?i.shiftKey&&i.metaKey:i.altKey;o.unit=r?"rectangle":"single"==t?"char":"double"==t?"word":"line"}if(null==o.extend||e.doc.extend){o.extend=e.doc.extend||i.shiftKey}if(null==o.addNew){o.addNew=Dl?i.metaKey:i.ctrlKey}if(null==o.moveOnDrag){o.moveOnDrag=!(Dl?i.altKey:i.ctrlKey)}return o}function Er(e,t,i,n){if(Cl){setTimeout(p(Pi,e),0)}else{e.curOp.focus=s()}var o=zr(e,i,n),r=e.doc.sel,l;if(e.options.dragDrop&&m&&!e.isReadOnly()&&"single"==i&&-1<(l=r.contains(t))&&(0>E((l=r.ranges[l]).from(),t)||0<t.xRel)&&(0<E(l.to(),t)||0>t.xRel)){Rr(e,n,t,o)}else{Gr(e,n,t,o)}}function Rr(t,e,i,n){var o=t.display,r=!1,l=xn(t,function(a){if(wl){o.scroller.draggable=!1}t.state.draggingText=!1;Ae(o.wrapper.ownerDocument,"mouseup",l);Ae(o.wrapper.ownerDocument,"mousemove",s);Ae(o.scroller,"dragstart",d);Ae(o.scroller,"drop",l);if(!r){Pe(a);if(!n.addNew){vo(t.doc,i,null,null,n.extend)}if(wl||Cl&&9==ie){setTimeout(function(){o.wrapper.ownerDocument.body.focus();o.input.focus()},20)}else{o.input.focus()}}}),s=function(t){r=r||10<=Math.abs(e.clientX-t.clientX)+Math.abs(e.clientY-t.clientY)},d=function(){return r=!0};if(wl){o.scroller.draggable=!0}t.state.draggingText=l;l.copy=!n.moveOnDrag;if(o.scroller.dragDrop){o.scroller.dragDrop()}es(o.wrapper.ownerDocument,"mouseup",l);es(o.wrapper.ownerDocument,"mousemove",s);es(o.scroller,"dragstart",d);es(o.scroller,"drop",l);Ii(t);setTimeout(function(){return o.input.focus()},20)}function Br(e,t,i){if("char"==i){return new Os(t,t)}if("word"==i){return e.findWordAt(t)}if("line"==i){return new Os(z(t.line,0),j(e.doc,z(t.line+1,0)))}var n=i(e,t);return new Os(n.from,n.to)}function Gr(t,e,i,n){var d=t.display,a=t.doc;Pe(e);var p,c,g=a.sel,f=g.ranges;if(n.addNew&&!n.extend){c=a.sel.contains(i);if(-1<c){p=f[c]}else{p=new Os(i,i)}}else{p=a.sel.primary();c=a.sel.primIndex}if("rectangle"==n.unit){if(!n.addNew){p=new Os(i,i)}i=Ni(t,e,!0,!0);c=-1}else{var m=Br(t,i,n.unit);if(n.extend){p=xo(p,m.anchor,m.head,n.extend)}else{p=m}}if(!n.addNew){c=0;ko(a,new Ns([p],0),jl);g=a.sel}else if(-1==c){c=f.length;ko(a,Un(t,f.concat([p]),c),{scroll:!1,origin:"*mouse"})}else if(1<f.length&&f[c].empty()&&"char"==n.unit&&!n.extend){ko(a,Un(t,f.slice(0,c).concat(f.slice(c+1)),0),{scroll:!1,origin:"*mouse"});g=a.sel}else{Co(a,c,p,jl)}var y=i;function o(e){if(0==E(y,e)){return}y=e;if("rectangle"==n.unit){for(var o=[],r=t.options.tabSize,l=h(A(a,i.line).text,i.ch,r),s=h(A(a,e.line).text,e.ch,r),d=Math.min(l,s),f=Math.max(l,s),m=Math.min(i.line,e.line),x=Math.min(t.lastLine(),Math.max(i.line,e.line));m<=x;m++){var v=A(a,m).text,b=u(v,d,r);if(d==f){o.push(new Os(z(m,b),z(m,b)))}else if(v.length>b){o.push(new Os(z(m,b),z(m,u(v,f,r))))}}if(!o.length){o.push(new Os(i,i))}ko(a,Un(t,g.ranges.slice(0,c).concat(o),c),{origin:"*mouse",scroll:!1});t.scrollIntoView(e)}else{var C=p,w=Br(t,e,n.unit),S=C.anchor,L;if(0<E(w.anchor,S)){L=w.head;S=$(C.from(),w.anchor)}else{L=w.anchor;S=G(C.to(),w.head)}var k=g.ranges.slice(0);k[c]=$r(t,new Os(j(a,S),L));ko(a,Un(t,k,c),jl)}}var x=d.wrapper.getBoundingClientRect(),v=0;function r(i){var e=++v,l=Ni(t,i,!0,"rectangle"==n.unit);if(!l){return}if(0!=E(l,y)){t.curOp.focus=s();o(l);var p=Gi(d,a);if(l.line>=p.to||l.line<p.from){setTimeout(xn(t,function(){if(v==e){r(i)}}),150)}}else{var c=i.clientY<x.top?-20:i.clientY>x.bottom?20:0;if(c){setTimeout(xn(t,function(){if(v!=e){return}d.scroller.scrollTop+=c;r(i)}),50)}}}function l(i){t.state.selectingText=!1;v=1/0;Pe(i);d.input.focus();Ae(d.wrapper.ownerDocument,"mousemove",b);Ae(d.wrapper.ownerDocument,"mouseup",C);a.history.lastSelOrigin=null}var b=xn(t,function(t){if(0===t.buttons||!Be(t)){l(t)}else{r(t)}}),C=xn(t,l);t.state.selectingText=C;es(d.wrapper.ownerDocument,"mousemove",b);es(d.wrapper.ownerDocument,"mouseup",C)}function $r(e,t){var i=t.anchor,n=t.head,o=A(e.doc,i.line);if(0==E(i,n)&&i.sticky==n.sticky){return t}var r=Ne(o);if(!r){return t}var l=Te(r,i.ch,i.sticky),s=r[l];if(s.from!=i.ch&&s.to!=i.ch){return t}var d=l+(s.from==i.ch==(1!=s.level)?0:1);if(0==d||d==r.length){return t}var a;if(n.line!=i.line){a=0<(n.line-i.line)*("ltr"==e.doc.direction?1:-1)}else{var p=Te(r,n.ch,n.sticky),c=p-l||(n.ch-i.ch)*(1==s.level?-1:1);if(p==d-1||p==d){a=0>c}else{a=0<c}}var h=r[d+(a?-1:0)],g=a==(1==h.level),u=g?h.from:h.to,f=g?"after":"before";return i.ch==u&&i.sticky==f?t:new Os(new z(i.line,u,f),n)}function Ur(t,n,e,o){var r,l;if(n.touches){r=n.touches[0].clientX;l=n.touches[0].clientY}else{try{r=n.clientX;l=n.clientY}catch(t){return!1}}if(r>=Math.floor(t.display.gutters.getBoundingClientRect().right)){return!1}if(o){Pe(n)}var s=t.display,d=s.lineDiv.getBoundingClientRect();if(l>d.bottom||!He(t,e)){return ze(n)}l-=d.top-s.viewOffset;for(var a=0,p;a<t.options.gutters.length;++a){p=s.gutters.childNodes[a];if(p&&p.getBoundingClientRect().right>=r){var c=F(t.doc,l),h=t.options.gutters[a];Me(t,e,t,c,h,n);return ze(n)}}}function jr(t,i){return Ur(t,i,"gutterClick",!0)}function Vr(t,i){if(Et(t.display,i)||Kr(t,i)){return}if(We(t,i,"contextmenu")){return}if(!zl){t.display.input.onContextMenu(i)}}function Kr(t,i){if(!He(t,"gutterContextMenu")){return!1}return Ur(t,i,"gutterContextMenu",!1)}function Xr(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-");oi(e)}var Ys={toString:function toString(){return"CodeMirror.Init"}},_s={},qs={};function Yr(e){En(e);Cn(e);$i(e)}function _r(e,t,i){if(!t!=!(i&&i!=Ys)){var n=e.display.dragFunctions,o=t?es:Ae;o(e.display.scroller,"dragstart",n.start);o(e.display.scroller,"dragenter",n.enter);o(e.display.scroller,"dragover",n.over);o(e.display.scroller,"dragleave",n.leave);o(e.display.scroller,"drop",n.drop)}}function qr(e){if(e.options.lineWrapping){d(e.display.wrapper,"CodeMirror-wrap");e.display.sizer.style.minWidth="";e.display.sizerWidth=null}else{El(e.display.wrapper,"CodeMirror-wrap");Le(e)}Ti(e);Cn(e);oi(e);setTimeout(function(){return ln(e)},100)}function Zr(e,t){var n=this;if(!(this instanceof Zr)){return new Zr(e,t)}this.options=t=t?c(t):{};c(_s,t,!1);Rn(t);var o=t.value;if("string"==typeof o){o=new Fs(o,t.mode,null,t.lineSeparator,t.direction)}else if(t.mode){o.modeOption=t.mode}this.doc=o;var r=new Zr.inputStyles[t.inputStyle](this),l=this.display=new O(e,o,r);l.wrapper.CodeMirror=this;En(this);Xr(this);if(t.lineWrapping){this.display.wrapper.className+=" CodeMirror-wrap"}dn(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 Gl,keySeq:null,specialChars:null};if(t.autofocus&&!Wl){l.input.focus()}if(Cl&&11>ie){setTimeout(function(){return n.display.input.reset(!0)},20)}Qr(this);lr();an(this);this.curOp.forceUpdate=!0;to(this,o);if(t.autofocus&&!Wl||this.hasFocus()){setTimeout(p(zi,this),20)}else{Ei(this)}for(var s in qs){if(qs.hasOwnProperty(s)){qs[s](this,t[s],Ys)}}Ui(this);if(t.finishInit){t.finishInit(this)}for(var d=0;d<Zs.length;++d){Zs[d](this)}pn(this);if(wl&&t.lineWrapping&&"optimizelegibility"==getComputedStyle(l.lineDiv).textRendering){l.lineDiv.style.textRendering="auto"}}Zr.defaults=_s;Zr.optionHandlers=qs;function Qr(t){var r=t.display;es(r.scroller,"mousedown",xn(t,Pr));if(Cl&&11>ie){es(r.scroller,"dblclick",xn(t,function(i){if(We(t,i)){return}var e=Ni(t,i);if(!e||jr(t,i)||Et(t.display,i)){return}Pe(i);var n=t.findWordAt(e);vo(t.doc,n.anchor,n.head)}))}else{es(r.scroller,"dblclick",function(i){return We(t,i)||Pe(i)})}es(r.scroller,"contextmenu",function(i){return Vr(t,i)});var l,s={end:0};function i(){if(r.activeTouch){l=setTimeout(function(){return r.activeTouch=null},1e3);s=r.activeTouch;s.end=+new Date}}function n(t){if(1!=t.touches.length){return!1}var e=t.touches[0];return 1>=e.radiusX&&1>=e.radiusY}function o(e,t){if(null==t.left){return!0}var i=t.left-e.left,n=t.top-e.top;return i*i+n*n>400}es(r.scroller,"touchstart",function(i){if(!We(t,i)&&!n(i)&&!jr(t,i)){r.input.ensurePolled();clearTimeout(l);var e=+new Date;r.activeTouch={start:e,moved:!1,prev:300>=e-s.end?s:null};if(1==i.touches.length){r.activeTouch.left=i.touches[0].pageX;r.activeTouch.top=i.touches[0].pageY}}});es(r.scroller,"touchmove",function(){if(r.activeTouch){r.activeTouch.moved=!0}});es(r.scroller,"touchend",function(n){var e=r.activeTouch;if(e&&!Et(r,n)&&null!=e.left&&!e.moved&&300>new Date-e.start){var l=t.coordsChar(r.activeTouch,"page"),s;if(!e.prev||o(e,e.prev)){s=new Os(l,l)}else if(!e.prev.prev||o(e,e.prev.prev)){s=t.findWordAt(l)}else{s=new Os(z(l.line,0),j(t.doc,z(l.line+1,0)))}t.setSelection(s.anchor,s.head);t.focus();Pe(n)}i()});es(r.scroller,"touchcancel",i);es(r.scroller,"scroll",function(){if(r.scroller.clientHeight){en(t,r.scroller.scrollTop);nn(t,r.scroller.scrollLeft,!0);Me(t,"scroll",t)}});es(r.scroller,"mousewheel",function(i){return $n(t,i)});es(r.scroller,"DOMMouseScroll",function(i){return $n(t,i)});es(r.wrapper,"scroll",function(){return r.wrapper.scrollTop=r.wrapper.scrollLeft=0});r.dragFunctions={enter:function enter(i){if(!We(t,i)){Ee(i)}},over:function over(i){if(!We(t,i)){nr(t,i);Ee(i)}},start:function start(i){return ir(t,i)},drop:xn(t,tr),leave:function leave(i){if(!We(t,i)){or(t)}}};var d=r.input.getField();es(d,"keyup",function(i){return Dr.call(t,i)});es(d,"keydown",xn(t,Mr));es(d,"keypress",xn(t,Hr));es(d,"focus",function(i){return zi(t,i)});es(d,"blur",function(i){return Ei(t,i)})}var Zs=[];Zr.defineInitHook=function(e){return Zs.push(e)};function Jr(e,t,n,o){var r=e.doc,l;if(null==n){n="add"}if("smart"==n){if(!r.mode.indent){n="prev"}else{l=Je(e,t).state}}var s=e.options.tabSize,d=A(r,t),a=h(d.text,null,s);if(d.stateAfter){d.stateAfter=null}var p=d.text.match(/^\s*/)[0],c;if(!o&&!/\S/.test(d.text)){c=0;n="not"}else if("smart"==n){c=r.mode.indent(l,d.text.slice(p.length),d.text);if(c==$l||150<c){if(!o){return}n="prev"}}if("prev"==n){if(t>r.first){c=h(A(r,t-1).text,null,s)}else{c=0}}else if("add"==n){c=a+e.options.indentUnit}else if("subtract"==n){c=a-e.options.indentUnit}else if("number"==typeof n){c=a+n}c=Math.max(0,c);var g="",u=0;if(e.options.indentWithTabs){for(var m=Math.floor(c/s);m;--m){u+=s;g+="\t"}}if(u<c){g+=f(c-u)}if(g!=p){Go(r,g,z(t,0),z(t,p.length),"+input");d.stateAfter=null;return!0}else{for(var y=0,x;y<r.sel.ranges.length;y++){x=r.sel.ranges[y];if(x.head.line==t&&x.head.ch<p.length){var v=z(t,p.length);Co(r,y,new Os(v,v));break}}}}var Qs=null;function el(e){Qs=e}function tl(e,t,n,o,r){var l=e.doc;e.display.shift=!1;if(!o){o=l.sel}var s=e.state.pasteIncoming||"paste"==r,d=is(t),a=null;if(s&&1<o.ranges.length){if(Qs&&Qs.text.join("\n")==t){if(0==o.ranges.length%Qs.text.length){a=[];for(var p=0;p<Qs.text.length;p++){a.push(l.splitLines(Qs.text[p]))}}}else if(d.length==o.ranges.length&&e.options.pasteLinesPerSelection){a=x(d,function(e){return[e]})}}for(var c,h=o.ranges.length-1;0<=h;h--){var g=o.ranges[h],u=g.from(),f=g.to();if(g.empty()){if(n&&0<n){u=z(u.line,u.ch-n)}else if(e.state.overwrite&&!s){f=z(f.line,Math.min(A(l,f.line).text.length,f.ch+y(d).length))}else if(s&&Qs&&Qs.lineWise&&Qs.text.join("\n")==t){u=f=z(u.line,0)}}c=e.curOp.updateInput;var m={from:u,to:f,text:a?a[h%a.length]:d,origin:r||(s?"paste":e.state.cutIncoming?"cut":"+input")};Po(e.doc,m);St(e,"inputRead",e,m)}if(t&&!s){nl(e,t)}_i(e);e.curOp.updateInput=c;e.curOp.typing=!0;e.state.pasteIncoming=e.state.cutIncoming=!1}function il(t,e){var i=t.clipboardData&&t.clipboardData.getData("Text");if(i){t.preventDefault();if(!e.isReadOnly()&&!e.options.disableInput){yn(e,function(){return tl(e,i,0,null,"paste")})}return!0}}function nl(e,t){if(!e.options.electricChars||!e.options.smartIndent){return}for(var n=e.doc.sel,o=n.ranges.length-1,r;0<=o;o--){r=n.ranges[o];if(100<r.head.ch||o&&n.ranges[o-1].head.line==r.head.line){continue}var l=e.getModeAt(r.head),s=!1;if(l.electricChars){for(var d=0;d<l.electricChars.length;d++){if(-1<t.indexOf(l.electricChars.charAt(d))){s=Jr(e,r.head.line,"smart");break}}}else if(l.electricInput){if(l.electricInput.test(A(e.doc,r.head.line).text.slice(0,r.head.ch))){s=Jr(e,r.head.line,"smart")}}if(s){St(e,"electricInput",e,r.head.line)}}}function ol(e){for(var t=[],n=[],o=0;o<e.doc.sel.ranges.length;o++){var r=e.doc.sel.ranges[o].head.line,l={anchor:z(r,0),head:z(r+1,0)};n.push(l);t.push(e.getRange(l.anchor,l.head))}return{text:t,ranges:n}}function rl(e,t){e.setAttribute("autocorrect","off");e.setAttribute("autocapitalize","off");e.setAttribute("spellcheck",!!t)}function ll(){var e=o("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),t=o("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");if(wl){e.style.width="1000px"}else{e.setAttribute("wrap","off")}if(Al){e.style.border="1px solid black"}rl(e);return t}function sl(e,t,i,n,o){var s=t,d=i,a=A(e,t.line);function r(){var n=t.line+i;if(n<e.first||n>=e.first+e.size){return!1}t=new z(n,t.ch,t.sticky);return a=A(e,n)}function l(n){var l;if(o){l=br(e.cm,a,t,i)}else{l=xr(a,t,i)}if(null==l){if(!n&&r()){t=vr(o,e.cm,a,t.line,i)}else{return!1}}else{t=l}return!0}if("char"==n){l()}else if("column"==n){l(!0)}else if("word"==n||"group"==n){for(var p=null,c="group"==n,h=e.cm&&e.cm.getHelper(t,"wordChars"),g=!0;;g=!1){if(0>i&&!l(!g)){break}var u=a.text.charAt(t.ch)||"\n",f=S(u,h)?"w":c&&"\n"==u?"n":!c||/\s/.test(u)?null:"p";if(c&&!g&&!f){f="s"}if(p&&p!=f){if(0>i){i=1;l();t.sticky="after"}break}if(f){p=f}if(0<i&&!l(!g)){break}}}var m=Wo(e,t,s,d,!0);if(R(s,m)){m.hitSide=!0}return m}function dl(e,t,i,n){var o=e.doc,r=t.left,l;if("page"==n){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),d=Math.max(s-.5*Ci(e.display),3);l=(0<i?t.bottom:t.top)+i*d}else if("line"==n){l=0<i?t.bottom+3:t.top-3}var a;for(;;){a=ui(e,r,l);if(!a.outside){break}if(0>i?0>=l:l>=o.height){a.hitSide=!0;break}l+=5*i}return a}var Js=function(e){this.cm=e;this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null;this.polling=new Gl;this.composing=null;this.gracePeriod=!1;this.readDOMTimeout=null};Js.prototype.init=function(e){var i=this,n=this,o=n.cm,r=n.div=e.lineDiv;rl(r,o.options.spellcheck);es(r,"paste",function(t){if(We(o,t)||il(t,o)){return}if(11>=ie){setTimeout(xn(o,function(){return i.updateFromDOM()}),20)}});es(r,"compositionstart",function(t){i.composing={data:t.data,done:!1}});es(r,"compositionupdate",function(t){if(!i.composing){i.composing={data:t.data,done:!1}}});es(r,"compositionend",function(t){if(i.composing){if(t.data!=i.composing.data){i.readFromDOMSoon()}i.composing.done=!0}});es(r,"touchstart",function(){return n.forceCompositionEnd()});es(r,"input",function(){if(!i.composing){i.readFromDOMSoon()}});function t(t){if(We(o,t)){return}if(o.somethingSelected()){el({lineWise:!1,text:o.getSelections()});if("cut"==t.type){o.replaceSelection("",null,"cut")}}else if(!o.options.lineWiseCopyCut){return}else{var e=ol(o);el({lineWise:!0,text:e.text});if("cut"==t.type){o.operation(function(){o.setSelections(e.ranges,0,Ul);o.replaceSelection("",null,"cut")})}}if(t.clipboardData){t.clipboardData.clearData();var i=Qs.text.join("\n");t.clipboardData.setData("Text",i);if(t.clipboardData.getData("Text")==i){t.preventDefault();return}}var l=ll(),s=l.firstChild;o.display.lineSpace.insertBefore(l,o.display.lineSpace.firstChild);s.value=Qs.text.join("\n");var d=document.activeElement;Bl(s);setTimeout(function(){o.display.lineSpace.removeChild(l);d.focus();if(d==r){n.showPrimarySelection()}},50)}es(r,"copy",t);es(r,"cut",t)};Js.prototype.prepareSelection=function(){var e=Mi(this.cm,!1);e.focus=this.cm.state.focused;return e};Js.prototype.showSelection=function(e,t){if(!e||!this.cm.display.view.length){return}if(e.focus||t){this.showPrimarySelection()}this.showMultipleSelections(e)};Js.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()};Js.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,i=t.doc.sel.primary(),n=i.from(),o=i.to();if(t.display.viewTo==t.display.viewFrom||n.line>=t.display.viewTo||o.line<t.display.viewFrom){e.removeAllRanges();return}var r=gl(t,e.anchorNode,e.anchorOffset),l=gl(t,e.focusNode,e.focusOffset);if(r&&!r.bad&&l&&!l.bad&&0==E($(r,l),n)&&0==E(G(r,l),o)){return}var s=t.display.view,d=n.line>=t.display.viewFrom&&al(t,n)||{node:s[0].measure.map[2],offset:0},a=o.line<t.display.viewTo&&al(t,o);if(!a){var p=s[s.length-1].measure,c=p.maps?p.maps[p.maps.length-1]:p.map;a={node:c[c.length-1],offset:c[c.length-2]-c[c.length-3]}}if(!d||!a){e.removeAllRanges();return}var h=e.rangeCount&&e.getRangeAt(0),g;try{g=Rl(d.node,d.offset,a.offset,a.node)}catch(t){}if(g){if(!yl&&t.state.focused){e.collapse(d.node,d.offset);if(!g.collapsed){e.removeAllRanges();e.addRange(g)}}else{e.removeAllRanges();e.addRange(g)}if(h&&null==e.anchorNode){e.addRange(h)}else if(yl){this.startGracePeriod()}}this.rememberSelection()};Js.prototype.startGracePeriod=function(){var e=this;clearTimeout(this.gracePeriod);this.gracePeriod=setTimeout(function(){e.gracePeriod=!1;if(e.selectionChanged()){e.cm.operation(function(){return e.cm.curOp.selectionChanged=!0})}},20)};Js.prototype.showMultipleSelections=function(e){n(this.cm.display.cursorDiv,e.cursors);n(this.cm.display.selectionDiv,e.selection)};Js.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode;this.lastAnchorOffset=e.anchorOffset;this.lastFocusNode=e.focusNode;this.lastFocusOffset=e.focusOffset};Js.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount){return!1}var t=e.getRangeAt(0).commonAncestorContainer;return l(this.div,t)};Js.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly){if(!this.selectionInEditor()){this.showSelection(this.prepareSelection(),!0)}this.div.focus()}};Js.prototype.blur=function(){this.div.blur()};Js.prototype.getField=function(){return this.div};Js.prototype.supportsTouch=function(){return!0};Js.prototype.receivedFocus=function(){var t=this;if(this.selectionInEditor()){this.pollSelection()}else{yn(this.cm,function(){return t.cm.curOp.selectionChanged=!0})}function e(){if(t.cm.state.focused){t.pollSelection();t.polling.set(t.cm.options.pollInterval,e)}}this.polling.set(this.cm.options.pollInterval,e)};Js.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset};Js.prototype.pollSelection=function(){if(null!=this.readDOMTimeout||this.gracePeriod||!this.selectionChanged()){return}var e=this.getSelection(),t=this.cm;if(Ml&&Ll&&this.cm.options.gutters.length&&pl(e.anchorNode)){this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs});this.blur();this.focus();return}if(this.composing){return}this.rememberSelection();var i=gl(t,e.anchorNode,e.anchorOffset),n=gl(t,e.focusNode,e.focusOffset);if(i&&n){yn(t,function(){ko(t.doc,jn(i,n),Ul);if(i.bad||n.bad){t.curOp.selectionChanged=!0}})}};Js.prototype.pollContent=function(){if(null!=this.readDOMTimeout){clearTimeout(this.readDOMTimeout);this.readDOMTimeout=null}var e=this.cm,t=e.display,i=e.doc.sel.primary(),n=i.from(),o=i.to();if(0==n.ch&&n.line>e.firstLine()){n=z(n.line-1,A(e.doc,n.line-1).length)}if(o.ch==A(e.doc,o.line).text.length&&o.line<e.lastLine()){o=z(o.line+1,0)}if(n.line<t.viewFrom||o.line>t.viewTo-1){return!1}var r,l,s;if(n.line==t.viewFrom||0==(r=Oi(e,n.line))){l=H(t.view[0].line);s=t.view[0].node}else{l=H(t.view[r].line);s=t.view[r-1].node.nextSibling}var d=Oi(e,o.line),a,p;if(d==t.view.length-1){a=t.viewTo-1;p=t.lineDiv.lastChild}else{a=H(t.view[d+1].line)-1;p=t.view[d+1].node.previousSibling}if(!s){return!1}var c=e.doc.splitLines(hl(e,s,p,l,a)),h=M(e.doc,z(l,0),z(a,A(e.doc,a).text.length));while(1<c.length&&1<h.length){if(y(c)==y(h)){c.pop();h.pop();a--}else if(c[0]==h[0]){c.shift();h.shift();l++}else{break}}var g=0,u=0,f=c[0],m=h[0],x=Math.min(f.length,m.length);while(g<x&&f.charCodeAt(g)==m.charCodeAt(g)){++g}var v=y(c),b=y(h),C=Math.min(v.length-(1==c.length?g:0),b.length-(1==h.length?g:0));while(u<C&&v.charCodeAt(v.length-u-1)==b.charCodeAt(b.length-u-1)){++u}if(1==c.length&&1==h.length&&l==n.line){while(g&&g>n.ch&&v.charCodeAt(v.length-u-1)==b.charCodeAt(b.length-u-1)){g--;u++}}c[c.length-1]=v.slice(0,v.length-u).replace(/^\u200b+/,"");c[0]=c[0].slice(g).replace(/\u200b+$/,"");var w=z(l,g),S=z(a,h.length?y(h).length-u:0);if(1<c.length||c[0]||E(w,S)){Go(e.doc,c,w,S,"+input");return!0}};Js.prototype.ensurePolled=function(){this.forceCompositionEnd()};Js.prototype.reset=function(){this.forceCompositionEnd()};Js.prototype.forceCompositionEnd=function(){if(!this.composing){return}clearTimeout(this.readDOMTimeout);this.composing=null;this.updateFromDOM();this.div.blur();this.div.focus()};Js.prototype.readFromDOMSoon=function(){var e=this;if(null!=this.readDOMTimeout){return}this.readDOMTimeout=setTimeout(function(){e.readDOMTimeout=null;if(e.composing){if(e.composing.done){e.composing=null}else{return}}e.updateFromDOM()},80)};Js.prototype.updateFromDOM=function(){var e=this;if(this.cm.isReadOnly()||!this.pollContent()){yn(this.cm,function(){return Cn(e.cm)})}};Js.prototype.setUneditable=function(e){e.contentEditable="false"};Js.prototype.onKeyPress=function(t){if(0==t.charCode||this.composing){return}t.preventDefault();if(!this.cm.isReadOnly()){xn(this.cm,tl)(this.cm,String.fromCharCode(null==t.charCode?t.keyCode:t.charCode),0)}};Js.prototype.readOnlyChanged=function(e){this.div.contentEditable=("nocursor"!=e)+""};Js.prototype.onContextMenu=function(){};Js.prototype.resetPosition=function(){};Js.prototype.needsContentAttribute=!0;function al(e,t){var i=_t(e,t.line);if(!i||i.hidden){return null}var n=A(e.doc,t.line),o=Kt(i,n,t.line),r=Ne(n,e.doc.direction),l="left";if(r){var s=Te(r,t.ch);l=s%2?"right":"left"}var d=Qt(o.map,t.ch,l);d.offset="right"==d.collapse?d.end:d.start;return d}function pl(e){for(var t=e;t;t=t.parentNode){if(/CodeMirror-gutter-wrapper/.test(t.className)){return!0}}return!1}function cl(e,t){if(t){e.bad=!0}return e}function hl(e,t,i,n,o){var a="",p=!1,c=e.doc.lineSeparator(),h=!1;function r(e){return function(t){return t.id==e}}function l(){if(p){a+=c;if(h){a+=c}p=h=!1}}function s(e){if(e){l();a+=e}}function d(t){if(1==t.nodeType){var a=t.getAttribute("cm-text");if(a){s(a);return}var g=t.getAttribute("cm-marker"),u;if(g){var f=e.findMarks(z(n,0),z(o+1,0),r(+g));if(f.length&&(u=f[0].find(0))){s(M(e.doc,u.from,u.to).join(c))}return}if("false"==t.getAttribute("contenteditable")){return}var m=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length){return}if(m){l()}for(var y=0;y<t.childNodes.length;y++){d(t.childNodes[y])}if(/^(pre|p)$/i.test(t.nodeName)){h=!0}if(m){p=!0}}else if(3==t.nodeType){s(t.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}}for(;;){d(t);if(t==i){break}t=t.nextSibling;h=!1}return a}function gl(e,t,n){var o;if(t==e.display.lineDiv){o=e.display.lineDiv.childNodes[n];if(!o){return cl(e.clipPos(z(e.display.viewTo-1)),!0)}t=null;n=0}else{for(o=t;;o=o.parentNode){if(!o||o==e.display.lineDiv){return null}if(o.parentNode&&o.parentNode==e.display.lineDiv){break}}}for(var r=0,l;r<e.display.view.length;r++){l=e.display.view[r];if(l.node==o){return ul(l,t,n)}}}function ul(e,t,i){var o=e.text.firstChild,r=!1;if(!t||!l(o,t)){return cl(z(H(e.line),0),!0)}if(t==o){r=!0;t=o.childNodes[i];i=0;if(!t){var s=e.rest?y(e.rest):e.line;return cl(z(H(s),s.text.length),r)}}var d=3==t.nodeType?t:null,a=t;if(!d&&1==t.childNodes.length&&3==t.firstChild.nodeType){d=t.firstChild;if(i){i=d.nodeValue.length}}while(a.parentNode!=o){a=a.parentNode}var p=e.measure,c=p.maps;function n(t,n,o){for(var r=-1,l;r<(c?c.length:0);r++){l=0>r?p.map:c[r];for(var s=0,d;s<l.length;s+=3){d=l[s+2];if(d==t||d==n){var a=H(0>r?e.line:e.rest[r]),h=l[s]+o;if(0>o||d!=t){h=l[s+(o?1:0)]}return z(a,h)}}}}var h=n(d,a,i);if(h){return cl(h,r)}for(var g=a.nextSibling,u=d?d.nodeValue.length-i:0;g;g=g.nextSibling){h=n(g,g.firstChild,0);if(h){return cl(z(h.line,h.ch-u),r)}else{u+=g.textContent.length}}for(var f=a.previousSibling,m=i;f;f=f.previousSibling){h=n(f,f.firstChild,-1);if(h){return cl(z(h.line,h.ch+m),r)}else{m+=f.textContent.length}}}var ed=function(e){this.cm=e;this.prevInput="";this.pollingFast=!1;this.polling=new Gl;this.hasSelection=!1;this.composing=null};ed.prototype.init=function(t){var n=this,o=this,r=this.cm;this.createField(t);var e=this.textarea;t.wrapper.insertBefore(this.wrapper,t.wrapper.firstChild);if(Al){e.style.width="0px"}es(e,"input",function(){if(Cl&&9<=ie&&n.hasSelection){n.hasSelection=null}o.poll()});es(e,"paste",function(t){if(We(r,t)||il(t,r)){return}r.state.pasteIncoming=!0;o.fastPoll()});function i(t){if(We(r,t)){return}if(r.somethingSelected()){el({lineWise:!1,text:r.getSelections()})}else if(!r.options.lineWiseCopyCut){return}else{var i=ol(r);el({lineWise:!0,text:i.text});if("cut"==t.type){r.setSelections(i.ranges,null,Ul)}else{o.prevInput="";e.value=i.text.join("\n");Bl(e)}}if("cut"==t.type){r.state.cutIncoming=!0}}es(e,"cut",i);es(e,"copy",i);es(t.scroller,"paste",function(i){if(Et(t,i)||We(r,i)){return}r.state.pasteIncoming=!0;o.focus()});es(t.lineSpace,"selectstart",function(i){if(!Et(t,i)){Pe(i)}});es(e,"compositionstart",function(){var e=r.getCursor("from");if(o.composing){o.composing.range.clear()}o.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}});es(e,"compositionend",function(){if(o.composing){o.poll();o.composing.range.clear();o.composing=null}})};ed.prototype.createField=function(){this.wrapper=ll();this.textarea=this.wrapper.firstChild};ed.prototype.prepareSelection=function(){var e=this.cm,t=e.display,i=e.doc,n=Mi(e);if(e.options.moveInputWithCursor){var o=ci(e,i.sel.primary().head,"div"),r=t.wrapper.getBoundingClientRect(),l=t.lineDiv.getBoundingClientRect();n.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,o.top+l.top-r.top));n.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,o.left+l.left-r.left))}return n};ed.prototype.showSelection=function(e){var t=this.cm,i=t.display;n(i.cursorDiv,e.cursors);n(i.selectionDiv,e.selection);if(null!=e.teTop){this.wrapper.style.top=e.teTop+"px";this.wrapper.style.left=e.teLeft+"px"}};ed.prototype.reset=function(e){if(this.contextMenuPending||this.composing){return}var t=this.cm;if(t.somethingSelected()){this.prevInput="";var i=t.getSelection();this.textarea.value=i;if(t.state.focused){Bl(this.textarea)}if(Cl&&9<=ie){this.hasSelection=i}}else if(!e){this.prevInput=this.textarea.value="";if(Cl&&9<=ie){this.hasSelection=null}}};ed.prototype.getField=function(){return this.textarea};ed.prototype.supportsTouch=function(){return!1};ed.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!Wl||s()!=this.textarea)){try{this.textarea.focus()}catch(t){}}};ed.prototype.blur=function(){this.textarea.blur()};ed.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0};ed.prototype.receivedFocus=function(){this.slowPoll()};ed.prototype.slowPoll=function(){var e=this;if(this.pollingFast){return}this.polling.set(this.cm.options.pollInterval,function(){e.poll();if(e.cm.state.focused){e.slowPoll()}})};ed.prototype.fastPoll=function(){var t=!1,i=this;i.pollingFast=!0;function e(){var n=i.poll();if(!n&&!t){t=!0;i.polling.set(60,e)}else{i.pollingFast=!1;i.slowPoll()}}i.polling.set(20,e)};ed.prototype.poll=function(){var e=this,t=this.cm,i=this.textarea,n=this.prevInput;if(this.contextMenuPending||!t.state.focused||ns(i)&&!n&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq){return!1}var o=i.value;if(o==n&&!t.somethingSelected()){return!1}if(Cl&&9<=ie&&this.hasSelection===o||Dl&&/[\uf700-\uf7ff]/.test(o)){t.display.input.reset();return!1}if(t.doc.sel==t.display.selForContextMenu){var r=o.charCodeAt(0);if(8203==r&&!n){n="\u200B"}if(8666==r){this.reset();return this.cm.execCommand("undo")}}var s=0,d=Math.min(n.length,o.length);while(s<d&&n.charCodeAt(s)==o.charCodeAt(s)){++s}yn(t,function(){tl(t,o.slice(s),n.length-s,null,e.composing?"*compose":null);if(1e3<o.length||-1<o.indexOf("\n")){i.value=e.prevInput=""}else{e.prevInput=o}if(e.composing){e.composing.range.clear();e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"})}});return!0};ed.prototype.ensurePolled=function(){if(this.pollingFast&&this.poll()){this.pollingFast=!1}};ed.prototype.onKeyPress=function(){if(Cl&&9<=ie){this.hasSelection=null}this.fastPoll()};ed.prototype.onContextMenu=function(t){var n=this,o=n.cm,r=o.display,l=n.textarea,s=Ni(o,t),d=r.scroller.scrollTop;if(!s||kl){return}var a=o.options.resetSelectionOnContextMenu;if(a&&-1==o.doc.sel.contains(s)){xn(o,ko)(o.doc,jn(s),Ul)}var p=l.style.cssText,c=n.wrapper.style.cssText;n.wrapper.style.cssText="position: absolute";var h=n.wrapper.getBoundingClientRect();l.style.cssText="position: absolute; width: 30px; height: 30px;\n      top: "+(t.clientY-h.top-5)+"px; left: "+(t.clientX-h.left-5)+"px;\n      z-index: 1000; background: "+(Cl?"rgba(255, 255, 255, .05)":"transparent")+";\n      outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";var g;if(wl){g=window.scrollY}r.input.focus();if(wl){window.scrollTo(null,g)}r.input.reset();if(!o.somethingSelected()){l.value=n.prevInput=" "}n.contextMenuPending=!0;r.selForContextMenu=o.doc.sel;clearTimeout(r.detectingSelectAll);function e(){if(null!=l.selectionStart){var e=o.somethingSelected(),t="\u200B"+(e?l.value:"");l.value="\u21DA";l.value=t;n.prevInput=e?"":"\u200B";l.selectionStart=1;l.selectionEnd=t.length;r.selForContextMenu=o.doc.sel}}function i(){n.contextMenuPending=!1;n.wrapper.style.cssText=c;l.style.cssText=p;if(Cl&&9>ie){r.scrollbars.setScrollTop(r.scroller.scrollTop=d)}if(null!=l.selectionStart){if(!Cl||Cl&&9>ie){e()}var t=0,s=function(){if(r.selForContextMenu==o.doc.sel&&0==l.selectionStart&&0<l.selectionEnd&&"\u200B"==n.prevInput){xn(o,Ho)(o)}else if(10>t++){r.detectingSelectAll=setTimeout(s,500)}else{r.selForContextMenu=null;r.input.reset()}};r.detectingSelectAll=setTimeout(s,200)}}if(Cl&&9<=ie){e()}if(zl){Ee(t);var u=function(){Ae(window,"mouseup",u);setTimeout(i,20)};es(window,"mouseup",u)}else{setTimeout(i,50)}};ed.prototype.readOnlyChanged=function(e){if(!e){this.reset()}this.textarea.disabled="nocursor"==e};ed.prototype.setUneditable=function(){};ed.prototype.needsContentAttribute=!1;(function(e){var i=e.optionHandlers;function t(t,n,o,r){e.defaults[t]=n;if(o){i[t]=r?function(e,t,i){if(i!=Ys){o(e,t,i)}}:o}}e.defineOption=t;e.Init=Ys;t("value","",function(e,t){return e.setValue(t)},!0);t("mode",null,function(e,t){e.doc.modeOption=t;qn(e)},!0);t("indentUnit",2,qn,!0);t("indentWithTabs",!1);t("smartIndent",!0);t("tabSize",4,function(e){Zn(e);oi(e);Cn(e)},!0);t("lineSeparator",null,function(e,t){e.doc.lineSep=t;if(!t){return}var n=[],o=e.doc.first;e.doc.iter(function(e){for(var i=0,r;;){r=e.text.indexOf(t,i);if(-1==r){break}i=r+t.length;n.push(z(o,r))}o++});for(var r=n.length-1;0<=r;r--){Go(e.doc,t,n[r],z(n[r].line,n[r].ch+t.length))}});t("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g,function(e,t,i){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g");if(i!=Ys){e.refresh()}});t("specialCharPlaceholder",ht,function(e){return e.refresh()},!0);t("electricChars",!0);t("inputStyle",Wl?"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",!Fl);t("wholeLineUpdateBefore",!0);t("theme","default",function(e){Xr(e);Yr(e)},!0);t("keyMap","default",function(e,t,i){var n=fr(t),o=i!=Ys&&fr(i);if(o&&o.detach){o.detach(e,n)}if(n.attach){n.attach(e,o||null)}});t("extraKeys",null);t("configureMouse",null);t("lineWrapping",!1,qr,!0);t("gutters",[],function(e){Rn(e.options);Yr(e)},!0);t("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?Li(e.display)+"px":"0";e.refresh()},!0);t("coverGutterNextToScrollbar",!1,function(e){return ln(e)},!0);t("scrollbarStyle","native",function(e){dn(e);ln(e);e.display.scrollbars.setScrollTop(e.doc.scrollTop);e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0);t("lineNumbers",!1,function(e){Rn(e.options);Yr(e)},!0);t("firstLineNumber",1,Yr,!0);t("lineNumberFormatter",function(e){return e},Yr,!0);t("showCursorWhenSelecting",!1,Ai,!0);t("resetSelectionOnContextMenu",!0);t("lineWiseCopyCut",!0);t("pasteLinesPerSelection",!0);t("selectionsMayTouch",!1);t("readOnly",!1,function(e,t){if("nocursor"==t){Ei(e);e.display.input.blur()}e.display.input.readOnlyChanged(t)});t("disableInput",!1,function(e,t){if(!t){e.display.input.reset()}},!0);t("dragDrop",!0,_r);t("allowDropFileTypes",null);t("cursorBlinkRate",530);t("cursorScrollMargin",0);t("cursorHeight",1,Ai,!0);t("singleCursorHeightPerLine",!0,Ai,!0);t("workTime",100);t("workDelay",100);t("flattenSpans",!0,Zn,!0);t("addModeClass",!1,Zn,!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,Zn,!0);t("moveInputWithCursor",!0,function(e,t){if(!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)})(Zr);(function(e){var t=e.optionHandlers,n=e.helpers={};e.prototype={constructor:e,focus:function focus(){window.focus();this.display.input.focus()},setOption:function setOption(e,i){var n=this.options,o=n[e];if(n[e]==i&&"mode"!=e){return}n[e]=i;if(t.hasOwnProperty(e)){xn(this,t[e])(this,i,o)}Me(this,"optionChange",this,e)},getOption:function getOption(e){return this.options[e]},getDoc:function getDoc(){return this.doc},addKeyMap:function addKeyMap(e,t){this.state.keyMaps[t?"push":"unshift"](fr(e))},removeKeyMap:function removeKeyMap(e){for(var t=this.state.keyMaps,n=0;n<t.length;++n){if(t[n]==e||t[n].name==e){t.splice(n,1);return!0}}},addOverlay:vn(function(t,i){var n=t.token?t:e.getMode(this.options,t);if(n.startState){throw new Error("Overlays may not be stateful.")}v(this.state.overlays,{mode:n,modeSpec:t,opaque:i&&i.opaque,priority:i&&i.priority||0},function(e){return e.priority});this.state.modeGen++;Cn(this)}),removeOverlay:vn(function(e){for(var t=this.state.overlays,n=0,o;n<t.length;++n){o=t[n].modeSpec;if(o==e||"string"==typeof e&&o.name==e){t.splice(n,1);this.state.modeGen++;Cn(this);return}}}),indentLine:vn(function(e,t,i){if("string"!=typeof t&&"number"!=typeof t){if(null==t){t=this.options.smartIndent?"smart":"prev"}else{t=t?"add":"subtract"}}if(P(this.doc,e)){Jr(this,e,t,i)}}),indentSelection:vn(function(e){for(var t=this.doc.sel.ranges,n=-1,o=0,r;o<t.length;o++){r=t[o];if(!r.empty()){var l=r.from(),s=r.to(),d=Math.max(n,l.line);n=Math.min(this.lastLine(),s.line-(s.ch?0:1))+1;for(var a=d;a<n;++a){Jr(this,a,e)}var p=this.doc.sel.ranges;if(0==l.ch&&t.length==p.length&&0<p[o].from().ch){Co(this.doc,o,new Os(l,p[o].to()),Ul)}}else if(r.head.line>n){Jr(this,r.head.line,e,!0);n=r.head.line;if(o==this.doc.sel.primIndex){_i(this)}}}}),getTokenAt:function getTokenAt(e,t){return nt(this,e,t)},getLineTokens:function getLineTokens(e,t){return nt(this,z(e),t,!0)},getTokenTypeAt:function getTokenTypeAt(e){e=j(this.doc,e);var t=Qe(this,A(this.doc,e.line)),i=0,n=(t.length-1)/2,o=e.ch,r;if(0==o){r=t[2]}else{for(;;){var l=i+n>>1;if((l?t[2*l-1]:0)>=o){n=l}else if(t[2*l+1]<o){i=l+1}else{r=t[2*l+2];break}}}var s=r?r.indexOf("overlay "):-1;return 0>s?r:0==s?null:r.slice(0,s-1)},getModeAt:function getModeAt(t){var i=this.doc.mode;if(!i.innerMode){return i}return e.innerMode(i,this.getTokenAt(t).state).mode},getHelper:function getHelper(e,t){return this.getHelpers(e,t)[0]},getHelpers:function getHelpers(e,t){var o=[];if(!n.hasOwnProperty(t)){return o}var r=n[t],l=this.getModeAt(e);if("string"==typeof l[t]){if(r[l[t]]){o.push(r[l[t]])}}else if(l[t]){for(var s=0,d;s<l[t].length;s++){d=r[l[t][s]];if(d){o.push(d)}}}else if(l.helperType&&r[l.helperType]){o.push(r[l.helperType])}else if(r[l.name]){o.push(r[l.name])}for(var a=0,p;a<r._global.length;a++){p=r._global[a];if(p.pred(l,this)&&-1==g(o,p.val)){o.push(p.val)}}return o},getStateAfter:function getStateAfter(e,t){var i=this.doc;e=U(i,null==e?i.first+i.size-1:e);return Je(this,e+1,t).state},cursorCoords:function cursorCoords(e,t){var i,n=this.doc.sel.primary();if(null==e){i=n.head}else if("object"==_typeof(e)){i=j(this.doc,e)}else{i=e?n.from():n.to()}return ci(this,i,t||"page")},charCoords:function charCoords(e,t){return pi(this,j(this.doc,e),t||"page")},coordsChar:function coordsChar(e,t){e=ai(this,e,t||"page");return ui(this,e.left,e.top)},lineAtHeight:function lineAtHeight(e,t){e=ai(this,{top:e,left:0},t||"page").top;return F(this.doc,e+this.display.viewOffset)},heightAtLine:function heightAtLine(e,t,i){var n=!1,o;if("number"==typeof e){var r=this.doc.first+this.doc.size-1;if(e<this.doc.first){e=this.doc.first}else if(e>r){e=r;n=!0}o=A(this.doc,e)}else{o=e}return di(this,o,{top:0,left:0},t||"page",i||n).top+(n?this.doc.height-we(o):0)},defaultTextHeight:function defaultTextHeight(){return Ci(this.display)},defaultCharWidth:function defaultCharWidth(){return wi(this.display)},getViewport:function getViewport(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function addWidget(e,t,i,n,o){var r=this.display;e=ci(this,j(this.doc,e));var l=e.bottom,s=e.left;t.style.position="absolute";t.setAttribute("cm-ignore-events","true");this.display.input.setUneditable(t);r.sizer.appendChild(t);if("over"==n){l=e.top}else if("above"==n||"near"==n){var d=Math.max(r.wrapper.clientHeight,this.doc.height),a=Math.max(r.sizer.clientWidth,r.lineSpace.clientWidth);if(("above"==n||e.bottom+t.offsetHeight>d)&&e.top>t.offsetHeight){l=e.top-t.offsetHeight}else if(e.bottom+t.offsetHeight<=d){l=e.bottom}if(s+t.offsetWidth>a){s=a-t.offsetWidth}}t.style.top=l+"px";t.style.left=t.style.right="";if("right"==o){s=r.sizer.clientWidth-t.offsetWidth;t.style.right="0px"}else{if("left"==o){s=0}else if("middle"==o){s=(r.sizer.clientWidth-t.offsetWidth)/2}t.style.left=s+"px"}if(i){Ki(this,{left:s,top:l,right:s+t.offsetWidth,bottom:l+t.offsetHeight})}},triggerOnKeyDown:vn(Mr),triggerOnKeyPress:vn(Hr),triggerOnKeyUp:Dr,triggerOnMouseDown:vn(Pr),execCommand:function execCommand(e){if($s.hasOwnProperty(e)){return $s[e].call(null,this)}},triggerElectric:vn(function(e){nl(this,e)}),findPosH:function findPosH(e,t,n,o){var r=1;if(0>t){r=-1;t=-t}for(var l=j(this.doc,e),s=0;s<t;++s){l=sl(this.doc,l,r,n,o);if(l.hitSide){break}}return l},moveH:vn(function(e,t){var i=this;this.extendSelectionsBy(function(n){if(i.display.shift||i.doc.extend||n.empty()){return sl(i.doc,n.head,e,t,i.options.rtlMoveVisually)}else{return 0>e?n.from():n.to()}},Vl)}),deleteH:vn(function(e,t){var i=this.doc.sel,n=this.doc;if(i.somethingSelected()){n.replaceSelection("",null,"+delete")}else{mr(this,function(i){var o=sl(n,i.head,e,t,!1);return 0>e?{from:o,to:i.head}:{from:i.head,to:o}})}}),findPosV:function findPosV(e,t,n,o){var r=1,l=o;if(0>t){r=-1;t=-t}for(var s=j(this.doc,e),d=0,a;d<t;++d){a=ci(this,s,"div");if(null==l){l=a.left}else{a.left=l}s=dl(this,a,r,n);if(s.hitSide){break}}return s},moveV:vn(function(e,t){var n=this,o=this.doc,r=[],l=!this.display.shift&&!o.extend&&o.sel.somethingSelected();o.extendSelectionsBy(function(i){if(l){return 0>e?i.from():i.to()}var s=ci(n,i.head,"div");if(null!=i.goalColumn){s.left=i.goalColumn}r.push(s.left);var d=dl(n,s,e,t);if("page"==t&&i==o.sel.primary()){Yi(n,pi(n,d,"div").top-s.top)}return d},Vl);if(r.length){for(var s=0;s<o.sel.ranges.length;s++){o.sel.ranges[s].goalColumn=r[s]}}}),findWordAt:function findWordAt(e){var t=this.doc,i=A(t,e.line).text,n=e.ch,o=e.ch;if(i){var r=this.getHelper(e,"wordChars");if(("before"==e.sticky||o==i.length)&&n){--n}else{++o}var l=i.charAt(n),s=S(l,r)?function(e){return S(e,r)}:/\s/.test(l)?function(e){return /\s/.test(e)}:function(e){return!/\s/.test(e)&&!S(e)};while(0<n&&s(i.charAt(n-1))){--n}while(o<i.length&&s(i.charAt(o))){++o}}return new Os(z(e.line,n),z(e.line,o))},toggleOverwrite:function toggleOverwrite(e){if(null!=e&&e==this.state.overwrite){return}if(this.state.overwrite=!this.state.overwrite){d(this.display.cursorDiv,"CodeMirror-overwrite")}else{El(this.display.cursorDiv,"CodeMirror-overwrite")}Me(this,"overwriteToggle",this,this.state.overwrite)},hasFocus:function hasFocus(){return this.display.input.getField()==s()},isReadOnly:function isReadOnly(){return!!(this.options.readOnly||this.doc.cantEdit)},scrollTo:vn(function(e,t){qi(this,e,t)}),getScrollInfo:function getScrollInfo(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-$t(this)-this.display.barHeight,width:e.scrollWidth-$t(this)-this.display.barWidth,clientHeight:jt(this),clientWidth:Ut(this)}},scrollIntoView:vn(function(e,t){if(null==e){e={from:this.doc.sel.primary().head,to:null};if(null==t){t=this.options.cursorScrollMargin}}else if("number"==typeof e){e={from:z(e,0),to:null}}else if(null==e.from){e={from:e,to:null}}if(!e.to){e.to=e.from}e.margin=t||0;if(null!=e.from.line){Zi(this,e)}else{Ji(this,e.from,e.to,e.margin)}}),setSize:vn(function(e,t){var i=this,n=function(e){return"number"==typeof e||/^\d+$/.test(e+"")?e+"px":e};if(null!=e){this.display.wrapper.style.width=n(e)}if(null!=t){this.display.wrapper.style.height=n(t)}if(this.options.lineWrapping){ni(this)}var o=this.display.viewFrom;this.doc.iter(o,this.display.viewTo,function(e){if(e.widgets){for(var t=0;t<e.widgets.length;t++){if(e.widgets[t].noHScroll){wn(i,o,"widget");break}}}++o});this.curOp.forceUpdate=!0;Me(this,"refresh",this)}),operation:function(e){return yn(this,e)},startOperation:function startOperation(){return an(this)},endOperation:function endOperation(){return pn(this)},refresh:vn(function(){var e=this.display.cachedTextHeight;Cn(this);this.curOp.forceUpdate=!0;oi(this);qi(this,this.doc.scrollLeft,this.doc.scrollTop);In(this);if(null==e||.5<Math.abs(e-Ci(this.display))){Ti(this)}Me(this,"refresh",this)}),swapDoc:vn(function(e){var t=this.doc;t.cm=null;to(this,e);oi(this);this.display.input.reset();qi(this,e.scrollLeft,e.scrollTop);this.curOp.forceScroll=!0;St(this,"swapDoc",this,t);return t}),phrase:function phrase(e){var t=this.options.phrases;return t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:e},getInputField:function getInputField(){return this.display.input.getField()},getWrapperElement:function getWrapperElement(){return this.display.wrapper},getScrollerElement:function getScrollerElement(){return this.display.scroller},getGutterElement:function getGutterElement(){return this.display.gutters}};Fe(e);e.registerHelper=function(t,i,o){if(!n.hasOwnProperty(t)){n[t]=e[t]={_global:[]}}n[t][i]=o};e.registerGlobalHelper=function(t,i,o,r){e.registerHelper(t,i,r);n[t]._global.push({pred:o,val:r})}})(Zr);var td=["iter","insert","remove","copy","getEditor","constructor"];for(var id in Fs.prototype){if(Fs.prototype.hasOwnProperty(id)&&0>g(td,id)){Zr.prototype[id]=function(e){return function(){return e.apply(this.doc,arguments)}}(Fs.prototype[id])}}Fe(Fs);Zr.inputStyles={textarea:ed,contenteditable:Js};Zr.defineMode=function(e){if(!Zr.defaults.mode&&"null"!=e){Zr.defaults.mode=e}je.apply(this,arguments)};Zr.defineMIME=function(e,t){ss[e]=t};Zr.defineMode("null",function(){return{token:function token(e){return e.skipToEnd()}}});Zr.defineMIME("text/plain","null");Zr.defineExtension=function(e,t){Zr.prototype[e]=t};Zr.defineDocExtension=function(e,t){Fs.prototype[e]=t};Zr.fromTextArea=function(e,t){t=t?c(t):{};t.value=e.value;if(!t.tabindex&&e.tabIndex){t.tabindex=e.tabIndex}if(!t.placeholder&&e.placeholder){t.placeholder=e.placeholder}if(null==t.autofocus){var n=s();t.autofocus=n==e||null!=e.getAttribute("autofocus")&&n==document.body}function i(){e.value=d.getValue()}var o;if(e.form){es(e.form,"submit",i);if(!t.leaveSubmitMethodAlone){var r=e.form;o=r.submit;try{var l=r.submit=function(){i();r.submit=o;r.submit();r.submit=l}}catch(t){}}}t.finishInit=function(t){t.save=i;t.getTextArea=function(){return e};t.toTextArea=function(){t.toTextArea=isNaN;i();e.parentNode.removeChild(t.getWrapperElement());e.style.display="";if(e.form){Ae(e.form,"submit",i);if("function"==typeof e.form.submit){e.form.submit=o}}}};e.style.display="none";var d=Zr(function(t){return e.parentNode.insertBefore(t,e.nextSibling)},t);return d};(function(e){e.off=Ae;e.on=es;e.wheelEventPixels=Gn;e.Doc=Fs;e.splitLines=is;e.countColumn=h;e.findColumn=u;e.isWordChar=w;e.Pass=$l;e.signal=Me;e.Line=gs;e.changeEnd=Vn;e.scrollbarModel=ws;e.Pos=z;e.cmpPos=E;e.modes=ls;e.mimeModes=ss;e.resolveMode=Ve;e.getMode=Ke;e.modeExtensions=ds;e.extendMode=Xe;e.copyState=Ye;e.startState=qe;e.innerMode=_e;e.commands=$s;e.keyMap=Gs;e.keyName=ur;e.isModifierKey=hr;e.lookupKey=cr;e.normalizeKeyMap=pr;e.StringStream=as;e.SharedTextMarker=Ds;e.TextMarker=Ws;e.LineWidget=As;e.e_preventDefault=Pe;e.e_stopPropagation=Ie;e.e_stop=Ee;e.addClass=d;e.contains=l;e.rmClass=El;e.keyNames=zs})(Zr);Zr.version="5.41.0";return Zr});
//# sourceMappingURL=codemirror.min.js.map