nomnoml
Version:
The sassy UML renderer that generates diagrams from text
1 lines • 188 kB
JavaScript
!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),w=n||r||i,x=w&&(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),u=/Apple Computer/.test(navigator.vendor),s=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e),c=/PhantomJS/.test(e),a=!i&&/AppleWebKit/.test(e)&&/Mobile\/\w+/.test(e),h=/Android/.test(e),f=a||h||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),y=a||/Mac/.test(t),d=/\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 C=y&&(o||m&&(null==b||b<12.11)),S=g||w&&9<=x;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 A(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 N(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 F(e,t){var n=e.className;L(t).test(n)||(e.className+=(n?" ":"")+t)}function H(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 B(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t)}}function R(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 E(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}:w&&(P=function(e){try{e.select()}catch(e){}});var I=function(){this.id=null,this.f=null,this.time=0,this.handler=B(this.onTimeout,this)};function z(e,t){for(var n=0;n<e.length;++n)if(e[n]==t)return n;return-1}I.prototype.onTimeout=function(e){e.id=0,e.time<=+new Date?e.f():setTimeout(e.handler,e.time-new Date)},I.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 K=50,U={toString:function(){return"CodeMirror.Pass"}},G={scroll:!1},V={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 q(e){for(;Y.length<=e;)Y.push(_(Y)+" ");return Y[e]}function _(e){return e[e.length-1]}function $(e,t){for(var n=[],r=0;r<e.length;r++)n[r]=t(e[r],r);return n}function Z(){}function J(e,t){var n=Object.create?Object.create(e):(Z.prototype=e,new Z);return t&&R(t,n),n}var Q=/[\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()||Q.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 ce,ue,he,fe,de,pe,ge,me=(ce="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",ue="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111",he=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,fe=/[stwN]/,de=/[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?ce.charAt(r):1424<=r&&r<=1524?"R":1536<=r&&r<=1785?ue.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 c=o[s];"m"==c?o[s]=a:a=c}for(var u=0,h=n;u<i;++u){var f=o[u];"1"==f&&"r"==h?o[u]="n":de.test(f)&&"r"==(h=f)&&(o[u]="R")}for(var d=1,p=o[0];d<i-1;++d){var g=o[d];"+"==g&&"1"==p&&"1"==o[d+1]?o[d]="1":","!=g||p!=o[d+1]||"1"!=p&&"n"!=p||(o[d]=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",C=m;C<y;++C)o[C]=b;m=y-1}}for(var w=0,x=n;w<i;++w){var S=o[w];"L"==x&&"1"==S?o[w]="L":de.test(S)&&(x=S)}for(var L=0;L<i;++L)if(fe.test(o[L])){for(var k=void 0,k=L+1;k<i&&fe.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,A=L;A<k;++A)o[A]=M;L=k-1}for(var N,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 F=D,H=O.length,P="rtl"==t?1:0;for(++D;D<i&&"L"!=o[D];++D);for(var B=F;B<D;)if(ge.test(o[B])){F<B&&(O.splice(H,0,new ve(1,F,B)),H+=P);var R=B;for(++B;B<D&&ge.test(o[B]);++B);O.splice(H,0,new ve(2,R,B)),H+=P,F=B}else++B;F<D&&O.splice(H,0,new ve(1,F,D))}return"ltr"==t&&(1==O[0].level&&(N=e.match(/^\s+/))&&(O[0].from=N[0].length,O.unshift(new ve(0,0,N[0].length))),1==_(O).level&&(N=e.match(/\s+$/))&&(_(O).to-=N[0].length,O.push(new ve(0,i-N[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=[],Ce=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 we(e,t){return e._handlers&&e._handlers[t]||be}function xe(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=z(i,n))&&(r[t]=i.slice(0,o).concat(i.slice(o+1)))}function Se(e,t){var n=we(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==z(n,t[r])&&n.push(t[r])}function Te(e,t){return 0<we(e,t).length}function Me(e){e.prototype.on=function(e,t){Ce(this,e,t)},e.prototype.off=function(e,t){xe(this,e,t)}}function Ae(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function Ne(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function Oe(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function De(e){Ae(e),Ne(e)}function We(e){return e.target||e.srcElement}function Fe(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 He,Pe,Be=function(){if(w&&x<9)return!1;var e=O("div");return"draggable"in e||"dragDrop"in e}();var Re,Ee=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/)},Ie=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)},ze="oncopy"in(Re=O("div"))||(Re.setAttribute("oncopy","return;"),"function"==typeof Re.oncopy),Ke=null;var Ue={},Ge={};function Ve(e){if("string"==typeof e&&Ge.hasOwnProperty(e))e=Ge[e];else if(e&&"string"==typeof e.name&&Ge.hasOwnProperty(e.name)){var t=Ge[e.name];"string"==typeof t&&(t={name:t}),(e=J(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Ve("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Ve("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function je(e,t){t=Ve(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){R(t,Xe.hasOwnProperty(e)?Xe[e]:Xe[e]={})}function qe(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 $e(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 Je(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 Qe(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=z(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 ct(e){return lt(e.line,e.ch)}function ut(e,t){return st(e,t)<0?t:e}function ht(e,t){return st(e,t)<0?e:t}function ft(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function dt(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,Je(e,o).text.length):(r=Je(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]=dt(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=E(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?E(this.string,this.lineStart,this.tabSize):0)},Ze.prototype.indentation=function(){return E(this.string,null,this.tabSize)-(this.lineStart?E(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 c=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=c,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&&qe(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=Je(o,s-1),c=a.stateAfter;if(c&&(!n||s+(c instanceof gt?c.lookAhead:0)<=o.modeFrontier))return s;var u=E(a.text,null,e.options.tabSize);(null==i||u<r)&&(i=s-1,r=u)}return i}(n,r,e),l=o>t.first&&Je(t,o-1).stateAfter,s=l?mt.fromSaved(t,l,o):new mt(t,$e(t.mode),o);return t.iter(o,r,function(e){Ct(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 Ct(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&&wt(i,n.state);!o.eol();)xt(i,o,n.state),o.start=o.pos}function wt(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 xt(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,qe(e.mode,t.state),n,t.lookAhead):new mt(e,qe(e.mode,t),n)},mt.prototype.save=function(e){var t=!1!==e?qe(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=Je(l,(t=dt(l,t)).line),c=bt(e,t.line,n),u=new Ze(a.text,e.options.tabSize,c);for(r&&(o=[]);(r||u.pos<t.ch)&&!u.eol();)u.start=u.pos,i=xt(s,u,c.state),r&&o.push(new St(u,i,qe(l.mode,c.state)));return r?o:new St(u,i,c.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,c=null,u=new Ze(t,e.options.tabSize,r),h=e.options.addModeClass&&[null];for(""==t&&kt(wt(n,r.state),o);!u.eol();){var f,d=u.pos>e.options.maxHighlightLength?(s=!1,l&&Ct(e,t,r,u.pos),u.pos=t.length,null):kt(xt(n,u,r.state,h),o);if(!h||(f=h[0].name)&&(d="m-"+(d?f+" "+d:f)),!s||c!=d){for(;a<u.start;)i(a=Math.min(u.start,a+5e3),c);c=d}u.start=u.pos}for(;a<u.pos;){var p=Math.min(u.pos,a+5e3);i(p,c),a=p}}var Mt=!1,At=!1;function Nt(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)&&Je(e,t.from.line).markedSpans,r=it(e,t.to.line)&&Je(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 Nt(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 Nt(s,o?null:l.from-t,null==l.to?null:l.to-t)))}return r}(r,o,l),c=1==t.text.length,u=_(t.text).length+(c?i:0);if(s)for(var h=0;h<s.length;++h){var f,d=s[h];null==d.to&&((f=Ot(a,d.marker))?c&&(d.to=null==f.to?null:f.to+u):d.to=i)}if(a)for(var p=0;p<a.length;++p){var g=a[p];null!=g.to&&(g.to+=u),null==g.from?Ot(s,g.marker)||(g.from=u,c&&(s=s||[]).push(g)):(g.from+=u,c&&(s=s||[]).push(g))}s=s&&Wt(s),a&&a!=s&&(a=Wt(a));var m=[s];if(!c){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 Nt(s[b].marker,null,null));for(var C=0;C<y;++C)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 Ft(e){var t=e.markedSpans;if(t){for(var n=0;n<t.length;++n)t[n].marker.detachLine(e);e.markedSpans=null}}function Ht(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 Bt(e){return e.inclusiveRight?1:0}function Rt(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)||Bt(e)-Bt(t);return l||t.id-e.id}function Et(e,t){var n,r=At&&e.markedSpans;if(r)for(var i,o=0;o<r.length;++o)(i=r[o]).marker.collapsed&&null==(t?i.from:i.to)&&(!n||Rt(n,i.marker)<0)&&(n=i.marker);return n}function It(e){return Et(e,!0)}function zt(e){return Et(e,!1)}function Kt(e,t,n,r,i){var o=Je(e,t),l=At&&o.markedSpans;if(l)for(var s=0;s<l.length;++s){var a=l[s];if(a.marker.collapsed){var c=a.marker.find(0),u=st(c.from,n)||Pt(a.marker)-Pt(i),h=st(c.to,r)||Bt(a.marker)-Bt(i);if(!(0<=u&&h<=0||u<=0&&0<=h)&&(u<=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?0<=st(c.to,n):0<st(c.to,n))||0<=u&&(a.marker.inclusiveRight&&i.inclusiveLeft?st(c.from,r)<=0:st(c.from,r)<0)))return 1}}}function Ut(e){for(var t;t=It(e);)e=t.find(-1,!0).line;return e}function Gt(e,t){var n=Je(e,t),r=Ut(n);return n==r?t:nt(r)}function Vt(e,t){if(t>e.lastLine())return t;var n,r=Je(e,t);if(!jt(e,r))return t;for(;n=zt(r);)r=n.find(1,!0).line;return nt(r)+1}function jt(e,t){var n=At&&t.markedSpans;if(n)for(var r,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=It(r);){var i=t.find(0,!0),r=i.from.line;n+=i.from.ch-i.to.ch}for(r=e;t=zt(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 qt(e){var n=e.display,t=e.doc;n.maxLine=Je(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,Ht(this,t),this.height=n?n(this):1};_t.prototype.lineNo=function(){return nt(this)},Me(_t);var $t={},Zt={};function Jt(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?Zt:$t;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Qt(e,t){var n=N("span",null,null,v?"padding-right: .1px":null),r={pre:N("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=A(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,f){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 c=void 0,u=0;u<f.length&&!((c=f[u]).to>s&&c.from<=s);u++);if(c.to>=a)return h(e,t,n,r,i,o,l);h(e,t.slice(0,c.to-s),n,r,null,o,l),r=null,t=t.slice(c.to-s),s=c.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]),Jt(n[l+1],t.cm.options));return}for(var s,a,c,u,h,f,d,p=i.length,g=0,m=1,v="",y=0;;){if(y==g){c=u=h=a="",f=d=null,y=1/0;for(var b=[],C=void 0,w=0;w<r.length;++w){var x=r[w],S=x.marker;if("bookmark"==S.type&&x.from==g&&S.widgetNode)b.push(S);else if(x.from<=g&&(null==x.to||x.to>g||S.collapsed&&x.to==g&&x.from==g)){if(null!=x.to&&x.to!=g&&y>x.to&&(y=x.to,u=""),S.className&&(c+=" "+S.className),S.css&&(a=(a?a+";":"")+S.css),S.startStyle&&x.from==g&&(h+=" "+S.startStyle),S.endStyle&&x.to==y&&(C=C||[]).push(S.endStyle,x.to),S.title&&((d=d||{}).title=S.title),S.attributes)for(var L in S.attributes)(d=d||{})[L]=S.attributes[L];S.collapsed&&(!f||Rt(f.marker,S)<0)&&(f=x)}else x.from>g&&y>x.from&&(y=x.from)}if(C)for(var k=0;k<C.length;k+=2)C[k+1]==y&&(u+=" "+C[k]);if(!f||f.from==g)for(var T=0;T<b.length;++T)nn(t,0,b[T]);if(f&&(f.from||0)==g){if(nn(t,(null==f.to?p+1:f.to)-g,f.marker,null==f.from),null==f.to)return;f.to==g&&(f=!1)}}if(p<=g)break;for(var M=Math.min(p,y);;){if(v){var A,N=g+v.length;if(f||(A=M<N?v.slice(0,M-g):v,t.addToken(t,A,s?s+c:c,h,g+A.length==y?u:"",a,d)),M<=N){v=v.slice(M-g),g=M;break}g=N,h=""}v=i.slice(o,o=n[m++]),s=Jt(n[m++],t.cm.options)}}}(l,r,yt(e,l,t!=e.display.externalMeasured&&nt(l))),l.styleClasses&&(l.styleClasses.bgClass&&(r.bgClass=H(l.styleClasses.bgClass,r.bgClass||"")),l.styleClasses.textClass&&(r.textClass=H(l.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(function(e){var t;null==He&&(t=O("span",""),A(e,O("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(He=t.offsetWidth<=1&&2<t.offsetHeight&&!(w&&x<8)));var n=He?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=H(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,c=e.cm.state.specialChars,u=!1;if(c.test(t)){s=document.createDocumentFragment();for(var h=0;;){c.lastIndex=h;var f,d=c.exec(t),p=d?d.index-h:t.length-h;if(p&&(f=document.createTextNode(a.slice(h,h+p)),w&&x<9?s.appendChild(O("span",[f])):s.appendChild(f),e.map.push(e.pos,e.pos+p,f),e.col+=p,e.pos+=p),!d)break;h+=1+p;var g,m,v=void 0;"\t"==d[0]?(m=(g=e.cm.options.tabSize)-e.col%g,(v=s.appendChild(O("span",q(m),"cm-tab"))).setAttribute("role","presentation"),v.setAttribute("cm-text","\t"),e.col+=m):("\r"==d[0]||"\n"==d[0]?(v=s.appendChild(O("span","\r"==d[0]?"␍":"","cm-invalidchar"))).setAttribute("cm-text",d[0]):((v=e.cm.options.specialCharPlaceholder(d[0])).setAttribute("cm-text",d[0]),w&&x<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),w&&x<9&&(u=!0),e.pos+=t.length;if(e.trailingSpace=32==a.charCodeAt(t.length-1),n||r||i||u||o){var y=n||"";r&&(y+=r),i&&(y+=i);var b=O("span",[s],y,o);if(l)for(var C in l)l.hasOwnProperty(C)&&"style"!=C&&"class"!=C&&b.setAttribute(C,l[C]);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=zt(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,Je(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 cn(e,t){var n=we(e,t);if(n.length){var r,i=Array.prototype.slice.call(arguments,2);ln?r=ln.delayedCallbacks:an?r=an:(r=an=[],setTimeout(un,0));for(var o=0;o<n.length;++o)!function(e){r.push(function(){return n[e].apply(null,i)})}(o)}}function un(){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=dn(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 fn(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),w&&x<8&&(e.node.style.zIndex=2)),e.node}function dn(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Qt(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=fn(r),r.background=i.insertBefore(O("div",null,o),i.firstChild),n.display.input.setUneditable(r.background)),t.line.wrapClass?fn(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=fn(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=fn(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 c=e.display.gutterSpecs[a].className,u=o.hasOwnProperty(c)&&o[c];u&&s.appendChild(O("div",[u],"CodeMirror-gutter-elt","left: "+r.gutterLeft[c]+"px; width: "+r.gutterWidth[c]+"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=fn(n),l=0,s=t.widgets;l<s.length;++l){var a=s[l],c=O("div",[a.node],"CodeMirror-linewidget"+(a.className?" "+a.className:""));a.handleMouseEvents||c.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,c,n,r),e.display.input.setUneditable(c),i&&a.above?o.insertBefore(c,n.gutter||n.text):o.appendChild(c),cn(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;"),A(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 Cn(e){return e.lineSpace.offsetTop}function wn(e){return e.mover.offsetHeight-e.lineSpace.offsetHeight}function xn(e){if(e.cachedPaddingH)return e.cachedPaddingH;var t=A(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 K-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,Nn(e,t),n,r)}function An(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 Nn(e,t){var n=nt(t),r=An(e,n);r&&!r.text?r=null:r&&r.changes&&(hn(e,r,n,Jn(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=Qt(e,r);return r.text=i.pre,A(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],c=l[s+1];2<Math.abs(a.bottom-c.bottom)&&o.push((a.bottom+c.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=Fn(t.map,n,r),s=l.node,a=l.start,c=l.end,u=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+c<l.coverEnd&&ie(t.line.text.charAt(l.coverStart+c));)++c;if((i=w&&x<9&&0==a&&c==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,c).getClientRects(),r)).left||i.right||0==a)break;c=a,--a,u="right"}w&&x<11&&(i=function(e,t){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!function(e){if(null!=Ke)return Ke;var t=A(e,O("span","x")),n=t.getBoundingClientRect(),r=k(t,0,1).getBoundingClientRect();return Ke=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&&(u=r="right"),i=e.options.lineWrapping&&1<(o=s.getClientRects()).length?o["right"==r?o.length-1:0]:s.getBoundingClientRect();{var f;!(w&&x<9)||a||i&&(i.left||i.right)||(f=s.parentNode.getClientRects()[0],i=f?{left:f.left,right:f.left+Zn(e.display),top:f.top,bottom:f.bottom}:Wn)}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,g=(d+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],C={left:("right"==u?i.right:i.left)-t.rect.left,right:("left"==u?i.left:i.right)-t.rect.left,top:y,bottom:b};i.left||i.right||(C.bogus=!0);e.options.singleCursorHeightPerLine||(C.rtop=d,C.rbottom=p);return C}(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 Fn(e,t,n){for(var r,i,o,l,s,a,c=0;c<e.length;c+=3)if(s=e[c],a=e[c+1],t<s?(i=0,o=1,l="left"):t<a?o=(i=t-s)+1:(c==e.length-3||t==a&&e[c+3]>t)&&(i=(o=a-s)-1,a<=t&&(l="right")),null!=i){if(r=e[c+2],s==a&&n==(r.insertLeft?"left":"right")&&(l=n),"left"==n&&0==i)for(;c&&e[c-2]==e[c-3]&&e[c-1].insertLeft;)r=e[2+(c-=3)],l="left";if("right"==n&&i==a-s)for(;c<e.length-3&&e[c+3]==e[c+4]&&!e[c+5].insertLeft;)r=e[(c+=3)+2],l="right";break}return{node:r,start:i,end:o,collapse:l,coverStart:s,coverEnd:a}}function Hn(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++)Hn(e.display.view[t])}function Bn(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 Rn(){return l&&h?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function En(){return l&&h?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function In(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 zn(e,t,n,r,i){var o;if(i||(o=In(t),n.top+=o,n.bottom+=o),"line"==r)return n;r=r||"local";var l,s,a=Xt(t);return"local"==r?a+=Cn(e.display):a-=e.display.viewOffset,"page"!=r&&"window"!=r||(a+=(l=e.display.lineSpace.getBoundingClientRect()).top+("window"==r?0:En()),s=l.left+("window"==r?0:Rn()),n.left+=s,n.right+=s),n.top+=a,n.bottom+=a,n}function Kn(e,t,n){if("div"==n)return t;var r,i=t.left,o=t.top;"page"==n?(i-=Rn(),o-=En()):"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 zn(e,r=r||Je(e.doc,t.line),Mn(e,r,t.ch,i),n)}function Gn(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,zn(r,o,n,i)}o=o||Je(r.doc,e.line),l=l||Nn(r,o);var c=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"),!c)return a("before"==n?t-1:t,"before"==n);function u(e,t,n){return a(n?e-1:e,1==c[t].level!=n)}var h=ae(c,t,n),f=se,d=u(t,h,"before"==n);return null!=f&&(d.other=u(t,f,"before"!=n)),d}function Vn(e,t){var n=0;t=dt(e.doc,t),e.options.lineWrapping||(n=Zn(e.display)*t.ch);var r=Je(e.doc,t.line),i=Xt(r)+Cn(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,Je(r,o).text.length,null,1,1);t<0&&(t=0);for(var l=Je(r,i);;){var s=function(n,e,t,r,i){i-=Xt(e);var o=Nn(n,e),l=In(e),s=0,a=e.text.length,c=!0,u=ye(e,n.doc.direction);{var h;u&&(h=(n.options.lineWrapping?function(e,t,n,r,i,o,l){var s=Yn(e,t,r,l),a=s.begin,c=s.end;/\s/.test(t.text.charAt(c-1))&&c--;for(var u=null,h=null,f=0;f<i.length;f++){var d,p,g,m=i[f];m.from>=c||m.to<=a||(d=1!=m.level,p=On(e,r,d?Math.min(c,m.to)-1:Math.max(a,m.from)).right,g=p<o?o-p+1e9:p-o,(!u||g<h)&&(u=m,h=g))}u=u||i[i.length-1];u.from<a&&(u={from:a,to:u.to,level:u.level});u.to>c&&(u={from:u.from,to:c,level:u.level});return u}:function(r,i,o,l,s,a,c){var e=le(function(e){var t=s[e],n=1!=t.level;return _n(Gn(r,lt(o,n?t.to:t.from,n?"before":"after"),"line",i,l),a,c,!0)},0,s.length-1),t=s[e];{var n,u;0<e&&(n=1!=t.level,_n(u=Gn(r,lt(o,n?t.from:t.to,n?"after":"before"),"line",i,l),a,c,!0)&&u.top>c&&(t=s[e-1]))}return t})(n,e,t,o,u,r,i),c=1!=h.level,s=c?h.from:h.to-1,a=c?h.to:h.from-1)}var f,d,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,C;g?(y=r-g.left<g.right-r,m=p+((b=y==c)?0:1),d=b?"after":"before",f=y?g.left:g.right):(c||m!=a&&m!=s||m++,d=0==m||m!=e.text.length&&On(n,o,m-(c?1:0)).bottom+l<=i==c?"after":"before",C=Gn(n,lt(t,m,d),"line",e,o),f=C.left,v=i<C.top?-1:i>=C.bottom?1:0)}return m=oe(e.text,m,1),jn(t,m,d,v,r-f)}(e,l,i,t,n),a=function(e,t){var n,r=At&&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||Rt(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 c=a.find(1);if(c.line==i)return c;l=Je(r,i=c.line)}}function Yn(t,e,n,r){r-=In(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 qn(e,t,n,r){return Yn(e,t,n=n||Nn(e,t),zn(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 $n(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"))}A(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");A(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return 2<i&&(e.cachedCharWidth=i),i||10}function Jn(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:Qn(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function Qn(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function er(r){var i=$n(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,c,u=Xn(e,o,l);return r&&0<u.xRel&&(a=Je(e.doc,u.line).text).length==u.ch&&(c=E(a,a.length,e.options.tabSize)-a.length,u=lt(u.line,Math.max(0,Math.round((o-xn(e.display).left)/Zn(e.display))-c))),u}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?At&&Gt(e.doc,t)<a.viewTo&&lr(e):n<=a.viewFrom?At&&Vt(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 c=a.externalMeasured;c&&(n<c.lineN?c.lineN+=r:t<c.lineN+c.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==z(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(!At||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(;Gt(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 cr(e){e.display.input.showSelection(e.display.input.prepareSelection())}function ur(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=xn(l.display),T=o.left,M=Math.max(n.sizerWidth,Ln(l)-n.sizer.offsetLeft)-o.right,A="ltr"==r.direction;function N(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 C,w,o=Je(r,n),x=o.text.length;function S(e,t){return Un(l,lt(n,e),"div",o,t)}function L(e,t,n){var r=qn(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?x:b,function(e,t,n,r){var i,o,l,s,a,c,u,h="ltr"==n,f=S(e,h?"left":"right"),d=S(t-1,h?"right":"left"),p=null==y&&0==e,g=null==b&&t==x,m=0==r,v=!k||r==k.length-1;d.top-f.top<=3?(i=(A?g:p)&&v,o=(A?p:g)&&m?T:(h?f:d).left,l=i?M:(h?d:f).right,N(o,f.top,l-o,f.bottom)):(u=h?(s=A&&p&&m?T:f.left,a=A?M:L(e,n,"before"),c=A?T:L(t,n,"after"),A&&g&&v?M:d.right):(s=A?L(e,n,"before"):T,a=!A&&p&&m?M:f.right,c=!A&&g&&v?T:d.left,A?L(t,n,"after"):M),N(s,f.top,a-s,f.bottom),f.bottom<d.top&&N(T,f.bo