TiddlyWiki5/plugins/tiddlywiki/codemirror/files/codemirror.js

2 wiersze
166 KiB
JavaScript
Executable File
Czysty Wina Historia

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).CodeMirror=t()}(this,function(){"use strict";var e=navigator.userAgent,t=navigator.platform,g=/gecko\/\d/i.test(e),n=/MSIE \d/.test(e),r=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e),i=/Edge\/(\d+)/.exec(e),x=n||r||i,C=x&&(n?document.documentMode||6:+(i||r)[1]),v=!i&&/WebKit\//.test(e),o=v&&/Qt\/\d+\.\d+/.test(e),l=!i&&/Chrome\//.test(e),m=/Opera\//.test(e),c=/Apple Computer/.test(navigator.vendor),s=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),u=/PhantomJS/.test(e),a=!i&&/AppleWebKit/.test(e)&&/Mobile\/\w+/.test(e),h=/Android/.test(e),d=a||h||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),y=a||/Mac/.test(t),f=/\bCrOS\b/.test(e),p=/win/i.test(t),b=m&&e.match(/Version\/(\d*\.\d*)/);(b=b&&Number(b[1]))&&15<=b&&(v=!(m=!1));var w=y&&(o||m&&(null==b||b<12.11)),S=g||x&&9<=C;function L(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var k,T=function(e,t){var n,r=e.className,i=L(t).exec(r);i&&(n=r.slice(i.index+i[0].length),e.className=r.slice(0,i.index)+(n?i[1]+n:""))};function M(e){for(var t=e.childNodes.length;0<t;--t)e.removeChild(e.firstChild);return e}function N(e,t){return M(e).appendChild(t)}function O(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o<t.length;++o)i.appendChild(t[o]);return i}function A(e,t,n,r){var i=O(e,t,n,r);return i.setAttribute("role","presentation"),i}function D(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do{if(11==t.nodeType&&(t=t.host),t==e)return!0}while(t=t.parentNode)}function W(){var t;try{t=document.activeElement}catch(e){t=document.body||null}for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function H(e,t){var n=e.className;L(t).test(n)||(e.className+=(n?" ":"")+t)}function F(e,t){for(var n=e.split(" "),r=0;r<n.length;r++)n[r]&&!L(n[r]).test(t)&&(t+=" "+n[r]);return t}k=document.createRange?function(e,t,n,r){var i=document.createRange();return i.setEnd(r||e,n),i.setStart(e,t),i}:function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(e){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",t),r};var P=function(e){e.select()};function E(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function I(e,t,n){for(var r in t=t||{},e)!e.hasOwnProperty(r)||!1===n&&t.hasOwnProperty(r)||(t[r]=e[r]);return t}function R(e,t,n,r,i){null==t&&-1==(t=e.search(/[^\s\u00a0]/))&&(t=e.length);for(var o=r||0,l=i||0;;){var s=e.indexOf("\t",o);if(s<0||t<=s)return l+(t-o);l+=s-o,l+=n-l%n,o=s+1}}a?P=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:x&&(P=function(e){try{e.select()}catch(e){}});var z=function(){this.id=null,this.f=null,this.time=0,this.handler=E(this.onTimeout,this)};function B(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}z.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-new Date)},z.prototype.set=function(e,t){this.f=t;var n=+new Date+e;(!this.id||n<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,e),this.time=n)};var G=50,U={toString:function(){return"CodeMirror.Pass"}},V={scroll:!1},K={origin:"*mouse"},j={origin:"+move"};function X(e,t,n){for(var r=0,i=0;;){var o=e.indexOf("\t",r);-1==o&&(o=e.length);var l=o-r;if(o==e.length||t<=i+l)return r+Math.min(l,t-i);if(i+=o-r,r=o+1,t<=(i+=n-i%n))return r}}var Y=[""];function _(e){for(;Y.length<=e;)Y.push($(Y)+" ");return Y[e]}function $(e){return e[e.length-1]}function q(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function Z(){}function Q(e,t){var n=Object.create?Object.create(e):(Z.prototype=e,new Z);return t&&I(t,n),n}var J=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function ee(e){return/\w/.test(e)||"€"<e&&(e.toUpperCase()!=e.toLowerCase()||J.test(e))}function te(e,t){return t?!!(-1<t.source.indexOf("\\w")&&ee(e))||t.test(e):ee(e)}function ne(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return;return 1}var re=/[\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 ie(e){return 768<=e.charCodeAt(0)&&re.test(e)}function oe(e,t,n){for(;(n<0?0<t:t<e.length)&&ie(e.charAt(t));)t+=n;return t}function le(e,t,n){for(var r=n<t?-1:1;;){if(t==n)return t;var i=(t+n)/2,o=r<0?Math.ceil(i):Math.floor(i);if(o==t)return e(o)?t:n;e(o)?n=o:t=o+r}}var se=null;function ae(e,t,n){var r;se=null;for(var i=0;i<e.length;++i){var o=e[i];if(o.from<t&&o.to>t)return i;o.to==t&&(o.from!=o.to&&"before"==n?r=i:se=i),o.from==t&&(o.from!=o.to&&"before"!=n?r=i:se=i)}return null!=r?r:se}var ue,ce,he,de,fe,pe,ge,me=(ue="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",ce="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",he=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,de=/[stwN]/,fe=/[LRr]/,pe=/[Lb1n]/,ge=/[1n]/,function(e,t){var n="ltr"==t?"L":"R";if(0==e.length||"ltr"==t&&!he.test(e))return!1;for(var r,i=e.length,o=[],l=0;l<i;++l)o.push((r=e.charCodeAt(l))<=247?ue.charAt(r):1424<=r&&r<=1524?"R":1536<=r&&r<=1785?ce.charAt(r-1536):1774<=r&&r<=2220?"r":8192<=r&&r<=8203?"w":8204==r?"b":"L");for(var s=0,a=n;s<i;++s){var u=o[s];"m"==u?o[s]=a:a=u}for(var c=0,h=n;c<i;++c){var d=o[c];"1"==d&&"r"==h?o[c]="n":fe.test(d)&&"r"==(h=d)&&(o[c]="R")}for(var f=1,p=o[0];f<i-1;++f){var g=o[f];"+"==g&&"1"==p&&"1"==o[f+1]?o[f]="1":","!=g||p!=o[f+1]||"1"!=p&&"n"!=p||(o[f]=p),p=g}for(var m=0;m<i;++m){var v=o[m];if(","==v)o[m]="N";else if("%"==v){for(var y=void 0,y=m+1;y<i&&"%"==o[y];++y);for(var b=m&&"!"==o[m-1]||y<i&&"1"==o[y]?"1":"N",w=m;w<y;++w)o[w]=b;m=y-1}}for(var x=0,C=n;x<i;++x){var S=o[x];"L"==C&&"1"==S?o[x]="L":fe.test(S)&&(C=S)}for(var L=0;L<i;++L)if(de.test(o[L])){for(var k=void 0,k=L+1;k<i&&de.test(o[k]);++k);for(var T="L"==(L?o[L-1]:n),M=T==("L"==(k<i?o[k]:n))?T?"L":"R":n,N=L;N<k;++N)o[N]=M;L=k-1}for(var A,O=[],D=0;D<i;)if(pe.test(o[D])){var W=D;for(++D;D<i&&pe.test(o[D]);++D);O.push(new ve(0,W,D))}else{var H=D,F=O.length,P="rtl"==t?1:0;for(++D;D<i&&"L"!=o[D];++D);for(var E=H;E<D;)if(ge.test(o[E])){H<E&&(O.splice(F,0,new ve(1,H,E)),F+=P);var I=E;for(++E;E<D&&ge.test(o[E]);++E);O.splice(F,0,new ve(2,I,E)),F+=P,H=E}else++E;H<D&&O.splice(F,0,new ve(1,H,D))}return"ltr"==t&&(1==O[0].level&&(A=e.match(/^\s+/))&&(O[0].from=A[0].length,O.unshift(new ve(0,0,A[0].length))),1==$(O).level&&(A=e.match(/\s+$/))&&($(O).to-=A[0].length,O.push(new ve(0,i-A[0].length,i)))),"rtl"==t?O.reverse():O});function ve(e,t,n){this.level=e,this.from=t,this.to=n}function ye(e,t){var n=e.order;return null==n&&(n=e.order=me(e.text,t)),n}var be=[],we=function(e,t,n){var r;e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent?e.attachEvent("on"+t,n):(r=e._handlers||(e._handlers={}))[t]=(r[t]||be).concat(n)};function xe(e,t){return e._handlers&&e._handlers[t]||be}function Ce(e,t,n){var r,i,o;e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent?e.detachEvent("on"+t,n):!(i=(r=e._handlers)&&r[t])||-1<(o=B(i,n))&&(r[t]=i.slice(0,o).concat(i.slice(o+1)))}function Se(e,t){var n=xe(e,t);if(n.length)for(var r=Array.prototype.slice.call(arguments,2),i=0;i<n.length;++i)n[i].apply(null,r)}function Le(e,t,n){return"string"==typeof t&&(t={type:t,preventDefault:function(){this.defaultPrevented=!0}}),Se(e,n||t.type,e,t),Oe(t)||t.codemirrorIgnore}function ke(e){var t=e._handlers&&e._handlers.cursorActivity;if(t)for(var n=e.curOp.cursorActivityHandlers||(e.curOp.cursorActivityHandlers=[]),r=0;r<t.length;++r)-1==B(n,t[r])&&n.push(t[r])}function Te(e,t){return 0<xe(e,t).length}function Me(e){e.prototype.on=function(e,t){we(this,e,t)},e.prototype.off=function(e,t){Ce(this,e,t)}}function Ne(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Ae(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function Oe(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function De(e){Ne(e),Ae(e)}function We(e){return e.target||e.srcElement}function He(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),y&&e.ctrlKey&&1==t&&(t=3),t}var Fe,Pe,Ee=function(){if(x&&C<9)return!1;var e=O("div");return"draggable"in e||"dragDrop"in e}();var Ie,Re=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],r=e.length;t<=r;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),l=o.indexOf("\r");-1!=l?(n.push(o.slice(0,l)),t+=l+1):(n.push(o),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},ze=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(e){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(e){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},Be="oncopy"in(Ie=O("div"))||(Ie.setAttribute("oncopy","return;"),"function"==typeof Ie.oncopy),Ge=null;var Ue={},Ve={};function Ke(e){if("string"==typeof e&&Ve.hasOwnProperty(e))e=Ve[e];else if(e&&"string"==typeof e.name&&Ve.hasOwnProperty(e.name)){var t=Ve[e.name];"string"==typeof t&&(t={name:t}),(e=Q(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ke("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ke("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function je(e,t){t=Ke(t);var n=Ue[t.name];if(!n)return je(e,"text/plain");var r=n(e,t);if(Xe.hasOwnProperty(t.name)){var i=Xe[t.name];for(var o in i)i.hasOwnProperty(o)&&(r.hasOwnProperty(o)&&(r["_"+o]=r[o]),r[o]=i[o])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var l in t.modeProps)r[l]=t.modeProps[l];return r}var Xe={};function Ye(e,t){I(t,Xe.hasOwnProperty(e)?Xe[e]:Xe[e]={})}function _e(e,t){if(!0===t)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n}function $e(e,t){for(var n;e.innerMode&&(n=e.innerMode(t))&&n.mode!=e;)t=n.state,e=n.mode;return n||{mode:e,state:t}}function qe(e,t,n){return!e.startState||e.startState(t,n)}var Ze=function(e,t,n){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};function Qe(e,t){if((t-=e.first)<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(t<o){n=i;break}t-=o}return n.lines[t]}function Je(e,n,r){var i=[],o=n.line;return e.iter(n.line,r.line+1,function(e){var t=e.text;o==r.line&&(t=t.slice(0,r.ch)),o==n.line&&(t=t.slice(n.ch)),i.push(t),++o}),i}function et(e,t,n){var r=[];return e.iter(t,n,function(e){r.push(e.text)}),r}function tt(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function nt(e){if(null==e.parent)return null;for(var t=e.parent,n=B(t.lines,e),r=t.parent;r;r=(t=r).parent)for(var i=0;r.children[i]!=t;++i)n+=r.children[i].chunkSize();return n+t.first}function rt(e,t){var n=e.first;e:do{for(var r=0;r<e.children.length;++r){var i=e.children[r],o=i.height;if(t<o){e=i;continue e}t-=o,n+=i.chunkSize()}return n}while(!e.lines);for(var l=0;l<e.lines.length;++l){var s=e.lines[l].height;if(t<s)break;t-=s}return n+l}function it(e,t){return t>=e.first&&t<e.first+e.size}function ot(e,t){return String(e.lineNumberFormatter(t+e.firstLineNumber))}function lt(e,t,n){if(void 0===n&&(n=null),!(this instanceof lt))return new lt(e,t,n);this.line=e,this.ch=t,this.sticky=n}function st(e,t){return e.line-t.line||e.ch-t.ch}function at(e,t){return e.sticky==t.sticky&&0==st(e,t)}function ut(e){return lt(e.line,e.ch)}function ct(e,t){return st(e,t)<0?t:e}function ht(e,t){return st(e,t)<0?e:t}function dt(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function ft(e,t){if(t.line<e.first)return lt(e.first,0);var n,r,i,o=e.first+e.size-1;return t.line>o?lt(o,Qe(e,o).text.length):(r=Qe(e,(n=t).line).text.length,null==(i=n.ch)||r<i?lt(n.line,r):i<0?lt(n.line,0):n)}function pt(e,t){for(var n=[],r=0;r<t.length;r++)n[r]=ft(e,t[r]);return n}Ze.prototype.eol=function(){return this.pos>=this.string.length},Ze.prototype.sol=function(){return this.pos==this.lineStart},Ze.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Ze.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Ze.prototype.eat=function(e){var t=this.string.charAt(this.pos),n="string"==typeof e?t==e:t&&(e.test?e.test(t):e(t));if(n)return++this.pos,t},Ze.prototype.eatWhile=function(e){for(var t=this.pos;this.eat(e););return this.pos>t},Ze.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},Ze.prototype.skipToEnd=function(){this.pos=this.string.length},Ze.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(-1<t)return this.pos=t,!0},Ze.prototype.backUp=function(e){this.pos-=e},Ze.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=R(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?R(this.string,this.lineStart,this.tabSize):0)},Ze.prototype.indentation=function(){return R(this.string,null,this.tabSize)-(this.lineStart?R(this.string,this.lineStart,this.tabSize):0)},Ze.prototype.match=function(e,t,n){if("string"!=typeof e){var r=this.string.slice(this.pos).match(e);return r&&0<r.index?null:(r&&!1!==t&&(this.pos+=r[0].length),r)}function i(e){return n?e.toLowerCase():e}if(i(this.string.substr(this.pos,e.length))==i(e))return!1!==t&&(this.pos+=e.length),!0},Ze.prototype.current=function(){return this.string.slice(this.start,this.pos)},Ze.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},Ze.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},Ze.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var gt=function(e,t){this.state=e,this.lookAhead=t},mt=function(e,t,n,r){this.state=t,this.doc=e,this.line=n,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};function vt(t,n,r,e){var a=[t.state.modeGen],i={};Tt(t,n.text,t.doc.mode,r,function(e,t){return a.push(e,t)},i,e);for(var u=r.state,o=0;o<t.state.overlays.length;++o)!function(e){r.baseTokens=a;var o=t.state.overlays[e],l=1,s=0;r.state=!0,Tt(t,n.text,o.mode,r,function(e,t){for(var n=l;s<e;){var r=a[l];e<r&&a.splice(l,1,e,a[l+1],r),l+=2,s=Math.min(e,r)}if(t)if(o.opaque)a.splice(n,l-n,e,"overlay "+t),l=n+2;else for(;n<l;n+=2){var i=a[n+1];a[n+1]=(i?i+" ":"")+"overlay "+t}},i),r.state=u,r.baseTokens=null,r.baseTokenPos=1}(o);return{styles:a,classes:i.bgClass||i.textClass?i:null}}function yt(e,t,n){var r,i,o;return t.styles&&t.styles[0]==e.state.modeGen||(r=bt(e,nt(t)),i=t.text.length>e.options.maxHighlightLength&&_e(e.doc.mode,r.state),o=vt(e,t,r),i&&(r.state=i),t.stateAfter=r.save(!i),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))),t.styles}function bt(n,r,e){var t=n.doc,i=n.display;if(!t.mode.startState)return new mt(t,!0,r);var o=function(e,t,n){for(var r,i,o=e.doc,l=n?-1:t-(e.doc.mode.innerMode?1e3:100),s=t;l<s;--s){if(s<=o.first)return o.first;var a=Qe(o,s-1),u=a.stateAfter;if(u&&(!n||s+(u instanceof gt?u.lookAhead:0)<=o.modeFrontier))return s;var c=R(a.text,null,e.options.tabSize);(null==i||c<r)&&(i=s-1,r=c)}return i}(n,r,e),l=o>t.first&&Qe(t,o-1).stateAfter,s=l?mt.fromSaved(t,l,o):new mt(t,qe(t.mode),o);return t.iter(o,r,function(e){wt(n,e.text,s);var t=s.line;e.stateAfter=t==r-1||t%5==0||t>=i.viewFrom&&t<i.viewTo?s.save():null,s.nextLine()}),e&&(t.modeFrontier=s.line),s}function wt(e,t,n,r){var i=e.doc.mode,o=new Ze(t,e.options.tabSize,n);for(o.start=o.pos=r||0,""==t&&xt(i,n.state);!o.eol();)Ct(i,o,n.state),o.start=o.pos}function xt(e,t){if(e.blankLine)return e.blankLine(t);if(e.innerMode){var n=$e(e,t);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Ct(e,t,n,r){for(var i=0;i<10;i++){r&&(r[0]=$e(e,n).mode);var o=e.token(t,n);if(t.pos>t.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}mt.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},mt.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},mt.prototype.nextLine=function(){this.line++,0<this.maxLookAhead&&this.maxLookAhead--},mt.fromSaved=function(e,t,n){return t instanceof gt?new mt(e,_e(e.mode,t.state),n,t.lookAhead):new mt(e,_e(e.mode,t),n)},mt.prototype.save=function(e){var t=!1!==e?_e(this.doc.mode,this.state):this.state;return 0<this.maxLookAhead?new gt(t,this.maxLookAhead):t};var St=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n};function Lt(e,t,n,r){var i,o,l=e.doc,s=l.mode,a=Qe(l,(t=ft(l,t)).line),u=bt(e,t.line,n),c=new Ze(a.text,e.options.tabSize,u);for(r&&(o=[]);(r||c.pos<t.ch)&&!c.eol();)c.start=c.pos,i=Ct(s,c,u.state),r&&o.push(new St(c,i,_e(l.mode,u.state)));return r?o:new St(c,i,u.state)}function kt(e,t){if(e)for(;;){var n=e.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;e=e.slice(0,n.index)+e.slice(n.index+n[0].length);var r=n[1]?"bgClass":"textClass";null==t[r]?t[r]=n[2]:new RegExp("(?:^|\\s)"+n[2]+"(?:$|\\s)").test(t[r])||(t[r]+=" "+n[2])}return e}function Tt(e,t,n,r,i,o,l){var s=n.flattenSpans;null==s&&(s=e.options.flattenSpans);var a=0,u=null,c=new Ze(t,e.options.tabSize,r),h=e.options.addModeClass&&[null];for(""==t&&kt(xt(n,r.state),o);!c.eol();){var d,f=c.pos>e.options.maxHighlightLength?(s=!1,l&&wt(e,t,r,c.pos),c.pos=t.length,null):kt(Ct(n,c,r.state,h),o);if(!h||(d=h[0].name)&&(f="m-"+(f?d+" "+f:d)),!s||u!=f){for(;a<c.start;)i(a=Math.min(c.start,a+5e3),u);u=f}c.start=c.pos}for(;a<c.pos;){var p=Math.min(c.pos,a+5e3);i(p,u),a=p}}var Mt=!1,Nt=!1;function At(e,t,n){this.marker=e,this.from=t,this.to=n}function Ot(e,t){if(e)for(var n=0;n<e.length;++n){var r=e[n];if(r.marker==t)return r}}function Dt(e,t){if(t.full)return null;var n=it(e,t.from.line)&&Qe(e,t.from.line).markedSpans,r=it(e,t.to.line)&&Qe(e,t.to.line).markedSpans;if(!n&&!r)return null;var i=t.from.ch,o=t.to.ch,l=0==st(t.from,t.to),s=function(e,t,n){var r;if(e)for(var i=0;i<e.length;++i){var o,l=e[i],s=l.marker;!(null==l.from||(s.inclusiveLeft?l.from<=t:l.from<t))&&(l.from!=t||"bookmark"!=s.type||n&&l.marker.insertLeft)||(o=null==l.to||(s.inclusiveRight?l.to>=t:l.to>t),(r=r||[]).push(new At(s,l.from,o?null:l.to)))}return r}(n,i,l),a=function(e,t,n){var r;if(e)for(var i=0;i<e.length;++i){var o,l=e[i],s=l.marker;!(null==l.to||(s.inclusiveRight?l.to>=t:l.to>t))&&(l.from!=t||"bookmark"!=s.type||n&&!l.marker.insertLeft)||(o=null==l.from||(s.inclusiveLeft?l.from<=t:l.from<t),(r=r||[]).push(new At(s,o?null:l.from-t,null==l.to?null:l.to-t)))}return r}(r,o,l),u=1==t.text.length,c=$(t.text).length+(u?i:0);if(s)for(var h=0;h<s.length;++h){var d,f=s[h];null==f.to&&((d=Ot(a,f.marker))?u&&(f.to=null==d.to?null:d.to+c):f.to=i)}if(a)for(var p=0;p<a.length;++p){var g=a[p];null!=g.to&&(g.to+=c),null==g.from?Ot(s,g.marker)||(g.from=c,u&&(s=s||[]).push(g)):(g.from+=c,u&&(s=s||[]).push(g))}s=s&&Wt(s),a&&a!=s&&(a=Wt(a));var m=[s];if(!u){var v,y=t.text.length-2;if(0<y&&s)for(var b=0;b<s.length;++b)null==s[b].to&&(v=v||[]).push(new At(s[b].marker,null,null));for(var w=0;w<y;++w)m.push(v);m.push(a)}return m}function Wt(e){for(var t=0;t<e.length;++t){var n=e[t];null!=n.from&&n.from==n.to&&!1!==n.marker.clearWhenEmpty&&e.splice(t--,1)}return e.length?e:null}function Ht(e){var t=e.markedSpans;if(t){for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}}function Ft(e,t){if(t){for(var n=0;n<t.length;++n)t[n].marker.attachLine(e);e.markedSpans=t}}function Pt(e){return e.inclusiveLeft?-1:0}function Et(e){return e.inclusiveRight?1:0}function It(e,t){var n=e.lines.length-t.lines.length;if(0!=n)return n;var r=e.find(),i=t.find(),o=st(r.from,i.from)||Pt(e)-Pt(t);if(o)return-o;var l=st(r.to,i.to)||Et(e)-Et(t);return l||t.id-e.id}function Rt(e,t){var n,r=Nt&&e.markedSpans;if(r)for(var i=void 0,o=0;o<r.length;++o)(i=r[o]).marker.collapsed&&null==(t?i.from:i.to)&&(!n||It(n,i.marker)<0)&&(n=i.marker);return n}function zt(e){return Rt(e,!0)}function Bt(e){return Rt(e,!1)}function Gt(e,t,n,r,i){var o=Qe(e,t),l=Nt&&o.markedSpans;if(l)for(var s=0;s<l.length;++s){var a=l[s];if(a.marker.collapsed){var u=a.marker.find(0),c=st(u.from,n)||Pt(a.marker)-Pt(i),h=st(u.to,r)||Et(a.marker)-Et(i);if(!(0<=c&&h<=0||c<=0&&0<=h)&&(c<=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?0<=st(u.to,n):0<st(u.to,n))||0<=c&&(a.marker.inclusiveRight&&i.inclusiveLeft?st(u.from,r)<=0:st(u.from,r)<0)))return 1}}}function Ut(e){for(var t;t=zt(e);)e=t.find(-1,!0).line;return e}function Vt(e,t){var n=Qe(e,t),r=Ut(n);return n==r?t:nt(r)}function Kt(e,t){if(t>e.lastLine())return t;var n,r=Qe(e,t);if(!jt(e,r))return t;for(;n=Bt(r);)r=n.find(1,!0).line;return nt(r)+1}function jt(e,t){var n=Nt&&t.markedSpans;if(n)for(var r=void 0,i=0;i<n.length;++i)if((r=n[i]).marker.collapsed){if(null==r.from)return!0;if(!r.marker.widgetNode&&0==r.from&&r.marker.inclusiveLeft&&function e(t,n,r){if(null==r.to){var i=r.marker.find(1,!0);return e(t,i.line,Ot(i.line.markedSpans,r.marker))}if(r.marker.inclusiveRight&&r.to==n.text.length)return!0;for(var o=void 0,l=0;l<n.markedSpans.length;++l)if((o=n.markedSpans[l]).marker.collapsed&&!o.marker.widgetNode&&o.from==r.to&&(null==o.to||o.to!=r.from)&&(o.marker.inclusiveLeft||r.marker.inclusiveRight)&&e(t,n,o))return!0}(e,t,r))return!0}}function Xt(e){for(var t=0,n=(e=Ut(e)).parent,r=0;r<n.lines.length;++r){var i=n.lines[r];if(i==e)break;t+=i.height}for(var o=n.parent;o;o=(n=o).parent)for(var l=0;l<o.children.length;++l){var s=o.children[l];if(s==n)break;t+=s.height}return t}function Yt(e){if(0==e.height)return 0;for(var t,n=e.text.length,r=e;t=zt(r);){var i=t.find(0,!0),r=i.from.line;n+=i.from.ch-i.to.ch}for(r=e;t=Bt(r);){var o=t.find(0,!0);n-=r.text.length-o.from.ch,n+=(r=o.to.line).text.length-o.to.ch}return n}function _t(e){var n=e.display,t=e.doc;n.maxLine=Qe(t,t.first),n.maxLineLength=Yt(n.maxLine),n.maxLineChanged=!0,t.iter(function(e){var t=Yt(e);t>n.maxLineLength&&(n.maxLineLength=t,n.maxLine=e)})}var $t=function(e,t,n){this.text=e,Ft(this,t),this.height=n?n(this):1};$t.prototype.lineNo=function(){return nt(this)},Me($t);var qt={},Zt={};function Qt(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?Zt:qt;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Jt(e,t){var n=A("span",null,null,v?"padding-right: .1px":null),r={pre:A("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i,o=0;o<=(t.rest?t.rest.length:0);o++){var l=o?t.rest[o-1]:t.line,s=void 0;r.pos=0,r.addToken=tn,function(e){if(null!=Pe)return Pe;var t=N(e,document.createTextNode("AخA")),n=k(t,0,1).getBoundingClientRect(),r=k(t,1,2).getBoundingClientRect();return M(e),n&&n.left!=n.right&&(Pe=r.right-n.right<3)}(e.display.measure)&&(s=ye(l,e.doc.direction))&&(r.addToken=function(h,d){return function(e,t,n,r,i,o,l){n=n?n+" cm-force-border":"cm-force-border";for(var s=e.pos,a=s+t.length;;){for(var u=void 0,c=0;c<d.length&&!((u=d[c]).to>s&&u.from<=s);c++);if(u.to>=a)return h(e,t,n,r,i,o,l);h(e,t.slice(0,u.to-s),n,r,null,o,l),r=null,t=t.slice(u.to-s),s=u.to}}}(r.addToken,s)),r.map=[],function(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(!r){for(var l=1;l<n.length;l+=2)t.addToken(t,i.slice(o,o=n[l]),Qt(n[l+1],t.cm.options));return}for(var s,a,u,c,h,d,f,p=i.length,g=0,m=1,v="",y=0;;){if(y==g){u=c=h=a="",d=f=null,y=1/0;for(var b=[],w=void 0,x=0;x<r.length;++x){var C=r[x],S=C.marker;if("bookmark"==S.type&&C.from==g&&S.widgetNode)b.push(S);else if(C.from<=g&&(null==C.to||C.to>g||S.collapsed&&C.to==g&&C.from==g)){if(null!=C.to&&C.to!=g&&y>C.to&&(y=C.to,c=""),S.className&&(u+=" "+S.className),S.css&&(a=(a?a+";":"")+S.css),S.startStyle&&C.from==g&&(h+=" "+S.startStyle),S.endStyle&&C.to==y&&(w=w||[]).push(S.endStyle,C.to),S.title&&((f=f||{}).title=S.title),S.attributes)for(var L in S.attributes)(f=f||{})[L]=S.attributes[L];S.collapsed&&(!d||It(d.marker,S)<0)&&(d=C)}else C.from>g&&y>C.from&&(y=C.from)}if(w)for(var k=0;k<w.length;k+=2)w[k+1]==y&&(c+=" "+w[k]);if(!d||d.from==g)for(var T=0;T<b.length;++T)nn(t,0,b[T]);if(d&&(d.from||0)==g){if(nn(t,(null==d.to?p+1:d.to)-g,d.marker,null==d.from),null==d.to)return;d.to==g&&(d=!1)}}if(p<=g)break;for(var M=Math.min(p,y);;){if(v){var N,A=g+v.length;if(d||(N=M<A?v.slice(0,M-g):v,t.addToken(t,N,s?s+u:u,h,g+N.length==y?c:"",a,f)),M<=A){v=v.slice(M-g),g=M;break}g=A,h=""}v=i.slice(o,o=n[m++]),s=Qt(n[m++],t.cm.options)}}}(l,r,yt(e,l,t!=e.display.externalMeasured&&nt(l))),l.styleClasses&&(l.styleClasses.bgClass&&(r.bgClass=F(l.styleClasses.bgClass,r.bgClass||"")),l.styleClasses.textClass&&(r.textClass=F(l.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(function(e){var t;null==Fe&&(t=O("span",""),N(e,O("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Fe=t.offsetWidth<=1&&2<t.offsetHeight&&!(x&&C<8)));var n=Fe?O("span",""):O("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}(e.display.measure))),0==o?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}return v&&(i=r.content.lastChild,(/\bcm-tab\b/.test(i.className)||i.querySelector&&i.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")),Se(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=F(r.pre.className,r.textClass||"")),r}function en(e){var t=O("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function tn(e,t,n,r,i,o,l){if(t){var s,a=e.splitSpaces?function(e,t){if(1<e.length&&!/ /.test(e))return e;for(var n=t,r="",i=0;i<e.length;i++){var o=e.charAt(i);" "!=o||!n||i!=e.length-1&&32!=e.charCodeAt(i+1)||(o=" "),r+=o,n=" "==o}return r}(t,e.trailingSpace):t,u=e.cm.state.specialChars,c=!1;if(u.test(t)){s=document.createDocumentFragment();for(var h=0;;){u.lastIndex=h;var d,f=u.exec(t),p=f?f.index-h:t.length-h;if(p&&(d=document.createTextNode(a.slice(h,h+p)),x&&C<9?s.appendChild(O("span",[d])):s.appendChild(d),e.map.push(e.pos,e.pos+p,d),e.col+=p,e.pos+=p),!f)break;h+=1+p;var g,m,v=void 0;"\t"==f[0]?(m=(g=e.cm.options.tabSize)-e.col%g,(v=s.appendChild(O("span",_(m),"cm-tab"))).setAttribute("role","presentation"),v.setAttribute("cm-text","\t"),e.col+=m):("\r"==f[0]||"\n"==f[0]?(v=s.appendChild(O("span","\r"==f[0]?"␍":"␤","cm-invalidchar"))).setAttribute("cm-text",f[0]):((v=e.cm.options.specialCharPlaceholder(f[0])).setAttribute("cm-text",f[0]),x&&C<9?s.appendChild(O("span",[v])):s.appendChild(v)),e.col+=1),e.map.push(e.pos,e.pos+1,v),e.pos++}}else e.col+=t.length,s=document.createTextNode(a),e.map.push(e.pos,e.pos+t.length,s),x&&C<9&&(c=!0),e.pos+=t.length;if(e.trailingSpace=32==a.charCodeAt(t.length-1),n||r||i||c||o||l){var y=n||"";r&&(y+=r),i&&(y+=i);var b=O("span",[s],y,o);if(l)for(var w in l)l.hasOwnProperty(w)&&"style"!=w&&"class"!=w&&b.setAttribute(w,l[w]);return e.content.appendChild(b)}e.content.appendChild(s)}}function nn(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i=i||e.content.appendChild(document.createElement("span"))).setAttribute("cm-marker",n.id),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function rn(e,t,n){this.line=t,this.rest=function(e){for(var t,n;t=Bt(e);)e=t.find(1,!0).line,(n=n||[]).push(e);return n}(t),this.size=this.rest?nt($(this.rest))-n+1:1,this.node=this.text=null,this.hidden=jt(e,t)}function on(e,t,n){for(var r=[],i=t;i<n;i=l){var o=new rn(e.doc,Qe(e.doc,i),i),l=i+o.size;r.push(o)}return r}var ln=null;function sn(e,t){var n=e.ownsGroup;if(n)try{!function(e){var t=e.delayedCallbacks,n=0;do{for(;n<t.length;n++)t[n].call(null);for(var r=0;r<e.ops.length;r++){var i=e.ops[r];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(n<t.length)}(n)}finally{ln=null,t(n)}}var an=null;function un(e,t){var n=xe(e,t);if(n.length){var r,i=Array.prototype.slice.call(arguments,2);ln?r=ln.delayedCallbacks:an?r=an:(r=an=[],setTimeout(cn,0));for(var o=0;o<n.length;++o)!function(e){r.push(function(){return n[e].apply(null,i)})}(o)}}function cn(){var e=an;an=null;for(var t=0;t<e.length;++t)e[t]()}function hn(e,t,n,r){for(var i=0;i<t.changes.length;i++){var o=t.changes[i];"text"==o?function(e,t){var n=t.text.className,r=fn(e,t);t.text==t.node&&(t.node=r.pre);t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,pn(e,t)):n&&(t.text.className=n)}(e,t):"gutter"==o?gn(e,t,n,r):"class"==o?pn(e,t):"widget"==o&&function(e,t,n){t.alignable&&(t.alignable=null);for(var r=L("CodeMirror-linewidget"),i=t.node.firstChild,o=void 0;i;i=o)o=i.nextSibling,r.test(i.className)&&t.node.removeChild(i);mn(e,t,n)}(e,t,r)}t.changes=null}function dn(e){return e.node==e.text&&(e.node=O("div",null,null,"position: relative"),e.text.parentNode&&e.text.parentNode.replaceChild(e.node,e.text),e.node.appendChild(e.text),x&&C<8&&(e.node.style.zIndex=2)),e.node}function fn(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Jt(e,t)}function pn(e,t){var n,r,i,o;n=e,(o=(r=t).bgClass?r.bgClass+" "+(r.line.bgClass||""):r.line.bgClass)&&(o+=" CodeMirror-linebackground"),r.background?o?r.background.className=o:(r.background.parentNode.removeChild(r.background),r.background=null):o&&(i=dn(r),r.background=i.insertBefore(O("div",null,o),i.firstChild),n.display.input.setUneditable(r.background)),t.line.wrapClass?dn(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var l=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=l||""}function gn(e,t,n,r){var i;t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass&&(i=dn(t),t.gutterBackground=O("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),e.display.input.setUneditable(t.gutterBackground),i.insertBefore(t.gutterBackground,t.text));var o=t.line.gutterMarkers;if(e.options.lineNumbers||o){var l=dn(t),s=t.gutter=O("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(s),l.insertBefore(s,t.text),t.line.gutterClass&&(s.className+=" "+t.line.gutterClass),!e.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(t.lineNumber=s.appendChild(O("div",ot(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),o)for(var a=0;a<e.display.gutterSpecs.length;++a){var u=e.display.gutterSpecs[a].className,c=o.hasOwnProperty(u)&&o[u];c&&s.appendChild(O("div",[c],"CodeMirror-gutter-elt","left: "+r.gutterLeft[u]+"px; width: "+r.gutterWidth[u]+"px"))}}}function mn(e,t,n){if(vn(e,t.line,t,n,!0),t.rest)for(var r=0;r<t.rest.length;r++)vn(e,t.rest[r],t,n,!1)}function vn(e,t,n,r,i){if(t.widgets)for(var o=dn(n),l=0,s=t.widgets;l<s.length;++l){var a=s[l],u=O("div",[a.node],"CodeMirror-linewidget"+(a.className?" "+a.className:""));a.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),function(e,t,n,r){{var i;e.noHScroll&&((n.alignable||(n.alignable=[])).push(t),i=r.wrapperWidth,t.style.left=r.fixedPos+"px",e.coverGutter||(i-=r.gutterTotalWidth,t.style.paddingLeft=r.gutterTotalWidth+"px"),t.style.width=i+"px")}e.coverGutter&&(t.style.zIndex=5,t.style.position="relative",e.noHScroll||(t.style.marginLeft=-r.gutterTotalWidth+"px"))}(a,u,n,r),e.display.input.setUneditable(u),i&&a.above?o.insertBefore(u,n.gutter||n.text):o.appendChild(u),un(a,"redraw")}}function yn(e){if(null!=e.height)return e.height;var t,n=e.doc.cm;return n?(D(document.body,e.node)||(t="position: relative;",e.coverGutter&&(t+="margin-left: -"+n.display.gutters.offsetWidth+"px;"),e.noHScroll&&(t+="width: "+n.display.wrapper.clientWidth+"px;"),N(n.display.measure,O("div",[e.node],null,t))),e.height=e.node.parentNode.offsetHeight):0}function bn(e,t){for(var n=We(t);n!=e.wrapper;n=n.parentNode)if(!n||1==n.nodeType&&"true"==n.getAttribute("cm-ignore-events")||n.parentNode==e.sizer&&n!=e.mover)return 1}function wn(e){return e.lineSpace.offsetTop}function xn(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function Cn(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=N(e.measure,O("pre","x","CodeMirror-line-like")),n=window.getComputedStyle?window.getComputedStyle(t):t.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return isNaN(r.left)||isNaN(r.right)||(e.cachedPaddingH=r),r}function Sn(e){return G-e.display.nativeBarWidth}function Ln(e){return e.display.scroller.clientWidth-Sn(e)-e.display.barWidth}function kn(e){return e.display.scroller.clientHeight-Sn(e)-e.display.barHeight}function Tn(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;r<e.rest.length;r++)if(e.rest[r]==t)return{map:e.measure.maps[r],cache:e.measure.caches[r]};for(var i=0;i<e.rest.length;i++)if(nt(e.rest[i])>n)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Mn(e,t,n,r){return On(e,An(e,t),n,r)}function Nn(e,t){if(t>=e.display.viewFrom&&t<e.display.viewTo)return e.display.view[rr(e,t)];var n=e.display.externalMeasured;return n&&t>=n.lineN&&t<n.lineN+n.size?n:void 0}function An(e,t){var n=nt(t),r=Nn(e,n);r&&!r.text?r=null:r&&r.changes&&(hn(e,r,n,Qn(e)),e.curOp.forceUpdate=!0);var i=Tn(r=r||function(e,t){var n=nt(t=Ut(t)),r=e.display.externalMeasured=new rn(e.doc,t,n);r.lineN=n;var i=r.built=Jt(e,r);return r.text=i.pre,N(e.display.lineMeasure,i.pre),r}(e,t),t,n);return{line:t,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function On(e,t,n,r,i){t.before&&(n=-1);var o,l=n+(r||"");return t.cache.hasOwnProperty(l)?o=t.cache[l]:(t.rect||(t.rect=t.view.text.getBoundingClientRect()),t.hasHeights||(function(e,t,n){var r=e.options.lineWrapping,i=r&&Ln(e);if(!t.measure.heights||r&&t.measure.width!=i){var o=t.measure.heights=[];if(r){t.measure.width=i;for(var l=t.text.firstChild.getClientRects(),s=0;s<l.length-1;s++){var a=l[s],u=l[s+1];2<Math.abs(a.bottom-u.bottom)&&o.push((a.bottom+u.top)/2-n.top)}}o.push(n.bottom-n.top)}}(e,t.view,t.rect),t.hasHeights=!0),(o=function(e,t,n,r){var i,o,l=Hn(t.map,n,r),s=l.node,a=l.start,u=l.end,c=l.collapse;if(3==s.nodeType){for(var h=0;h<4;h++){for(;a&&ie(t.line.text.charAt(l.coverStart+a));)--a;for(;l.coverStart+u<l.coverEnd&&ie(t.line.text.charAt(l.coverStart+u));)++u;if((i=x&&C<9&&0==a&&u==l.coverEnd-l.coverStart?s.parentNode.getBoundingClientRect():function(e,t){var n=Wn;if("left"==t)for(var r=0;r<e.length&&(n=e[r]).left==n.right;r++);else for(var i=e.length-1;0<=i&&(n=e[i]).left==n.right;i--);return n}(k(s,a,u).getClientRects(),r)).left||i.right||0==a)break;u=a,--a,c="right"}x&&C<11&&(i=function(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!function(e){if(null!=Ge)return Ge;var t=N(e,O("span","x")),n=t.getBoundingClientRect(),r=k(t,0,1).getBoundingClientRect();return Ge=1<Math.abs(n.left-r.left)}(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}(e.display.measure,i))}else 0<a&&(c=r="right"),i=e.options.lineWrapping&&1<(o=s.getClientRects()).length?o["right"==r?o.length-1:0]:s.getBoundingClientRect();{var d;!(x&&C<9)||a||i&&(i.left||i.right)||(d=s.parentNode.getClientRects()[0],i=d?{left:d.left,right:d.left+Zn(e.display),top:d.top,bottom:d.bottom}:Wn)}for(var f=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(f+p)/2,m=t.view.measure.heights,v=0;v<m.length-1&&!(g<m[v]);v++);var y=v?m[v-1]:0,b=m[v],w={left:("right"==c?i.right:i.left)-t.rect.left,right:("left"==c?i.left:i.right)-t.rect.left,top:y,bottom:b};i.left||i.right||(w.bogus=!0);e.options.singleCursorHeightPerLine||(w.rtop=f,w.rbottom=p);return w}(e,t,n,r)).bogus||(t.cache[l]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}var Dn,Wn={left:0,right:0,top:0,bottom:0};function Hn(e,t,n){for(var r,i,o,l,s,a,u=0;u<e.length;u+=3)if(s=e[u],a=e[u+1],t<s?(i=0,o=1,l="left"):t<a?o=(i=t-s)+1:(u==e.length-3||t==a&&e[u+3]>t)&&(i=(o=a-s)-1,a<=t&&(l="right")),null!=i){if(r=e[u+2],s==a&&n==(r.insertLeft?"left":"right")&&(l=n),"left"==n&&0==i)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)r=e[2+(u-=3)],l="left";if("right"==n&&i==a-s)for(;u<e.length-3&&e[u+3]==e[u+4]&&!e[u+5].insertLeft;)r=e[(u+=3)+2],l="right";break}return{node:r,start:i,end:o,collapse:l,coverStart:s,coverEnd:a}}function Fn(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t<e.rest.length;t++)e.measure.caches[t]={}}function Pn(e){e.display.externalMeasure=null,M(e.display.lineMeasure);for(var t=0;t<e.display.view.length;t++)Fn(e.display.view[t])}function En(e){Pn(e),e.display.cachedCharWidth=e.display.cachedTextHeight=e.display.cachedPaddingH=null,e.options.lineWrapping||(e.display.maxLineChanged=!0),e.display.lineNumChars=null}function In(){return l&&h?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function Rn(){return l&&h?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function zn(e){var t=0;if(e.widgets)for(var n=0;n<e.widgets.length;++n)e.widgets[n].above&&(t+=yn(e.widgets[n]));return t}function Bn(e,t,n,r,i){var o;if(i||(o=zn(t),n.top+=o,n.bottom+=o),"line"==r)return n;r=r||"local";var l,s,a=Xt(t);return"local"==r?a+=wn(e.display):a-=e.display.viewOffset,"page"!=r&&"window"!=r||(a+=(l=e.display.lineSpace.getBoundingClientRect()).top+("window"==r?0:Rn()),s=l.left+("window"==r?0:In()),n.left+=s,n.right+=s),n.top+=a,n.bottom+=a,n}function Gn(e,t,n){if("div"==n)return t;var r,i=t.left,o=t.top;"page"==n?(i-=In(),o-=Rn()):"local"!=n&&n||(i+=(r=e.display.sizer.getBoundingClientRect()).left,o+=r.top);var l=e.display.lineSpace.getBoundingClientRect();return{left:i-l.left,top:o-l.top}}function Un(e,t,n,r,i){return Bn(e,r=r||Qe(e.doc,t.line),Mn(e,r,t.ch,i),n)}function Vn(r,e,i,o,l,s){function a(e,t){var n=On(r,l,e,t?"right":"left",s);return t?n.left=n.right:n.right=n.left,Bn(r,o,n,i)}o=o||Qe(r.doc,e.line),l=l||An(r,o);var u=ye(o,r.doc.direction),t=e.ch,n=e.sticky;if(t>=o.text.length?(t=o.text.length,n="before"):t<=0&&(t=0,n="after"),!u)return a("before"==n?t-1:t,"before"==n);function c(e,t,n){return a(n?e-1:e,1==u[t].level!=n)}var h=ae(u,t,n),d=se,f=c(t,h,"before"==n);return null!=d&&(f.other=c(t,d,"before"!=n)),f}function Kn(e,t){var n=0;t=ft(e.doc,t),e.options.lineWrapping||(n=Zn(e.display)*t.ch);var r=Qe(e.doc,t.line),i=Xt(r)+wn(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function jn(e,t,n,r,i){var o=lt(e,t,n);return o.xRel=i,r&&(o.outside=r),o}function Xn(e,t,n){var r=e.doc;if((n+=e.display.viewOffset)<0)return jn(r.first,0,null,-1,-1);var i=rt(r,n),o=r.first+r.size-1;if(o<i)return jn(r.first+r.size-1,Qe(r,o).text.length,null,1,1);t<0&&(t=0);for(var l=Qe(r,i);;){var s=function(n,e,t,r,i){i-=Xt(e);var o=An(n,e),l=zn(e),s=0,a=e.text.length,u=!0,c=ye(e,n.doc.direction);{var h;c&&(h=(n.options.lineWrapping?function(e,t,n,r,i,o,l){var s=Yn(e,t,r,l),a=s.begin,u=s.end;/\s/.test(t.text.charAt(u-1))&&u--;for(var c=null,h=null,d=0;d<i.length;d++){var f,p,g,m=i[d];m.from>=u||m.to<=a||(f=1!=m.level,p=On(e,r,f?Math.min(u,m.to)-1:Math.max(a,m.from)).right,g=p<o?o-p+1e9:p-o,(!c||g<h)&&(c=m,h=g))}c=c||i[i.length-1];c.from<a&&(c={from:a,to:c.to,level:c.level});c.to>u&&(c={from:c.from,to:u,level:c.level});return c}:function(r,i,o,l,s,a,u){var e=le(function(e){var t=s[e],n=1!=t.level;return $n(Vn(r,lt(o,n?t.to:t.from,n?"before":"after"),"line",i,l),a,u,!0)},0,s.length-1),t=s[e];{var n,c;0<e&&(n=1!=t.level,$n(c=Vn(r,lt(o,n?t.from:t.to,n?"after":"before"),"line",i,l),a,u,!0)&&c.top>u&&(t=s[e-1]))}return t})(n,e,t,o,c,r,i),u=1!=h.level,s=u?h.from:h.to-1,a=u?h.to:h.from-1)}var d,f,p=null,g=null,m=le(function(e){var t=On(n,o,e);return t.top+=l,t.bottom+=l,$n(t,r,i,!1)&&(t.top<=i&&t.left<=r&&(p=e,g=t),1)},s,a),v=!1;{var y,b,w;g?(y=r-g.left<g.right-r,m=p+((b=y==u)?0:1),f=b?"after":"before",d=y?g.left:g.right):(u||m!=a&&m!=s||m++,f=0==m||m!=e.text.length&&On(n,o,m-(u?1:0)).bottom+l<=i==u?"after":"before",w=Vn(n,lt(t,m,f),"line",e,o),d=w.left,v=i<w.top?-1:i>=w.bottom?1:0)}return m=oe(e.text,m,1),jn(t,m,f,v,r-d)}(e,l,i,t,n),a=function(e,t){var n,r=Nt&&e.markedSpans;if(r)for(var i=0;i<r.length;++i){var o=r[i];o.marker.collapsed&&(null==o.from||o.from<t)&&(null==o.to||o.to>t)&&(!n||It(n,o.marker)<0)&&(n=o.marker)}return n}(l,s.ch+(0<s.xRel||0<s.outside?1:0));if(!a)return s;var u=a.find(1);if(u.line==i)return u;l=Qe(r,i=u.line)}}function Yn(t,e,n,r){r-=zn(e);var i=e.text.length,o=le(function(e){return On(t,n,e-1).bottom<=r},i,0);return{begin:o,end:i=le(function(e){return On(t,n,e).top>r},o,i)}}function _n(e,t,n,r){return Yn(e,t,n=n||An(e,t),Bn(e,t,On(e,n,r),"line").top)}function $n(e,t,n,r){return!(e.bottom<=n)&&(e.top>n||(r?e.left:e.right)>t)}function qn(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==Dn){Dn=O("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)Dn.appendChild(document.createTextNode("x")),Dn.appendChild(O("br"));Dn.appendChild(document.createTextNode("x"))}N(e.measure,Dn);var n=Dn.offsetHeight/50;return 3<n&&(e.cachedTextHeight=n),M(e.measure),n||1}function Zn(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=O("span","xxxxxxxxxx"),n=O("pre",[t],"CodeMirror-line-like");N(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return 2<i&&(e.cachedCharWidth=i),i||10}function Qn(e){for(var t=e.display,n={},r={},i=t.gutters.clientLeft,o=t.gutters.firstChild,l=0;o;o=o.nextSibling,++l){var s=e.display.gutterSpecs[l].className;n[s]=o.offsetLeft+o.clientLeft+i,r[s]=o.clientWidth}return{fixedPos:Jn(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Jn(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function er(r){var i=qn(r.display),o=r.options.lineWrapping,l=o&&Math.max(5,r.display.scroller.clientWidth/Zn(r.display)-3);return function(e){if(jt(r.doc,e))return 0;var t=0;if(e.widgets)for(var n=0;n<e.widgets.length;n++)e.widgets[n].height&&(t+=e.widgets[n].height);return o?t+(Math.ceil(e.text.length/l)||1)*i:t+i}}function tr(e){var t=e.doc,n=er(e);t.iter(function(e){var t=n(e);t!=e.height&&tt(e,t)})}function nr(e,t,n,r){var i=e.display;if(!n&&"true"==We(t).getAttribute("cm-not-content"))return null;var o,l,s=i.lineSpace.getBoundingClientRect();try{o=t.clientX-s.left,l=t.clientY-s.top}catch(e){return null}var a,u,c=Xn(e,o,l);return r&&0<c.xRel&&(a=Qe(e.doc,c.line).text).length==c.ch&&(u=R(a,a.length,e.options.tabSize)-a.length,c=lt(c.line,Math.max(0,Math.round((o-Cn(e.display).left)/Zn(e.display))-u))),c}function rr(e,t){if(t>=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var n=e.display.view,r=0;r<n.length;r++)if((t-=n[r].size)<0)return r}function ir(e,t,n,r){null==t&&(t=e.doc.first),null==n&&(n=e.doc.first+e.doc.size),r=r||0;var i,o,l,s,a=e.display;r&&n<a.viewTo&&(null==a.updateLineNumbers||a.updateLineNumbers>t)&&(a.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=a.viewTo?Nt&&Vt(e.doc,t)<a.viewTo&&lr(e):n<=a.viewFrom?Nt&&Kt(e.doc,n+r)>a.viewFrom?lr(e):(a.viewFrom+=r,a.viewTo+=r):t<=a.viewFrom&&n>=a.viewTo?lr(e):t<=a.viewFrom?(i=sr(e,n,n+r,1))?(a.view=a.view.slice(i.index),a.viewFrom=i.lineN,a.viewTo+=r):lr(e):n>=a.viewTo?(o=sr(e,t,t,-1))?(a.view=a.view.slice(0,o.index),a.viewTo=o.lineN):lr(e):(l=sr(e,t,t,-1),s=sr(e,n,n+r,1),l&&s?(a.view=a.view.slice(0,l.index).concat(on(e,l.lineN,s.lineN)).concat(a.view.slice(s.index)),a.viewTo+=r):lr(e));var u=a.externalMeasured;u&&(n<u.lineN?u.lineN+=r:t<u.lineN+u.size&&(a.externalMeasured=null))}function or(e,t,n){e.curOp.viewChanged=!0;var r,i,o=e.display,l=e.display.externalMeasured;l&&t>=l.lineN&&t<l.lineN+l.size&&(o.externalMeasured=null),t<o.viewFrom||t>=o.viewTo||(null==(r=o.view[rr(e,t)]).node||-1==B(i=r.changes||(r.changes=[]),n)&&i.push(n))}function lr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function sr(e,t,n,r){var i,o=rr(e,t),l=e.display.view;if(!Nt||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var s=e.display.viewFrom,a=0;a<o;a++)s+=l[a].size;if(s!=t){if(0<r){if(o==l.length-1)return null;i=s+l[o].size-t,o++}else i=s-t;t+=i,n+=i}for(;Vt(e.doc,n)!=n;){if(o==(r<0?0:l.length-1))return null;n+=r*l[o-(r<0?1:0)].size,o+=r}return{index:o,lineN:n}}function ar(e){for(var t=e.display.view,n=0,r=0;r<t.length;r++){var i=t[r];i.hidden||i.node&&!i.changes||++n}return n}function ur(e){e.display.input.showSelection(e.display.input.prepareSelection())}function cr(e,t){void 0===t&&(t=!0);for(var n,r,i=e.doc,o={},l=o.cursors=document.createDocumentFragment(),s=o.selection=document.createDocumentFragment(),a=0;a<i.sel.ranges.length;a++){!t&&a==i.sel.primIndex||((n=i.sel.ranges[a]).from().line>=e.display.viewTo||n.to().line<e.display.viewFrom||(((r=n.empty())||e.options.showCursorWhenSelecting)&&hr(e,n.head,l),r||function(l,e,t){var n=l.display,r=l.doc,i=document.createDocumentFragment(),o=Cn(l.display),T=o.left,M=Math.max(n.sizerWidth,Ln(l)-n.sizer.offsetLeft)-o.right,N="ltr"==r.direction;function A(e,t,n,r){t<0&&(t=0),t=Math.round(t),r=Math.round(r),i.appendChild(O("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px;\n top: "+t+"px; width: "+(null==n?M-e:n)+"px;\n height: "+(r-t)+"px"))}function s(n,y,b){var w,x,o=Qe(r,n),C=o.text.length;function S(e,t){return Un(l,lt(n,e),"div",o,t)}function L(e,t,n){var r=_n(l,o,null,e),i="ltr"==t==("after"==n)?"left":"right";return S("after"==n?r.begin:r.end-(/\s/.test(o.text.charAt(r.end-1))?2:1),i)[i]}var k=ye(o,r.direction);return function(e,t,n,r){if(!e)return r(t,n,"ltr",0);for(var i=!1,o=0;o<e.length;++o){var l=e[o];(l.from<n&&l.to>t||t==n&&l.to==t)&&(r(Math.max(l.from,t),Math.min(l.to,n),1==l.level?"rtl":"ltr",o),i=!0)}i||r(t,n,"ltr")}(k,y||0,null==b?C:b,function(e,t,n,r){var i,o,l,s,a,u,c,h="ltr"==n,d=S(e,h?"left":"right"),f=S(t-1,h?"right":"left"),p=null==y&&0==e,g=null==b&&t==C,m=0==r,v=!k||r==k.length-1;f.top-d.top<=3?(i=(N?g:p)&&v,o=(N?p:g)&&m?T:(h?d:f).left,l=i?M:(h?f:d).right,A(o,d.top,l-o,d.bottom)):(c=h?(s=N&&p&&m?T:d.left,a=N?M:L(e,n,"before"),u=N?T:L(t,n,"after"),N&&g&&v?M:f.right):(s=N?L(e,n,"before"):T,a=!N&&p&&m?M:d.right,u=!N&&g&&v?T:f.left,N?L(t,n,"after"):M),A(s,d.top,a-s,d.bottom),d.bottom<f.top&&A(T,d.bottom,null,f.top),A(u,f.top,c-u,f.bottom)),(!w||dr(d,w)<0)&&(w=d),dr(f,w)<0&&(w=f),(!x||dr(d,x)<0)&&(x=d),dr(f,x)<0&&(x=f)}),{start:w,end:x}}var a=e.from(),u=e.to();{var c,h,d,f,p;a.line==u.line?s(a.line,a.ch,u.ch):(c=Qe(r,a.line),h=Qe(r,u.line),d=Ut(c)==Ut(h),f=s(a.line,a.ch,d?c.text.length+1:null).end,p=s(u.line,d?0:null,u.ch).start,d&&(f.top<p.top-2?(A(f.right,f.top,null,f.bottom),A(T,p.top,p.left,p.bottom)):A(f.right,f.top,p.left-f.right,f.bottom)),f.bottom<p.top&&A(T,f.bottom,null,p.top))}t.appendChild(i)}(e,n,s)))}return o}function hr(e,t,n){var r,i=Vn(e,t,"div",null,null,!e.options.singleCursorHeightPerLine),o=n.appendChild(O("div"," ","CodeMirror-cursor"));o.style.left=i.left+"px",o.style.top=i.top+"px",o.style.height=Math.max(0,i.bottom-i.top)*e.options.cursorHeight+"px",i.other&&((r=n.appendChild(O("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"))).style.display="",r.style.left=i.other.left+"px",r.style.top=i.other.top+"px",r.style.height=.85*(i.other.bottom-i.other.top)+"px")}function dr(e,t){return e.top-t.top||e.left-t.left}function fr(e){var t,n;e.state.focused&&(t=e.display,clearInterval(t.blinker),n=!0,t.cursorDiv.style.visibility="",0<e.options.cursorBlinkRate?t.blinker=setInterval(function(){e.hasFocus()||vr(e),t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden"))}function pr(e){e.state.focused||(e.display.input.focus(),mr(e))}function gr(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,vr(e))},100)}function mr(e,t){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Se(e,"focus",e,t),e.state.focused=!0,H(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),v&&setTimeout(function(){return e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),fr(e))}function vr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(Se(e,"blur",e,t),e.state.focused=!1,T(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function yr(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;r<t.view.length;r++){var i,o,l=t.view[r],s=e.options.lineWrapping,a=void 0,u=0;if(!l.hidden){x&&C<8?(a=(i=l.node.offsetTop+l.node.offsetHeight)-n,n=i):(a=(o=l.node.getBoundingClientRect()).bottom-o.top,!s&&l.text.firstChild&&(u=l.text.firstChild.getBoundingClientRect().right-o.left-1));var c,h=l.line.height-a;if((.005<h||h<-.005)&&(tt(l.line,a),br(l.line),l.rest))for(var d=0;d<l.rest.length;d++)br(l.rest[d]);u>e.display.sizerWidth&&((c=Math.ceil(u/Zn(e.display)))>e.display.maxLineLength&&(e.display.maxLineLength=c,e.display.maxLine=l.line,e.display.maxLineChanged=!0))}}}function br(e){if(e.widgets)for(var t=0;t<e.widgets.length;++t){var n=e.widgets[t],r=n.node.parentNode;r&&(n.height=r.offsetHeight)}}function wr(e,t,n){var r,i,o=n&&null!=n.top?Math.max(0,n.top):e.scroller.scrollTop,o=Math.floor(o-wn(e)),l=n&&null!=n.bottom?n.bottom:o+e.wrapper.clientHeight,s=rt(t,o),a=rt(t,l);return n&&n.ensure&&(r=n.ensure.from.line,i=n.ensure.to.line,r<s?a=rt(t,Xt(Qe(t,s=r))+e.wrapper.clientHeight):Math.min(i,t.lastLine())>=a&&(s=rt(t,Xt(Qe(t,i))-e.wrapper.clientHeight),a=i)),{from:s,to:Math.max(a,s+1)}}function xr(e,t){var n=e.display,r=qn(e.display);t.top<0&&(t.top=0);var i=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:n.scroller.scrollTop,o=kn(e),l={};t.bottom-t.top>o&&(t.bottom=t.top+o);var s,a=e.doc.height+xn(n),u=t.top<r,c=t.bottom>a-r;t.top<i?l.scrollTop=u?0:t.top:t.bottom>i+o&&((s=Math.min(t.top,(c?a:t.bottom)-o))!=i&&(l.scrollTop=s));var h=e.options.fixedGutter?0:n.gutters.offsetWidth,d=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft-h,f=Ln(e)-n.gutters.offsetWidth,p=t.right-t.left>f;return p&&(t.right=t.left+f),t.left<10?l.scrollLeft=0:t.left<d?l.scrollLeft=Math.max(0,t.left+h-(p?0:10)):t.right>f+d-3&&(l.scrollLeft=t.right+(p?0:10)-f),l}function Cr(e,t){null!=t&&(kr(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Sr(e){kr(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Lr(e,t,n){null==t&&null==n||kr(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function kr(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,Tr(e,Kn(e,t.from),Kn(e,t.to),t.margin))}function Tr(e,t,n,r){var i=xr(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-r,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+r});Lr(e,i.scrollLeft,i.scrollTop)}function Mr(e,t){Math.abs(e.doc.scrollTop-t)<2||(g||$r(e,{top:t}),Nr(e,t,!0),g&&$r(e),Kr(e,100))}function Nr(e,t,n){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),e.display.scroller.scrollTop==t&&!n||(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function Ar(e,t,n,r){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r||(e.doc.scrollLeft=t,Qr(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Or(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+xn(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+Sn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}function Dr(e,t,n){this.cm=n;var r=this.vert=O("div",[O("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=O("div",[O("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=i.tabIndex=-1,e(r),e(i),we(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),we(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,x&&C<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}Dr.prototype.update=function(e){var t,n,r=e.scrollWidth>e.clientWidth+1,i=e.scrollHeight>e.clientHeight+1,o=e.nativeBarWidth;return i?(this.vert.style.display="block",this.vert.style.bottom=r?o+"px":"0",t=e.viewHeight-(r?o:0),this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+t)+"px"):(this.vert.style.display="",this.vert.firstChild.style.height="0"),r?(this.horiz.style.display="block",this.horiz.style.right=i?o+"px":"0",this.horiz.style.left=e.barLeft+"px",n=e.viewWidth-e.barLeft-(i?o:0),this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+n)+"px"):(this.horiz.style.display="",this.horiz.firstChild.style.width="0"),!this.checkedZeroWidth&&0<e.clientHeight&&(0==o&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:i?o:0,bottom:r?o:0}},Dr.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Dr.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Dr.prototype.zeroWidthHack=function(){var e=y&&!s?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new z,this.disableVert=new z},Dr.prototype.enableZeroWidthBar=function(n,r,i){n.style.pointerEvents="auto",r.set(1e3,function e(){var t=n.getBoundingClientRect();("vert"==i?document.elementFromPoint(t.right-1,(t.top+t.bottom)/2):document.elementFromPoint((t.right+t.left)/2,t.bottom-1))!=n?n.style.pointerEvents="none":r.set(1e3,e)})},Dr.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};function Wr(){}function Hr(e,t){t=t||Or(e);var n=e.display.barWidth,r=e.display.barHeight;Fr(e,t);for(var i=0;i<4&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&yr(e),Fr(e,Or(e)),n=e.display.barWidth,r=e.display.barHeight}function Fr(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}Wr.prototype.update=function(){return{bottom:0,right:0}},Wr.prototype.setScrollLeft=function(){},Wr.prototype.setScrollTop=function(){},Wr.prototype.clear=function(){};var Pr={native:Dr,null:Wr};function Er(n){n.display.scrollbars&&(n.display.scrollbars.clear(),n.display.scrollbars.addClass&&T(n.display.wrapper,n.display.scrollbars.addClass)),n.display.scrollbars=new Pr[n.options.scrollbarStyle](function(e){n.display.wrapper.insertBefore(e,n.display.scrollbarFiller),we(e,"mousedown",function(){n.state.focused&&setTimeout(function(){return n.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,t){("horizontal"==t?Ar:Mr)(n,e)},n),n.display.scrollbars.addClass&&H(n.display.wrapper,n.display.scrollbars.addClass)}var Ir=0;function Rr(e){var t;e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Ir},t=e.curOp,ln?ln.ops.push(t):t.ownsGroup=ln={ops:[t],delayedCallbacks:[]}}function zr(e){var t=e.curOp;t&&sn(t,function(e){for(var t=0;t<e.ops.length;t++)e.ops[t].cm.curOp=null;!function(e){for(var t=e.ops,n=0;n<t.length;n++)!function(e){var t=e.cm,n=t.display;(function(e){var t=e.display;!t.scrollbarsClipped&&t.scroller.offsetWidth&&(t.nativeBarWidth=t.scroller.offsetWidth-t.scroller.clientWidth,t.heightForcer.style.height=Sn(e)+"px",t.sizer.style.marginBottom=-t.nativeBarWidth+"px",t.sizer.style.borderRightWidth=Sn(e)+"px",t.scrollbarsClipped=!0)})(t),e.updateMaxLine&&_t(t);e.mustUpdate=e.viewChanged||e.forceUpdate||null!=e.scrollTop||e.scrollToPos&&(e.scrollToPos.from.line<n.viewFrom||e.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new Xr(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}(t[n]);for(var r=0;r<t.length;r++)!function(e){e.updatedDisplay=e.mustUpdate&&Yr(e.cm,e.update)}(t[r]);for(var i=0;i<t.length;i++)!function(e){var t=e.cm,n=t.display;e.updatedDisplay&&yr(t);e.barMeasure=Or(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Mn(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+Sn(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-Ln(t)));(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}(t[i]);for(var o=0;o<t.length;o++)!function(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft<t.doc.scrollLeft&&Ar(t,Math.min(t.display.scroller.scrollLeft,e.maxScrollLeft),!0),t.display.maxLineChanged=!1);var n=e.focus&&e.focus==W();e.preparedSelection&&t.display.input.showSelection(e.preparedSelection,n);!e.updatedDisplay&&e.startHeight==t.doc.height||Hr(t,e.barMeasure);e.updatedDisplay&&Zr(t,e.barMeasure);e.selectionChanged&&fr(t);t.state.focused&&e.updateInput&&t.display.input.reset(e.typing);n&&pr(e.cm)}(t[o]);for(var l=0;l<t.length;l++)!function(e){var t=e.cm,n=t.display,r=t.doc;e.updatedDisplay&&_r(t,e.update);null==n.wheelStartX||null==e.scrollTop&&null==e.scrollLeft&&!e.scrollToPos||(n.wheelStartX=n.wheelStartY=null);null!=e.scrollTop&&Nr(t,e.scrollTop,e.forceScroll);null!=e.scrollLeft&&Ar(t,e.scrollLeft,!0,!0);{var i;e.scrollToPos&&(i=function(e,t,n,r){null==r&&(r=0),e.options.lineWrapping||t!=n||(n="before"==(t=t.ch?lt(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t).sticky?lt(t.line,t.ch+1,"before"):t);for(var i=0;i<5;i++){var o,l=!1,s=Vn(e,t),a=n&&n!=t?Vn(e,n):s,u=xr(e,o={left:Math.min(s.left,a.left),top:Math.min(s.top,a.top)-r,right:Math.max(s.left,a.left),bottom:Math.max(s.bottom,a.bottom)+r}),c=e.doc.scrollTop,h=e.doc.scrollLeft;if(null!=u.scrollTop&&(Mr(e,u.scrollTop),1<Math.abs(e.doc.scrollTop-c)&&(l=!0)),null!=u.scrollLeft&&(Ar(e,u.scrollLeft),1<Math.abs(e.doc.scrollLeft-h)&&(l=!0)),!l)break}return o}(t,ft(r,e.scrollToPos.from),ft(r,e.scrollToPos.to),e.scrollToPos.margin),function(e,t){var n,r,i,o;Le(e,"scrollCursorIntoView")||(r=(n=e.display).sizer.getBoundingClientRect(),i=null,t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null==i||u||(o=O("div","",null,"position: absolute;\n top: "+(t.top-n.viewOffset-wn(e.display))+"px;\n height: "+(t.bottom-t.top+Sn(e)+n.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;"),e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)))}(t,i))}var o=e.maybeHiddenMarkers,l=e.maybeUnhiddenMarkers;if(o)for(var s=0;s<o.length;++s)o[s].lines.length||Se(o[s],"hide");if(l)for(var a=0;a<l.length;++a)l[a].lines.length&&Se(l[a],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=t.display.scroller.scrollTop);e.changeObjs&&Se(t,"changes",t,e.changeObjs);e.update&&e.update.finish()}(t[l])}(e)})}function Br(e,t){if(e.curOp)return t();Rr(e);try{return t()}finally{zr(e)}}function Gr(e,t){return function(){if(e.curOp)return t.apply(e,arguments);Rr(e);try{return t.apply(e,arguments)}finally{zr(e)}}}function Ur(e){return function(){if(this.curOp)return e.apply(this,arguments);Rr(this);try{return e.apply(this,arguments)}finally{zr(this)}}}function Vr(t){return function(){var e=this.cm;if(!e||e.curOp)return t.apply(this,arguments);Rr(e);try{return t.apply(this,arguments)}finally{zr(e)}}}function Kr(e,t){e.doc.highlightFrontier<e.display.viewTo&&e.state.highlight.set(t,E(jr,e))}function jr(a){var u,c,h,d=a.doc;d.highlightFrontier>=a.display.viewTo||(u=+new Date+a.options.workTime,c=bt(a,d.highlightFrontier),h=[],d.iter(c.line,Math.min(d.first+d.size,a.display.viewTo+500),function(e){if(c.line>=a.display.viewFrom){var t=e.styles,n=e.text.length>a.options.maxHighlightLength?_e(d.mode,c.state):null,r=vt(a,e,c,!0);n&&(c.state=n),e.styles=r.styles;var i=e.styleClasses,o=r.classes;o?e.styleClasses=o:i&&(e.styleClasses=null);for(var l=!t||t.length!=e.styles.length||i!=o&&(!i||!o||i.bgClass!=o.bgClass||i.textClass!=o.textClass),s=0;!l&&s<t.length;++s)l=t[s]!=e.styles[s];l&&h.push(c.line),e.stateAfter=c.save(),c.nextLine()}else e.text.length<=a.options.maxHighlightLength&&wt(a,e.text,c),e.stateAfter=c.line%5==0?c.save():null,c.nextLine();if(+new Date>u)return Kr(a,a.options.workDelay),!0}),d.highlightFrontier=c.line,d.modeFrontier=Math.max(d.modeFrontier,c.line),h.length&&Br(a,function(){for(var e=0;e<h.length;e++)or(a,h[e],"text")}))}var Xr=function(e,t,n){var r=e.display;this.viewport=t,this.visible=wr(r,e.doc,t),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=Ln(e),this.force=n,this.dims=Qn(e),this.events=[]};function Yr(e,t){var n=e.display,r=e.doc;if(t.editorIsHidden)return lr(e),!1;if(!t.force&&t.visible.from>=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==ar(e))return!1;Jr(e)&&(lr(e),t.dims=Qn(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),l=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFrom<o&&o-n.viewFrom<20&&(o=Math.max(r.first,n.viewFrom)),n.viewTo>l&&n.viewTo-l<20&&(l=Math.min(i,n.viewTo)),Nt&&(o=Vt(e.doc,o),l=Kt(e.doc,l));var s,a,u,c,h=o!=n.viewFrom||l!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;a=o,u=l,0==(c=(s=e).display).view.length||a>=c.viewTo||u<=c.viewFrom?(c.view=on(s,a,u),c.viewFrom=a):(c.viewFrom>a?c.view=on(s,a,c.viewFrom).concat(c.view):c.viewFrom<a&&(c.view=c.view.slice(rr(s,a))),c.viewFrom=a,c.viewTo<u?c.view=c.view.concat(on(s,c.viewTo,u)):c.viewTo>u&&(c.view=c.view.slice(0,rr(s,u)))),c.viewTo=u,n.viewOffset=Xt(Qe(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var d=ar(e);if(!h&&0==d&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var f,p,g,m=function(e){if(e.hasFocus())return null;var t=W();if(!t||!D(e.display.lineDiv,t))return null;var n,r={activeElt:t};return!window.getSelection||(n=window.getSelection()).anchorNode&&n.extend&&D(e.display.lineDiv,n.anchorNode)&&(r.anchorNode=n.anchorNode,r.anchorOffset=n.anchorOffset,r.focusNode=n.focusNode,r.focusOffset=n.focusOffset),r}(e);return 4<d&&(n.lineDiv.style.display="none"),function(n,e,t){var r=n.display,i=n.options.lineNumbers,o=r.lineDiv,l=o.firstChild;function s(e){var t=e.nextSibling;return v&&y&&n.display.currentWheelTarget==e?e.style.display="none":e.parentNode.removeChild(e),t}for(var a=r.view,u=r.viewFrom,c=0;c<a.length;c++){var h=a[c];if(!h.hidden)if(h.node&&h.node.parentNode==o){for(;l!=h.node;)l=s(l);var d=i&&null!=e&&e<=u&&h.lineNumber;h.changes&&(-1<B(h.changes,"gutter")&&(d=!1),hn(n,h,u,t)),d&&(M(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(ot(n.options,u)))),l=h.node.nextSibling}else{var f=function(e,t,n,r){var i=fn(e,t);return t.text=t.node=i.pre,i.bgClass&&(t.bgClass=i.bgClass),i.textClass&&(t.textClass=i.textClass),pn(e,t),gn(e,t,n,r),mn(e,t,r),t.node}(n,h,u,t);o.insertBefore(f,l)}u+=h.size}for(;l;)l=s(l)}(e,n.updateLineNumbers,t.dims),4<d&&(n.lineDiv.style.display=""),n.renderedView=n.view,(f=m)&&f.activeElt&&f.activeElt!=W()&&(f.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(f.activeElt.nodeName)&&f.anchorNode&&D(document.body,f.anchorNode)&&D(document.body,f.focusNode)&&(p=window.getSelection(),(g=document.createRange()).setEnd(f.anchorNode,f.anchorOffset),g.collapse(!1),p.removeAllRanges(),p.addRange(g),p.extend(f.focusNode,f.focusOffset))),M(n.cursorDiv),M(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,h&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,Kr(e,400)),!(n.updateLineNumbers=null)}function _r(e,t){for(var n=t.viewport,r=!0;;r=!1){if(r&&e.options.lineWrapping&&t.oldDisplayWidth!=Ln(e))r&&(t.visible=wr(e.display,e.doc,n));else if(n&&null!=n.top&&(n={top:Math.min(e.doc.height+xn(e.display)-kn(e),n.top)}),t.visible=wr(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!Yr(e,t))break;yr(e);var i=Or(e);ur(e),Hr(e,i),Zr(e,i),t.force=!1}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function $r(e,t){var n,r=new Xr(e,t);Yr(e,r)&&(yr(e),_r(e,r),n=Or(e),ur(e),Hr(e,n),Zr(e,n),r.finish())}function qr(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px"}function Zr(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+Sn(e)+"px"}function Qr(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=Jn(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",l=0;l<n.length;l++)if(!n[l].hidden){e.options.fixedGutter&&(n[l].gutter&&(n[l].gutter.style.left=o),n[l].gutterBackground&&(n[l].gutterBackground.style.left=o));var s=n[l].alignable;if(s)for(var a=0;a<s.length;a++)s[a].style.left=o}e.options.fixedGutter&&(t.gutters.style.left=r+i+"px")}}function Jr(e){if(e.options.lineNumbers){var t=e.doc,n=ot(e.options,t.first+t.size-1),r=e.display;if(n.length!=r.lineNumChars){var i=r.measure.appendChild(O("div",[O("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,l=i.offsetWidth-o;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(o,r.lineGutter.offsetWidth-l)+1,r.lineNumWidth=r.lineNumInnerWidth+l,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",qr(e.display),1}}}function ei(e,t){for(var n=[],r=!1,i=0;i<e.length;i++){var o=e[i],l=null;if("string"!=typeof o&&(l=o.style,o=o.className),"CodeMirror-linenumbers"==o){if(!t)continue;r=!0}n.push({className:o,style:l})}return t&&!r&&n.push({className:"CodeMirror-linenumbers",style:null}),n}function ti(e){var t=e.gutters,n=e.gutterSpecs;M(t),e.lineGutter=null;for(var r=0;r<n.length;++r){var i=n[r],o=i.className,l=i.style,s=t.appendChild(O("div",null,"CodeMirror-gutter "+o));l&&(s.style.cssText=l),"CodeMirror-linenumbers"==o&&((e.lineGutter=s).style.width=(e.lineNumWidth||1)+"px")}t.style.display=n.length?"":"none",qr(e)}function ni(e){ti(e.display),ir(e),Qr(e)}function ri(e,t,n,r){var i=this;this.input=n,i.scrollbarFiller=O("div",null,"CodeMirror-scrollbar-filler"),i.scrollbarFiller.setAttribute("cm-not-content","true"),i.gutterFiller=O("div",null,"CodeMirror-gutter-filler"),i.gutterFiller.setAttribute("cm-not-content","true"),i.lineDiv=A("div",null,"CodeMirror-code"),i.selectionDiv=O("div",null,null,"position: relative; z-index: 1"),i.cursorDiv=O("div",null,"CodeMirror-cursors"),i.measure=O("div",null,"CodeMirror-measure"),i.lineMeasure=O("div",null,"CodeMirror-measure"),i.lineSpace=A("div",[i.measure,i.lineMeasure,i.selectionDiv,i.cursorDiv,i.lineDiv],null,"position: relative; outline: none");var o=A("div",[i.lineSpace],"CodeMirror-lines");i.mover=O("div",[o],null,"position: relative"),i.sizer=O("div",[i.mover],"CodeMirror-sizer"),i.sizerWidth=null,i.heightForcer=O("div",null,null,"position: absolute; height: "+G+"px; width: 1px;"),i.gutters=O("div",null,"CodeMirror-gutters"),i.lineGutter=null,i.scroller=O("div",[i.sizer,i.heightForcer,i.gutters],"CodeMirror-scroll"),i.scroller.setAttribute("tabIndex","-1"),i.wrapper=O("div",[i.scrollbarFiller,i.gutterFiller,i.scroller],"CodeMirror"),x&&C<8&&(i.gutters.style.zIndex=-1,i.scroller.style.paddingRight=0),v||g&&d||(i.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(i.wrapper):e(i.wrapper)),i.viewFrom=i.viewTo=t.first,i.reportedViewFrom=i.reportedViewTo=t.first,i.view=[],i.renderedView=null,i.externalMeasured=null,i.viewOffset=0,i.lastWrapHeight=i.lastWrapWidth=0,i.updateLineNumbers=null,i.nativeBarWidth=i.barHeight=i.barWidth=0,i.scrollbarsClipped=!1,i.lineNumWidth=i.lineNumInnerWidth=i.lineNumChars=null,i.alignWidgets=!1,i.cachedCharWidth=i.cachedTextHeight=i.cachedPaddingH=null,i.maxLine=null,i.maxLineLength=0,i.maxLineChanged=!1,i.wheelDX=i.wheelDY=i.wheelStartX=i.wheelStartY=null,i.shift=!1,i.selForContextMenu=null,i.activeTouch=null,i.gutterSpecs=ei(r.gutters,r.lineNumbers),ti(i),n.init(i)}Xr.prototype.signal=function(e,t){Te(e,t)&&this.events.push(arguments)},Xr.prototype.finish=function(){for(var e=0;e<this.events.length;e++)Se.apply(null,this.events[e])};var ii=0,oi=null;function li(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==n&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:null==n&&(n=e.wheelDelta),{x:t,y:n}}function si(e){var t=li(e);return t.x*=oi,t.y*=oi,t}function ai(e,t){var n,r,i,o=li(t),l=o.x,s=o.y,a=e.display,u=a.scroller,c=u.scrollWidth>u.clientWidth,h=u.scrollHeight>u.clientHeight;if(l&&c||s&&h){if(s&&y&&v)e:for(var d=t.target,f=a.view;d!=u;d=d.parentNode)for(var p=0;p<f.length;p++)if(f[p].node==d){e.display.currentWheelTarget=d;break e}if(l&&!g&&!m&&null!=oi)return s&&h&&Mr(e,Math.max(0,u.scrollTop+s*oi)),Ar(e,Math.max(0,u.scrollLeft+l*oi)),(!s||s&&h)&&Ne(t),void(a.wheelStartX=null);s&&null!=oi&&(n=s*oi,i=(r=e.doc.scrollTop)+a.wrapper.clientHeight,n<0?r=Math.max(0,r+n-50):i=Math.min(e.doc.height,i+n+50),$r(e,{top:r,bottom:i})),ii<20&&(null==a.wheelStartX?(a.wheelStartX=u.scrollLeft,a.wheelStartY=u.scrollTop,a.wheelDX=l,a.wheelDY=s,setTimeout(function(){var e,t,n;null!=a.wheelStartX&&(e=u.scrollLeft-a.wheelStartX,n=(t=u.scrollTop-a.wheelStartY)&&a.wheelDY&&t/a.wheelDY||e&&a.wheelDX&&e/a.wheelDX,a.wheelStartX=a.wheelStartY=null,n&&(oi=(oi*ii+n)/(ii+1),++ii))},200)):(a.wheelDX+=l,a.wheelDY+=s))}}x?oi=-.53:g?oi=15:l?oi=-.7:c&&(oi=-1/3);var ui=function(e,t){this.ranges=e,this.primIndex=t};ui.prototype.primary=function(){return this.ranges[this.primIndex]},ui.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],r=e.ranges[t];if(!at(n.anchor,r.anchor)||!at(n.head,r.head))return!1}return!0},ui.prototype.deepCopy=function(){for(var e=[],t=0;t<this.ranges.length;t++)e[t]=new ci(ut(this.ranges[t].anchor),ut(this.ranges[t].head));return new ui(e,this.primIndex)},ui.prototype.somethingSelected=function(){for(var e=0;e<this.ranges.length;e++)if(!this.ranges[e].empty())return!0;return!1},ui.prototype.contains=function(e,t){t=t||e;for(var n=0;n<this.ranges.length;n++){var r=this.ranges[n];if(0<=st(t,r.from())&&st(e,r.to())<=0)return n}return-1};var ci=function(e,t){this.anchor=e,this.head=t};function hi(e,t,n){var r=e&&e.options.selectionsMayTouch,i=t[n];t.sort(function(e,t){return st(e.from(),t.from())}),n=B(t,i);for(var o=1;o<t.length;o++){var l,s,a,u=t[o],c=t[o-1],h=st(c.to(),u.from());(r&&!u.empty()?0<h:0<=h)&&(l=ht(c.from(),u.from()),s=ct(c.to(),u.to()),a=c.empty()?u.from()==u.head:c.from()==c.head,o<=n&&--n,t.splice(--o,2,new ci(a?s:l,a?l:s)))}return new ui(t,n)}function di(e,t){return new ui([new ci(e,t||e)],0)}function fi(e){return e.text?lt(e.from.line+e.text.length-1,$(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function pi(e,t){if(st(e,t.from)<0)return e;if(st(e,t.to)<=0)return fi(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=fi(t).ch-t.to.ch),lt(n,r)}function gi(e,t){for(var n=[],r=0;r<e.sel.ranges.length;r++){var i=e.sel.ranges[r];n.push(new ci(pi(i.anchor,t),pi(i.head,t)))}return hi(e.cm,n,e.sel.primIndex)}function mi(e,t,n){return e.line==t.line?lt(n.line,e.ch-t.ch+n.ch):lt(n.line+(e.line-t.line),e.ch)}function vi(e){e.doc.mode=je(e.options,e.doc.modeOption),yi(e)}function yi(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.modeFrontier=e.doc.highlightFrontier=e.doc.first,Kr(e,100),e.state.modeGen++,e.curOp&&ir(e)}function bi(e,t){return 0==t.from.ch&&0==t.to.ch&&""==$(t.text)&&(!e.cm||e.cm.options.wholeLineUpdateBefore)}function wi(e,r,t,i){function o(e){return t?t[e]:null}function n(e,t,n){!function(e,t,n,r){e.text=t,e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null),null!=e.order&&(e.order=null),Ht(e),Ft(e,n);var i=r?r(e):1;i!=e.height&&tt(e,i)}(e,t,n,i),un(e,"change",e,r)}function l(e,t){for(var n=[],r=e;r<t;++r)n.push(new $t(d[r],o(r),i));return n}var s,a,u,c=r.from,h=r.to,d=r.text,f=Qe(e,c.line),p=Qe(e,h.line),g=$(d),m=o(d.length-1),v=h.line-c.line;r.full?(e.insert(0,l(0,d.length)),e.remove(d.length,e.size-d.length)):bi(e,r)?(s=l(0,d.length-1),n(p,p.text,m),v&&e.remove(c.line,v),s.length&&e.insert(c.line,s)):f==p?1==d.length?n(f,f.text.slice(0,c.ch)+g+f.text.slice(h.ch),m):((a=l(1,d.length-1)).push(new $t(g+f.text.slice(h.ch),m,i)),n(f,f.text.slice(0,c.ch)+d[0],o(0)),e.insert(c.line+1,a)):1==d.length?(n(f,f.text.slice(0,c.ch)+d[0]+p.text.slice(h.ch),o(0)),e.remove(c.line+1,v)):(n(f,f.text.slice(0,c.ch)+d[0],o(0)),n(p,g+p.text.slice(h.ch),m),u=l(1,d.length-1),1<v&&e.remove(c.line+1,v-1),e.insert(c.line+1,u)),un(e,"change",e,r)}function xi(e,s,a){!function e(t,n,r){if(t.linked)for(var i=0;i<t.linked.length;++i){var o,l=t.linked[i];l.doc!=n&&(o=r&&l.sharedHist,a&&!o||(s(l.doc,o),e(l.doc,t,o)))}}(e,null,!0)}function Ci(e,t){if(t.cm)throw new Error("This document is already in use.");tr((e.doc=t).cm=e),vi(e),Si(e),e.options.lineWrapping||_t(e),e.options.mode=t.modeOption,ir(e)}function Si(e){("rtl"==e.doc.direction?H:T)(e.display.lineDiv,"CodeMirror-rtl")}function Li(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 ki(e,t){var n={from:ut(t.from),to:fi(t),text:Je(e,t.from,t.to)};return Oi(e,n,t.from.line,t.to.line+1),xi(e,function(e){return Oi(e,n,t.from.line,t.to.line+1),0},!0),n}function Ti(e){for(;e.length;){if(!$(e).ranges)break;e.pop()}}function Mi(e,t,n,r){var i=e.history;i.undone.length=0;var o,l,s,a=+new Date;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&i.lastModTime>a-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(o=(s=i).lastOp==r?(Ti(s.done),$(s.done)):s.done.length&&!$(s.done).ranges?$(s.done):1<s.done.length&&!s.done[s.done.length-2].ranges?(s.done.pop(),$(s.done)):void 0))l=$(o.changes),0==st(t.from,t.to)&&0==st(t.from,l.to)?l.to=fi(t):o.changes.push(ki(e,t));else{var u=$(i.done);for(u&&u.ranges||Ai(e.sel,i.done),o={changes:[ki(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=a,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,l||Se(e,"historyAdded")}function Ni(e,t,n,r){var i,o,l,s,a,u=e.history,c=r&&r.origin;n==u.lastSelOp||c&&u.lastSelOrigin==c&&(u.lastModTime==u.lastSelTime&&u.lastOrigin==c||(i=e,o=c,l=$(u.done),s=t,"*"==(a=o.charAt(0))||"+"==a&&l.ranges.length==s.ranges.length&&l.somethingSelected()==s.somethingSelected()&&new Date-i.history.lastSelTime<=(i.cm?i.cm.options.historyEventDelay:500)))?u.done[u.done.length-1]=t:Ai(t,u.done),u.lastSelTime=+new Date,u.lastSelOrigin=c,u.lastSelOp=n,r&&!1!==r.clearRedo&&Ti(u.undone)}function Ai(e,t){var n=$(t);n&&n.ranges&&n.equals(e)||t.push(e)}function Oi(t,n,e,r){var i=n["spans_"+t.id],o=0;t.iter(Math.max(t.first,e),Math.min(t.first+t.size,r),function(e){e.markedSpans&&((i=i||(n["spans_"+t.id]={}))[o]=e.markedSpans),++o})}function Di(e,t){var n=t["spans_"+e.id];if(!n)return null;for(var r=[],i=0;i<t.text.length;++i)r.push(function(e){if(!e)return null;for(var t,n=0;n<e.length;++n)e[n].marker.explicitlyCleared?t=t||e.slice(0,n):t&&t.push(e[n]);return t?t.length?t:null:e}(n[i]));return r}function Wi(e,t){var n=Di(e,t),r=Dt(e,t);if(!n)return r;if(!r)return n;for(var i=0;i<n.length;++i){var o=n[i],l=r[i];if(o&&l)e:for(var s=0;s<l.length;++s){for(var a=l[s],u=0;u<o.length;++u)if(o[u].marker==a.marker)continue e;o.push(a)}else l&&(n[i]=l)}return n}function Hi(e,t,n){for(var r=[],i=0;i<e.length;++i){var o=e[i];if(o.ranges)r.push(n?ui.prototype.deepCopy.call(o):o);else{var l=o.changes,s=[];r.push({changes:s});for(var a=0;a<l.length;++a){var u=l[a],c=void 0;if(s.push({from:u.from,to:u.to,text:u.text}),t)for(var h in u)(c=h.match(/^spans_(\d+)$/))&&-1<B(t,Number(c[1]))&&($(s)[h]=u[h],delete u[h])}}}return r}function Fi(e,t,n,r){if(r){var i,o=e.anchor;return n&&((i=st(t,o)<0)!=st(n,o)<0?(o=t,t=n):i!=st(t,n)<0&&(t=n)),new ci(o,t)}return new ci(n||t,t)}function Pi(e,t,n,r,i){null==i&&(i=e.cm&&(e.cm.display.shift||e.extend)),Bi(e,new ui([Fi(e.sel.primary(),t,n,i)],0),r)}function Ei(e,t,n){for(var r=[],i=e.cm&&(e.cm.display.shift||e.extend),o=0;o<e.sel.ranges.length;o++)r[o]=Fi(e.sel.ranges[o],t[o],null,i);Bi(e,hi(e.cm,r,e.sel.primIndex),n)}function Ii(e,t,n,r){var i=e.sel.ranges.slice(0);i[t]=n,Bi(e,hi(e.cm,i,e.sel.primIndex),r)}function Ri(e,t,n,r){Bi(e,di(t,n),r)}function zi(e,t,n){var r=e.history.done,i=$(r);i&&i.ranges?Gi(e,r[r.length-1]=t,n):Bi(e,t,n)}function Bi(e,t,n){Gi(e,t,n),Ni(e,e.sel,e.cm?e.cm.curOp.id:NaN,n)}function Gi(e,t,n){var r,i,o,l;(Te(e,"beforeSelectionChange")||e.cm&&Te(e.cm,"beforeSelectionChange"))&&(r=e,o=n,l={ranges:(i=t).ranges,update:function(e){this.ranges=[];for(var t=0;t<e.length;t++)this.ranges[t]=new ci(ft(r,e[t].anchor),ft(r,e[t].head))},origin:o&&o.origin},Se(r,"beforeSelectionChange",r,l),r.cm&&Se(r.cm,"beforeSelectionChange",r.cm,l),t=l.ranges!=i.ranges?hi(r.cm,l.ranges,l.ranges.length-1):i);var s=n&&n.bias||(st(t.primary().head,e.sel.primary().head)<0?-1:1);Ui(e,Ki(e,t,s,!0)),n&&!1===n.scroll||!e.cm||Sr(e.cm)}function Ui(e,t){t.equals(e.sel)||(e.sel=t,e.cm&&(e.cm.curOp.updateInput=1,e.cm.curOp.selectionChanged=!0,ke(e.cm)),un(e,"cursorActivity",e))}function Vi(e){Ui(e,Ki(e,e.sel,null,!1))}function Ki(e,t,n,r){for(var i,o=0;o<t.ranges.length;o++){var l=t.ranges[o],s=t.ranges.length==e.sel.ranges.length&&e.sel.ranges[o],a=Xi(e,l.anchor,s&&s.anchor,n,r),u=Xi(e,l.head,s&&s.head,n,r);!i&&a==l.anchor&&u==l.head||((i=i||t.ranges.slice(0,o))[o]=new ci(a,u))}return i?hi(e.cm,i,t.primIndex):t}function ji(e,t,n,r,i){var o=Qe(e,t.line);if(o.markedSpans)for(var l=0;l<o.markedSpans.length;++l){var s=o.markedSpans[l],a=s.marker,u="selectLeft"in a?!a.selectLeft:a.inclusiveLeft,c="selectRight"in a?!a.selectRight:a.inclusiveRight;if((null==s.from||(u?s.from<=t.ch:s.from<t.ch))&&(null==s.to||(c?s.to>=t.ch:s.to>t.ch))){if(i&&(Se(a,"beforeCursorEnter"),a.explicitlyCleared)){if(o.markedSpans){--l;continue}break}if(!a.atomic)continue;if(n){var h=a.find(r<0?1:-1),d=void 0;if((r<0?c:u)&&(h=Yi(e,h,-r,h&&h.line==t.line?o:null)),h&&h.line==t.line&&(d=st(h,n))&&(r<0?d<0:0<d))return ji(e,h,t,r,i)}var f=a.find(r<0?-1:1);return(r<0?u:c)&&(f=Yi(e,f,r,f.line==t.line?o:null)),f?ji(e,f,t,r,i):null}}return t}function Xi(e,t,n,r,i){var o=r||1,l=ji(e,t,n,o,i)||!i&&ji(e,t,n,o,!0)||ji(e,t,n,-o,i)||!i&&ji(e,t,n,-o,!0);return l||(e.cantEdit=!0,lt(e.first,0))}function Yi(e,t,n,r){return n<0&&0==t.ch?t.line>e.first?ft(e,lt(t.line-1)):null:0<n&&t.ch==(r||Qe(e,t.line)).text.length?t.line<e.first+e.size-1?lt(t.line+1,0):null:new lt(t.line,t.ch+n)}function _i(e){e.setSelection(lt(e.firstLine(),0),lt(e.lastLine()),V)}function $i(i,e,t){var o={canceled:!1,from:e.from,to:e.to,text:e.text,origin:e.origin,cancel:function(){return o.canceled=!0}};return t&&(o.update=function(e,t,n,r){e&&(o.from=ft(i,e)),t&&(o.to=ft(i,t)),n&&(o.text=n),void 0!==r&&(o.origin=r)}),Se(i,"beforeChange",i,o),i.cm&&Se(i.cm,"beforeChange",i.cm,o),o.canceled?(i.cm&&(i.cm.curOp.updateInput=2),null):{from:o.from,to:o.to,text:o.text,origin:o.origin}}function qi(e,t,n){if(e.cm){if(!e.cm.curOp)return Gr(e.cm,qi)(e,t,n);if(e.cm.state.suppressEdits)return}if(!(Te(e,"beforeChange")||e.cm&&Te(e.cm,"beforeChange"))||(t=$i(e,t,!0))){var r=Mt&&!n&&function(e,t,n){var r=null;if(e.iter(t.line,n.line+1,function(e){if(e.markedSpans)for(var t=0;t<e.markedSpans.length;++t){var n=e.markedSpans[t].marker;!n.readOnly||r&&-1!=B(r,n)||(r=r||[]).push(n)}}),!r)return null;for(var i=[{from:t,to:n}],o=0;o<r.length;++o)for(var l=r[o],s=l.find(0),a=0;a<i.length;++a){var u,c,h,d=i[a];st(d.to,s.from)<0||0<st(d.from,s.to)||(u=[a,1],c=st(d.from,s.from),h=st(d.to,s.to),(c<0||!l.inclusiveLeft&&!c)&&u.push({from:d.from,to:s.from}),(0<h||!l.inclusiveRight&&!h)&&u.push({from:s.to,to:d.to}),i.splice.apply(i,u),a+=u.length-3)}return i}(e,t.from,t.to);if(r)for(var i=r.length-1;0<=i;--i)Zi(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text,origin:t.origin});else Zi(e,t)}}function Zi(e,n){var t,r;1==n.text.length&&""==n.text[0]&&0==st(n.from,n.to)||(t=gi(e,n),Mi(e,n,t,e.cm?e.cm.curOp.id:NaN),eo(e,n,t,Dt(e,n)),r=[],xi(e,function(e,t){t||-1!=B(r,e.history)||(io(e.history,n),r.push(e.history)),eo(e,n,null,Dt(e,n))}))}function Qi(i,o,e){var t=i.cm&&i.cm.state.suppressEdits;if(!t||e){for(var l,n=i.history,r=i.sel,s="undo"==o?n.done:n.undone,a="undo"==o?n.undone:n.done,u=0;u<s.length&&(l=s[u],e?!l.ranges||l.equals(i.sel):l.ranges);u++);if(u!=s.length){for(n.lastOrigin=n.lastSelOrigin=null;;){if(!(l=s.pop()).ranges){if(t)return void s.push(l);break}if(Ai(l,a),e&&!l.equals(i.sel))return void Bi(i,l,{clearRedo:!1});r=l}var c=[];Ai(r,a),a.push({changes:c,generation:n.generation}),n.generation=l.generation||++n.maxGeneration;for(var h=Te(i,"beforeChange")||i.cm&&Te(i.cm,"beforeChange"),d=l.changes.length-1;0<=d;--d){var f=function(e){var n=l.changes[e];if(n.origin=o,h&&!$i(i,n,!1))return s.length=0,{};c.push(ki(i,n));var t=e?gi(i,n):$(s);eo(i,n,t,Wi(i,n)),!e&&i.cm&&i.cm.scrollIntoView({from:n.from,to:fi(n)});var r=[];xi(i,function(e,t){t||-1!=B(r,e.history)||(io(e.history,n),r.push(e.history)),eo(e,n,null,Wi(e,n))})}(d);if(f)return f.v}}}}function Ji(e,t){if(0!=t&&(e.first+=t,e.sel=new ui(q(e.sel.ranges,function(e){return new ci(lt(e.anchor.line+t,e.anchor.ch),lt(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){ir(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;r<n.viewTo;r++)or(e.cm,r,"gutter")}}function eo(e,t,n,r){if(e.cm&&!e.cm.curOp)return Gr(e.cm,eo)(e,t,n,r);var i,o;t.to.line<e.first?Ji(e,t.text.length-1-(t.to.line-t.from.line)):t.from.line>e.lastLine()||(t.from.line<e.first&&(Ji(e,i=t.text.length-1-(e.first-t.from.line)),t={from:lt(e.first,0),to:lt(t.to.line+i,t.to.ch),text:[$(t.text)],origin:t.origin}),o=e.lastLine(),t.to.line>o&&(t={from:t.from,to:lt(o,Qe(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Je(e,t.from,t.to),n=n||gi(e,t),e.cm?function(e,t,n){var r=e.doc,i=e.display,o=t.from,l=t.to,s=!1,a=o.line;e.options.lineWrapping||(a=nt(Ut(Qe(r,o.line))),r.iter(a,l.line+1,function(e){if(e==i.maxLine)return s=!0}));-1<r.sel.contains(t.from,t.to)&&ke(e);wi(r,t,n,er(e)),e.options.lineWrapping||(r.iter(a,o.line+t.text.length,function(e){var t=Yt(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0));(function(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontier<t-10)){for(var n=e.first,r=t-1;n<r;r--){var i=Qe(e,r).stateAfter;if(i&&(!(i instanceof gt)||r+i.lookAhead<t)){n=r+1;break}}e.highlightFrontier=Math.min(e.highlightFrontier,n)}})(r,o.line),Kr(e,400);var u=t.text.length-(l.line-o.line)-1;t.full?ir(e):o.line!=l.line||1!=t.text.length||bi(e.doc,t)?ir(e,o.line,l.line+1,u):or(e,o.line,"text");var c=Te(e,"changes"),h=Te(e,"change");{var d;(h||c)&&(d={from:o,to:l,text:t.text,removed:t.removed,origin:t.origin},h&&un(e,"change",e,d),c&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(d))}e.display.selForContextMenu=null}(e.cm,t,r):wi(e,t,r),Gi(e,n,V),e.cantEdit&&Xi(e,lt(e.firstLine(),0))&&(e.cantEdit=!1))}function to(e,t,n,r,i){var o;st(r=r||n,n)<0&&(n=(o=[r,n])[0],r=o[1]),"string"==typeof t&&(t=e.splitLines(t)),qi(e,{from:n,to:r,text:t,origin:i})}function no(e,t,n,r){n<e.line?e.line+=r:t<e.line&&(e.line=t,e.ch=0)}function ro(e,t,n,r){for(var i=0;i<e.length;++i){var o=e[i],l=!0;if(o.ranges){o.copied||((o=e[i]=o.deepCopy()).copied=!0);for(var s=0;s<o.ranges.length;s++)no(o.ranges[s].anchor,t,n,r),no(o.ranges[s].head,t,n,r)}else{for(var a=0;a<o.changes.length;++a){var u=o.changes[a];if(n<u.from.line)u.from=lt(u.from.line+r,u.from.ch),u.to=lt(u.to.line+r,u.to.ch);else if(t<=u.to.line){l=!1;break}}l||(e.splice(0,i+1),i=0)}}}function io(e,t){var n=t.from.line,r=t.to.line,i=t.text.length-(r-n)-1;ro(e.done,n,r,i),ro(e.undone,n,r,i)}function oo(e,t,n,r){var i=t,o=t;return"number"==typeof t?o=Qe(e,dt(e,t)):i=nt(t),null==i?null:(r(o,i)&&e.cm&&or(e.cm,i,n),o)}function lo(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}function so(e){this.children=e;for(var t=0,n=0,r=0;r<e.length;++r){var i=e[r];t+=i.chunkSize(),n+=i.height,i.parent=this}this.size=t,this.height=n,this.parent=null}ci.prototype.from=function(){return ht(this.anchor,this.head)},ci.prototype.to=function(){return ct(this.anchor,this.head)},ci.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},lo.prototype={chunkSize:function(){return this.lines.length},removeInner:function(e,t){for(var n,r=e,i=e+t;r<i;++r){var o=this.lines[r];this.height-=o.height,(n=o).parent=null,Ht(n),un(o,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;r<t.length;++r)t[r].parent=this},iterN:function(e,t,n){for(var r=e+t;e<r;++e)if(n(this.lines[e]))return!0}},so.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n,r=0;r<this.children.length;++r){var i=this.children[r],o=i.chunkSize();if(e<o){var l=Math.min(t,o-e),s=i.height;if(i.removeInner(e,l),this.height-=s-i.height,o==l&&(this.children.splice(r--,1),i.parent=null),0==(t-=l))break;e=0}else e-=o}this.size-t<25&&(1<this.children.length||!(this.children[0]instanceof lo))&&(n=[],this.collapse(n),this.children=[new lo(n)],this.children[0].parent=this)},collapse:function(e){for(var t=0;t<this.children.length;++t)this.children[t].collapse(e)},insertInner:function(e,t,n){this.size+=t.length,this.height+=n;for(var r=0;r<this.children.length;++r){var i=this.children[r],o=i.chunkSize();if(e<=o){if(i.insertInner(e,t,n),i.lines&&50<i.lines.length){for(var l=i.lines.length%25+25,s=l;s<i.lines.length;){var a=new lo(i.lines.slice(s,s+=25));i.height-=a.height,this.children.splice(++r,0,a),a.parent=this}i.lines=i.lines.slice(0,l),this.maybeSpill()}break}e-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var e=this;do{var t,n,r=new so(e.children.splice(e.children.length-5,5));e.parent?(e.size-=r.size,e.height-=r.height,t=B(e.parent.children,e),e.parent.children.splice(t+1,0,r)):(((n=new so(e.children)).parent=e).children=[n,r],e=n),r.parent=e.parent}while(10<e.children.length);e.parent.maybeSpill()}},iterN:function(e,t,n){for(var r=0;r<this.children.length;++r){var i=this.children[r],o=i.chunkSize();if(e<o){var l=Math.min(t,o-e);if(i.iterN(e,l,n))return!0;if(0==(t-=l))break;e=0}else e-=o}}};function ao(e,t,n){if(n)for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.doc=e,this.node=t}function uo(e,t,n){Xt(t)<(e.curOp&&e.curOp.scrollTop||e.doc.scrollTop)&&Cr(e,n)}ao.prototype.clear=function(){var e=this.doc.cm,t=this.line.widgets,n=this.line,r=nt(n);if(null!=r&&t){for(var i=0;i<t.length;++i)t[i]==this&&t.splice(i--,1);t.length||(n.widgets=null);var o=yn(this);tt(n,Math.max(0,n.height-o)),e&&(Br(e,function(){uo(e,n,-o),or(e,r,"widget")}),un(e,"lineWidgetCleared",e,this,r))}},ao.prototype.changed=function(){var e=this,t=this.height,n=this.doc.cm,r=this.line;this.height=null;var i=yn(this)-t;i&&(jt(this.doc,r)||tt(r,r.height+i),n&&Br(n,function(){n.curOp.forceUpdate=!0,uo(n,r,i),un(n,"lineWidgetChanged",n,e,nt(r))}))},Me(ao);var co=0,ho=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++co};function fo(t,r,i,e,n){if(e&&e.shared)return function(e,n,r,i,o){(i=I(i)).shared=!1;var l=[fo(e,n,r,i,o)],s=l[0],a=i.widgetNode;return xi(e,function(e){a&&(i.widgetNode=a.cloneNode(!0)),l.push(fo(e,ft(e,n),ft(e,r),i,o));for(var t=0;t<e.linked.length;++t)if(e.linked[t].isParent)return;s=$(l)}),new po(l,s)}(t,r,i,e,n);if(t.cm&&!t.cm.curOp)return Gr(t.cm,fo)(t,r,i,e,n);var o=new ho(t,n),l=st(r,i);if(e&&I(e,o,!1),0<l||0==l&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=A("span",[o.replacedWith],"CodeMirror-widget"),e.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),e.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(Gt(t,r.line,r,i,o)||r.line!=i.line&&Gt(t,i.line,r,i,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Nt=!0}o.addToHistory&&Mi(t,{from:r,to:i,origin:"markText"},t.sel,NaN);var s,a=r.line,u=t.cm;if(t.iter(a,i.line+1,function(e){var t,n;u&&o.collapsed&&!u.options.lineWrapping&&Ut(e)==u.display.maxLine&&(s=!0),o.collapsed&&a!=r.line&&tt(e,0),t=e,n=new At(o,a==r.line?r.ch:null,a==i.line?i.ch:null),t.markedSpans=t.markedSpans?t.markedSpans.concat([n]):[n],n.marker.attachLine(t),++a}),o.collapsed&&t.iter(r.line,i.line+1,function(e){jt(t,e)&&tt(e,0)}),o.clearOnEnter&&we(o,"beforeCursorEnter",function(){return o.clear()}),o.readOnly&&(Mt=!0,(t.history.done.length||t.history.undone.length)&&t.clearHistory()),o.collapsed&&(o.id=++co,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)ir(u,r.line,i.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(var c=r.line;c<=i.line;c++)or(u,c,"text");o.atomic&&Vi(u.doc),un(u,"markerAdded",u,o)}return o}ho.prototype.clear=function(){if(!this.explicitlyCleared){var e,t=this.doc.cm,n=t&&!t.curOp;n&&Rr(t),!Te(this,"clear")||(e=this.find())&&un(this,"clear",e.from,e.to);for(var r=null,i=null,o=0;o<this.lines.length;++o){var l=this.lines[o],s=Ot(l.markedSpans,this);t&&!this.collapsed?or(t,nt(l),"text"):t&&(null!=s.to&&(i=nt(l)),null!=s.from&&(r=nt(l))),l.markedSpans=function(e,t){for(var n,r=0;r<e.length;++r)e[r]!=t&&(n=n||[]).push(e[r]);return n}(l.markedSpans,s),null==s.from&&this.collapsed&&!jt(this.doc,l)&&t&&tt(l,qn(t.display))}if(t&&this.collapsed&&!t.options.lineWrapping)for(var a=0;a<this.lines.length;++a){var u=Ut(this.lines[a]),c=Yt(u);c>t.display.maxLineLength&&(t.display.maxLine=u,t.display.maxLineLength=c,t.display.maxLineChanged=!0)}null!=r&&t&&this.collapsed&&ir(t,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&Vi(t.doc)),t&&un(t,"markerCleared",t,this,r,i),n&&zr(t),this.parent&&this.parent.clear()}},ho.prototype.find=function(e,t){var n,r;null==e&&"bookmark"==this.type&&(e=1);for(var i=0;i<this.lines.length;++i){var o=this.lines[i],l=Ot(o.markedSpans,this);if(null!=l.from&&(n=lt(t?o:nt(o),l.from),-1==e))return n;if(null!=l.to&&(r=lt(t?o:nt(o),l.to),1==e))return r}return n&&{from:n,to:r}},ho.prototype.changed=function(){var o=this,l=this.find(-1,!0),s=this,a=this.doc.cm;l&&a&&Br(a,function(){var e,t,n=l.line,r=nt(l.line),i=Nn(a,r);i&&(Fn(i),a.curOp.selectionChanged=a.curOp.forceUpdate=!0),a.curOp.updateMaxLine=!0,jt(s.doc,n)||null==s.height||(e=s.height,s.height=null,(t=yn(s)-e)&&tt(n,n.height+t)),un(a,"markerChanged",a,o)})},ho.prototype.attachLine=function(e){var t;!this.lines.length&&this.doc.cm&&((t=this.doc.cm.curOp).maybeHiddenMarkers&&-1!=B(t.maybeHiddenMarkers,this)||(t.maybeUnhiddenMarkers||(t.maybeUnhiddenMarkers=[])).push(this)),this.lines.push(e)},ho.prototype.detachLine=function(e){var t;this.lines.splice(B(this.lines,e),1),!this.lines.length&&this.doc.cm&&((t=this.doc.cm.curOp).maybeHiddenMarkers||(t.maybeHiddenMarkers=[])).push(this)},Me(ho);var po=function(e,t){this.markers=e,this.primary=t;for(var n=0;n<e.length;++n)e[n].parent=this};function go(e){return e.findMarks(lt(e.first,0),e.clipPos(lt(e.lastLine())),function(e){return e.parent})}po.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var e=0;e<this.markers.length;++e)this.markers[e].clear();un(this,"clear")}},po.prototype.find=function(e,t){return this.primary.find(e,t)},Me(po);var mo=0,vo=function(e,t,n,r,i){if(!(this instanceof vo))return new vo(e,t,n,r,i);null==n&&(n=0),so.call(this,[new lo([new $t("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1;var o=lt(this.modeFrontier=this.highlightFrontier=n,0);this.sel=di(o),this.history=new Li(null),this.id=++mo,this.modeOption=t,this.lineSep=r,this.direction="rtl"==i?"rtl":"ltr",this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),wi(this,{from:o,to:o,text:e}),Bi(this,di(o),V)};vo.prototype=Q(so.prototype,{constructor:vo,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var n=0,r=0;r<t.length;++r)n+=t[r].height;this.insertInner(e-this.first,t,n)},remove:function(e,t){this.removeInner(e-this.first,t)},getValue:function(e){var t=et(this,this.first,this.first+this.size);return!1===e?t:t.join(e||this.lineSeparator())},setValue:Vr(function(e){var t=lt(this.first,0),n=this.first+this.size-1;qi(this,{from:t,to:lt(n,Qe(this,n).text.length),text:this.splitLines(e),origin:"setValue",full:!0},!0),this.cm&&Lr(this.cm,0,0),Bi(this,di(t),V)}),replaceRange:function(e,t,n,r){to(this,e,t=ft(this,t),n=n?ft(this,n):t,r)},getRange:function(e,t,n){var r=Je(this,ft(this,e),ft(this,t));return!1===n?r:r.join(n||this.lineSeparator())},getLine:function(e){var t=this.getLineHandle(e);return t&&t.text},getLineHandle:function(e){if(it(this,e))return Qe(this,e)},getLineNumber:nt,getLineHandleVisualStart:function(e){return"number"==typeof e&&(e=Qe(this,e)),Ut(e)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(e){return ft(this,e)},getCursor:function(e){var t=this.sel.primary(),n=null==e||"head"==e?t.head:"anchor"==e?t.anchor:"end"==e||"to"==e||!1===e?t.to():t.from();return n},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:Vr(function(e,t,n){Ri(this,ft(this,"number"==typeof e?lt(e,t||0):e),null,n)}),setSelection:Vr(function(e,t,n){Ri(this,ft(this,e),ft(this,t||e),n)}),extendSelection:Vr(function(e,t,n){Pi(this,ft(this,e),t&&ft(this,t),n)}),extendSelections:Vr(function(e,t){Ei(this,pt(this,e),t)}),extendSelectionsBy:Vr(function(e,t){Ei(this,pt(this,q(this.sel.ranges,e)),t)}),setSelections:Vr(function(e,t,n){if(e.length){for(var r=[],i=0;i<e.length;i++)r[i]=new ci(ft(this,e[i].anchor),ft(this,e[i].head));null==t&&(t=Math.min(e.length-1,this.sel.primIndex)),Bi(this,hi(this.cm,r,t),n)}}),addSelection:Vr(function(e,t,n){var r=this.sel.ranges.slice(0);r.push(new ci(ft(this,e),ft(this,t||e))),Bi(this,hi(this.cm,r,r.length-1),n)}),getSelection:function(e){for(var t=this.sel.ranges,n=0;n<t.length;n++)var r=Je(this,t[n].from(),t[n].to()),i=i?i.concat(r):r;return!1===e?i:i.join(e||this.lineSeparator())},getSelections:function(e){for(var t=[],n=this.sel.ranges,r=0;r<n.length;r++){var i=Je(this,n[r].from(),n[r].to());!1!==e&&(i=i.join(e||this.lineSeparator())),t[r]=i}return t},replaceSelection:function(e,t,n){for(var r=[],i=0;i<this.sel.ranges.length;i++)r[i]=e;this.replaceSelections(r,t,n||"+input")},replaceSelections:Vr(function(e,t,n){for(var r=[],i=this.sel,o=0;o<i.ranges.length;o++){var l=i.ranges[o];r[o]={from:l.from(),to:l.to(),text:this.splitLines(e[o]),origin:n}}for(var s=t&&"end"!=t&&function(e,t,n){for(var r=[],i=h=lt(e.first,0),o=0;o<t.length;o++){var l,s,a=t[o],u=mi(a.from,h,i),c=mi(fi(a),h,i),h=a.to,i=c;"around"==n?(s=st((l=e.sel.ranges[o]).head,l.anchor)<0,r[o]=new ci(s?c:u,s?u:c)):r[o]=new ci(u,u)}return new ui(r,e.sel.primIndex)}(this,r,t),a=r.length-1;0<=a;a--)qi(this,r[a]);s?zi(this,s):this.cm&&Sr(this.cm)}),undo:Vr(function(){Qi(this,"undo")}),redo:Vr(function(){Qi(this,"redo")}),undoSelection:Vr(function(){Qi(this,"undo",!0)}),redoSelection:Vr(function(){Qi(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,r=0;r<e.done.length;r++)e.done[r].ranges||++t;for(var i=0;i<e.undone.length;i++)e.undone[i].ranges||++n;return{undo:t,redo:n}},clearHistory:function(){var t=this;this.history=new Li(this.history.maxGeneration),xi(this,function(e){return e.history=t.history},!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(e){return e&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(e){return this.history.generation==(e||this.cleanGeneration)},getHistory:function(){return{done:Hi(this.history.done),undone:Hi(this.history.undone)}},setHistory:function(e){var t=this.history=new Li(this.history.maxGeneration);t.done=Hi(e.done.slice(0),null,!0),t.undone=Hi(e.undone.slice(0),null,!0)},setGutterMarker:Vr(function(e,n,r){return oo(this,e,"gutter",function(e){var t=e.gutterMarkers||(e.gutterMarkers={});return!(t[n]=r)&&ne(t)&&(e.gutterMarkers=null),1})}),clearGutter:Vr(function(t){var n=this;this.iter(function(e){e.gutterMarkers&&e.gutterMarkers[t]&&oo(n,e,"gutter",function(){return e.gutterMarkers[t]=null,ne(e.gutterMarkers)&&(e.gutterMarkers=null),1})})}),lineInfo:function(e){var t;if("number"==typeof e){if(!it(this,e))return null;if(!(e=Qe(this,t=e)))return null}else if(null==(t=nt(e)))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:Vr(function(e,n,r){return oo(this,e,"gutter"==n?"gutter":"class",function(e){var t="text"==n?"textClass":"background"==n?"bgClass":"gutter"==n?"gutterClass":"wrapClass";if(e[t]){if(L(r).test(e[t]))return;e[t]+=" "+r}else e[t]=r;return 1})}),removeLineClass:Vr(function(e,o,l){return oo(this,e,"gutter"==o?"gutter":"class",function(e){var t="text"==o?"textClass":"background"==o?"bgClass":"gutter"==o?"gutterClass":"wrapClass",n=e[t];if(n){if(null==l)e[t]=null;else{var r=n.match(L(l));if(!r)return;var i=r.index+r[0].length;e[t]=n.slice(0,r.index)+(r.index&&i!=n.length?" ":"")+n.slice(i)||null}return 1}})}),addLineWidget:Vr(function(e,t,n){return i=e,o=new ao(r=this,t,n),(l=r.cm)&&o.noHScroll&&(l.display.alignWidgets=!0),oo(r,i,"widget",function(e){var t,n=e.widgets||(e.widgets=[]);return null==o.insertAt?n.push(o):n.splice(Math.min(n.length-1,Math.max(0,o.insertAt)),0,o),o.line=e,l&&!jt(r,e)&&(t=Xt(e)<r.scrollTop,tt(e,e.height+yn(o)),t&&Cr(l,o.height),l.curOp.forceUpdate=!0),1}),l&&un(l,"lineWidgetAdded",l,o,"number"==typeof i?i:nt(i)),o;var r,i,o,l}),removeLineWidget:function(e){e.clear()},markText:function(e,t,n){return fo(this,ft(this,e),ft(this,t),n,n&&n.type||"range")},setBookmark:function(e,t){var n={replacedWith:t&&(null==t.nodeType?t.widget:t),insertLeft:t&&t.insertLeft,clearWhenEmpty:!1,shared:t&&t.shared,handleMouseEvents:t&&t.handleMouseEvents};return fo(this,e=ft(this,e),e,n,"bookmark")},findMarksAt:function(e){var t=[],n=Qe(this,(e=ft(this,e)).line).markedSpans;if(n)for(var r=0;r<n.length;++r){var i=n[r];(null==i.from||i.from<=e.ch)&&(null==i.to||i.to>=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(i,o,l){i=ft(this,i),o=ft(this,o);var s=[],a=i.line;return this.iter(i.line,o.line+1,function(e){var t=e.markedSpans;if(t)for(var n=0;n<t.length;n++){var r=t[n];null!=r.to&&a==i.line&&i.ch>=r.to||null==r.from&&a!=i.line||null!=r.from&&a==o.line&&r.from>=o.ch||l&&!l(r.marker)||s.push(r.marker.parent||r.marker)}++a}),s},getAllMarks:function(){var r=[];return this.iter(function(e){var t=e.markedSpans;if(t)for(var n=0;n<t.length;++n)null!=t[n].from&&r.push(t[n].marker)}),r},posFromIndex:function(n){var r,i=this.first,o=this.lineSeparator().length;return this.iter(function(e){var t=e.text.length+o;if(n<t)return r=n,!0;n-=t,++i}),ft(this,lt(i,r))},indexFromPos:function(e){var t=(e=ft(this,e)).ch;if(e.line<this.first||e.ch<0)return 0;var n=this.lineSeparator().length;return this.iter(this.first,e.line,function(e){t+=e.text.length+n}),t},copy:function(e){var t=new vo(et(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return t.scrollTop=this.scrollTop,t.scrollLeft=this.scrollLeft,t.sel=this.sel,t.extend=!1,e&&(t.history.undoDepth=this.history.undoDepth,t.setHistory(this.getHistory())),t},linkedDoc:function(e){e=e||{};var t=this.first,n=this.first+this.size;null!=e.from&&e.from>t&&(t=e.from),null!=e.to&&e.to<n&&(n=e.to);var r=new vo(et(this,t,n),e.mode||this.modeOption,t,this.lineSep,this.direction);return e.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:e.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:e.sharedHist}],function(e,t){for(var n=0;n<t.length;n++){var r,i=t[n],o=i.find(),l=e.clipPos(o.from),s=e.clipPos(o.to);st(l,s)&&(r=fo(e,l,s,i.primary,i.primary.type),i.markers.push(r),r.parent=i)}}(r,go(this)),r},unlinkDoc:function(e){if(e instanceof pl&&(e=e.doc),this.linked)for(var t=0;t<this.linked.length;++t){if(this.linked[t].doc==e){this.linked.splice(t,1),e.unlinkDoc(this),function(o){for(var e=0;e<o.length;e++)!function(e){var t=o[e],n=[t.primary.doc];xi(t.primary.doc,function(e){return n.push(e)});for(var r=0;r<t.markers.length;r++){var i=t.markers[r];-1==B(n,i.doc)&&(i.parent=null,t.markers.splice(r--,1))}}(e)}(go(this));break}}var n;e.history==this.history&&(n=[e.id],xi(e,function(e){return n.push(e.id)},!0),e.history=new Li(null),e.history.done=Hi(this.history.done,n),e.history.undone=Hi(this.history.undone,n))},iterLinkedDocs:function(e){xi(this,e)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(e){return this.lineSep?e.split(this.lineSep):Re(e)},lineSeparator:function(){return this.lineSep||"\n"},setDirection:Vr(function(e){var t;"rtl"!=e&&(e="ltr"),e!=this.direction&&(this.direction=e,this.iter(function(e){return e.order=null}),this.cm&&Br(t=this.cm,function(){Si(t),ir(t)}))})}),vo.prototype.eachLine=vo.prototype.iter;var yo=0;function bo(e){var r=this;if(wo(r),!Le(r,e)&&!bn(r.display,e)){Ne(e),x&&(yo=+new Date);var t=nr(r,e,!0),n=e.dataTransfer.files;if(t&&!r.isReadOnly())if(n&&n.length&&window.FileReader&&window.File)for(var i=n.length,o=Array(i),l=0,s=function(){++l==i&&Gr(r,function(){var e={from:t=ft(r.doc,t),to:t,text:r.doc.splitLines(o.filter(function(e){return null!=e}).join(r.doc.lineSeparator())),origin:"paste"};qi(r.doc,e),zi(r.doc,di(ft(r.doc,t),ft(r.doc,fi(e))))})()},a=0;a<n.length;a++)!function(e,t){var n;r.options.allowDropFileTypes&&-1==B(r.options.allowDropFileTypes,e.type)?s():((n=new FileReader).onerror=s,n.onload=function(){var e=n.result;/[\x00-\x08\x0e-\x1f]{2}/.test(e)||(o[t]=e),s()},n.readAsText(e))}(n[a],a);else{if(r.state.draggingText&&-1<r.doc.sel.contains(t))return r.state.draggingText(e),void setTimeout(function(){return r.display.input.focus()},20);try{var u,c=e.dataTransfer.getData("Text");if(c){if(r.state.draggingText&&!r.state.draggingText.copy&&(u=r.listSelections()),Gi(r.doc,di(t,t)),u)for(var h=0;h<u.length;++h)to(r.doc,"",u[h].anchor,u[h].head,"drag");r.replaceSelection(c,"around","paste"),r.display.input.focus()}}catch(e){}}}}function wo(e){e.display.dragCursor&&(e.display.lineSpace.removeChild(e.display.dragCursor),e.display.dragCursor=null)}function xo(t){if(document.getElementsByClassName){for(var e=document.getElementsByClassName("CodeMirror"),n=[],r=0;r<e.length;r++){var i=e[r].CodeMirror;i&&n.push(i)}n.length&&n[0].operation(function(){for(var e=0;e<n.length;e++)t(n[e])})}}var Co=!1;function So(){var e;Co||(we(window,"resize",function(){null==e&&(e=setTimeout(function(){e=null,xo(Lo)},100))}),we(window,"blur",function(){return xo(vr)}),Co=!0)}function Lo(e){var t=e.display;t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize()}for(var ko={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:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},To=0;To<10;To++)ko[To+48]=ko[To+96]=String(To);for(var Mo=65;Mo<=90;Mo++)ko[Mo]=String.fromCharCode(Mo);for(var No=1;No<=12;No++)ko[No+111]=ko[No+63235]="F"+No;var Ao={};function Oo(e){var t,n,r,i,o=e.split(/-(?!$)/);e=o[o.length-1];for(var l=0;l<o.length-1;l++){var s=o[l];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else{if(!/^s(hift)?$/i.test(s))throw new Error("Unrecognized modifier name: "+s);r=!0}}return t&&(e="Alt-"+e),n&&(e="Ctrl-"+e),i&&(e="Cmd-"+e),r&&(e="Shift-"+e),e}function Do(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if("..."==r){delete e[n];continue}for(var i=q(n.split(" "),Oo),o=0;o<i.length;o++){var l=void 0,s=void 0,l=o==i.length-1?(s=i.join(" "),r):(s=i.slice(0,o+1).join(" "),"..."),a=t[s];if(a){if(a!=l)throw new Error("Inconsistent bindings for "+s)}else t[s]=l}delete e[n]}for(var u in t)e[u]=t[u];return e}function Wo(e,t,n,r){var i=(t=Eo(t)).call?t.call(e,r):t[e];if(!1===i)return"nothing";if("..."===i)return"multi";if(null!=i&&n(i))return"handled";if(t.fallthrough){if("[object Array]"!=Object.prototype.toString.call(t.fallthrough))return Wo(e,t.fallthrough,n,r);for(var o=0;o<t.fallthrough.length;o++){var l=Wo(e,t.fallthrough[o],n,r);if(l)return l}}}function Ho(e){var t="string"==typeof e?e:ko[e.keyCode];return"Ctrl"==t||"Alt"==t||"Shift"==t||"Mod"==t}function Fo(e,t,n){var r=e;return t.altKey&&"Alt"!=r&&(e="Alt-"+e),(w?t.metaKey:t.ctrlKey)&&"Ctrl"!=r&&(e="Ctrl-"+e),(w?t.ctrlKey:t.metaKey)&&"Mod"!=r&&(e="Cmd-"+e),!n&&t.shiftKey&&"Shift"!=r&&(e="Shift-"+e),e}function Po(e,t){if(m&&34==e.keyCode&&e.char)return!1;var n=ko[e.keyCode];return null!=n&&!e.altGraphKey&&(3==e.keyCode&&e.code&&(n=e.code),Fo(n,e,t))}function Eo(e){return"string"==typeof e?Ao[e]:e}function Io(t,e){for(var n=t.doc.sel.ranges,r=[],i=0;i<n.length;i++){for(var o=e(n[i]);r.length&&st(o.from,$(r).to)<=0;){var l=r.pop();if(st(l.from,o.from)<0){o.from=l.from;break}}r.push(o)}Br(t,function(){for(var e=r.length-1;0<=e;e--)to(t.doc,"",r[e].from,r[e].to,"+delete");Sr(t)})}function Ro(e,t,n){var r=oe(e.text,t+n,n);return r<0||r>e.text.length?null:r}function zo(e,t,n){var r=Ro(e,t.ch,n);return null==r?null:new lt(t.line,r,n<0?"after":"before")}function Bo(e,t,n,r,i){if(e){"rtl"==t.doc.direction&&(i=-i);var o=ye(n,t.doc.direction);if(o){var l,s,a,u=i<0?$(o):o[0],c=i<0==(1==u.level)?"after":"before";return 0<u.level||"rtl"==t.doc.direction?(l=An(t,n),s=i<0?n.text.length-1:0,a=On(t,l,s).top,s=le(function(e){return On(t,l,e).top==a},i<0==(1==u.level)?u.from:u.to-1,s),"before"==c&&(s=Ro(n,s,1))):s=i<0?u.to:u.from,new lt(r,s,c)}}return new lt(r,i<0?n.text.length:0,i<0?"before":"after")}function Go(t,n,s,e){var a=ye(n,t.doc.direction);if(!a)return zo(n,s,e);s.ch>=n.text.length?(s.ch=n.text.length,s.sticky="before"):s.ch<=0&&(s.ch=0,s.sticky="after");var r=ae(a,s.ch,s.sticky),i=a[r];if("ltr"==t.doc.direction&&i.level%2==0&&(0<e?i.to>s.ch:i.from<s.ch))return zo(n,s,e);function u(e,t){return Ro(n,e instanceof lt?e.ch:e,t)}function o(e){return t.options.lineWrapping?(l=l||An(t,n),_n(t,n,l,e)):{begin:0,end:n.text.length}}var l,c=o("before"==s.sticky?u(s,-1):s.ch);if("rtl"==t.doc.direction||1==i.level){var h=1==i.level==e<0,d=u(s,h?1:-1);if(null!=d&&(h?d<=i.to&&d<=c.end:d>=i.from&&d>=c.begin)){var f=h?"before":"after";return new lt(s.line,d,f)}}function p(e,t,n){for(var r=function(e,t){return t?new lt(s.line,u(e,1),"before"):new lt(s.line,e,"after")};0<=e&&e<a.length;e+=t){var i=a[e],o=0<t==(1!=i.level),l=o?n.begin:u(n.end,-1);if(i.from<=l&&l<i.to)return r(l,o);if(l=o?i.from:u(i.to,-1),n.begin<=l&&l<n.end)return r(l,o)}}var g=p(r+e,e,c);if(g)return g;var m=0<e?c.end:u(c.begin,-1);return null==m||0<e&&m==n.text.length||!(g=p(0<e?0:a.length-1,e,o(m)))?null:g}Ao.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"},Ao.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"},Ao.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"},Ao.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"]},Ao.default=y?Ao.macDefault:Ao.pcDefault;var Uo={selectAll:_i,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),V)},killLine:function(n){return Io(n,function(e){if(e.empty()){var t=Qe(n.doc,e.head.line).text.length;return e.head.ch==t&&e.head.line<n.lastLine()?{from:e.head,to:lt(e.head.line+1,0)}:{from:e.head,to:lt(e.head.line,t)}}return{from:e.from(),to:e.to()}})},deleteLine:function(t){return Io(t,function(e){return{from:lt(e.from().line,0),to:ft(t.doc,lt(e.to().line+1,0))}})},delLineLeft:function(e){return Io(e,function(e){return{from:lt(e.from().line,0),to:e.from()}})},delWrappedLineLeft:function(n){return Io(n,function(e){var t=n.charCoords(e.head,"div").top+5;return{from:n.coordsChar({left:0,top:t},"div"),to:e.from()}})},delWrappedLineRight:function(r){return Io(r,function(e){var t=r.charCoords(e.head,"div").top+5,n=r.coordsChar({left:r.display.lineDiv.offsetWidth+100,top:t},"div");return{from:e.from(),to:n}})},undo:function(e){return e.undo()},redo:function(e){return e.redo()},undoSelection:function(e){return e.undoSelection()},redoSelection:function(e){return e.redoSelection()},goDocStart:function(e){return e.extendSelection(lt(e.firstLine(),0))},goDocEnd:function(e){return e.extendSelection(lt(e.lastLine()))},goLineStart:function(t){return t.extendSelectionsBy(function(e){return Vo(t,e.head.line)},{origin:"+move",bias:1})},goLineStartSmart:function(t){return t.extendSelectionsBy(function(e){return Ko(t,e.head)},{origin:"+move",bias:1})},goLineEnd:function(t){return t.extendSelectionsBy(function(e){return function(e,t){var n=Qe(e.doc,t),r=function(e){for(var t;t=Bt(e);)e=t.find(1,!0).line;return e}(n);r!=n&&(t=nt(r));return Bo(!0,e,n,t,-1)}(t,e.head.line)},{origin:"+move",bias:-1})},goLineRight:function(n){return n.extendSelectionsBy(function(e){var t=n.cursorCoords(e.head,"div").top+5;return n.coordsChar({left:n.display.lineDiv.offsetWidth+100,top:t},"div")},j)},goLineLeft:function(n){return n.extendSelectionsBy(function(e){var t=n.cursorCoords(e.head,"div").top+5;return n.coordsChar({left:0,top:t},"div")},j)},goLineLeftSmart:function(r){return r.extendSelectionsBy(function(e){var t=r.cursorCoords(e.head,"div").top+5,n=r.coordsChar({left:0,top:t},"div");return n.ch<r.getLine(n.line).search(/\S/)?Ko(r,e.head):n},j)},goLineUp:function(e){return e.moveV(-1,"line")},goLineDown:function(e){return e.moveV(1,"line")},goPageUp:function(e){return e.moveV(-1,"page")},goPageDown:function(e){return e.moveV(1,"page")},goCharLeft:function(e){return e.moveH(-1,"char")},goCharRight:function(e){return e.moveH(1,"char")},goColumnLeft:function(e){return e.moveH(-1,"column")},goColumnRight:function(e){return e.moveH(1,"column")},goWordLeft:function(e){return e.moveH(-1,"word")},goGroupRight:function(e){return e.moveH(1,"group")},goGroupLeft:function(e){return e.moveH(-1,"group")},goWordRight:function(e){return e.moveH(1,"word")},delCharBefore:function(e){return e.deleteH(-1,"codepoint")},delCharAfter:function(e){return e.deleteH(1,"char")},delWordBefore:function(e){return e.deleteH(-1,"word")},delWordAfter:function(e){return e.deleteH(1,"word")},delGroupBefore:function(e){return e.deleteH(-1,"group")},delGroupAfter:function(e){return e.deleteH(1,"group")},indentAuto:function(e){return e.indentSelection("smart")},indentMore:function(e){return e.indentSelection("add")},indentLess:function(e){return e.indentSelection("subtract")},insertTab:function(e){return e.replaceSelection("\t")},insertSoftTab:function(e){for(var t=[],n=e.listSelections(),r=e.options.tabSize,i=0;i<n.length;i++){var o=n[i].from(),l=R(e.getLine(o.line),o.ch,r);t.push(_(r-l%r))}e.replaceSelections(t)},defaultTab:function(e){e.somethingSelected()?e.indentSelection("add"):e.execCommand("insertTab")},transposeChars:function(l){return Br(l,function(){for(var e,t,n,r=l.listSelections(),i=[],o=0;o<r.length;o++){r[o].empty()&&(e=r[o].head,(t=Qe(l.doc,e.line).text)&&(e.ch==t.length&&(e=new lt(e.line,e.ch-1)),0<e.ch?(e=new lt(e.line,e.ch+1),l.replaceRange(t.charAt(e.ch-1)+t.charAt(e.ch-2),lt(e.line,e.ch-2),e,"+transpose")):e.line>l.doc.first&&((n=Qe(l.doc,e.line-1).text)&&(e=new lt(e.line,1),l.replaceRange(t.charAt(0)+l.doc.lineSeparator()+n.charAt(n.length-1),lt(e.line-1,n.length-1),e,"+transpose")))),i.push(new ci(e,e)))}l.setSelections(i)})},newlineAndIndent:function(r){return Br(r,function(){for(var e=r.listSelections(),t=e.length-1;0<=t;t--)r.replaceRange(r.doc.lineSeparator(),e[t].anchor,e[t].head,"+input");e=r.listSelections();for(var n=0;n<e.length;n++)r.indentLine(e[n].from().line,null,!0);Sr(r)})},openLine:function(e){return e.replaceSelection("\n","start")},toggleOverwrite:function(e){return e.toggleOverwrite()}};function Vo(e,t){var n=Qe(e.doc,t),r=Ut(n);return r!=n&&(t=nt(r)),Bo(!0,e,r,t,1)}function Ko(e,t){var n=Vo(e,t.line),r=Qe(e.doc,n.line),i=ye(r,e.doc.direction);if(i&&0!=i[0].level)return n;var o=Math.max(n.ch,r.text.search(/\S/)),l=t.line==n.line&&t.ch<=o&&t.ch;return lt(n.line,l?0:o,n.sticky)}function jo(e,t,n){if("string"==typeof t&&!(t=Uo[t]))return!1;e.display.input.ensurePolled();var r=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=U}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}var Xo=new z;function Yo(e,t,n,r){var i=e.state.keySeq;if(i){if(Ho(t))return"handled";if(/\'$/.test(t)?e.state.keySeq=null:Xo.set(50,function(){e.state.keySeq==i&&(e.state.keySeq=null,e.display.input.reset())}),_o(e,i+" "+t,n,r))return!0}return _o(e,t,n,r)}function _o(e,t,n,r){var i=function(e,t,n){for(var r=0;r<e.state.keyMaps.length;r++){var i=Wo(t,e.state.keyMaps[r],n,e);if(i)return i}return e.options.extraKeys&&Wo(t,e.options.extraKeys,n,e)||Wo(t,e.options.keyMap,n,e)}(e,t,r);return"multi"==i&&(e.state.keySeq=t),"handled"==i&&un(e,"keyHandled",e,t,n),"handled"!=i&&"multi"!=i||(Ne(n),fr(e)),!!i}function $o(t,e){var n=Po(e,!0);return!!n&&(e.shiftKey&&!t.state.keySeq?Yo(t,"Shift-"+n,e,function(e){return jo(t,e,!0)})||Yo(t,n,e,function(e){if("string"==typeof e?/^go[A-Z]/.test(e):e.motion)return jo(t,e)}):Yo(t,n,e,function(e){return jo(t,e)}))}var qo=null;function Zo(e){var t,n,r,i=this;function o(e){18!=e.keyCode&&e.altKey||(T(r,"CodeMirror-crosshair"),Ce(document,"keyup",o),Ce(document,"mouseover",o))}e.target&&e.target!=i.display.input.getField()||(i.curOp.focus=W(),Le(i,e)||(x&&C<11&&27==e.keyCode&&(e.returnValue=!1),t=e.keyCode,i.display.shift=16==t||e.shiftKey,n=$o(i,e),m&&(qo=n?t:null,!n&&88==t&&!Be&&(y?e.metaKey:e.ctrlKey)&&i.replaceSelection("",null,"cut")),g&&!y&&!n&&46==t&&e.shiftKey&&!e.ctrlKey&&document.execCommand&&document.execCommand("cut"),18!=t||/\bCodeMirror-crosshair\b/.test(i.display.lineDiv.className)||(H(r=i.display.lineDiv,"CodeMirror-crosshair"),we(document,"keyup",o),we(document,"mouseover",o))))}function Qo(e){16==e.keyCode&&(this.doc.sel.shift=!1),Le(this,e)}function Jo(e){var t=this;if(!(e.target&&e.target!=t.display.input.getField()||bn(t.display,e)||Le(t,e)||e.ctrlKey&&!e.altKey||y&&e.metaKey)){var n,r,i=e.keyCode,o=e.charCode;if(m&&i==qo)return qo=null,void Ne(e);m&&(!e.which||e.which<10)&&$o(t,e)||"\b"!=(n=String.fromCharCode(null==o?i:o))&&(Yo(r=t,"'"+n+"'",e,function(e){return jo(r,e,!0)})||t.display.input.onKeyPress(e))}}var el,tl,nl=function(e,t,n){this.time=e,this.pos=t,this.button=n};function rl(e){var t,n,r,i,o,l,s=this,a=s.display;Le(s,e)||a.activeTouch&&a.input.supportsTouch()||(a.input.ensurePolled(),a.shift=e.shiftKey,bn(a,e)?v||(a.scroller.draggable=!1,setTimeout(function(){return a.scroller.draggable=!0},100)):ll(s,e)||(t=nr(s,e),n=He(e),r=t?(i=t,o=n,l=+new Date,tl&&tl.compare(l,i,o)?(el=tl=null,"triple"):el&&el.compare(l,i,o)?(tl=new nl(l,i,o),el=null,"double"):(el=new nl(l,i,o),tl=null,"single")):"single",window.focus(),1==n&&s.state.selectingText&&s.state.selectingText(e),t&&function(n,e,r,t,i){var o="Click";"double"==t?o="Double"+o:"triple"==t&&(o="Triple"+o);return Yo(n,Fo(o=(1==e?"Left":2==e?"Middle":"Right")+o,i),i,function(e){if("string"==typeof e&&(e=Uo[e]),!e)return!1;var t=!1;try{n.isReadOnly()&&(n.state.suppressEdits=!0),t=e(n,r)!=U}finally{n.state.suppressEdits=!1}return t})}(s,n,t,r,e)||(1==n?t?function(e,t,n,r){x?setTimeout(E(pr,e),0):e.curOp.focus=W();var i,o=function(e,t,n){var r=e.getOption("configureMouse"),i=r?r(e,t,n):{};{var o;null==i.unit&&(o=f?n.shiftKey&&n.metaKey:n.altKey,i.unit=o?"rectangle":"single"==t?"char":"double"==t?"word":"line")}null!=i.extend&&!e.doc.extend||(i.extend=e.doc.extend||n.shiftKey);null==i.addNew&&(i.addNew=y?n.metaKey:n.ctrlKey);null==i.moveOnDrag&&(i.moveOnDrag=!(y?n.altKey:n.ctrlKey));return i}(e,n,r),l=e.doc.sel;(e.options.dragDrop&&Ee&&!e.isReadOnly()&&"single"==n&&-1<(i=l.contains(t))&&(st((i=l.ranges[i]).from(),t)<0||0<t.xRel)&&(0<st(i.to(),t)||t.xRel<0)?function(t,n,r,i){var o=t.display,l=!1,s=Gr(t,function(e){v&&(o.scroller.draggable=!1),t.state.draggingText=!1,Ce(o.wrapper.ownerDocument,"mouseup",s),Ce(o.wrapper.ownerDocument,"mousemove",a),Ce(o.scroller,"dragstart",u),Ce(o.scroller,"drop",s),l||(Ne(e),i.addNew||Pi(t.doc,r,null,null,i.extend),v&&!c||x&&9==C?setTimeout(function(){o.wrapper.ownerDocument.body.focus({preventScroll:!0}),o.input.focus()},20):o.input.focus())}),a=function(e){l=l||10<=Math.abs(n.clientX-e.clientX)+Math.abs(n.clientY-e.clientY)},u=function(){return l=!0};v&&(o.scroller.draggable=!0);(t.state.draggingText=s).copy=!i.moveOnDrag,o.scroller.dragDrop&&o.scroller.dragDrop();we(o.wrapper.ownerDocument,"mouseup",s),we(o.wrapper.ownerDocument,"mousemove",a),we(o.scroller,"dragstart",u),we(o.scroller,"drop",s),gr(t),setTimeout(function(){return o.input.focus()},20)}:function(m,e,v,y){var l=m.display,b=m.doc;Ne(e);var w,x,C=b.sel,t=C.ranges;y.addNew&&!y.extend?(x=b.sel.contains(v),w=-1<x?t[x]:new ci(v,v)):(w=b.sel.primary(),x=b.sel.primIndex);{var n;"rectangle"==y.unit?(y.addNew||(w=new ci(v,v)),v=nr(m,e,!0,!0),x=-1):(n=il(m,v,y.unit),w=y.extend?Fi(w,n.anchor,n.head,y.extend):n)}y.addNew?-1==x?(x=t.length,Bi(b,hi(m,t.concat([w]),x),{scroll:!1,origin:"*mouse"})):1<t.length&&t[x].empty()&&"char"==y.unit&&!y.extend?(Bi(b,hi(m,t.slice(0,x).concat(t.slice(x+1)),0),{scroll:!1,origin:"*mouse"}),C=b.sel):Ii(b,x,w,K):(Bi(b,new ui([w],x=0),K),C=b.sel);var S=v;function s(e){if(0!=st(S,e))if(S=e,"rectangle"==y.unit){for(var t=[],n=m.options.tabSize,r=R(Qe(b,v.line).text,v.ch,n),i=R(Qe(b,e.line).text,e.ch,n),o=Math.min(r,i),l=Math.max(r,i),s=Math.min(v.line,e.line),a=Math.min(m.lastLine(),Math.max(v.line,e.line));s<=a;s++){var u=Qe(b,s).text,c=X(u,o,n);o==l?t.push(new ci(lt(s,c),lt(s,c))):u.length>c&&t.push(new ci(lt(s,c),lt(s,X(u,l,n))))}t.length||t.push(new ci(v,v)),Bi(b,hi(m,C.ranges.slice(0,x).concat(t),x),{origin:"*mouse",scroll:!1}),m.scrollIntoView(e)}else{var h,d=w,f=il(m,e,y.unit),p=d.anchor,p=0<st(f.anchor,p)?(h=f.head,ht(d.from(),f.anchor)):(h=f.anchor,ct(d.to(),f.head)),g=C.ranges.slice(0);g[x]=function(e,t){var n=t.anchor,r=t.head,i=Qe(e.doc,n.line);if(0==st(n,r)&&n.sticky==r.sticky)return t;var o=ye(i);if(!o)return t;var l=ae(o,n.ch,n.sticky),s=o[l];if(s.from!=n.ch&&s.to!=n.ch)return t;var a,u=l+(s.from==n.ch==(1!=s.level)?0:1);if(0==u||u==o.length)return t;{var c,h;a=r.line!=n.line?0<(r.line-n.line)*("ltr"==e.doc.direction?1:-1):(c=ae(o,r.ch,r.sticky),h=c-l||(r.ch-n.ch)*(1==s.level?-1:1),c==u-1||c==u?h<0:0<h)}var d=o[u+(a?-1:0)],f=a==(1==d.level),p=f?d.from:d.to,g=f?"after":"before";return n.ch==p&&n.sticky==g?t:new ci(new lt(n.line,p,g),r)}(m,new ci(ft(b,p),h)),Bi(b,hi(m,g,x),K)}}var a=l.wrapper.getBoundingClientRect(),u=0;function r(e){m.state.selectingText=!1,u=1/0,e&&(Ne(e),l.input.focus()),Ce(l.wrapper.ownerDocument,"mousemove",i),Ce(l.wrapper.ownerDocument,"mouseup",o),b.history.lastSelOrigin=null}var i=Gr(m,function(e){(0!==e.buttons&&He(e)?function e(t){var n,r,i=++u,o=nr(m,t,!0,"rectangle"==y.unit);o&&(0!=st(o,S)?(m.curOp.focus=W(),s(o),n=wr(l,b),(o.line>=n.to||o.line<n.from)&&setTimeout(Gr(m,function(){u==i&&e(t)}),150)):(r=t.clientY<a.top?-20:t.clientY>a.bottom?20:0)&&setTimeout(Gr(m,function(){u==i&&(l.scroller.scrollTop+=r,e(t))}),50))}:r)(e)}),o=Gr(m,r);m.state.selectingText=o,we(l.wrapper.ownerDocument,"mousemove",i),we(l.wrapper.ownerDocument,"mouseup",o)})(e,r,t,o)}(s,t,r,e):We(e)==a.scroller&&Ne(e):2==n?(t&&Pi(s.doc,t),setTimeout(function(){return a.input.focus()},20)):3==n&&(S?s.display.input.onContextMenu(e):gr(s)))))}function il(e,t,n){if("char"==n)return new ci(t,t);if("word"==n)return e.findWordAt(t);if("line"==n)return new ci(lt(t.line,0),ft(e.doc,lt(t.line+1,0)));var r=n(e,t);return new ci(r.from,r.to)}function ol(e,t,n,r){var i,o;if(t.touches)i=t.touches[0].clientX,o=t.touches[0].clientY;else try{i=t.clientX,o=t.clientY}catch(e){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Ne(t);var l=e.display,s=l.lineDiv.getBoundingClientRect();if(o>s.bottom||!Te(e,n))return Oe(t);o-=s.top-l.viewOffset;for(var a=0;a<e.display.gutterSpecs.length;++a){var u=l.gutters.childNodes[a];if(u&&u.getBoundingClientRect().right>=i)return Se(e,n,e,rt(e.doc,o),e.display.gutterSpecs[a].className,t),Oe(t)}}function ll(e,t){return ol(e,t,"gutterClick",!0)}function sl(e,t){var n,r;bn(e.display,t)||(r=t,Te(n=e,"gutterContextMenu")&&ol(n,r,"gutterContextMenu",!1))||Le(e,t,"contextmenu")||S||e.display.input.onContextMenu(t)}function al(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),En(e)}nl.prototype.compare=function(e,t,n){return this.time+400>e&&0==st(t,this.pos)&&n==this.button};var ul={toString:function(){return"CodeMirror.Init"}},cl={},hl={};function dl(e,t,n){var r,i;!t!=!(n&&n!=ul)&&(r=e.display.dragFunctions,(i=t?we:Ce)(e.display.scroller,"dragstart",r.start),i(e.display.scroller,"dragenter",r.enter),i(e.display.scroller,"dragover",r.over),i(e.display.scroller,"dragleave",r.leave),i(e.display.scroller,"drop",r.drop))}function fl(e){e.options.lineWrapping?(H(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(T(e.display.wrapper,"CodeMirror-wrap"),_t(e)),tr(e),ir(e),En(e),setTimeout(function(){return Hr(e)},100)}function pl(e,t){var n=this;if(!(this instanceof pl))return new pl(e,t);this.options=t=t?I(t):{},I(cl,t,!1);var r=t.value;"string"==typeof r?r=new vo(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var i=new pl.inputStyles[t.inputStyle](this),o=this.display=new ri(e,r,i,t);for(var l in al(o.wrapper.CodeMirror=this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Er(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 z,keySeq:null,specialChars:null},t.autofocus&&!d&&o.input.focus(),x&&C<11&&setTimeout(function(){return n.display.input.reset(!0)},20),function(i){var o=i.display;we(o.scroller,"mousedown",Gr(i,rl)),we(o.scroller,"dblclick",x&&C<11?Gr(i,function(e){var t,n;Le(i,e)||(!(t=nr(i,e))||ll(i,e)||bn(i.display,e)||(Ne(e),n=i.findWordAt(t),Pi(i.doc,n.anchor,n.head)))}):function(e){return Le(i,e)||Ne(e)});we(o.scroller,"contextmenu",function(e){return sl(i,e)}),we(o.input.getField(),"contextmenu",function(e){o.scroller.contains(e.target)||sl(i,e)});var n,r={end:0};function l(){o.activeTouch&&(n=setTimeout(function(){return o.activeTouch=null},1e3),(r=o.activeTouch).end=+new Date)}function s(e,t){if(null==t.left)return 1;var n=t.left-e.left,r=t.top-e.top;return 400<n*n+r*r}we(o.scroller,"touchstart",function(e){var t;Le(i,e)||function(e){if(1==e.touches.length){var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}}(e)||ll(i,e)||(o.input.ensurePolled(),clearTimeout(n),t=+new Date,o.activeTouch={start:t,moved:!1,prev:t-r.end<=300?r:null},1==e.touches.length&&(o.activeTouch.left=e.touches[0].pageX,o.activeTouch.top=e.touches[0].pageY))}),we(o.scroller,"touchmove",function(){o.activeTouch&&(o.activeTouch.moved=!0)}),we(o.scroller,"touchend",function(e){var t,n,r=o.activeTouch;r&&!bn(o,e)&&null!=r.left&&!r.moved&&new Date-r.start<300&&(t=i.coordsChar(o.activeTouch,"page"),n=!r.prev||s(r,r.prev)?new ci(t,t):!r.prev.prev||s(r,r.prev.prev)?i.findWordAt(t):new ci(lt(t.line,0),ft(i.doc,lt(t.line+1,0))),i.setSelection(n.anchor,n.head),i.focus(),Ne(e)),l()}),we(o.scroller,"touchcancel",l),we(o.scroller,"scroll",function(){o.scroller.clientHeight&&(Mr(i,o.scroller.scrollTop),Ar(i,o.scroller.scrollLeft,!0),Se(i,"scroll",i))}),we(o.scroller,"mousewheel",function(e){return ai(i,e)}),we(o.scroller,"DOMMouseScroll",function(e){return ai(i,e)}),we(o.wrapper,"scroll",function(){return o.wrapper.scrollTop=o.wrapper.scrollLeft=0}),o.dragFunctions={enter:function(e){Le(i,e)||De(e)},over:function(e){var t,n,r;Le(i,e)||((r=nr(t=i,e))&&(hr(t,r,n=document.createDocumentFragment()),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,n)),De(e))},start:function(e){return t=i,n=e,void(x&&(!t.state.draggingText||new Date-yo<100)?De(n):Le(t,n)||bn(t.display,n)||(n.dataTransfer.setData("Text",t.getSelection()),n.dataTransfer.effectAllowed="copyMove",n.dataTransfer.setDragImage&&!c&&((r=O("img",null,null,"position: fixed; left: 0; top: 0;")).src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",m&&(r.width=r.height=1,t.display.wrapper.appendChild(r),r._top=r.offsetTop),n.dataTransfer.setDragImage(r,0,0),m&&r.parentNode.removeChild(r))));var t,n,r},drop:Gr(i,bo),leave:function(e){Le(i,e)||wo(i)}};var e=o.input.getField();we(e,"keyup",function(e){return Qo.call(i,e)}),we(e,"keydown",Gr(i,Zo)),we(e,"keypress",Gr(i,Jo)),we(e,"focus",function(e){return mr(i,e)}),we(e,"blur",function(e){return vr(i,e)})}(this),So(),Rr(this),this.curOp.forceUpdate=!0,Ci(this,r),t.autofocus&&!d||this.hasFocus()?setTimeout(function(){n.hasFocus()&&!n.state.focused&&mr(n)},20):vr(this),hl)hl.hasOwnProperty(l)&&hl[l](this,t[l],ul);Jr(this),t.finishInit&&t.finishInit(this);for(var s=0;s<gl.length;++s)gl[s](this);zr(this),v&&t.lineWrapping&&"optimizelegibility"==getComputedStyle(o.lineDiv).textRendering&&(o.lineDiv.style.textRendering="auto")}pl.defaults=cl,pl.optionHandlers=hl;var gl=[];function ml(e,t,n,r){var i,o=e.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?i=bt(e,t).state:n="prev");var l=e.options.tabSize,s=Qe(o,t),a=R(s.text,null,l);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(r||/\S/.test(s.text)){if("smart"==n&&((u=o.mode.indent(i,s.text.slice(c.length),s.text))==U||150<u)){if(!r)return;n="prev"}}else u=0,n="not";"prev"==n?u=t>o.first?R(Qe(o,t-1).text,null,l):0:"add"==n?u=a+e.options.indentUnit:"subtract"==n?u=a-e.options.indentUnit:"number"==typeof n&&(u=a+n),u=Math.max(0,u);var h="",d=0;if(e.options.indentWithTabs)for(var f=Math.floor(u/l);f;--f)d+=l,h+="\t";if(d<u&&(h+=_(u-d)),h!=c)return to(o,h,lt(t,0),lt(t,c.length),"+input"),!(s.stateAfter=null);for(var p=0;p<o.sel.ranges.length;p++){var g=o.sel.ranges[p];if(g.head.line==t&&g.head.ch<c.length){var m=lt(t,c.length);Ii(o,p,new ci(m,m));break}}}pl.defineInitHook=function(e){return gl.push(e)};var vl=null;function yl(e){vl=e}function bl(e,t,n,r,i){var o=e.doc;e.display.shift=!1,r=r||o.sel;var l=new Date-200,s="paste"==i||e.state.pasteIncoming>l,a=Re(t),u=null;if(s&&1<r.ranges.length)if(vl&&vl.text.join("\n")==t){if(r.ranges.length%vl.text.length==0){u=[];for(var c=0;c<vl.text.length;c++)u.push(o.splitLines(vl.text[c]))}}else a.length==r.ranges.length&&e.options.pasteLinesPerSelection&&(u=q(a,function(e){return[e]}));for(var h=e.curOp.updateInput,d=r.ranges.length-1;0<=d;d--){var f=r.ranges[d],p=f.from(),g=f.to();f.empty()&&(n&&0<n?p=lt(p.line,p.ch-n):e.state.overwrite&&!s?g=lt(g.line,Math.min(Qe(o,g.line).text.length,g.ch+$(a).length)):s&&vl&&vl.lineWise&&vl.text.join("\n")==a.join("\n")&&(p=g=lt(p.line,0)));var m={from:p,to:g,text:u?u[d%u.length]:a,origin:i||(s?"paste":e.state.cutIncoming>l?"cut":"+input")};qi(e.doc,m),un(e,"inputRead",e,m)}t&&!s&&xl(e,t),Sr(e),e.curOp.updateInput<2&&(e.curOp.updateInput=h),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function wl(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");return n&&(e.preventDefault(),t.isReadOnly()||t.options.disableInput||Br(t,function(){return bl(t,n,0,null,"paste")}),1)}function xl(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;0<=r;r--){var i=n.ranges[r];if(!(100<i.head.ch||r&&n.ranges[r-1].head.line==i.head.line)){var o=e.getModeAt(i.head),l=!1;if(o.electricChars){for(var s=0;s<o.electricChars.length;s++)if(-1<t.indexOf(o.electricChars.charAt(s))){l=ml(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Qe(e.doc,i.head.line).text.slice(0,i.head.ch))&&(l=ml(e,i.head.line,"smart"));l&&un(e,"electricInput",e,i.head.line)}}}function Cl(e){for(var t=[],n=[],r=0;r<e.doc.sel.ranges.length;r++){var i=e.doc.sel.ranges[r].head.line,o={anchor:lt(i,0),head:lt(i+1,0)};n.push(o),t.push(e.getRange(o.anchor,o.head))}return{text:t,ranges:n}}function Sl(e,t,n,r){e.setAttribute("autocorrect",n?"":"off"),e.setAttribute("autocapitalize",r?"":"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;");return v?e.style.width="1000px":e.setAttribute("wrap","off"),a&&(e.style.border="1px solid black"),Sl(e),t}function kl(i,o,l,s,a){var e=o,t=l,u=Qe(i,o.line),c=a&&"rtl"==i.direction?-l:l;function n(e){var t,n,r;if(null==(n="codepoint"==s?(t=u.text.charCodeAt(o.ch+(0<s?0:-1)),isNaN(t)?null:new lt(o.line,Math.max(0,Math.min(u.text.length,o.ch+l*(55296<=t&&t<56320?2:1))),-l)):a?Go(i.cm,u,o,l):zo(u,o,l))){if(e||(r=o.line+c)<i.first||r>=i.first+i.size||(o=new lt(r,o.ch,o.sticky),!(u=Qe(i,r))))return;o=Bo(a,i.cm,u,o.line,c)}else o=n;return 1}if("char"==s||"codepoint"==s)n();else if("column"==s)n(!0);else if("word"==s||"group"==s)for(var r=null,h="group"==s,d=i.cm&&i.cm.getHelper(o,"wordChars"),f=!0;!(l<0)||n(!f);f=!1){var p=u.text.charAt(o.ch)||"\n",g=te(p,d)?"w":h&&"\n"==p?"n":!h||/\s/.test(p)?null:"p";if(!h||f||g||(g="s"),r&&r!=g){l<0&&(l=1,n(),o.sticky="after");break}if(g&&(r=g),0<l&&!n(!f))break}var m=Xi(i,o,e,t,!0);return at(e,m)&&(m.hitSide=!0),m}function Tl(e,t,n,r){var i,o,l,s,a=e.doc,u=t.left;for("page"==r?(i=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),o=Math.max(i-.5*qn(e.display),3),l=(0<n?t.bottom:t.top)+n*o):"line"==r&&(l=0<n?t.bottom+3:t.top-3);(s=Xn(e,u,l)).outside;){if(n<0?l<=0:l>=a.height){s.hitSide=!0;break}l+=5*n}return s}function Ml(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new z,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null}function Nl(e,t){var n=Nn(e,t.line);if(!n||n.hidden)return null;var r=Qe(e.doc,t.line),i=Tn(n,r,t.line),o=ye(r,e.doc.direction),l="left";o&&(l=ae(o,t.ch)%2?"right":"left");var s=Hn(i.map,t.ch,l);return s.offset="right"==s.collapse?s.end:s.start,s}function Al(e,t){return t&&(e.bad=!0),e}function Ol(e,t,n){var r;if(t==e.display.lineDiv){if(!(r=e.display.lineDiv.childNodes[n]))return Al(e.clipPos(lt(e.display.viewTo-1)),!0);t=null,n=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var i=0;i<e.display.view.length;i++){var o=e.display.view[i];if(o.node==r)return function(u,e,t){var n=u.text.firstChild,r=!1;if(!e||!D(n,e))return Al(lt(nt(u.line),0),!0);if(e==n&&(r=!0,e=n.childNodes[t],t=0,!e)){var i=u.rest?$(u.rest):u.line;return Al(lt(nt(i),i.text.length),r)}var o=3==e.nodeType?e:null,l=e;o||1!=e.childNodes.length||3!=e.firstChild.nodeType||(o=e.firstChild,t=t&&o.nodeValue.length);for(;l.parentNode!=n;)l=l.parentNode;var c=u.measure,h=c.maps;function s(e,t,n){for(var r=-1;r<(h?h.length:0);r++)for(var i=r<0?c.map:h[r],o=0;o<i.length;o+=3){var l=i[o+2];if(l==e||l==t){var s=nt(r<0?u.line:u.rest[r]),a=i[o]+n;return(n<0||l!=e)&&(a=i[o+(n?1:0)]),lt(s,a)}}}var a=s(o,l,t);if(a)return Al(a,r);for(var d=l.nextSibling,f=o?o.nodeValue.length-t:0;d;d=d.nextSibling){if(a=s(d,d.firstChild,0))return Al(lt(a.line,a.ch-f),r);f+=d.textContent.length}for(var p=l.previousSibling,g=t;p;p=p.previousSibling){if(a=s(p,p.firstChild,-1))return Al(lt(a.line,a.ch+g),r);g+=p.textContent.length}}(o,t,n)}}Ml.prototype.init=function(e){var t=this,l=this,s=l.cm,a=l.div=e.lineDiv;function u(e){for(var t=e.target;t;t=t.parentNode){if(t==a)return 1;if(/\bCodeMirror-(?:line)?widget\b/.test(t.className))break}}function n(e){if(u(e)&&!Le(s,e)){if(s.somethingSelected())yl({lineWise:!1,text:s.getSelections()}),"cut"==e.type&&s.replaceSelection("",null,"cut");else{if(!s.options.lineWiseCopyCut)return;var t=Cl(s);yl({lineWise:!0,text:t.text}),"cut"==e.type&&s.operation(function(){s.setSelections(t.ranges,0,V),s.replaceSelection("",null,"cut")})}if(e.clipboardData){e.clipboardData.clearData();var n=vl.text.join("\n");if(e.clipboardData.setData("Text",n),e.clipboardData.getData("Text")==n)return void e.preventDefault()}var r=Ll(),i=r.firstChild;s.display.lineSpace.insertBefore(r,s.display.lineSpace.firstChild),i.value=vl.text.join("\n");var o=document.activeElement;P(i),setTimeout(function(){s.display.lineSpace.removeChild(r),o.focus(),o==a&&l.showPrimarySelection()},50)}}Sl(a,s.options.spellcheck,s.options.autocorrect,s.options.autocapitalize),we(a,"paste",function(e){!u(e)||Le(s,e)||wl(e,s)||C<=11&&setTimeout(Gr(s,function(){return t.updateFromDOM()}),20)}),we(a,"compositionstart",function(e){t.composing={data:e.data,done:!1}}),we(a,"compositionupdate",function(e){t.composing||(t.composing={data:e.data,done:!1})}),we(a,"compositionend",function(e){t.composing&&(e.data!=t.composing.data&&t.readFromDOMSoon(),t.composing.done=!0)}),we(a,"touchstart",function(){return l.forceCompositionEnd()}),we(a,"input",function(){t.composing||t.readFromDOMSoon()}),we(a,"copy",n),we(a,"cut",n)},Ml.prototype.screenReaderLabelChanged=function(e){e?this.div.setAttribute("aria-label",e):this.div.removeAttribute("aria-label")},Ml.prototype.prepareSelection=function(){var e=cr(this.cm,!1);return e.focus=document.activeElement==this.div,e},Ml.prototype.showSelection=function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},Ml.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Ml.prototype.showPrimarySelection=function(){var e=this.getSelection(),t=this.cm,n=t.doc.sel.primary(),r=n.from(),i=n.to();if(t.display.viewTo==t.display.viewFrom||r.line>=t.display.viewTo||i.line<t.display.viewFrom)e.removeAllRanges();else{var o=Ol(t,e.anchorNode,e.anchorOffset),l=Ol(t,e.focusNode,e.focusOffset);if(!o||o.bad||!l||l.bad||0!=st(ht(o,l),r)||0!=st(ct(o,l),i)){var s,a,u=t.display.view,c=r.line>=t.display.viewFrom&&Nl(t,r)||{node:u[0].measure.map[2],offset:0},h=i.line<t.display.viewTo&&Nl(t,i);if(h||(h={node:(a=(s=u[u.length-1].measure).maps?s.maps[s.maps.length-1]:s.map)[a.length-1],offset:a[a.length-2]-a[a.length-3]}),c&&h){var d,f=e.rangeCount&&e.getRangeAt(0);try{d=k(c.node,c.offset,h.offset,h.node)}catch(e){}d&&(!g&&t.state.focused?(e.collapse(c.node,c.offset),d.collapsed||(e.removeAllRanges(),e.addRange(d))):(e.removeAllRanges(),e.addRange(d)),f&&null==e.anchorNode?e.addRange(f):g&&this.startGracePeriod()),this.rememberSelection()}else e.removeAllRanges()}}},Ml.prototype.startGracePeriod=function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){return e.cm.curOp.selectionChanged=!0})},20)},Ml.prototype.showMultipleSelections=function(e){N(this.cm.display.cursorDiv,e.cursors),N(this.cm.display.selectionDiv,e.selection)},Ml.prototype.rememberSelection=function(){var e=this.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},Ml.prototype.selectionInEditor=function(){var e=this.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return D(this.div,t)},Ml.prototype.focus=function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()&&document.activeElement==this.div||this.showSelection(this.prepareSelection(),!0),this.div.focus())},Ml.prototype.blur=function(){this.div.blur()},Ml.prototype.getField=function(){return this.div},Ml.prototype.supportsTouch=function(){return!0},Ml.prototype.receivedFocus=function(){var t=this;this.selectionInEditor()?this.pollSelection():Br(this.cm,function(){return t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))})},Ml.prototype.selectionChanged=function(){var e=this.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},Ml.prototype.pollSelection=function(){if(null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var e,t,n=this.getSelection(),r=this.cm;if(h&&l&&this.cm.display.gutterSpecs.length&&function(e){for(var t=e;t;t=t.parentNode)if(/CodeMirror-gutter-wrapper/.test(t.className))return!0;return!1}(n.anchorNode))return this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),void this.focus();this.composing||(this.rememberSelection(),e=Ol(r,n.anchorNode,n.anchorOffset),t=Ol(r,n.focusNode,n.focusOffset),e&&t&&Br(r,function(){Bi(r.doc,di(e,t),V),(e.bad||t.bad)&&(r.curOp.selectionChanged=!0)}))}},Ml.prototype.pollContent=function(){null!=this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var e,t,n,r=this.cm,i=r.display,o=r.doc.sel.primary(),l=o.from(),s=o.to();if(0==l.ch&&l.line>r.firstLine()&&(l=lt(l.line-1,Qe(r.doc,l.line-1).length)),s.ch==Qe(r.doc,s.line).text.length&&s.line<r.lastLine()&&(s=lt(s.line+1,0)),l.line<i.viewFrom||s.line>i.viewTo-1)return!1;n=l.line==i.viewFrom||0==(e=rr(r,l.line))?(t=nt(i.view[0].line),i.view[0].node):(t=nt(i.view[e].line),i.view[e-1].node.nextSibling);var a,u=rr(r,s.line),c=u==i.view.length-1?(a=i.viewTo-1,i.lineDiv.lastChild):(a=nt(i.view[u+1].line)-1,i.view[u+1].node.previousSibling);if(!n)return!1;for(var h=r.doc.splitLines(function(u,e,t,c,h){var n="",d=!1,f=u.doc.lineSeparator(),p=!1;function g(){d&&(n+=f,p&&(n+=f),d=p=!1)}function m(e){e&&(g(),n+=e)}for(;!function e(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(n)return void m(n);var r,i=t.getAttribute("cm-marker");if(i){var o=u.findMarks(lt(c,0),lt(h+1,0),(a=+i,function(e){return e.id==a}));return void(o.length&&(r=o[0].find(0))&&m(Je(u.doc,r.from,r.to).join(f)))}if("false"==t.getAttribute("contenteditable"))return;var l=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;l&&g();for(var s=0;s<t.childNodes.length;s++)e(t.childNodes[s]);/^(pre|p)$/i.test(t.nodeName)&&(p=!0),l&&(d=!0)}else 3==t.nodeType&&m(t.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "));var a}(e),e!=t;)e=e.nextSibling,p=!1;return n}(r,n,c,t,a)),d=Je(r.doc,lt(t,0),lt(a,Qe(r.doc,a).text.length));1<h.length&&1<d.length;)if($(h)==$(d))h.pop(),d.pop(),a--;else{if(h[0]!=d[0])break;h.shift(),d.shift(),t++}for(var f=0,p=0,g=h[0],m=d[0],v=Math.min(g.length,m.length);f<v&&g.charCodeAt(f)==m.charCodeAt(f);)++f;for(var y=$(h),b=$(d),w=Math.min(y.length-(1==h.length?f:0),b.length-(1==d.length?f:0));p<w&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)++p;if(1==h.length&&1==d.length&&t==l.line)for(;f&&f>l.ch&&y.charCodeAt(y.length-p-1)==b.charCodeAt(b.length-p-1);)f--,p++;h[h.length-1]=y.slice(0,y.length-p).replace(/^\u200b+/,""),h[0]=h[0].slice(f).replace(/\u200b+$/,"");var x=lt(t,f),C=lt(a,d.length?$(d).length-p:0);return 1<h.length||h[0]||st(x,C)?(to(r.doc,h,x,C,"+input"),!0):void 0},Ml.prototype.ensurePolled=function(){this.forceCompositionEnd()},Ml.prototype.reset=function(){this.forceCompositionEnd()},Ml.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Ml.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout(function(){if(e.readDOMTimeout=null,e.composing){if(!e.composing.done)return;e.composing=null}e.updateFromDOM()},80))},Ml.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||Br(this.cm,function(){return ir(e.cm)})},Ml.prototype.setUneditable=function(e){e.contentEditable="false"},Ml.prototype.onKeyPress=function(e){0==e.charCode||this.composing||(e.preventDefault(),this.cm.isReadOnly()||Gr(this.cm,bl)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},Ml.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},Ml.prototype.onContextMenu=function(){},Ml.prototype.resetPosition=function(){},Ml.prototype.needsContentAttribute=!0;function Dl(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new z,this.hasSelection=!1,this.composing=null}var Wl,Hl,Fl,Pl,El;function Il(e,t,r,n){Wl.defaults[e]=t,r&&(Hl[e]=n?function(e,t,n){n!=ul&&r(e,t,n)}:r)}Dl.prototype.init=function(n){var e=this,r=this,i=this.cm;this.createField(n);var o=this.textarea;function t(e){if(!Le(i,e)){if(i.somethingSelected())yl({lineWise:!1,text:i.getSelections()});else{if(!i.options.lineWiseCopyCut)return;var t=Cl(i);yl({lineWise:!0,text:t.text}),"cut"==e.type?i.setSelections(t.ranges,null,V):(r.prevInput="",o.value=t.text.join("\n"),P(o))}"cut"==e.type&&(i.state.cutIncoming=+new Date)}}n.wrapper.insertBefore(this.wrapper,n.wrapper.firstChild),a&&(o.style.width="0px"),we(o,"input",function(){x&&9<=C&&e.hasSelection&&(e.hasSelection=null),r.poll()}),we(o,"paste",function(e){Le(i,e)||wl(e,i)||(i.state.pasteIncoming=+new Date,r.fastPoll())}),we(o,"cut",t),we(o,"copy",t),we(n.scroller,"paste",function(e){if(!bn(n,e)&&!Le(i,e)){if(!o.dispatchEvent)return i.state.pasteIncoming=+new Date,void r.focus();var t=new Event("paste");t.clipboardData=e.clipboardData,o.dispatchEvent(t)}}),we(n.lineSpace,"selectstart",function(e){bn(n,e)||Ne(e)}),we(o,"compositionstart",function(){var e=i.getCursor("from");r.composing&&r.composing.range.clear(),r.composing={start:e,range:i.markText(e,i.getCursor("to"),{className:"CodeMirror-composing"})}}),we(o,"compositionend",function(){r.composing&&(r.poll(),r.composing.range.clear(),r.composing=null)})},Dl.prototype.createField=function(e){this.wrapper=Ll(),this.textarea=this.wrapper.firstChild},Dl.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},Dl.prototype.prepareSelection=function(){var e,t,n,r=this.cm,i=r.display,o=r.doc,l=cr(r);return r.options.moveInputWithCursor&&(e=Vn(r,o.sel.primary().head,"div"),t=i.wrapper.getBoundingClientRect(),n=i.lineDiv.getBoundingClientRect(),l.teTop=Math.max(0,Math.min(i.wrapper.clientHeight-10,e.top+n.top-t.top)),l.teLeft=Math.max(0,Math.min(i.wrapper.clientWidth-10,e.left+n.left-t.left))),l},Dl.prototype.showSelection=function(e){var t=this.cm.display;N(t.cursorDiv,e.cursors),N(t.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},Dl.prototype.reset=function(e){var t,n;this.contextMenuPending||this.composing||((t=this.cm).somethingSelected()?(this.prevInput="",n=t.getSelection(),this.textarea.value=n,t.state.focused&&P(this.textarea),x&&9<=C&&(this.hasSelection=n)):e||(this.prevInput=this.textarea.value="",x&&9<=C&&(this.hasSelection=null)))},Dl.prototype.getField=function(){return this.textarea},Dl.prototype.supportsTouch=function(){return!1},Dl.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!d||W()!=this.textarea))try{this.textarea.focus()}catch(e){}},Dl.prototype.blur=function(){this.textarea.blur()},Dl.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Dl.prototype.receivedFocus=function(){this.slowPoll()},Dl.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},Dl.prototype.fastPoll=function(){var t=!1,n=this;n.pollingFast=!0,n.polling.set(20,function e(){n.poll()||t?(n.pollingFast=!1,n.slowPoll()):(t=!0,n.polling.set(60,e))})},Dl.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||ze(n)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=n.value;if(i==r&&!t.somethingSelected())return!1;if(x&&9<=C&&this.hasSelection===i||y&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||r||(r=""),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var l=0,s=Math.min(r.length,i.length);l<s&&r.charCodeAt(l)==i.charCodeAt(l);)++l;return Br(t,function(){bl(t,i.slice(l),r.length-l,null,e.composing?"*compose":null),1e3<i.length||-1<i.indexOf("\n")?n.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},Dl.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Dl.prototype.onKeyPress=function(){x&&9<=C&&(this.hasSelection=null),this.fastPoll()},Dl.prototype.onContextMenu=function(e){var n=this,r=n.cm,i=r.display,o=n.textarea;n.contextMenuPending&&n.contextMenuPending();var l,s,t,a,u,c=nr(r,e),h=i.scroller.scrollTop;function d(){var e,t;null!=o.selectionStart&&(t=""+((e=r.somethingSelected())?o.value:""),o.value="⇚",o.value=t,n.prevInput=e?"":"",o.selectionStart=1,o.selectionEnd=t.length,i.selForContextMenu=r.doc.sel)}function f(){var e,t;n.contextMenuPending==f&&(n.contextMenuPending=!1,n.wrapper.style.cssText=s,o.style.cssText=l,x&&C<9&&i.scrollbars.setScrollTop(i.scroller.scrollTop=h),null!=o.selectionStart&&((!x||x&&C<9)&&d(),e=0,t=function(){i.selForContextMenu==r.doc.sel&&0==o.selectionStart&&0<o.selectionEnd&&""==n.prevInput?Gr(r,_i)(r):e++<10?i.detectingSelectAll=setTimeout(t,500):(i.selForContextMenu=null,i.input.reset())},i.detectingSelectAll=setTimeout(t,200)))}c&&!m&&(r.options.resetSelectionOnContextMenu&&-1==r.doc.sel.contains(c)&&Gr(r,Bi)(r.doc,di(c),V),l=o.style.cssText,s=n.wrapper.style.cssText,t=n.wrapper.offsetParent.getBoundingClientRect(),n.wrapper.style.cssText="position: static",o.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-t.top-5)+"px; left: "+(e.clientX-t.left-5)+"px;\n z-index: 1000; background: "+(x?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",v&&(a=window.scrollY),i.input.focus(),v&&window.scrollTo(null,a),i.input.reset(),r.somethingSelected()||(o.value=n.prevInput=" "),n.contextMenuPending=f,i.selForContextMenu=r.doc.sel,clearTimeout(i.detectingSelectAll),x&&9<=C&&d(),S?(De(e),u=function(){Ce(window,"mouseup",u),setTimeout(f,20)},we(window,"mouseup",u)):setTimeout(f,50))},Dl.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e,this.textarea.readOnly=!!e},Dl.prototype.setUneditable=function(){},Dl.prototype.needsContentAttribute=!1,Hl=(Wl=pl).optionHandlers,Wl.defineOption=Il,Wl.Init=ul,Il("value","",function(e,t){return e.setValue(t)},!0),Il("mode",null,function(e,t){e.doc.modeOption=t,vi(e)},!0),Il("indentUnit",2,vi,!0),Il("indentWithTabs",!1),Il("smartIndent",!0),Il("tabSize",4,function(e){yi(e),En(e),ir(e)},!0),Il("lineSeparator",null,function(e,r){if(e.doc.lineSep=r){var i=[],o=e.doc.first;e.doc.iter(function(e){for(var t=0;;){var n=e.text.indexOf(r,t);if(-1==n)break;t=n+r.length,i.push(lt(o,n))}o++});for(var t=i.length-1;0<=t;t--)to(e.doc,r,i[t],lt(i[t].line,i[t].ch+r.length))}}),Il("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,function(e,t,n){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),n!=ul&&e.refresh()}),Il("specialCharPlaceholder",en,function(e){return e.refresh()},!0),Il("electricChars",!0),Il("inputStyle",d?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Il("spellcheck",!1,function(e,t){return e.getInputField().spellcheck=t},!0),Il("autocorrect",!1,function(e,t){return e.getInputField().autocorrect=t},!0),Il("autocapitalize",!1,function(e,t){return e.getInputField().autocapitalize=t},!0),Il("rtlMoveVisually",!p),Il("wholeLineUpdateBefore",!0),Il("theme","default",function(e){al(e),ni(e)},!0),Il("keyMap","default",function(e,t,n){var r=Eo(t),i=n!=ul&&Eo(n);i&&i.detach&&i.detach(e,r),r.attach&&r.attach(e,i||null)}),Il("extraKeys",null),Il("configureMouse",null),Il("lineWrapping",!1,fl,!0),Il("gutters",[],function(e,t){e.display.gutterSpecs=ei(t,e.options.lineNumbers),ni(e)},!0),Il("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?Jn(e.display)+"px":"0",e.refresh()},!0),Il("coverGutterNextToScrollbar",!1,function(e){return Hr(e)},!0),Il("scrollbarStyle","native",function(e){Er(e),Hr(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Il("lineNumbers",!1,function(e,t){e.display.gutterSpecs=ei(e.options.gutters,t),ni(e)},!0),Il("firstLineNumber",1,ni,!0),Il("lineNumberFormatter",function(e){return e},ni,!0),Il("showCursorWhenSelecting",!1,ur,!0),Il("resetSelectionOnContextMenu",!0),Il("lineWiseCopyCut",!0),Il("pasteLinesPerSelection",!0),Il("selectionsMayTouch",!1),Il("readOnly",!1,function(e,t){"nocursor"==t&&(vr(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)}),Il("screenReaderLabel",null,function(e,t){t=""===t?null:t,e.display.input.screenReaderLabelChanged(t)}),Il("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Il("dragDrop",!0,dl),Il("allowDropFileTypes",null),Il("cursorBlinkRate",530),Il("cursorScrollMargin",0),Il("cursorHeight",1,ur,!0),Il("singleCursorHeightPerLine",!0,ur,!0),Il("workTime",100),Il("workDelay",100),Il("flattenSpans",!0,yi,!0),Il("addModeClass",!1,yi,!0),Il("pollInterval",100),Il("undoDepth",200,function(e,t){return e.doc.history.undoDepth=t}),Il("historyEventDelay",1250),Il("viewportMargin",10,function(e){return e.refresh()},!0),Il("maxHighlightLength",1e4,yi,!0),Il("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Il("tabindex",null,function(e,t){return e.display.input.getField().tabIndex=t||""}),Il("autofocus",null),Il("direction","ltr",function(e,t){return e.doc.setDirection(t)},!0),Il("phrases",null),Pl=(Fl=pl).optionHandlers,El=Fl.helpers={},Fl.prototype={constructor:Fl,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var n=this.options,r=n[e];n[e]==t&&"mode"!=e||(n[e]=t,Pl.hasOwnProperty(e)&&Gr(this,Pl[e])(this,t,r),Se(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Eo(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;n<t.length;++n)if(t[n]==e||t[n].name==e)return t.splice(n,1),!0},addOverlay:Ur(function(e,t){var n=e.token?e:Fl.getMode(this.options,e);if(n.startState)throw new Error("Overlays may not be stateful.");!function(e,t,n){for(var r=0,i=n(t);r<e.length&&n(e[r])<=i;)r++;e.splice(r,0,t)}(this.state.overlays,{mode:n,modeSpec:e,opaque:t&&t.opaque,priority:t&&t.priority||0},function(e){return e.priority}),this.state.modeGen++,ir(this)}),removeOverlay:Ur(function(e){for(var t=this.state.overlays,n=0;n<t.length;++n){var r=t[n].modeSpec;if(r==e||"string"==typeof e&&r.name==e)return t.splice(n,1),this.state.modeGen++,void ir(this)}}),indentLine:Ur(function(e,t,n){"string"!=typeof t&&"number"!=typeof t&&(t=null==t?this.options.smartIndent?"smart":"prev":t?"add":"subtract"),it(this.doc,e)&&ml(this,e,t,n)}),indentSelection:Ur(function(e){for(var t=this.doc.sel.ranges,n=-1,r=0;r<t.length;r++){var i=t[r];if(i.empty())i.head.line>n&&(ml(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&Sr(this));else{for(var o=i.from(),l=i.to(),s=Math.max(n,o.line),n=Math.min(this.lastLine(),l.line-(l.ch?0:1))+1,a=s;a<n;++a)ml(this,a,e);var u=this.doc.sel.ranges;0==o.ch&&t.length==u.length&&0<u[r].from().ch&&Ii(this.doc,r,new ci(o,u[r].to()),V)}}}),getTokenAt:function(e,t){return Lt(this,e,t)},getLineTokens:function(e,t){return Lt(this,lt(e),t,!0)},getTokenTypeAt:function(e){e=ft(this.doc,e);var t,n=yt(this,Qe(this.doc,e.line)),r=0,i=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var l=r+i>>1;if((l?n[2*l-1]:0)>=o)i=l;else{if(!(n[2*l+1]<o)){t=n[2*l+2];break}r=1+l}}var s=t?t.indexOf("overlay "):-1;return s<0?t:0==s?null:t.slice(0,s-1)},getModeAt:function(e){var t=this.doc.mode;return t.innerMode?Fl.innerMode(t,this.getTokenAt(e).state).mode:t},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var n=[];if(!El.hasOwnProperty(t))return n;var r=El[t],i=this.getModeAt(e);if("string"==typeof i[t])r[i[t]]&&n.push(r[i[t]]);else if(i[t])for(var o=0;o<i[t].length;o++){var l=r[i[t][o]];l&&n.push(l)}else i.helperType&&r[i.helperType]?n.push(r[i.helperType]):r[i.name]&&n.push(r[i.name]);for(var s=0;s<r._global.length;s++){var a=r._global[s];a.pred(i,this)&&-1==B(n,a.val)&&n.push(a.val)}return n},getStateAfter:function(e,t){var n=this.doc;return bt(this,(e=dt(n,null==e?n.first+n.size-1:e))+1,t).state},cursorCoords:function(e,t){var n=this.doc.sel.primary(),r=null==e?n.head:"object"==typeof e?ft(this.doc,e):e?n.from():n.to();return Vn(this,r,t||"page")},charCoords:function(e,t){return Un(this,ft(this.doc,e),t||"page")},coordsChar:function(e,t){return Xn(this,(e=Gn(this,e,t||"page")).left,e.top)},lineAtHeight:function(e,t){return e=Gn(this,{top:e,left:0},t||"page").top,rt(this.doc,e+this.display.viewOffset)},heightAtLine:function(e,t,n){var r,i=!1,o="number"==typeof e?(r=this.doc.first+this.doc.size-1,e<this.doc.first?e=this.doc.first:r<e&&(e=r,i=!0),Qe(this.doc,e)):e;return Bn(this,o,{top:0,left:0},t||"page",n||i).top+(i?this.doc.height-Xt(o):0)},defaultTextHeight:function(){return qn(this.display)},defaultCharWidth:function(){return Zn(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var o,l,s,a,u,c=this.display,h=(e=Vn(this,ft(this.doc,e))).bottom,d=e.left;t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),c.sizer.appendChild(t),"over"==r?h=e.top:"above"!=r&&"near"!=r||(o=Math.max(c.wrapper.clientHeight,this.doc.height),l=Math.max(c.sizer.clientWidth,c.lineSpace.clientWidth),("above"==r||e.bottom+t.offsetHeight>o)&&e.top>t.offsetHeight?h=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=o&&(h=e.bottom),d+t.offsetWidth>l&&(d=l-t.offsetWidth)),t.style.top=h+"px",t.style.left=t.style.right="","right"==i?(d=c.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?d=0:"middle"==i&&(d=(c.sizer.clientWidth-t.offsetWidth)/2),t.style.left=d+"px"),n&&(s=this,a={left:d,top:h,right:d+t.offsetWidth,bottom:h+t.offsetHeight},null!=(u=xr(s,a)).scrollTop&&Mr(s,u.scrollTop),null!=u.scrollLeft&&Ar(s,u.scrollLeft))},triggerOnKeyDown:Ur(Zo),triggerOnKeyPress:Ur(Jo),triggerOnKeyUp:Qo,triggerOnMouseDown:Ur(rl),execCommand:function(e){if(Uo.hasOwnProperty(e))return Uo[e].call(null,this)},triggerElectric:Ur(function(e){xl(this,e)}),findPosH:function(e,t,n,r){var i=1;t<0&&(i=-1,t=-t);for(var o=ft(this.doc,e),l=0;l<t&&!(o=kl(this.doc,o,i,n,r)).hitSide;++l);return o},moveH:Ur(function(t,n){var r=this;this.extendSelectionsBy(function(e){return r.display.shift||r.doc.extend||e.empty()?kl(r.doc,e.head,t,n,r.options.rtlMoveVisually):t<0?e.from():e.to()},j)}),deleteH:Ur(function(n,r){var e=this.doc.sel,i=this.doc;e.somethingSelected()?i.replaceSelection("",null,"+delete"):Io(this,function(e){var t=kl(i,e.head,n,r,!1);return n<0?{from:t,to:e.head}:{from:e.head,to:t}})}),findPosV:function(e,t,n,r){var i=1,o=r;t<0&&(i=-1,t=-t);for(var l=ft(this.doc,e),s=0;s<t;++s){var a=Vn(this,l,"div");if(null==o?o=a.left:a.left=o,(l=Tl(this,a,i,n)).hitSide)break}return l},moveV:Ur(function(r,i){var o=this,l=this.doc,s=[],a=!this.display.shift&&!l.extend&&l.sel.somethingSelected();if(l.extendSelectionsBy(function(e){if(a)return r<0?e.from():e.to();var t=Vn(o,e.head,"div");null!=e.goalColumn&&(t.left=e.goalColumn),s.push(t.left);var n=Tl(o,t,r,i);return"page"==i&&e==l.sel.primary()&&Cr(o,Un(o,n,"div").top-t.top),n},j),s.length)for(var e=0;e<l.sel.ranges.length;e++)l.sel.ranges[e].goalColumn=s[e]}),findWordAt:function(e){var t=Qe(this.doc,e.line).text,n=e.ch,r=e.ch;if(t){var i=this.getHelper(e,"wordChars");"before"!=e.sticky&&r!=t.length||!n?++r:--n;for(var o=t.charAt(n),l=te(o,i)?function(e){return te(e,i)}:/\s/.test(o)?function(e){return/\s/.test(e)}:function(e){return!/\s/.test(e)&&!te(e)};0<n&&l(t.charAt(n-1));)--n;for(;r<t.length&&l(t.charAt(r));)++r}return new ci(lt(e.line,n),lt(e.line,r))},toggleOverwrite:function(e){null!=e&&e==this.state.overwrite||(((this.state.overwrite=!this.state.overwrite)?H:T)(this.display.cursorDiv,"CodeMirror-overwrite"),Se(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==W()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:Ur(function(e,t){Lr(this,e,t)}),getScrollInfo:function(){var e=this.display.scroller;return{left:e.scrollLeft,top:e.scrollTop,height:e.scrollHeight-Sn(this)-this.display.barHeight,width:e.scrollWidth-Sn(this)-this.display.barWidth,clientHeight:kn(this),clientWidth:Ln(this)}},scrollIntoView:Ur(function(e,t){var n,r;null==e?(e={from:this.doc.sel.primary().head,to:null},null==t&&(t=this.options.cursorScrollMargin)):"number"==typeof e?e={from:lt(e,0),to:null}:null==e.from&&(e={from:e,to:null}),e.to||(e.to=e.from),e.margin=t||0,null!=e.from.line?(r=e,kr(n=this),n.curOp.scrollToPos=r):Tr(this,e.from,e.to,e.margin)}),setSize:Ur(function(e,t){function n(e){return"number"==typeof e||/^\d+$/.test(String(e))?e+"px":e}var r=this;null!=e&&(this.display.wrapper.style.width=n(e)),null!=t&&(this.display.wrapper.style.height=n(t)),this.options.lineWrapping&&Pn(this);var i=this.display.viewFrom;this.doc.iter(i,this.display.viewTo,function(e){if(e.widgets)for(var t=0;t<e.widgets.length;t++)if(e.widgets[t].noHScroll){or(r,i,"widget");break}++i}),this.curOp.forceUpdate=!0,Se(this,"refresh",this)}),operation:function(e){return Br(this,e)},startOperation:function(){return Rr(this)},endOperation:function(){return zr(this)},refresh:Ur(function(){var e=this.display.cachedTextHeight;ir(this),this.curOp.forceUpdate=!0,En(this),Lr(this,this.doc.scrollLeft,this.doc.scrollTop),qr(this.display),(null==e||.5<Math.abs(e-qn(this.display))||this.options.lineWrapping)&&tr(this),Se(this,"refresh",this)}),swapDoc:Ur(function(e){var t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),Ci(this,e),En(this),this.display.input.reset(),Lr(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,un(this,"swapDoc",this,t),t}),phrase:function(e){var t=this.options.phrases;return t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:e},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Me(Fl),Fl.registerHelper=function(e,t,n){El.hasOwnProperty(e)||(El[e]=Fl[e]={_global:[]}),El[e][t]=n},Fl.registerGlobalHelper=function(e,t,n,r){Fl.registerHelper(e,t,r),El[e]._global.push({pred:n,val:r})};var Rl,zl="iter insert remove copy getEditor constructor".split(" ");for(var Bl in vo.prototype)vo.prototype.hasOwnProperty(Bl)&&B(zl,Bl)<0&&(pl.prototype[Bl]=function(e){return function(){return e.apply(this.doc,arguments)}}(vo.prototype[Bl]));return Me(vo),pl.inputStyles={textarea:Dl,contenteditable:Ml},pl.defineMode=function(e){pl.defaults.mode||"null"==e||(pl.defaults.mode=e),function(e,t){2<arguments.length&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Ue[e]=t}.apply(this,arguments)},pl.defineMIME=function(e,t){Ve[e]=t},pl.defineMode("null",function(){return{token:function(e){return e.skipToEnd()}}}),pl.defineMIME("text/plain","null"),pl.defineExtension=function(e,t){pl.prototype[e]=t},pl.defineDocExtension=function(e,t){vo.prototype[e]=t},pl.fromTextArea=function(t,n){var e;function r(){t.value=s.getValue()}if((n=n?I(n):{}).value=t.value,!n.tabindex&&t.tabIndex&&(n.tabindex=t.tabIndex),!n.placeholder&&t.placeholder&&(n.placeholder=t.placeholder),null==n.autofocus&&(e=W(),n.autofocus=e==t||null!=t.getAttribute("autofocus")&&e==document.body),t.form&&(we(t.form,"submit",r),!n.leaveSubmitMethodAlone)){var i=t.form,o=i.submit;try{var l=i.submit=function(){r(),i.submit=o,i.submit(),i.submit=l}}catch(e){}}n.finishInit=function(e){e.save=r,e.getTextArea=function(){return t},e.toTextArea=function(){e.toTextArea=isNaN,r(),t.parentNode.removeChild(e.getWrapperElement()),t.style.display="",t.form&&(Ce(t.form,"submit",r),n.leaveSubmitMethodAlone||"function"!=typeof t.form.submit||(t.form.submit=o))}},t.style.display="none";var s=pl(function(e){return t.parentNode.insertBefore(e,t.nextSibling)},n);return s},(Rl=pl).off=Ce,Rl.on=we,Rl.wheelEventPixels=si,Rl.Doc=vo,Rl.splitLines=Re,Rl.countColumn=R,Rl.findColumn=X,Rl.isWordChar=ee,Rl.Pass=U,Rl.signal=Se,Rl.Line=$t,Rl.changeEnd=fi,Rl.scrollbarModel=Pr,Rl.Pos=lt,Rl.cmpPos=st,Rl.modes=Ue,Rl.mimeModes=Ve,Rl.resolveMode=Ke,Rl.getMode=je,Rl.modeExtensions=Xe,Rl.extendMode=Ye,Rl.copyState=_e,Rl.startState=qe,Rl.innerMode=$e,Rl.commands=Uo,Rl.keyMap=Ao,Rl.keyName=Po,Rl.isModifierKey=Ho,Rl.lookupKey=Wo,Rl.normalizeKeyMap=Do,Rl.StringStream=Ze,Rl.SharedTextMarker=po,Rl.TextMarker=ho,Rl.LineWidget=ao,Rl.e_preventDefault=Ne,Rl.e_stopPropagation=Ae,Rl.e_stop=De,Rl.addClass=H,Rl.contains=D,Rl.rmClass=T,Rl.keyNames=ko,pl.version="5.58.2",pl});