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