UNPKG

mergely

Version:

A javascript UI for diff/merge

1 lines 246 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.mergely=e():t.mergely=e()}(self,(()=>(()=>{var t={653:(t,e,n)=>{!function(t){"use strict";var e,n,r=t.Pos;function i(t){var e=t.flags;return null!=e?e:(t.ignoreCase?"i":"")+(t.global?"g":"")+(t.multiline?"m":"")}function o(t,e){for(var n=i(t),r=n,o=0;o<e.length;o++)-1==r.indexOf(e.charAt(o))&&(r+=e.charAt(o));return n==r?t:new RegExp(t.source,r)}function s(t){return/\\s|\\n|\n|\\W|\\D|\[\^/.test(t.source)}function l(t,e,n){e=o(e,"g");for(var i=n.line,s=n.ch,l=t.lastLine();i<=l;i++,s=0){e.lastIndex=s;var a=t.getLine(i),c=e.exec(a);if(c)return{from:r(i,c.index),to:r(i,c.index+c[0].length),match:c}}}function a(t,e,n){if(!s(e))return l(t,e,n);e=o(e,"gm");for(var i,a=1,c=n.line,h=t.lastLine();c<=h;){for(var u=0;u<a&&!(c>h);u++){var d=t.getLine(c++);i=null==i?d:i+"\n"+d}a*=2,e.lastIndex=n.ch;var f=e.exec(i);if(f){var p=i.slice(0,f.index).split("\n"),g=f[0].split("\n"),m=n.line+p.length-1,v=p[p.length-1].length;return{from:r(m,v),to:r(m+g.length-1,1==g.length?v+g[0].length:g[g.length-1].length),match:f}}}}function c(t,e,n){for(var r,i=0;i<=t.length;){e.lastIndex=i;var o=e.exec(t);if(!o)break;var s=o.index+o[0].length;if(s>t.length-n)break;(!r||s>r.index+r[0].length)&&(r=o),i=o.index+1}return r}function h(t,e,n){e=o(e,"g");for(var i=n.line,s=n.ch,l=t.firstLine();i>=l;i--,s=-1){var a=t.getLine(i),h=c(a,e,s<0?0:a.length-s);if(h)return{from:r(i,h.index),to:r(i,h.index+h[0].length),match:h}}}function u(t,e,n){if(!s(e))return h(t,e,n);e=o(e,"gm");for(var i,l=1,a=t.getLine(n.line).length-n.ch,u=n.line,d=t.firstLine();u>=d;){for(var f=0;f<l&&u>=d;f++){var p=t.getLine(u--);i=null==i?p:p+"\n"+i}l*=2;var g=c(i,e,a);if(g){var m=i.slice(0,g.index).split("\n"),v=g[0].split("\n"),y=u+m.length,b=m[m.length-1].length;return{from:r(y,b),to:r(y+v.length-1,1==v.length?b+v[0].length:v[v.length-1].length),match:g}}}}function d(t,e,n,r){if(t.length==e.length)return n;for(var i=0,o=n+Math.max(0,t.length-e.length);;){if(i==o)return i;var s=i+o>>1,l=r(t.slice(0,s)).length;if(l==n)return s;l>n?o=s:i=s+1}}function f(t,i,o,s){if(!i.length)return null;var l=s?e:n,a=l(i).split(/\r|\n\r?/);t:for(var c=o.line,h=o.ch,u=t.lastLine()+1-a.length;c<=u;c++,h=0){var f=t.getLine(c).slice(h),p=l(f);if(1==a.length){var g=p.indexOf(a[0]);if(-1==g)continue t;return o=d(f,p,g,l)+h,{from:r(c,d(f,p,g,l)+h),to:r(c,d(f,p,g+a[0].length,l)+h)}}var m=p.length-a[0].length;if(p.slice(m)==a[0]){for(var v=1;v<a.length-1;v++)if(l(t.getLine(c+v))!=a[v])continue t;var y=t.getLine(c+a.length-1),b=l(y),w=a[a.length-1];if(b.slice(0,w.length)==w)return{from:r(c,d(f,p,m,l)+h),to:r(c+a.length-1,d(y,b,w.length,l))}}}}function p(t,i,o,s){if(!i.length)return null;var l=s?e:n,a=l(i).split(/\r|\n\r?/);t:for(var c=o.line,h=o.ch,u=t.firstLine()-1+a.length;c>=u;c--,h=-1){var f=t.getLine(c);h>-1&&(f=f.slice(0,h));var p=l(f);if(1==a.length){var g=p.lastIndexOf(a[0]);if(-1==g)continue t;return{from:r(c,d(f,p,g,l)),to:r(c,d(f,p,g+a[0].length,l))}}var m=a[a.length-1];if(p.slice(0,m.length)==m){var v=1;for(o=c-a.length+1;v<a.length-1;v++)if(l(t.getLine(o+v))!=a[v])continue t;var y=t.getLine(c+1-a.length),b=l(y);if(b.slice(b.length-a[0].length)==a[0])return{from:r(c+1-a.length,d(y,b,y.length-a[0].length,l)),to:r(c,d(f,p,m.length,l))}}}}function g(t,e,n,i){var s;this.atOccurrence=!1,this.afterEmptyMatch=!1,this.doc=t,n=n?t.clipPos(n):r(0,0),this.pos={from:n,to:n},"object"==typeof i?s=i.caseFold:(s=i,i=null),"string"==typeof e?(null==s&&(s=!1),this.matches=function(n,r){return(n?p:f)(t,e,r,s)}):(e=o(e,"gm"),i&&!1===i.multiline?this.matches=function(n,r){return(n?h:l)(t,e,r)}:this.matches=function(n,r){return(n?u:a)(t,e,r)})}String.prototype.normalize?(e=function(t){return t.normalize("NFD").toLowerCase()},n=function(t){return t.normalize("NFD")}):(e=function(t){return t.toLowerCase()},n=function(t){return t}),g.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(e){var n=this.doc.clipPos(e?this.pos.from:this.pos.to);if(this.afterEmptyMatch&&this.atOccurrence&&(n=r(n.line,n.ch),e?(n.ch--,n.ch<0&&(n.line--,n.ch=(this.doc.getLine(n.line)||"").length)):(n.ch++,n.ch>(this.doc.getLine(n.line)||"").length&&(n.ch=0,n.line++)),0!=t.cmpPos(n,this.doc.clipPos(n))))return this.atOccurrence=!1;var i=this.matches(e,n);if(this.afterEmptyMatch=i&&0==t.cmpPos(i.from,i.to),i)return this.pos=i,this.atOccurrence=!0,this.pos.match||!0;var o=r(e?this.doc.firstLine():this.doc.lastLine()+1,0);return this.pos={from:o,to:o},this.atOccurrence=!1},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(e,n){if(this.atOccurrence){var i=t.splitLines(e);this.doc.replaceRange(i,this.pos.from,this.pos.to,n),this.pos.to=r(this.pos.from.line+i.length-1,i[i.length-1].length+(1==i.length?this.pos.from.ch:0))}}},t.defineExtension("getSearchCursor",(function(t,e,n){return new g(this.doc,t,e,n)})),t.defineDocExtension("getSearchCursor",(function(t,e,n){return new g(this,t,e,n)})),t.defineExtension("selectMatches",(function(e,n){for(var r=[],i=this.getSearchCursor(e,this.getCursor("from"),n);i.findNext()&&!(t.cmpPos(i.to(),this.getCursor("to"))>0);)r.push({anchor:i.from(),head:i.to()});r.length&&this.setSelections(r,0)}))}(n(237))},533:(t,e,n)=>{!function(t){"use strict";function e(t){t.state.markedSelection&&t.operation((function(){c(t)}))}function n(t){t.state.markedSelection&&t.state.markedSelection.length&&t.operation((function(){l(t)}))}t.defineOption("styleSelectedText",!1,(function(r,i,o){var s=o&&o!=t.Init;i&&!s?(r.state.markedSelection=[],r.state.markedSelectionStyle="string"==typeof i?i:"CodeMirror-selectedtext",a(r),r.on("cursorActivity",e),r.on("change",n)):!i&&s&&(r.off("cursorActivity",e),r.off("change",n),l(r),r.state.markedSelection=r.state.markedSelectionStyle=null)}));var r=8,i=t.Pos,o=t.cmpPos;function s(t,e,n,s){if(0!=o(e,n))for(var l=t.state.markedSelection,a=t.state.markedSelectionStyle,c=e.line;;){var h=c==e.line?e:i(c,0),u=c+r,d=u>=n.line,f=d?n:i(u,0),p=t.markText(h,f,{className:a});if(null==s?l.push(p):l.splice(s++,0,p),d)break;c=u}}function l(t){for(var e=t.state.markedSelection,n=0;n<e.length;++n)e[n].clear();e.length=0}function a(t){l(t);for(var e=t.listSelections(),n=0;n<e.length;n++)s(t,e[n].from(),e[n].to())}function c(t){if(!t.somethingSelected())return l(t);if(t.listSelections().length>1)return a(t);var e=t.getCursor("start"),n=t.getCursor("end"),i=t.state.markedSelection;if(!i.length)return s(t,e,n);var c=i[0].find(),h=i[i.length-1].find();if(!c||!h||n.line-e.line<=r||o(e,h.to)>=0||o(n,c.from)<=0)return a(t);for(;o(e,c.from)>0;)i.shift().clear(),c=i[0].find();for(o(e,c.from)<0&&(c.to.line-e.line<r?(i.shift().clear(),s(t,e,c.to,0)):s(t,e,c.from,0));o(n,h.to)<0;)i.pop().clear(),h=i[i.length-1].find();o(n,h.to)>0&&(n.line-h.from.line<r?(i.pop().clear(),s(t,h.from,n)):s(t,h.to,n))}}(n(237))},237:function(t){t.exports=function(){"use strict";var t=navigator.userAgent,e=navigator.platform,n=/gecko\/\d/i.test(t),r=/MSIE \d/.test(t),i=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(t),o=/Edge\/(\d+)/.exec(t),s=r||i||o,l=s&&(r?document.documentMode||6:+(o||i)[1]),a=!o&&/WebKit\//.test(t),c=a&&/Qt\/\d+\.\d+/.test(t),h=!o&&/Chrome\/(\d+)/.exec(t),u=h&&+h[1],d=/Opera\//.test(t),f=/Apple Computer/.test(navigator.vendor),p=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(t),g=/PhantomJS/.test(t),m=f&&(/Mobile\/\w+/.test(t)||navigator.maxTouchPoints>2),v=/Android/.test(t),y=m||v||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(t),b=m||/Mac/.test(e),w=/\bCrOS\b/.test(t),x=/win/i.test(e),_=d&&t.match(/Version\/(\d*\.\d*)/);_&&(_=Number(_[1])),_&&_>=15&&(d=!1,a=!0);var C=b&&(c||d&&(null==_||_<12.11)),k=n||s&&l>=9;function S(t){return new RegExp("(^|\\s)"+t+"(?:$|\\s)\\s*")}var L,M=function(t,e){var n=t.className,r=S(e).exec(n);if(r){var i=n.slice(r.index+r[0].length);t.className=n.slice(0,r.index)+(i?r[1]+i:"")}};function T(t){for(var e=t.childNodes.length;e>0;--e)t.removeChild(t.firstChild);return t}function O(t,e){return T(t).appendChild(e)}function N(t,e,n,r){var i=document.createElement(t);if(n&&(i.className=n),r&&(i.style.cssText=r),"string"==typeof e)i.appendChild(document.createTextNode(e));else if(e)for(var o=0;o<e.length;++o)i.appendChild(e[o]);return i}function A(t,e,n,r){var i=N(t,e,n,r);return i.setAttribute("role","presentation"),i}function D(t,e){if(3==e.nodeType&&(e=e.parentNode),t.contains)return t.contains(e);do{if(11==e.nodeType&&(e=e.host),e==t)return!0}while(e=e.parentNode)}function E(t){var e,n=t.ownerDocument||t;try{e=t.activeElement}catch(t){e=n.body||null}for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e}function W(t,e){var n=t.className;S(e).test(n)||(t.className+=(n?" ":"")+e)}function P(t,e){for(var n=t.split(" "),r=0;r<n.length;r++)n[r]&&!S(n[r]).test(e)&&(e+=" "+n[r]);return e}L=document.createRange?function(t,e,n,r){var i=document.createRange();return i.setEnd(r||t,n),i.setStart(t,e),i}:function(t,e,n){var r=document.body.createTextRange();try{r.moveToElementText(t.parentNode)}catch(t){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",e),r};var H=function(t){t.select()};function z(t){return t.display.wrapper.ownerDocument}function R(t){return F(t.display.wrapper)}function F(t){return t.getRootNode?t.getRootNode():t.ownerDocument}function I(t){return z(t).defaultView}function B(t){var e=Array.prototype.slice.call(arguments,1);return function(){return t.apply(null,e)}}function V(t,e,n){for(var r in e||(e={}),t)!t.hasOwnProperty(r)||!1===n&&e.hasOwnProperty(r)||(e[r]=t[r]);return e}function $(t,e,n,r,i){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);for(var o=r||0,s=i||0;;){var l=t.indexOf("\t",o);if(l<0||l>=e)return s+(e-o);s+=l-o,s+=n-s%n,o=l+1}}m?H=function(t){t.selectionStart=0,t.selectionEnd=t.value.length}:s&&(H=function(t){try{t.select()}catch(t){}});var U=function(){this.id=null,this.f=null,this.time=0,this.handler=B(this.onTimeout,this)};function G(t,e){for(var n=0;n<t.length;++n)if(t[n]==e)return n;return-1}U.prototype.onTimeout=function(t){t.id=0,t.time<=+new Date?t.f():setTimeout(t.handler,t.time-+new Date)},U.prototype.set=function(t,e){this.f=e;var n=+new Date+t;(!this.id||n<this.time)&&(clearTimeout(this.id),this.id=setTimeout(this.handler,t),this.time=n)};var j=50,K={toString:function(){return"CodeMirror.Pass"}},q={scroll:!1},X={origin:"*mouse"},Y={origin:"+move"};function Z(t,e,n){for(var r=0,i=0;;){var o=t.indexOf("\t",r);-1==o&&(o=t.length);var s=o-r;if(o==t.length||i+s>=e)return r+Math.min(s,e-i);if(i+=o-r,r=o+1,(i+=n-i%n)>=e)return r}}var J=[""];function Q(t){for(;J.length<=t;)J.push(tt(J)+" ");return J[t]}function tt(t){return t[t.length-1]}function et(t,e){for(var n=[],r=0;r<t.length;r++)n[r]=e(t[r],r);return n}function nt(t,e,n){for(var r=0,i=n(e);r<t.length&&n(t[r])<=i;)r++;t.splice(r,0,e)}function rt(){}function it(t,e){var n;return Object.create?n=Object.create(t):(rt.prototype=t,n=new rt),e&&V(e,n),n}var ot=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function st(t){return/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||ot.test(t))}function lt(t,e){return e?!!(e.source.indexOf("\\w")>-1&&st(t))||e.test(t):st(t)}function at(t){for(var e in t)if(t.hasOwnProperty(e)&&t[e])return!1;return!0}var ct=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function ht(t){return t.charCodeAt(0)>=768&&ct.test(t)}function ut(t,e,n){for(;(n<0?e>0:e<t.length)&&ht(t.charAt(e));)e+=n;return e}function dt(t,e,n){for(var r=e>n?-1:1;;){if(e==n)return e;var i=(e+n)/2,o=r<0?Math.ceil(i):Math.floor(i);if(o==e)return t(o)?e:n;t(o)?n=o:e=o+r}}function ft(t,e,n,r){if(!t)return r(e,n,"ltr",0);for(var i=!1,o=0;o<t.length;++o){var s=t[o];(s.from<n&&s.to>e||e==n&&s.to==e)&&(r(Math.max(s.from,e),Math.min(s.to,n),1==s.level?"rtl":"ltr",o),i=!0)}i||r(e,n,"ltr")}var pt=null;function gt(t,e,n){var r;pt=null;for(var i=0;i<t.length;++i){var o=t[i];if(o.from<e&&o.to>e)return i;o.to==e&&(o.from!=o.to&&"before"==n?r=i:pt=i),o.from==e&&(o.from!=o.to&&"before"!=n?r=i:pt=i)}return null!=r?r:pt}var mt=function(){var t="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",e="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function n(n){return n<=247?t.charAt(n):1424<=n&&n<=1524?"R":1536<=n&&n<=1785?e.charAt(n-1536):1774<=n&&n<=2220?"r":8192<=n&&n<=8203?"w":8204==n?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,o=/[LRr]/,s=/[Lb1n]/,l=/[1n]/;function a(t,e,n){this.level=t,this.from=e,this.to=n}return function(t,e){var c="ltr"==e?"L":"R";if(0==t.length||"ltr"==e&&!r.test(t))return!1;for(var h=t.length,u=[],d=0;d<h;++d)u.push(n(t.charCodeAt(d)));for(var f=0,p=c;f<h;++f){var g=u[f];"m"==g?u[f]=p:p=g}for(var m=0,v=c;m<h;++m){var y=u[m];"1"==y&&"r"==v?u[m]="n":o.test(y)&&(v=y,"r"==y&&(u[m]="R"))}for(var b=1,w=u[0];b<h-1;++b){var x=u[b];"+"==x&&"1"==w&&"1"==u[b+1]?u[b]="1":","!=x||w!=u[b+1]||"1"!=w&&"n"!=w||(u[b]=w),w=x}for(var _=0;_<h;++_){var C=u[_];if(","==C)u[_]="N";else if("%"==C){var k=void 0;for(k=_+1;k<h&&"%"==u[k];++k);for(var S=_&&"!"==u[_-1]||k<h&&"1"==u[k]?"1":"N",L=_;L<k;++L)u[L]=S;_=k-1}}for(var M=0,T=c;M<h;++M){var O=u[M];"L"==T&&"1"==O?u[M]="L":o.test(O)&&(T=O)}for(var N=0;N<h;++N)if(i.test(u[N])){var A=void 0;for(A=N+1;A<h&&i.test(u[A]);++A);for(var D="L"==(N?u[N-1]:c),E=D==("L"==(A<h?u[A]:c))?D?"L":"R":c,W=N;W<A;++W)u[W]=E;N=A-1}for(var P,H=[],z=0;z<h;)if(s.test(u[z])){var R=z;for(++z;z<h&&s.test(u[z]);++z);H.push(new a(0,R,z))}else{var F=z,I=H.length,B="rtl"==e?1:0;for(++z;z<h&&"L"!=u[z];++z);for(var V=F;V<z;)if(l.test(u[V])){F<V&&(H.splice(I,0,new a(1,F,V)),I+=B);var $=V;for(++V;V<z&&l.test(u[V]);++V);H.splice(I,0,new a(2,$,V)),I+=B,F=V}else++V;F<z&&H.splice(I,0,new a(1,F,z))}return"ltr"==e&&(1==H[0].level&&(P=t.match(/^\s+/))&&(H[0].from=P[0].length,H.unshift(new a(0,0,P[0].length))),1==tt(H).level&&(P=t.match(/\s+$/))&&(tt(H).to-=P[0].length,H.push(new a(0,h-P[0].length,h)))),"rtl"==e?H.reverse():H}}();function vt(t,e){var n=t.order;return null==n&&(n=t.order=mt(t.text,e)),n}var yt=[],bt=function(t,e,n){if(t.addEventListener)t.addEventListener(e,n,!1);else if(t.attachEvent)t.attachEvent("on"+e,n);else{var r=t._handlers||(t._handlers={});r[e]=(r[e]||yt).concat(n)}};function wt(t,e){return t._handlers&&t._handlers[e]||yt}function xt(t,e,n){if(t.removeEventListener)t.removeEventListener(e,n,!1);else if(t.detachEvent)t.detachEvent("on"+e,n);else{var r=t._handlers,i=r&&r[e];if(i){var o=G(i,n);o>-1&&(r[e]=i.slice(0,o).concat(i.slice(o+1)))}}}function _t(t,e){var n=wt(t,e);if(n.length)for(var r=Array.prototype.slice.call(arguments,2),i=0;i<n.length;++i)n[i].apply(null,r)}function Ct(t,e,n){return"string"==typeof e&&(e={type:e,preventDefault:function(){this.defaultPrevented=!0}}),_t(t,n||e.type,t,e),Ot(e)||e.codemirrorIgnore}function kt(t){var e=t._handlers&&t._handlers.cursorActivity;if(e)for(var n=t.curOp.cursorActivityHandlers||(t.curOp.cursorActivityHandlers=[]),r=0;r<e.length;++r)-1==G(n,e[r])&&n.push(e[r])}function St(t,e){return wt(t,e).length>0}function Lt(t){t.prototype.on=function(t,e){bt(this,t,e)},t.prototype.off=function(t,e){xt(this,t,e)}}function Mt(t){t.preventDefault?t.preventDefault():t.returnValue=!1}function Tt(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0}function Ot(t){return null!=t.defaultPrevented?t.defaultPrevented:0==t.returnValue}function Nt(t){Mt(t),Tt(t)}function At(t){return t.target||t.srcElement}function Dt(t){var e=t.which;return null==e&&(1&t.button?e=1:2&t.button?e=3:4&t.button&&(e=2)),b&&t.ctrlKey&&1==e&&(e=3),e}var Et,Wt,Pt=function(){if(s&&l<9)return!1;var t=N("div");return"draggable"in t||"dragDrop"in t}();function Ht(t){if(null==Et){var e=N("span","​");O(t,N("span",[e,document.createTextNode("x")])),0!=t.firstChild.offsetHeight&&(Et=e.offsetWidth<=1&&e.offsetHeight>2&&!(s&&l<8))}var n=Et?N("span","​"):N("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function zt(t){if(null!=Wt)return Wt;var e=O(t,document.createTextNode("AخA")),n=L(e,0,1).getBoundingClientRect(),r=L(e,1,2).getBoundingClientRect();return T(t),!(!n||n.left==n.right)&&(Wt=r.right-n.right<3)}var Rt,Ft=3!="\n\nb".split(/\n/).length?function(t){for(var e=0,n=[],r=t.length;e<=r;){var i=t.indexOf("\n",e);-1==i&&(i=t.length);var o=t.slice(e,"\r"==t.charAt(i-1)?i-1:i),s=o.indexOf("\r");-1!=s?(n.push(o.slice(0,s)),e+=s+1):(n.push(o),e=i+1)}return n}:function(t){return t.split(/\r\n?|\n/)},It=window.getSelection?function(t){try{return t.selectionStart!=t.selectionEnd}catch(t){return!1}}:function(t){var e;try{e=t.ownerDocument.selection.createRange()}catch(t){}return!(!e||e.parentElement()!=t)&&0!=e.compareEndPoints("StartToEnd",e)},Bt="oncopy"in(Rt=N("div"))||(Rt.setAttribute("oncopy","return;"),"function"==typeof Rt.oncopy),Vt=null;function $t(t){if(null!=Vt)return Vt;var e=O(t,N("span","x")),n=e.getBoundingClientRect(),r=L(e,0,1).getBoundingClientRect();return Vt=Math.abs(n.left-r.left)>1}var Ut={},Gt={};function jt(t,e){arguments.length>2&&(e.dependencies=Array.prototype.slice.call(arguments,2)),Ut[t]=e}function Kt(t,e){Gt[t]=e}function qt(t){if("string"==typeof t&&Gt.hasOwnProperty(t))t=Gt[t];else if(t&&"string"==typeof t.name&&Gt.hasOwnProperty(t.name)){var e=Gt[t.name];"string"==typeof e&&(e={name:e}),(t=it(e,t)).name=e.name}else{if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return qt("application/xml");if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+json$/.test(t))return qt("application/json")}return"string"==typeof t?{name:t}:t||{name:"null"}}function Xt(t,e){e=qt(e);var n=Ut[e.name];if(!n)return Xt(t,"text/plain");var r=n(t,e);if(Yt.hasOwnProperty(e.name)){var i=Yt[e.name];for(var o in i)i.hasOwnProperty(o)&&(r.hasOwnProperty(o)&&(r["_"+o]=r[o]),r[o]=i[o])}if(r.name=e.name,e.helperType&&(r.helperType=e.helperType),e.modeProps)for(var s in e.modeProps)r[s]=e.modeProps[s];return r}var Yt={};function Zt(t,e){V(e,Yt.hasOwnProperty(t)?Yt[t]:Yt[t]={})}function Jt(t,e){if(!0===e)return e;if(t.copyState)return t.copyState(e);var n={};for(var r in e){var i=e[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n}function Qt(t,e){for(var n;t.innerMode&&(n=t.innerMode(e))&&n.mode!=t;)e=n.state,t=n.mode;return n||{mode:t,state:e}}function te(t,e,n){return!t.startState||t.startState(e,n)}var ee=function(t,e,n){this.pos=this.start=0,this.string=t,this.tabSize=e||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};function ne(t,e){if((e-=t.first)<0||e>=t.size)throw new Error("There is no line "+(e+t.first)+" in the document.");for(var n=t;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(e<o){n=i;break}e-=o}return n.lines[e]}function re(t,e,n){var r=[],i=e.line;return t.iter(e.line,n.line+1,(function(t){var o=t.text;i==n.line&&(o=o.slice(0,n.ch)),i==e.line&&(o=o.slice(e.ch)),r.push(o),++i})),r}function ie(t,e,n){var r=[];return t.iter(e,n,(function(t){r.push(t.text)})),r}function oe(t,e){var n=e-t.height;if(n)for(var r=t;r;r=r.parent)r.height+=n}function se(t){if(null==t.parent)return null;for(var e=t.parent,n=G(e.lines,t),r=e.parent;r;e=r,r=r.parent)for(var i=0;r.children[i]!=e;++i)n+=r.children[i].chunkSize();return n+e.first}function le(t,e){var n=t.first;t:do{for(var r=0;r<t.children.length;++r){var i=t.children[r],o=i.height;if(e<o){t=i;continue t}e-=o,n+=i.chunkSize()}return n}while(!t.lines);for(var s=0;s<t.lines.length;++s){var l=t.lines[s].height;if(e<l)break;e-=l}return n+s}function ae(t,e){return e>=t.first&&e<t.first+t.size}function ce(t,e){return String(t.lineNumberFormatter(e+t.firstLineNumber))}function he(t,e,n){if(void 0===n&&(n=null),!(this instanceof he))return new he(t,e,n);this.line=t,this.ch=e,this.sticky=n}function ue(t,e){return t.line-e.line||t.ch-e.ch}function de(t,e){return t.sticky==e.sticky&&0==ue(t,e)}function fe(t){return he(t.line,t.ch)}function pe(t,e){return ue(t,e)<0?e:t}function ge(t,e){return ue(t,e)<0?t:e}function me(t,e){return Math.max(t.first,Math.min(e,t.first+t.size-1))}function ve(t,e){if(e.line<t.first)return he(t.first,0);var n=t.first+t.size-1;return e.line>n?he(n,ne(t,n).text.length):ye(e,ne(t,e.line).text.length)}function ye(t,e){var n=t.ch;return null==n||n>e?he(t.line,e):n<0?he(t.line,0):t}function be(t,e){for(var n=[],r=0;r<e.length;r++)n[r]=ve(t,e[r]);return n}ee.prototype.eol=function(){return this.pos>=this.string.length},ee.prototype.sol=function(){return this.pos==this.lineStart},ee.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},ee.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},ee.prototype.eat=function(t){var e=this.string.charAt(this.pos);if("string"==typeof t?e==t:e&&(t.test?t.test(e):t(e)))return++this.pos,e},ee.prototype.eatWhile=function(t){for(var e=this.pos;this.eat(t););return this.pos>e},ee.prototype.eatSpace=function(){for(var t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t},ee.prototype.skipToEnd=function(){this.pos=this.string.length},ee.prototype.skipTo=function(t){var e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0},ee.prototype.backUp=function(t){this.pos-=t},ee.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=$(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?$(this.string,this.lineStart,this.tabSize):0)},ee.prototype.indentation=function(){return $(this.string,null,this.tabSize)-(this.lineStart?$(this.string,this.lineStart,this.tabSize):0)},ee.prototype.match=function(t,e,n){if("string"!=typeof t){var r=this.string.slice(this.pos).match(t);return r&&r.index>0?null:(r&&!1!==e&&(this.pos+=r[0].length),r)}var i=function(t){return n?t.toLowerCase():t};if(i(this.string.substr(this.pos,t.length))==i(t))return!1!==e&&(this.pos+=t.length),!0},ee.prototype.current=function(){return this.string.slice(this.start,this.pos)},ee.prototype.hideFirstChars=function(t,e){this.lineStart+=t;try{return e()}finally{this.lineStart-=t}},ee.prototype.lookAhead=function(t){var e=this.lineOracle;return e&&e.lookAhead(t)},ee.prototype.baseToken=function(){var t=this.lineOracle;return t&&t.baseToken(this.pos)};var we=function(t,e){this.state=t,this.lookAhead=e},xe=function(t,e,n,r){this.state=e,this.doc=t,this.line=n,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};function _e(t,e,n,r){var i=[t.state.modeGen],o={};Ae(t,e.text,t.doc.mode,n,(function(t,e){return i.push(t,e)}),o,r);for(var s=n.state,l=function(r){n.baseTokens=i;var l=t.state.overlays[r],a=1,c=0;n.state=!0,Ae(t,e.text,l.mode,n,(function(t,e){for(var n=a;c<t;){var r=i[a];r>t&&i.splice(a,1,t,i[a+1],r),a+=2,c=Math.min(t,r)}if(e)if(l.opaque)i.splice(n,a-n,t,"overlay "+e),a=n+2;else for(;n<a;n+=2){var o=i[n+1];i[n+1]=(o?o+" ":"")+"overlay "+e}}),o),n.state=s,n.baseTokens=null,n.baseTokenPos=1},a=0;a<t.state.overlays.length;++a)l(a);return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Ce(t,e,n){if(!e.styles||e.styles[0]!=t.state.modeGen){var r=ke(t,se(e)),i=e.text.length>t.options.maxHighlightLength&&Jt(t.doc.mode,r.state),o=_e(t,e,r);i&&(r.state=i),e.stateAfter=r.save(!i),e.styles=o.styles,o.classes?e.styleClasses=o.classes:e.styleClasses&&(e.styleClasses=null),n===t.doc.highlightFrontier&&(t.doc.modeFrontier=Math.max(t.doc.modeFrontier,++t.doc.highlightFrontier))}return e.styles}function ke(t,e,n){var r=t.doc,i=t.display;if(!r.mode.startState)return new xe(r,!0,e);var o=De(t,e,n),s=o>r.first&&ne(r,o-1).stateAfter,l=s?xe.fromSaved(r,s,o):new xe(r,te(r.mode),o);return r.iter(o,e,(function(n){Se(t,n.text,l);var r=l.line;n.stateAfter=r==e-1||r%5==0||r>=i.viewFrom&&r<i.viewTo?l.save():null,l.nextLine()})),n&&(r.modeFrontier=l.line),l}function Se(t,e,n,r){var i=t.doc.mode,o=new ee(e,t.options.tabSize,n);for(o.start=o.pos=r||0,""==e&&Le(i,n.state);!o.eol();)Me(i,o,n.state),o.start=o.pos}function Le(t,e){if(t.blankLine)return t.blankLine(e);if(t.innerMode){var n=Qt(t,e);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Me(t,e,n,r){for(var i=0;i<10;i++){r&&(r[0]=Qt(t,n).mode);var o=t.token(e,n);if(e.pos>e.start)return o}throw new Error("Mode "+t.name+" failed to advance stream.")}xe.prototype.lookAhead=function(t){var e=this.doc.getLine(this.line+t);return null!=e&&t>this.maxLookAhead&&(this.maxLookAhead=t),e},xe.prototype.baseToken=function(t){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=t;)this.baseTokenPos+=2;var e=this.baseTokens[this.baseTokenPos+1];return{type:e&&e.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-t}},xe.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},xe.fromSaved=function(t,e,n){return e instanceof we?new xe(t,Jt(t.mode,e.state),n,e.lookAhead):new xe(t,Jt(t.mode,e),n)},xe.prototype.save=function(t){var e=!1!==t?Jt(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new we(e,this.maxLookAhead):e};var Te=function(t,e,n){this.start=t.start,this.end=t.pos,this.string=t.current(),this.type=e||null,this.state=n};function Oe(t,e,n,r){var i,o,s=t.doc,l=s.mode,a=ne(s,(e=ve(s,e)).line),c=ke(t,e.line,n),h=new ee(a.text,t.options.tabSize,c);for(r&&(o=[]);(r||h.pos<e.ch)&&!h.eol();)h.start=h.pos,i=Me(l,h,c.state),r&&o.push(new Te(h,i,Jt(s.mode,c.state)));return r?o:new Te(h,i,c.state)}function Ne(t,e){if(t)for(;;){var n=t.match(/(?:^|\s+)line-(background-)?(\S+)/);if(!n)break;t=t.slice(0,n.index)+t.slice(n.index+n[0].length);var r=n[1]?"bgClass":"textClass";null==e[r]?e[r]=n[2]:new RegExp("(?:^|\\s)"+n[2]+"(?:$|\\s)").test(e[r])||(e[r]+=" "+n[2])}return t}function Ae(t,e,n,r,i,o,s){var l=n.flattenSpans;null==l&&(l=t.options.flattenSpans);var a,c=0,h=null,u=new ee(e,t.options.tabSize,r),d=t.options.addModeClass&&[null];for(""==e&&Ne(Le(n,r.state),o);!u.eol();){if(u.pos>t.options.maxHighlightLength?(l=!1,s&&Se(t,e,r,u.pos),u.pos=e.length,a=null):a=Ne(Me(n,u,r.state,d),o),d){var f=d[0].name;f&&(a="m-"+(a?f+" "+a:f))}if(!l||h!=a){for(;c<u.start;)i(c=Math.min(u.start,c+5e3),h);h=a}u.start=u.pos}for(;c<u.pos;){var p=Math.min(u.pos,c+5e3);i(p,h),c=p}}function De(t,e,n){for(var r,i,o=t.doc,s=n?-1:e-(t.doc.mode.innerMode?1e3:100),l=e;l>s;--l){if(l<=o.first)return o.first;var a=ne(o,l-1),c=a.stateAfter;if(c&&(!n||l+(c instanceof we?c.lookAhead:0)<=o.modeFrontier))return l;var h=$(a.text,null,t.options.tabSize);(null==i||r>h)&&(i=l-1,r=h)}return i}function Ee(t,e){if(t.modeFrontier=Math.min(t.modeFrontier,e),!(t.highlightFrontier<e-10)){for(var n=t.first,r=e-1;r>n;r--){var i=ne(t,r).stateAfter;if(i&&(!(i instanceof we)||r+i.lookAhead<e)){n=r+1;break}}t.highlightFrontier=Math.min(t.highlightFrontier,n)}}var We=!1,Pe=!1;function He(){We=!0}function ze(){Pe=!0}function Re(t,e,n){this.marker=t,this.from=e,this.to=n}function Fe(t,e){if(t)for(var n=0;n<t.length;++n){var r=t[n];if(r.marker==e)return r}}function Ie(t,e){for(var n,r=0;r<t.length;++r)t[r]!=e&&(n||(n=[])).push(t[r]);return n}function Be(t,e,n){var r=n&&window.WeakSet&&(n.markedSpans||(n.markedSpans=new WeakSet));r&&t.markedSpans&&r.has(t.markedSpans)?t.markedSpans.push(e):(t.markedSpans=t.markedSpans?t.markedSpans.concat([e]):[e],r&&r.add(t.markedSpans)),e.marker.attachLine(t)}function Ve(t,e,n){var r;if(t)for(var i=0;i<t.length;++i){var o=t[i],s=o.marker;if(null==o.from||(s.inclusiveLeft?o.from<=e:o.from<e)||o.from==e&&"bookmark"==s.type&&(!n||!o.marker.insertLeft)){var l=null==o.to||(s.inclusiveRight?o.to>=e:o.to>e);(r||(r=[])).push(new Re(s,o.from,l?null:o.to))}}return r}function $e(t,e,n){var r;if(t)for(var i=0;i<t.length;++i){var o=t[i],s=o.marker;if(null==o.to||(s.inclusiveRight?o.to>=e:o.to>e)||o.from==e&&"bookmark"==s.type&&(!n||o.marker.insertLeft)){var l=null==o.from||(s.inclusiveLeft?o.from<=e:o.from<e);(r||(r=[])).push(new Re(s,l?null:o.from-e,null==o.to?null:o.to-e))}}return r}function Ue(t,e){if(e.full)return null;var n=ae(t,e.from.line)&&ne(t,e.from.line).markedSpans,r=ae(t,e.to.line)&&ne(t,e.to.line).markedSpans;if(!n&&!r)return null;var i=e.from.ch,o=e.to.ch,s=0==ue(e.from,e.to),l=Ve(n,i,s),a=$e(r,o,s),c=1==e.text.length,h=tt(e.text).length+(c?i:0);if(l)for(var u=0;u<l.length;++u){var d=l[u];if(null==d.to){var f=Fe(a,d.marker);f?c&&(d.to=null==f.to?null:f.to+h):d.to=i}}if(a)for(var p=0;p<a.length;++p){var g=a[p];null!=g.to&&(g.to+=h),null==g.from?Fe(l,g.marker)||(g.from=h,c&&(l||(l=[])).push(g)):(g.from+=h,c&&(l||(l=[])).push(g))}l&&(l=Ge(l)),a&&a!=l&&(a=Ge(a));var m=[l];if(!c){var v,y=e.text.length-2;if(y>0&&l)for(var b=0;b<l.length;++b)null==l[b].to&&(v||(v=[])).push(new Re(l[b].marker,null,null));for(var w=0;w<y;++w)m.push(v);m.push(a)}return m}function Ge(t){for(var e=0;e<t.length;++e){var n=t[e];null!=n.from&&n.from==n.to&&!1!==n.marker.clearWhenEmpty&&t.splice(e--,1)}return t.length?t:null}function je(t,e,n){var r=null;if(t.iter(e.line,n.line+1,(function(t){if(t.markedSpans)for(var e=0;e<t.markedSpans.length;++e){var n=t.markedSpans[e].marker;!n.readOnly||r&&-1!=G(r,n)||(r||(r=[])).push(n)}})),!r)return null;for(var i=[{from:e,to:n}],o=0;o<r.length;++o)for(var s=r[o],l=s.find(0),a=0;a<i.length;++a){var c=i[a];if(!(ue(c.to,l.from)<0||ue(c.from,l.to)>0)){var h=[a,1],u=ue(c.from,l.from),d=ue(c.to,l.to);(u<0||!s.inclusiveLeft&&!u)&&h.push({from:c.from,to:l.from}),(d>0||!s.inclusiveRight&&!d)&&h.push({from:l.to,to:c.to}),i.splice.apply(i,h),a+=h.length-3}}return i}function Ke(t){var e=t.markedSpans;if(e){for(var n=0;n<e.length;++n)e[n].marker.detachLine(t);t.markedSpans=null}}function qe(t,e){if(e){for(var n=0;n<e.length;++n)e[n].marker.attachLine(t);t.markedSpans=e}}function Xe(t){return t.inclusiveLeft?-1:0}function Ye(t){return t.inclusiveRight?1:0}function Ze(t,e){var n=t.lines.length-e.lines.length;if(0!=n)return n;var r=t.find(),i=e.find(),o=ue(r.from,i.from)||Xe(t)-Xe(e);if(o)return-o;var s=ue(r.to,i.to)||Ye(t)-Ye(e);return s||e.id-t.id}function Je(t,e){var n,r=Pe&&t.markedSpans;if(r)for(var i=void 0,o=0;o<r.length;++o)(i=r[o]).marker.collapsed&&null==(e?i.from:i.to)&&(!n||Ze(n,i.marker)<0)&&(n=i.marker);return n}function Qe(t){return Je(t,!0)}function tn(t){return Je(t,!1)}function en(t,e){var n,r=Pe&&t.markedSpans;if(r)for(var i=0;i<r.length;++i){var o=r[i];o.marker.collapsed&&(null==o.from||o.from<e)&&(null==o.to||o.to>e)&&(!n||Ze(n,o.marker)<0)&&(n=o.marker)}return n}function nn(t,e,n,r,i){var o=ne(t,e),s=Pe&&o.markedSpans;if(s)for(var l=0;l<s.length;++l){var a=s[l];if(a.marker.collapsed){var c=a.marker.find(0),h=ue(c.from,n)||Xe(a.marker)-Xe(i),u=ue(c.to,r)||Ye(a.marker)-Ye(i);if(!(h>=0&&u<=0||h<=0&&u>=0)&&(h<=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?ue(c.to,n)>=0:ue(c.to,n)>0)||h>=0&&(a.marker.inclusiveRight&&i.inclusiveLeft?ue(c.from,r)<=0:ue(c.from,r)<0)))return!0}}}function rn(t){for(var e;e=Qe(t);)t=e.find(-1,!0).line;return t}function on(t){for(var e;e=tn(t);)t=e.find(1,!0).line;return t}function sn(t){for(var e,n;e=tn(t);)t=e.find(1,!0).line,(n||(n=[])).push(t);return n}function ln(t,e){var n=ne(t,e),r=rn(n);return n==r?e:se(r)}function an(t,e){if(e>t.lastLine())return e;var n,r=ne(t,e);if(!cn(t,r))return e;for(;n=tn(r);)r=n.find(1,!0).line;return se(r)+1}function cn(t,e){var n=Pe&&e.markedSpans;if(n)for(var r=void 0,i=0;i<n.length;++i)if((r=n[i]).marker.collapsed){if(null==r.from)return!0;if(!r.marker.widgetNode&&0==r.from&&r.marker.inclusiveLeft&&hn(t,e,r))return!0}}function hn(t,e,n){if(null==n.to){var r=n.marker.find(1,!0);return hn(t,r.line,Fe(r.line.markedSpans,n.marker))}if(n.marker.inclusiveRight&&n.to==e.text.length)return!0;for(var i=void 0,o=0;o<e.markedSpans.length;++o)if((i=e.markedSpans[o]).marker.collapsed&&!i.marker.widgetNode&&i.from==n.to&&(null==i.to||i.to!=n.from)&&(i.marker.inclusiveLeft||n.marker.inclusiveRight)&&hn(t,e,i))return!0}function un(t){for(var e=0,n=(t=rn(t)).parent,r=0;r<n.lines.length;++r){var i=n.lines[r];if(i==t)break;e+=i.height}for(var o=n.parent;o;o=(n=o).parent)for(var s=0;s<o.children.length;++s){var l=o.children[s];if(l==n)break;e+=l.height}return e}function dn(t){if(0==t.height)return 0;for(var e,n=t.text.length,r=t;e=Qe(r);){var i=e.find(0,!0);r=i.from.line,n+=i.from.ch-i.to.ch}for(r=t;e=tn(r);){var o=e.find(0,!0);n-=r.text.length-o.from.ch,n+=(r=o.to.line).text.length-o.to.ch}return n}function fn(t){var e=t.display,n=t.doc;e.maxLine=ne(n,n.first),e.maxLineLength=dn(e.maxLine),e.maxLineChanged=!0,n.iter((function(t){var n=dn(t);n>e.maxLineLength&&(e.maxLineLength=n,e.maxLine=t)}))}var pn=function(t,e,n){this.text=t,qe(this,e),this.height=n?n(this):1};function gn(t,e,n,r){t.text=e,t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null),null!=t.order&&(t.order=null),Ke(t),qe(t,n);var i=r?r(t):1;i!=t.height&&oe(t,i)}function mn(t){t.parent=null,Ke(t)}pn.prototype.lineNo=function(){return se(this)},Lt(pn);var vn={},yn={};function bn(t,e){if(!t||/^\s*$/.test(t))return null;var n=e.addModeClass?yn:vn;return n[t]||(n[t]=t.replace(/\S+/g,"cm-$&"))}function wn(t,e){var n=A("span",null,null,a?"padding-right: .1px":null),r={pre:A("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:t,trailingSpace:!1,splitSpaces:t.getOption("lineWrapping")};e.measure={};for(var i=0;i<=(e.rest?e.rest.length:0);i++){var o=i?e.rest[i-1]:e.line,s=void 0;r.pos=0,r.addToken=_n,zt(t.display.measure)&&(s=vt(o,t.doc.direction))&&(r.addToken=kn(r.addToken,s)),r.map=[],Ln(o,r,Ce(t,o,e!=t.display.externalMeasured&&se(o))),o.styleClasses&&(o.styleClasses.bgClass&&(r.bgClass=P(o.styleClasses.bgClass,r.bgClass||"")),o.styleClasses.textClass&&(r.textClass=P(o.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(Ht(t.display.measure))),0==i?(e.measure.map=r.map,e.measure.cache={}):((e.measure.maps||(e.measure.maps=[])).push(r.map),(e.measure.caches||(e.measure.caches=[])).push({}))}if(a){var l=r.content.lastChild;(/\bcm-tab\b/.test(l.className)||l.querySelector&&l.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return _t(t,"renderLine",t,e.line,r.pre),r.pre.className&&(r.textClass=P(r.pre.className,r.textClass||"")),r}function xn(t){var e=N("span","•","cm-invalidchar");return e.title="\\u"+t.charCodeAt(0).toString(16),e.setAttribute("aria-label",e.title),e}function _n(t,e,n,r,i,o,a){if(e){var c,h=t.splitSpaces?Cn(e,t.trailingSpace):e,u=t.cm.state.specialChars,d=!1;if(u.test(e)){c=document.createDocumentFragment();for(var f=0;;){u.lastIndex=f;var p=u.exec(e),g=p?p.index-f:e.length-f;if(g){var m=document.createTextNode(h.slice(f,f+g));s&&l<9?c.appendChild(N("span",[m])):c.appendChild(m),t.map.push(t.pos,t.pos+g,m),t.col+=g,t.pos+=g}if(!p)break;f+=g+1;var v=void 0;if("\t"==p[0]){var y=t.cm.options.tabSize,b=y-t.col%y;(v=c.appendChild(N("span",Q(b),"cm-tab"))).setAttribute("role","presentation"),v.setAttribute("cm-text","\t"),t.col+=b}else"\r"==p[0]||"\n"==p[0]?((v=c.appendChild(N("span","\r"==p[0]?"␍":"␤","cm-invalidchar"))).setAttribute("cm-text",p[0]),t.col+=1):((v=t.cm.options.specialCharPlaceholder(p[0])).setAttribute("cm-text",p[0]),s&&l<9?c.appendChild(N("span",[v])):c.appendChild(v),t.col+=1);t.map.push(t.pos,t.pos+1,v),t.pos++}}else t.col+=e.length,c=document.createTextNode(h),t.map.push(t.pos,t.pos+e.length,c),s&&l<9&&(d=!0),t.pos+=e.length;if(t.trailingSpace=32==h.charCodeAt(e.length-1),n||r||i||d||o||a){var w=n||"";r&&(w+=r),i&&(w+=i);var x=N("span",[c],w,o);if(a)for(var _ in a)a.hasOwnProperty(_)&&"style"!=_&&"class"!=_&&x.setAttribute(_,a[_]);return t.content.appendChild(x)}t.content.appendChild(c)}}function Cn(t,e){if(t.length>1&&!/ /.test(t))return t;for(var n=e,r="",i=0;i<t.length;i++){var o=t.charAt(i);" "!=o||!n||i!=t.length-1&&32!=t.charCodeAt(i+1)||(o=" "),r+=o,n=" "==o}return r}function kn(t,e){return function(n,r,i,o,s,l,a){i=i?i+" cm-force-border":"cm-force-border";for(var c=n.pos,h=c+r.length;;){for(var u=void 0,d=0;d<e.length&&!((u=e[d]).to>c&&u.from<=c);d++);if(u.to>=h)return t(n,r,i,o,s,l,a);t(n,r.slice(0,u.to-c),i,o,null,l,a),o=null,r=r.slice(u.to-c),c=u.to}}}function Sn(t,e,n,r){var i=!r&&n.widgetNode;i&&t.map.push(t.pos,t.pos+e,i),!r&&t.cm.display.input.needsContentAttribute&&(i||(i=t.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(t.cm.display.input.setUneditable(i),t.content.appendChild(i)),t.pos+=e,t.trailingSpace=!1}function Ln(t,e,n){var r=t.markedSpans,i=t.text,o=0;if(r)for(var s,l,a,c,h,u,d,f=i.length,p=0,g=1,m="",v=0;;){if(v==p){a=c=h=l="",d=null,u=null,v=1/0;for(var y=[],b=void 0,w=0;w<r.length;++w){var x=r[w],_=x.marker;if("bookmark"==_.type&&x.from==p&&_.widgetNode)y.push(_);else if(x.from<=p&&(null==x.to||x.to>p||_.collapsed&&x.to==p&&x.from==p)){if(null!=x.to&&x.to!=p&&v>x.to&&(v=x.to,c=""),_.className&&(a+=" "+_.className),_.css&&(l=(l?l+";":"")+_.css),_.startStyle&&x.from==p&&(h+=" "+_.startStyle),_.endStyle&&x.to==v&&(b||(b=[])).push(_.endStyle,x.to),_.title&&((d||(d={})).title=_.title),_.attributes)for(var C in _.attributes)(d||(d={}))[C]=_.attributes[C];_.collapsed&&(!u||Ze(u.marker,_)<0)&&(u=x)}else x.from>p&&v>x.from&&(v=x.from)}if(b)for(var k=0;k<b.length;k+=2)b[k+1]==v&&(c+=" "+b[k]);if(!u||u.from==p)for(var S=0;S<y.length;++S)Sn(e,0,y[S]);if(u&&(u.from||0)==p){if(Sn(e,(null==u.to?f+1:u.to)-p,u.marker,null==u.from),null==u.to)return;u.to==p&&(u=!1)}}if(p>=f)break;for(var L=Math.min(f,v);;){if(m){var M=p+m.length;if(!u){var T=M>L?m.slice(0,L-p):m;e.addToken(e,T,s?s+a:a,h,p+T.length==v?c:"",l,d)}if(M>=L){m=m.slice(L-p),p=L;break}p=M,h=""}m=i.slice(o,o=n[g++]),s=bn(n[g++],e.cm.options)}}else for(var O=1;O<n.length;O+=2)e.addToken(e,i.slice(o,o=n[O]),bn(n[O+1],e.cm.options))}function Mn(t,e,n){this.line=e,this.rest=sn(e),this.size=this.rest?se(tt(this.rest))-n+1:1,this.node=this.text=null,this.hidden=cn(t,e)}function Tn(t,e,n){for(var r,i=[],o=e;o<n;o=r){var s=new Mn(t.doc,ne(t.doc,o),o);r=o+s.size,i.push(s)}return i}var On=null;function Nn(t){On?On.ops.push(t):t.ownsGroup=On={ops:[t],delayedCallbacks:[]}}function An(t){var e=t.delayedCallbacks,n=0;do{for(;n<e.length;n++)e[n].call(null);for(var r=0;r<t.ops.length;r++){var i=t.ops[r];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(n<e.length)}function Dn(t,e){var n=t.ownsGroup;if(n)try{An(n)}finally{On=null,e(n)}}var En=null;function Wn(t,e){var n=wt(t,e);if(n.length){var r,i=Array.prototype.slice.call(arguments,2);On?r=On.delayedCallbacks:En?r=En:(r=En=[],setTimeout(Pn,0));for(var o=function(t){r.push((function(){return n[t].apply(null,i)}))},s=0;s<n.length;++s)o(s)}}function Pn(){var t=En;En=null;for(var e=0;e<t.length;++e)t[e]()}function Hn(t,e,n,r){for(var i=0;i<e.changes.length;i++){var o=e.changes[i];"text"==o?In(t,e):"gutter"==o?Vn(t,e,n,r):"class"==o?Bn(t,e):"widget"==o&&$n(t,e,r)}e.changes=null}function zn(t){return t.node==t.text&&(t.node=N("div",null,null,"position: relative"),t.text.parentNode&&t.text.parentNode.replaceChild(t.node,t.text),t.node.appendChild(t.text),s&&l<8&&(t.node.style.zIndex=2)),t.node}function Rn(t,e){var n=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(n&&(n+=" CodeMirror-linebackground"),e.background)n?e.background.className=n:(e.background.parentNode.removeChild(e.background),e.background=null);else if(n){var r=zn(e);e.background=r.insertBefore(N("div",null,n),r.firstChild),t.display.input.setUneditable(e.background)}}function Fn(t,e){var n=t.display.externalMeasured;return n&&n.line==e.line?(t.display.externalMeasured=null,e.measure=n.measure,n.built):wn(t,e)}function In(t,e){var n=e.text.className,r=Fn(t,e);e.text==e.node&&(e.node=r.pre),e.text.parentNode.replaceChild(r.pre,e.text),e.text=r.pre,r.bgClass!=e.bgClass||r.textClass!=e.textClass?(e.bgClass=r.bgClass,e.textClass=r.textClass,Bn(t,e)):n&&(e.text.className=n)}function Bn(t,e){Rn(t,e),e.line.wrapClass?zn(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var n=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=n||""}function Vn(t,e,n,r){if(e.gutter&&(e.node.removeChild(e.gutter),e.gutter=null),e.gutterBackground&&(e.node.removeChild(e.gutterBackground),e.gutterBackground=null),e.line.gutterClass){var i=zn(e);e.gutterBackground=N("div",null,"CodeMirror-gutter-background "+e.line.gutterClass,"left: "+(t.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),t.display.input.setUneditable(e.gutterBackground),i.insertBefore(e.gutterBackground,e.text)}var o=e.line.gutterMarkers;if(t.options.lineNumbers||o){var s=zn(e),l=e.gutter=N("div",null,"CodeMirror-gutter-wrapper","left: "+(t.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(l.setAttribute("aria-hidden","true"),t.display.input.setUneditable(l),s.insertBefore(l,e.text),e.line.gutterClass&&(l.className+=" "+e.line.gutterClass),!t.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(e.lineNumber=l.appendChild(N("div",ce(t.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+t.display.lineNumInnerWidth+"px"))),o)for(var a=0;a<t.display.gutterSpecs.length;++a){var c=t.display.gutterSpecs[a].className,h=o.hasOwnProperty(c)&&o[c];h&&l.appendChild(N("div",[h],"CodeMirror-gutter-elt","left: "+r.gutterLeft[c]+"px; width: "+r.gutterWidth[c]+"px"))}}}function $n(t,e,n){e.alignable&&(e.alignable=null);for(var r=S("CodeMirror-linewidget"),i=e.node.firstChild,o=void 0;i;i=o)o=i.nextSibling,r.test(i.className)&&e.node.removeChild(i);Gn(t,e,n)}function Un(t,e,n,r){var i=Fn(t,e);return e.text=e.node=i.pre,i.bgClass&&(e.bgClass=i.bgClass),i.textClass&&(e.textClass=i.textClass),Bn(t,e),Vn(t,e,n,r),Gn(t,e,r),e.node}function Gn(t,e,n){if(jn(t,e.line,e,n,!0),e.rest)for(var r=0;r<e.rest.length;r++)jn(t,e.rest[r],e,n,!1)}function jn(t,e,n,r,i){if(e.widgets)for(var o=zn(n),s=0,l=e.widgets;s<l.length;++s){var a=l[s],c=N("div",[a.node],"CodeMirror-linewidget"+(a.className?" "+a.className:""));a.handleMouseEvents||c.setAttribute("cm-ignore-events","true"),Kn(a,c,n,r),t.display.input.setUneditable(c),i&&a.above?o.insertBefore(c,n.gutter||n.text):o.appendChild(c),Wn(a,"redraw")}}function Kn(t,e,n,r){if(t.noHScroll){(n.alignable||(n.alignable=[])).push(e);var i=r.wrapperWidth;e.style.left=r.fixedPos+"px",t.coverGutter||(i-=r.gutterTotalWidth,e.style.paddingLeft=r.gutterTotalWidth+"px"),e.style.width=i+"px"}t.coverGutter&&(e.style.zIndex=5,e.style.position="relative",t.noHScroll||(e.style.marginLeft=-r.gutterTotalWidth+"px"))}function qn(t){if(null!=t.height)return t.height;var e=t.doc.cm;if(!e)return 0;if(!D(document.body,t.node)){var n="position: relative;";t.coverGutter&&(n+="margin-left: -"+e.display.gutters.offsetWidth+"px;"),t.noHScroll&&(n+="width: "+e.display.wrapper.clientWidth+"px;"),O(e.display.measure,N("div",[t.node],null,n))}return t.height=t.node.parentNode.offsetHeight}function Xn(t,e){for(var n=At(e);n!=t.wrapper;n=n.parentNode)if(!n||1==n.nodeType&&"true"==n.getAttribute("cm-ignore-events")||n.parentNode==t.sizer&&n!=t.mover)return!0}function Yn(t){return t.lineSpace.offsetTop}function Zn(t){return t.mover.offsetHeight-t.lineSpace.offsetHeight}function Jn(t){if(t.cachedPaddingH)return t.cachedPaddingH;var e=O(t.measure,N("pre","x","CodeMirror-line-like")),n=window.getComputedStyle?window.getComputedStyle(e):e.currentStyle,r={left:parseInt(n.paddingLeft),right:parseInt(n.paddingRight)};return isNaN(r.left)||isNaN(r.right)||(t.cachedPaddingH=r),r}function Qn(t){return j-t.display.nativeBarWidth}function tr(t){return t.display.scroller.clientWidth-Qn(t)-t.display.barWidth}function er(t){return t.display.scroller.clientHeight-Qn(t)-t.display.barHeight}function nr(t,e,n){var r=t.options.lineWrapping,i=r&&tr(t);if(!e.measure.heights||r&&e.measure.width!=i){var o=e.measure.heights=[];if(r){e.measure.width=i;for(var s=e.text.firstChild.getClientRects(),l=0;l<s.length-1;l++){var a=s[l],c=s[l+1];Math.abs(a.bottom-c.bottom)>2&&o.push((a.bottom+c.top)/2-n.top)}}o.push(n.bottom-n.top)}}function rr(t,e,n){if(t.line==e)return{map:t.measure.map,cache:t.measure.cache};if(t.rest){for(var r=0;r<t.rest.length;r++)if(t.rest[r]==e)return{map:t.measure.maps[r],cache:t.measure.caches[r]};for(var i=0;i<t.rest.length;i++)if(se(t.rest[i])>n)return{map:t.measure.maps[i],cache:t.measure.caches[i],before:!0}}}function ir(t,e){var n=se(e=rn(e)),r=t.display.externalMeasured=new Mn(t.doc,e,n);r.lineN=n;var i=r.built=wn(t,r);return r.text=i.pre,O(t.display.lineMeasure,i.pre),r}function or(t,e,n,r){return ar(t,lr(t,e),n,r)}function sr(t,e){if(e>=t.display.viewFrom&&e<t.display.viewTo)return t.display.view[Br(t,e)];var n=t.display.externalMeasured;return n&&e>=n.lineN&&e<n.lineN+n.size?n:void 0}function lr(t,e){var n=se(e),r=sr(t,n);r&&!r.text?r=null:r&&r.changes&&(Hn(t,r,n,Hr(t)),t.curOp.forceUpdate=!0),r||(r=ir(t,e));var i=rr(r,e,n);return{line:e,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function ar(t,e,n,r,i){e.before&&(n=-1);var o,s=n+(r||"");return e.cache.hasOwnProperty(s)?o=e.cache[s]:(e.rect||(e.rect=e.view.text.getBoundingClientRect()),e.hasHeights||(nr(t,e.view,e.rect),e.hasHeights=!0),(o=fr(t,e,n,r)).bogus||(e.cache[s]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}var cr,hr={left:0,right:0,top:0,bottom:0};function ur(t,e,n){for(var r,i,o,s,l,a,c=0;c<t.length;c+=3)if(l=t[c],a=t[c+1],e<l?(i=0,o=1,s="left"):e<a?o=1+(i=e-l):(c==t.length-3||e==a&&t[c+3]>e)&&(i=(o=a-l)-1,e>=a&&(s="right")),null!=i){if(r=t[c+2],l==a&&n==(r.insertLeft?"left":"right")&&(s=n),"left"==n&&0==i)for(;c&&t[c-2]==t[c-3]&&t[c-1].insertLeft;)r=t[2+(c-=3)],s="left";if("right"==n&&i==a-l)for(;c<t.length-3&&t[c+3]==t[c+4]&&!t[c+5].insertLeft;)r=t[(c+=3)+2],s="right";break}return{node:r,start:i,end:o,collapse:s,coverStart:l,coverEnd:a}}function dr(t,e){var n=hr;if("left"==e)for(var r=0;r<t.length&&(n=t[r]).left==n.right;r++);else for(var i=t.length-1;i>=0&&(n=t[i]).left==n.right;i--);return n}function fr(t,e,n,r){var i,o=ur(e.map,n,r),a=o.node,c=o.start,h=o.end,u=o.collapse;if(3==a.nodeType){for(var d=0;d<4;d++){for(;c&&ht(e.line.text.charAt(o.coverStart+c));)--c;for(;o.coverStart+h<o.coverEnd&&ht(e.line.text.charAt(o.coverStart+h));)++h;if((i=s&&l<9&&0==c&&h==o.coverEnd-o.coverStart?a.parentNode.getBoundingClientRect():dr(L(a,c,h).getClientRects(),r)).left||i.right||0==c)break;h=c,c-=1,u="right"}s&&l<11&&(i=pr(t.display.measure,i))}else{var f;c>0&&(u=r="right"),i=t.options.lineWrapping&&(f=a.getClientRects()).length>1?f["right"==r?f.length-1:0]:a.getBoundingClientRect()}if(s&&l<9&&!c&&(!i||!i.left&&!i.right)){var p=a.parentNode.getClientRects()[0];i=p?{left:p.left,right:p.left+Pr(t.display),top:p.top,bottom:p.bottom}:hr}for(var g=i.top-e.rect.top,m=i.bottom-e.rect.top,v=(g+m)/2,y=e.view.measure.heights,b=0;b<y.length-1&&!(v<y[b]);b++);var w=b?y[b-1]:0,x=y[b],_={left:("right"==u?i.right:i.left)-e.rect.left,right:("left"==u?i.left:i.right)-e.rect.left,top:w,bottom:x};return i.left||i.right||(_.bogus=!0),t.options.singleCursorHeightPerLine||(_.rtop=g,_.rbottom=m),_}function pr(t,e){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!$t(t))return e;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:e.left*n,right:e.right*n,top:e.top*r,bottom:e.bottom*r}}function gr(t){if(t.measure&&(t.measure.cache={},t.measure.heights=null,t.rest))for(var e=0;e<t.rest.length;e++)t.measure.caches[e]={}}function mr(t){t.display.externalMeasure=null,T(t.display.lineMeasure);for(var e=0;e<t.display.view.length;e++)gr(t.display.view[e])}function vr(t){mr(t),