tianta/_server/CodeMirror/codeMirror.bundle.min.js
2022-10-17 02:58:52 +13:00

1 line
186 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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