1
0
mirror of https://github.com/pdemian/human2regex.git synced 2025-05-15 20:10:19 -07:00
human2regex/docs/bundle.min.js
2020-11-18 01:55:36 -05:00

7 lines
343 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

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

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=7)}([function(t,e,n){"use strict";function r(t){return t&&0===t.length}function i(t){return null==t?[]:Object.keys(t)}function o(t){for(var e=[],n=Object.keys(t),r=0;r<n.length;r++)e.push(t[n[r]]);return e}function a(t,e){for(var n=[],r=i(t),o=0;o<r.length;o++){var a=r[o];n.push(e.call(null,t[a],a))}return n}function s(t,e){for(var n=[],r=0;r<t.length;r++)n.push(e.call(null,t[r],r));return n}function c(t){for(var e=[],n=0;n<t.length;n++){var r=t[n];Array.isArray(r)?e=e.concat(c(r)):e.push(r)}return e}function l(t){return r(t)?void 0:t[0]}function u(t){var e=t&&t.length;return e?t[e-1]:void 0}function h(t,e){if(Array.isArray(t))for(var n=0;n<t.length;n++)e.call(null,t[n],n);else{if(!R(t))throw Error("non exhaustive match");var r=i(t);for(n=0;n<r.length;n++){var o=r[n],a=t[o];e.call(null,a,o)}}}function f(t){return"string"==typeof t}function p(t){return void 0===t}function d(t){return t instanceof Function}function m(t,e){return void 0===e&&(e=1),t.slice(e,t.length)}function g(t,e){return void 0===e&&(e=1),t.slice(0,t.length-e)}function v(t,e){var n=[];if(Array.isArray(t))for(var r=0;r<t.length;r++){var i=t[r];e.call(null,i)&&n.push(i)}return n}function y(t,e){return v(t,(function(t){return!e(t)}))}function b(t,e){for(var n=Object.keys(t),r={},i=0;i<n.length;i++){var o=n[i],a=t[o];e(a)&&(r[o]=a)}return r}function T(t,e){return!!R(t)&&t.hasOwnProperty(e)}function O(t,e){return void 0!==E(t,(function(t){return t===e}))}function S(t){for(var e=[],n=0;n<t.length;n++)e.push(t[n]);return e}function x(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function E(t,e){for(var n=0;n<t.length;n++){var r=t[n];if(e.call(null,r))return r}}function C(t,e){for(var n=[],r=0;r<t.length;r++){var i=t[r];e.call(null,i)&&n.push(i)}return n}function k(t,e,n){for(var r=Array.isArray(t),a=r?t:o(t),s=r?[]:i(t),c=n,l=0;l<a.length;l++)c=e.call(null,c,a[l],r?l:s[l]);return c}function w(t){return y(t,(function(t){return null==t}))}function N(t,e){void 0===e&&(e=function(t){return t});var n=[];return k(t,(function(t,r){var i=e(r);return O(n,i)?t:(n.push(i),t.concat(r))}),[])}function L(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=[null],i=r.concat(e);return Function.bind.apply(t,i)}function A(t){return Array.isArray(t)}function I(t){return t instanceof RegExp}function R(t){return t instanceof Object}function M(t,e){for(var n=0;n<t.length;n++)if(!e(t[n],n))return!1;return!0}function _(t,e){return y(t,(function(t){return O(e,t)}))}function P(t,e){for(var n=0;n<t.length;n++)if(e(t[n]))return!0;return!1}function j(t,e){for(var n=0;n<t.length;n++)if(t[n]===e)return n;return-1}function D(t,e){var n=S(t);return n.sort((function(t,n){return e(t)-e(n)})),n}function F(t,e){if(t.length!==e.length)throw Error("can't zipObject with different number of keys and values!");for(var n={},r=0;r<t.length;r++)n[t[r]]=e[r];return n}function U(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++)for(var o=e[r],a=i(o),s=0;s<a.length;s++){var c=a[s];t[c]=o[c]}return t}function W(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++)for(var o=e[r],a=i(o),s=0;s<a.length;s++){var c=a[s];T(t,c)||(t[c]=o[c])}return t}function B(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return W.apply(null,[{}].concat(t))}function H(t,e){var n={};return h(t,(function(t){var r=e(t),i=n[r];i?i.push(t):n[r]=[t]})),n}function G(t,e){for(var n=x(t),r=i(e),o=0;o<r.length;o++){var a=r[o],s=e[a];n[a]=s}return n}function z(){}function V(t){return t}function K(t){for(var e=[],n=0;n<t.length;n++){var r=t[n];e.push(void 0!==r?r:void 0)}return e}function Y(t){console&&console.error&&console.error("Error: "+t)}function X(t){console&&console.warn&&console.warn("Warning: "+t)}function $(){return"function"==typeof Map}function q(t,e){e.forEach((function(e){var n=e.prototype;Object.getOwnPropertyNames(n).forEach((function(r){if("constructor"!==r){var i=Object.getOwnPropertyDescriptor(n,r);i&&(i.get||i.set)?Object.defineProperty(t.prototype,r,i):t.prototype[r]=e.prototype[r]}}))}))}function Z(t){function e(){}e.prototype=t;var n=new e;function r(){return typeof n.bar}return r(),r(),t}function Q(t){return t[t.length-1]}function J(t){var e=(new Date).getTime(),n=t();return{time:(new Date).getTime()-e,value:n}}n.d(e,"A",(function(){return r})),n.d(e,"G",(function(){return i})),n.d(e,"U",(function(){return o})),n.d(e,"J",(function(){return a})),n.d(e,"I",(function(){return s})),n.d(e,"t",(function(){return c})),n.d(e,"s",(function(){return l})),n.d(e,"H",(function(){return u})),n.d(e,"u",(function(){return h})),n.d(e,"E",(function(){return f})),n.d(e,"F",(function(){return p})),n.d(e,"B",(function(){return d})),n.d(e,"m",(function(){return m})),n.d(e,"n",(function(){return g})),n.d(e,"p",(function(){return v})),n.d(e,"P",(function(){return y})),n.d(e,"N",(function(){return b})),n.d(e,"w",(function(){return T})),n.d(e,"j",(function(){return O})),n.d(e,"g",(function(){return S})),n.d(e,"h",(function(){return x})),n.d(e,"q",(function(){return E})),n.d(e,"r",(function(){return C})),n.d(e,"O",(function(){return k})),n.d(e,"i",(function(){return w})),n.d(e,"T",(function(){return N})),n.d(e,"y",(function(){return A})),n.d(e,"D",(function(){return I})),n.d(e,"C",(function(){return R})),n.d(e,"o",(function(){return M})),n.d(e,"l",(function(){return _})),n.d(e,"Q",(function(){return P})),n.d(e,"x",(function(){return j})),n.d(e,"f",(function(){return U})),n.d(e,"k",(function(){return B})),n.d(e,"v",(function(){return H})),n.d(e,"K",(function(){return G})),n.d(e,"b",(function(){return z})),n.d(e,"a",(function(){return V})),n.d(e,"L",(function(){return K})),n.d(e,"c",(function(){return Y})),n.d(e,"d",(function(){return X})),n.d(e,"z",(function(){return $})),n.d(e,"e",(function(){return q})),n.d(e,"S",(function(){return Z})),n.d(e,"M",(function(){return Q})),n.d(e,"R",(function(){return J}))},function(t,e,n){var r,i,o;"undefined"!=typeof self&&self,i=[],void 0===(o="function"==typeof(r=function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(t){this.idx=t.idx,this.input=t.input,this.groupIdx=t.groupIdx},t.prototype.pattern=function(t){this.idx=0,this.input=t,this.groupIdx=0,this.consumeChar("/");var e=this.disjunction();this.consumeChar("/");for(var n={type:"Flags",loc:{begin:this.idx,end:t.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":s(n,"global");break;case"i":s(n,"ignoreCase");break;case"m":s(n,"multiLine");break;case"u":s(n,"unicode");break;case"y":s(n,"sticky")}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:e,loc:this.loc(0)}},t.prototype.disjunction=function(){var t=[],e=this.idx;for(t.push(this.alternative());"|"===this.peekChar();)this.consumeChar("|"),t.push(this.alternative());return{type:"Disjunction",value:t,loc:this.loc(e)}},t.prototype.alternative=function(){for(var t=[],e=this.idx;this.isTerm();)t.push(this.term());return{type:"Alternative",value:t,loc:this.loc(e)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var t=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(t)};case"$":return{type:"EndAnchor",loc:this.loc(t)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(t)};case"B":return{type:"NonWordBoundary",loc:this.loc(t)}}throw Error("Invalid Assertion Escape");case"(":var e;switch(this.consumeChar("?"),this.popChar()){case"=":e="Lookahead";break;case"!":e="NegativeLookahead"}c(e);var n=this.disjunction();return this.consumeChar(")"),{type:e,value:n,loc:this.loc(t)}}!function(){throw Error("Internal Error - Should never get here!")}()},t.prototype.quantifier=function(t){var e,n=this.idx;switch(this.popChar()){case"*":e={atLeast:0,atMost:1/0};break;case"+":e={atLeast:1,atMost:1/0};break;case"?":e={atLeast:0,atMost:1};break;case"{":var r=this.integerIncludingZero();switch(this.popChar()){case"}":e={atLeast:r,atMost:r};break;case",":e=this.isDigit()?{atLeast:r,atMost:this.integerIncludingZero()}:{atLeast:r,atMost:1/0},this.consumeChar("}")}if(!0===t&&void 0===e)return;c(e)}if(!0!==t||void 0!==e)return c(e),"?"===this.peekChar(0)?(this.consumeChar("?"),e.greedy=!1):e.greedy=!0,e.type="Quantifier",e.loc=this.loc(n),e},t.prototype.atom=function(){var t,e=this.idx;switch(this.peekChar()){case".":t=this.dotAll();break;case"\\":t=this.atomEscape();break;case"[":t=this.characterClass();break;case"(":t=this.group()}return void 0===t&&this.isPatternCharacter()&&(t=this.patternCharacter()),c(t),t.loc=this.loc(e),this.isQuantifier()&&(t.quantifier=this.quantifier()),t},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[o("\n"),o("\r"),o("\u2028"),o("\u2029")]}},t.prototype.atomEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.decimalEscapeAtom=function(){return{type:"GroupBackReference",value:this.positiveInteger()}},t.prototype.characterClassEscape=function(){var t,e=!1;switch(this.popChar()){case"d":t=l;break;case"D":t=l,e=!0;break;case"s":t=h;break;case"S":t=h,e=!0;break;case"w":t=u;break;case"W":t=u,e=!0}return c(t),{type:"Set",value:t,complement:e}},t.prototype.controlEscapeAtom=function(){var t;switch(this.popChar()){case"f":t=o("\f");break;case"n":t=o("\n");break;case"r":t=o("\r");break;case"t":t=o("\t");break;case"v":t=o("\v")}return c(t),{type:"Character",value:t}},t.prototype.controlLetterEscapeAtom=function(){this.consumeChar("c");var t=this.popChar();if(!1===/[a-zA-Z]/.test(t))throw Error("Invalid ");return{type:"Character",value:t.toUpperCase().charCodeAt(0)-64}},t.prototype.nulCharacterAtom=function(){return this.consumeChar("0"),{type:"Character",value:o("\0")}},t.prototype.hexEscapeSequenceAtom=function(){return this.consumeChar("x"),this.parseHexDigits(2)},t.prototype.regExpUnicodeEscapeSequenceAtom=function(){return this.consumeChar("u"),this.parseHexDigits(4)},t.prototype.identityEscapeAtom=function(){return{type:"Character",value:o(this.popChar())}},t.prototype.classPatternCharacterAtom=function(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:o(this.popChar())}}},t.prototype.characterClass=function(){var t=[],e=!1;for(this.consumeChar("["),"^"===this.peekChar(0)&&(this.consumeChar("^"),e=!0);this.isClassAtom();){var n=this.classAtom();if("Character"===n.type&&this.isRangeDash()){this.consumeChar("-");var r=this.classAtom();if("Character"===r.type){if(r.value<n.value)throw Error("Range out of order in character class");t.push({from:n.value,to:r.value})}else a(n.value,t),t.push(o("-")),a(r.value,t)}else a(n.value,t)}return this.consumeChar("]"),{type:"Set",complement:e,value:t}},t.prototype.classAtom=function(){switch(this.peekChar()){case"]":case"\n":case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}},t.prototype.classEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:o("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.group=function(){var t=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),t=!1;break;default:this.groupIdx++}var e=this.disjunction();this.consumeChar(")");var n={type:"Group",capturing:t,value:e};return t&&(n.idx=this.groupIdx),n},t.prototype.positiveInteger=function(){var t=this.popChar();if(!1===i.test(t))throw Error("Expecting a positive integer");for(;r.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)},t.prototype.integerIncludingZero=function(){var t=this.popChar();if(!1===r.test(t))throw Error("Expecting an integer");for(;r.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)},t.prototype.patternCharacter=function(){var t=this.popChar();switch(t){case"\n":case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:o(t)}}},t.prototype.isRegExpFlag=function(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}},t.prototype.isRangeDash=function(){return"-"===this.peekChar()&&this.isClassAtom(1)},t.prototype.isDigit=function(){return r.test(this.peekChar(0))},t.prototype.isClassAtom=function(t){switch(void 0===t&&(t=0),this.peekChar(t)){case"]":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.isTerm=function(){return this.isAtom()||this.isAssertion()},t.prototype.isAtom=function(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}},t.prototype.isAssertion=function(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return"?"===this.peekChar(1)&&("="===this.peekChar(2)||"!"===this.peekChar(2));default:return!1}},t.prototype.isQuantifier=function(){var t=this.saveState();try{return void 0!==this.quantifier(!0)}catch(t){return!1}finally{this.restoreState(t)}},t.prototype.isPatternCharacter=function(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.parseHexDigits=function(t){for(var e="",r=0;r<t;r++){var i=this.popChar();if(!1===n.test(i))throw Error("Expecting a HexDecimal digits");e+=i}return{type:"Character",value:parseInt(e,16)}},t.prototype.peekChar=function(t){return void 0===t&&(t=0),this.input[this.idx+t]},t.prototype.popChar=function(){var t=this.peekChar(0);return this.consumeChar(),t},t.prototype.consumeChar=function(t){if(void 0!==t&&this.input[this.idx]!==t)throw Error("Expected: '"+t+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++},t.prototype.loc=function(t){return{begin:t,end:this.idx}};var e,n=/[0-9a-fA-F]/,r=/[0-9]/,i=/[1-9]/;function o(t){return t.charCodeAt(0)}function a(t,e){void 0!==t.length?t.forEach((function(t){e.push(t)})):e.push(t)}function s(t,e){if(!0===t[e])throw"duplicate flag "+e;t[e]=!0}function c(t){if(void 0===t)throw Error("Internal Error - Should never get here!")}var l=[];for(e=o("0");e<=o("9");e++)l.push(e);var u=[o("_")].concat(l);for(e=o("a");e<=o("z");e++)u.push(e);for(e=o("A");e<=o("Z");e++)u.push(e);var h=[o(" "),o("\f"),o("\n"),o("\r"),o("\t"),o("\v"),o("\t"),o(" "),o(""),o(" "),o(""),o(""),o(""),o(""),o(""),o(""),o(""),o(""),o(""),o(""),o("\u2028"),o("\u2029"),o(""),o(""),o(" "),o("\ufeff")];function f(){}return f.prototype.visitChildren=function(t){for(var e in t){var n=t[e];t.hasOwnProperty(e)&&(void 0!==n.type?this.visit(n):Array.isArray(n)&&n.forEach((function(t){this.visit(t)}),this))}},f.prototype.visit=function(t){switch(t.type){case"Pattern":this.visitPattern(t);break;case"Flags":this.visitFlags(t);break;case"Disjunction":this.visitDisjunction(t);break;case"Alternative":this.visitAlternative(t);break;case"StartAnchor":this.visitStartAnchor(t);break;case"EndAnchor":this.visitEndAnchor(t);break;case"WordBoundary":this.visitWordBoundary(t);break;case"NonWordBoundary":this.visitNonWordBoundary(t);break;case"Lookahead":this.visitLookahead(t);break;case"NegativeLookahead":this.visitNegativeLookahead(t);break;case"Character":this.visitCharacter(t);break;case"Set":this.visitSet(t);break;case"Group":this.visitGroup(t);break;case"GroupBackReference":this.visitGroupBackReference(t);break;case"Quantifier":this.visitQuantifier(t)}this.visitChildren(t)},f.prototype.visitPattern=function(t){},f.prototype.visitFlags=function(t){},f.prototype.visitDisjunction=function(t){},f.prototype.visitAlternative=function(t){},f.prototype.visitStartAnchor=function(t){},f.prototype.visitEndAnchor=function(t){},f.prototype.visitWordBoundary=function(t){},f.prototype.visitNonWordBoundary=function(t){},f.prototype.visitLookahead=function(t){},f.prototype.visitNegativeLookahead=function(t){},f.prototype.visitCharacter=function(t){},f.prototype.visitSet=function(t){},f.prototype.visitGroup=function(t){},f.prototype.visitGroupBackReference=function(t){},f.prototype.visitQuantifier=function(t){},{RegExpParser:t,BaseRegExpVisitor:f,VERSION:"0.5.0"}})?r.apply(e,i):r)||(t.exports=o)},function(t,e,n){"use strict";
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */Object.defineProperty(e,"__esModule",{value:!0}),e.CommonError=e.append=e.regexEscape=e.removeQuotes=e.findLastIndex=e.last=e.first=e.isSingleRegexCharacter=e.combineFlags=e.hasFlag=e.makeFlag=e.usefulConditional=e.unusedParameter=void 0,e.unusedParameter=function(t,e){},e.usefulConditional=function(t,e){return Boolean(t)},e.makeFlag=function(t){return 1<<t},e.hasFlag=function(t,e){return 0!=(t&e)},e.combineFlags=function(t,e){return t|e},e.isSingleRegexCharacter=function(t){return t.startsWith("\\u")&&6===t.length||t.startsWith("\\U")&&8===t.length||t.startsWith("\\")&&2===t.length||1===t.length},e.first=function(t){return t[0]},e.last=function(t){return t[t.length-1]},e.findLastIndex=function(t,e){for(let n=t.length-1;n>=0;n--)if(t[n]===e)return n;return-1},e.removeQuotes=function(t){return t.substring(1,t.length-1)},e.regexEscape=function(t){return t.replace(/([:\\\-\.\[\]\^\|\(\)\*\+\?\{\}\$\/])/g,"\\$1")},e.append=function(t,...e){for(const n of e)for(const e of n)t.push(e)};class r{constructor(t,e,n,r,i){this.type=t,this.start_line=e,this.start_column=n,this.length=r,this.message=i}static fromLexError(t){const e=t.message.replace(/(--?>|<--?)/g,"");return new r("Lexer Error",t.line,t.column,t.length,e)}static fromParseError(t){var e,n,i;const o=t.name+" - "+t.message.replace(/(--?>|<--?)/g,"");return new r("Parser Error",null!==(e=t.token.startLine)&&void 0!==e?e:NaN,null!==(n=t.token.startColumn)&&void 0!==n?n:NaN,null!==(i=t.token.endOffset)&&void 0!==i?i:NaN-t.token.startOffset,o)}static fromSemanticError(t){return new r("Semantic Error",t.startLine,t.startColumn,t.length,t.message)}toString(){return`${this.type} @ (${this.start_line}, ${this.start_column}): ${this.message}`}}e.CommonError=r},function(t,e,n){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),a=r||i||o,s=a&&(r?document.documentMode||6:+(o||i)[1]),c=!o&&/WebKit\//.test(t),l=c&&/Qt\/\d+\.\d+/.test(t),u=!o&&/Chrome\//.test(t),h=/Opera\//.test(t),f=/Apple Computer/.test(navigator.vendor),p=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(t),d=/PhantomJS/.test(t),m=!o&&/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t),g=/Android/.test(t),v=m||g||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(t),y=m||/Mac/.test(e),b=/\bCrOS\b/.test(t),T=/win/i.test(e),O=h&&t.match(/Version\/(\d*\.\d*)/);O&&(O=Number(O[1])),O&&O>=15&&(h=!1,c=!0);var S=y&&(l||h&&(null==O||O<12.11)),x=n||a&&s>=9;function E(t){return new RegExp("(^|\\s)"+t+"(?:$|\\s)\\s*")}var C,k=function(t,e){var n=t.className,r=E(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 w(t){for(var e=t.childNodes.length;e>0;--e)t.removeChild(t.firstChild);return t}function N(t,e){return w(t).appendChild(e)}function L(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=L(t,e,n,r);return i.setAttribute("role","presentation"),i}function I(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 R(){var t;try{t=document.activeElement}catch(e){t=document.body||null}for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function M(t,e){var n=t.className;E(e).test(n)||(t.className+=(n?" ":"")+e)}function _(t,e){for(var n=t.split(" "),r=0;r<n.length;r++)n[r]&&!E(n[r]).test(e)&&(e+=" "+n[r]);return e}C=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 P=function(t){t.select()};function j(t){var e=Array.prototype.slice.call(arguments,1);return function(){return t.apply(null,e)}}function D(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 F(t,e,n,r,i){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);for(var o=r||0,a=i||0;;){var s=t.indexOf("\t",o);if(s<0||s>=e)return a+(e-o);a+=s-o,a+=n-a%n,o=s+1}}m?P=function(t){t.selectionStart=0,t.selectionEnd=t.value.length}:a&&(P=function(t){try{t.select()}catch(t){}});var U=function(){this.id=null,this.f=null,this.time=0,this.handler=j(this.onTimeout,this)};function W(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 B={toString:function(){return"CodeMirror.Pass"}},H={scroll:!1},G={origin:"*mouse"},z={origin:"+move"};function V(t,e,n){for(var r=0,i=0;;){var o=t.indexOf("\t",r);-1==o&&(o=t.length);var a=o-r;if(o==t.length||i+a>=e)return r+Math.min(a,e-i);if(i+=o-r,r=o+1,(i+=n-i%n)>=e)return r}}var K=[""];function Y(t){for(;K.length<=t;)K.push(X(K)+" ");return K[t]}function X(t){return t[t.length-1]}function $(t,e){for(var n=[],r=0;r<t.length;r++)n[r]=e(t[r],r);return n}function q(){}function Z(t,e){var n;return Object.create?n=Object.create(t):(q.prototype=t,n=new q),e&&D(e,n),n}var Q=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function J(t){return/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||Q.test(t))}function tt(t,e){return e?!!(e.source.indexOf("\\w")>-1&&J(t))||e.test(t):J(t)}function et(t){for(var e in t)if(t.hasOwnProperty(e)&&t[e])return!1;return!0}var nt=/[\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 rt(t){return t.charCodeAt(0)>=768&&nt.test(t)}function it(t,e,n){for(;(n<0?e>0:e<t.length)&&rt(t.charAt(e));)e+=n;return e}function ot(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}}var at=null;function st(t,e,n){var r;at=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:at=i),o.from==e&&(o.from!=o.to&&"before"!=n?r=i:at=i)}return null!=r?r:at}var ct=function(){var t=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,n=/[LRr]/,r=/[Lb1n]/,i=/[1n]/;function o(t,e,n){this.level=t,this.from=e,this.to=n}return function(a,s){var c="ltr"==s?"L":"R";if(0==a.length||"ltr"==s&&!t.test(a))return!1;for(var l,u=a.length,h=[],f=0;f<u;++f)h.push((l=a.charCodeAt(f))<=247?"bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(l):1424<=l&&l<=1524?"R":1536<=l&&l<=1785?"nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111".charAt(l-1536):1774<=l&&l<=2220?"r":8192<=l&&l<=8203?"w":8204==l?"b":"L");for(var p=0,d=c;p<u;++p){var m=h[p];"m"==m?h[p]=d:d=m}for(var g=0,v=c;g<u;++g){var y=h[g];"1"==y&&"r"==v?h[g]="n":n.test(y)&&(v=y,"r"==y&&(h[g]="R"))}for(var b=1,T=h[0];b<u-1;++b){var O=h[b];"+"==O&&"1"==T&&"1"==h[b+1]?h[b]="1":","!=O||T!=h[b+1]||"1"!=T&&"n"!=T||(h[b]=T),T=O}for(var S=0;S<u;++S){var x=h[S];if(","==x)h[S]="N";else if("%"==x){var E=void 0;for(E=S+1;E<u&&"%"==h[E];++E);for(var C=S&&"!"==h[S-1]||E<u&&"1"==h[E]?"1":"N",k=S;k<E;++k)h[k]=C;S=E-1}}for(var w=0,N=c;w<u;++w){var L=h[w];"L"==N&&"1"==L?h[w]="L":n.test(L)&&(N=L)}for(var A=0;A<u;++A)if(e.test(h[A])){var I=void 0;for(I=A+1;I<u&&e.test(h[I]);++I);for(var R="L"==(A?h[A-1]:c),M=R==("L"==(I<u?h[I]:c))?R?"L":"R":c,_=A;_<I;++_)h[_]=M;A=I-1}for(var P,j=[],D=0;D<u;)if(r.test(h[D])){var F=D;for(++D;D<u&&r.test(h[D]);++D);j.push(new o(0,F,D))}else{var U=D,W=j.length,B="rtl"==s?1:0;for(++D;D<u&&"L"!=h[D];++D);for(var H=U;H<D;)if(i.test(h[H])){U<H&&(j.splice(W,0,new o(1,U,H)),W+=B);var G=H;for(++H;H<D&&i.test(h[H]);++H);j.splice(W,0,new o(2,G,H)),W+=B,U=H}else++H;U<D&&j.splice(W,0,new o(1,U,D))}return"ltr"==s&&(1==j[0].level&&(P=a.match(/^\s+/))&&(j[0].from=P[0].length,j.unshift(new o(0,0,P[0].length))),1==X(j).level&&(P=a.match(/\s+$/))&&(X(j).to-=P[0].length,j.push(new o(0,u-P[0].length,u)))),"rtl"==s?j.reverse():j}}();function lt(t,e){var n=t.order;return null==n&&(n=t.order=ct(t.text,e)),n}var ut=[],ht=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]||ut).concat(n)}};function ft(t,e){return t._handlers&&t._handlers[e]||ut}function pt(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=W(i,n);o>-1&&(r[e]=i.slice(0,o).concat(i.slice(o+1)))}}}function dt(t,e){var n=ft(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 mt(t,e,n){return"string"==typeof e&&(e={type:e,preventDefault:function(){this.defaultPrevented=!0}}),dt(t,n||e.type,t,e),Ot(e)||e.codemirrorIgnore}function gt(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==W(n,e[r])&&n.push(e[r])}function vt(t,e){return ft(t,e).length>0}function yt(t){t.prototype.on=function(t,e){ht(this,t,e)},t.prototype.off=function(t,e){pt(this,t,e)}}function bt(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 St(t){bt(t),Tt(t)}function xt(t){return t.target||t.srcElement}function Et(t){var e=t.which;return null==e&&(1&t.button?e=1:2&t.button?e=3:4&t.button&&(e=2)),y&&t.ctrlKey&&1==e&&(e=3),e}var Ct,kt,wt=function(){if(a&&s<9)return!1;var t=L("div");return"draggable"in t||"dragDrop"in t}();function Nt(t){if(null==Ct){var e=L("span","");N(t,L("span",[e,document.createTextNode("x")])),0!=t.firstChild.offsetHeight&&(Ct=e.offsetWidth<=1&&e.offsetHeight>2&&!(a&&s<8))}var n=Ct?L("span",""):L("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function Lt(t){if(null!=kt)return kt;var e=N(t,document.createTextNode("AخA")),n=C(e,0,1).getBoundingClientRect(),r=C(e,1,2).getBoundingClientRect();return w(t),!(!n||n.left==n.right)&&(kt=r.right-n.right<3)}var At,It=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),a=o.indexOf("\r");-1!=a?(n.push(o.slice(0,a)),e+=a+1):(n.push(o),e=i+1)}return n}:function(t){return t.split(/\r\n?|\n/)},Rt=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)},Mt="oncopy"in(At=L("div"))||(At.setAttribute("oncopy","return;"),"function"==typeof At.oncopy),_t=null,Pt={},jt={};function Dt(t,e){arguments.length>2&&(e.dependencies=Array.prototype.slice.call(arguments,2)),Pt[t]=e}function Ft(t){if("string"==typeof t&&jt.hasOwnProperty(t))t=jt[t];else if(t&&"string"==typeof t.name&&jt.hasOwnProperty(t.name)){var e=jt[t.name];"string"==typeof e&&(e={name:e}),(t=Z(e,t)).name=e.name}else{if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return Ft("application/xml");if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+json$/.test(t))return Ft("application/json")}return"string"==typeof t?{name:t}:t||{name:"null"}}function Ut(t,e){e=Ft(e);var n=Pt[e.name];if(!n)return Ut(t,"text/plain");var r=n(t,e);if(Wt.hasOwnProperty(e.name)){var i=Wt[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 a in e.modeProps)r[a]=e.modeProps[a];return r}var Wt={};function Bt(t,e){D(e,Wt.hasOwnProperty(t)?Wt[t]:Wt[t]={})}function Ht(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 Gt(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 zt(t,e,n){return!t.startState||t.startState(e,n)}var Vt=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 Kt(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 Yt(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 Xt(t,e,n){var r=[];return t.iter(e,n,(function(t){r.push(t.text)})),r}function $t(t,e){var n=e-t.height;if(n)for(var r=t;r;r=r.parent)r.height+=n}function qt(t){if(null==t.parent)return null;for(var e=t.parent,n=W(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 Zt(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 a=0;a<t.lines.length;++a){var s=t.lines[a].height;if(e<s)break;e-=s}return n+a}function Qt(t,e){return e>=t.first&&e<t.first+t.size}function Jt(t,e){return String(t.lineNumberFormatter(e+t.firstLineNumber))}function te(t,e,n){if(void 0===n&&(n=null),!(this instanceof te))return new te(t,e,n);this.line=t,this.ch=e,this.sticky=n}function ee(t,e){return t.line-e.line||t.ch-e.ch}function ne(t,e){return t.sticky==e.sticky&&0==ee(t,e)}function re(t){return te(t.line,t.ch)}function ie(t,e){return ee(t,e)<0?e:t}function oe(t,e){return ee(t,e)<0?t:e}function ae(t,e){return Math.max(t.first,Math.min(e,t.first+t.size-1))}function se(t,e){if(e.line<t.first)return te(t.first,0);var n=t.first+t.size-1;return e.line>n?te(n,Kt(t,n).text.length):function(t,e){var n=t.ch;return null==n||n>e?te(t.line,e):n<0?te(t.line,0):t}(e,Kt(t,e.line).text.length)}function ce(t,e){for(var n=[],r=0;r<e.length;r++)n[r]=se(t,e[r]);return n}Vt.prototype.eol=function(){return this.pos>=this.string.length},Vt.prototype.sol=function(){return this.pos==this.lineStart},Vt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},Vt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},Vt.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},Vt.prototype.eatWhile=function(t){for(var e=this.pos;this.eat(t););return this.pos>e},Vt.prototype.eatSpace=function(){for(var t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t},Vt.prototype.skipToEnd=function(){this.pos=this.string.length},Vt.prototype.skipTo=function(t){var e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0},Vt.prototype.backUp=function(t){this.pos-=t},Vt.prototype.column=function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=F(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue-(this.lineStart?F(this.string,this.lineStart,this.tabSize):0)},Vt.prototype.indentation=function(){return F(this.string,null,this.tabSize)-(this.lineStart?F(this.string,this.lineStart,this.tabSize):0)},Vt.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},Vt.prototype.current=function(){return this.string.slice(this.start,this.pos)},Vt.prototype.hideFirstChars=function(t,e){this.lineStart+=t;try{return e()}finally{this.lineStart-=t}},Vt.prototype.lookAhead=function(t){var e=this.lineOracle;return e&&e.lookAhead(t)},Vt.prototype.baseToken=function(){var t=this.lineOracle;return t&&t.baseToken(this.pos)};var le=function(t,e){this.state=t,this.lookAhead=e},ue=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 he(t,e,n,r){var i=[t.state.modeGen],o={};Te(t,e.text,t.doc.mode,n,(function(t,e){return i.push(t,e)}),o,r);for(var a=n.state,s=function(r){n.baseTokens=i;var s=t.state.overlays[r],c=1,l=0;n.state=!0,Te(t,e.text,s.mode,n,(function(t,e){for(var n=c;l<t;){var r=i[c];r>t&&i.splice(c,1,t,i[c+1],r),c+=2,l=Math.min(t,r)}if(e)if(s.opaque)i.splice(n,c-n,t,"overlay "+e),c=n+2;else for(;n<c;n+=2){var o=i[n+1];i[n+1]=(o?o+" ":"")+"overlay "+e}}),o),n.state=a,n.baseTokens=null,n.baseTokenPos=1},c=0;c<t.state.overlays.length;++c)s(c);return{styles:i,classes:o.bgClass||o.textClass?o:null}}function fe(t,e,n){if(!e.styles||e.styles[0]!=t.state.modeGen){var r=pe(t,qt(e)),i=e.text.length>t.options.maxHighlightLength&&Ht(t.doc.mode,r.state),o=he(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 pe(t,e,n){var r=t.doc,i=t.display;if(!r.mode.startState)return new ue(r,!0,e);var o=function(t,e,n){for(var r,i,o=t.doc,a=n?-1:e-(t.doc.mode.innerMode?1e3:100),s=e;s>a;--s){if(s<=o.first)return o.first;var c=Kt(o,s-1),l=c.stateAfter;if(l&&(!n||s+(l instanceof le?l.lookAhead:0)<=o.modeFrontier))return s;var u=F(c.text,null,t.options.tabSize);(null==i||r>u)&&(i=s-1,r=u)}return i}(t,e,n),a=o>r.first&&Kt(r,o-1).stateAfter,s=a?ue.fromSaved(r,a,o):new ue(r,zt(r.mode),o);return r.iter(o,e,(function(n){de(t,n.text,s);var r=s.line;n.stateAfter=r==e-1||r%5==0||r>=i.viewFrom&&r<i.viewTo?s.save():null,s.nextLine()})),n&&(r.modeFrontier=s.line),s}function de(t,e,n,r){var i=t.doc.mode,o=new Vt(e,t.options.tabSize,n);for(o.start=o.pos=r||0,""==e&&me(i,n.state);!o.eol();)ge(i,o,n.state),o.start=o.pos}function me(t,e){if(t.blankLine)return t.blankLine(e);if(t.innerMode){var n=Gt(t,e);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function ge(t,e,n,r){for(var i=0;i<10;i++){r&&(r[0]=Gt(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.")}ue.prototype.lookAhead=function(t){var e=this.doc.getLine(this.line+t);return null!=e&&t>this.maxLookAhead&&(this.maxLookAhead=t),e},ue.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}},ue.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},ue.fromSaved=function(t,e,n){return e instanceof le?new ue(t,Ht(t.mode,e.state),n,e.lookAhead):new ue(t,Ht(t.mode,e),n)},ue.prototype.save=function(t){var e=!1!==t?Ht(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new le(e,this.maxLookAhead):e};var ve=function(t,e,n){this.start=t.start,this.end=t.pos,this.string=t.current(),this.type=e||null,this.state=n};function ye(t,e,n,r){var i,o,a=t.doc,s=a.mode,c=Kt(a,(e=se(a,e)).line),l=pe(t,e.line,n),u=new Vt(c.text,t.options.tabSize,l);for(r&&(o=[]);(r||u.pos<e.ch)&&!u.eol();)u.start=u.pos,i=ge(s,u,l.state),r&&o.push(new ve(u,i,Ht(a.mode,l.state)));return r?o:new ve(u,i,l.state)}function be(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 Te(t,e,n,r,i,o,a){var s=n.flattenSpans;null==s&&(s=t.options.flattenSpans);var c,l=0,u=null,h=new Vt(e,t.options.tabSize,r),f=t.options.addModeClass&&[null];for(""==e&&be(me(n,r.state),o);!h.eol();){if(h.pos>t.options.maxHighlightLength?(s=!1,a&&de(t,e,r,h.pos),h.pos=e.length,c=null):c=be(ge(n,h,r.state,f),o),f){var p=f[0].name;p&&(c="m-"+(c?p+" "+c:p))}if(!s||u!=c){for(;l<h.start;)i(l=Math.min(h.start,l+5e3),u);u=c}h.start=h.pos}for(;l<h.pos;){var d=Math.min(h.pos,l+5e3);i(d,u),l=d}}var Oe=!1,Se=!1;function xe(t,e,n){this.marker=t,this.from=e,this.to=n}function Ee(t,e){if(t)for(var n=0;n<t.length;++n){var r=t[n];if(r.marker==e)return r}}function Ce(t,e){for(var n,r=0;r<t.length;++r)t[r]!=e&&(n||(n=[])).push(t[r]);return n}function ke(t,e){if(e.full)return null;var n=Qt(t,e.from.line)&&Kt(t,e.from.line).markedSpans,r=Qt(t,e.to.line)&&Kt(t,e.to.line).markedSpans;if(!n&&!r)return null;var i=e.from.ch,o=e.to.ch,a=0==ee(e.from,e.to),s=function(t,e,n){var r;if(t)for(var i=0;i<t.length;++i){var o=t[i],a=o.marker;if(null==o.from||(a.inclusiveLeft?o.from<=e:o.from<e)||o.from==e&&"bookmark"==a.type&&(!n||!o.marker.insertLeft)){var s=null==o.to||(a.inclusiveRight?o.to>=e:o.to>e);(r||(r=[])).push(new xe(a,o.from,s?null:o.to))}}return r}(n,i,a),c=function(t,e,n){var r;if(t)for(var i=0;i<t.length;++i){var o=t[i],a=o.marker;if(null==o.to||(a.inclusiveRight?o.to>=e:o.to>e)||o.from==e&&"bookmark"==a.type&&(!n||o.marker.insertLeft)){var s=null==o.from||(a.inclusiveLeft?o.from<=e:o.from<e);(r||(r=[])).push(new xe(a,s?null:o.from-e,null==o.to?null:o.to-e))}}return r}(r,o,a),l=1==e.text.length,u=X(e.text).length+(l?i:0);if(s)for(var h=0;h<s.length;++h){var f=s[h];if(null==f.to){var p=Ee(c,f.marker);p?l&&(f.to=null==p.to?null:p.to+u):f.to=i}}if(c)for(var d=0;d<c.length;++d){var m=c[d];null!=m.to&&(m.to+=u),null==m.from?Ee(s,m.marker)||(m.from=u,l&&(s||(s=[])).push(m)):(m.from+=u,l&&(s||(s=[])).push(m))}s&&(s=we(s)),c&&c!=s&&(c=we(c));var g=[s];if(!l){var v,y=e.text.length-2;if(y>0&&s)for(var b=0;b<s.length;++b)null==s[b].to&&(v||(v=[])).push(new xe(s[b].marker,null,null));for(var T=0;T<y;++T)g.push(v);g.push(c)}return g}function we(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 Ne(t){var e=t.markedSpans;if(e){for(var n=0;n<e.length;++n)e[n].marker.detachLine(t);t.markedSpans=null}}function Le(t,e){if(e){for(var n=0;n<e.length;++n)e[n].marker.attachLine(t);t.markedSpans=e}}function Ae(t){return t.inclusiveLeft?-1:0}function Ie(t){return t.inclusiveRight?1:0}function Re(t,e){var n=t.lines.length-e.lines.length;if(0!=n)return n;var r=t.find(),i=e.find(),o=ee(r.from,i.from)||Ae(t)-Ae(e);if(o)return-o;var a=ee(r.to,i.to)||Ie(t)-Ie(e);return a||e.id-t.id}function Me(t,e){var n,r=Se&&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||Re(n,i.marker)<0)&&(n=i.marker);return n}function _e(t){return Me(t,!0)}function Pe(t){return Me(t,!1)}function je(t,e){var n,r=Se&&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||Re(n,o.marker)<0)&&(n=o.marker)}return n}function De(t,e,n,r,i){var o=Kt(t,e),a=Se&&o.markedSpans;if(a)for(var s=0;s<a.length;++s){var c=a[s];if(c.marker.collapsed){var l=c.marker.find(0),u=ee(l.from,n)||Ae(c.marker)-Ae(i),h=ee(l.to,r)||Ie(c.marker)-Ie(i);if(!(u>=0&&h<=0||u<=0&&h>=0)&&(u<=0&&(c.marker.inclusiveRight&&i.inclusiveLeft?ee(l.to,n)>=0:ee(l.to,n)>0)||u>=0&&(c.marker.inclusiveRight&&i.inclusiveLeft?ee(l.from,r)<=0:ee(l.from,r)<0)))return!0}}}function Fe(t){for(var e;e=_e(t);)t=e.find(-1,!0).line;return t}function Ue(t,e){var n=Kt(t,e),r=Fe(n);return n==r?e:qt(r)}function We(t,e){if(e>t.lastLine())return e;var n,r=Kt(t,e);if(!Be(t,r))return e;for(;n=Pe(r);)r=n.find(1,!0).line;return qt(r)+1}function Be(t,e){var n=Se&&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&&He(t,e,r))return!0}}function He(t,e,n){if(null==n.to){var r=n.marker.find(1,!0);return He(t,r.line,Ee(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)&&He(t,e,i))return!0}function Ge(t){for(var e=0,n=(t=Fe(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 a=0;a<o.children.length;++a){var s=o.children[a];if(s==n)break;e+=s.height}return e}function ze(t){if(0==t.height)return 0;for(var e,n=t.text.length,r=t;e=_e(r);){var i=e.find(0,!0);r=i.from.line,n+=i.from.ch-i.to.ch}for(r=t;e=Pe(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 Ve(t){var e=t.display,n=t.doc;e.maxLine=Kt(n,n.first),e.maxLineLength=ze(e.maxLine),e.maxLineChanged=!0,n.iter((function(t){var n=ze(t);n>e.maxLineLength&&(e.maxLineLength=n,e.maxLine=t)}))}var Ke=function(t,e,n){this.text=t,Le(this,e),this.height=n?n(this):1};function Ye(t){t.parent=null,Ne(t)}Ke.prototype.lineNo=function(){return qt(this)},yt(Ke);var Xe={},$e={};function qe(t,e){if(!t||/^\s*$/.test(t))return null;var n=e.addModeClass?$e:Xe;return n[t]||(n[t]=t.replace(/\S+/g,"cm-$&"))}function Ze(t,e){var n=A("span",null,null,c?"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,a=void 0;r.pos=0,r.addToken=Je,Lt(t.display.measure)&&(a=lt(o,t.doc.direction))&&(r.addToken=tn(r.addToken,a)),r.map=[],nn(o,r,fe(t,o,e!=t.display.externalMeasured&&qt(o))),o.styleClasses&&(o.styleClasses.bgClass&&(r.bgClass=_(o.styleClasses.bgClass,r.bgClass||"")),o.styleClasses.textClass&&(r.textClass=_(o.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(Nt(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(c){var s=r.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return dt(t,"renderLine",t,e.line,r.pre),r.pre.className&&(r.textClass=_(r.pre.className,r.textClass||"")),r}function Qe(t){var e=L("span","•","cm-invalidchar");return e.title="\\u"+t.charCodeAt(0).toString(16),e.setAttribute("aria-label",e.title),e}function Je(t,e,n,r,i,o,c){if(e){var l,u=t.splitSpaces?function(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}(e,t.trailingSpace):e,h=t.cm.state.specialChars,f=!1;if(h.test(e)){l=document.createDocumentFragment();for(var p=0;;){h.lastIndex=p;var d=h.exec(e),m=d?d.index-p:e.length-p;if(m){var g=document.createTextNode(u.slice(p,p+m));a&&s<9?l.appendChild(L("span",[g])):l.appendChild(g),t.map.push(t.pos,t.pos+m,g),t.col+=m,t.pos+=m}if(!d)break;p+=m+1;var v=void 0;if("\t"==d[0]){var y=t.cm.options.tabSize,b=y-t.col%y;(v=l.appendChild(L("span",Y(b),"cm-tab"))).setAttribute("role","presentation"),v.setAttribute("cm-text","\t"),t.col+=b}else"\r"==d[0]||"\n"==d[0]?((v=l.appendChild(L("span","\r"==d[0]?"␍":"␤","cm-invalidchar"))).setAttribute("cm-text",d[0]),t.col+=1):((v=t.cm.options.specialCharPlaceholder(d[0])).setAttribute("cm-text",d[0]),a&&s<9?l.appendChild(L("span",[v])):l.appendChild(v),t.col+=1);t.map.push(t.pos,t.pos+1,v),t.pos++}}else t.col+=e.length,l=document.createTextNode(u),t.map.push(t.pos,t.pos+e.length,l),a&&s<9&&(f=!0),t.pos+=e.length;if(t.trailingSpace=32==u.charCodeAt(e.length-1),n||r||i||f||o||c){var T=n||"";r&&(T+=r),i&&(T+=i);var O=L("span",[l],T,o);if(c)for(var S in c)c.hasOwnProperty(S)&&"style"!=S&&"class"!=S&&O.setAttribute(S,c[S]);return t.content.appendChild(O)}t.content.appendChild(l)}}function tn(t,e){return function(n,r,i,o,a,s,c){i=i?i+" cm-force-border":"cm-force-border";for(var l=n.pos,u=l+r.length;;){for(var h=void 0,f=0;f<e.length&&!((h=e[f]).to>l&&h.from<=l);f++);if(h.to>=u)return t(n,r,i,o,a,s,c);t(n,r.slice(0,h.to-l),i,o,null,s,c),o=null,r=r.slice(h.to-l),l=h.to}}}function en(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 nn(t,e,n){var r=t.markedSpans,i=t.text,o=0;if(r)for(var a,s,c,l,u,h,f,p=i.length,d=0,m=1,g="",v=0;;){if(v==d){c=l=u=s="",f=null,h=null,v=1/0;for(var y=[],b=void 0,T=0;T<r.length;++T){var O=r[T],S=O.marker;if("bookmark"==S.type&&O.from==d&&S.widgetNode)y.push(S);else if(O.from<=d&&(null==O.to||O.to>d||S.collapsed&&O.to==d&&O.from==d)){if(null!=O.to&&O.to!=d&&v>O.to&&(v=O.to,l=""),S.className&&(c+=" "+S.className),S.css&&(s=(s?s+";":"")+S.css),S.startStyle&&O.from==d&&(u+=" "+S.startStyle),S.endStyle&&O.to==v&&(b||(b=[])).push(S.endStyle,O.to),S.title&&((f||(f={})).title=S.title),S.attributes)for(var x in S.attributes)(f||(f={}))[x]=S.attributes[x];S.collapsed&&(!h||Re(h.marker,S)<0)&&(h=O)}else O.from>d&&v>O.from&&(v=O.from)}if(b)for(var E=0;E<b.length;E+=2)b[E+1]==v&&(l+=" "+b[E]);if(!h||h.from==d)for(var C=0;C<y.length;++C)en(e,0,y[C]);if(h&&(h.from||0)==d){if(en(e,(null==h.to?p+1:h.to)-d,h.marker,null==h.from),null==h.to)return;h.to==d&&(h=!1)}}if(d>=p)break;for(var k=Math.min(p,v);;){if(g){var w=d+g.length;if(!h){var N=w>k?g.slice(0,k-d):g;e.addToken(e,N,a?a+c:c,u,d+N.length==v?l:"",s,f)}if(w>=k){g=g.slice(k-d),d=k;break}d=w,u=""}g=i.slice(o,o=n[m++]),a=qe(n[m++],e.cm.options)}}else for(var L=1;L<n.length;L+=2)e.addToken(e,i.slice(o,o=n[L]),qe(n[L+1],e.cm.options))}function rn(t,e,n){this.line=e,this.rest=function(t){for(var e,n;e=Pe(t);)t=e.find(1,!0).line,(n||(n=[])).push(t);return n}(e),this.size=this.rest?qt(X(this.rest))-n+1:1,this.node=this.text=null,this.hidden=Be(t,e)}function on(t,e,n){for(var r,i=[],o=e;o<n;o=r){var a=new rn(t.doc,Kt(t.doc,o),o);r=o+a.size,i.push(a)}return i}var an=null,sn=null;function cn(t,e){var n=ft(t,e);if(n.length){var r,i=Array.prototype.slice.call(arguments,2);an?r=an.delayedCallbacks:sn?r=sn:(r=sn=[],setTimeout(ln,0));for(var o=function(t){r.push((function(){return n[t].apply(null,i)}))},a=0;a<n.length;++a)o(a)}}function ln(){var t=sn;sn=null;for(var e=0;e<t.length;++e)t[e]()}function un(t,e,n,r){for(var i=0;i<e.changes.length;i++){var o=e.changes[i];"text"==o?pn(t,e):"gutter"==o?mn(t,e,n,r):"class"==o?dn(t,e):"widget"==o&&gn(t,e,r)}e.changes=null}function hn(t){return t.node==t.text&&(t.node=L("div",null,null,"position: relative"),t.text.parentNode&&t.text.parentNode.replaceChild(t.node,t.text),t.node.appendChild(t.text),a&&s<8&&(t.node.style.zIndex=2)),t.node}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):Ze(t,e)}function pn(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,dn(t,e)):n&&(e.text.className=n)}function dn(t,e){!function(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=hn(e);e.background=r.insertBefore(L("div",null,n),r.firstChild),t.display.input.setUneditable(e.background)}}(t,e),e.line.wrapClass?hn(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 mn(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=hn(e);e.gutterBackground=L("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 a=hn(e),s=e.gutter=L("div",null,"CodeMirror-gutter-wrapper","left: "+(t.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(t.display.input.setUneditable(s),a.insertBefore(s,e.text),e.line.gutterClass&&(s.className+=" "+e.line.gutterClass),!t.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(e.lineNumber=s.appendChild(L("div",Jt(t.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+t.display.lineNumInnerWidth+"px"))),o)for(var c=0;c<t.display.gutterSpecs.length;++c){var l=t.display.gutterSpecs[c].className,u=o.hasOwnProperty(l)&&o[l];u&&s.appendChild(L("div",[u],"CodeMirror-gutter-elt","left: "+r.gutterLeft[l]+"px; width: "+r.gutterWidth[l]+"px"))}}}function gn(t,e,n){e.alignable&&(e.alignable=null);for(var r=E("CodeMirror-linewidget"),i=e.node.firstChild,o=void 0;i;i=o)o=i.nextSibling,r.test(i.className)&&e.node.removeChild(i);yn(t,e,n)}function vn(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),dn(t,e),mn(t,e,n,r),yn(t,e,r),e.node}function yn(t,e,n){if(bn(t,e.line,e,n,!0),e.rest)for(var r=0;r<e.rest.length;r++)bn(t,e.rest[r],e,n,!1)}function bn(t,e,n,r,i){if(e.widgets)for(var o=hn(n),a=0,s=e.widgets;a<s.length;++a){var c=s[a],l=L("div",[c.node],"CodeMirror-linewidget"+(c.className?" "+c.className:""));c.handleMouseEvents||l.setAttribute("cm-ignore-events","true"),Tn(c,l,n,r),t.display.input.setUneditable(l),i&&c.above?o.insertBefore(l,n.gutter||n.text):o.appendChild(l),cn(c,"redraw")}}function Tn(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 On(t){if(null!=t.height)return t.height;var e=t.doc.cm;if(!e)return 0;if(!I(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;"),N(e.display.measure,L("div",[t.node],null,n))}return t.height=t.node.parentNode.offsetHeight}function Sn(t,e){for(var n=xt(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 xn(t){return t.lineSpace.offsetTop}function En(t){return t.mover.offsetHeight-t.lineSpace.offsetHeight}function Cn(t){if(t.cachedPaddingH)return t.cachedPaddingH;var e=N(t.measure,L("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 kn(t){return 50-t.display.nativeBarWidth}function wn(t){return t.display.scroller.clientWidth-kn(t)-t.display.barWidth}function Nn(t){return t.display.scroller.clientHeight-kn(t)-t.display.barHeight}function Ln(t,e,n){if(t.line==e)return{map:t.measure.map,cache:t.measure.cache};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(qt(t.rest[i])>n)return{map:t.measure.maps[i],cache:t.measure.caches[i],before:!0}}function An(t,e,n,r){return Mn(t,Rn(t,e),n,r)}function In(t,e){if(e>=t.display.viewFrom&&e<t.display.viewTo)return t.display.view[ur(t,e)];var n=t.display.externalMeasured;return n&&e>=n.lineN&&e<n.lineN+n.size?n:void 0}function Rn(t,e){var n=qt(e),r=In(t,n);r&&!r.text?r=null:r&&r.changes&&(un(t,r,n,or(t)),t.curOp.forceUpdate=!0),r||(r=function(t,e){var n=qt(e=Fe(e)),r=t.display.externalMeasured=new rn(t.doc,e,n);r.lineN=n;var i=r.built=Ze(t,r);return r.text=i.pre,N(t.display.lineMeasure,i.pre),r}(t,e));var i=Ln(r,e,n);return{line:e,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function Mn(t,e,n,r,i){e.before&&(n=-1);var o,c=n+(r||"");return e.cache.hasOwnProperty(c)?o=e.cache[c]:(e.rect||(e.rect=e.view.text.getBoundingClientRect()),e.hasHeights||(function(t,e,n){var r=t.options.lineWrapping,i=r&&wn(t);if(!e.measure.heights||r&&e.measure.width!=i){var o=e.measure.heights=[];if(r){e.measure.width=i;for(var a=e.text.firstChild.getClientRects(),s=0;s<a.length-1;s++){var c=a[s],l=a[s+1];Math.abs(c.bottom-l.bottom)>2&&o.push((c.bottom+l.top)/2-n.top)}}o.push(n.bottom-n.top)}}(t,e.view,e.rect),e.hasHeights=!0),(o=function(t,e,n,r){var i,o=jn(e.map,n,r),c=o.node,l=o.start,u=o.end,h=o.collapse;if(3==c.nodeType){for(var f=0;f<4;f++){for(;l&&rt(e.line.text.charAt(o.coverStart+l));)--l;for(;o.coverStart+u<o.coverEnd&&rt(e.line.text.charAt(o.coverStart+u));)++u;if((i=a&&s<9&&0==l&&u==o.coverEnd-o.coverStart?c.parentNode.getBoundingClientRect():Dn(C(c,l,u).getClientRects(),r)).left||i.right||0==l)break;u=l,l-=1,h="right"}a&&s<11&&(i=function(t,e){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!function(t){if(null!=_t)return _t;var e=N(t,L("span","x")),n=e.getBoundingClientRect(),r=C(e,0,1).getBoundingClientRect();return _t=Math.abs(n.left-r.left)>1}(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}}(t.display.measure,i))}else{var p;l>0&&(h=r="right"),i=t.options.lineWrapping&&(p=c.getClientRects()).length>1?p["right"==r?p.length-1:0]:c.getBoundingClientRect()}if(a&&s<9&&!l&&(!i||!i.left&&!i.right)){var d=c.parentNode.getClientRects()[0];i=d?{left:d.left,right:d.left+ir(t.display),top:d.top,bottom:d.bottom}:Pn}for(var m=i.top-e.rect.top,g=i.bottom-e.rect.top,v=(m+g)/2,y=e.view.measure.heights,b=0;b<y.length-1&&!(v<y[b]);b++);var T=b?y[b-1]:0,O=y[b],S={left:("right"==h?i.right:i.left)-e.rect.left,right:("left"==h?i.left:i.right)-e.rect.left,top:T,bottom:O};return i.left||i.right||(S.bogus=!0),t.options.singleCursorHeightPerLine||(S.rtop=m,S.rbottom=g),S}(t,e,n,r)).bogus||(e.cache[c]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}var _n,Pn={left:0,right:0,top:0,bottom:0};function jn(t,e,n){for(var r,i,o,a,s,c,l=0;l<t.length;l+=3)if(s=t[l],c=t[l+1],e<s?(i=0,o=1,a="left"):e<c?o=1+(i=e-s):(l==t.length-3||e==c&&t[l+3]>e)&&(i=(o=c-s)-1,e>=c&&(a="right")),null!=i){if(r=t[l+2],s==c&&n==(r.insertLeft?"left":"right")&&(a=n),"left"==n&&0==i)for(;l&&t[l-2]==t[l-3]&&t[l-1].insertLeft;)r=t[2+(l-=3)],a="left";if("right"==n&&i==c-s)for(;l<t.length-3&&t[l+3]==t[l+4]&&!t[l+5].insertLeft;)r=t[(l+=3)+2],a="right";break}return{node:r,start:i,end:o,collapse:a,coverStart:s,coverEnd:c}}function Dn(t,e){var n=Pn;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 Fn(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 Un(t){t.display.externalMeasure=null,w(t.display.lineMeasure);for(var e=0;e<t.display.view.length;e++)Fn(t.display.view[e])}function Wn(t){Un(t),t.display.cachedCharWidth=t.display.cachedTextHeight=t.display.cachedPaddingH=null,t.options.lineWrapping||(t.display.maxLineChanged=!0),t.display.lineNumChars=null}function Bn(){return u&&g?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function Hn(){return u&&g?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function Gn(t){var e=0;if(t.widgets)for(var n=0;n<t.widgets.length;++n)t.widgets[n].above&&(e+=On(t.widgets[n]));return e}function zn(t,e,n,r,i){if(!i){var o=Gn(e);n.top+=o,n.bottom+=o}if("line"==r)return n;r||(r="local");var a=Ge(e);if("local"==r?a+=xn(t.display):a-=t.display.viewOffset,"page"==r||"window"==r){var s=t.display.lineSpace.getBoundingClientRect();a+=s.top+("window"==r?0:Hn());var c=s.left+("window"==r?0:Bn());n.left+=c,n.right+=c}return n.top+=a,n.bottom+=a,n}function Vn(t,e,n){if("div"==n)return e;var r=e.left,i=e.top;if("page"==n)r-=Bn(),i-=Hn();else if("local"==n||!n){var o=t.display.sizer.getBoundingClientRect();r+=o.left,i+=o.top}var a=t.display.lineSpace.getBoundingClientRect();return{left:r-a.left,top:i-a.top}}function Kn(t,e,n,r,i){return r||(r=Kt(t.doc,e.line)),zn(t,r,An(t,r,e.ch,i),n)}function Yn(t,e,n,r,i,o){function a(e,a){var s=Mn(t,i,e,a?"right":"left",o);return a?s.left=s.right:s.right=s.left,zn(t,r,s,n)}r=r||Kt(t.doc,e.line),i||(i=Rn(t,r));var s=lt(r,t.doc.direction),c=e.ch,l=e.sticky;if(c>=r.text.length?(c=r.text.length,l="before"):c<=0&&(c=0,l="after"),!s)return a("before"==l?c-1:c,"before"==l);function u(t,e,n){return a(n?t-1:t,1==s[e].level!=n)}var h=st(s,c,l),f=at,p=u(c,h,"before"==l);return null!=f&&(p.other=u(c,f,"before"!=l)),p}function Xn(t,e){var n=0;e=se(t.doc,e),t.options.lineWrapping||(n=ir(t.display)*e.ch);var r=Kt(t.doc,e.line),i=Ge(r)+xn(t.display);return{left:n,right:n,top:i,bottom:i+r.height}}function $n(t,e,n,r,i){var o=te(t,e,n);return o.xRel=i,r&&(o.outside=r),o}function qn(t,e,n){var r=t.doc;if((n+=t.display.viewOffset)<0)return $n(r.first,0,null,-1,-1);var i=Zt(r,n),o=r.first+r.size-1;if(i>o)return $n(r.first+r.size-1,Kt(r,o).text.length,null,1,1);e<0&&(e=0);for(var a=Kt(r,i);;){var s=tr(t,a,i,e,n),c=je(a,s.ch+(s.xRel>0||s.outside>0?1:0));if(!c)return s;var l=c.find(1);if(l.line==i)return l;a=Kt(r,i=l.line)}}function Zn(t,e,n,r){r-=Gn(e);var i=e.text.length,o=ot((function(e){return Mn(t,n,e-1).bottom<=r}),i,0);return{begin:o,end:i=ot((function(e){return Mn(t,n,e).top>r}),o,i)}}function Qn(t,e,n,r){return n||(n=Rn(t,e)),Zn(t,e,n,zn(t,e,Mn(t,n,r),"line").top)}function Jn(t,e,n,r){return!(t.bottom<=n)&&(t.top>n||(r?t.left:t.right)>e)}function tr(t,e,n,r,i){i-=Ge(e);var o=Rn(t,e),a=Gn(e),s=0,c=e.text.length,l=!0,u=lt(e,t.doc.direction);if(u){var h=(t.options.lineWrapping?nr:er)(t,e,n,o,u,r,i);s=(l=1!=h.level)?h.from:h.to-1,c=l?h.to:h.from-1}var f,p,d=null,m=null,g=ot((function(e){var n=Mn(t,o,e);return n.top+=a,n.bottom+=a,!!Jn(n,r,i,!1)&&(n.top<=i&&n.left<=r&&(d=e,m=n),!0)}),s,c),v=!1;if(m){var y=r-m.left<m.right-r,b=y==l;g=d+(b?0:1),p=b?"after":"before",f=y?m.left:m.right}else{l||g!=c&&g!=s||g++,p=0==g?"after":g==e.text.length?"before":Mn(t,o,g-(l?1:0)).bottom+a<=i==l?"after":"before";var T=Yn(t,te(n,g,p),"line",e,o);f=T.left,v=i<T.top?-1:i>=T.bottom?1:0}return $n(n,g=it(e.text,g,1),p,v,r-f)}function er(t,e,n,r,i,o,a){var s=ot((function(s){var c=i[s],l=1!=c.level;return Jn(Yn(t,te(n,l?c.to:c.from,l?"before":"after"),"line",e,r),o,a,!0)}),0,i.length-1),c=i[s];if(s>0){var l=1!=c.level,u=Yn(t,te(n,l?c.from:c.to,l?"after":"before"),"line",e,r);Jn(u,o,a,!0)&&u.top>a&&(c=i[s-1])}return c}function nr(t,e,n,r,i,o,a){var s=Zn(t,e,r,a),c=s.begin,l=s.end;/\s/.test(e.text.charAt(l-1))&&l--;for(var u=null,h=null,f=0;f<i.length;f++){var p=i[f];if(!(p.from>=l||p.to<=c)){var d=Mn(t,r,1!=p.level?Math.min(l,p.to)-1:Math.max(c,p.from)).right,m=d<o?o-d+1e9:d-o;(!u||h>m)&&(u=p,h=m)}}return u||(u=i[i.length-1]),u.from<c&&(u={from:c,to:u.to,level:u.level}),u.to>l&&(u={from:u.from,to:l,level:u.level}),u}function rr(t){if(null!=t.cachedTextHeight)return t.cachedTextHeight;if(null==_n){_n=L("pre",null,"CodeMirror-line-like");for(var e=0;e<49;++e)_n.appendChild(document.createTextNode("x")),_n.appendChild(L("br"));_n.appendChild(document.createTextNode("x"))}N(t.measure,_n);var n=_n.offsetHeight/50;return n>3&&(t.cachedTextHeight=n),w(t.measure),n||1}function ir(t){if(null!=t.cachedCharWidth)return t.cachedCharWidth;var e=L("span","xxxxxxxxxx"),n=L("pre",[e],"CodeMirror-line-like");N(t.measure,n);var r=e.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(t.cachedCharWidth=i),i||10}function or(t){for(var e=t.display,n={},r={},i=e.gutters.clientLeft,o=e.gutters.firstChild,a=0;o;o=o.nextSibling,++a){var s=t.display.gutterSpecs[a].className;n[s]=o.offsetLeft+o.clientLeft+i,r[s]=o.clientWidth}return{fixedPos:ar(e),gutterTotalWidth:e.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:e.wrapper.clientWidth}}function ar(t){return t.scroller.getBoundingClientRect().left-t.sizer.getBoundingClientRect().left}function sr(t){var e=rr(t.display),n=t.options.lineWrapping,r=n&&Math.max(5,t.display.scroller.clientWidth/ir(t.display)-3);return function(i){if(Be(t.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;a<i.widgets.length;a++)i.widgets[a].height&&(o+=i.widgets[a].height);return n?o+(Math.ceil(i.text.length/r)||1)*e:o+e}}function cr(t){var e=t.doc,n=sr(t);e.iter((function(t){var e=n(t);e!=t.height&&$t(t,e)}))}function lr(t,e,n,r){var i=t.display;if(!n&&"true"==xt(e).getAttribute("cm-not-content"))return null;var o,a,s=i.lineSpace.getBoundingClientRect();try{o=e.clientX-s.left,a=e.clientY-s.top}catch(t){return null}var c,l=qn(t,o,a);if(r&&l.xRel>0&&(c=Kt(t.doc,l.line).text).length==l.ch){var u=F(c,c.length,t.options.tabSize)-c.length;l=te(l.line,Math.max(0,Math.round((o-Cn(t.display).left)/ir(t.display))-u))}return l}function ur(t,e){if(e>=t.display.viewTo)return null;if((e-=t.display.viewFrom)<0)return null;for(var n=t.display.view,r=0;r<n.length;r++)if((e-=n[r].size)<0)return r}function hr(t,e,n,r){null==e&&(e=t.doc.first),null==n&&(n=t.doc.first+t.doc.size),r||(r=0);var i=t.display;if(r&&n<i.viewTo&&(null==i.updateLineNumbers||i.updateLineNumbers>e)&&(i.updateLineNumbers=e),t.curOp.viewChanged=!0,e>=i.viewTo)Se&&Ue(t.doc,e)<i.viewTo&&pr(t);else if(n<=i.viewFrom)Se&&We(t.doc,n+r)>i.viewFrom?pr(t):(i.viewFrom+=r,i.viewTo+=r);else if(e<=i.viewFrom&&n>=i.viewTo)pr(t);else if(e<=i.viewFrom){var o=dr(t,n,n+r,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=r):pr(t)}else if(n>=i.viewTo){var a=dr(t,e,e,-1);a?(i.view=i.view.slice(0,a.index),i.viewTo=a.lineN):pr(t)}else{var s=dr(t,e,e,-1),c=dr(t,n,n+r,1);s&&c?(i.view=i.view.slice(0,s.index).concat(on(t,s.lineN,c.lineN)).concat(i.view.slice(c.index)),i.viewTo+=r):pr(t)}var l=i.externalMeasured;l&&(n<l.lineN?l.lineN+=r:e<l.lineN+l.size&&(i.externalMeasured=null))}function fr(t,e,n){t.curOp.viewChanged=!0;var r=t.display,i=t.display.externalMeasured;if(i&&e>=i.lineN&&e<i.lineN+i.size&&(r.externalMeasured=null),!(e<r.viewFrom||e>=r.viewTo)){var o=r.view[ur(t,e)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==W(a,n)&&a.push(n)}}}function pr(t){t.display.viewFrom=t.display.viewTo=t.doc.first,t.display.view=[],t.display.viewOffset=0}function dr(t,e,n,r){var i,o=ur(t,e),a=t.display.view;if(!Se||n==t.doc.first+t.doc.size)return{index:o,lineN:n};for(var s=t.display.viewFrom,c=0;c<o;c++)s+=a[c].size;if(s!=e){if(r>0){if(o==a.length-1)return null;i=s+a[o].size-e,o++}else i=s-e;e+=i,n+=i}for(;Ue(t.doc,n)!=n;){if(o==(r<0?0:a.length-1))return null;n+=r*a[o-(r<0?1:0)].size,o+=r}return{index:o,lineN:n}}function mr(t){for(var e=t.display.view,n=0,r=0;r<e.length;r++){var i=e[r];i.hidden||i.node&&!i.changes||++n}return n}function gr(t){t.display.input.showSelection(t.display.input.prepareSelection())}function vr(t,e){void 0===e&&(e=!0);for(var n=t.doc,r={},i=r.cursors=document.createDocumentFragment(),o=r.selection=document.createDocumentFragment(),a=0;a<n.sel.ranges.length;a++)if(e||a!=n.sel.primIndex){var s=n.sel.ranges[a];if(!(s.from().line>=t.display.viewTo||s.to().line<t.display.viewFrom)){var c=s.empty();(c||t.options.showCursorWhenSelecting)&&yr(t,s.head,i),c||Tr(t,s,o)}}return r}function yr(t,e,n){var r=Yn(t,e,"div",null,null,!t.options.singleCursorHeightPerLine),i=n.appendChild(L("div"," ","CodeMirror-cursor"));if(i.style.left=r.left+"px",i.style.top=r.top+"px",i.style.height=Math.max(0,r.bottom-r.top)*t.options.cursorHeight+"px",r.other){var o=n.appendChild(L("div"," ","CodeMirror-cursor CodeMirror-secondarycursor"));o.style.display="",o.style.left=r.other.left+"px",o.style.top=r.other.top+"px",o.style.height=.85*(r.other.bottom-r.other.top)+"px"}}function br(t,e){return t.top-e.top||t.left-e.left}function Tr(t,e,n){var r=t.display,i=t.doc,o=document.createDocumentFragment(),a=Cn(t.display),s=a.left,c=Math.max(r.sizerWidth,wn(t)-r.sizer.offsetLeft)-a.right,l="ltr"==i.direction;function u(t,e,n,r){e<0&&(e=0),e=Math.round(e),r=Math.round(r),o.appendChild(L("div",null,"CodeMirror-selected","position: absolute; left: "+t+"px;\n top: "+e+"px; width: "+(null==n?c-t:n)+"px;\n height: "+(r-e)+"px"))}function h(e,n,r){var o,a,h=Kt(i,e),f=h.text.length;function p(n,r){return Kn(t,te(e,n),"div",h,r)}function d(e,n,r){var i=Qn(t,h,null,e),o="ltr"==n==("after"==r)?"left":"right";return p("after"==r?i.begin:i.end-(/\s/.test(h.text.charAt(i.end-1))?2:1),o)[o]}var m=lt(h,i.direction);return function(t,e,n,r){if(!t)return r(e,n,"ltr",0);for(var i=!1,o=0;o<t.length;++o){var a=t[o];(a.from<n&&a.to>e||e==n&&a.to==e)&&(r(Math.max(a.from,e),Math.min(a.to,n),1==a.level?"rtl":"ltr",o),i=!0)}i||r(e,n,"ltr")}(m,n||0,null==r?f:r,(function(t,e,i,h){var g="ltr"==i,v=p(t,g?"left":"right"),y=p(e-1,g?"right":"left"),b=null==n&&0==t,T=null==r&&e==f,O=0==h,S=!m||h==m.length-1;if(y.top-v.top<=3){var x=(l?T:b)&&S,E=(l?b:T)&&O?s:(g?v:y).left,C=x?c:(g?y:v).right;u(E,v.top,C-E,v.bottom)}else{var k,w,N,L;g?(k=l&&b&&O?s:v.left,w=l?c:d(t,i,"before"),N=l?s:d(e,i,"after"),L=l&&T&&S?c:y.right):(k=l?d(t,i,"before"):s,w=!l&&b&&O?c:v.right,N=!l&&T&&S?s:y.left,L=l?d(e,i,"after"):c),u(k,v.top,w-k,v.bottom),v.bottom<y.top&&u(s,v.bottom,null,y.top),u(N,y.top,L-N,y.bottom)}(!o||br(v,o)<0)&&(o=v),br(y,o)<0&&(o=y),(!a||br(v,a)<0)&&(a=v),br(y,a)<0&&(a=y)})),{start:o,end:a}}var f=e.from(),p=e.to();if(f.line==p.line)h(f.line,f.ch,p.ch);else{var d=Kt(i,f.line),m=Kt(i,p.line),g=Fe(d)==Fe(m),v=h(f.line,f.ch,g?d.text.length+1:null).end,y=h(p.line,g?0:null,p.ch).start;g&&(v.top<y.top-2?(u(v.right,v.top,null,v.bottom),u(s,y.top,y.left,y.bottom)):u(v.right,v.top,y.left-v.right,v.bottom)),v.bottom<y.top&&u(s,v.bottom,null,y.top)}n.appendChild(o)}function Or(t){if(t.state.focused){var e=t.display;clearInterval(e.blinker);var n=!0;e.cursorDiv.style.visibility="",t.options.cursorBlinkRate>0?e.blinker=setInterval((function(){t.hasFocus()||Cr(t),e.cursorDiv.style.visibility=(n=!n)?"":"hidden"}),t.options.cursorBlinkRate):t.options.cursorBlinkRate<0&&(e.cursorDiv.style.visibility="hidden")}}function Sr(t){t.state.focused||(t.display.input.focus(),Er(t))}function xr(t){t.state.delayingBlurEvent=!0,setTimeout((function(){t.state.delayingBlurEvent&&(t.state.delayingBlurEvent=!1,Cr(t))}),100)}function Er(t,e){t.state.delayingBlurEvent&&(t.state.delayingBlurEvent=!1),"nocursor"!=t.options.readOnly&&(t.state.focused||(dt(t,"focus",t,e),t.state.focused=!0,M(t.display.wrapper,"CodeMirror-focused"),t.curOp||t.display.selForContextMenu==t.doc.sel||(t.display.input.reset(),c&&setTimeout((function(){return t.display.input.reset(!0)}),20)),t.display.input.receivedFocus()),Or(t))}function Cr(t,e){t.state.delayingBlurEvent||(t.state.focused&&(dt(t,"blur",t,e),t.state.focused=!1,k(t.display.wrapper,"CodeMirror-focused")),clearInterval(t.display.blinker),setTimeout((function(){t.state.focused||(t.display.shift=!1)}),150))}function kr(t){for(var e=t.display,n=e.lineDiv.offsetTop,r=0;r<e.view.length;r++){var i=e.view[r],o=t.options.lineWrapping,c=void 0,l=0;if(!i.hidden){if(a&&s<8){var u=i.node.offsetTop+i.node.offsetHeight;c=u-n,n=u}else{var h=i.node.getBoundingClientRect();c=h.bottom-h.top,!o&&i.text.firstChild&&(l=i.text.firstChild.getBoundingClientRect().right-h.left-1)}var f=i.line.height-c;if((f>.005||f<-.005)&&($t(i.line,c),wr(i.line),i.rest))for(var p=0;p<i.rest.length;p++)wr(i.rest[p]);if(l>t.display.sizerWidth){var d=Math.ceil(l/ir(t.display));d>t.display.maxLineLength&&(t.display.maxLineLength=d,t.display.maxLine=i.line,t.display.maxLineChanged=!0)}}}}function wr(t){if(t.widgets)for(var e=0;e<t.widgets.length;++e){var n=t.widgets[e],r=n.node.parentNode;r&&(n.height=r.offsetHeight)}}function Nr(t,e,n){var r=n&&null!=n.top?Math.max(0,n.top):t.scroller.scrollTop;r=Math.floor(r-xn(t));var i=n&&null!=n.bottom?n.bottom:r+t.wrapper.clientHeight,o=Zt(e,r),a=Zt(e,i);if(n&&n.ensure){var s=n.ensure.from.line,c=n.ensure.to.line;s<o?(o=s,a=Zt(e,Ge(Kt(e,s))+t.wrapper.clientHeight)):Math.min(c,e.lastLine())>=a&&(o=Zt(e,Ge(Kt(e,c))-t.wrapper.clientHeight),a=c)}return{from:o,to:Math.max(a,o+1)}}function Lr(t,e){var n=t.display,r=rr(t.display);e.top<0&&(e.top=0);var i=t.curOp&&null!=t.curOp.scrollTop?t.curOp.scrollTop:n.scroller.scrollTop,o=Nn(t),a={};e.bottom-e.top>o&&(e.bottom=e.top+o);var s=t.doc.height+En(n),c=e.top<r,l=e.bottom>s-r;if(e.top<i)a.scrollTop=c?0:e.top;else if(e.bottom>i+o){var u=Math.min(e.top,(l?s:e.bottom)-o);u!=i&&(a.scrollTop=u)}var h=t.options.fixedGutter?0:n.gutters.offsetWidth,f=t.curOp&&null!=t.curOp.scrollLeft?t.curOp.scrollLeft:n.scroller.scrollLeft-h,p=wn(t)-n.gutters.offsetWidth,d=e.right-e.left>p;return d&&(e.right=e.left+p),e.left<10?a.scrollLeft=0:e.left<f?a.scrollLeft=Math.max(0,e.left+h-(d?0:10)):e.right>p+f-3&&(a.scrollLeft=e.right+(d?0:10)-p),a}function Ar(t,e){null!=e&&(Mr(t),t.curOp.scrollTop=(null==t.curOp.scrollTop?t.doc.scrollTop:t.curOp.scrollTop)+e)}function Ir(t){Mr(t);var e=t.getCursor();t.curOp.scrollToPos={from:e,to:e,margin:t.options.cursorScrollMargin}}function Rr(t,e,n){null==e&&null==n||Mr(t),null!=e&&(t.curOp.scrollLeft=e),null!=n&&(t.curOp.scrollTop=n)}function Mr(t){var e=t.curOp.scrollToPos;e&&(t.curOp.scrollToPos=null,_r(t,Xn(t,e.from),Xn(t,e.to),e.margin))}function _r(t,e,n,r){var i=Lr(t,{left:Math.min(e.left,n.left),top:Math.min(e.top,n.top)-r,right:Math.max(e.right,n.right),bottom:Math.max(e.bottom,n.bottom)+r});Rr(t,i.scrollLeft,i.scrollTop)}function Pr(t,e){Math.abs(t.doc.scrollTop-e)<2||(n||ci(t,{top:e}),jr(t,e,!0),n&&ci(t),ri(t,100))}function jr(t,e,n){e=Math.max(0,Math.min(t.display.scroller.scrollHeight-t.display.scroller.clientHeight,e)),(t.display.scroller.scrollTop!=e||n)&&(t.doc.scrollTop=e,t.display.scrollbars.setScrollTop(e),t.display.scroller.scrollTop!=e&&(t.display.scroller.scrollTop=e))}function Dr(t,e,n,r){e=Math.max(0,Math.min(e,t.display.scroller.scrollWidth-t.display.scroller.clientWidth)),(n?e==t.doc.scrollLeft:Math.abs(t.doc.scrollLeft-e)<2)&&!r||(t.doc.scrollLeft=e,hi(t),t.display.scroller.scrollLeft!=e&&(t.display.scroller.scrollLeft=e),t.display.scrollbars.setScrollLeft(e))}function Fr(t){var e=t.display,n=e.gutters.offsetWidth,r=Math.round(t.doc.height+En(t.display));return{clientHeight:e.scroller.clientHeight,viewHeight:e.wrapper.clientHeight,scrollWidth:e.scroller.scrollWidth,clientWidth:e.scroller.clientWidth,viewWidth:e.wrapper.clientWidth,barLeft:t.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+kn(t)+e.barHeight,nativeBarWidth:e.nativeBarWidth,gutterWidth:n}}var Ur=function(t,e,n){this.cm=n;var r=this.vert=L("div",[L("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=L("div",[L("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=i.tabIndex=-1,t(r),t(i),ht(r,"scroll",(function(){r.clientHeight&&e(r.scrollTop,"vertical")})),ht(i,"scroll",(function(){i.clientWidth&&e(i.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,a&&s<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Ur.prototype.update=function(t){var e=t.scrollWidth>t.clientWidth+1,n=t.scrollHeight>t.clientHeight+1,r=t.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=e?r+"px":"0";var i=t.viewHeight-(e?r:0);this.vert.firstChild.style.height=Math.max(0,t.scrollHeight-t.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(e){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=t.barLeft+"px";var o=t.viewWidth-t.barLeft-(n?r:0);this.horiz.firstChild.style.width=Math.max(0,t.scrollWidth-t.clientWidth+o)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&t.clientHeight>0&&(0==r&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?r:0,bottom:e?r:0}},Ur.prototype.setScrollLeft=function(t){this.horiz.scrollLeft!=t&&(this.horiz.scrollLeft=t),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Ur.prototype.setScrollTop=function(t){this.vert.scrollTop!=t&&(this.vert.scrollTop=t),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Ur.prototype.zeroWidthHack=function(){var t=y&&!p?"12px":"18px";this.horiz.style.height=this.vert.style.width=t,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new U,this.disableVert=new U},Ur.prototype.enableZeroWidthBar=function(t,e,n){t.style.pointerEvents="auto",e.set(1e3,(function r(){var i=t.getBoundingClientRect();("vert"==n?document.elementFromPoint(i.right-1,(i.top+i.bottom)/2):document.elementFromPoint((i.right+i.left)/2,i.bottom-1))!=t?t.style.pointerEvents="none":e.set(1e3,r)}))},Ur.prototype.clear=function(){var t=this.horiz.parentNode;t.removeChild(this.horiz),t.removeChild(this.vert)};var Wr=function(){};function Br(t,e){e||(e=Fr(t));var n=t.display.barWidth,r=t.display.barHeight;Hr(t,e);for(var i=0;i<4&&n!=t.display.barWidth||r!=t.display.barHeight;i++)n!=t.display.barWidth&&t.options.lineWrapping&&kr(t),Hr(t,Fr(t)),n=t.display.barWidth,r=t.display.barHeight}function Hr(t,e){var n=t.display,r=n.scrollbars.update(e);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&t.options.coverGutterNextToScrollbar&&t.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=e.gutterWidth+"px"):n.gutterFiller.style.display=""}Wr.prototype.update=function(){return{bottom:0,right:0}},Wr.prototype.setScrollLeft=function(){},Wr.prototype.setScrollTop=function(){},Wr.prototype.clear=function(){};var Gr={native:Ur,null:Wr};function zr(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&k(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new Gr[t.options.scrollbarStyle]((function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),ht(e,"mousedown",(function(){t.state.focused&&setTimeout((function(){return t.display.input.focus()}),0)})),e.setAttribute("cm-not-content","true")}),(function(e,n){"horizontal"==n?Dr(t,e):Pr(t,e)}),t),t.display.scrollbars.addClass&&M(t.display.wrapper,t.display.scrollbars.addClass)}var Vr=0;function Kr(t){var e;t.curOp={cm:t,viewChanged:!1,startHeight:t.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Vr},e=t.curOp,an?an.ops.push(e):e.ownsGroup=an={ops:[e],delayedCallbacks:[]}}function Yr(t){var e=t.curOp;e&&function(t,e){var n=t.ownsGroup;if(n)try{!function(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)}(n)}finally{an=null,e(n)}}(e,(function(t){for(var e=0;e<t.ops.length;e++)t.ops[e].cm.curOp=null;!function(t){for(var e=t.ops,n=0;n<e.length;n++)Xr(e[n]);for(var r=0;r<e.length;r++)$r(e[r]);for(var i=0;i<e.length;i++)qr(e[i]);for(var o=0;o<e.length;o++)Zr(e[o]);for(var a=0;a<e.length;a++)Qr(e[a])}(t)}))}function Xr(t){var e=t.cm,n=e.display;!function(t){var e=t.display;!e.scrollbarsClipped&&e.scroller.offsetWidth&&(e.nativeBarWidth=e.scroller.offsetWidth-e.scroller.clientWidth,e.heightForcer.style.height=kn(t)+"px",e.sizer.style.marginBottom=-e.nativeBarWidth+"px",e.sizer.style.borderRightWidth=kn(t)+"px",e.scrollbarsClipped=!0)}(e),t.updateMaxLine&&Ve(e),t.mustUpdate=t.viewChanged||t.forceUpdate||null!=t.scrollTop||t.scrollToPos&&(t.scrollToPos.from.line<n.viewFrom||t.scrollToPos.to.line>=n.viewTo)||n.maxLineChanged&&e.options.lineWrapping,t.update=t.mustUpdate&&new oi(e,t.mustUpdate&&{top:t.scrollTop,ensure:t.scrollToPos},t.forceUpdate)}function $r(t){t.updatedDisplay=t.mustUpdate&&ai(t.cm,t.update)}function qr(t){var e=t.cm,n=e.display;t.updatedDisplay&&kr(e),t.barMeasure=Fr(e),n.maxLineChanged&&!e.options.lineWrapping&&(t.adjustWidthTo=An(e,n.maxLine,n.maxLine.text.length).left+3,e.display.sizerWidth=t.adjustWidthTo,t.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+t.adjustWidthTo+kn(e)+e.display.barWidth),t.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+t.adjustWidthTo-wn(e))),(t.updatedDisplay||t.selectionChanged)&&(t.preparedSelection=n.input.prepareSelection())}function Zr(t){var e=t.cm;null!=t.adjustWidthTo&&(e.display.sizer.style.minWidth=t.adjustWidthTo+"px",t.maxScrollLeft<e.doc.scrollLeft&&Dr(e,Math.min(e.display.scroller.scrollLeft,t.maxScrollLeft),!0),e.display.maxLineChanged=!1);var n=t.focus&&t.focus==R();t.preparedSelection&&e.display.input.showSelection(t.preparedSelection,n),(t.updatedDisplay||t.startHeight!=e.doc.height)&&Br(e,t.barMeasure),t.updatedDisplay&&ui(e,t.barMeasure),t.selectionChanged&&Or(e),e.state.focused&&t.updateInput&&e.display.input.reset(t.typing),n&&Sr(t.cm)}function Qr(t){var e=t.cm,n=e.display,r=e.doc;t.updatedDisplay&&si(e,t.update),null==n.wheelStartX||null==t.scrollTop&&null==t.scrollLeft&&!t.scrollToPos||(n.wheelStartX=n.wheelStartY=null),null!=t.scrollTop&&jr(e,t.scrollTop,t.forceScroll),null!=t.scrollLeft&&Dr(e,t.scrollLeft,!0,!0),t.scrollToPos&&function(t,e){if(!mt(t,"scrollCursorIntoView")){var n=t.display,r=n.sizer.getBoundingClientRect(),i=null;if(e.top+r.top<0?i=!0:e.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!d){var o=L("div","",null,"position: absolute;\n top: "+(e.top-n.viewOffset-xn(t.display))+"px;\n height: "+(e.bottom-e.top+kn(t)+n.barHeight)+"px;\n left: "+e.left+"px; width: "+Math.max(2,e.right-e.left)+"px;");t.display.lineSpace.appendChild(o),o.scrollIntoView(i),t.display.lineSpace.removeChild(o)}}}(e,function(t,e,n,r){var i;null==r&&(r=0),t.options.lineWrapping||e!=n||(n="before"==(e=e.ch?te(e.line,"before"==e.sticky?e.ch-1:e.ch,"after"):e).sticky?te(e.line,e.ch+1,"before"):e);for(var o=0;o<5;o++){var a=!1,s=Yn(t,e),c=n&&n!=e?Yn(t,n):s,l=Lr(t,i={left:Math.min(s.left,c.left),top:Math.min(s.top,c.top)-r,right:Math.max(s.left,c.left),bottom:Math.max(s.bottom,c.bottom)+r}),u=t.doc.scrollTop,h=t.doc.scrollLeft;if(null!=l.scrollTop&&(Pr(t,l.scrollTop),Math.abs(t.doc.scrollTop-u)>1&&(a=!0)),null!=l.scrollLeft&&(Dr(t,l.scrollLeft),Math.abs(t.doc.scrollLeft-h)>1&&(a=!0)),!a)break}return i}(e,se(r,t.scrollToPos.from),se(r,t.scrollToPos.to),t.scrollToPos.margin));var i=t.maybeHiddenMarkers,o=t.maybeUnhiddenMarkers;if(i)for(var a=0;a<i.length;++a)i[a].lines.length||dt(i[a],"hide");if(o)for(var s=0;s<o.length;++s)o[s].lines.length&&dt(o[s],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=e.display.scroller.scrollTop),t.changeObjs&&dt(e,"changes",e,t.changeObjs),t.update&&t.update.finish()}function Jr(t,e){if(t.curOp)return e();Kr(t);try{return e()}finally{Yr(t)}}function ti(t,e){return function(){if(t.curOp)return e.apply(t,arguments);Kr(t);try{return e.apply(t,arguments)}finally{Yr(t)}}}function ei(t){return function(){if(this.curOp)return t.apply(this,arguments);Kr(this);try{return t.apply(this,arguments)}finally{Yr(this)}}}function ni(t){return function(){var e=this.cm;if(!e||e.curOp)return t.apply(this,arguments);Kr(e);try{return t.apply(this,arguments)}finally{Yr(e)}}}function ri(t,e){t.doc.highlightFrontier<t.display.viewTo&&t.state.highlight.set(e,j(ii,t))}function ii(t){var e=t.doc;if(!(e.highlightFrontier>=t.display.viewTo)){var n=+new Date+t.options.workTime,r=pe(t,e.highlightFrontier),i=[];e.iter(r.line,Math.min(e.first+e.size,t.display.viewTo+500),(function(o){if(r.line>=t.display.viewFrom){var a=o.styles,s=o.text.length>t.options.maxHighlightLength?Ht(e.mode,r.state):null,c=he(t,o,r,!0);s&&(r.state=s),o.styles=c.styles;var l=o.styleClasses,u=c.classes;u?o.styleClasses=u:l&&(o.styleClasses=null);for(var h=!a||a.length!=o.styles.length||l!=u&&(!l||!u||l.bgClass!=u.bgClass||l.textClass!=u.textClass),f=0;!h&&f<a.length;++f)h=a[f]!=o.styles[f];h&&i.push(r.line),o.stateAfter=r.save(),r.nextLine()}else o.text.length<=t.options.maxHighlightLength&&de(t,o.text,r),o.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>n)return ri(t,t.options.workDelay),!0})),e.highlightFrontier=r.line,e.modeFrontier=Math.max(e.modeFrontier,r.line),i.length&&Jr(t,(function(){for(var e=0;e<i.length;e++)fr(t,i[e],"text")}))}}var oi=function(t,e,n){var r=t.display;this.viewport=e,this.visible=Nr(r,t.doc,e),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=wn(t),this.force=n,this.dims=or(t),this.events=[]};function ai(t,e){var n=t.display,r=t.doc;if(e.editorIsHidden)return pr(t),!1;if(!e.force&&e.visible.from>=n.viewFrom&&e.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==mr(t))return!1;fi(t)&&(pr(t),e.dims=or(t));var i=r.first+r.size,o=Math.max(e.visible.from-t.options.viewportMargin,r.first),a=Math.min(i,e.visible.to+t.options.viewportMargin);n.viewFrom<o&&o-n.viewFrom<20&&(o=Math.max(r.first,n.viewFrom)),n.viewTo>a&&n.viewTo-a<20&&(a=Math.min(i,n.viewTo)),Se&&(o=Ue(t.doc,o),a=We(t.doc,a));var s=o!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=e.wrapperHeight||n.lastWrapWidth!=e.wrapperWidth;!function(t,e,n){var r=t.display;0==r.view.length||e>=r.viewTo||n<=r.viewFrom?(r.view=on(t,e,n),r.viewFrom=e):(r.viewFrom>e?r.view=on(t,e,r.viewFrom).concat(r.view):r.viewFrom<e&&(r.view=r.view.slice(ur(t,e))),r.viewFrom=e,r.viewTo<n?r.view=r.view.concat(on(t,r.viewTo,n)):r.viewTo>n&&(r.view=r.view.slice(0,ur(t,n)))),r.viewTo=n}(t,o,a),n.viewOffset=Ge(Kt(t.doc,n.viewFrom)),t.display.mover.style.top=n.viewOffset+"px";var l=mr(t);if(!s&&0==l&&!e.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var u=function(t){if(t.hasFocus())return null;var e=R();if(!e||!I(t.display.lineDiv,e))return null;var n={activeElt:e};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&I(t.display.lineDiv,r.anchorNode)&&(n.anchorNode=r.anchorNode,n.anchorOffset=r.anchorOffset,n.focusNode=r.focusNode,n.focusOffset=r.focusOffset)}return n}(t);return l>4&&(n.lineDiv.style.display="none"),function(t,e,n){var r=t.display,i=t.options.lineNumbers,o=r.lineDiv,a=o.firstChild;function s(e){var n=e.nextSibling;return c&&y&&t.display.currentWheelTarget==e?e.style.display="none":e.parentNode.removeChild(e),n}for(var l=r.view,u=r.viewFrom,h=0;h<l.length;h++){var f=l[h];if(f.hidden);else if(f.node&&f.node.parentNode==o){for(;a!=f.node;)a=s(a);var p=i&&null!=e&&e<=u&&f.lineNumber;f.changes&&(W(f.changes,"gutter")>-1&&(p=!1),un(t,f,u,n)),p&&(w(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(Jt(t.options,u)))),a=f.node.nextSibling}else{var d=vn(t,f,u,n);o.insertBefore(d,a)}u+=f.size}for(;a;)a=s(a)}(t,n.updateLineNumbers,e.dims),l>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,function(t){if(t&&t.activeElt&&t.activeElt!=R()&&(t.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(t.activeElt.nodeName)&&t.anchorNode&&I(document.body,t.anchorNode)&&I(document.body,t.focusNode))){var e=window.getSelection(),n=document.createRange();n.setEnd(t.anchorNode,t.anchorOffset),n.collapse(!1),e.removeAllRanges(),e.addRange(n),e.extend(t.focusNode,t.focusOffset)}}(u),w(n.cursorDiv),w(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,s&&(n.lastWrapHeight=e.wrapperHeight,n.lastWrapWidth=e.wrapperWidth,ri(t,400)),n.updateLineNumbers=null,!0}function si(t,e){for(var n=e.viewport,r=!0;;r=!1){if(r&&t.options.lineWrapping&&e.oldDisplayWidth!=wn(t))r&&(e.visible=Nr(t.display,t.doc,n));else if(n&&null!=n.top&&(n={top:Math.min(t.doc.height+En(t.display)-Nn(t),n.top)}),e.visible=Nr(t.display,t.doc,n),e.visible.from>=t.display.viewFrom&&e.visible.to<=t.display.viewTo)break;if(!ai(t,e))break;kr(t);var i=Fr(t);gr(t),Br(t,i),ui(t,i),e.force=!1}e.signal(t,"update",t),t.display.viewFrom==t.display.reportedViewFrom&&t.display.viewTo==t.display.reportedViewTo||(e.signal(t,"viewportChange",t,t.display.viewFrom,t.display.viewTo),t.display.reportedViewFrom=t.display.viewFrom,t.display.reportedViewTo=t.display.viewTo)}function ci(t,e){var n=new oi(t,e);if(ai(t,n)){kr(t),si(t,n);var r=Fr(t);gr(t),Br(t,r),ui(t,r),n.finish()}}function li(t){var e=t.gutters.offsetWidth;t.sizer.style.marginLeft=e+"px"}function ui(t,e){t.display.sizer.style.minHeight=e.docHeight+"px",t.display.heightForcer.style.top=e.docHeight+"px",t.display.gutters.style.height=e.docHeight+t.display.barHeight+kn(t)+"px"}function hi(t){var e=t.display,n=e.view;if(e.alignWidgets||e.gutters.firstChild&&t.options.fixedGutter){for(var r=ar(e)-e.scroller.scrollLeft+t.doc.scrollLeft,i=e.gutters.offsetWidth,o=r+"px",a=0;a<n.length;a++)if(!n[a].hidden){t.options.fixedGutter&&(n[a].gutter&&(n[a].gutter.style.left=o),n[a].gutterBackground&&(n[a].gutterBackground.style.left=o));var s=n[a].alignable;if(s)for(var c=0;c<s.length;c++)s[c].style.left=o}t.options.fixedGutter&&(e.gutters.style.left=r+i+"px")}}function fi(t){if(!t.options.lineNumbers)return!1;var e=t.doc,n=Jt(t.options,e.first+e.size-1),r=t.display;if(n.length!=r.lineNumChars){var i=r.measure.appendChild(L("div",[L("div",n)],"CodeMirror-linenumber CodeMirror-gutter-elt")),o=i.firstChild.offsetWidth,a=i.offsetWidth-o;return r.lineGutter.style.width="",r.lineNumInnerWidth=Math.max(o,r.lineGutter.offsetWidth-a)+1,r.lineNumWidth=r.lineNumInnerWidth+a,r.lineNumChars=r.lineNumInnerWidth?n.length:-1,r.lineGutter.style.width=r.lineNumWidth+"px",li(t.display),!0}return!1}function pi(t,e){for(var n=[],r=!1,i=0;i<t.length;i++){var o=t[i],a=null;if("string"!=typeof o&&(a=o.style,o=o.className),"CodeMirror-linenumbers"==o){if(!e)continue;r=!0}n.push({className:o,style:a})}return e&&!r&&n.push({className:"CodeMirror-linenumbers",style:null}),n}function di(t){var e=t.gutters,n=t.gutterSpecs;w(e),t.lineGutter=null;for(var r=0;r<n.length;++r){var i=n[r],o=i.className,a=i.style,s=e.appendChild(L("div",null,"CodeMirror-gutter "+o));a&&(s.style.cssText=a),"CodeMirror-linenumbers"==o&&(t.lineGutter=s,s.style.width=(t.lineNumWidth||1)+"px")}e.style.display=n.length?"":"none",li(t)}function mi(t){di(t.display),hr(t),hi(t)}function gi(t,e,r,i){var o=this;this.input=r,o.scrollbarFiller=L("div",null,"CodeMirror-scrollbar-filler"),o.scrollbarFiller.setAttribute("cm-not-content","true"),o.gutterFiller=L("div",null,"CodeMirror-gutter-filler"),o.gutterFiller.setAttribute("cm-not-content","true"),o.lineDiv=A("div",null,"CodeMirror-code"),o.selectionDiv=L("div",null,null,"position: relative; z-index: 1"),o.cursorDiv=L("div",null,"CodeMirror-cursors"),o.measure=L("div",null,"CodeMirror-measure"),o.lineMeasure=L("div",null,"CodeMirror-measure"),o.lineSpace=A("div",[o.measure,o.lineMeasure,o.selectionDiv,o.cursorDiv,o.lineDiv],null,"position: relative; outline: none");var l=A("div",[o.lineSpace],"CodeMirror-lines");o.mover=L("div",[l],null,"position: relative"),o.sizer=L("div",[o.mover],"CodeMirror-sizer"),o.sizerWidth=null,o.heightForcer=L("div",null,null,"position: absolute; height: 50px; width: 1px;"),o.gutters=L("div",null,"CodeMirror-gutters"),o.lineGutter=null,o.scroller=L("div",[o.sizer,o.heightForcer,o.gutters],"CodeMirror-scroll"),o.scroller.setAttribute("tabIndex","-1"),o.wrapper=L("div",[o.scrollbarFiller,o.gutterFiller,o.scroller],"CodeMirror"),a&&s<8&&(o.gutters.style.zIndex=-1,o.scroller.style.paddingRight=0),c||n&&v||(o.scroller.draggable=!0),t&&(t.appendChild?t.appendChild(o.wrapper):t(o.wrapper)),o.viewFrom=o.viewTo=e.first,o.reportedViewFrom=o.reportedViewTo=e.first,o.view=[],o.renderedView=null,o.externalMeasured=null,o.viewOffset=0,o.lastWrapHeight=o.lastWrapWidth=0,o.updateLineNumbers=null,o.nativeBarWidth=o.barHeight=o.barWidth=0,o.scrollbarsClipped=!1,o.lineNumWidth=o.lineNumInnerWidth=o.lineNumChars=null,o.alignWidgets=!1,o.cachedCharWidth=o.cachedTextHeight=o.cachedPaddingH=null,o.maxLine=null,o.maxLineLength=0,o.maxLineChanged=!1,o.wheelDX=o.wheelDY=o.wheelStartX=o.wheelStartY=null,o.shift=!1,o.selForContextMenu=null,o.activeTouch=null,o.gutterSpecs=pi(i.gutters,i.lineNumbers),di(o),r.init(o)}oi.prototype.signal=function(t,e){vt(t,e)&&this.events.push(arguments)},oi.prototype.finish=function(){for(var t=0;t<this.events.length;t++)dt.apply(null,this.events[t])};var vi=0,yi=null;function bi(t){var e=t.wheelDeltaX,n=t.wheelDeltaY;return null==e&&t.detail&&t.axis==t.HORIZONTAL_AXIS&&(e=t.detail),null==n&&t.detail&&t.axis==t.VERTICAL_AXIS?n=t.detail:null==n&&(n=t.wheelDelta),{x:e,y:n}}function Ti(t){var e=bi(t);return e.x*=yi,e.y*=yi,e}function Oi(t,e){var r=bi(e),i=r.x,o=r.y,a=t.display,s=a.scroller,l=s.scrollWidth>s.clientWidth,u=s.scrollHeight>s.clientHeight;if(i&&l||o&&u){if(o&&y&&c)t:for(var f=e.target,p=a.view;f!=s;f=f.parentNode)for(var d=0;d<p.length;d++)if(p[d].node==f){t.display.currentWheelTarget=f;break t}if(i&&!n&&!h&&null!=yi)return o&&u&&Pr(t,Math.max(0,s.scrollTop+o*yi)),Dr(t,Math.max(0,s.scrollLeft+i*yi)),(!o||o&&u)&&bt(e),void(a.wheelStartX=null);if(o&&null!=yi){var m=o*yi,g=t.doc.scrollTop,v=g+a.wrapper.clientHeight;m<0?g=Math.max(0,g+m-50):v=Math.min(t.doc.height,v+m+50),ci(t,{top:g,bottom:v})}vi<20&&(null==a.wheelStartX?(a.wheelStartX=s.scrollLeft,a.wheelStartY=s.scrollTop,a.wheelDX=i,a.wheelDY=o,setTimeout((function(){if(null!=a.wheelStartX){var t=s.scrollLeft-a.wheelStartX,e=s.scrollTop-a.wheelStartY,n=e&&a.wheelDY&&e/a.wheelDY||t&&a.wheelDX&&t/a.wheelDX;a.wheelStartX=a.wheelStartY=null,n&&(yi=(yi*vi+n)/(vi+1),++vi)}}),200)):(a.wheelDX+=i,a.wheelDY+=o))}}a?yi=-.53:n?yi=15:u?yi=-.7:f&&(yi=-1/3);var Si=function(t,e){this.ranges=t,this.primIndex=e};Si.prototype.primary=function(){return this.ranges[this.primIndex]},Si.prototype.equals=function(t){if(t==this)return!0;if(t.primIndex!=this.primIndex||t.ranges.length!=this.ranges.length)return!1;for(var e=0;e<this.ranges.length;e++){var n=this.ranges[e],r=t.ranges[e];if(!ne(n.anchor,r.anchor)||!ne(n.head,r.head))return!1}return!0},Si.prototype.deepCopy=function(){for(var t=[],e=0;e<this.ranges.length;e++)t[e]=new xi(re(this.ranges[e].anchor),re(this.ranges[e].head));return new Si(t,this.primIndex)},Si.prototype.somethingSelected=function(){for(var t=0;t<this.ranges.length;t++)if(!this.ranges[t].empty())return!0;return!1},Si.prototype.contains=function(t,e){e||(e=t);for(var n=0;n<this.ranges.length;n++){var r=this.ranges[n];if(ee(e,r.from())>=0&&ee(t,r.to())<=0)return n}return-1};var xi=function(t,e){this.anchor=t,this.head=e};function Ei(t,e,n){var r=t&&t.options.selectionsMayTouch,i=e[n];e.sort((function(t,e){return ee(t.from(),e.from())})),n=W(e,i);for(var o=1;o<e.length;o++){var a=e[o],s=e[o-1],c=ee(s.to(),a.from());if(r&&!a.empty()?c>0:c>=0){var l=oe(s.from(),a.from()),u=ie(s.to(),a.to()),h=s.empty()?a.from()==a.head:s.from()==s.head;o<=n&&--n,e.splice(--o,2,new xi(h?u:l,h?l:u))}}return new Si(e,n)}function Ci(t,e){return new Si([new xi(t,e||t)],0)}function ki(t){return t.text?te(t.from.line+t.text.length-1,X(t.text).length+(1==t.text.length?t.from.ch:0)):t.to}function wi(t,e){if(ee(t,e.from)<0)return t;if(ee(t,e.to)<=0)return ki(e);var n=t.line+e.text.length-(e.to.line-e.from.line)-1,r=t.ch;return t.line==e.to.line&&(r+=ki(e).ch-e.to.ch),te(n,r)}function Ni(t,e){for(var n=[],r=0;r<t.sel.ranges.length;r++){var i=t.sel.ranges[r];n.push(new xi(wi(i.anchor,e),wi(i.head,e)))}return Ei(t.cm,n,t.sel.primIndex)}function Li(t,e,n){return t.line==e.line?te(n.line,t.ch-e.ch+n.ch):te(n.line+(t.line-e.line),t.ch)}function Ai(t){t.doc.mode=Ut(t.options,t.doc.modeOption),Ii(t)}function Ii(t){t.doc.iter((function(t){t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null)})),t.doc.modeFrontier=t.doc.highlightFrontier=t.doc.first,ri(t,100),t.state.modeGen++,t.curOp&&hr(t)}function Ri(t,e){return 0==e.from.ch&&0==e.to.ch&&""==X(e.text)&&(!t.cm||t.cm.options.wholeLineUpdateBefore)}function Mi(t,e,n,r){function i(t){return n?n[t]:null}function o(t,n,i){!function(t,e,n,r){t.text=e,t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null),null!=t.order&&(t.order=null),Ne(t),Le(t,n);var i=r?r(t):1;i!=t.height&&$t(t,i)}(t,n,i,r),cn(t,"change",t,e)}function a(t,e){for(var n=[],o=t;o<e;++o)n.push(new Ke(l[o],i(o),r));return n}var s=e.from,c=e.to,l=e.text,u=Kt(t,s.line),h=Kt(t,c.line),f=X(l),p=i(l.length-1),d=c.line-s.line;if(e.full)t.insert(0,a(0,l.length)),t.remove(l.length,t.size-l.length);else if(Ri(t,e)){var m=a(0,l.length-1);o(h,h.text,p),d&&t.remove(s.line,d),m.length&&t.insert(s.line,m)}else if(u==h)if(1==l.length)o(u,u.text.slice(0,s.ch)+f+u.text.slice(c.ch),p);else{var g=a(1,l.length-1);g.push(new Ke(f+u.text.slice(c.ch),p,r)),o(u,u.text.slice(0,s.ch)+l[0],i(0)),t.insert(s.line+1,g)}else if(1==l.length)o(u,u.text.slice(0,s.ch)+l[0]+h.text.slice(c.ch),i(0)),t.remove(s.line+1,d);else{o(u,u.text.slice(0,s.ch)+l[0],i(0)),o(h,f+h.text.slice(c.ch),p);var v=a(1,l.length-1);d>1&&t.remove(s.line+1,d-1),t.insert(s.line+1,v)}cn(t,"change",t,e)}function _i(t,e,n){!function t(r,i,o){if(r.linked)for(var a=0;a<r.linked.length;++a){var s=r.linked[a];if(s.doc!=i){var c=o&&s.sharedHist;n&&!c||(e(s.doc,c),t(s.doc,r,c))}}}(t,null,!0)}function Pi(t,e){if(e.cm)throw new Error("This document is already in use.");t.doc=e,e.cm=t,cr(t),Ai(t),ji(t),t.options.lineWrapping||Ve(t),t.options.mode=e.modeOption,hr(t)}function ji(t){("rtl"==t.doc.direction?M:k)(t.display.lineDiv,"CodeMirror-rtl")}function Di(t){this.done=[],this.undone=[],this.undoDepth=1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=t||1}function Fi(t,e){var n={from:re(e.from),to:ki(e),text:Yt(t,e.from,e.to)};return Gi(t,n,e.from.line,e.to.line+1),_i(t,(function(t){return Gi(t,n,e.from.line,e.to.line+1)}),!0),n}function Ui(t){for(;t.length&&X(t).ranges;)t.pop()}function Wi(t,e,n,r){var i=t.history;i.undone.length=0;var o,a,s=+new Date;if((i.lastOp==r||i.lastOrigin==e.origin&&e.origin&&("+"==e.origin.charAt(0)&&i.lastModTime>s-(t.cm?t.cm.options.historyEventDelay:500)||"*"==e.origin.charAt(0)))&&(o=function(t,e){return e?(Ui(t.done),X(t.done)):t.done.length&&!X(t.done).ranges?X(t.done):t.done.length>1&&!t.done[t.done.length-2].ranges?(t.done.pop(),X(t.done)):void 0}(i,i.lastOp==r)))a=X(o.changes),0==ee(e.from,e.to)&&0==ee(e.from,a.to)?a.to=ki(e):o.changes.push(Fi(t,e));else{var c=X(i.done);for(c&&c.ranges||Hi(t.sel,i.done),o={changes:[Fi(t,e)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=s,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=e.origin,a||dt(t,"historyAdded")}function Bi(t,e,n,r){var i=t.history,o=r&&r.origin;n==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||function(t,e,n,r){var i=e.charAt(0);return"*"==i||"+"==i&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-t.history.lastSelTime<=(t.cm?t.cm.options.historyEventDelay:500)}(t,o,X(i.done),e))?i.done[i.done.length-1]=e:Hi(e,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=n,r&&!1!==r.clearRedo&&Ui(i.undone)}function Hi(t,e){var n=X(e);n&&n.ranges&&n.equals(t)||e.push(t)}function Gi(t,e,n,r){var i=e["spans_"+t.id],o=0;t.iter(Math.max(t.first,n),Math.min(t.first+t.size,r),(function(n){n.markedSpans&&((i||(i=e["spans_"+t.id]={}))[o]=n.markedSpans),++o}))}function zi(t){if(!t)return null;for(var e,n=0;n<t.length;++n)t[n].marker.explicitlyCleared?e||(e=t.slice(0,n)):e&&e.push(t[n]);return e?e.length?e:null:t}function Vi(t,e){var n=function(t,e){var n=e["spans_"+t.id];if(!n)return null;for(var r=[],i=0;i<e.text.length;++i)r.push(zi(n[i]));return r}(t,e),r=ke(t,e);if(!n)return r;if(!r)return n;for(var i=0;i<n.length;++i){var o=n[i],a=r[i];if(o&&a)t:for(var s=0;s<a.length;++s){for(var c=a[s],l=0;l<o.length;++l)if(o[l].marker==c.marker)continue t;o.push(c)}else a&&(n[i]=a)}return n}function Ki(t,e,n){for(var r=[],i=0;i<t.length;++i){var o=t[i];if(o.ranges)r.push(n?Si.prototype.deepCopy.call(o):o);else{var a=o.changes,s=[];r.push({changes:s});for(var c=0;c<a.length;++c){var l=a[c],u=void 0;if(s.push({from:l.from,to:l.to,text:l.text}),e)for(var h in l)(u=h.match(/^spans_(\d+)$/))&&W(e,Number(u[1]))>-1&&(X(s)[h]=l[h],delete l[h])}}}return r}function Yi(t,e,n,r){if(r){var i=t.anchor;if(n){var o=ee(e,i)<0;o!=ee(n,i)<0?(i=e,e=n):o!=ee(e,n)<0&&(e=n)}return new xi(i,e)}return new xi(n||e,e)}function Xi(t,e,n,r,i){null==i&&(i=t.cm&&(t.cm.display.shift||t.extend)),Ji(t,new Si([Yi(t.sel.primary(),e,n,i)],0),r)}function $i(t,e,n){for(var r=[],i=t.cm&&(t.cm.display.shift||t.extend),o=0;o<t.sel.ranges.length;o++)r[o]=Yi(t.sel.ranges[o],e[o],null,i);Ji(t,Ei(t.cm,r,t.sel.primIndex),n)}function qi(t,e,n,r){var i=t.sel.ranges.slice(0);i[e]=n,Ji(t,Ei(t.cm,i,t.sel.primIndex),r)}function Zi(t,e,n,r){Ji(t,Ci(e,n),r)}function Qi(t,e,n){var r=t.history.done,i=X(r);i&&i.ranges?(r[r.length-1]=e,to(t,e,n)):Ji(t,e,n)}function Ji(t,e,n){to(t,e,n),Bi(t,t.sel,t.cm?t.cm.curOp.id:NaN,n)}function to(t,e,n){(vt(t,"beforeSelectionChange")||t.cm&&vt(t.cm,"beforeSelectionChange"))&&(e=function(t,e,n){var r={ranges:e.ranges,update:function(e){this.ranges=[];for(var n=0;n<e.length;n++)this.ranges[n]=new xi(se(t,e[n].anchor),se(t,e[n].head))},origin:n&&n.origin};return dt(t,"beforeSelectionChange",t,r),t.cm&&dt(t.cm,"beforeSelectionChange",t.cm,r),r.ranges!=e.ranges?Ei(t.cm,r.ranges,r.ranges.length-1):e}(t,e,n));var r=n&&n.bias||(ee(e.primary().head,t.sel.primary().head)<0?-1:1);eo(t,ro(t,e,r,!0)),n&&!1===n.scroll||!t.cm||Ir(t.cm)}function eo(t,e){e.equals(t.sel)||(t.sel=e,t.cm&&(t.cm.curOp.updateInput=1,t.cm.curOp.selectionChanged=!0,gt(t.cm)),cn(t,"cursorActivity",t))}function no(t){eo(t,ro(t,t.sel,null,!1))}function ro(t,e,n,r){for(var i,o=0;o<e.ranges.length;o++){var a=e.ranges[o],s=e.ranges.length==t.sel.ranges.length&&t.sel.ranges[o],c=oo(t,a.anchor,s&&s.anchor,n,r),l=oo(t,a.head,s&&s.head,n,r);(i||c!=a.anchor||l!=a.head)&&(i||(i=e.ranges.slice(0,o)),i[o]=new xi(c,l))}return i?Ei(t.cm,i,e.primIndex):e}function io(t,e,n,r,i){var o=Kt(t,e.line);if(o.markedSpans)for(var a=0;a<o.markedSpans.length;++a){var s=o.markedSpans[a],c=s.marker,l="selectLeft"in c?!c.selectLeft:c.inclusiveLeft,u="selectRight"in c?!c.selectRight:c.inclusiveRight;if((null==s.from||(l?s.from<=e.ch:s.from<e.ch))&&(null==s.to||(u?s.to>=e.ch:s.to>e.ch))){if(i&&(dt(c,"beforeCursorEnter"),c.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!c.atomic)continue;if(n){var h=c.find(r<0?1:-1),f=void 0;if((r<0?u:l)&&(h=ao(t,h,-r,h&&h.line==e.line?o:null)),h&&h.line==e.line&&(f=ee(h,n))&&(r<0?f<0:f>0))return io(t,h,e,r,i)}var p=c.find(r<0?-1:1);return(r<0?l:u)&&(p=ao(t,p,r,p.line==e.line?o:null)),p?io(t,p,e,r,i):null}}return e}function oo(t,e,n,r,i){var o=r||1,a=io(t,e,n,o,i)||!i&&io(t,e,n,o,!0)||io(t,e,n,-o,i)||!i&&io(t,e,n,-o,!0);return a||(t.cantEdit=!0,te(t.first,0))}function ao(t,e,n,r){return n<0&&0==e.ch?e.line>t.first?se(t,te(e.line-1)):null:n>0&&e.ch==(r||Kt(t,e.line)).text.length?e.line<t.first+t.size-1?te(e.line+1,0):null:new te(e.line,e.ch+n)}function so(t){t.setSelection(te(t.firstLine(),0),te(t.lastLine()),H)}function co(t,e,n){var r={canceled:!1,from:e.from,to:e.to,text:e.text,origin:e.origin,cancel:function(){return r.canceled=!0}};return n&&(r.update=function(e,n,i,o){e&&(r.from=se(t,e)),n&&(r.to=se(t,n)),i&&(r.text=i),void 0!==o&&(r.origin=o)}),dt(t,"beforeChange",t,r),t.cm&&dt(t.cm,"beforeChange",t.cm,r),r.canceled?(t.cm&&(t.cm.curOp.updateInput=2),null):{from:r.from,to:r.to,text:r.text,origin:r.origin}}function lo(t,e,n){if(t.cm){if(!t.cm.curOp)return ti(t.cm,lo)(t,e,n);if(t.cm.state.suppressEdits)return}if(!(vt(t,"beforeChange")||t.cm&&vt(t.cm,"beforeChange"))||(e=co(t,e,!0))){var r=Oe&&!n&&function(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!=W(r,n)||(r||(r=[])).push(n)}})),!r)return null;for(var i=[{from:e,to:n}],o=0;o<r.length;++o)for(var a=r[o],s=a.find(0),c=0;c<i.length;++c){var l=i[c];if(!(ee(l.to,s.from)<0||ee(l.from,s.to)>0)){var u=[c,1],h=ee(l.from,s.from),f=ee(l.to,s.to);(h<0||!a.inclusiveLeft&&!h)&&u.push({from:l.from,to:s.from}),(f>0||!a.inclusiveRight&&!f)&&u.push({from:s.to,to:l.to}),i.splice.apply(i,u),c+=u.length-3}}return i}(t,e.from,e.to);if(r)for(var i=r.length-1;i>=0;--i)uo(t,{from:r[i].from,to:r[i].to,text:i?[""]:e.text,origin:e.origin});else uo(t,e)}}function uo(t,e){if(1!=e.text.length||""!=e.text[0]||0!=ee(e.from,e.to)){var n=Ni(t,e);Wi(t,e,n,t.cm?t.cm.curOp.id:NaN),po(t,e,n,ke(t,e));var r=[];_i(t,(function(t,n){n||-1!=W(r,t.history)||(yo(t.history,e),r.push(t.history)),po(t,e,null,ke(t,e))}))}}function ho(t,e,n){var r=t.cm&&t.cm.state.suppressEdits;if(!r||n){for(var i,o=t.history,a=t.sel,s="undo"==e?o.done:o.undone,c="undo"==e?o.undone:o.done,l=0;l<s.length&&(i=s[l],n?!i.ranges||i.equals(t.sel):i.ranges);l++);if(l!=s.length){for(o.lastOrigin=o.lastSelOrigin=null;;){if(!(i=s.pop()).ranges){if(r)return void s.push(i);break}if(Hi(i,c),n&&!i.equals(t.sel))return void Ji(t,i,{clearRedo:!1});a=i}var u=[];Hi(a,c),c.push({changes:u,generation:o.generation}),o.generation=i.generation||++o.maxGeneration;for(var h=vt(t,"beforeChange")||t.cm&&vt(t.cm,"beforeChange"),f=function(n){var r=i.changes[n];if(r.origin=e,h&&!co(t,r,!1))return s.length=0,{};u.push(Fi(t,r));var o=n?Ni(t,r):X(s);po(t,r,o,Vi(t,r)),!n&&t.cm&&t.cm.scrollIntoView({from:r.from,to:ki(r)});var a=[];_i(t,(function(t,e){e||-1!=W(a,t.history)||(yo(t.history,r),a.push(t.history)),po(t,r,null,Vi(t,r))}))},p=i.changes.length-1;p>=0;--p){var d=f(p);if(d)return d.v}}}}function fo(t,e){if(0!=e&&(t.first+=e,t.sel=new Si($(t.sel.ranges,(function(t){return new xi(te(t.anchor.line+e,t.anchor.ch),te(t.head.line+e,t.head.ch))})),t.sel.primIndex),t.cm)){hr(t.cm,t.first,t.first-e,e);for(var n=t.cm.display,r=n.viewFrom;r<n.viewTo;r++)fr(t.cm,r,"gutter")}}function po(t,e,n,r){if(t.cm&&!t.cm.curOp)return ti(t.cm,po)(t,e,n,r);if(e.to.line<t.first)fo(t,e.text.length-1-(e.to.line-e.from.line));else if(!(e.from.line>t.lastLine())){if(e.from.line<t.first){var i=e.text.length-1-(t.first-e.from.line);fo(t,i),e={from:te(t.first,0),to:te(e.to.line+i,e.to.ch),text:[X(e.text)],origin:e.origin}}var o=t.lastLine();e.to.line>o&&(e={from:e.from,to:te(o,Kt(t,o).text.length),text:[e.text[0]],origin:e.origin}),e.removed=Yt(t,e.from,e.to),n||(n=Ni(t,e)),t.cm?function(t,e,n){var r=t.doc,i=t.display,o=e.from,a=e.to,s=!1,c=o.line;t.options.lineWrapping||(c=qt(Fe(Kt(r,o.line))),r.iter(c,a.line+1,(function(t){if(t==i.maxLine)return s=!0,!0}))),r.sel.contains(e.from,e.to)>-1&&gt(t),Mi(r,e,n,sr(t)),t.options.lineWrapping||(r.iter(c,o.line+e.text.length,(function(t){var e=ze(t);e>i.maxLineLength&&(i.maxLine=t,i.maxLineLength=e,i.maxLineChanged=!0,s=!1)})),s&&(t.curOp.updateMaxLine=!0)),function(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=Kt(t,r).stateAfter;if(i&&(!(i instanceof le)||r+i.lookAhead<e)){n=r+1;break}}t.highlightFrontier=Math.min(t.highlightFrontier,n)}}(r,o.line),ri(t,400);var l=e.text.length-(a.line-o.line)-1;e.full?hr(t):o.line!=a.line||1!=e.text.length||Ri(t.doc,e)?hr(t,o.line,a.line+1,l):fr(t,o.line,"text");var u=vt(t,"changes"),h=vt(t,"change");if(h||u){var f={from:o,to:a,text:e.text,removed:e.removed,origin:e.origin};h&&cn(t,"change",t,f),u&&(t.curOp.changeObjs||(t.curOp.changeObjs=[])).push(f)}t.display.selForContextMenu=null}(t.cm,e,r):Mi(t,e,r),to(t,n,H),t.cantEdit&&oo(t,te(t.firstLine(),0))&&(t.cantEdit=!1)}}function mo(t,e,n,r,i){var o;r||(r=n),ee(r,n)<0&&(n=(o=[r,n])[0],r=o[1]),"string"==typeof e&&(e=t.splitLines(e)),lo(t,{from:n,to:r,text:e,origin:i})}function go(t,e,n,r){n<t.line?t.line+=r:e<t.line&&(t.line=e,t.ch=0)}function vo(t,e,n,r){for(var i=0;i<t.length;++i){var o=t[i],a=!0;if(o.ranges){o.copied||((o=t[i]=o.deepCopy()).copied=!0);for(var s=0;s<o.ranges.length;s++)go(o.ranges[s].anchor,e,n,r),go(o.ranges[s].head,e,n,r)}else{for(var c=0;c<o.changes.length;++c){var l=o.changes[c];if(n<l.from.line)l.from=te(l.from.line+r,l.from.ch),l.to=te(l.to.line+r,l.to.ch);else if(e<=l.to.line){a=!1;break}}a||(t.splice(0,i+1),i=0)}}}function yo(t,e){var n=e.from.line,r=e.to.line,i=e.text.length-(r-n)-1;vo(t.done,n,r,i),vo(t.undone,n,r,i)}function bo(t,e,n,r){var i=e,o=e;return"number"==typeof e?o=Kt(t,ae(t,e)):i=qt(e),null==i?null:(r(o,i)&&t.cm&&fr(t.cm,i,n),o)}function To(t){this.lines=t,this.parent=null;for(var e=0,n=0;n<t.length;++n)t[n].parent=this,e+=t[n].height;this.height=e}function Oo(t){this.children=t;for(var e=0,n=0,r=0;r<t.length;++r){var i=t[r];e+=i.chunkSize(),n+=i.height,i.parent=this}this.size=e,this.height=n,this.parent=null}xi.prototype.from=function(){return oe(this.anchor,this.head)},xi.prototype.to=function(){return ie(this.anchor,this.head)},xi.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},To.prototype={chunkSize:function(){return this.lines.length},removeInner:function(t,e){for(var n=t,r=t+e;n<r;++n){var i=this.lines[n];this.height-=i.height,Ye(i),cn(i,"delete")}this.lines.splice(t,e)},collapse:function(t){t.push.apply(t,this.lines)},insertInner:function(t,e,n){this.height+=n,this.lines=this.lines.slice(0,t).concat(e).concat(this.lines.slice(t));for(var r=0;r<e.length;++r)e[r].parent=this},iterN:function(t,e,n){for(var r=t+e;t<r;++t)if(n(this.lines[t]))return!0}},Oo.prototype={chunkSize:function(){return this.size},removeInner:function(t,e){this.size-=e;for(var n=0;n<this.children.length;++n){var r=this.children[n],i=r.chunkSize();if(t<i){var o=Math.min(e,i-t),a=r.height;if(r.removeInner(t,o),this.height-=a-r.height,i==o&&(this.children.splice(n--,1),r.parent=null),0==(e-=o))break;t=0}else t-=i}if(this.size-e<25&&(this.children.length>1||!(this.children[0]instanceof To))){var s=[];this.collapse(s),this.children=[new To(s)],this.children[0].parent=this}},collapse:function(t){for(var e=0;e<this.children.length;++e)this.children[e].collapse(t)},insertInner:function(t,e,n){this.size+=e.length,this.height+=n;for(var r=0;r<this.children.length;++r){var i=this.children[r],o=i.chunkSize();if(t<=o){if(i.insertInner(t,e,n),i.lines&&i.lines.length>50){for(var a=i.lines.length%25+25,s=a;s<i.lines.length;){var c=new To(i.lines.slice(s,s+=25));i.height-=c.height,this.children.splice(++r,0,c),c.parent=this}i.lines=i.lines.slice(0,a),this.maybeSpill()}break}t-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var t=this;do{var e=new Oo(t.children.splice(t.children.length-5,5));if(t.parent){t.size-=e.size,t.height-=e.height;var n=W(t.parent.children,t);t.parent.children.splice(n+1,0,e)}else{var r=new Oo(t.children);r.parent=t,t.children=[r,e],t=r}e.parent=t.parent}while(t.children.length>10);t.parent.maybeSpill()}},iterN:function(t,e,n){for(var r=0;r<this.children.length;++r){var i=this.children[r],o=i.chunkSize();if(t<o){var a=Math.min(e,o-t);if(i.iterN(t,a,n))return!0;if(0==(e-=a))break;t=0}else t-=o}}};var So=function(t,e,n){if(n)for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.doc=t,this.node=e};function xo(t,e,n){Ge(e)<(t.curOp&&t.curOp.scrollTop||t.doc.scrollTop)&&Ar(t,n)}So.prototype.clear=function(){var t=this.doc.cm,e=this.line.widgets,n=this.line,r=qt(n);if(null!=r&&e){for(var i=0;i<e.length;++i)e[i]==this&&e.splice(i--,1);e.length||(n.widgets=null);var o=On(this);$t(n,Math.max(0,n.height-o)),t&&(Jr(t,(function(){xo(t,n,-o),fr(t,r,"widget")})),cn(t,"lineWidgetCleared",t,this,r))}},So.prototype.changed=function(){var t=this,e=this.height,n=this.doc.cm,r=this.line;this.height=null;var i=On(this)-e;i&&(Be(this.doc,r)||$t(r,r.height+i),n&&Jr(n,(function(){n.curOp.forceUpdate=!0,xo(n,r,i),cn(n,"lineWidgetChanged",n,t,qt(r))})))},yt(So);var Eo=0,Co=function(t,e){this.lines=[],this.type=e,this.doc=t,this.id=++Eo};function ko(t,e,n,r,i){if(r&&r.shared)return function(t,e,n,r,i){(r=D(r)).shared=!1;var o=[ko(t,e,n,r,i)],a=o[0],s=r.widgetNode;return _i(t,(function(t){s&&(r.widgetNode=s.cloneNode(!0)),o.push(ko(t,se(t,e),se(t,n),r,i));for(var c=0;c<t.linked.length;++c)if(t.linked[c].isParent)return;a=X(o)})),new wo(o,a)}(t,e,n,r,i);if(t.cm&&!t.cm.curOp)return ti(t.cm,ko)(t,e,n,r,i);var o=new Co(t,i),a=ee(e,n);if(r&&D(r,o,!1),a>0||0==a&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=A("span",[o.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(De(t,e.line,e,n,o)||e.line!=n.line&&De(t,n.line,e,n,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Se=!0}o.addToHistory&&Wi(t,{from:e,to:n,origin:"markText"},t.sel,NaN);var s,c=e.line,l=t.cm;if(t.iter(c,n.line+1,(function(t){l&&o.collapsed&&!l.options.lineWrapping&&Fe(t)==l.display.maxLine&&(s=!0),o.collapsed&&c!=e.line&&$t(t,0),function(t,e){t.markedSpans=t.markedSpans?t.markedSpans.concat([e]):[e],e.marker.attachLine(t)}(t,new xe(o,c==e.line?e.ch:null,c==n.line?n.ch:null)),++c})),o.collapsed&&t.iter(e.line,n.line+1,(function(e){Be(t,e)&&$t(e,0)})),o.clearOnEnter&&ht(o,"beforeCursorEnter",(function(){return o.clear()})),o.readOnly&&(Oe=!0,(t.history.done.length||t.history.undone.length)&&t.clearHistory()),o.collapsed&&(o.id=++Eo,o.atomic=!0),l){if(s&&(l.curOp.updateMaxLine=!0),o.collapsed)hr(l,e.line,n.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(var u=e.line;u<=n.line;u++)fr(l,u,"text");o.atomic&&no(l.doc),cn(l,"markerAdded",l,o)}return o}Co.prototype.clear=function(){if(!this.explicitlyCleared){var t=this.doc.cm,e=t&&!t.curOp;if(e&&Kr(t),vt(this,"clear")){var n=this.find();n&&cn(this,"clear",n.from,n.to)}for(var r=null,i=null,o=0;o<this.lines.length;++o){var a=this.lines[o],s=Ee(a.markedSpans,this);t&&!this.collapsed?fr(t,qt(a),"text"):t&&(null!=s.to&&(i=qt(a)),null!=s.from&&(r=qt(a))),a.markedSpans=Ce(a.markedSpans,s),null==s.from&&this.collapsed&&!Be(this.doc,a)&&t&&$t(a,rr(t.display))}if(t&&this.collapsed&&!t.options.lineWrapping)for(var c=0;c<this.lines.length;++c){var l=Fe(this.lines[c]),u=ze(l);u>t.display.maxLineLength&&(t.display.maxLine=l,t.display.maxLineLength=u,t.display.maxLineChanged=!0)}null!=r&&t&&this.collapsed&&hr(t,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&no(t.doc)),t&&cn(t,"markerCleared",t,this,r,i),e&&Yr(t),this.parent&&this.parent.clear()}},Co.prototype.find=function(t,e){var n,r;null==t&&"bookmark"==this.type&&(t=1);for(var i=0;i<this.lines.length;++i){var o=this.lines[i],a=Ee(o.markedSpans,this);if(null!=a.from&&(n=te(e?o:qt(o),a.from),-1==t))return n;if(null!=a.to&&(r=te(e?o:qt(o),a.to),1==t))return r}return n&&{from:n,to:r}},Co.prototype.changed=function(){var t=this,e=this.find(-1,!0),n=this,r=this.doc.cm;e&&r&&Jr(r,(function(){var i=e.line,o=qt(e.line),a=In(r,o);if(a&&(Fn(a),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!Be(n.doc,i)&&null!=n.height){var s=n.height;n.height=null;var c=On(n)-s;c&&$t(i,i.height+c)}cn(r,"markerChanged",r,t)}))},Co.prototype.attachLine=function(t){if(!this.lines.length&&this.doc.cm){var e=this.doc.cm.curOp;e.maybeHiddenMarkers&&-1!=W(e.maybeHiddenMarkers,this)||(e.maybeUnhiddenMarkers||(e.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(t)},Co.prototype.detachLine=function(t){if(this.lines.splice(W(this.lines,t),1),!this.lines.length&&this.doc.cm){var e=this.doc.cm.curOp;(e.maybeHiddenMarkers||(e.maybeHiddenMarkers=[])).push(this)}},yt(Co);var wo=function(t,e){this.markers=t,this.primary=e;for(var n=0;n<t.length;++n)t[n].parent=this};function No(t){return t.findMarks(te(t.first,0),t.clipPos(te(t.lastLine())),(function(t){return t.parent}))}function Lo(t){for(var e=function(e){var n=t[e],r=[n.primary.doc];_i(n.primary.doc,(function(t){return r.push(t)}));for(var i=0;i<n.markers.length;i++){var o=n.markers[i];-1==W(r,o.doc)&&(o.parent=null,n.markers.splice(i--,1))}},n=0;n<t.length;n++)e(n)}wo.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var t=0;t<this.markers.length;++t)this.markers[t].clear();cn(this,"clear")}},wo.prototype.find=function(t,e){return this.primary.find(t,e)},yt(wo);var Ao=0,Io=function(t,e,n,r,i){if(!(this instanceof Io))return new Io(t,e,n,r,i);null==n&&(n=0),Oo.call(this,[new To([new Ke("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=n;var o=te(n,0);this.sel=Ci(o),this.history=new Di(null),this.id=++Ao,this.modeOption=e,this.lineSep=r,this.direction="rtl"==i?"rtl":"ltr",this.extend=!1,"string"==typeof t&&(t=this.splitLines(t)),Mi(this,{from:o,to:o,text:t}),Ji(this,Ci(o),H)};Io.prototype=Z(Oo.prototype,{constructor:Io,iter:function(t,e,n){n?this.iterN(t-this.first,e-t,n):this.iterN(this.first,this.first+this.size,t)},insert:function(t,e){for(var n=0,r=0;r<e.length;++r)n+=e[r].height;this.insertInner(t-this.first,e,n)},remove:function(t,e){this.removeInner(t-this.first,e)},getValue:function(t){var e=Xt(this,this.first,this.first+this.size);return!1===t?e:e.join(t||this.lineSeparator())},setValue:ni((function(t){var e=te(this.first,0),n=this.first+this.size-1;lo(this,{from:e,to:te(n,Kt(this,n).text.length),text:this.splitLines(t),origin:"setValue",full:!0},!0),this.cm&&Rr(this.cm,0,0),Ji(this,Ci(e),H)})),replaceRange:function(t,e,n,r){mo(this,t,e=se(this,e),n=n?se(this,n):e,r)},getRange:function(t,e,n){var r=Yt(this,se(this,t),se(this,e));return!1===n?r:r.join(n||this.lineSeparator())},getLine:function(t){var e=this.getLineHandle(t);return e&&e.text},getLineHandle:function(t){if(Qt(this,t))return Kt(this,t)},getLineNumber:function(t){return qt(t)},getLineHandleVisualStart:function(t){return"number"==typeof t&&(t=Kt(this,t)),Fe(t)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(t){return se(this,t)},getCursor:function(t){var e=this.sel.primary();return null==t||"head"==t?e.head:"anchor"==t?e.anchor:"end"==t||"to"==t||!1===t?e.to():e.from()},listSelections:function(){return this.sel.ranges},somethingSelected:function(){return this.sel.somethingSelected()},setCursor:ni((function(t,e,n){Zi(this,se(this,"number"==typeof t?te(t,e||0):t),null,n)})),setSelection:ni((function(t,e,n){Zi(this,se(this,t),se(this,e||t),n)})),extendSelection:ni((function(t,e,n){Xi(this,se(this,t),e&&se(this,e),n)})),extendSelections:ni((function(t,e){$i(this,ce(this,t),e)})),extendSelectionsBy:ni((function(t,e){$i(this,ce(this,$(this.sel.ranges,t)),e)})),setSelections:ni((function(t,e,n){if(t.length){for(var r=[],i=0;i<t.length;i++)r[i]=new xi(se(this,t[i].anchor),se(this,t[i].head));null==e&&(e=Math.min(t.length-1,this.sel.primIndex)),Ji(this,Ei(this.cm,r,e),n)}})),addSelection:ni((function(t,e,n){var r=this.sel.ranges.slice(0);r.push(new xi(se(this,t),se(this,e||t))),Ji(this,Ei(this.cm,r,r.length-1),n)})),getSelection:function(t){for(var e,n=this.sel.ranges,r=0;r<n.length;r++){var i=Yt(this,n[r].from(),n[r].to());e=e?e.concat(i):i}return!1===t?e:e.join(t||this.lineSeparator())},getSelections:function(t){for(var e=[],n=this.sel.ranges,r=0;r<n.length;r++){var i=Yt(this,n[r].from(),n[r].to());!1!==t&&(i=i.join(t||this.lineSeparator())),e[r]=i}return e},replaceSelection:function(t,e,n){for(var r=[],i=0;i<this.sel.ranges.length;i++)r[i]=t;this.replaceSelections(r,e,n||"+input")},replaceSelections:ni((function(t,e,n){for(var r=[],i=this.sel,o=0;o<i.ranges.length;o++){var a=i.ranges[o];r[o]={from:a.from(),to:a.to(),text:this.splitLines(t[o]),origin:n}}for(var s=e&&"end"!=e&&function(t,e,n){for(var r=[],i=te(t.first,0),o=i,a=0;a<e.length;a++){var s=e[a],c=Li(s.from,i,o),l=Li(ki(s),i,o);if(i=s.to,o=l,"around"==n){var u=t.sel.ranges[a],h=ee(u.head,u.anchor)<0;r[a]=new xi(h?l:c,h?c:l)}else r[a]=new xi(c,c)}return new Si(r,t.sel.primIndex)}(this,r,e),c=r.length-1;c>=0;c--)lo(this,r[c]);s?Qi(this,s):this.cm&&Ir(this.cm)})),undo:ni((function(){ho(this,"undo")})),redo:ni((function(){ho(this,"redo")})),undoSelection:ni((function(){ho(this,"undo",!0)})),redoSelection:ni((function(){ho(this,"redo",!0)})),setExtending:function(t){this.extend=t},getExtending:function(){return this.extend},historySize:function(){for(var t=this.history,e=0,n=0,r=0;r<t.done.length;r++)t.done[r].ranges||++e;for(var i=0;i<t.undone.length;i++)t.undone[i].ranges||++n;return{undo:e,redo:n}},clearHistory:function(){var t=this;this.history=new Di(this.history.maxGeneration),_i(this,(function(e){return e.history=t.history}),!0)},markClean:function(){this.cleanGeneration=this.changeGeneration(!0)},changeGeneration:function(t){return t&&(this.history.lastOp=this.history.lastSelOp=this.history.lastOrigin=null),this.history.generation},isClean:function(t){return this.history.generation==(t||this.cleanGeneration)},getHistory:function(){return{done:Ki(this.history.done),undone:Ki(this.history.undone)}},setHistory:function(t){var e=this.history=new Di(this.history.maxGeneration);e.done=Ki(t.done.slice(0),null,!0),e.undone=Ki(t.undone.slice(0),null,!0)},setGutterMarker:ni((function(t,e,n){return bo(this,t,"gutter",(function(t){var r=t.gutterMarkers||(t.gutterMarkers={});return r[e]=n,!n&&et(r)&&(t.gutterMarkers=null),!0}))})),clearGutter:ni((function(t){var e=this;this.iter((function(n){n.gutterMarkers&&n.gutterMarkers[t]&&bo(e,n,"gutter",(function(){return n.gutterMarkers[t]=null,et(n.gutterMarkers)&&(n.gutterMarkers=null),!0}))}))})),lineInfo:function(t){var e;if("number"==typeof t){if(!Qt(this,t))return null;if(e=t,!(t=Kt(this,t)))return null}else if(null==(e=qt(t)))return null;return{line:e,handle:t,text:t.text,gutterMarkers:t.gutterMarkers,textClass:t.textClass,bgClass:t.bgClass,wrapClass:t.wrapClass,widgets:t.widgets}},addLineClass:ni((function(t,e,n){return bo(this,t,"gutter"==e?"gutter":"class",(function(t){var r="text"==e?"textClass":"background"==e?"bgClass":"gutter"==e?"gutterClass":"wrapClass";if(t[r]){if(E(n).test(t[r]))return!1;t[r]+=" "+n}else t[r]=n;return!0}))})),removeLineClass:ni((function(t,e,n){return bo(this,t,"gutter"==e?"gutter":"class",(function(t){var r="text"==e?"textClass":"background"==e?"bgClass":"gutter"==e?"gutterClass":"wrapClass",i=t[r];if(!i)return!1;if(null==n)t[r]=null;else{var o=i.match(E(n));if(!o)return!1;var a=o.index+o[0].length;t[r]=i.slice(0,o.index)+(o.index&&a!=i.length?" ":"")+i.slice(a)||null}return!0}))})),addLineWidget:ni((function(t,e,n){return function(t,e,n,r){var i=new So(t,n,r),o=t.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),bo(t,e,"widget",(function(e){var n=e.widgets||(e.widgets=[]);if(null==i.insertAt?n.push(i):n.splice(Math.min(n.length-1,Math.max(0,i.insertAt)),0,i),i.line=e,o&&!Be(t,e)){var r=Ge(e)<t.scrollTop;$t(e,e.height+On(i)),r&&Ar(o,i.height),o.curOp.forceUpdate=!0}return!0})),o&&cn(o,"lineWidgetAdded",o,i,"number"==typeof e?e:qt(e)),i}(this,t,e,n)})),removeLineWidget:function(t){t.clear()},markText:function(t,e,n){return ko(this,se(this,t),se(this,e),n,n&&n.type||"range")},setBookmark:function(t,e){var n={replacedWith:e&&(null==e.nodeType?e.widget:e),insertLeft:e&&e.insertLeft,clearWhenEmpty:!1,shared:e&&e.shared,handleMouseEvents:e&&e.handleMouseEvents};return ko(this,t=se(this,t),t,n,"bookmark")},findMarksAt:function(t){var e=[],n=Kt(this,(t=se(this,t)).line).markedSpans;if(n)for(var r=0;r<n.length;++r){var i=n[r];(null==i.from||i.from<=t.ch)&&(null==i.to||i.to>=t.ch)&&e.push(i.marker.parent||i.marker)}return e},findMarks:function(t,e,n){t=se(this,t),e=se(this,e);var r=[],i=t.line;return this.iter(t.line,e.line+1,(function(o){var a=o.markedSpans;if(a)for(var s=0;s<a.length;s++){var c=a[s];null!=c.to&&i==t.line&&t.ch>=c.to||null==c.from&&i!=t.line||null!=c.from&&i==e.line&&c.from>=e.ch||n&&!n(c.marker)||r.push(c.marker.parent||c.marker)}++i})),r},getAllMarks:function(){var t=[];return this.iter((function(e){var n=e.markedSpans;if(n)for(var r=0;r<n.length;++r)null!=n[r].from&&t.push(n[r].marker)})),t},posFromIndex:function(t){var e,n=this.first,r=this.lineSeparator().length;return this.iter((function(i){var o=i.text.length+r;if(o>t)return e=t,!0;t-=o,++n})),se(this,te(n,e))},indexFromPos:function(t){var e=(t=se(this,t)).ch;if(t.line<this.first||t.ch<0)return 0;var n=this.lineSeparator().length;return this.iter(this.first,t.line,(function(t){e+=t.text.length+n})),e},copy:function(t){var e=new Io(Xt(this,this.first,this.first+this.size),this.modeOption,this.first,this.lineSep,this.direction);return e.scrollTop=this.scrollTop,e.scrollLeft=this.scrollLeft,e.sel=this.sel,e.extend=!1,t&&(e.history.undoDepth=this.history.undoDepth,e.setHistory(this.getHistory())),e},linkedDoc:function(t){t||(t={});var e=this.first,n=this.first+this.size;null!=t.from&&t.from>e&&(e=t.from),null!=t.to&&t.to<n&&(n=t.to);var r=new Io(Xt(this,e,n),t.mode||this.modeOption,e,this.lineSep,this.direction);return t.sharedHist&&(r.history=this.history),(this.linked||(this.linked=[])).push({doc:r,sharedHist:t.sharedHist}),r.linked=[{doc:this,isParent:!0,sharedHist:t.sharedHist}],function(t,e){for(var n=0;n<e.length;n++){var r=e[n],i=r.find(),o=t.clipPos(i.from),a=t.clipPos(i.to);if(ee(o,a)){var s=ko(t,o,a,r.primary,r.primary.type);r.markers.push(s),s.parent=r}}}(r,No(this)),r},unlinkDoc:function(t){if(t instanceof wa&&(t=t.doc),this.linked)for(var e=0;e<this.linked.length;++e)if(this.linked[e].doc==t){this.linked.splice(e,1),t.unlinkDoc(this),Lo(No(this));break}if(t.history==this.history){var n=[t.id];_i(t,(function(t){return n.push(t.id)}),!0),t.history=new Di(null),t.history.done=Ki(this.history.done,n),t.history.undone=Ki(this.history.undone,n)}},iterLinkedDocs:function(t){_i(this,t)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(t){return this.lineSep?t.split(this.lineSep):It(t)},lineSeparator:function(){return this.lineSep||"\n"},setDirection:ni((function(t){var e;"rtl"!=t&&(t="ltr"),t!=this.direction&&(this.direction=t,this.iter((function(t){return t.order=null})),this.cm&&Jr(e=this.cm,(function(){ji(e),hr(e)})))}))}),Io.prototype.eachLine=Io.prototype.iter;var Ro=0;function Mo(t){var e=this;if(_o(e),!mt(e,t)&&!Sn(e.display,t)){bt(t),a&&(Ro=+new Date);var n=lr(e,t,!0),r=t.dataTransfer.files;if(n&&!e.isReadOnly())if(r&&r.length&&window.FileReader&&window.File)for(var i=r.length,o=Array(i),s=0,c=function(){++s==i&&ti(e,(function(){var t={from:n=se(e.doc,n),to:n,text:e.doc.splitLines(o.filter((function(t){return null!=t})).join(e.doc.lineSeparator())),origin:"paste"};lo(e.doc,t),Qi(e.doc,Ci(se(e.doc,n),se(e.doc,ki(t))))}))()},l=function(t,n){if(e.options.allowDropFileTypes&&-1==W(e.options.allowDropFileTypes,t.type))c();else{var r=new FileReader;r.onerror=function(){return c()},r.onload=function(){var t=r.result;/[\x00-\x08\x0e-\x1f]{2}/.test(t)||(o[n]=t),c()},r.readAsText(t)}},u=0;u<r.length;u++)l(r[u],u);else{if(e.state.draggingText&&e.doc.sel.contains(n)>-1)return e.state.draggingText(t),void setTimeout((function(){return e.display.input.focus()}),20);try{var h=t.dataTransfer.getData("Text");if(h){var f;if(e.state.draggingText&&!e.state.draggingText.copy&&(f=e.listSelections()),to(e.doc,Ci(n,n)),f)for(var p=0;p<f.length;++p)mo(e.doc,"",f[p].anchor,f[p].head,"drag");e.replaceSelection(h,"around","paste"),e.display.input.focus()}}catch(t){}}}}function _o(t){t.display.dragCursor&&(t.display.lineSpace.removeChild(t.display.dragCursor),t.display.dragCursor=null)}function Po(t){if(document.getElementsByClassName){for(var e=document.getElementsByClassName("CodeMirror"),n=[],r=0;r<e.length;r++){var i=e[r].CodeMirror;i&&n.push(i)}n.length&&n[0].operation((function(){for(var e=0;e<n.length;e++)t(n[e])}))}}var jo=!1;function Do(){var t;jo||(ht(window,"resize",(function(){null==t&&(t=setTimeout((function(){t=null,Po(Fo)}),100))})),ht(window,"blur",(function(){return Po(Cr)})),jo=!0)}function Fo(t){var e=t.display;e.cachedCharWidth=e.cachedTextHeight=e.cachedPaddingH=null,e.scrollbarsClipped=!1,t.setSize()}for(var Uo={3:"Pause",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",145:"ScrollLock",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"Mod",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"},Wo=0;Wo<10;Wo++)Uo[Wo+48]=Uo[Wo+96]=String(Wo);for(var Bo=65;Bo<=90;Bo++)Uo[Bo]=String.fromCharCode(Bo);for(var Ho=1;Ho<=12;Ho++)Uo[Ho+111]=Uo[Ho+63235]="F"+Ho;var Go={};function zo(t){var e,n,r,i,o=t.split(/-(?!$)/);t=o[o.length-1];for(var a=0;a<o.length-1;a++){var s=o[a];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))e=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else{if(!/^s(hift)?$/i.test(s))throw new Error("Unrecognized modifier name: "+s);r=!0}}return e&&(t="Alt-"+t),n&&(t="Ctrl-"+t),i&&(t="Cmd-"+t),r&&(t="Shift-"+t),t}function Vo(t){var e={};for(var n in t)if(t.hasOwnProperty(n)){var r=t[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if("..."==r){delete t[n];continue}for(var i=$(n.split(" "),zo),o=0;o<i.length;o++){var a=void 0,s=void 0;o==i.length-1?(s=i.join(" "),a=r):(s=i.slice(0,o+1).join(" "),a="...");var c=e[s];if(c){if(c!=a)throw new Error("Inconsistent bindings for "+s)}else e[s]=a}delete t[n]}for(var l in e)t[l]=e[l];return t}function Ko(t,e,n,r){var i=(e=qo(e)).call?e.call(t,r):e[t];if(!1===i)return"nothing";if("..."===i)return"multi";if(null!=i&&n(i))return"handled";if(e.fallthrough){if("[object Array]"!=Object.prototype.toString.call(e.fallthrough))return Ko(t,e.fallthrough,n,r);for(var o=0;o<e.fallthrough.length;o++){var a=Ko(t,e.fallthrough[o],n,r);if(a)return a}}}function Yo(t){var e="string"==typeof t?t:Uo[t.keyCode];return"Ctrl"==e||"Alt"==e||"Shift"==e||"Mod"==e}function Xo(t,e,n){var r=t;return e.altKey&&"Alt"!=r&&(t="Alt-"+t),(S?e.metaKey:e.ctrlKey)&&"Ctrl"!=r&&(t="Ctrl-"+t),(S?e.ctrlKey:e.metaKey)&&"Mod"!=r&&(t="Cmd-"+t),!n&&e.shiftKey&&"Shift"!=r&&(t="Shift-"+t),t}function $o(t,e){if(h&&34==t.keyCode&&t.char)return!1;var n=Uo[t.keyCode];return null!=n&&!t.altGraphKey&&(3==t.keyCode&&t.code&&(n=t.code),Xo(n,t,e))}function qo(t){return"string"==typeof t?Go[t]:t}function Zo(t,e){for(var n=t.doc.sel.ranges,r=[],i=0;i<n.length;i++){for(var o=e(n[i]);r.length&&ee(o.from,X(r).to)<=0;){var a=r.pop();if(ee(a.from,o.from)<0){o.from=a.from;break}}r.push(o)}Jr(t,(function(){for(var e=r.length-1;e>=0;e--)mo(t.doc,"",r[e].from,r[e].to,"+delete");Ir(t)}))}function Qo(t,e,n){var r=it(t.text,e+n,n);return r<0||r>t.text.length?null:r}function Jo(t,e,n){var r=Qo(t,e.ch,n);return null==r?null:new te(e.line,r,n<0?"after":"before")}function ta(t,e,n,r,i){if(t){"rtl"==e.doc.direction&&(i=-i);var o=lt(n,e.doc.direction);if(o){var a,s=i<0?X(o):o[0],c=i<0==(1==s.level)?"after":"before";if(s.level>0||"rtl"==e.doc.direction){var l=Rn(e,n);a=i<0?n.text.length-1:0;var u=Mn(e,l,a).top;a=ot((function(t){return Mn(e,l,t).top==u}),i<0==(1==s.level)?s.from:s.to-1,a),"before"==c&&(a=Qo(n,a,1))}else a=i<0?s.to:s.from;return new te(r,a,c)}}return new te(r,i<0?n.text.length:0,i<0?"before":"after")}Go.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"},Go.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"},Go.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"},Go.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"]},Go.default=y?Go.macDefault:Go.pcDefault;var ea={selectAll:so,singleSelection:function(t){return t.setSelection(t.getCursor("anchor"),t.getCursor("head"),H)},killLine:function(t){return Zo(t,(function(e){if(e.empty()){var n=Kt(t.doc,e.head.line).text.length;return e.head.ch==n&&e.head.line<t.lastLine()?{from:e.head,to:te(e.head.line+1,0)}:{from:e.head,to:te(e.head.line,n)}}return{from:e.from(),to:e.to()}}))},deleteLine:function(t){return Zo(t,(function(e){return{from:te(e.from().line,0),to:se(t.doc,te(e.to().line+1,0))}}))},delLineLeft:function(t){return Zo(t,(function(t){return{from:te(t.from().line,0),to:t.from()}}))},delWrappedLineLeft:function(t){return Zo(t,(function(e){var n=t.charCoords(e.head,"div").top+5;return{from:t.coordsChar({left:0,top:n},"div"),to:e.from()}}))},delWrappedLineRight:function(t){return Zo(t,(function(e){var n=t.charCoords(e.head,"div").top+5,r=t.coordsChar({left:t.display.lineDiv.offsetWidth+100,top:n},"div");return{from:e.from(),to:r}}))},undo:function(t){return t.undo()},redo:function(t){return t.redo()},undoSelection:function(t){return t.undoSelection()},redoSelection:function(t){return t.redoSelection()},goDocStart:function(t){return t.extendSelection(te(t.firstLine(),0))},goDocEnd:function(t){return t.extendSelection(te(t.lastLine()))},goLineStart:function(t){return t.extendSelectionsBy((function(e){return na(t,e.head.line)}),{origin:"+move",bias:1})},goLineStartSmart:function(t){return t.extendSelectionsBy((function(e){return ra(t,e.head)}),{origin:"+move",bias:1})},goLineEnd:function(t){return t.extendSelectionsBy((function(e){return function(t,e){var n=Kt(t.doc,e),r=function(t){for(var e;e=Pe(t);)t=e.find(1,!0).line;return t}(n);return r!=n&&(e=qt(r)),ta(!0,t,n,e,-1)}(t,e.head.line)}),{origin:"+move",bias:-1})},goLineRight:function(t){return t.extendSelectionsBy((function(e){var n=t.cursorCoords(e.head,"div").top+5;return t.coordsChar({left:t.display.lineDiv.offsetWidth+100,top:n},"div")}),z)},goLineLeft:function(t){return t.extendSelectionsBy((function(e){var n=t.cursorCoords(e.head,"div").top+5;return t.coordsChar({left:0,top:n},"div")}),z)},goLineLeftSmart:function(t){return t.extendSelectionsBy((function(e){var n=t.cursorCoords(e.head,"div").top+5,r=t.coordsChar({left:0,top:n},"div");return r.ch<t.getLine(r.line).search(/\S/)?ra(t,e.head):r}),z)},goLineUp:function(t){return t.moveV(-1,"line")},goLineDown:function(t){return t.moveV(1,"line")},goPageUp:function(t){return t.moveV(-1,"page")},goPageDown:function(t){return t.moveV(1,"page")},goCharLeft:function(t){return t.moveH(-1,"char")},goCharRight:function(t){return t.moveH(1,"char")},goColumnLeft:function(t){return t.moveH(-1,"column")},goColumnRight:function(t){return t.moveH(1,"column")},goWordLeft:function(t){return t.moveH(-1,"word")},goGroupRight:function(t){return t.moveH(1,"group")},goGroupLeft:function(t){return t.moveH(-1,"group")},goWordRight:function(t){return t.moveH(1,"word")},delCharBefore:function(t){return t.deleteH(-1,"codepoint")},delCharAfter:function(t){return t.deleteH(1,"char")},delWordBefore:function(t){return t.deleteH(-1,"word")},delWordAfter:function(t){return t.deleteH(1,"word")},delGroupBefore:function(t){return t.deleteH(-1,"group")},delGroupAfter:function(t){return t.deleteH(1,"group")},indentAuto:function(t){return t.indentSelection("smart")},indentMore:function(t){return t.indentSelection("add")},indentLess:function(t){return t.indentSelection("subtract")},insertTab:function(t){return t.replaceSelection("\t")},insertSoftTab:function(t){for(var e=[],n=t.listSelections(),r=t.options.tabSize,i=0;i<n.length;i++){var o=n[i].from(),a=F(t.getLine(o.line),o.ch,r);e.push(Y(r-a%r))}t.replaceSelections(e)},defaultTab:function(t){t.somethingSelected()?t.indentSelection("add"):t.execCommand("insertTab")},transposeChars:function(t){return Jr(t,(function(){for(var e=t.listSelections(),n=[],r=0;r<e.length;r++)if(e[r].empty()){var i=e[r].head,o=Kt(t.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new te(i.line,i.ch-1)),i.ch>0)i=new te(i.line,i.ch+1),t.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),te(i.line,i.ch-2),i,"+transpose");else if(i.line>t.doc.first){var a=Kt(t.doc,i.line-1).text;a&&(i=new te(i.line,1),t.replaceRange(o.charAt(0)+t.doc.lineSeparator()+a.charAt(a.length-1),te(i.line-1,a.length-1),i,"+transpose"))}n.push(new xi(i,i))}t.setSelections(n)}))},newlineAndIndent:function(t){return Jr(t,(function(){for(var e=t.listSelections(),n=e.length-1;n>=0;n--)t.replaceRange(t.doc.lineSeparator(),e[n].anchor,e[n].head,"+input");e=t.listSelections();for(var r=0;r<e.length;r++)t.indentLine(e[r].from().line,null,!0);Ir(t)}))},openLine:function(t){return t.replaceSelection("\n","start")},toggleOverwrite:function(t){return t.toggleOverwrite()}};function na(t,e){var n=Kt(t.doc,e),r=Fe(n);return r!=n&&(e=qt(r)),ta(!0,t,r,e,1)}function ra(t,e){var n=na(t,e.line),r=Kt(t.doc,n.line),i=lt(r,t.doc.direction);if(!i||0==i[0].level){var o=Math.max(n.ch,r.text.search(/\S/)),a=e.line==n.line&&e.ch<=o&&e.ch;return te(n.line,a?0:o,n.sticky)}return n}function ia(t,e,n){if("string"==typeof e&&!(e=ea[e]))return!1;t.display.input.ensurePolled();var r=t.display.shift,i=!1;try{t.isReadOnly()&&(t.state.suppressEdits=!0),n&&(t.display.shift=!1),i=e(t)!=B}finally{t.display.shift=r,t.state.suppressEdits=!1}return i}var oa=new U;function aa(t,e,n,r){var i=t.state.keySeq;if(i){if(Yo(e))return"handled";if(/\'$/.test(e)?t.state.keySeq=null:oa.set(50,(function(){t.state.keySeq==i&&(t.state.keySeq=null,t.display.input.reset())})),sa(t,i+" "+e,n,r))return!0}return sa(t,e,n,r)}function sa(t,e,n,r){var i=function(t,e,n){for(var r=0;r<t.state.keyMaps.length;r++){var i=Ko(e,t.state.keyMaps[r],n,t);if(i)return i}return t.options.extraKeys&&Ko(e,t.options.extraKeys,n,t)||Ko(e,t.options.keyMap,n,t)}(t,e,r);return"multi"==i&&(t.state.keySeq=e),"handled"==i&&cn(t,"keyHandled",t,e,n),"handled"!=i&&"multi"!=i||(bt(n),Or(t)),!!i}function ca(t,e){var n=$o(e,!0);return!!n&&(e.shiftKey&&!t.state.keySeq?aa(t,"Shift-"+n,e,(function(e){return ia(t,e,!0)}))||aa(t,n,e,(function(e){if("string"==typeof e?/^go[A-Z]/.test(e):e.motion)return ia(t,e)})):aa(t,n,e,(function(e){return ia(t,e)})))}var la=null;function ua(t){var e=this;if(!(t.target&&t.target!=e.display.input.getField()||(e.curOp.focus=R(),mt(e,t)))){a&&s<11&&27==t.keyCode&&(t.returnValue=!1);var r=t.keyCode;e.display.shift=16==r||t.shiftKey;var i=ca(e,t);h&&(la=i?r:null,i||88!=r||Mt||!(y?t.metaKey:t.ctrlKey)||e.replaceSelection("",null,"cut")),n&&!y&&!i&&46==r&&t.shiftKey&&!t.ctrlKey&&document.execCommand&&document.execCommand("cut"),18!=r||/\bCodeMirror-crosshair\b/.test(e.display.lineDiv.className)||function(t){var e=t.display.lineDiv;function n(t){18!=t.keyCode&&t.altKey||(k(e,"CodeMirror-crosshair"),pt(document,"keyup",n),pt(document,"mouseover",n))}M(e,"CodeMirror-crosshair"),ht(document,"keyup",n),ht(document,"mouseover",n)}(e)}}function ha(t){16==t.keyCode&&(this.doc.sel.shift=!1),mt(this,t)}function fa(t){var e=this;if(!(t.target&&t.target!=e.display.input.getField()||Sn(e.display,t)||mt(e,t)||t.ctrlKey&&!t.altKey||y&&t.metaKey)){var n=t.keyCode,r=t.charCode;if(h&&n==la)return la=null,void bt(t);if(!h||t.which&&!(t.which<10)||!ca(e,t)){var i=String.fromCharCode(null==r?n:r);"\b"!=i&&(function(t,e,n){return aa(t,"'"+n+"'",e,(function(e){return ia(t,e,!0)}))}(e,t,i)||e.display.input.onKeyPress(t))}}}var pa,da,ma=function(t,e,n){this.time=t,this.pos=e,this.button=n};function ga(t){var e=this,n=e.display;if(!(mt(e,t)||n.activeTouch&&n.input.supportsTouch()))if(n.input.ensurePolled(),n.shift=t.shiftKey,Sn(n,t))c||(n.scroller.draggable=!1,setTimeout((function(){return n.scroller.draggable=!0}),100));else if(!ba(e,t)){var r=lr(e,t),i=Et(t),o=r?function(t,e){var n=+new Date;return da&&da.compare(n,t,e)?(pa=da=null,"triple"):pa&&pa.compare(n,t,e)?(da=new ma(n,t,e),pa=null,"double"):(pa=new ma(n,t,e),da=null,"single")}(r,i):"single";window.focus(),1==i&&e.state.selectingText&&e.state.selectingText(t),r&&function(t,e,n,r,i){var o="Click";return"double"==r?o="Double"+o:"triple"==r&&(o="Triple"+o),aa(t,Xo(o=(1==e?"Left":2==e?"Middle":"Right")+o,i),i,(function(e){if("string"==typeof e&&(e=ea[e]),!e)return!1;var r=!1;try{t.isReadOnly()&&(t.state.suppressEdits=!0),r=e(t,n)!=B}finally{t.state.suppressEdits=!1}return r}))}(e,i,r,o,t)||(1==i?r?function(t,e,n,r){a?setTimeout(j(Sr,t),0):t.curOp.focus=R();var i,o=function(t,e,n){var r=t.getOption("configureMouse"),i=r?r(t,e,n):{};if(null==i.unit){var o=b?n.shiftKey&&n.metaKey:n.altKey;i.unit=o?"rectangle":"single"==e?"char":"double"==e?"word":"line"}return(null==i.extend||t.doc.extend)&&(i.extend=t.doc.extend||n.shiftKey),null==i.addNew&&(i.addNew=y?n.metaKey:n.ctrlKey),null==i.moveOnDrag&&(i.moveOnDrag=!(y?n.altKey:n.ctrlKey)),i}(t,n,r),l=t.doc.sel;t.options.dragDrop&&wt&&!t.isReadOnly()&&"single"==n&&(i=l.contains(e))>-1&&(ee((i=l.ranges[i]).from(),e)<0||e.xRel>0)&&(ee(i.to(),e)>0||e.xRel<0)?function(t,e,n,r){var i=t.display,o=!1,l=ti(t,(function(e){c&&(i.scroller.draggable=!1),t.state.draggingText=!1,pt(i.wrapper.ownerDocument,"mouseup",l),pt(i.wrapper.ownerDocument,"mousemove",u),pt(i.scroller,"dragstart",h),pt(i.scroller,"drop",l),o||(bt(e),r.addNew||Xi(t.doc,n,null,null,r.extend),c&&!f||a&&9==s?setTimeout((function(){i.wrapper.ownerDocument.body.focus({preventScroll:!0}),i.input.focus()}),20):i.input.focus())})),u=function(t){o=o||Math.abs(e.clientX-t.clientX)+Math.abs(e.clientY-t.clientY)>=10},h=function(){return o=!0};c&&(i.scroller.draggable=!0),t.state.draggingText=l,l.copy=!r.moveOnDrag,i.scroller.dragDrop&&i.scroller.dragDrop(),ht(i.wrapper.ownerDocument,"mouseup",l),ht(i.wrapper.ownerDocument,"mousemove",u),ht(i.scroller,"dragstart",h),ht(i.scroller,"drop",l),xr(t),setTimeout((function(){return i.input.focus()}),20)}(t,r,e,o):function(t,e,n,r){var i=t.display,o=t.doc;bt(e);var a,s,c=o.sel,l=c.ranges;if(r.addNew&&!r.extend?(s=o.sel.contains(n),a=s>-1?l[s]:new xi(n,n)):(a=o.sel.primary(),s=o.sel.primIndex),"rectangle"==r.unit)r.addNew||(a=new xi(n,n)),n=lr(t,e,!0,!0),s=-1;else{var u=va(t,n,r.unit);a=r.extend?Yi(a,u.anchor,u.head,r.extend):u}r.addNew?-1==s?(s=l.length,Ji(o,Ei(t,l.concat([a]),s),{scroll:!1,origin:"*mouse"})):l.length>1&&l[s].empty()&&"char"==r.unit&&!r.extend?(Ji(o,Ei(t,l.slice(0,s).concat(l.slice(s+1)),0),{scroll:!1,origin:"*mouse"}),c=o.sel):qi(o,s,a,G):(s=0,Ji(o,new Si([a],0),G),c=o.sel);var h=n;function f(e){if(0!=ee(h,e))if(h=e,"rectangle"==r.unit){for(var i=[],l=t.options.tabSize,u=F(Kt(o,n.line).text,n.ch,l),f=F(Kt(o,e.line).text,e.ch,l),p=Math.min(u,f),d=Math.max(u,f),m=Math.min(n.line,e.line),g=Math.min(t.lastLine(),Math.max(n.line,e.line));m<=g;m++){var v=Kt(o,m).text,y=V(v,p,l);p==d?i.push(new xi(te(m,y),te(m,y))):v.length>y&&i.push(new xi(te(m,y),te(m,V(v,d,l))))}i.length||i.push(new xi(n,n)),Ji(o,Ei(t,c.ranges.slice(0,s).concat(i),s),{origin:"*mouse",scroll:!1}),t.scrollIntoView(e)}else{var b,T=a,O=va(t,e,r.unit),S=T.anchor;ee(O.anchor,S)>0?(b=O.head,S=oe(T.from(),O.anchor)):(b=O.anchor,S=ie(T.to(),O.head));var x=c.ranges.slice(0);x[s]=function(t,e){var n=e.anchor,r=e.head,i=Kt(t.doc,n.line);if(0==ee(n,r)&&n.sticky==r.sticky)return e;var o=lt(i);if(!o)return e;var a=st(o,n.ch,n.sticky),s=o[a];if(s.from!=n.ch&&s.to!=n.ch)return e;var c,l=a+(s.from==n.ch==(1!=s.level)?0:1);if(0==l||l==o.length)return e;if(r.line!=n.line)c=(r.line-n.line)*("ltr"==t.doc.direction?1:-1)>0;else{var u=st(o,r.ch,r.sticky),h=u-a||(r.ch-n.ch)*(1==s.level?-1:1);c=u==l-1||u==l?h<0:h>0}var f=o[l+(c?-1:0)],p=c==(1==f.level),d=p?f.from:f.to,m=p?"after":"before";return n.ch==d&&n.sticky==m?e:new xi(new te(n.line,d,m),r)}(t,new xi(se(o,S),b)),Ji(o,Ei(t,x,s),G)}}var p=i.wrapper.getBoundingClientRect(),d=0;function m(e){t.state.selectingText=!1,d=1/0,e&&(bt(e),i.input.focus()),pt(i.wrapper.ownerDocument,"mousemove",g),pt(i.wrapper.ownerDocument,"mouseup",v),o.history.lastSelOrigin=null}var g=ti(t,(function(e){0!==e.buttons&&Et(e)?function e(n){var a=++d,s=lr(t,n,!0,"rectangle"==r.unit);if(s)if(0!=ee(s,h)){t.curOp.focus=R(),f(s);var c=Nr(i,o);(s.line>=c.to||s.line<c.from)&&setTimeout(ti(t,(function(){d==a&&e(n)})),150)}else{var l=n.clientY<p.top?-20:n.clientY>p.bottom?20:0;l&&setTimeout(ti(t,(function(){d==a&&(i.scroller.scrollTop+=l,e(n))})),50)}}(e):m(e)})),v=ti(t,m);t.state.selectingText=v,ht(i.wrapper.ownerDocument,"mousemove",g),ht(i.wrapper.ownerDocument,"mouseup",v)}(t,r,e,o)}(e,r,o,t):xt(t)==n.scroller&&bt(t):2==i?(r&&Xi(e.doc,r),setTimeout((function(){return n.input.focus()}),20)):3==i&&(x?e.display.input.onContextMenu(t):xr(e)))}}function va(t,e,n){if("char"==n)return new xi(e,e);if("word"==n)return t.findWordAt(e);if("line"==n)return new xi(te(e.line,0),se(t.doc,te(e.line+1,0)));var r=n(t,e);return new xi(r.from,r.to)}function ya(t,e,n,r){var i,o;if(e.touches)i=e.touches[0].clientX,o=e.touches[0].clientY;else try{i=e.clientX,o=e.clientY}catch(t){return!1}if(i>=Math.floor(t.display.gutters.getBoundingClientRect().right))return!1;r&&bt(e);var a=t.display,s=a.lineDiv.getBoundingClientRect();if(o>s.bottom||!vt(t,n))return Ot(e);o-=s.top-a.viewOffset;for(var c=0;c<t.display.gutterSpecs.length;++c){var l=a.gutters.childNodes[c];if(l&&l.getBoundingClientRect().right>=i)return dt(t,n,t,Zt(t.doc,o),t.display.gutterSpecs[c].className,e),Ot(e)}}function ba(t,e){return ya(t,e,"gutterClick",!0)}function Ta(t,e){Sn(t.display,e)||function(t,e){return!!vt(t,"gutterContextMenu")&&ya(t,e,"gutterContextMenu",!1)}(t,e)||mt(t,e,"contextmenu")||x||t.display.input.onContextMenu(e)}function Oa(t){t.display.wrapper.className=t.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+t.options.theme.replace(/(^|\s)\s*/g," cm-s-"),Wn(t)}ma.prototype.compare=function(t,e,n){return this.time+400>t&&0==ee(e,this.pos)&&n==this.button};var Sa={toString:function(){return"CodeMirror.Init"}},xa={},Ea={};function Ca(t,e,n){if(!e!=!(n&&n!=Sa)){var r=t.display.dragFunctions,i=e?ht:pt;i(t.display.scroller,"dragstart",r.start),i(t.display.scroller,"dragenter",r.enter),i(t.display.scroller,"dragover",r.over),i(t.display.scroller,"dragleave",r.leave),i(t.display.scroller,"drop",r.drop)}}function ka(t){t.options.lineWrapping?(M(t.display.wrapper,"CodeMirror-wrap"),t.display.sizer.style.minWidth="",t.display.sizerWidth=null):(k(t.display.wrapper,"CodeMirror-wrap"),Ve(t)),cr(t),hr(t),Wn(t),setTimeout((function(){return Br(t)}),100)}function wa(t,e){var n=this;if(!(this instanceof wa))return new wa(t,e);this.options=e=e?D(e):{},D(xa,e,!1);var r=e.value;"string"==typeof r?r=new Io(r,e.mode,null,e.lineSeparator,e.direction):e.mode&&(r.modeOption=e.mode),this.doc=r;var i=new wa.inputStyles[e.inputStyle](this),o=this.display=new gi(t,r,i,e);for(var l in o.wrapper.CodeMirror=this,Oa(this),e.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),zr(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new U,keySeq:null,specialChars:null},e.autofocus&&!v&&o.input.focus(),a&&s<11&&setTimeout((function(){return n.display.input.reset(!0)}),20),function(t){var e=t.display;ht(e.scroller,"mousedown",ti(t,ga)),ht(e.scroller,"dblclick",a&&s<11?ti(t,(function(e){if(!mt(t,e)){var n=lr(t,e);if(n&&!ba(t,e)&&!Sn(t.display,e)){bt(e);var r=t.findWordAt(n);Xi(t.doc,r.anchor,r.head)}}})):function(e){return mt(t,e)||bt(e)}),ht(e.scroller,"contextmenu",(function(e){return Ta(t,e)})),ht(e.input.getField(),"contextmenu",(function(n){e.scroller.contains(n.target)||Ta(t,n)}));var n,r={end:0};function i(){e.activeTouch&&(n=setTimeout((function(){return e.activeTouch=null}),1e3),(r=e.activeTouch).end=+new Date)}function o(t,e){if(null==e.left)return!0;var n=e.left-t.left,r=e.top-t.top;return n*n+r*r>400}ht(e.scroller,"touchstart",(function(i){if(!mt(t,i)&&!function(t){if(1!=t.touches.length)return!1;var e=t.touches[0];return e.radiusX<=1&&e.radiusY<=1}(i)&&!ba(t,i)){e.input.ensurePolled(),clearTimeout(n);var o=+new Date;e.activeTouch={start:o,moved:!1,prev:o-r.end<=300?r:null},1==i.touches.length&&(e.activeTouch.left=i.touches[0].pageX,e.activeTouch.top=i.touches[0].pageY)}})),ht(e.scroller,"touchmove",(function(){e.activeTouch&&(e.activeTouch.moved=!0)})),ht(e.scroller,"touchend",(function(n){var r=e.activeTouch;if(r&&!Sn(e,n)&&null!=r.left&&!r.moved&&new Date-r.start<300){var a,s=t.coordsChar(e.activeTouch,"page");a=!r.prev||o(r,r.prev)?new xi(s,s):!r.prev.prev||o(r,r.prev.prev)?t.findWordAt(s):new xi(te(s.line,0),se(t.doc,te(s.line+1,0))),t.setSelection(a.anchor,a.head),t.focus(),bt(n)}i()})),ht(e.scroller,"touchcancel",i),ht(e.scroller,"scroll",(function(){e.scroller.clientHeight&&(Pr(t,e.scroller.scrollTop),Dr(t,e.scroller.scrollLeft,!0),dt(t,"scroll",t))})),ht(e.scroller,"mousewheel",(function(e){return Oi(t,e)})),ht(e.scroller,"DOMMouseScroll",(function(e){return Oi(t,e)})),ht(e.wrapper,"scroll",(function(){return e.wrapper.scrollTop=e.wrapper.scrollLeft=0})),e.dragFunctions={enter:function(e){mt(t,e)||St(e)},over:function(e){mt(t,e)||(function(t,e){var n=lr(t,e);if(n){var r=document.createDocumentFragment();yr(t,n,r),t.display.dragCursor||(t.display.dragCursor=L("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),t.display.lineSpace.insertBefore(t.display.dragCursor,t.display.cursorDiv)),N(t.display.dragCursor,r)}}(t,e),St(e))},start:function(e){return function(t,e){if(a&&(!t.state.draggingText||+new Date-Ro<100))St(e);else if(!mt(t,e)&&!Sn(t.display,e)&&(e.dataTransfer.setData("Text",t.getSelection()),e.dataTransfer.effectAllowed="copyMove",e.dataTransfer.setDragImage&&!f)){var n=L("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",h&&(n.width=n.height=1,t.display.wrapper.appendChild(n),n._top=n.offsetTop),e.dataTransfer.setDragImage(n,0,0),h&&n.parentNode.removeChild(n)}}(t,e)},drop:ti(t,Mo),leave:function(e){mt(t,e)||_o(t)}};var c=e.input.getField();ht(c,"keyup",(function(e){return ha.call(t,e)})),ht(c,"keydown",ti(t,ua)),ht(c,"keypress",ti(t,fa)),ht(c,"focus",(function(e){return Er(t,e)})),ht(c,"blur",(function(e){return Cr(t,e)}))}(this),Do(),Kr(this),this.curOp.forceUpdate=!0,Pi(this,r),e.autofocus&&!v||this.hasFocus()?setTimeout((function(){n.hasFocus()&&!n.state.focused&&Er(n)}),20):Cr(this),Ea)Ea.hasOwnProperty(l)&&Ea[l](this,e[l],Sa);fi(this),e.finishInit&&e.finishInit(this);for(var u=0;u<Na.length;++u)Na[u](this);Yr(this),c&&e.lineWrapping&&"optimizelegibility"==getComputedStyle(o.lineDiv).textRendering&&(o.lineDiv.style.textRendering="auto")}wa.defaults=xa,wa.optionHandlers=Ea;var Na=[];function La(t,e,n,r){var i,o=t.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?i=pe(t,e).state:n="prev");var a=t.options.tabSize,s=Kt(o,e),c=F(s.text,null,a);s.stateAfter&&(s.stateAfter=null);var l,u=s.text.match(/^\s*/)[0];if(r||/\S/.test(s.text)){if("smart"==n&&((l=o.mode.indent(i,s.text.slice(u.length),s.text))==B||l>150)){if(!r)return;n="prev"}}else l=0,n="not";"prev"==n?l=e>o.first?F(Kt(o,e-1).text,null,a):0:"add"==n?l=c+t.options.indentUnit:"subtract"==n?l=c-t.options.indentUnit:"number"==typeof n&&(l=c+n),l=Math.max(0,l);var h="",f=0;if(t.options.indentWithTabs)for(var p=Math.floor(l/a);p;--p)f+=a,h+="\t";if(f<l&&(h+=Y(l-f)),h!=u)return mo(o,h,te(e,0),te(e,u.length),"+input"),s.stateAfter=null,!0;for(var d=0;d<o.sel.ranges.length;d++){var m=o.sel.ranges[d];if(m.head.line==e&&m.head.ch<u.length){var g=te(e,u.length);qi(o,d,new xi(g,g));break}}}wa.defineInitHook=function(t){return Na.push(t)};var Aa=null;function Ia(t){Aa=t}function Ra(t,e,n,r,i){var o=t.doc;t.display.shift=!1,r||(r=o.sel);var a=+new Date-200,s="paste"==i||t.state.pasteIncoming>a,c=It(e),l=null;if(s&&r.ranges.length>1)if(Aa&&Aa.text.join("\n")==e){if(r.ranges.length%Aa.text.length==0){l=[];for(var u=0;u<Aa.text.length;u++)l.push(o.splitLines(Aa.text[u]))}}else c.length==r.ranges.length&&t.options.pasteLinesPerSelection&&(l=$(c,(function(t){return[t]})));for(var h=t.curOp.updateInput,f=r.ranges.length-1;f>=0;f--){var p=r.ranges[f],d=p.from(),m=p.to();p.empty()&&(n&&n>0?d=te(d.line,d.ch-n):t.state.overwrite&&!s?m=te(m.line,Math.min(Kt(o,m.line).text.length,m.ch+X(c).length)):s&&Aa&&Aa.lineWise&&Aa.text.join("\n")==c.join("\n")&&(d=m=te(d.line,0)));var g={from:d,to:m,text:l?l[f%l.length]:c,origin:i||(s?"paste":t.state.cutIncoming>a?"cut":"+input")};lo(t.doc,g),cn(t,"inputRead",t,g)}e&&!s&&_a(t,e),Ir(t),t.curOp.updateInput<2&&(t.curOp.updateInput=h),t.curOp.typing=!0,t.state.pasteIncoming=t.state.cutIncoming=-1}function Ma(t,e){var n=t.clipboardData&&t.clipboardData.getData("Text");if(n)return t.preventDefault(),e.isReadOnly()||e.options.disableInput||Jr(e,(function(){return Ra(e,n,0,null,"paste")})),!0}function _a(t,e){if(t.options.electricChars&&t.options.smartIndent)for(var n=t.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(!(i.head.ch>100||r&&n.ranges[r-1].head.line==i.head.line)){var o=t.getModeAt(i.head),a=!1;if(o.electricChars){for(var s=0;s<o.electricChars.length;s++)if(e.indexOf(o.electricChars.charAt(s))>-1){a=La(t,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Kt(t.doc,i.head.line).text.slice(0,i.head.ch))&&(a=La(t,i.head.line,"smart"));a&&cn(t,"electricInput",t,i.head.line)}}}function Pa(t){for(var e=[],n=[],r=0;r<t.doc.sel.ranges.length;r++){var i=t.doc.sel.ranges[r].head.line,o={anchor:te(i,0),head:te(i+1,0)};n.push(o),e.push(t.getRange(o.anchor,o.head))}return{text:e,ranges:n}}function ja(t,e,n,r){t.setAttribute("autocorrect",n?"":"off"),t.setAttribute("autocapitalize",r?"":"off"),t.setAttribute("spellcheck",!!e)}function Da(){var t=L("textarea",null,null,"position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"),e=L("div",[t],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");return c?t.style.width="1000px":t.setAttribute("wrap","off"),m&&(t.style.border="1px solid black"),ja(t),e}function Fa(t,e,n,r,i){var o=e,a=n,s=Kt(t,e.line),c=i&&"rtl"==t.direction?-n:n;function l(o){var a,l;if("codepoint"==r){var u=s.text.charCodeAt(e.ch+(r>0?0:-1));a=isNaN(u)?null:new te(e.line,Math.max(0,Math.min(s.text.length,e.ch+n*(u>=55296&&u<56320?2:1))),-n)}else a=i?function(t,e,n,r){var i=lt(e,t.doc.direction);if(!i)return Jo(e,n,r);n.ch>=e.text.length?(n.ch=e.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var o=st(i,n.ch,n.sticky),a=i[o];if("ltr"==t.doc.direction&&a.level%2==0&&(r>0?a.to>n.ch:a.from<n.ch))return Jo(e,n,r);var s,c=function(t,n){return Qo(e,t instanceof te?t.ch:t,n)},l=function(n){return t.options.lineWrapping?(s=s||Rn(t,e),Qn(t,e,s,n)):{begin:0,end:e.text.length}},u=l("before"==n.sticky?c(n,-1):n.ch);if("rtl"==t.doc.direction||1==a.level){var h=1==a.level==r<0,f=c(n,h?1:-1);if(null!=f&&(h?f<=a.to&&f<=u.end:f>=a.from&&f>=u.begin)){var p=h?"before":"after";return new te(n.line,f,p)}}var d=function(t,e,r){for(var o=function(t,e){return e?new te(n.line,c(t,1),"before"):new te(n.line,t,"after")};t>=0&&t<i.length;t+=e){var a=i[t],s=e>0==(1!=a.level),l=s?r.begin:c(r.end,-1);if(a.from<=l&&l<a.to)return o(l,s);if(l=s?a.from:c(a.to,-1),r.begin<=l&&l<r.end)return o(l,s)}},m=d(o+r,r,u);if(m)return m;var g=r>0?u.end:c(u.begin,-1);return null==g||r>0&&g==e.text.length||!(m=d(r>0?0:i.length-1,r,l(g)))?null:m}(t.cm,s,e,n):Jo(s,e,n);if(null==a){if(o||(l=e.line+c)<t.first||l>=t.first+t.size||(e=new te(l,e.ch,e.sticky),!(s=Kt(t,l))))return!1;e=ta(i,t.cm,s,e.line,c)}else e=a;return!0}if("char"==r||"codepoint"==r)l();else if("column"==r)l(!0);else if("word"==r||"group"==r)for(var u=null,h="group"==r,f=t.cm&&t.cm.getHelper(e,"wordChars"),p=!0;!(n<0)||l(!p);p=!1){var d=s.text.charAt(e.ch)||"\n",m=tt(d,f)?"w":h&&"\n"==d?"n":!h||/\s/.test(d)?null:"p";if(!h||p||m||(m="s"),u&&u!=m){n<0&&(n=1,l(),e.sticky="after");break}if(m&&(u=m),n>0&&!l(!p))break}var g=oo(t,e,o,a,!0);return ne(o,g)&&(g.hitSide=!0),g}function Ua(t,e,n,r){var i,o,a=t.doc,s=e.left;if("page"==r){var c=Math.min(t.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),l=Math.max(c-.5*rr(t.display),3);i=(n>0?e.bottom:e.top)+n*l}else"line"==r&&(i=n>0?e.bottom+3:e.top-3);for(;(o=qn(t,s,i)).outside;){if(n<0?i<=0:i>=a.height){o.hitSide=!0;break}i+=5*n}return o}var Wa=function(t){this.cm=t,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new U,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function Ba(t,e){var n=In(t,e.line);if(!n||n.hidden)return null;var r=Kt(t.doc,e.line),i=Ln(n,r,e.line),o=lt(r,t.doc.direction),a="left";o&&(a=st(o,e.ch)%2?"right":"left");var s=jn(i.map,e.ch,a);return s.offset="right"==s.collapse?s.end:s.start,s}function Ha(t,e){return e&&(t.bad=!0),t}function Ga(t,e,n){var r;if(e==t.display.lineDiv){if(!(r=t.display.lineDiv.childNodes[n]))return Ha(t.clipPos(te(t.display.viewTo-1)),!0);e=null,n=0}else for(r=e;;r=r.parentNode){if(!r||r==t.display.lineDiv)return null;if(r.parentNode&&r.parentNode==t.display.lineDiv)break}for(var i=0;i<t.display.view.length;i++){var o=t.display.view[i];if(o.node==r)return za(o,e,n)}}function za(t,e,n){var r=t.text.firstChild,i=!1;if(!e||!I(r,e))return Ha(te(qt(t.line),0),!0);if(e==r&&(i=!0,e=r.childNodes[n],n=0,!e)){var o=t.rest?X(t.rest):t.line;return Ha(te(qt(o),o.text.length),i)}var a=3==e.nodeType?e:null,s=e;for(a||1!=e.childNodes.length||3!=e.firstChild.nodeType||(a=e.firstChild,n&&(n=a.nodeValue.length));s.parentNode!=r;)s=s.parentNode;var c=t.measure,l=c.maps;function u(e,n,r){for(var i=-1;i<(l?l.length:0);i++)for(var o=i<0?c.map:l[i],a=0;a<o.length;a+=3){var s=o[a+2];if(s==e||s==n){var u=qt(i<0?t.line:t.rest[i]),h=o[a]+r;return(r<0||s!=e)&&(h=o[a+(r?1:0)]),te(u,h)}}}var h=u(a,s,n);if(h)return Ha(h,i);for(var f=s.nextSibling,p=a?a.nodeValue.length-n:0;f;f=f.nextSibling){if(h=u(f,f.firstChild,0))return Ha(te(h.line,h.ch-p),i);p+=f.textContent.length}for(var d=s.previousSibling,m=n;d;d=d.previousSibling){if(h=u(d,d.firstChild,-1))return Ha(te(h.line,h.ch+m),i);m+=d.textContent.length}}Wa.prototype.init=function(t){var e=this,n=this,r=n.cm,i=n.div=t.lineDiv;function o(t){for(var e=t.target;e;e=e.parentNode){if(e==i)return!0;if(/\bCodeMirror-(?:line)?widget\b/.test(e.className))break}return!1}function a(t){if(o(t)&&!mt(r,t)){if(r.somethingSelected())Ia({lineWise:!1,text:r.getSelections()}),"cut"==t.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var e=Pa(r);Ia({lineWise:!0,text:e.text}),"cut"==t.type&&r.operation((function(){r.setSelections(e.ranges,0,H),r.replaceSelection("",null,"cut")}))}if(t.clipboardData){t.clipboardData.clearData();var a=Aa.text.join("\n");if(t.clipboardData.setData("Text",a),t.clipboardData.getData("Text")==a)return void t.preventDefault()}var s=Da(),c=s.firstChild;r.display.lineSpace.insertBefore(s,r.display.lineSpace.firstChild),c.value=Aa.text.join("\n");var l=document.activeElement;P(c),setTimeout((function(){r.display.lineSpace.removeChild(s),l.focus(),l==i&&n.showPrimarySelection()}),50)}}ja(i,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize),ht(i,"paste",(function(t){!o(t)||mt(r,t)||Ma(t,r)||s<=11&&setTimeout(ti(r,(function(){return e.updateFromDOM()})),20)})),ht(i,"compositionstart",(function(t){e.composing={data:t.data,done:!1}})),ht(i,"compositionupdate",(function(t){e.composing||(e.composing={data:t.data,done:!1})})),ht(i,"compositionend",(function(t){e.composing&&(t.data!=e.composing.data&&e.readFromDOMSoon(),e.composing.done=!0)})),ht(i,"touchstart",(function(){return n.forceCompositionEnd()})),ht(i,"input",(function(){e.composing||e.readFromDOMSoon()})),ht(i,"copy",a),ht(i,"cut",a)},Wa.prototype.screenReaderLabelChanged=function(t){t?this.div.setAttribute("aria-label",t):this.div.removeAttribute("aria-label")},Wa.prototype.prepareSelection=function(){var t=vr(this.cm,!1);return t.focus=document.activeElement==this.div,t},Wa.prototype.showSelection=function(t,e){t&&this.cm.display.view.length&&((t.focus||e)&&this.showPrimarySelection(),this.showMultipleSelections(t))},Wa.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Wa.prototype.showPrimarySelection=function(){var t=this.getSelection(),e=this.cm,r=e.doc.sel.primary(),i=r.from(),o=r.to();if(e.display.viewTo==e.display.viewFrom||i.line>=e.display.viewTo||o.line<e.display.viewFrom)t.removeAllRanges();else{var a=Ga(e,t.anchorNode,t.anchorOffset),s=Ga(e,t.focusNode,t.focusOffset);if(!a||a.bad||!s||s.bad||0!=ee(oe(a,s),i)||0!=ee(ie(a,s),o)){var c=e.display.view,l=i.line>=e.display.viewFrom&&Ba(e,i)||{node:c[0].measure.map[2],offset:0},u=o.line<e.display.viewTo&&Ba(e,o);if(!u){var h=c[c.length-1].measure,f=h.maps?h.maps[h.maps.length-1]:h.map;u={node:f[f.length-1],offset:f[f.length-2]-f[f.length-3]}}if(l&&u){var p,d=t.rangeCount&&t.getRangeAt(0);try{p=C(l.node,l.offset,u.offset,u.node)}catch(t){}p&&(!n&&e.state.focused?(t.collapse(l.node,l.offset),p.collapsed||(t.removeAllRanges(),t.addRange(p))):(t.removeAllRanges(),t.addRange(p)),d&&null==t.anchorNode?t.addRange(d):n&&this.startGracePeriod()),this.rememberSelection()}else t.removeAllRanges()}}},Wa.prototype.startGracePeriod=function(){var t=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout((function(){t.gracePeriod=!1,t.selectionChanged()&&t.cm.operation((function(){return t.cm.curOp.selectionChanged=!0}))}),20)},Wa.prototype.showMultipleSelections=function(t){N(this.cm.display.cursorDiv,t.cursors),N(this.cm.display.selectionDiv,t.selection)},Wa.prototype.rememberSelection=function(){var t=this.getSelection();this.lastAnchorNode=t.anchorNode,this.lastAnchorOffset=t.anchorOffset,this.lastFocusNode=t.focusNode,this.lastFocusOffset=t.focusOffset},Wa.prototype.selectionInEditor=function(){var t=this.getSelection();if(!t.rangeCount)return!1;var e=t.getRangeAt(0).commonAncestorContainer;return I(this.div,e)},Wa.prototype.focus=function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()&&document.activeElement==this.div||this.showSelection(this.prepareSelection(),!0),this.div.focus())},Wa.prototype.blur=function(){this.div.blur()},Wa.prototype.getField=function(){return this.div},Wa.prototype.supportsTouch=function(){return!0},Wa.prototype.receivedFocus=function(){var t=this;this.selectionInEditor()?this.pollSelection():Jr(this.cm,(function(){return t.cm.curOp.selectionChanged=!0})),this.polling.set(this.cm.options.pollInterval,(function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}))},Wa.prototype.selectionChanged=function(){var t=this.getSelection();return t.anchorNode!=this.lastAnchorNode||t.anchorOffset!=this.lastAnchorOffset||t.focusNode!=this.lastFocusNode||t.focusOffset!=this.lastFocusOffset},Wa.prototype.pollSelection=function(){if(null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var t=this.getSelection(),e=this.cm;if(g&&u&&this.cm.display.gutterSpecs.length&&function(t){for(var e=t;e;e=e.parentNode)if(/CodeMirror-gutter-wrapper/.test(e.className))return!0;return!1}(t.anchorNode))return this.cm.triggerOnKeyDown({type:"keydown",keyCode:8,preventDefault:Math.abs}),this.blur(),void this.focus();if(!this.composing){this.rememberSelection();var n=Ga(e,t.anchorNode,t.anchorOffset),r=Ga(e,t.focusNode,t.focusOffset);n&&r&&Jr(e,(function(){Ji(e.doc,Ci(n,r),H),(n.bad||r.bad)&&(e.curOp.selectionChanged=!0)}))}}},Wa.prototype.pollContent=function(){null!=this.readDOMTimeout&&(clearTimeout(this.readDOMTimeout),this.readDOMTimeout=null);var t,e,n,r=this.cm,i=r.display,o=r.doc.sel.primary(),a=o.from(),s=o.to();if(0==a.ch&&a.line>r.firstLine()&&(a=te(a.line-1,Kt(r.doc,a.line-1).length)),s.ch==Kt(r.doc,s.line).text.length&&s.line<r.lastLine()&&(s=te(s.line+1,0)),a.line<i.viewFrom||s.line>i.viewTo-1)return!1;a.line==i.viewFrom||0==(t=ur(r,a.line))?(e=qt(i.view[0].line),n=i.view[0].node):(e=qt(i.view[t].line),n=i.view[t-1].node.nextSibling);var c,l,u=ur(r,s.line);if(u==i.view.length-1?(c=i.viewTo-1,l=i.lineDiv.lastChild):(c=qt(i.view[u+1].line)-1,l=i.view[u+1].node.previousSibling),!n)return!1;for(var h=r.doc.splitLines(function(t,e,n,r,i){var o="",a=!1,s=t.doc.lineSeparator(),c=!1;function l(){a&&(o+=s,c&&(o+=s),a=c=!1)}function u(t){t&&(l(),o+=t)}function h(e){if(1==e.nodeType){var n=e.getAttribute("cm-text");if(n)return void u(n);var o,f=e.getAttribute("cm-marker");if(f){var p=t.findMarks(te(r,0),te(i+1,0),(g=+f,function(t){return t.id==g}));return void(p.length&&(o=p[0].find(0))&&u(Yt(t.doc,o.from,o.to).join(s)))}if("false"==e.getAttribute("contenteditable"))return;var d=/^(pre|div|p|li|table|br)$/i.test(e.nodeName);if(!/^br$/i.test(e.nodeName)&&0==e.textContent.length)return;d&&l();for(var m=0;m<e.childNodes.length;m++)h(e.childNodes[m]);/^(pre|p)$/i.test(e.nodeName)&&(c=!0),d&&(a=!0)}else 3==e.nodeType&&u(e.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "));var g}for(;h(e),e!=n;)e=e.nextSibling,c=!1;return o}(r,n,l,e,c)),f=Yt(r.doc,te(e,0),te(c,Kt(r.doc,c).text.length));h.length>1&&f.length>1;)if(X(h)==X(f))h.pop(),f.pop(),c--;else{if(h[0]!=f[0])break;h.shift(),f.shift(),e++}for(var p=0,d=0,m=h[0],g=f[0],v=Math.min(m.length,g.length);p<v&&m.charCodeAt(p)==g.charCodeAt(p);)++p;for(var y=X(h),b=X(f),T=Math.min(y.length-(1==h.length?p:0),b.length-(1==f.length?p:0));d<T&&y.charCodeAt(y.length-d-1)==b.charCodeAt(b.length-d-1);)++d;if(1==h.length&&1==f.length&&e==a.line)for(;p&&p>a.ch&&y.charCodeAt(y.length-d-1)==b.charCodeAt(b.length-d-1);)p--,d++;h[h.length-1]=y.slice(0,y.length-d).replace(/^\u200b+/,""),h[0]=h[0].slice(p).replace(/\u200b+$/,"");var O=te(e,p),S=te(c,f.length?X(f).length-d:0);return h.length>1||h[0]||ee(O,S)?(mo(r.doc,h,O,S,"+input"),!0):void 0},Wa.prototype.ensurePolled=function(){this.forceCompositionEnd()},Wa.prototype.reset=function(){this.forceCompositionEnd()},Wa.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Wa.prototype.readFromDOMSoon=function(){var t=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout((function(){if(t.readDOMTimeout=null,t.composing){if(!t.composing.done)return;t.composing=null}t.updateFromDOM()}),80))},Wa.prototype.updateFromDOM=function(){var t=this;!this.cm.isReadOnly()&&this.pollContent()||Jr(this.cm,(function(){return hr(t.cm)}))},Wa.prototype.setUneditable=function(t){t.contentEditable="false"},Wa.prototype.onKeyPress=function(t){0==t.charCode||this.composing||(t.preventDefault(),this.cm.isReadOnly()||ti(this.cm,Ra)(this.cm,String.fromCharCode(null==t.charCode?t.keyCode:t.charCode),0))},Wa.prototype.readOnlyChanged=function(t){this.div.contentEditable=String("nocursor"!=t)},Wa.prototype.onContextMenu=function(){},Wa.prototype.resetPosition=function(){},Wa.prototype.needsContentAttribute=!0;var Va=function(t){this.cm=t,this.prevInput="",this.pollingFast=!1,this.polling=new U,this.hasSelection=!1,this.composing=null};Va.prototype.init=function(t){var e=this,n=this,r=this.cm;this.createField(t);var i=this.textarea;function o(t){if(!mt(r,t)){if(r.somethingSelected())Ia({lineWise:!1,text:r.getSelections()});else{if(!r.options.lineWiseCopyCut)return;var e=Pa(r);Ia({lineWise:!0,text:e.text}),"cut"==t.type?r.setSelections(e.ranges,null,H):(n.prevInput="",i.value=e.text.join("\n"),P(i))}"cut"==t.type&&(r.state.cutIncoming=+new Date)}}t.wrapper.insertBefore(this.wrapper,t.wrapper.firstChild),m&&(i.style.width="0px"),ht(i,"input",(function(){a&&s>=9&&e.hasSelection&&(e.hasSelection=null),n.poll()})),ht(i,"paste",(function(t){mt(r,t)||Ma(t,r)||(r.state.pasteIncoming=+new Date,n.fastPoll())})),ht(i,"cut",o),ht(i,"copy",o),ht(t.scroller,"paste",(function(e){if(!Sn(t,e)&&!mt(r,e)){if(!i.dispatchEvent)return r.state.pasteIncoming=+new Date,void n.focus();var o=new Event("paste");o.clipboardData=e.clipboardData,i.dispatchEvent(o)}})),ht(t.lineSpace,"selectstart",(function(e){Sn(t,e)||bt(e)})),ht(i,"compositionstart",(function(){var t=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:t,range:r.markText(t,r.getCursor("to"),{className:"CodeMirror-composing"})}})),ht(i,"compositionend",(function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)}))},Va.prototype.createField=function(t){this.wrapper=Da(),this.textarea=this.wrapper.firstChild},Va.prototype.screenReaderLabelChanged=function(t){t?this.textarea.setAttribute("aria-label",t):this.textarea.removeAttribute("aria-label")},Va.prototype.prepareSelection=function(){var t=this.cm,e=t.display,n=t.doc,r=vr(t);if(t.options.moveInputWithCursor){var i=Yn(t,n.sel.primary().head,"div"),o=e.wrapper.getBoundingClientRect(),a=e.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(e.wrapper.clientHeight-10,i.top+a.top-o.top)),r.teLeft=Math.max(0,Math.min(e.wrapper.clientWidth-10,i.left+a.left-o.left))}return r},Va.prototype.showSelection=function(t){var e=this.cm.display;N(e.cursorDiv,t.cursors),N(e.selectionDiv,t.selection),null!=t.teTop&&(this.wrapper.style.top=t.teTop+"px",this.wrapper.style.left=t.teLeft+"px")},Va.prototype.reset=function(t){if(!this.contextMenuPending&&!this.composing){var e=this.cm;if(e.somethingSelected()){this.prevInput="";var n=e.getSelection();this.textarea.value=n,e.state.focused&&P(this.textarea),a&&s>=9&&(this.hasSelection=n)}else t||(this.prevInput=this.textarea.value="",a&&s>=9&&(this.hasSelection=null))}},Va.prototype.getField=function(){return this.textarea},Va.prototype.supportsTouch=function(){return!1},Va.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!v||R()!=this.textarea))try{this.textarea.focus()}catch(t){}},Va.prototype.blur=function(){this.textarea.blur()},Va.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},Va.prototype.receivedFocus=function(){this.slowPoll()},Va.prototype.slowPoll=function(){var t=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,(function(){t.poll(),t.cm.state.focused&&t.slowPoll()}))},Va.prototype.fastPoll=function(){var t=!1,e=this;e.pollingFast=!0,e.polling.set(20,(function n(){e.poll()||t?(e.pollingFast=!1,e.slowPoll()):(t=!0,e.polling.set(60,n))}))},Va.prototype.poll=function(){var t=this,e=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||!e.state.focused||Rt(n)&&!r&&!this.composing||e.isReadOnly()||e.options.disableInput||e.state.keySeq)return!1;var i=n.value;if(i==r&&!e.somethingSelected())return!1;if(a&&s>=9&&this.hasSelection===i||y&&/[\uf700-\uf7ff]/.test(i))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||r||(r=""),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var c=0,l=Math.min(r.length,i.length);c<l&&r.charCodeAt(c)==i.charCodeAt(c);)++c;return Jr(e,(function(){Ra(e,i.slice(c),r.length-c,null,t.composing?"*compose":null),i.length>1e3||i.indexOf("\n")>-1?n.value=t.prevInput="":t.prevInput=i,t.composing&&(t.composing.range.clear(),t.composing.range=e.markText(t.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))})),!0},Va.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},Va.prototype.onKeyPress=function(){a&&s>=9&&(this.hasSelection=null),this.fastPoll()},Va.prototype.onContextMenu=function(t){var e=this,n=e.cm,r=n.display,i=e.textarea;e.contextMenuPending&&e.contextMenuPending();var o=lr(n,t),l=r.scroller.scrollTop;if(o&&!h){n.options.resetSelectionOnContextMenu&&-1==n.doc.sel.contains(o)&&ti(n,Ji)(n.doc,Ci(o),H);var u,f=i.style.cssText,p=e.wrapper.style.cssText,d=e.wrapper.offsetParent.getBoundingClientRect();if(e.wrapper.style.cssText="position: static",i.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(t.clientY-d.top-5)+"px; left: "+(t.clientX-d.left-5)+"px;\n z-index: 1000; background: "+(a?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",c&&(u=window.scrollY),r.input.focus(),c&&window.scrollTo(null,u),r.input.reset(),n.somethingSelected()||(i.value=e.prevInput=" "),e.contextMenuPending=v,r.selForContextMenu=n.doc.sel,clearTimeout(r.detectingSelectAll),a&&s>=9&&g(),x){St(t);var m=function(){pt(window,"mouseup",m),setTimeout(v,20)};ht(window,"mouseup",m)}else setTimeout(v,50)}function g(){if(null!=i.selectionStart){var t=n.somethingSelected(),o=""+(t?i.value:"");i.value="⇚",i.value=o,e.prevInput=t?"":"",i.selectionStart=1,i.selectionEnd=o.length,r.selForContextMenu=n.doc.sel}}function v(){if(e.contextMenuPending==v&&(e.contextMenuPending=!1,e.wrapper.style.cssText=p,i.style.cssText=f,a&&s<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=l),null!=i.selectionStart)){(!a||a&&s<9)&&g();var t=0,o=function(){r.selForContextMenu==n.doc.sel&&0==i.selectionStart&&i.selectionEnd>0&&""==e.prevInput?ti(n,so)(n):t++<10?r.detectingSelectAll=setTimeout(o,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(o,200)}}},Va.prototype.readOnlyChanged=function(t){t||this.reset(),this.textarea.disabled="nocursor"==t,this.textarea.readOnly=!!t},Va.prototype.setUneditable=function(){},Va.prototype.needsContentAttribute=!1,function(t){var e=t.optionHandlers;function n(n,r,i,o){t.defaults[n]=r,i&&(e[n]=o?function(t,e,n){n!=Sa&&i(t,e,n)}:i)}t.defineOption=n,t.Init=Sa,n("value","",(function(t,e){return t.setValue(e)}),!0),n("mode",null,(function(t,e){t.doc.modeOption=e,Ai(t)}),!0),n("indentUnit",2,Ai,!0),n("indentWithTabs",!1),n("smartIndent",!0),n("tabSize",4,(function(t){Ii(t),Wn(t),hr(t)}),!0),n("lineSeparator",null,(function(t,e){if(t.doc.lineSep=e,e){var n=[],r=t.doc.first;t.doc.iter((function(t){for(var i=0;;){var o=t.text.indexOf(e,i);if(-1==o)break;i=o+e.length,n.push(te(r,o))}r++}));for(var i=n.length-1;i>=0;i--)mo(t.doc,e,n[i],te(n[i].line,n[i].ch+e.length))}})),n("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200c\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,(function(t,e,n){t.state.specialChars=new RegExp(e.source+(e.test("\t")?"":"|\t"),"g"),n!=Sa&&t.refresh()})),n("specialCharPlaceholder",Qe,(function(t){return t.refresh()}),!0),n("electricChars",!0),n("inputStyle",v?"contenteditable":"textarea",(function(){throw new Error("inputStyle can not (yet) be changed in a running editor")}),!0),n("spellcheck",!1,(function(t,e){return t.getInputField().spellcheck=e}),!0),n("autocorrect",!1,(function(t,e){return t.getInputField().autocorrect=e}),!0),n("autocapitalize",!1,(function(t,e){return t.getInputField().autocapitalize=e}),!0),n("rtlMoveVisually",!T),n("wholeLineUpdateBefore",!0),n("theme","default",(function(t){Oa(t),mi(t)}),!0),n("keyMap","default",(function(t,e,n){var r=qo(e),i=n!=Sa&&qo(n);i&&i.detach&&i.detach(t,r),r.attach&&r.attach(t,i||null)})),n("extraKeys",null),n("configureMouse",null),n("lineWrapping",!1,ka,!0),n("gutters",[],(function(t,e){t.display.gutterSpecs=pi(e,t.options.lineNumbers),mi(t)}),!0),n("fixedGutter",!0,(function(t,e){t.display.gutters.style.left=e?ar(t.display)+"px":"0",t.refresh()}),!0),n("coverGutterNextToScrollbar",!1,(function(t){return Br(t)}),!0),n("scrollbarStyle","native",(function(t){zr(t),Br(t),t.display.scrollbars.setScrollTop(t.doc.scrollTop),t.display.scrollbars.setScrollLeft(t.doc.scrollLeft)}),!0),n("lineNumbers",!1,(function(t,e){t.display.gutterSpecs=pi(t.options.gutters,e),mi(t)}),!0),n("firstLineNumber",1,mi,!0),n("lineNumberFormatter",(function(t){return t}),mi,!0),n("showCursorWhenSelecting",!1,gr,!0),n("resetSelectionOnContextMenu",!0),n("lineWiseCopyCut",!0),n("pasteLinesPerSelection",!0),n("selectionsMayTouch",!1),n("readOnly",!1,(function(t,e){"nocursor"==e&&(Cr(t),t.display.input.blur()),t.display.input.readOnlyChanged(e)})),n("screenReaderLabel",null,(function(t,e){e=""===e?null:e,t.display.input.screenReaderLabelChanged(e)})),n("disableInput",!1,(function(t,e){e||t.display.input.reset()}),!0),n("dragDrop",!0,Ca),n("allowDropFileTypes",null),n("cursorBlinkRate",530),n("cursorScrollMargin",0),n("cursorHeight",1,gr,!0),n("singleCursorHeightPerLine",!0,gr,!0),n("workTime",100),n("workDelay",100),n("flattenSpans",!0,Ii,!0),n("addModeClass",!1,Ii,!0),n("pollInterval",100),n("undoDepth",200,(function(t,e){return t.doc.history.undoDepth=e})),n("historyEventDelay",1250),n("viewportMargin",10,(function(t){return t.refresh()}),!0),n("maxHighlightLength",1e4,Ii,!0),n("moveInputWithCursor",!0,(function(t,e){e||t.display.input.resetPosition()})),n("tabindex",null,(function(t,e){return t.display.input.getField().tabIndex=e||""})),n("autofocus",null),n("direction","ltr",(function(t,e){return t.doc.setDirection(e)}),!0),n("phrases",null)}(wa),function(t){var e=t.optionHandlers,n=t.helpers={};t.prototype={constructor:t,focus:function(){window.focus(),this.display.input.focus()},setOption:function(t,n){var r=this.options,i=r[t];r[t]==n&&"mode"!=t||(r[t]=n,e.hasOwnProperty(t)&&ti(this,e[t])(this,n,i),dt(this,"optionChange",this,t))},getOption:function(t){return this.options[t]},getDoc:function(){return this.doc},addKeyMap:function(t,e){this.state.keyMaps[e?"push":"unshift"](qo(t))},removeKeyMap:function(t){for(var e=this.state.keyMaps,n=0;n<e.length;++n)if(e[n]==t||e[n].name==t)return e.splice(n,1),!0},addOverlay:ei((function(e,n){var r=e.token?e:t.getMode(this.options,e);if(r.startState)throw new Error("Overlays may not be stateful.");!function(t,e,n){for(var r=0,i=n(e);r<t.length&&n(t[r])<=i;)r++;t.splice(r,0,e)}(this.state.overlays,{mode:r,modeSpec:e,opaque:n&&n.opaque,priority:n&&n.priority||0},(function(t){return t.priority})),this.state.modeGen++,hr(this)})),removeOverlay:ei((function(t){for(var e=this.state.overlays,n=0;n<e.length;++n){var r=e[n].modeSpec;if(r==t||"string"==typeof t&&r.name==t)return e.splice(n,1),this.state.modeGen++,void hr(this)}})),indentLine:ei((function(t,e,n){"string"!=typeof e&&"number"!=typeof e&&(e=null==e?this.options.smartIndent?"smart":"prev":e?"add":"subtract"),Qt(this.doc,t)&&La(this,t,e,n)})),indentSelection:ei((function(t){for(var e=this.doc.sel.ranges,n=-1,r=0;r<e.length;r++){var i=e[r];if(i.empty())i.head.line>n&&(La(this,i.head.line,t,!0),n=i.head.line,r==this.doc.sel.primIndex&&Ir(this));else{var o=i.from(),a=i.to(),s=Math.max(n,o.line);n=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var c=s;c<n;++c)La(this,c,t);var l=this.doc.sel.ranges;0==o.ch&&e.length==l.length&&l[r].from().ch>0&&qi(this.doc,r,new xi(o,l[r].to()),H)}}})),getTokenAt:function(t,e){return ye(this,t,e)},getLineTokens:function(t,e){return ye(this,te(t),e,!0)},getTokenTypeAt:function(t){t=se(this.doc,t);var e,n=fe(this,Kt(this.doc,t.line)),r=0,i=(n.length-1)/2,o=t.ch;if(0==o)e=n[2];else for(;;){var a=r+i>>1;if((a?n[2*a-1]:0)>=o)i=a;else{if(!(n[2*a+1]<o)){e=n[2*a+2];break}r=a+1}}var s=e?e.indexOf("overlay "):-1;return s<0?e:0==s?null:e.slice(0,s-1)},getModeAt:function(e){var n=this.doc.mode;return n.innerMode?t.innerMode(n,this.getTokenAt(e).state).mode:n},getHelper:function(t,e){return this.getHelpers(t,e)[0]},getHelpers:function(t,e){var r=[];if(!n.hasOwnProperty(e))return r;var i=n[e],o=this.getModeAt(t);if("string"==typeof o[e])i[o[e]]&&r.push(i[o[e]]);else if(o[e])for(var a=0;a<o[e].length;a++){var s=i[o[e][a]];s&&r.push(s)}else o.helperType&&i[o.helperType]?r.push(i[o.helperType]):i[o.name]&&r.push(i[o.name]);for(var c=0;c<i._global.length;c++){var l=i._global[c];l.pred(o,this)&&-1==W(r,l.val)&&r.push(l.val)}return r},getStateAfter:function(t,e){var n=this.doc;return pe(this,(t=ae(n,null==t?n.first+n.size-1:t))+1,e).state},cursorCoords:function(t,e){var n=this.doc.sel.primary();return Yn(this,null==t?n.head:"object"==typeof t?se(this.doc,t):t?n.from():n.to(),e||"page")},charCoords:function(t,e){return Kn(this,se(this.doc,t),e||"page")},coordsChar:function(t,e){return qn(this,(t=Vn(this,t,e||"page")).left,t.top)},lineAtHeight:function(t,e){return t=Vn(this,{top:t,left:0},e||"page").top,Zt(this.doc,t+this.display.viewOffset)},heightAtLine:function(t,e,n){var r,i=!1;if("number"==typeof t){var o=this.doc.first+this.doc.size-1;t<this.doc.first?t=this.doc.first:t>o&&(t=o,i=!0),r=Kt(this.doc,t)}else r=t;return zn(this,r,{top:0,left:0},e||"page",n||i).top+(i?this.doc.height-Ge(r):0)},defaultTextHeight:function(){return rr(this.display)},defaultCharWidth:function(){return ir(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(t,e,n,r,i){var o,a,s,c=this.display,l=(t=Yn(this,se(this.doc,t))).bottom,u=t.left;if(e.style.position="absolute",e.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(e),c.sizer.appendChild(e),"over"==r)l=t.top;else if("above"==r||"near"==r){var h=Math.max(c.wrapper.clientHeight,this.doc.height),f=Math.max(c.sizer.clientWidth,c.lineSpace.clientWidth);("above"==r||t.bottom+e.offsetHeight>h)&&t.top>e.offsetHeight?l=t.top-e.offsetHeight:t.bottom+e.offsetHeight<=h&&(l=t.bottom),u+e.offsetWidth>f&&(u=f-e.offsetWidth)}e.style.top=l+"px",e.style.left=e.style.right="","right"==i?(u=c.sizer.clientWidth-e.offsetWidth,e.style.right="0px"):("left"==i?u=0:"middle"==i&&(u=(c.sizer.clientWidth-e.offsetWidth)/2),e.style.left=u+"px"),n&&(o=this,a={left:u,top:l,right:u+e.offsetWidth,bottom:l+e.offsetHeight},null!=(s=Lr(o,a)).scrollTop&&Pr(o,s.scrollTop),null!=s.scrollLeft&&Dr(o,s.scrollLeft))},triggerOnKeyDown:ei(ua),triggerOnKeyPress:ei(fa),triggerOnKeyUp:ha,triggerOnMouseDown:ei(ga),execCommand:function(t){if(ea.hasOwnProperty(t))return ea[t].call(null,this)},triggerElectric:ei((function(t){_a(this,t)})),findPosH:function(t,e,n,r){var i=1;e<0&&(i=-1,e=-e);for(var o=se(this.doc,t),a=0;a<e&&!(o=Fa(this.doc,o,i,n,r)).hitSide;++a);return o},moveH:ei((function(t,e){var n=this;this.extendSelectionsBy((function(r){return n.display.shift||n.doc.extend||r.empty()?Fa(n.doc,r.head,t,e,n.options.rtlMoveVisually):t<0?r.from():r.to()}),z)})),deleteH:ei((function(t,e){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):Zo(this,(function(n){var i=Fa(r,n.head,t,e,!1);return t<0?{from:i,to:n.head}:{from:n.head,to:i}}))})),findPosV:function(t,e,n,r){var i=1,o=r;e<0&&(i=-1,e=-e);for(var a=se(this.doc,t),s=0;s<e;++s){var c=Yn(this,a,"div");if(null==o?o=c.left:c.left=o,(a=Ua(this,c,i,n)).hitSide)break}return a},moveV:ei((function(t,e){var n=this,r=this.doc,i=[],o=!this.display.shift&&!r.extend&&r.sel.somethingSelected();if(r.extendSelectionsBy((function(a){if(o)return t<0?a.from():a.to();var s=Yn(n,a.head,"div");null!=a.goalColumn&&(s.left=a.goalColumn),i.push(s.left);var c=Ua(n,s,t,e);return"page"==e&&a==r.sel.primary()&&Ar(n,Kn(n,c,"div").top-s.top),c}),z),i.length)for(var a=0;a<r.sel.ranges.length;a++)r.sel.ranges[a].goalColumn=i[a]})),findWordAt:function(t){var e=Kt(this.doc,t.line).text,n=t.ch,r=t.ch;if(e){var i=this.getHelper(t,"wordChars");"before"!=t.sticky&&r!=e.length||!n?++r:--n;for(var o=e.charAt(n),a=tt(o,i)?function(t){return tt(t,i)}:/\s/.test(o)?function(t){return/\s/.test(t)}:function(t){return!/\s/.test(t)&&!tt(t)};n>0&&a(e.charAt(n-1));)--n;for(;r<e.length&&a(e.charAt(r));)++r}return new xi(te(t.line,n),te(t.line,r))},toggleOverwrite:function(t){null!=t&&t==this.state.overwrite||((this.state.overwrite=!this.state.overwrite)?M(this.display.cursorDiv,"CodeMirror-overwrite"):k(this.display.cursorDiv,"CodeMirror-overwrite"),dt(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==R()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:ei((function(t,e){Rr(this,t,e)})),getScrollInfo:function(){var t=this.display.scroller;return{left:t.scrollLeft,top:t.scrollTop,height:t.scrollHeight-kn(this)-this.display.barHeight,width:t.scrollWidth-kn(this)-this.display.barWidth,clientHeight:Nn(this),clientWidth:wn(this)}},scrollIntoView:ei((function(t,e){null==t?(t={from:this.doc.sel.primary().head,to:null},null==e&&(e=this.options.cursorScrollMargin)):"number"==typeof t?t={from:te(t,0),to:null}:null==t.from&&(t={from:t,to:null}),t.to||(t.to=t.from),t.margin=e||0,null!=t.from.line?function(t,e){Mr(t),t.curOp.scrollToPos=e}(this,t):_r(this,t.from,t.to,t.margin)})),setSize:ei((function(t,e){var n=this,r=function(t){return"number"==typeof t||/^\d+$/.test(String(t))?t+"px":t};null!=t&&(this.display.wrapper.style.width=r(t)),null!=e&&(this.display.wrapper.style.height=r(e)),this.options.lineWrapping&&Un(this);var i=this.display.viewFrom;this.doc.iter(i,this.display.viewTo,(function(t){if(t.widgets)for(var e=0;e<t.widgets.length;e++)if(t.widgets[e].noHScroll){fr(n,i,"widget");break}++i})),this.curOp.forceUpdate=!0,dt(this,"refresh",this)})),operation:function(t){return Jr(this,t)},startOperation:function(){return Kr(this)},endOperation:function(){return Yr(this)},refresh:ei((function(){var t=this.display.cachedTextHeight;hr(this),this.curOp.forceUpdate=!0,Wn(this),Rr(this,this.doc.scrollLeft,this.doc.scrollTop),li(this.display),(null==t||Math.abs(t-rr(this.display))>.5||this.options.lineWrapping)&&cr(this),dt(this,"refresh",this)})),swapDoc:ei((function(t){var e=this.doc;return e.cm=null,this.state.selectingText&&this.state.selectingText(),Pi(this,t),Wn(this),this.display.input.reset(),Rr(this,t.scrollLeft,t.scrollTop),this.curOp.forceScroll=!0,cn(this,"swapDoc",this,e),e})),phrase:function(t){var e=this.options.phrases;return e&&Object.prototype.hasOwnProperty.call(e,t)?e[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}},yt(t),t.registerHelper=function(e,r,i){n.hasOwnProperty(e)||(n[e]=t[e]={_global:[]}),n[e][r]=i},t.registerGlobalHelper=function(e,r,i,o){t.registerHelper(e,r,o),n[e]._global.push({pred:i,val:o})}}(wa);var Ka="iter insert remove copy getEditor constructor".split(" ");for(var Ya in Io.prototype)Io.prototype.hasOwnProperty(Ya)&&W(Ka,Ya)<0&&(wa.prototype[Ya]=function(t){return function(){return t.apply(this.doc,arguments)}}(Io.prototype[Ya]));return yt(Io),wa.inputStyles={textarea:Va,contenteditable:Wa},wa.defineMode=function(t){wa.defaults.mode||"null"==t||(wa.defaults.mode=t),Dt.apply(this,arguments)},wa.defineMIME=function(t,e){jt[t]=e},wa.defineMode("null",(function(){return{token:function(t){return t.skipToEnd()}}})),wa.defineMIME("text/plain","null"),wa.defineExtension=function(t,e){wa.prototype[t]=e},wa.defineDocExtension=function(t,e){Io.prototype[t]=e},wa.fromTextArea=function(t,e){if((e=e?D(e):{}).value=t.value,!e.tabindex&&t.tabIndex&&(e.tabindex=t.tabIndex),!e.placeholder&&t.placeholder&&(e.placeholder=t.placeholder),null==e.autofocus){var n=R();e.autofocus=n==t||null!=t.getAttribute("autofocus")&&n==document.body}function r(){t.value=s.getValue()}var i;if(t.form&&(ht(t.form,"submit",r),!e.leaveSubmitMethodAlone)){var o=t.form;i=o.submit;try{var a=o.submit=function(){r(),o.submit=i,o.submit(),o.submit=a}}catch(t){}}e.finishInit=function(n){n.save=r,n.getTextArea=function(){return t},n.toTextArea=function(){n.toTextArea=isNaN,r(),t.parentNode.removeChild(n.getWrapperElement()),t.style.display="",t.form&&(pt(t.form,"submit",r),e.leaveSubmitMethodAlone||"function"!=typeof t.form.submit||(t.form.submit=i))}},t.style.display="none";var s=wa((function(e){return t.parentNode.insertBefore(e,t.nextSibling)}),e);return s},function(t){t.off=pt,t.on=ht,t.wheelEventPixels=Ti,t.Doc=Io,t.splitLines=It,t.countColumn=F,t.findColumn=V,t.isWordChar=J,t.Pass=B,t.signal=dt,t.Line=Ke,t.changeEnd=ki,t.scrollbarModel=Gr,t.Pos=te,t.cmpPos=ee,t.modes=Pt,t.mimeModes=jt,t.resolveMode=Ft,t.getMode=Ut,t.modeExtensions=Wt,t.extendMode=Bt,t.copyState=Ht,t.startState=zt,t.innerMode=Gt,t.commands=ea,t.keyMap=Go,t.keyName=$o,t.isModifierKey=Yo,t.lookupKey=Ko,t.normalizeKeyMap=Vo,t.StringStream=Vt,t.SharedTextMarker=wo,t.TextMarker=Co,t.LineWidget=So,t.e_preventDefault=bt,t.e_stopPropagation=Tt,t.e_stop=St,t.addClass=M,t.contains=I,t.rmClass=k,t.keyNames=Uo}(wa),wa.version="5.58.2",wa}()},function(t,e,n){"use strict";n.r(e),n.d(e,"VERSION",(function(){return r})),n.d(e,"CstParser",(function(){return nn})),n.d(e,"EmbeddedActionsParser",(function(){return rn})),n.d(e,"ParserDefinitionErrorType",(function(){return Ze})),n.d(e,"EMPTY_ALT",(function(){return tn})),n.d(e,"Lexer",(function(){return X})),n.d(e,"LexerDefinitionErrorType",(function(){return V})),n.d(e,"createToken",(function(){return Q})),n.d(e,"createTokenInstance",(function(){return tt})),n.d(e,"EOF",(function(){return J})),n.d(e,"tokenLabel",(function(){return $})),n.d(e,"tokenMatcher",(function(){return et})),n.d(e,"tokenName",(function(){return q})),n.d(e,"defaultGrammarResolverErrorProvider",(function(){return Lt})),n.d(e,"defaultGrammarValidatorErrorProvider",(function(){return At})),n.d(e,"defaultParserErrorProvider",(function(){return Nt})),n.d(e,"EarlyExitException",(function(){return ve})),n.d(e,"isRecognitionException",(function(){return pe})),n.d(e,"MismatchedTokenException",(function(){return de})),n.d(e,"NotAllInputParsedException",(function(){return ge})),n.d(e,"NoViableAltException",(function(){return me})),n.d(e,"defaultLexerErrorProvider",(function(){return K})),n.d(e,"Alternation",(function(){return ft})),n.d(e,"Alternative",(function(){return at})),n.d(e,"NonTerminal",(function(){return it})),n.d(e,"Option",(function(){return st})),n.d(e,"Repetition",(function(){return ut})),n.d(e,"RepetitionMandatory",(function(){return ct})),n.d(e,"RepetitionMandatoryWithSeparator",(function(){return lt})),n.d(e,"RepetitionWithSeparator",(function(){return ht})),n.d(e,"Rule",(function(){return ot})),n.d(e,"Terminal",(function(){return pt})),n.d(e,"serializeGrammar",(function(){return dt})),n.d(e,"serializeProduction",(function(){return mt})),n.d(e,"GAstVisitor",(function(){return yt})),n.d(e,"assignOccurrenceIndices",(function(){return he})),n.d(e,"resolveGrammar",(function(){return le})),n.d(e,"validateGrammar",(function(){return ue})),n.d(e,"clearCache",(function(){return gn})),n.d(e,"createSyntaxDiagramsCode",(function(){return on})),n.d(e,"generateParserFactory",(function(){return dn})),n.d(e,"generateParserModule",(function(){return mn})),n.d(e,"Parser",(function(){return vn}));var r="7.0.3",i=n(0),o=n(1),a={},s=new o.RegExpParser;function c(t){var e=t.toString();if(a.hasOwnProperty(e))return a[e];var n=s.pattern(e);return a[e]=n,n}var l,u=(l=function(t,e){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),h='Unable to use "first char" lexer optimizations:\n';function f(t,e){void 0===e&&(e=!1);try{var n=c(t);return function t(e,n,r){switch(e.type){case"Disjunction":for(var o=0;o<e.value.length;o++)t(e.value[o],n,r);break;case"Alternative":var a=e.value;for(o=0;o<a.length;o++){var s=a[o];switch(s.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var c=s;switch(c.type){case"Character":p(c.value,n,r);break;case"Set":if(!0===c.complement)throw Error("Complement Sets are not supported for first char optimization");Object(i.u)(c.value,(function(t){if("number"==typeof t)p(t,n,r);else{var e=t;if(!0===r)for(var i=e.from;i<=e.to;i++)p(i,n,r);else{for(i=e.from;i<=e.to&&i<_;i++)p(i,n,r);if(e.to>=_)for(var o=e.from>=_?e.from:_,a=e.to,s=P(o),c=P(a),l=s;l<=c;l++)n[l]=l}}}));break;case"Group":t(c.value,n,r);break;default:throw Error("Non Exhaustive Match")}var l=void 0!==c.quantifier&&0===c.quantifier.atLeast;if("Group"===c.type&&!1===m(c)||"Group"!==c.type&&!1===l)break}break;default:throw Error("non exhaustive match!")}return Object(i.U)(n)}(n.value,{},n.flags.ignoreCase)}catch(n){if("Complement Sets are not supported for first char optimization"===n.message)e&&Object(i.d)(h+"\tUnable to optimize: < "+t.toString()+" >\n\tComplement Sets cannot be automatically optimized.\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.");else{var r="";e&&(r="\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),Object(i.c)(h+"\n\tFailed parsing: < "+t.toString()+" >\n\tUsing the regexp-to-ast library version: "+o.VERSION+"\n\tPlease open an issue at: https://github.com/bd82/regexp-to-ast/issues"+r)}}return[]}function p(t,e,n){var r=P(t);e[r]=r,!0===n&&function(t,e){var n=String.fromCharCode(t),r=n.toUpperCase();if(r!==n){var i=P(r.charCodeAt(0));e[i]=i}else{var o=n.toLowerCase();if(o!==n){i=P(o.charCodeAt(0));e[i]=i}}}(t,e)}function d(t,e){return Object(i.q)(t.value,(function(t){if("number"==typeof t)return Object(i.j)(e,t);var n=t;return void 0!==Object(i.q)(e,(function(t){return n.from<=t&&t<=n.to}))}))}function m(t){return!(!t.quantifier||0!==t.quantifier.atLeast)||!!t.value&&(Object(i.y)(t.value)?Object(i.o)(t.value,m):m(t.value))}var g=function(t){function e(e){var n=t.call(this)||this;return n.targetCharCodes=e,n.found=!1,n}return u(e,t),e.prototype.visitChildren=function(e){if(!0!==this.found){switch(e.type){case"Lookahead":return void this.visitLookahead(e);case"NegativeLookahead":return void this.visitNegativeLookahead(e)}t.prototype.visitChildren.call(this,e)}},e.prototype.visitCharacter=function(t){Object(i.j)(this.targetCharCodes,t.value)&&(this.found=!0)},e.prototype.visitSet=function(t){t.complement?void 0===d(t,this.targetCharCodes)&&(this.found=!0):void 0!==d(t,this.targetCharCodes)&&(this.found=!0)},e}(o.BaseRegExpVisitor);function v(t,e){if(e instanceof RegExp){var n=c(e),r=new g(t);return r.visit(n),r.found}return void 0!==Object(i.q)(e,(function(e){return Object(i.j)(t,e.charCodeAt(0))}))}var y=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),b="PATTERN",T="boolean"==typeof new RegExp("(?:)").sticky;function O(t,e){var n,r=(e=Object(i.k)(e,{useSticky:T,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:function(t,e){return e()}})).tracer;r("initCharCodeToOptimizedIndexMap",(function(){!function(){if(Object(i.A)(j)){j=new Array(65536);for(var t=0;t<65536;t++)j[t]=t>255?255+~~(t/255):t}}()})),r("Reject Lexer.NA",(function(){n=Object(i.P)(t,(function(t){return t[b]===X.NA}))}));var o,a,s,c,l,u,p,d,m,g,y,O=!1;r("Transform Patterns",(function(){O=!1,o=Object(i.I)(n,(function(t){var n=t[b];if(Object(i.D)(n)){var r=n.source;return 1!==r.length||"^"===r||"$"===r||"."===r||n.ignoreCase?2!==r.length||"\\"!==r[0]||Object(i.j)(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],r[1])?e.useSticky?k(n):C(n):r[1]:r}if(Object(i.B)(n))return O=!0,{exec:n};if(Object(i.w)(n,"exec"))return O=!0,n;if("string"==typeof n){if(1===n.length)return n;var o=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),a=new RegExp(o);return e.useSticky?k(a):C(a)}throw Error("non exhaustive match")}))})),r("misc mapping",(function(){a=Object(i.I)(n,(function(t){return t.tokenTypeIdx})),s=Object(i.I)(n,(function(t){var e=t.GROUP;if(e!==X.SKIPPED){if(Object(i.E)(e))return e;if(Object(i.F)(e))return!1;throw Error("non exhaustive match")}})),c=Object(i.I)(n,(function(t){var e=t.LONGER_ALT;if(e)return Object(i.x)(n,e)})),l=Object(i.I)(n,(function(t){return t.PUSH_MODE})),u=Object(i.I)(n,(function(t){return Object(i.w)(t,"POP_MODE")}))})),r("Line Terminator Handling",(function(){var t=R(e.lineTerminatorCharacters);p=Object(i.I)(n,(function(t){return!1})),"onlyOffset"!==e.positionTracking&&(p=Object(i.I)(n,(function(e){return Object(i.w)(e,"LINE_BREAKS")?e.LINE_BREAKS:!1===I(e,t)?v(t,e.PATTERN):void 0})))})),r("Misc Mapping #2",(function(){d=Object(i.I)(n,N),m=Object(i.I)(o,L),g=Object(i.O)(n,(function(t,e){var n=e.GROUP;return Object(i.E)(n)&&n!==X.SKIPPED&&(t[n]=[]),t}),{}),y=Object(i.I)(o,(function(t,e){return{pattern:o[e],longerAlt:c[e],canLineTerminator:p[e],isCustom:d[e],short:m[e],group:s[e],push:l[e],pop:u[e],tokenTypeIdx:a[e],tokenType:n[e]}}))}));var S=!0,x=[];return e.safeMode||r("First Char Optimization",(function(){x=Object(i.O)(n,(function(t,n,r){if("string"==typeof n.PATTERN){var o=P(n.PATTERN.charCodeAt(0));M(t,o,y[r])}else if(Object(i.y)(n.START_CHARS_HINT)){var a;Object(i.u)(n.START_CHARS_HINT,(function(e){var n=P("string"==typeof e?e.charCodeAt(0):e);a!==n&&(a=n,M(t,n,y[r]))}))}else if(Object(i.D)(n.PATTERN))if(n.PATTERN.unicode)S=!1,e.ensureOptimizations&&Object(i.c)(h+"\tUnable to analyze < "+n.PATTERN.toString()+" > pattern.\n\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE");else{var s=f(n.PATTERN,e.ensureOptimizations);Object(i.A)(s)&&(S=!1),Object(i.u)(s,(function(e){M(t,e,y[r])}))}else e.ensureOptimizations&&Object(i.c)(h+"\tTokenType: <"+n.name+"> is using a custom token pattern without providing <start_chars_hint> parameter.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE"),S=!1;return t}),[])})),r("ArrayPacking",(function(){x=Object(i.L)(x)})),{emptyGroups:g,patternIdxToConfig:y,charCodeToPatternIdxToConfig:x,hasCustom:O,canBeOptimized:S}}function S(t,e){var n=[],r=function(t){var e=Object(i.p)(t,(function(t){return!Object(i.w)(t,b)})),n=Object(i.I)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- missing static 'PATTERN' property",type:V.MISSING_PATTERN,tokenTypes:[t]}})),r=Object(i.l)(t,e);return{errors:n,valid:r}}(t);n=n.concat(r.errors);var a=function(t){var e=Object(i.p)(t,(function(t){var e=t[b];return!(Object(i.D)(e)||Object(i.B)(e)||Object(i.w)(e,"exec")||Object(i.E)(e))})),n=Object(i.I)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:V.INVALID_PATTERN,tokenTypes:[t]}})),r=Object(i.l)(t,e);return{errors:n,valid:r}}(r.valid),s=a.valid;return n=(n=(n=(n=(n=n.concat(a.errors)).concat(function(t){var e=[],n=Object(i.p)(t,(function(t){return Object(i.D)(t[b])}));return e=(e=(e=(e=(e=e.concat(function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.found=!1,e}return y(e,t),e.prototype.visitEndAnchor=function(t){this.found=!0},e}(o.BaseRegExpVisitor),n=Object(i.p)(t,(function(t){var n=t[b];try{var r=c(n),i=new e;return i.visit(r),i.found}catch(t){return x.test(n.source)}}));return Object(i.I)(n,(function(t){return{message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+t.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n\tSee sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:V.EOI_ANCHOR_FOUND,tokenTypes:[t]}}))}(n))).concat(function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.found=!1,e}return y(e,t),e.prototype.visitStartAnchor=function(t){this.found=!0},e}(o.BaseRegExpVisitor),n=Object(i.p)(t,(function(t){var n=t[b];try{var r=c(n),i=new e;return i.visit(r),i.found}catch(t){return E.test(n.source)}}));return Object(i.I)(n,(function(t){return{message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+t.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n\tSee https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:V.SOI_ANCHOR_FOUND,tokenTypes:[t]}}))}(n))).concat(function(t){var e=Object(i.p)(t,(function(t){var e=t[b];return e instanceof RegExp&&(e.multiline||e.global)}));return Object(i.I)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:V.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[t]}}))}(n))).concat(function(t){var e=[],n=Object(i.I)(t,(function(n){return Object(i.O)(t,(function(t,r){return n.PATTERN.source!==r.PATTERN.source||Object(i.j)(e,r)||r.PATTERN===X.NA||(e.push(r),t.push(r)),t}),[])}));n=Object(i.i)(n);var r=Object(i.p)(n,(function(t){return t.length>1}));return Object(i.I)(r,(function(t){var e=Object(i.I)(t,(function(t){return t.name}));return{message:"The same RegExp pattern ->"+Object(i.s)(t).PATTERN+"<-has been used in all of the following Token Types: "+e.join(", ")+" <-",type:V.DUPLICATE_PATTERNS_FOUND,tokenTypes:t}}))}(n))).concat(function(t){var e=Object(i.p)(t,(function(t){return t[b].test("")}));return Object(i.I)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PATTERN' must not match an empty string",type:V.EMPTY_MATCH_PATTERN,tokenTypes:[t]}}))}(n))}(s))).concat(function(t){var e=Object(i.p)(t,(function(t){if(!Object(i.w)(t,"GROUP"))return!1;var e=t.GROUP;return e!==X.SKIPPED&&e!==X.NA&&!Object(i.E)(e)}));return Object(i.I)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:V.INVALID_GROUP_TYPE_FOUND,tokenTypes:[t]}}))}(s))).concat(function(t,e){var n=Object(i.p)(t,(function(t){return void 0!==t.PUSH_MODE&&!Object(i.j)(e,t.PUSH_MODE)}));return Object(i.I)(n,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+t.PUSH_MODE+"<-which does not exist",type:V.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[t]}}))}(s,e))).concat(function(t){var e=[],n=Object(i.O)(t,(function(t,e,n){var r,o=e.PATTERN;return o===X.NA||(Object(i.E)(o)?t.push({str:o,idx:n,tokenType:e}):Object(i.D)(o)&&(r=o,void 0===Object(i.q)([".","\\","[","]","|","^","$","(",")","?","*","+","{"],(function(t){return-1!==r.source.indexOf(t)})))&&t.push({str:o.source,idx:n,tokenType:e})),t}),[]);return Object(i.u)(t,(function(t,r){Object(i.u)(n,(function(n){var o=n.str,a=n.idx,s=n.tokenType;if(r<a&&function(t,e){if(Object(i.D)(e)){var n=e.exec(t);return null!==n&&0===n.index}if(Object(i.B)(e))return e(t,0,[],{});if(Object(i.w)(e,"exec"))return e.exec(t,0,[],{});if("string"==typeof e)return e===t;throw Error("non exhaustive match")}(o,t.PATTERN)){var c="Token: ->"+s.name+"<- can never be matched.\nBecause it appears AFTER the Token Type ->"+t.name+"<-in the lexer's definition.\nSee https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#UNREACHABLE";e.push({message:c,type:V.UNREACHABLE_PATTERN,tokenTypes:[t,s]})}}))})),e}(s))}var x=/[^\\][\$]/;var E=/[^\\[][\^]|^\^/;function C(t){var e=t.ignoreCase?"i":"";return new RegExp("^(?:"+t.source+")",e)}function k(t){var e=t.ignoreCase?"iy":"y";return new RegExp(""+t.source,e)}function w(t,e,n){var r=[],o=!1,a=Object(i.i)(Object(i.t)(Object(i.J)(t.modes,(function(t){return t})))),s=Object(i.P)(a,(function(t){return t[b]===X.NA})),c=R(n);return e&&Object(i.u)(s,(function(t){var e=I(t,c);if(!1!==e){var n={message:function(t,e){if(e.issue===V.IDENTIFY_TERMINATOR)return"Warning: unable to identify line terminator usage in pattern.\n\tThe problem is in the <"+t.name+"> Token Type\n\t Root cause: "+e.errMsg+".\n\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(e.issue===V.CUSTOM_LINE_BREAK)return"Warning: A Custom Token Pattern should specify the <line_breaks> option.\n\tThe problem is in the <"+t.name+"> Token Type\n\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}(t,e),type:e.issue,tokenType:t};r.push(n)}else Object(i.w)(t,"LINE_BREAKS")?!0===t.LINE_BREAKS&&(o=!0):v(c,t.PATTERN)&&(o=!0)})),e&&!o&&r.push({message:"Warning: No LINE_BREAKS Found.\n\tThis Lexer has been defined to track line and column information,\n\tBut none of the Token Types can be identified as matching a line terminator.\n\tSee https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n\tfor details.",type:V.NO_LINE_BREAKS_FLAGS}),r}function N(t){var e=t.PATTERN;if(Object(i.D)(e))return!1;if(Object(i.B)(e))return!0;if(Object(i.w)(e,"exec"))return!0;if(Object(i.E)(e))return!1;throw Error("non exhaustive match")}function L(t){return!(!Object(i.E)(t)||1!==t.length)&&t.charCodeAt(0)}var A={test:function(t){for(var e=t.length,n=this.lastIndex;n<e;n++){var r=t.charCodeAt(n);if(10===r)return this.lastIndex=n+1,!0;if(13===r)return 10===t.charCodeAt(n+1)?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function I(t,e){if(Object(i.w)(t,"LINE_BREAKS"))return!1;if(Object(i.D)(t.PATTERN)){try{v(e,t.PATTERN)}catch(t){return{issue:V.IDENTIFY_TERMINATOR,errMsg:t.message}}return!1}if(Object(i.E)(t.PATTERN))return!1;if(N(t))return{issue:V.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function R(t){return Object(i.I)(t,(function(t){return Object(i.E)(t)&&t.length>0?t.charCodeAt(0):t}))}function M(t,e,n){void 0===t[e]?t[e]=[n]:t[e].push(n)}var _=256;function P(t){return t<_?t:j[t]}var j=[];function D(t,e){var n=t.tokenTypeIdx;return n===e.tokenTypeIdx||!0===e.isParent&&!0===e.categoryMatchesMap[n]}function F(t,e){return t.tokenTypeIdx===e.tokenTypeIdx}var U=1,W={};function B(t){var e=function(t){var e=Object(i.g)(t),n=t,r=!0;for(;r;){n=Object(i.i)(Object(i.t)(Object(i.I)(n,(function(t){return t.CATEGORIES}))));var o=Object(i.l)(n,e);e=e.concat(o),Object(i.A)(o)?r=!1:n=o}return e}(t);!function(t){Object(i.u)(t,(function(t){var e;H(t)||(W[U]=t,t.tokenTypeIdx=U++),G(t)&&!Object(i.y)(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),G(t)||(t.CATEGORIES=[]),e=t,Object(i.w)(e,"categoryMatches")||(t.categoryMatches=[]),function(t){return Object(i.w)(t,"categoryMatchesMap")}(t)||(t.categoryMatchesMap={})}))}(e),function(t){Object(i.u)(t,(function(t){!function t(e,n){Object(i.u)(e,(function(t){n.categoryMatchesMap[t.tokenTypeIdx]=!0})),Object(i.u)(n.CATEGORIES,(function(r){var o=e.concat(n);Object(i.j)(o,r)||t(o,r)}))}([],t)}))}(e),function(t){Object(i.u)(t,(function(t){t.categoryMatches=[],Object(i.u)(t.categoryMatchesMap,(function(e,n){t.categoryMatches.push(W[n].tokenTypeIdx)}))}))}(e),Object(i.u)(e,(function(t){t.isParent=t.categoryMatches.length>0}))}function H(t){return Object(i.w)(t,"tokenTypeIdx")}function G(t){return Object(i.w)(t,"CATEGORIES")}function z(t){return Object(i.w)(t,"tokenTypeIdx")}var V,K={buildUnableToPopLexerModeMessage:function(t){return"Unable to pop Lexer Mode after encountering Token ->"+t.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(t,e,n,r,i){return"unexpected character: ->"+t.charAt(e)+"<- at offset: "+e+", skipped "+n+" characters."}};!function(t){t[t.MISSING_PATTERN=0]="MISSING_PATTERN",t[t.INVALID_PATTERN=1]="INVALID_PATTERN",t[t.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",t[t.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",t[t.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",t[t.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",t[t.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",t[t.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",t[t.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",t[t.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",t[t.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",t[t.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",t[t.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",t[t.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",t[t.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",t[t.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",t[t.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK"}(V||(V={}));var Y={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:K,traceInitPerf:!1,skipValidations:!1};Object.freeze(Y);var X=function(){function t(t,e){var n=this;if(void 0===e&&(e=Y),this.lexerDefinition=t,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.config=void 0,this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},"boolean"==typeof e)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=Object(i.K)(Y,e);var r=this.config.traceInitPerf;!0===r?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof r&&(this.traceInitMaxIdent=r,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",(function(){var r,o=!0;n.TRACE_INIT("Lexer Config handling",(function(){if(n.config.lineTerminatorsPattern===Y.lineTerminatorsPattern)n.config.lineTerminatorsPattern=A;else if(n.config.lineTerminatorCharacters===Y.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS");if(e.safeMode&&e.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');n.trackStartLines=/full|onlyStart/i.test(n.config.positionTracking),n.trackEndLines=/full/i.test(n.config.positionTracking),Object(i.y)(t)?((r={modes:{}}).modes.defaultMode=Object(i.g)(t),r.defaultMode="defaultMode"):(o=!1,r=Object(i.h)(t))})),!1===n.config.skipValidations&&(n.TRACE_INIT("performRuntimeChecks",(function(){n.lexerDefinitionErrors=n.lexerDefinitionErrors.concat(function(t,e,n){var r=[];return Object(i.w)(t,"defaultMode")||r.push({message:"A MultiMode Lexer cannot be initialized without a <defaultMode> property in its definition\n",type:V.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),Object(i.w)(t,"modes")||r.push({message:"A MultiMode Lexer cannot be initialized without a <modes> property in its definition\n",type:V.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),Object(i.w)(t,"modes")&&Object(i.w)(t,"defaultMode")&&!Object(i.w)(t.modes,t.defaultMode)&&r.push({message:"A MultiMode Lexer cannot be initialized with a defaultMode: <"+t.defaultMode+">which does not exist\n",type:V.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),Object(i.w)(t,"modes")&&Object(i.u)(t.modes,(function(t,e){Object(i.u)(t,(function(t,n){Object(i.F)(t)&&r.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:<"+e+"> at index: <"+n+">\n",type:V.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})}))})),r}(r,n.trackStartLines,n.config.lineTerminatorCharacters))})),n.TRACE_INIT("performWarningRuntimeChecks",(function(){n.lexerDefinitionWarning=n.lexerDefinitionWarning.concat(w(r,n.trackStartLines,n.config.lineTerminatorCharacters))}))),r.modes=r.modes?r.modes:{},Object(i.u)(r.modes,(function(t,e){r.modes[e]=Object(i.P)(t,(function(t){return Object(i.F)(t)}))}));var s=Object(i.G)(r.modes);if(Object(i.u)(r.modes,(function(t,r){n.TRACE_INIT("Mode: <"+r+"> processing",(function(){var o;(n.modes.push(r),!1===n.config.skipValidations&&n.TRACE_INIT("validatePatterns",(function(){n.lexerDefinitionErrors=n.lexerDefinitionErrors.concat(S(t,s))})),Object(i.A)(n.lexerDefinitionErrors))&&(B(t),n.TRACE_INIT("analyzeTokenTypes",(function(){o=O(t,{lineTerminatorCharacters:n.config.lineTerminatorCharacters,positionTracking:e.positionTracking,ensureOptimizations:e.ensureOptimizations,safeMode:e.safeMode,tracer:n.TRACE_INIT.bind(n)})})),n.patternIdxToConfig[r]=o.patternIdxToConfig,n.charCodeToPatternIdxToConfig[r]=o.charCodeToPatternIdxToConfig,n.emptyGroups=Object(i.K)(n.emptyGroups,o.emptyGroups),n.hasCustom=o.hasCustom||n.hasCustom,n.canModeBeOptimized[r]=o.canBeOptimized)}))})),n.defaultMode=r.defaultMode,!Object(i.A)(n.lexerDefinitionErrors)&&!n.config.deferDefinitionErrorsHandling){var c=Object(i.I)(n.lexerDefinitionErrors,(function(t){return t.message})).join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+c)}Object(i.u)(n.lexerDefinitionWarning,(function(t){Object(i.d)(t.message)})),n.TRACE_INIT("Choosing sub-methods implementations",(function(){if(T?(n.chopInput=i.a,n.match=n.matchWithTest):(n.updateLastIndex=i.b,n.match=n.matchWithExec),o&&(n.handleModes=i.b),!1===n.trackStartLines&&(n.computeNewColumn=i.a),!1===n.trackEndLines&&(n.updateTokenEndLineColumnLocation=i.b),/full/i.test(n.config.positionTracking))n.createTokenInstance=n.createFullToken;else if(/onlyStart/i.test(n.config.positionTracking))n.createTokenInstance=n.createStartOnlyToken;else{if(!/onlyOffset/i.test(n.config.positionTracking))throw Error('Invalid <positionTracking> config option: "'+n.config.positionTracking+'"');n.createTokenInstance=n.createOffsetOnlyToken}n.hasCustom?(n.addToken=n.addTokenUsingPush,n.handlePayload=n.handlePayloadWithCustom):(n.addToken=n.addTokenUsingMemberAccess,n.handlePayload=n.handlePayloadNoCustom)})),n.TRACE_INIT("Failed Optimization Warnings",(function(){var t=Object(i.O)(n.canModeBeOptimized,(function(t,e,n){return!1===e&&t.push(n),t}),[]);if(e.ensureOptimizations&&!Object(i.A)(t))throw Error("Lexer Modes: < "+t.join(", ")+' > cannot be optimized.\n\t Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.\n\t Or inspect the console log for details on how to resolve these issues.')})),n.TRACE_INIT("clearRegExpParserCache",(function(){a={}})),n.TRACE_INIT("toFastProperties",(function(){Object(i.S)(n)}))}))}return t.prototype.tokenize=function(t,e){if(void 0===e&&(e=this.defaultMode),!Object(i.A)(this.lexerDefinitionErrors)){var n=Object(i.I)(this.lexerDefinitionErrors,(function(t){return t.message})).join("-----------------------\n");throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+n)}return this.tokenizeInternal(t,e)},t.prototype.tokenizeInternal=function(t,e){var n,r,o,a,s,c,l,u,h,f,p,d,m,g,v,y,b,T=this,O=t,S=O.length,x=0,E=0,C=this.hasCustom?0:Math.floor(t.length/10),k=new Array(C),w=[],N=this.trackStartLines?1:void 0,L=this.trackStartLines?1:void 0,A=(v=this.emptyGroups,y={},b=Object(i.G)(v),Object(i.u)(b,(function(t){var e=v[t];if(!Object(i.y)(e))throw Error("non exhaustive match");y[t]=[]})),y),I=this.trackStartLines,R=this.config.lineTerminatorsPattern,M=0,_=[],j=[],D=[],F=[];Object.freeze(F);var U=void 0;function W(){return _}function B(t){var e=P(t),n=j[e];return void 0===n?F:n}var H,G=function(t){if(1===D.length&&void 0===t.tokenType.PUSH_MODE){var e=T.config.errorMessageProvider.buildUnableToPopLexerModeMessage(t);w.push({offset:t.startOffset,line:void 0!==t.startLine?t.startLine:void 0,column:void 0!==t.startColumn?t.startColumn:void 0,length:t.image.length,message:e})}else{D.pop();var n=Object(i.H)(D);_=T.patternIdxToConfig[n],j=T.charCodeToPatternIdxToConfig[n],M=_.length;var r=T.canModeBeOptimized[n]&&!1===T.config.safeMode;U=j&&r?B:W}};function z(t){D.push(t),j=this.charCodeToPatternIdxToConfig[t],_=this.patternIdxToConfig[t],M=_.length,M=_.length;var e=this.canModeBeOptimized[t]&&!1===this.config.safeMode;U=j&&e?B:W}for(z.call(this,e);x<S;){s=null;var V=O.charCodeAt(x),K=U(V),Y=K.length;for(n=0;n<Y;n++){var X=(H=K[n]).pattern;if(c=null,!1!==(it=H.short)?V===it&&(s=X):!0===H.isCustom?null!==(g=X.exec(O,x,k,A))?(s=g[0],void 0!==g.payload&&(c=g.payload)):s=null:(this.updateLastIndex(X,x),s=this.match(X,t,x)),null!==s){if(void 0!==(a=H.longerAlt)){var $=_[a],q=$.pattern;l=null,!0===$.isCustom?null!==(g=q.exec(O,x,k,A))?(o=g[0],void 0!==g.payload&&(l=g.payload)):o=null:(this.updateLastIndex(q,x),o=this.match(q,t,x)),o&&o.length>s.length&&(s=o,c=l,H=$)}break}}if(null!==s){if(u=s.length,void 0!==(h=H.group)&&(f=H.tokenTypeIdx,p=this.createTokenInstance(s,x,f,H.tokenType,N,L,u),this.handlePayload(p,c),!1===h?E=this.addToken(k,E,p):A[h].push(p)),t=this.chopInput(t,u),x+=u,L=this.computeNewColumn(L,u),!0===I&&!0===H.canLineTerminator){var Z=0,Q=void 0,J=void 0;R.lastIndex=0;do{!0===(Q=R.test(s))&&(J=R.lastIndex-1,Z++)}while(!0===Q);0!==Z&&(N+=Z,L=u-J,this.updateTokenEndLineColumnLocation(p,h,J,Z,N,L,u))}this.handleModes(H,G,z,p)}else{for(var tt=x,et=N,nt=L,rt=!1;!rt&&x<S;)for(O.charCodeAt(x),t=this.chopInput(t,1),x++,r=0;r<M;r++){var it,ot=_[r];X=ot.pattern;if(!1!==(it=ot.short)?O.charCodeAt(x)===it&&(rt=!0):!0===ot.isCustom?rt=null!==X.exec(O,x,k,A):(this.updateLastIndex(X,x),rt=null!==X.exec(t)),!0===rt)break}d=x-tt,m=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(O,tt,d,et,nt),w.push({offset:tt,line:et,column:nt,length:d,message:m})}}return this.hasCustom||(k.length=E),{tokens:k,groups:A,errors:w}},t.prototype.handleModes=function(t,e,n,r){if(!0===t.pop){var i=t.push;e(r),void 0!==i&&n.call(this,i)}else void 0!==t.push&&n.call(this,t.push)},t.prototype.chopInput=function(t,e){return t.substring(e)},t.prototype.updateLastIndex=function(t,e){t.lastIndex=e},t.prototype.updateTokenEndLineColumnLocation=function(t,e,n,r,i,o,a){var s,c;void 0!==e&&(c=(s=n===a-1)?-1:0,1===r&&!0===s||(t.endLine=i+c,t.endColumn=o-1-c))},t.prototype.computeNewColumn=function(t,e){return t+e},t.prototype.createTokenInstance=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return null},t.prototype.createOffsetOnlyToken=function(t,e,n,r){return{image:t,startOffset:e,tokenTypeIdx:n,tokenType:r}},t.prototype.createStartOnlyToken=function(t,e,n,r,i,o){return{image:t,startOffset:e,startLine:i,startColumn:o,tokenTypeIdx:n,tokenType:r}},t.prototype.createFullToken=function(t,e,n,r,i,o,a){return{image:t,startOffset:e,endOffset:e+a-1,startLine:i,endLine:i,startColumn:o,endColumn:o+a-1,tokenTypeIdx:n,tokenType:r}},t.prototype.addToken=function(t,e,n){return 666},t.prototype.addTokenUsingPush=function(t,e,n){return t.push(n),e},t.prototype.addTokenUsingMemberAccess=function(t,e,n){return t[e]=n,++e},t.prototype.handlePayload=function(t,e){},t.prototype.handlePayloadNoCustom=function(t,e){},t.prototype.handlePayloadWithCustom=function(t,e){null!==e&&(t.payload=e)},t.prototype.match=function(t,e,n){return null},t.prototype.matchWithTest=function(t,e,n){return!0===t.test(e)?e.substring(n,t.lastIndex):null},t.prototype.matchWithExec=function(t,e){var n=t.exec(e);return null!==n?n[0]:n},t.prototype.TRACE_INIT=function(t,e){if(!0===this.traceInitPerf){this.traceInitIndent++;var n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(n+"--\x3e <"+t+">");var r=Object(i.R)(e),o=r.time,a=r.value,s=o>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(n+"<-- <"+t+"> time: "+o+"ms"),this.traceInitIndent--,a}return e()},t.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",t.NA=/NOT_APPLICABLE/,t}();function $(t){return Z(t)?t.LABEL:t.name}function q(t){return t.name}function Z(t){return Object(i.E)(t.LABEL)&&""!==t.LABEL}function Q(t){return function(t){var e=t.pattern,n={};n.name=t.name,Object(i.F)(e)||(n.PATTERN=e);if(Object(i.w)(t,"parent"))throw"The parent property is no longer supported.\nSee: https://github.com/SAP/chevrotain/issues/564#issuecomment-349062346 for details.";Object(i.w)(t,"categories")&&(n.CATEGORIES=t.categories);B([n]),Object(i.w)(t,"label")&&(n.LABEL=t.label);Object(i.w)(t,"group")&&(n.GROUP=t.group);Object(i.w)(t,"pop_mode")&&(n.POP_MODE=t.pop_mode);Object(i.w)(t,"push_mode")&&(n.PUSH_MODE=t.push_mode);Object(i.w)(t,"longer_alt")&&(n.LONGER_ALT=t.longer_alt);Object(i.w)(t,"line_breaks")&&(n.LINE_BREAKS=t.line_breaks);Object(i.w)(t,"start_chars_hint")&&(n.START_CHARS_HINT=t.start_chars_hint);return n}(t)}var J=Q({name:"EOF",pattern:X.NA});function tt(t,e,n,r,i,o,a,s){return{image:e,startOffset:n,endOffset:r,startLine:i,endLine:o,startColumn:a,endColumn:s,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}function et(t,e){return D(t,e)}B([J]);var nt=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),rt=function(){function t(t){this._definition=t}return Object.defineProperty(t.prototype,"definition",{get:function(){return this._definition},set:function(t){this._definition=t},enumerable:!1,configurable:!0}),t.prototype.accept=function(t){t.visit(this),Object(i.u)(this.definition,(function(e){e.accept(t)}))},t}(),it=function(t){function e(e){var n=t.call(this,[])||this;return n.idx=1,Object(i.f)(n,Object(i.N)(e,(function(t){return void 0!==t}))),n}return nt(e,t),Object.defineProperty(e.prototype,"definition",{get:function(){return void 0!==this.referencedRule?this.referencedRule.definition:[]},set:function(t){},enumerable:!1,configurable:!0}),e.prototype.accept=function(t){t.visit(this)},e}(rt),ot=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.orgText="",Object(i.f)(n,Object(i.N)(e,(function(t){return void 0!==t}))),n}return nt(e,t),e}(rt),at=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.ignoreAmbiguities=!1,Object(i.f)(n,Object(i.N)(e,(function(t){return void 0!==t}))),n}return nt(e,t),e}(rt),st=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,Object(i.f)(n,Object(i.N)(e,(function(t){return void 0!==t}))),n}return nt(e,t),e}(rt),ct=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,Object(i.f)(n,Object(i.N)(e,(function(t){return void 0!==t}))),n}return nt(e,t),e}(rt),lt=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,Object(i.f)(n,Object(i.N)(e,(function(t){return void 0!==t}))),n}return nt(e,t),e}(rt),ut=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,Object(i.f)(n,Object(i.N)(e,(function(t){return void 0!==t}))),n}return nt(e,t),e}(rt),ht=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,Object(i.f)(n,Object(i.N)(e,(function(t){return void 0!==t}))),n}return nt(e,t),e}(rt),ft=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,n.ignoreAmbiguities=!1,n.hasPredicates=!1,Object(i.f)(n,Object(i.N)(e,(function(t){return void 0!==t}))),n}return nt(e,t),Object.defineProperty(e.prototype,"definition",{get:function(){return this._definition},set:function(t){this._definition=t},enumerable:!1,configurable:!0}),e}(rt),pt=function(){function t(t){this.idx=1,Object(i.f)(this,Object(i.N)(t,(function(t){return void 0!==t})))}return t.prototype.accept=function(t){t.visit(this)},t}();function dt(t){return Object(i.I)(t,mt)}function mt(t){function e(t){return Object(i.I)(t,mt)}if(t instanceof it)return{type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};if(t instanceof at)return{type:"Alternative",definition:e(t.definition)};if(t instanceof st)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof ct)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof lt)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:mt(new pt({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof ht)return{type:"RepetitionWithSeparator",idx:t.idx,separator:mt(new pt({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof ut)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof ft)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof pt){var n={type:"Terminal",name:t.terminalType.name,label:$(t.terminalType),idx:t.idx},r=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(n.pattern=Object(i.D)(r)?r.source:r),n}if(t instanceof ot)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}var gt=function(){function t(){}return t.prototype.walk=function(t,e){var n=this;void 0===e&&(e=[]),Object(i.u)(t.definition,(function(r,o){var a=Object(i.m)(t.definition,o+1);if(r instanceof it)n.walkProdRef(r,a,e);else if(r instanceof pt)n.walkTerminal(r,a,e);else if(r instanceof at)n.walkFlat(r,a,e);else if(r instanceof st)n.walkOption(r,a,e);else if(r instanceof ct)n.walkAtLeastOne(r,a,e);else if(r instanceof lt)n.walkAtLeastOneSep(r,a,e);else if(r instanceof ht)n.walkManySep(r,a,e);else if(r instanceof ut)n.walkMany(r,a,e);else{if(!(r instanceof ft))throw Error("non exhaustive match");n.walkOr(r,a,e)}}))},t.prototype.walkTerminal=function(t,e,n){},t.prototype.walkProdRef=function(t,e,n){},t.prototype.walkFlat=function(t,e,n){var r=e.concat(n);this.walk(t,r)},t.prototype.walkOption=function(t,e,n){var r=e.concat(n);this.walk(t,r)},t.prototype.walkAtLeastOne=function(t,e,n){var r=[new st({definition:t.definition})].concat(e,n);this.walk(t,r)},t.prototype.walkAtLeastOneSep=function(t,e,n){var r=vt(t,e,n);this.walk(t,r)},t.prototype.walkMany=function(t,e,n){var r=[new st({definition:t.definition})].concat(e,n);this.walk(t,r)},t.prototype.walkManySep=function(t,e,n){var r=vt(t,e,n);this.walk(t,r)},t.prototype.walkOr=function(t,e,n){var r=this,o=e.concat(n);Object(i.u)(t.definition,(function(t){var e=new at({definition:[t]});r.walk(e,o)}))},t}();function vt(t,e,n){return[new st({definition:[new pt({terminalType:t.separator})].concat(t.definition)})].concat(e,n)}var yt=function(){function t(){}return t.prototype.visit=function(t){var e=t;switch(e.constructor){case it:return this.visitNonTerminal(e);case at:return this.visitAlternative(e);case st:return this.visitOption(e);case ct:return this.visitRepetitionMandatory(e);case lt:return this.visitRepetitionMandatoryWithSeparator(e);case ht:return this.visitRepetitionWithSeparator(e);case ut:return this.visitRepetition(e);case ft:return this.visitAlternation(e);case pt:return this.visitTerminal(e);case ot:return this.visitRule(e);default:throw Error("non exhaustive match")}},t.prototype.visitNonTerminal=function(t){},t.prototype.visitAlternative=function(t){},t.prototype.visitOption=function(t){},t.prototype.visitRepetition=function(t){},t.prototype.visitRepetitionMandatory=function(t){},t.prototype.visitRepetitionMandatoryWithSeparator=function(t){},t.prototype.visitRepetitionWithSeparator=function(t){},t.prototype.visitAlternation=function(t){},t.prototype.visitTerminal=function(t){},t.prototype.visitRule=function(t){},t}(),bt=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();function Tt(t,e){return void 0===e&&(e=[]),!!(t instanceof st||t instanceof ut||t instanceof ht)||(t instanceof ft?Object(i.Q)(t.definition,(function(t){return Tt(t,e)})):!(t instanceof it&&Object(i.j)(e,t))&&(t instanceof rt&&(t instanceof it&&e.push(t),Object(i.o)(t.definition,(function(t){return Tt(t,e)})))))}function Ot(t){if(t instanceof it)return"SUBRULE";if(t instanceof st)return"OPTION";if(t instanceof ft)return"OR";if(t instanceof ct)return"AT_LEAST_ONE";if(t instanceof lt)return"AT_LEAST_ONE_SEP";if(t instanceof ht)return"MANY_SEP";if(t instanceof ut)return"MANY";if(t instanceof pt)return"CONSUME";throw Error("non exhaustive match")}var St=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.separator="-",e.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},e}return bt(e,t),e.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},e.prototype.visitTerminal=function(t){var e=t.terminalType.name+this.separator+"Terminal";Object(i.w)(this.dslMethods,e)||(this.dslMethods[e]=[]),this.dslMethods[e].push(t)},e.prototype.visitNonTerminal=function(t){var e=t.nonTerminalName+this.separator+"Terminal";Object(i.w)(this.dslMethods,e)||(this.dslMethods[e]=[]),this.dslMethods[e].push(t)},e.prototype.visitOption=function(t){this.dslMethods.option.push(t)},e.prototype.visitRepetitionWithSeparator=function(t){this.dslMethods.repetitionWithSeparator.push(t)},e.prototype.visitRepetitionMandatory=function(t){this.dslMethods.repetitionMandatory.push(t)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)},e.prototype.visitRepetition=function(t){this.dslMethods.repetition.push(t)},e.prototype.visitAlternation=function(t){this.dslMethods.alternation.push(t)},e}(yt),xt=new St;function Et(t){if(t instanceof it)return Et(t.referencedRule);if(t instanceof pt)return[t.terminalType];if(function(t){return t instanceof at||t instanceof st||t instanceof ut||t instanceof ct||t instanceof lt||t instanceof ht||t instanceof pt||t instanceof ot}(t))return function(t){var e,n=[],r=t.definition,o=0,a=r.length>o,s=!0;for(;a&&s;)e=r[o],s=Tt(e),n=n.concat(Et(e)),o+=1,a=r.length>o;return Object(i.T)(n)}(t);if(function(t){return t instanceof ft}(t))return function(t){var e=Object(i.I)(t.definition,(function(t){return Et(t)}));return Object(i.T)(Object(i.t)(e))}(t);throw Error("non exhaustive match")}var Ct="_~IN~_",kt=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),wt=function(t){function e(e){var n=t.call(this)||this;return n.topProd=e,n.follows={},n}return kt(e,t),e.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},e.prototype.walkTerminal=function(t,e,n){},e.prototype.walkProdRef=function(t,e,n){var r,i,o=(r=t.referencedRule,i=t.idx,r.name+i+Ct+this.topProd.name),a=e.concat(n),s=Et(new at({definition:a}));this.follows[o]=s},e}(gt);var Nt={buildMismatchTokenMessage:function(t){var e=t.expected,n=t.actual;t.previous,t.ruleName;return"Expecting "+(Z(e)?"--\x3e "+$(e)+" <--":"token of type --\x3e "+e.name+" <--")+" but found --\x3e '"+n.image+"' <--"},buildNotAllInputParsedMessage:function(t){var e=t.firstRedundant;t.ruleName;return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage:function(t){var e=t.expectedPathsPerAlt,n=t.actual,r=(t.previous,t.customUserDescription),o=(t.ruleName,"\nbut found: '"+Object(i.s)(n).image+"'");if(r)return"Expecting: "+r+o;var a=Object(i.O)(e,(function(t,e){return t.concat(e)}),[]),s=Object(i.I)(a,(function(t){return"["+Object(i.I)(t,(function(t){return $(t)})).join(", ")+"]"}));return"Expecting: "+("one of these possible Token sequences:\n"+Object(i.I)(s,(function(t,e){return" "+(e+1)+". "+t})).join("\n"))+o},buildEarlyExitMessage:function(t){var e=t.expectedIterationPaths,n=t.actual,r=t.customUserDescription,o=(t.ruleName,"\nbut found: '"+Object(i.s)(n).image+"'");return r?"Expecting: "+r+o:"Expecting: "+("expecting at least one iteration which starts with one of these possible Token sequences::\n <"+Object(i.I)(e,(function(t){return"["+Object(i.I)(t,(function(t){return $(t)})).join(",")+"]"})).join(" ,")+">")+o}};Object.freeze(Nt);var Lt={buildRuleNotFoundError:function(t,e){return"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+"<-\ninside top level rule: ->"+t.name+"<-"}},At={buildDuplicateFoundError:function(t,e){var n,r=t.name,o=Object(i.s)(e),a=o.idx,s=Ot(o),c=(n=o)instanceof pt?n.terminalType.name:n instanceof it?n.nonTerminalName:"",l="->"+s+(a>0?a:"")+"<- "+(c?"with argument: ->"+c+"<-":"")+"\n appears more than once ("+e.length+" times) in the top level rule: ->"+r+"<-. \n For further details see: https://sap.github.io/chevrotain/docs/FAQ.html#NUMERICAL_SUFFIXES \n ";return l=(l=l.replace(/[ \t]+/g," ")).replace(/\s\s+/g,"\n")},buildNamespaceConflictError:function(t){return"Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <"+t.name+">.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter."},buildAlternationPrefixAmbiguityError:function(t){var e=Object(i.I)(t.prefixPath,(function(t){return $(t)})).join(", "),n=0===t.alternation.idx?"":t.alternation.idx;return"Ambiguous alternatives: <"+t.ambiguityIndices.join(" ,")+"> due to common lookahead prefix\nin <OR"+n+"> inside <"+t.topLevelRule.name+"> Rule,\n<"+e+"> may appears as a prefix path in all these alternatives.\nSee: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details."},buildAlternationAmbiguityError:function(t){var e=Object(i.I)(t.prefixPath,(function(t){return $(t)})).join(", "),n=0===t.alternation.idx?"":t.alternation.idx,r="Ambiguous Alternatives Detected: <"+t.ambiguityIndices.join(" ,")+"> in <OR"+n+"> inside <"+t.topLevelRule.name+"> Rule,\n<"+e+"> may appears as a prefix path in all these alternatives.\n";return r+="See: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details."},buildEmptyRepetitionError:function(t){var e=Ot(t.repetition);return 0!==t.repetition.idx&&(e+=t.repetition.idx),"The repetition <"+e+"> within Rule <"+t.topLevelRule.name+"> can never consume any tokens.\nThis could lead to an infinite loop."},buildTokenNameError:function(t){return"Invalid Grammar Token name: ->"+t.tokenType.name+"<- it must match the pattern: ->"+t.expectedPattern.toString()+"<-"},buildEmptyAlternationError:function(t){return"Ambiguous empty alternative: <"+(t.emptyChoiceIdx+1)+"> in <OR"+t.alternation.idx+"> inside <"+t.topLevelRule.name+"> Rule.\nOnly the last alternative may be an empty alternative."},buildTooManyAlternativesError:function(t){return"An Alternation cannot have more than 256 alternatives:\n<OR"+t.alternation.idx+"> inside <"+t.topLevelRule.name+"> Rule.\n has "+(t.alternation.definition.length+1)+" alternatives."},buildLeftRecursionError:function(t){var e=t.topLevelRule.name;return"Left Recursion found in grammar.\nrule: <"+e+"> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n "+(e+" --\x3e "+i.I(t.leftRecursionPath,(function(t){return t.name})).concat([e]).join(" --\x3e "))+"\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring."},buildInvalidRuleNameError:function(t){return"Invalid grammar rule name: ->"+t.topLevelRule.name+"<- it must match the pattern: ->"+t.expectedPattern.toString()+"<-"},buildDuplicateRuleNameError:function(t){return"Duplicate definition, rule: ->"+(t.topLevelRule instanceof ot?t.topLevelRule.name:t.topLevelRule)+"<- is already defined in the grammar: ->"+t.grammarName+"<-"}},It=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();var Rt=function(t){function e(e,n){var r=t.call(this)||this;return r.nameToTopRule=e,r.errMsgProvider=n,r.errors=[],r}return It(e,t),e.prototype.resolveRefs=function(){var t=this;Object(i.u)(Object(i.U)(this.nameToTopRule),(function(e){t.currTopLevel=e,e.accept(t)}))},e.prototype.visitNonTerminal=function(t){var e=this.nameToTopRule[t.nonTerminalName];if(e)t.referencedRule=e;else{var n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:n,type:Ze.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}},e}(yt),Mt=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),_t=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.path=n,r.nextTerminalName="",r.nextTerminalOccurrence=0,r.nextTerminalName=r.path.lastTok.name,r.nextTerminalOccurrence=r.path.lastTokOccurrence,r}return Mt(e,t),e.prototype.walkTerminal=function(t,e,n){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){var r=e.concat(n),i=new at({definition:r});this.possibleTokTypes=Et(i),this.found=!0}},e}(function(t){function e(e,n){var r=t.call(this)||this;return r.topProd=e,r.path=n,r.possibleTokTypes=[],r.nextProductionName="",r.nextProductionOccurrence=0,r.found=!1,r.isAtEndOfPath=!1,r}return Mt(e,t),e.prototype.startWalking=function(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=Object(i.g)(this.path.ruleStack).reverse(),this.occurrenceStack=Object(i.g)(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},e.prototype.walk=function(e,n){void 0===n&&(n=[]),this.found||t.prototype.walk.call(this,e,n)},e.prototype.walkProdRef=function(t,e,n){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){var r=e.concat(n);this.updateExpectedNext(),this.walk(t.referencedRule,r)}},e.prototype.updateExpectedNext=function(){Object(i.A)(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},e}(gt)),Pt=function(t){function e(e,n){var r=t.call(this)||this;return r.topRule=e,r.occurrence=n,r.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},r}return Mt(e,t),e.prototype.startWalking=function(){return this.walk(this.topRule),this.result},e}(gt),jt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Mt(e,t),e.prototype.walkMany=function(e,n,r){if(e.idx===this.occurrence){var o=Object(i.s)(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof pt&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else t.prototype.walkMany.call(this,e,n,r)},e}(Pt),Dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Mt(e,t),e.prototype.walkManySep=function(e,n,r){if(e.idx===this.occurrence){var o=Object(i.s)(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof pt&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else t.prototype.walkManySep.call(this,e,n,r)},e}(Pt),Ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Mt(e,t),e.prototype.walkAtLeastOne=function(e,n,r){if(e.idx===this.occurrence){var o=Object(i.s)(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof pt&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else t.prototype.walkAtLeastOne.call(this,e,n,r)},e}(Pt),Ut=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Mt(e,t),e.prototype.walkAtLeastOneSep=function(e,n,r){if(e.idx===this.occurrence){var o=Object(i.s)(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof pt&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else t.prototype.walkAtLeastOneSep.call(this,e,n,r)},e}(Pt);function Wt(t,e,n){void 0===n&&(n=[]),n=Object(i.g)(n);var r=[],o=0;function a(a){var s=Wt(a.concat(Object(i.m)(t,o+1)),e,n);return r.concat(s)}for(;n.length<e&&o<t.length;){var s=t[o];if(s instanceof at)return a(s.definition);if(s instanceof it)return a(s.definition);if(s instanceof st)r=a(s.definition);else{if(s instanceof ct)return a(c=s.definition.concat([new ut({definition:s.definition})]));if(s instanceof lt)return a(c=[new at({definition:s.definition}),new ut({definition:[new pt({terminalType:s.separator})].concat(s.definition)})]);if(s instanceof ht){var c=s.definition.concat([new ut({definition:[new pt({terminalType:s.separator})].concat(s.definition)})]);r=a(c)}else if(s instanceof ut){c=s.definition.concat([new ut({definition:s.definition})]);r=a(c)}else{if(s instanceof ft)return Object(i.u)(s.definition,(function(t){!1===Object(i.A)(t.definition)&&(r=a(t.definition))})),r;if(!(s instanceof pt))throw Error("non exhaustive match");n.push(s.terminalType)}}o++}return r.push({partialPath:n,suffixDef:Object(i.m)(t,o)}),r}function Bt(t,e,n,r){var o=["EXIT_NONE_TERMINAL"],a=!1,s=e.length,c=s-r-1,l=[],u=[];for(u.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});!Object(i.A)(u);){var h=u.pop();if("EXIT_ALTERNATIVE"!==h){var f=h.def,p=h.idx,d=h.ruleStack,m=h.occurrenceStack;if(!Object(i.A)(f)){var g=f[0];if("EXIT_NONE_TERMINAL"===g){var v={idx:p,def:Object(i.m)(f),ruleStack:Object(i.n)(d),occurrenceStack:Object(i.n)(m)};u.push(v)}else if(g instanceof pt)if(p<s-1){var y=p+1;if(n(e[y],g.terminalType)){v={idx:y,def:Object(i.m)(f),ruleStack:d,occurrenceStack:m};u.push(v)}}else{if(p!==s-1)throw Error("non exhaustive match");l.push({nextTokenType:g.terminalType,nextTokenOccurrence:g.idx,ruleStack:d,occurrenceStack:m}),a=!0}else if(g instanceof it){var b=Object(i.g)(d);b.push(g.nonTerminalName);var T=Object(i.g)(m);T.push(g.idx);v={idx:p,def:g.definition.concat(o,Object(i.m)(f)),ruleStack:b,occurrenceStack:T};u.push(v)}else if(g instanceof st){var O={idx:p,def:Object(i.m)(f),ruleStack:d,occurrenceStack:m};u.push(O),u.push("EXIT_ALTERNATIVE");var S={idx:p,def:g.definition.concat(Object(i.m)(f)),ruleStack:d,occurrenceStack:m};u.push(S)}else if(g instanceof ct){var x=new ut({definition:g.definition,idx:g.idx});v={idx:p,def:g.definition.concat([x],Object(i.m)(f)),ruleStack:d,occurrenceStack:m};u.push(v)}else if(g instanceof lt){var E=new pt({terminalType:g.separator});x=new ut({definition:[E].concat(g.definition),idx:g.idx}),v={idx:p,def:g.definition.concat([x],Object(i.m)(f)),ruleStack:d,occurrenceStack:m};u.push(v)}else if(g instanceof ht){O={idx:p,def:Object(i.m)(f),ruleStack:d,occurrenceStack:m};u.push(O),u.push("EXIT_ALTERNATIVE");E=new pt({terminalType:g.separator});var C=new ut({definition:[E].concat(g.definition),idx:g.idx});S={idx:p,def:g.definition.concat([C],Object(i.m)(f)),ruleStack:d,occurrenceStack:m};u.push(S)}else if(g instanceof ut){O={idx:p,def:Object(i.m)(f),ruleStack:d,occurrenceStack:m};u.push(O),u.push("EXIT_ALTERNATIVE");C=new ut({definition:g.definition,idx:g.idx}),S={idx:p,def:g.definition.concat([C],Object(i.m)(f)),ruleStack:d,occurrenceStack:m};u.push(S)}else if(g instanceof ft)for(var k=g.definition.length-1;k>=0;k--){var w={idx:p,def:g.definition[k].definition.concat(Object(i.m)(f)),ruleStack:d,occurrenceStack:m};u.push(w),u.push("EXIT_ALTERNATIVE")}else if(g instanceof at)u.push({idx:p,def:g.definition.concat(Object(i.m)(f)),ruleStack:d,occurrenceStack:m});else{if(!(g instanceof ot))throw Error("non exhaustive match");u.push(Ht(g,p,d,m))}}}else a&&Object(i.H)(u).idx<=c&&u.pop()}return l}function Ht(t,e,n,r){var o=Object(i.g)(n);o.push(t.name);var a=Object(i.g)(r);return a.push(1),{idx:e,def:t.definition,ruleStack:o,occurrenceStack:a}}var Gt,zt=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t[t.OPTION=0]="OPTION",t[t.REPETITION=1]="REPETITION",t[t.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",t[t.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",t[t.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",t[t.ALTERNATION=5]="ALTERNATION"}(Gt||(Gt={}));var Vt=function(t){function e(e,n,r){var i=t.call(this)||this;return i.topProd=e,i.targetOccurrence=n,i.targetProdType=r,i}return zt(e,t),e.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},e.prototype.checkIsTarget=function(t,e,n,r){return t.idx===this.targetOccurrence&&this.targetProdType===e&&(this.restDef=n.concat(r),!0)},e.prototype.walkOption=function(e,n,r){this.checkIsTarget(e,Gt.OPTION,n,r)||t.prototype.walkOption.call(this,e,n,r)},e.prototype.walkAtLeastOne=function(e,n,r){this.checkIsTarget(e,Gt.REPETITION_MANDATORY,n,r)||t.prototype.walkOption.call(this,e,n,r)},e.prototype.walkAtLeastOneSep=function(e,n,r){this.checkIsTarget(e,Gt.REPETITION_MANDATORY_WITH_SEPARATOR,n,r)||t.prototype.walkOption.call(this,e,n,r)},e.prototype.walkMany=function(e,n,r){this.checkIsTarget(e,Gt.REPETITION,n,r)||t.prototype.walkOption.call(this,e,n,r)},e.prototype.walkManySep=function(e,n,r){this.checkIsTarget(e,Gt.REPETITION_WITH_SEPARATOR,n,r)||t.prototype.walkOption.call(this,e,n,r)},e}(gt),Kt=function(t){function e(e,n,r){var i=t.call(this)||this;return i.targetOccurrence=e,i.targetProdType=n,i.targetRef=r,i.result=[],i}return zt(e,t),e.prototype.checkIsTarget=function(t,e){t.idx!==this.targetOccurrence||this.targetProdType!==e||void 0!==this.targetRef&&t!==this.targetRef||(this.result=t.definition)},e.prototype.visitOption=function(t){this.checkIsTarget(t,Gt.OPTION)},e.prototype.visitRepetition=function(t){this.checkIsTarget(t,Gt.REPETITION)},e.prototype.visitRepetitionMandatory=function(t){this.checkIsTarget(t,Gt.REPETITION_MANDATORY)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.checkIsTarget(t,Gt.REPETITION_MANDATORY_WITH_SEPARATOR)},e.prototype.visitRepetitionWithSeparator=function(t){this.checkIsTarget(t,Gt.REPETITION_WITH_SEPARATOR)},e.prototype.visitAlternation=function(t){this.checkIsTarget(t,Gt.ALTERNATION)},e}(yt);function Yt(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=[];return e}function Xt(t){for(var e=[""],n=0;n<t.length;n++){for(var r=t[n],i=[],o=0;o<e.length;o++){var a=e[o];i.push(a+"_"+r.tokenTypeIdx);for(var s=0;s<r.categoryMatches.length;s++){var c="_"+r.categoryMatches[s];i.push(a+c)}}e=i}return e}function $t(t,e,n){for(var r=0;r<t.length;r++)if(r!==n)for(var i=t[r],o=0;o<e.length;o++){if(!0===i[e[o]])return!1}return!0}function qt(t,e){for(var n=Object(i.I)(t,(function(t){return Wt([t],1)})),r=Yt(n.length),o=Object(i.I)(n,(function(t){var e={};return Object(i.u)(t,(function(t){var n=Xt(t.partialPath);Object(i.u)(n,(function(t){e[t]=!0}))})),e})),a=n,s=1;s<=e;s++){var c=a;a=Yt(c.length);for(var l=function(t){for(var n=c[t],l=0;l<n.length;l++){var u=n[l].partialPath,h=n[l].suffixDef,f=Xt(u);if($t(o,f,t)||Object(i.A)(h)||u.length===e){var p=r[t];if(!1===Jt(p,u)){p.push(u);for(var d=0;d<f.length;d++){var m=f[d];o[t][m]=!0}}}else{var g=Wt(h,s+1,u);a[t]=a[t].concat(g),Object(i.u)(g,(function(e){var n=Xt(e.partialPath);Object(i.u)(n,(function(e){o[t][e]=!0}))}))}}},u=0;u<c.length;u++)l(u)}return r}function Zt(t,e,n,r){var i=new Kt(t,Gt.ALTERNATION,r);return e.accept(i),qt(i.result,n)}function Qt(t,e,n,r){var i=new Kt(t,n);e.accept(i);var o=i.result,a=new Vt(e,t,n).startWalking();return qt([new at({definition:o}),new at({definition:a})],r)}function Jt(t,e){t:for(var n=0;n<t.length;n++){var r=t[n];if(r.length===e.length){for(var i=0;i<r.length;i++){var o=e[i],a=r[i];if(!1===(o===a||void 0!==a.categoryMatchesMap[o.tokenTypeIdx]))continue t}return!0}}return!1}function te(t){return Object(i.o)(t,(function(t){return Object(i.o)(t,(function(t){return Object(i.o)(t,(function(t){return Object(i.A)(t.categoryMatches)}))}))}))}var ee=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();function ne(t,e,n,r,o){var a=i.I(t,(function(t){return function(t,e){var n=new oe;t.accept(n);var r=n.allProductions,o=i.v(r,re),a=i.N(o,(function(t){return t.length>1}));return i.I(i.U(a),(function(n){var r=i.s(n),o=e.buildDuplicateFoundError(t,n),a=Ot(r),s={message:o,type:Ze.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:a,occurrence:r.idx},c=ie(r);return c&&(s.parameter=c),s}))}(t,r)})),s=i.I(t,(function(t){return function t(e,n,r,o){void 0===o&&(o=[]);var a=[],s=function t(e){var n=[];if(i.A(e))return n;var r=i.s(e);if(r instanceof it)n.push(r.referencedRule);else if(r instanceof at||r instanceof st||r instanceof ct||r instanceof lt||r instanceof ht||r instanceof ut)n=n.concat(t(r.definition));else if(r instanceof ft)n=i.t(i.I(r.definition,(function(e){return t(e.definition)})));else if(!(r instanceof pt))throw Error("non exhaustive match");var o=Tt(r),a=e.length>1;if(o&&a){var s=i.m(e);return n.concat(t(s))}return n}(n.definition);if(i.A(s))return[];var c=e.name;i.j(s,e)&&a.push({message:r.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:o}),type:Ze.LEFT_RECURSION,ruleName:c});var l=i.l(s,o.concat([e])),u=i.I(l,(function(n){var a=i.g(o);return a.push(n),t(e,n,r,a)}));return a.concat(i.t(u))}(t,t,r)})),c=[],l=[],u=[];Object(i.o)(s,i.A)&&(c=Object(i.I)(t,(function(t){return function(t,e){var n=new se;t.accept(n);var r=n.alternations;return i.O(r,(function(n,r){var o=i.n(r.definition),a=i.I(o,(function(n,o){var a=Bt([n],[],null,1);return i.A(a)?{message:e.buildEmptyAlternationError({topLevelRule:t,alternation:r,emptyChoiceIdx:o}),type:Ze.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:r.idx,alternative:o+1}:null}));return n.concat(i.i(a))}),[])}(t,r)})),l=Object(i.I)(t,(function(t){return function(t,e,n){var r=new se;t.accept(r);var o=r.alternations;return o=Object(i.P)(o,(function(t){return!0===t.ignoreAmbiguities})),i.O(o,(function(r,o){var a=o.idx,s=o.maxLookahead||e,c=Zt(a,t,s,o),l=function(t,e,n,r){var o=[],a=Object(i.O)(t,(function(n,r,a){return!0===e.definition[a].ignoreAmbiguities||Object(i.u)(r,(function(r){var s=[a];Object(i.u)(t,(function(t,n){a!==n&&Jt(t,r)&&!0!==e.definition[n].ignoreAmbiguities&&s.push(n)})),s.length>1&&!Jt(o,r)&&(o.push(r),n.push({alts:s,path:r}))})),n}),[]);return i.I(a,(function(t){var o=Object(i.I)(t.alts,(function(t){return t+1}));return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:o,prefixPath:t.path}),type:Ze.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:e.idx,alternatives:[t.alts]}}))}(c,o,t,n),u=function(t,e,n,r){var o=[],a=Object(i.O)(t,(function(t,e,n){var r=Object(i.I)(e,(function(t){return{idx:n,path:t}}));return t.concat(r)}),[]);return Object(i.u)(a,(function(t){if(!0!==e.definition[t.idx].ignoreAmbiguities){var s=t.idx,c=t.path,l=Object(i.r)(a,(function(t){return!0!==e.definition[t.idx].ignoreAmbiguities&&t.idx<s&&(n=t.path,r=c,n.length<r.length&&Object(i.o)(n,(function(t,e){var n=r[e];return t===n||n.categoryMatchesMap[t.tokenTypeIdx]})));var n,r})),u=Object(i.I)(l,(function(t){var i=[t.idx+1,s+1],o=0===e.idx?"":e.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:i,prefixPath:t.path}),type:Ze.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:i}}));o=o.concat(u)}})),o}(c,o,t,n);return r.concat(l,u)}),[])}(t,e,r)})),u=function(t,e,n){var r=[];return Object(i.u)(t,(function(t){var o=new ce;t.accept(o);var a=o.allProductions;Object(i.u)(a,(function(o){var a=function(t){if(t instanceof st)return Gt.OPTION;if(t instanceof ut)return Gt.REPETITION;if(t instanceof ct)return Gt.REPETITION_MANDATORY;if(t instanceof lt)return Gt.REPETITION_MANDATORY_WITH_SEPARATOR;if(t instanceof ht)return Gt.REPETITION_WITH_SEPARATOR;if(t instanceof ft)return Gt.ALTERNATION;throw Error("non exhaustive match")}(o),s=o.maxLookahead||e,c=Qt(o.idx,t,a,s)[0];if(Object(i.A)(Object(i.t)(c))){var l=n.buildEmptyRepetitionError({topLevelRule:t,repetition:o});r.push({message:l,type:Ze.NO_NON_EMPTY_LOOKAHEAD,ruleName:t.name})}}))})),r}(t,e,r));var h=function(t,e,n){var r=[],o=Object(i.I)(e,(function(t){return t.name}));return Object(i.u)(t,(function(t){var e=t.name;if(Object(i.j)(o,e)){var a=n.buildNamespaceConflictError(t);r.push({message:a,type:Ze.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:e})}})),r}(t,n,r),f=i.I(n,(function(t){return function(t,e){var n=[];t.name.match(ae)||n.push({message:e.buildTokenNameError({tokenType:t,expectedPattern:ae}),type:Ze.INVALID_TOKEN_NAME});return n}(t,r)})),p=Object(i.I)(t,(function(t){return function(t,e){var n=new se;t.accept(n);var r=n.alternations;return i.O(r,(function(n,r){return r.definition.length>255&&n.push({message:e.buildTooManyAlternativesError({topLevelRule:t,alternation:r}),type:Ze.TOO_MANY_ALTS,ruleName:t.name,occurrence:r.idx}),n}),[])}(t,r)})),d=Object(i.I)(t,(function(t){return function(t,e){var n=[],r=t.name;r.match(ae)||n.push({message:e.buildInvalidRuleNameError({topLevelRule:t,expectedPattern:ae}),type:Ze.INVALID_RULE_NAME,ruleName:r});return n}(t,r)})),m=Object(i.I)(t,(function(e){return function(t,e,n,r){var o=[];if(Object(i.O)(e,(function(e,n){return n.name===t.name?e+1:e}),0)>1){var a=r.buildDuplicateRuleNameError({topLevelRule:t,grammarName:n});o.push({message:a,type:Ze.DUPLICATE_RULE_NAME,ruleName:t.name})}return o}(e,t,o,r)}));return i.t(a.concat(f,u,s,c,l,h,p,d,m))}function re(t){return Ot(t)+"_#_"+t.idx+"_#_"+ie(t)}function ie(t){return t instanceof pt?t.terminalType.name:t instanceof it?t.nonTerminalName:""}var oe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allProductions=[],e}return ee(e,t),e.prototype.visitNonTerminal=function(t){this.allProductions.push(t)},e.prototype.visitOption=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatory=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetition=function(t){this.allProductions.push(t)},e.prototype.visitAlternation=function(t){this.allProductions.push(t)},e.prototype.visitTerminal=function(t){this.allProductions.push(t)},e}(yt),ae=/^[a-zA-Z_]\w*$/;var se=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.alternations=[],e}return ee(e,t),e.prototype.visitAlternation=function(t){this.alternations.push(t)},e}(yt);var ce=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allProductions=[],e}return ee(e,t),e.prototype.visitRepetitionWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatory=function(t){this.allProductions.push(t)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.allProductions.push(t)},e.prototype.visitRepetition=function(t){this.allProductions.push(t)},e}(yt);function le(t){t=Object(i.k)(t,{errMsgProvider:Lt});var e,n,r,o={};return Object(i.u)(t.rules,(function(t){o[t.name]=t})),e=o,n=t.errMsgProvider,(r=new Rt(e,n)).resolveRefs(),r.errors}function ue(t){return ne((t=Object(i.k)(t,{errMsgProvider:At})).rules,t.maxLookahead,t.tokenTypes,t.errMsgProvider,t.grammarName)}function he(t){Object(i.u)(t.rules,(function(t){var e=new St;t.accept(e),Object(i.u)(e.dslMethods,(function(t){Object(i.u)(t,(function(t,e){t.idx=e+1}))}))}))}var fe=["MismatchedTokenException","NoViableAltException","EarlyExitException","NotAllInputParsedException"];function pe(t){return Object(i.j)(fe,t.name)}function de(t,e,n){this.name="MismatchedTokenException",this.message=t,this.token=e,this.previousToken=n,this.resyncedTokens=[]}function me(t,e,n){this.name="NoViableAltException",this.message=t,this.token=e,this.previousToken=n,this.resyncedTokens=[]}function ge(t,e){this.name="NotAllInputParsedException",this.message=t,this.token=e,this.resyncedTokens=[]}function ve(t,e,n){this.name="EarlyExitException",this.message=t,this.token=e,this.previousToken=n,this.resyncedTokens=[]}Object.freeze(fe),de.prototype=Error.prototype,me.prototype=Error.prototype,ge.prototype=Error.prototype,ve.prototype=Error.prototype;var ye={};function be(t){this.name="InRuleRecoveryException",this.message=t}be.prototype=Error.prototype;var Te=function(){function t(){}return t.prototype.initRecoverable=function(t){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=Object(i.w)(t,"recoveryEnabled")?t.recoveryEnabled:Qe.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=Oe)},t.prototype.getTokenToInsert=function(t){var e=tt(t,"",NaN,NaN,NaN,NaN,NaN,NaN);return e.isInsertedInRecovery=!0,e},t.prototype.canTokenTypeBeInsertedInRecovery=function(t){return!0},t.prototype.tryInRepetitionRecovery=function(t,e,n,r){for(var o=this,a=this.findReSyncTokenType(),s=this.exportLexerState(),c=[],l=!1,u=this.LA(1),h=this.LA(1),f=function(){var t=o.LA(0),e=new de(o.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:u,previous:t,ruleName:o.getCurrRuleFullName()}),u,o.LA(0));e.resyncedTokens=Object(i.n)(c),o.SAVE_ERROR(e)};!l;){if(this.tokenMatcher(h,r))return void f();if(n.call(this))return f(),void t.apply(this,e);this.tokenMatcher(h,a)?l=!0:(h=this.SKIP_TOKEN(),this.addToResyncTokens(h,c))}this.importLexerState(s)},t.prototype.shouldInRepetitionRecoveryBeTried=function(t,e,n){return!1!==n&&(void 0!==t&&void 0!==e&&(!this.tokenMatcher(this.LA(1),t)&&(!this.isBackTracking()&&!this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,e)))))},t.prototype.getFollowsForInRuleRecovery=function(t,e){var n=this.getCurrentGrammarPath(t,e);return this.getNextPossibleTokenTypes(n)},t.prototype.tryInRuleRecovery=function(t,e){if(this.canRecoverWithSingleTokenInsertion(t,e))return this.getTokenToInsert(t);if(this.canRecoverWithSingleTokenDeletion(t)){var n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new be("sad sad panda")},t.prototype.canPerformInRuleRecovery=function(t,e){return this.canRecoverWithSingleTokenInsertion(t,e)||this.canRecoverWithSingleTokenDeletion(t)},t.prototype.canRecoverWithSingleTokenInsertion=function(t,e){var n=this;if(!this.canTokenTypeBeInsertedInRecovery(t))return!1;if(Object(i.A)(e))return!1;var r=this.LA(1);return void 0!==Object(i.q)(e,(function(t){return n.tokenMatcher(r,t)}))},t.prototype.canRecoverWithSingleTokenDeletion=function(t){return this.tokenMatcher(this.LA(2),t)},t.prototype.isInCurrentRuleReSyncSet=function(t){var e=this.getCurrFollowKey(),n=this.getFollowSetFromFollowKey(e);return Object(i.j)(n,t)},t.prototype.findReSyncTokenType=function(){for(var t=this.flattenFollowSet(),e=this.LA(1),n=2;;){var r=e.tokenType;if(Object(i.j)(t,r))return r;e=this.LA(n),n++}},t.prototype.getCurrFollowKey=function(){if(1===this.RULE_STACK.length)return ye;var t=this.getLastExplicitRuleShortName(),e=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:e,inRule:this.shortRuleNameToFullName(n)}},t.prototype.buildFullFollowKeyStack=function(){var t=this,e=this.RULE_STACK,n=this.RULE_OCCURRENCE_STACK;return Object(i.I)(e,(function(r,i){return 0===i?ye:{ruleName:t.shortRuleNameToFullName(r),idxInCallingRule:n[i],inRule:t.shortRuleNameToFullName(e[i-1])}}))},t.prototype.flattenFollowSet=function(){var t=this,e=Object(i.I)(this.buildFullFollowKeyStack(),(function(e){return t.getFollowSetFromFollowKey(e)}));return Object(i.t)(e)},t.prototype.getFollowSetFromFollowKey=function(t){if(t===ye)return[J];var e=t.ruleName+t.idxInCallingRule+Ct+t.inRule;return this.resyncFollows[e]},t.prototype.addToResyncTokens=function(t,e){return this.tokenMatcher(t,J)||e.push(t),e},t.prototype.reSyncTo=function(t){for(var e=[],n=this.LA(1);!1===this.tokenMatcher(n,t);)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,e);return Object(i.n)(e)},t.prototype.attemptInRepetitionRecovery=function(t,e,n,r,i,o,a){},t.prototype.getCurrentGrammarPath=function(t,e){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:Object(i.g)(this.RULE_OCCURRENCE_STACK),lastTok:t,lastTokOccurrence:e}},t.prototype.getHumanReadableRuleStack=function(){var t=this;return Object(i.I)(this.RULE_STACK,(function(e){return t.shortRuleNameToFullName(e)}))},t}();function Oe(t,e,n,r,i,o,a){var s=this.getKeyForAutomaticLookahead(r,i),c=this.firstAfterRepMap[s];if(void 0===c){var l=this.getCurrRuleFullName();c=new o(this.getGAstProductions()[l],i).startWalking(),this.firstAfterRepMap[s]=c}var u=c.token,h=c.occurrence,f=c.isEndOfRule;1===this.RULE_STACK.length&&f&&void 0===u&&(u=J,h=1),this.shouldInRepetitionRecoveryBeTried(u,h,a)&&this.tryInRepetitionRecovery(t,e,n,u)}function Se(t,e,n){return n|e|t}var xe=function(){function t(){}return t.prototype.initLooksAhead=function(t){this.dynamicTokensEnabled=Object(i.w)(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:Qe.dynamicTokensEnabled,this.maxLookahead=Object(i.w)(t,"maxLookahead")?t.maxLookahead:Qe.maxLookahead,this.lookAheadFuncsCache=Object(i.z)()?new Map:[],Object(i.z)()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},t.prototype.preComputeLookaheadFunctions=function(t){var e=this;Object(i.u)(t,(function(t){e.TRACE_INIT(t.name+" Rule Lookahead",(function(){var n=function(t){xt.reset(),t.accept(xt);var e=xt.dslMethods;return xt.reset(),e}(t),r=n.alternation,o=n.repetition,a=n.option,s=n.repetitionMandatory,c=n.repetitionMandatoryWithSeparator,l=n.repetitionWithSeparator;Object(i.u)(r,(function(n){var r=0===n.idx?"":n.idx;e.TRACE_INIT(""+Ot(n)+r,(function(){var r,i,o,a,s,c,l,u=(r=n.idx,i=t,o=n.maxLookahead||e.maxLookahead,a=n.hasPredicates,s=e.dynamicTokensEnabled,c=e.lookAheadBuilderForAlternatives,l=Zt(r,i,o),c(l,a,te(l)?F:D,s)),h=Se(e.fullRuleNameToShort[t.name],256,n.idx);e.setLaFuncCache(h,u)}))})),Object(i.u)(o,(function(n){e.computeLookaheadFunc(t,n.idx,768,Gt.REPETITION,n.maxLookahead,Ot(n))})),Object(i.u)(a,(function(n){e.computeLookaheadFunc(t,n.idx,512,Gt.OPTION,n.maxLookahead,Ot(n))})),Object(i.u)(s,(function(n){e.computeLookaheadFunc(t,n.idx,1024,Gt.REPETITION_MANDATORY,n.maxLookahead,Ot(n))})),Object(i.u)(c,(function(n){e.computeLookaheadFunc(t,n.idx,1536,Gt.REPETITION_MANDATORY_WITH_SEPARATOR,n.maxLookahead,Ot(n))})),Object(i.u)(l,(function(n){e.computeLookaheadFunc(t,n.idx,1280,Gt.REPETITION_WITH_SEPARATOR,n.maxLookahead,Ot(n))}))}))}))},t.prototype.computeLookaheadFunc=function(t,e,n,r,i,o){var a=this;this.TRACE_INIT(""+o+(0===e?"":e),(function(){var o=function(t,e,n,r,i,o){var a=Qt(t,e,i,n),s=te(a)?F:D;return o(a[0],s,r)}(e,t,i||a.maxLookahead,a.dynamicTokensEnabled,r,a.lookAheadBuilderForOptional),s=Se(a.fullRuleNameToShort[t.name],n,e);a.setLaFuncCache(s,o)}))},t.prototype.lookAheadBuilderForOptional=function(t,e,n){return function(t,e,n){var r=Object(i.o)(t,(function(t){return 1===t.length})),o=t.length;if(r&&!n){var a=Object(i.t)(t);if(1===a.length&&Object(i.A)(a[0].categoryMatches)){var s=a[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===s}}var c=Object(i.O)(a,(function(t,e,n){return t[e.tokenTypeIdx]=!0,Object(i.u)(e.categoryMatches,(function(e){t[e]=!0})),t}),[]);return function(){var t=this.LA(1);return!0===c[t.tokenTypeIdx]}}return function(){t:for(var n=0;n<o;n++){for(var r=t[n],i=r.length,a=0;a<i;a++){var s=this.LA(a+1);if(!1===e(s,r[a]))continue t}return!0}return!1}}(t,e,n)},t.prototype.lookAheadBuilderForAlternatives=function(t,e,n,r){return function(t,e,n,r){var o=t.length,a=Object(i.o)(t,(function(t){return Object(i.o)(t,(function(t){return 1===t.length}))}));if(e)return function(e){for(var r=Object(i.I)(e,(function(t){return t.GATE})),a=0;a<o;a++){var s=t[a],c=s.length,l=r[a];if(void 0===l||!1!==l.call(this))t:for(var u=0;u<c;u++){for(var h=s[u],f=h.length,p=0;p<f;p++){var d=this.LA(p+1);if(!1===n(d,h[p]))continue t}return a}}};if(a&&!r){var s=Object(i.I)(t,(function(t){return Object(i.t)(t)})),c=Object(i.O)(s,(function(t,e,n){return Object(i.u)(e,(function(e){Object(i.w)(t,e.tokenTypeIdx)||(t[e.tokenTypeIdx]=n),Object(i.u)(e.categoryMatches,(function(e){Object(i.w)(t,e)||(t[e]=n)}))})),t}),[]);return function(){var t=this.LA(1);return c[t.tokenTypeIdx]}}return function(){for(var e=0;e<o;e++){var r=t[e],i=r.length;t:for(var a=0;a<i;a++){for(var s=r[a],c=s.length,l=0;l<c;l++){var u=this.LA(l+1);if(!1===n(u,s[l]))continue t}return e}}}}(t,e,n,r)},t.prototype.getKeyForAutomaticLookahead=function(t,e){return Se(this.getLastExplicitRuleShortName(),t,e)},t.prototype.getLaFuncFromCache=function(t){},t.prototype.getLaFuncFromMap=function(t){return this.lookAheadFuncsCache.get(t)},t.prototype.getLaFuncFromObj=function(t){return this.lookAheadFuncsCache[t]},t.prototype.setLaFuncCache=function(t,e){},t.prototype.setLaFuncCacheUsingMap=function(t,e){this.lookAheadFuncsCache.set(t,e)},t.prototype.setLaFuncUsingObj=function(t,e){this.lookAheadFuncsCache[t]=e},t}();function Ee(t,e){!0===isNaN(t.startOffset)?(t.startOffset=e.startOffset,t.endOffset=e.endOffset):t.endOffset<e.endOffset==!0&&(t.endOffset=e.endOffset)}function Ce(t,e){!0===isNaN(t.startOffset)?(t.startOffset=e.startOffset,t.startColumn=e.startColumn,t.startLine=e.startLine,t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine):t.endOffset<e.endOffset==!0&&(t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine)}var ke;function we(t){var e=t.name;return e||"anonymous"}function Ne(t,e){var n=Object.getOwnPropertyDescriptor(t,"name");return!(!Object(i.F)(n)&&!n.configurable)&&(Object.defineProperty(t,"name",{enumerable:!1,configurable:!0,writable:!1,value:e}),!0)}function Le(t,e){for(var n=Object(i.G)(t),r=n.length,o=0;o<r;o++)for(var a=t[n[o]],s=a.length,c=0;c<s;c++){var l=a[c];void 0===l.tokenTypeIdx&&this[l.name](l.children,e)}}function Ae(t,e){var n=function(){};return Ne(n,t+"BaseSemantics"),(n.prototype={visit:function(t,e){if(Object(i.y)(t)&&(t=t[0]),!Object(i.F)(t))return this[t.name](t.children,e)},validateVisitor:function(){var t=function(t,e){var n=function(t,e){var n=Object(i.I)(e,(function(e){if(!Object(i.B)(t[e]))return{msg:"Missing visitor method: <"+e+"> on "+we(t.constructor)+" CST Visitor.",type:ke.MISSING_METHOD,methodName:e}}));return Object(i.i)(n)}(t,e),r=function(t,e){var n=[];for(var r in t)ae.test(r)&&Object(i.B)(t[r])&&!Object(i.j)(Ie,r)&&!Object(i.j)(e,r)&&n.push({msg:"Redundant visitor method: <"+r+"> on "+we(t.constructor)+" CST Visitor\nThere is no Grammar Rule corresponding to this method's name.\nFor utility methods on visitor classes use methods names that do not match /"+ae.source+"/.",type:ke.REDUNDANT_METHOD,methodName:r});return n}(t,e);return n.concat(r)}(this,e);if(!Object(i.A)(t)){var n=Object(i.I)(t,(function(t){return t.msg}));throw Error("Errors Detected in CST Visitor <"+we(this.constructor)+">:\n\t"+n.join("\n\n").replace(/\n/g,"\n\t"))}}}).constructor=n,n._RULE_NAMES=e,n}!function(t){t[t.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",t[t.MISSING_METHOD=1]="MISSING_METHOD"}(ke||(ke={}));var Ie=["constructor","visit","validateVisitor"];var Re=function(){function t(){}return t.prototype.initTreeBuilder=function(t){if(this.CST_STACK=[],this.outputCst=t.outputCst,this.nodeLocationTracking=Object(i.w)(t,"nodeLocationTracking")?t.nodeLocationTracking:Qe.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Ce,this.setNodeLocationFromNode=Ce,this.cstPostRule=i.b,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=i.b,this.setNodeLocationFromNode=i.b,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Ee,this.setNodeLocationFromNode=Ee,this.cstPostRule=i.b,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=i.b,this.setNodeLocationFromNode=i.b,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else{if(!/none/i.test(this.nodeLocationTracking))throw Error('Invalid <nodeLocationTracking> config option: "'+t.nodeLocationTracking+'"');this.setNodeLocationFromToken=i.b,this.setNodeLocationFromNode=i.b,this.cstPostRule=i.b,this.setInitialNodeLocation=i.b}else this.cstInvocationStateUpdate=i.b,this.cstFinallyStateUpdate=i.b,this.cstPostTerminal=i.b,this.cstPostNonTerminal=i.b,this.cstPostRule=i.b},t.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(t){t.location={startOffset:NaN,endOffset:NaN}},t.prototype.setInitialNodeLocationOnlyOffsetRegular=function(t){t.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},t.prototype.setInitialNodeLocationFullRecovery=function(t){t.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},t.prototype.setInitialNodeLocationFullRegular=function(t){var e=this.LA(1);t.location={startOffset:e.startOffset,startLine:e.startLine,startColumn:e.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},t.prototype.cstInvocationStateUpdate=function(t,e){var n={name:t,children:{}};this.setInitialNodeLocation(n),this.CST_STACK.push(n)},t.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},t.prototype.cstPostRuleFull=function(t){var e=this.LA(0),n=t.location;n.startOffset<=e.startOffset==!0?(n.endOffset=e.endOffset,n.endLine=e.endLine,n.endColumn=e.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)},t.prototype.cstPostRuleOnlyOffset=function(t){var e=this.LA(0),n=t.location;n.startOffset<=e.startOffset==!0?n.endOffset=e.endOffset:n.startOffset=NaN},t.prototype.cstPostTerminal=function(t,e){var n,r,i,o=this.CST_STACK[this.CST_STACK.length-1];r=e,i=t,void 0===(n=o).children[i]?n.children[i]=[r]:n.children[i].push(r),this.setNodeLocationFromToken(o.location,e)},t.prototype.cstPostNonTerminal=function(t,e){var n=this.CST_STACK[this.CST_STACK.length-1];!function(t,e,n){void 0===t.children[e]?t.children[e]=[n]:t.children[e].push(n)}(n,e,t),this.setNodeLocationFromNode(n.location,t.location)},t.prototype.getBaseCstVisitorConstructor=function(){if(Object(i.F)(this.baseCstVisitorConstructor)){var t=Ae(this.className,Object(i.G)(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor},t.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(Object(i.F)(this.baseCstVisitorWithDefaultsConstructor)){var t=function(t,e,n){var r=function(){};Ne(r,t+"BaseSemanticsWithDefaults");var o=Object.create(n.prototype);return Object(i.u)(e,(function(t){o[t]=Le})),(r.prototype=o).constructor=r,r}(this.className,Object(i.G)(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=t,t}return this.baseCstVisitorWithDefaultsConstructor},t.prototype.getLastExplicitRuleShortName=function(){var t=this.RULE_STACK;return t[t.length-1]},t.prototype.getPreviousExplicitRuleShortName=function(){var t=this.RULE_STACK;return t[t.length-2]},t.prototype.getLastExplicitRuleOccurrenceIndex=function(){var t=this.RULE_OCCURRENCE_STACK;return t[t.length-1]},t}(),Me=function(){function t(){}return t.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(t.prototype,"input",{get:function(){return this.tokVector},set:function(t){if(!0!==this.selfAnalysisDone)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=t,this.tokVectorLength=t.length},enumerable:!1,configurable:!0}),t.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):qe},t.prototype.LA=function(t){var e=this.currIdx+t;return e<0||this.tokVectorLength<=e?qe:this.tokVector[e]},t.prototype.consumeToken=function(){this.currIdx++},t.prototype.exportLexerState=function(){return this.currIdx},t.prototype.importLexerState=function(t){this.currIdx=t},t.prototype.resetLexerState=function(){this.currIdx=-1},t.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},t.prototype.getLexerPosition=function(){return this.exportLexerState()},t}(),_e=function(){function t(){}return t.prototype.ACTION=function(t){return t.call(this)},t.prototype.consume=function(t,e,n){return this.consumeInternal(e,t,n)},t.prototype.subrule=function(t,e,n){return this.subruleInternal(e,t,n)},t.prototype.option=function(t,e){return this.optionInternal(e,t)},t.prototype.or=function(t,e){return this.orInternal(e,t)},t.prototype.many=function(t,e){return this.manyInternal(t,e)},t.prototype.atLeastOne=function(t,e){return this.atLeastOneInternal(t,e)},t.prototype.CONSUME=function(t,e){return this.consumeInternal(t,0,e)},t.prototype.CONSUME1=function(t,e){return this.consumeInternal(t,1,e)},t.prototype.CONSUME2=function(t,e){return this.consumeInternal(t,2,e)},t.prototype.CONSUME3=function(t,e){return this.consumeInternal(t,3,e)},t.prototype.CONSUME4=function(t,e){return this.consumeInternal(t,4,e)},t.prototype.CONSUME5=function(t,e){return this.consumeInternal(t,5,e)},t.prototype.CONSUME6=function(t,e){return this.consumeInternal(t,6,e)},t.prototype.CONSUME7=function(t,e){return this.consumeInternal(t,7,e)},t.prototype.CONSUME8=function(t,e){return this.consumeInternal(t,8,e)},t.prototype.CONSUME9=function(t,e){return this.consumeInternal(t,9,e)},t.prototype.SUBRULE=function(t,e){return this.subruleInternal(t,0,e)},t.prototype.SUBRULE1=function(t,e){return this.subruleInternal(t,1,e)},t.prototype.SUBRULE2=function(t,e){return this.subruleInternal(t,2,e)},t.prototype.SUBRULE3=function(t,e){return this.subruleInternal(t,3,e)},t.prototype.SUBRULE4=function(t,e){return this.subruleInternal(t,4,e)},t.prototype.SUBRULE5=function(t,e){return this.subruleInternal(t,5,e)},t.prototype.SUBRULE6=function(t,e){return this.subruleInternal(t,6,e)},t.prototype.SUBRULE7=function(t,e){return this.subruleInternal(t,7,e)},t.prototype.SUBRULE8=function(t,e){return this.subruleInternal(t,8,e)},t.prototype.SUBRULE9=function(t,e){return this.subruleInternal(t,9,e)},t.prototype.OPTION=function(t){return this.optionInternal(t,0)},t.prototype.OPTION1=function(t){return this.optionInternal(t,1)},t.prototype.OPTION2=function(t){return this.optionInternal(t,2)},t.prototype.OPTION3=function(t){return this.optionInternal(t,3)},t.prototype.OPTION4=function(t){return this.optionInternal(t,4)},t.prototype.OPTION5=function(t){return this.optionInternal(t,5)},t.prototype.OPTION6=function(t){return this.optionInternal(t,6)},t.prototype.OPTION7=function(t){return this.optionInternal(t,7)},t.prototype.OPTION8=function(t){return this.optionInternal(t,8)},t.prototype.OPTION9=function(t){return this.optionInternal(t,9)},t.prototype.OR=function(t){return this.orInternal(t,0)},t.prototype.OR1=function(t){return this.orInternal(t,1)},t.prototype.OR2=function(t){return this.orInternal(t,2)},t.prototype.OR3=function(t){return this.orInternal(t,3)},t.prototype.OR4=function(t){return this.orInternal(t,4)},t.prototype.OR5=function(t){return this.orInternal(t,5)},t.prototype.OR6=function(t){return this.orInternal(t,6)},t.prototype.OR7=function(t){return this.orInternal(t,7)},t.prototype.OR8=function(t){return this.orInternal(t,8)},t.prototype.OR9=function(t){return this.orInternal(t,9)},t.prototype.MANY=function(t){this.manyInternal(0,t)},t.prototype.MANY1=function(t){this.manyInternal(1,t)},t.prototype.MANY2=function(t){this.manyInternal(2,t)},t.prototype.MANY3=function(t){this.manyInternal(3,t)},t.prototype.MANY4=function(t){this.manyInternal(4,t)},t.prototype.MANY5=function(t){this.manyInternal(5,t)},t.prototype.MANY6=function(t){this.manyInternal(6,t)},t.prototype.MANY7=function(t){this.manyInternal(7,t)},t.prototype.MANY8=function(t){this.manyInternal(8,t)},t.prototype.MANY9=function(t){this.manyInternal(9,t)},t.prototype.MANY_SEP=function(t){this.manySepFirstInternal(0,t)},t.prototype.MANY_SEP1=function(t){this.manySepFirstInternal(1,t)},t.prototype.MANY_SEP2=function(t){this.manySepFirstInternal(2,t)},t.prototype.MANY_SEP3=function(t){this.manySepFirstInternal(3,t)},t.prototype.MANY_SEP4=function(t){this.manySepFirstInternal(4,t)},t.prototype.MANY_SEP5=function(t){this.manySepFirstInternal(5,t)},t.prototype.MANY_SEP6=function(t){this.manySepFirstInternal(6,t)},t.prototype.MANY_SEP7=function(t){this.manySepFirstInternal(7,t)},t.prototype.MANY_SEP8=function(t){this.manySepFirstInternal(8,t)},t.prototype.MANY_SEP9=function(t){this.manySepFirstInternal(9,t)},t.prototype.AT_LEAST_ONE=function(t){this.atLeastOneInternal(0,t)},t.prototype.AT_LEAST_ONE1=function(t){return this.atLeastOneInternal(1,t)},t.prototype.AT_LEAST_ONE2=function(t){this.atLeastOneInternal(2,t)},t.prototype.AT_LEAST_ONE3=function(t){this.atLeastOneInternal(3,t)},t.prototype.AT_LEAST_ONE4=function(t){this.atLeastOneInternal(4,t)},t.prototype.AT_LEAST_ONE5=function(t){this.atLeastOneInternal(5,t)},t.prototype.AT_LEAST_ONE6=function(t){this.atLeastOneInternal(6,t)},t.prototype.AT_LEAST_ONE7=function(t){this.atLeastOneInternal(7,t)},t.prototype.AT_LEAST_ONE8=function(t){this.atLeastOneInternal(8,t)},t.prototype.AT_LEAST_ONE9=function(t){this.atLeastOneInternal(9,t)},t.prototype.AT_LEAST_ONE_SEP=function(t){this.atLeastOneSepFirstInternal(0,t)},t.prototype.AT_LEAST_ONE_SEP1=function(t){this.atLeastOneSepFirstInternal(1,t)},t.prototype.AT_LEAST_ONE_SEP2=function(t){this.atLeastOneSepFirstInternal(2,t)},t.prototype.AT_LEAST_ONE_SEP3=function(t){this.atLeastOneSepFirstInternal(3,t)},t.prototype.AT_LEAST_ONE_SEP4=function(t){this.atLeastOneSepFirstInternal(4,t)},t.prototype.AT_LEAST_ONE_SEP5=function(t){this.atLeastOneSepFirstInternal(5,t)},t.prototype.AT_LEAST_ONE_SEP6=function(t){this.atLeastOneSepFirstInternal(6,t)},t.prototype.AT_LEAST_ONE_SEP7=function(t){this.atLeastOneSepFirstInternal(7,t)},t.prototype.AT_LEAST_ONE_SEP8=function(t){this.atLeastOneSepFirstInternal(8,t)},t.prototype.AT_LEAST_ONE_SEP9=function(t){this.atLeastOneSepFirstInternal(9,t)},t.prototype.RULE=function(t,e,n){if(void 0===n&&(n=Je),Object(i.j)(this.definedRulesNames,t)){var r={message:At.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:Ze.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(r)}this.definedRulesNames.push(t);var o=this.defineRule(t,e,n);return this[t]=o,o},t.prototype.OVERRIDE_RULE=function(t,e,n){void 0===n&&(n=Je);var r,o,a,s,c,l=[];l=l.concat((r=t,o=this.definedRulesNames,a=this.className,c=[],i.j(o,r)||(s="Invalid rule override, rule: ->"+r+"<- cannot be overridden in the grammar: ->"+a+"<-as it is not defined in any of the super grammars ",c.push({message:s,type:Ze.INVALID_RULE_OVERRIDE,ruleName:r})),c)),this.definitionErrors.push.apply(this.definitionErrors,l);var u=this.defineRule(t,e,n);return this[t]=u,u},t.prototype.BACKTRACK=function(t,e){return function(){this.isBackTrackingStack.push(1);var n=this.saveRecogState();try{return t.apply(this,e),!0}catch(t){if(pe(t))return!1;throw t}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}},t.prototype.getGAstProductions=function(){return this.gastProductionsCache},t.prototype.getSerializedGastProductions=function(){return dt(Object(i.U)(this.gastProductionsCache))},t}(),Pe=function(){function t(){}return t.prototype.initRecognizerEngine=function(t,e){if(this.className=we(this.constructor),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=F,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},Object(i.w)(e,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n\tSee: https://sap.github.io/chevrotain/docs/changes/BREAKING_CHANGES.html#_6-0-0\n\tFor Further details.");if(Object(i.y)(t)){if(Object(i.A)(t))throw Error("A Token Vocabulary cannot be empty.\n\tNote that the first argument for the parser constructor\n\tis no longer a Token vector (since v4.0).");if("number"==typeof t[0].startOffset)throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n\tSee: https://sap.github.io/chevrotain/docs/changes/BREAKING_CHANGES.html#_4-0-0\n\tFor Further details.")}if(Object(i.y)(t))this.tokensMap=Object(i.O)(t,(function(t,e){return t[e.name]=e,t}),{});else if(Object(i.w)(t,"modes")&&Object(i.o)(Object(i.t)(Object(i.U)(t.modes)),z)){var n=Object(i.t)(Object(i.U)(t.modes)),r=Object(i.T)(n);this.tokensMap=Object(i.O)(r,(function(t,e){return t[e.name]=e,t}),{})}else{if(!Object(i.C)(t))throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=Object(i.h)(t)}this.tokensMap.EOF=J;var o=Object(i.o)(Object(i.U)(t),(function(t){return Object(i.A)(t.categoryMatches)}));this.tokenMatcher=o?F:D,B(Object(i.U)(this.tokensMap))},t.prototype.defineRule=function(t,e,n){if(this.selfAnalysisDone)throw Error("Grammar rule <"+t+"> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.");var r,o=Object(i.w)(n,"resyncEnabled")?n.resyncEnabled:Je.resyncEnabled,a=Object(i.w)(n,"recoveryValueFunc")?n.recoveryValueFunc:Je.recoveryValueFunc,s=this.ruleShortNameIdx<<12;function c(t){try{if(!0===this.outputCst){e.apply(this,t);var n=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(n),n}return e.apply(this,t)}catch(t){return this.invokeRuleCatch(t,o,a)}finally{this.ruleFinallyStateUpdate()}}this.ruleShortNameIdx++,this.shortRuleNameToFull[s]=t,this.fullRuleNameToShort[t]=s;return(r=function(e,n){return void 0===e&&(e=0),this.ruleInvocationStateUpdate(s,t,e),c.call(this,n)}).ruleName=t,r.originalGrammarAction=e,r},t.prototype.invokeRuleCatch=function(t,e,n){var r=1===this.RULE_STACK.length,i=e&&!this.isBackTracking()&&this.recoveryEnabled;if(pe(t)){var o=t;if(i){var a,s=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(s))return o.resyncedTokens=this.reSyncTo(s),this.outputCst?((a=this.CST_STACK[this.CST_STACK.length-1]).recoveredNode=!0,a):n();throw this.outputCst&&((a=this.CST_STACK[this.CST_STACK.length-1]).recoveredNode=!0,o.partialCstResult=a),o}if(r)return this.moveToTerminatedState(),n();throw o}throw t},t.prototype.optionInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(512,e);return this.optionInternalLogic(t,e,n)},t.prototype.optionInternalLogic=function(t,e,n){var r,i,o=this,a=this.getLaFuncFromCache(n);if(void 0!==t.DEF){if(r=t.DEF,void 0!==(i=t.GATE)){var s=a;a=function(){return i.call(o)&&s.call(o)}}}else r=t;if(!0===a.call(this))return r.call(this)},t.prototype.atLeastOneInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(1024,t);return this.atLeastOneInternalLogic(t,e,n)},t.prototype.atLeastOneInternalLogic=function(t,e,n){var r,i,o=this,a=this.getLaFuncFromCache(n);if(void 0!==e.DEF){if(r=e.DEF,void 0!==(i=e.GATE)){var s=a;a=function(){return i.call(o)&&s.call(o)}}}else r=e;if(!0!==a.call(this))throw this.raiseEarlyExitException(t,Gt.REPETITION_MANDATORY,e.ERR_MSG);for(var c=this.doSingleRepetition(r);!0===a.call(this)&&!0===c;)c=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,e],a,1024,t,Ft)},t.prototype.atLeastOneSepFirstInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(1536,t);this.atLeastOneSepFirstInternalLogic(t,e,n)},t.prototype.atLeastOneSepFirstInternalLogic=function(t,e,n){var r=this,i=e.DEF,o=e.SEP;if(!0!==this.getLaFuncFromCache(n).call(this))throw this.raiseEarlyExitException(t,Gt.REPETITION_MANDATORY_WITH_SEPARATOR,e.ERR_MSG);i.call(this);for(var a=function(){return r.tokenMatcher(r.LA(1),o)};!0===this.tokenMatcher(this.LA(1),o);)this.CONSUME(o),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,o,a,i,Ut],a,1536,t,Ut)},t.prototype.manyInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(768,t);return this.manyInternalLogic(t,e,n)},t.prototype.manyInternalLogic=function(t,e,n){var r,i,o=this,a=this.getLaFuncFromCache(n);if(void 0!==e.DEF){if(r=e.DEF,void 0!==(i=e.GATE)){var s=a;a=function(){return i.call(o)&&s.call(o)}}}else r=e;for(var c=!0;!0===a.call(this)&&!0===c;)c=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.manyInternal,[t,e],a,768,t,jt,c)},t.prototype.manySepFirstInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(1280,t);this.manySepFirstInternalLogic(t,e,n)},t.prototype.manySepFirstInternalLogic=function(t,e,n){var r=this,i=e.DEF,o=e.SEP;if(!0===this.getLaFuncFromCache(n).call(this)){i.call(this);for(var a=function(){return r.tokenMatcher(r.LA(1),o)};!0===this.tokenMatcher(this.LA(1),o);)this.CONSUME(o),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,o,a,i,Dt],a,1280,t,Dt)}},t.prototype.repetitionSepSecondInternal=function(t,e,n,r,i){for(;n();)this.CONSUME(e),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,e,n,r,i],n,1536,t,i)},t.prototype.doSingleRepetition=function(t){var e=this.getLexerPosition();return t.call(this),this.getLexerPosition()>e},t.prototype.orInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(256,e),r=Object(i.y)(t)?t:t.DEF,o=this.getLaFuncFromCache(n).call(this,r);if(void 0!==o)return r[o].ALT.call(this);this.raiseNoAltException(e,t.ERR_MSG)},t.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),0===this.RULE_STACK.length&&!1===this.isAtEndOfInput()){var t=this.LA(1),e=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:t,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new ge(e,t))}},t.prototype.subruleInternal=function(t,e,n){var r;try{var i=void 0!==n?n.ARGS:void 0;return r=t.call(this,e,i),this.cstPostNonTerminal(r,void 0!==n&&void 0!==n.LABEL?n.LABEL:t.ruleName),r}catch(e){this.subruleInternalError(e,n,t.ruleName)}},t.prototype.subruleInternalError=function(t,e,n){throw pe(t)&&void 0!==t.partialCstResult&&(this.cstPostNonTerminal(t.partialCstResult,void 0!==e&&void 0!==e.LABEL?e.LABEL:n),delete t.partialCstResult),t},t.prototype.consumeInternal=function(t,e,n){var r;try{var i=this.LA(1);!0===this.tokenMatcher(i,t)?(this.consumeToken(),r=i):this.consumeInternalError(t,i,n)}catch(n){r=this.consumeInternalRecovery(t,e,n)}return this.cstPostTerminal(void 0!==n&&void 0!==n.LABEL?n.LABEL:t.name,r),r},t.prototype.consumeInternalError=function(t,e,n){var r,i=this.LA(0);throw r=void 0!==n&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:t,actual:e,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new de(r,e,i))},t.prototype.consumeInternalRecovery=function(t,e,n){if(!this.recoveryEnabled||"MismatchedTokenException"!==n.name||this.isBackTracking())throw n;var r=this.getFollowsForInRuleRecovery(t,e);try{return this.tryInRuleRecovery(t,r)}catch(t){throw"InRuleRecoveryException"===t.name?n:t}},t.prototype.saveRecogState=function(){var t=this.errors,e=Object(i.g)(this.RULE_STACK);return{errors:t,lexerState:this.exportLexerState(),RULE_STACK:e,CST_STACK:this.CST_STACK}},t.prototype.reloadRecogState=function(t){this.errors=t.errors,this.importLexerState(t.lexerState),this.RULE_STACK=t.RULE_STACK},t.prototype.ruleInvocationStateUpdate=function(t,e,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(t),this.cstInvocationStateUpdate(e,t)},t.prototype.isBackTracking=function(){return 0!==this.isBackTrackingStack.length},t.prototype.getCurrRuleFullName=function(){var t=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[t]},t.prototype.shortRuleNameToFullName=function(t){return this.shortRuleNameToFull[t]},t.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),J)},t.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},t}(),je=function(){function t(){}return t.prototype.initErrorHandler=function(t){this._errors=[],this.errorMessageProvider=Object(i.w)(t,"errorMessageProvider")?t.errorMessageProvider:Qe.errorMessageProvider},t.prototype.SAVE_ERROR=function(t){if(pe(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:Object(i.g)(this.RULE_OCCURRENCE_STACK)},this._errors.push(t),t;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(t.prototype,"errors",{get:function(){return Object(i.g)(this._errors)},set:function(t){this._errors=t},enumerable:!1,configurable:!0}),t.prototype.raiseEarlyExitException=function(t,e,n){for(var r=this.getCurrRuleFullName(),i=Qt(t,this.getGAstProductions()[r],e,this.maxLookahead)[0],o=[],a=1;a<=this.maxLookahead;a++)o.push(this.LA(a));var s=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:i,actual:o,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new ve(s,this.LA(1),this.LA(0)))},t.prototype.raiseNoAltException=function(t,e){for(var n=this.getCurrRuleFullName(),r=Zt(t,this.getGAstProductions()[n],this.maxLookahead),i=[],o=1;o<=this.maxLookahead;o++)i.push(this.LA(o));var a=this.LA(0),s=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:r,actual:i,previous:a,customUserDescription:e,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new me(s,this.LA(1),a))},t}(),De=function(){function t(){}return t.prototype.initContentAssist=function(){},t.prototype.computeContentAssist=function(t,e){var n=this.gastProductionsCache[t];if(Object(i.F)(n))throw Error("Rule ->"+t+"<- does not exist in this grammar.");return Bt([n],e,this.tokenMatcher,this.maxLookahead)},t.prototype.getNextPossibleTokenTypes=function(t){var e=Object(i.s)(t.ruleStack),n=this.getGAstProductions()[e];return new _t(n,t).startWalking()},t}(),Fe={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Fe);var Ue=Math.pow(2,8)-1,We=Q({name:"RECORDING_PHASE_TOKEN",pattern:X.NA});B([We]);var Be=tt(We,"This IToken indicates the Parser is in Recording Phase\n\tSee: https://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(Be);var He={name:"This CSTNode indicates the Parser is in Recording Phase\n\tSee: https://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording for details",children:{}},Ge=function(){function t(){}return t.prototype.initGastRecorder=function(t){this.recordingProdStack=[],this.RECORDING_PHASE=!1},t.prototype.enableRecording=function(){var t=this;this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",(function(){for(var e=function(e){var n=e>0?e:"";t["CONSUME"+n]=function(t,n){return this.consumeInternalRecord(t,e,n)},t["SUBRULE"+n]=function(t,n){return this.subruleInternalRecord(t,e,n)},t["OPTION"+n]=function(t){return this.optionInternalRecord(t,e)},t["OR"+n]=function(t){return this.orInternalRecord(t,e)},t["MANY"+n]=function(t){this.manyInternalRecord(e,t)},t["MANY_SEP"+n]=function(t){this.manySepFirstInternalRecord(e,t)},t["AT_LEAST_ONE"+n]=function(t){this.atLeastOneInternalRecord(e,t)},t["AT_LEAST_ONE_SEP"+n]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}},n=0;n<10;n++)e(n);t.consume=function(t,e,n){return this.consumeInternalRecord(e,t,n)},t.subrule=function(t,e,n){return this.subruleInternalRecord(e,t,n)},t.option=function(t,e){return this.optionInternalRecord(e,t)},t.or=function(t,e){return this.orInternalRecord(e,t)},t.many=function(t,e){this.manyInternalRecord(t,e)},t.atLeastOne=function(t,e){this.atLeastOneInternalRecord(t,e)},t.ACTION=t.ACTION_RECORD,t.BACKTRACK=t.BACKTRACK_RECORD,t.LA=t.LA_RECORD}))},t.prototype.disableRecording=function(){var t=this;this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",(function(){for(var e=0;e<10;e++){var n=e>0?e:"";delete t["CONSUME"+n],delete t["SUBRULE"+n],delete t["OPTION"+n],delete t["OR"+n],delete t["MANY"+n],delete t["MANY_SEP"+n],delete t["AT_LEAST_ONE"+n],delete t["AT_LEAST_ONE_SEP"+n]}delete t.consume,delete t.subrule,delete t.option,delete t.or,delete t.many,delete t.atLeastOne,delete t.ACTION,delete t.BACKTRACK,delete t.LA}))},t.prototype.ACTION_RECORD=function(t){},t.prototype.BACKTRACK_RECORD=function(t,e){return function(){return!0}},t.prototype.LA_RECORD=function(t){return qe},t.prototype.topLevelRuleRecord=function(t,e){try{var n=new ot({definition:[],name:t});return n.name=t,this.recordingProdStack.push(n),e.call(this),this.recordingProdStack.pop(),n}catch(t){if(!0!==t.KNOWN_RECORDER_ERROR)try{t.message=t.message+'\n\t This error was thrown during the "grammar recording phase" For more info see:\n\thttps://sap.github.io/chevrotain/docs/guide/internals.html#grammar-recording'}catch(e){throw t}throw t}},t.prototype.optionInternalRecord=function(t,e){return ze.call(this,st,t,e)},t.prototype.atLeastOneInternalRecord=function(t,e){ze.call(this,ct,e,t)},t.prototype.atLeastOneSepFirstInternalRecord=function(t,e){ze.call(this,lt,e,t,!0)},t.prototype.manyInternalRecord=function(t,e){ze.call(this,ut,e,t)},t.prototype.manySepFirstInternalRecord=function(t,e){ze.call(this,ht,e,t,!0)},t.prototype.orInternalRecord=function(t,e){return Ve.call(this,t,e)},t.prototype.subruleInternalRecord=function(t,e,n){if(Ye(e),!t||!1===Object(i.w)(t,"ruleName")){var r=new Error("<SUBRULE"+Ke(e)+"> argument is invalid expecting a Parser method reference but got: <"+JSON.stringify(t)+">\n inside top level rule: <"+this.recordingProdStack[0].name+">");throw r.KNOWN_RECORDER_ERROR=!0,r}var o=Object(i.M)(this.recordingProdStack),a=t.ruleName,s=new it({idx:e,nonTerminalName:a,referencedRule:void 0});return o.definition.push(s),this.outputCst?He:Fe},t.prototype.consumeInternalRecord=function(t,e,n){if(Ye(e),!H(t)){var r=new Error("<CONSUME"+Ke(e)+"> argument is invalid expecting a TokenType reference but got: <"+JSON.stringify(t)+">\n inside top level rule: <"+this.recordingProdStack[0].name+">");throw r.KNOWN_RECORDER_ERROR=!0,r}var o=Object(i.M)(this.recordingProdStack),a=new pt({idx:e,terminalType:t});return o.definition.push(a),Be},t}();function ze(t,e,n,r){void 0===r&&(r=!1),Ye(n);var o=Object(i.M)(this.recordingProdStack),a=Object(i.B)(e)?e:e.DEF,s=new t({definition:[],idx:n});return r&&(s.separator=e.SEP),Object(i.w)(e,"MAX_LOOKAHEAD")&&(s.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(s),a.call(this),o.definition.push(s),this.recordingProdStack.pop(),Fe}function Ve(t,e){var n=this;Ye(e);var r=Object(i.M)(this.recordingProdStack),o=!1===Object(i.y)(t),a=!1===o?t:t.DEF,s=new ft({definition:[],idx:e,ignoreAmbiguities:o&&!0===t.IGNORE_AMBIGUITIES});Object(i.w)(t,"MAX_LOOKAHEAD")&&(s.maxLookahead=t.MAX_LOOKAHEAD);var c=Object(i.Q)(a,(function(t){return Object(i.B)(t.GATE)}));return s.hasPredicates=c,r.definition.push(s),Object(i.u)(a,(function(t){var e=new at({definition:[]});s.definition.push(e),Object(i.w)(t,"IGNORE_AMBIGUITIES")?e.ignoreAmbiguities=t.IGNORE_AMBIGUITIES:Object(i.w)(t,"GATE")&&(e.ignoreAmbiguities=!0),n.recordingProdStack.push(e),t.ALT.call(n),n.recordingProdStack.pop()})),Fe}function Ke(t){return 0===t?"":""+t}function Ye(t){if(t<0||t>Ue){var e=new Error("Invalid DSL Method idx value: <"+t+">\n\tIdx value must be a none negative value smaller than "+(Ue+1));throw e.KNOWN_RECORDER_ERROR=!0,e}}var Xe=function(){function t(){}return t.prototype.initPerformanceTracer=function(t){if(Object(i.w)(t,"traceInitPerf")){var e=t.traceInitPerf,n="number"==typeof e;this.traceInitMaxIdent=n?e:1/0,this.traceInitPerf=n?e>0:e}else this.traceInitMaxIdent=0,this.traceInitPerf=Qe.traceInitPerf;this.traceInitIndent=-1},t.prototype.TRACE_INIT=function(t,e){if(!0===this.traceInitPerf){this.traceInitIndent++;var n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(n+"--\x3e <"+t+">");var r=Object(i.R)(e),o=r.time,a=r.value,s=o>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(n+"<-- <"+t+"> time: "+o+"ms"),this.traceInitIndent--,a}return e()},t}(),$e=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),qe=tt(J,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(qe);var Ze,Qe=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Nt,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Je=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0});function tn(t){return void 0===t&&(t=void 0),function(){return t}}!function(t){t[t.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",t[t.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",t[t.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",t[t.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",t[t.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",t[t.LEFT_RECURSION=5]="LEFT_RECURSION",t[t.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",t[t.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",t[t.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",t[t.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",t[t.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",t[t.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",t[t.TOO_MANY_ALTS=12]="TOO_MANY_ALTS"}(Ze||(Ze={}));var en=function(){function t(t,e){this.definitionErrors=[],this.selfAnalysisDone=!1;if(this.initErrorHandler(e),this.initLexerAdapter(),this.initLooksAhead(e),this.initRecognizerEngine(t,e),this.initRecoverable(e),this.initTreeBuilder(e),this.initContentAssist(),this.initGastRecorder(e),this.initPerformanceTracer(e),Object(i.w)(e,"ignoredIssues"))throw new Error("The <ignoredIssues> IParserConfig property has been deprecated.\n\tPlease use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n\tSee: https://sap.github.io/chevrotain/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\tFor further details.");this.skipValidations=Object(i.w)(e,"skipValidations")?e.skipValidations:Qe.skipValidations}return t.performSelfAnalysis=function(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")},t.prototype.performSelfAnalysis=function(){var e=this;this.TRACE_INIT("performSelfAnalysis",(function(){var n;e.selfAnalysisDone=!0;var r=e.className;e.TRACE_INIT("toFastProps",(function(){Object(i.S)(e)})),e.TRACE_INIT("Grammar Recording",(function(){try{e.enableRecording(),Object(i.u)(e.definedRulesNames,(function(t){var n=e[t].originalGrammarAction,r=void 0;e.TRACE_INIT(t+" Rule",(function(){r=e.topLevelRuleRecord(t,n)})),e.gastProductionsCache[t]=r}))}finally{e.disableRecording()}}));var o=[];if(e.TRACE_INIT("Grammar Resolving",(function(){o=le({rules:Object(i.U)(e.gastProductionsCache)}),e.definitionErrors.push.apply(e.definitionErrors,o)})),e.TRACE_INIT("Grammar Validations",(function(){if(Object(i.A)(o)&&!1===e.skipValidations){var t=ue({rules:Object(i.U)(e.gastProductionsCache),maxLookahead:e.maxLookahead,tokenTypes:Object(i.U)(e.tokensMap),errMsgProvider:At,grammarName:r});e.definitionErrors.push.apply(e.definitionErrors,t)}})),Object(i.A)(e.definitionErrors)&&(e.recoveryEnabled&&e.TRACE_INIT("computeAllProdsFollows",(function(){var t,n,r=(t=Object(i.U)(e.gastProductionsCache),n={},Object(i.u)(t,(function(t){var e=new wt(t).startWalking();Object(i.f)(n,e)})),n);e.resyncFollows=r})),e.TRACE_INIT("ComputeLookaheadFunctions",(function(){e.preComputeLookaheadFunctions(Object(i.U)(e.gastProductionsCache))}))),!t.DEFER_DEFINITION_ERRORS_HANDLING&&!Object(i.A)(e.definitionErrors))throw n=Object(i.I)(e.definitionErrors,(function(t){return t.message})),new Error("Parser Definition Errors detected:\n "+n.join("\n-------------------------------\n"))}))},t.DEFER_DEFINITION_ERRORS_HANDLING=!1,t}();Object(i.e)(en,[Te,xe,Re,Me,Pe,_e,je,De,Ge,Xe]);var nn=function(t){function e(e,n){void 0===n&&(n=Qe);var r=Object(i.h)(n);return r.outputCst=!0,t.call(this,e,r)||this}return $e(e,t),e}(en),rn=function(t){function e(e,n){void 0===n&&(n=Qe);var r=Object(i.h)(n);return r.outputCst=!1,t.call(this,e,r)||this}return $e(e,t),e}(en);function on(t,e){var n=void 0===e?{}:e,i=n.resourceBase,o=void 0===i?"https://unpkg.com/chevrotain@"+r+"/diagrams/":i,a=n.css;return'\n\x3c!-- This is a generated file --\x3e\n<!DOCTYPE html>\n<meta charset="utf-8">\n<style>\n body {\n background-color: hsl(30, 20%, 95%)\n }\n</style>\n\n'+("\n<link rel='stylesheet' href='"+(void 0===a?"https://unpkg.com/chevrotain@"+r+"/diagrams/diagrams.css":a)+"'>\n")+("\n<script src='"+o+"vendor/railroad-diagrams.js'><\/script>\n<script src='"+o+"src/diagrams_builder.js'><\/script>\n<script src='"+o+"src/diagrams_behavior.js'><\/script>\n<script src='"+o+"src/main.js'><\/script>\n")+'\n<div id="diagrams" align="center"></div> \n'+("\n<script>\n window.serializedGrammar = "+JSON.stringify(t,null," ")+";\n<\/script>\n")+'\n<script>\n var diagramsDiv = document.getElementById("diagrams");\n main.drawDiagramsFromSerializedGrammar(serializedGrammar, diagramsDiv);\n<\/script>\n'}var an="\n";function sn(t){var e;return"\nfunction "+t.name+"(tokenVocabulary, config) {\n // invoke super constructor\n // No support for embedded actions currently, so we can 'hardcode'\n // The use of CstParser.\n chevrotain.CstParser.call(this, tokenVocabulary, config)\n\n const $ = this\n\n "+(e=t.rules,Object(i.I)(e,(function(t){return r=pn(n=1,'$.RULE("'+(e=t).name+'", function() {')+an,r+=fn(e.definition,n+1),r+=pn(n+1,"})")+an;var e,n,r})).join("\n")+"\n\n // very important to call this after all the rules have been defined.\n // otherwise the parser may not work correctly as it will lack information\n // derived during the self analysis phase.\n this.performSelfAnalysis(this)\n}\n\n// inheritance as implemented in javascript in the previous decade... :(\n")+t.name+".prototype = Object.create(chevrotain.CstParser.prototype)\n"+t.name+".prototype.constructor = "+t.name+" \n "}function cn(t,e){var n=pn(e,"$.OR"+t.idx+"([")+an,r=Object(i.I)(t.definition,(function(t){return function(t,e){var n=pn(e,"{")+an;return n+=pn(e+1,"ALT: function() {")+an,n+=fn(t.definition,e+1),n+=pn(e+1,"}")+an,n+=pn(e,"}")}(t,e+1)}));return n+=r.join(",\n"),n+=an+pn(e,"])\n")}function ln(t,e){if(t instanceof it)return function(t,e){return pn(e,"$.SUBRULE"+t.idx+"($."+t.nonTerminalName+")"+an)}(t,e);if(t instanceof st)return un("OPTION",t,e);if(t instanceof ct)return un("AT_LEAST_ONE",t,e);if(t instanceof lt)return un("AT_LEAST_ONE_SEP",t,e);if(t instanceof ht)return un("MANY_SEP",t,e);if(t instanceof ut)return un("MANY",t,e);if(t instanceof ft)return cn(t,e);if(t instanceof pt)return function(t,e){var n=t.terminalType.name;return pn(e,"$.CONSUME"+t.idx+"(this.tokensMap."+n+")"+an)}(t,e);if(t instanceof at)return fn(t.definition,e);throw Error("non exhaustive match")}function un(t,e,n){var r=pn(n,"$."+(t+e.idx)+"(");return e.separator?(r+="{\n",r+=pn(n+1,"SEP: this.tokensMap."+e.separator.name)+","+an,r+="DEF: "+hn(e.definition,n+2)+an,r+=pn(n,"}")+an):r+=hn(e.definition,n+1),r+=pn(n,")")+an}function hn(t,e){var n="function() {\n";return n+=fn(t,e),n+=pn(e,"}")+an}function fn(t,e){var n="";return Object(i.u)(t,(function(t){n+=ln(t,e+1)})),n}function pn(t,e){return Array(4*t+1).join(" ")+e}function dn(t){var e=function(t){return" \n"+sn(t)+"\nreturn new "+t.name+"(tokenVocabulary, config) \n"}({name:t.name,rules:t.rules}),r=new Function("tokenVocabulary","config","chevrotain",e);return function(e){return r(t.tokenVocabulary,e,n(4))}}function mn(t){return function(t){return"\n(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define(['chevrotain'], factory);\n } else if (typeof module === 'object' && module.exports) {\n // Node. Does not work with strict CommonJS, but\n // only CommonJS-like environments that support module.exports,\n // like Node.\n module.exports = factory(require('chevrotain'));\n } else {\n // Browser globals (root is window)\n root.returnExports = factory(root.b);\n }\n}(typeof self !== 'undefined' ? self : this, function (chevrotain) {\n\n"+sn(t)+"\n \nreturn {\n "+t.name+": "+t.name+" \n}\n}));\n"}({name:t.name,rules:t.rules})}function gn(){console.warn("The clearCache function was 'soft' removed from the Chevrotain API.\n\t It performs no action other than printing this message.\n\t Please avoid using it as it will be completely removed in the future")}var vn=function(){throw new Error("The Parser class has been deprecated, use CstParser or EmbeddedActionsParser instead.\t\nSee: https://sap.github.io/chevrotain/docs/changes/BREAKING_CHANGES.html#_7-0-0")}},function(t,e,n){"use strict";
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */Object.defineProperty(e,"__esModule",{value:!0}),e.AllTokens=e.Outdent=e.Indent=e.StringLiteral=e.NumberLiteral=e.Identifier=e.MultilineComment=e.SingleLineComment=e.WS=e.EndOfLine=e.OrMore=e.CaseSensitive=e.CaseInsensitive=e.CarriageReturn=e.Newline=e.Repeat=e.Called=e.Create=e.To=e.From=e.Exclusive=e.Inclusive=e.Exactly=e.Times=e.A=e.Group=e.Linefeed=e.Tab=e.Between=e.Not=e.Matching=e.Exact=e.Multiline=e.Global=e.Using=e.Unicode=e.Number=e.Boundary=e.Whitespace=e.Integer=e.Decimal=e.Letter=e.Character=e.Digit=e.Word=e.And=e.Or=e.Anything=e.Then=e.Match=e.Optional=e.Ten=e.Nine=e.Eight=e.Seven=e.Six=e.Five=e.Four=e.Three=e.Two=e.One=e.Zero=void 0;const r=n(4);e.Zero=r.createToken({name:"Zero",pattern:/zero/i}),e.One=r.createToken({name:"One",pattern:/one/i}),e.Two=r.createToken({name:"Two",pattern:/two/i}),e.Three=r.createToken({name:"Three",pattern:/three/i}),e.Four=r.createToken({name:"Four",pattern:/four/i}),e.Five=r.createToken({name:"Five",pattern:/five/i}),e.Six=r.createToken({name:"Six",pattern:/six/i}),e.Seven=r.createToken({name:"Seven",pattern:/seven/i}),e.Eight=r.createToken({name:"Eight",pattern:/eight/i}),e.Nine=r.createToken({name:"Nine",pattern:/nine/i}),e.Ten=r.createToken({name:"Ten",pattern:/ten/i}),e.Optional=r.createToken({name:"Optional",pattern:/(optional(ly)?|possibl[ye]|maybe)/i}),e.Match=r.createToken({name:"Match",pattern:/match(es)?/i}),e.Then=r.createToken({name:"Then",pattern:/then/i}),e.Anything=r.createToken({name:"Anything",pattern:/(any thing|any|anything)(s)?/i}),e.Or=r.createToken({name:"Or",pattern:/or/i}),e.And=r.createToken({name:"And",pattern:/and|,/i}),e.Word=r.createToken({name:"WordSpecifier",pattern:/word(s)?/i}),e.Digit=r.createToken({name:"DigitSpecifier",pattern:/digit(s)?/i}),e.Character=r.createToken({name:"CharacterSpecifier",pattern:/character(s)?/i}),e.Letter=r.createToken({name:"LetterSpecifier",pattern:/letter(s)?/i}),e.Decimal=r.createToken({name:"DecimalSpecifier",pattern:/decimal(s)?/i}),e.Integer=r.createToken({name:"IntegerSpecifier",pattern:/integer(s)?/i}),e.Whitespace=r.createToken({name:"WhitespaceSpecifier",pattern:/(white space|whitespace)s?/i}),e.Boundary=r.createToken({name:"BoundarySpecifier",pattern:/(word )?boundary/i}),e.Number=r.createToken({name:"NumberSpecifier",pattern:/number(s)?/i}),e.Unicode=r.createToken({name:"UnicodeSpecifier",pattern:/unicode( class)?/i}),e.Using=r.createToken({name:"Using",pattern:/using/i}),e.Global=r.createToken({name:"Global",pattern:/global/i}),e.Multiline=r.createToken({name:"Multiline",pattern:/(multi line|multiline)/i}),e.Exact=r.createToken({name:"Exact",pattern:/exact/i}),e.Matching=r.createToken({name:"Matching",pattern:/matching/i}),e.Not=r.createToken({name:"Not",pattern:/not|anything but|any thing but|everything but|every thing but/i}),e.Between=r.createToken({name:"Between",pattern:/between/i}),e.Tab=r.createToken({name:"Tab",pattern:/tab/i}),e.Linefeed=r.createToken({name:"Linefeed",pattern:/(line feed|linefeed)/i}),e.Group=r.createToken({name:"Group",pattern:/group/i}),e.A=r.createToken({name:"A",pattern:/a(n)?/i}),e.Times=r.createToken({name:"Times",pattern:/times/i}),e.Exactly=r.createToken({name:"Exactly",pattern:/exact(ly)?/i}),e.Inclusive=r.createToken({name:"Inclusive",pattern:/inclusive(ly)?/i}),e.Exclusive=r.createToken({name:"Exclusive",pattern:/exclusive(ly)?/i}),e.From=r.createToken({name:"From",pattern:/from/i}),e.To=r.createToken({name:"To",pattern:/(to|through|thru|\-|\.\.\.?)/i}),e.Create=r.createToken({name:"Create",pattern:/create(s)?/i}),e.Called=r.createToken({name:"Called",pattern:/name(d)?|call(ed)?/i}),e.Repeat=r.createToken({name:"Repeat",pattern:/repeat(s|ing)?/i}),e.Newline=r.createToken({name:"Newline",pattern:/(new line|newline)/i}),e.CarriageReturn=r.createToken({name:"CarriageReturn",pattern:/carriage return/i}),e.CaseInsensitive=r.createToken({name:"CaseInsensitive",pattern:/case insensitive/i}),e.CaseSensitive=r.createToken({name:"CaseSensitive",pattern:/case sensitive/i}),e.OrMore=r.createToken({name:"OrMore",pattern:/\+|or more/i}),e.EndOfLine=r.createToken({name:"EOL",pattern:/\n/}),e.WS=r.createToken({name:"Whitespace",pattern:/[^\S\n]+/,start_chars_hint:[" ","\r"],group:r.Lexer.SKIPPED}),e.SingleLineComment=r.createToken({name:"SingleLineComment",pattern:/(#|\/\/).*/,group:r.Lexer.SKIPPED}),e.MultilineComment=r.createToken({name:"MultiLineComment",pattern:/\/\*(.*)\*\//,line_breaks:!0,group:r.Lexer.SKIPPED}),e.Identifier=r.createToken({name:"Identifier",pattern:/[a-z]\w*/i}),e.NumberLiteral=r.createToken({name:"NumberLiteral",pattern:/\d+/}),e.StringLiteral=r.createToken({name:"StringLiteral",pattern:/"(?:[^\\"]|\\(?:[bfnrtv"\\/]|u[0-9a-f]{4}|U[0-9a-f]{8}))*"/i}),e.Indent=r.createToken({name:"Indent"}),e.Outdent=r.createToken({name:"Outdent"}),e.AllTokens=[e.Zero,e.One,e.Two,e.Three,e.Four,e.Five,e.Six,e.Seven,e.Eight,e.Nine,e.Ten,e.Optional,e.Matching,e.Match,e.Then,e.Not,e.Anything,e.And,e.Boundary,e.Word,e.Digit,e.Letter,e.Decimal,e.Integer,e.Character,e.Whitespace,e.Number,e.Unicode,e.Using,e.Global,e.Multiline,e.Exact,e.Between,e.Tab,e.Linefeed,e.Group,e.A,e.Times,e.Exactly,e.Inclusive,e.Exclusive,e.From,e.Create,e.Called,e.Repeat,e.Newline,e.CarriageReturn,e.CaseInsensitive,e.CaseSensitive,e.OrMore,e.Or,e.To,e.EndOfLine,e.Indent,e.WS,e.SingleLineComment,e.MultilineComment,e.Identifier,e.NumberLiteral,e.StringLiteral]},function(t,e,n){"use strict";
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */Object.defineProperty(e,"__esModule",{value:!0}),e.minimizeMatchString=e.RegularExpressionCST=e.GroupStatementCST=e.RepeatStatementCST=e.MatchStatementCST=e.CountSubStatementCST=e.UsingStatementCST=e.MatchSubStatementCST=e.StatementCST=e.MatchStatementValue=e.MatchSubStatementValue=e.MatchSubStatementType=e.UsingFlags=e.H2RCST=e.RegexDialect=void 0;const r=n(2);var i;!function(t){t[t.JS=0]="JS",t[t.PCRE=1]="PCRE",t[t.DotNet=2]="DotNet",t[t.Java=3]="Java",t[t.Python=4]="Python",t[t.Boost=5]="Boost"}(i=e.RegexDialect||(e.RegexDialect={}));const o=["C","Cc","Cf","Cn","Co","Cs","L","Ll","Lm","Lo","Lt","Lu","M","Mc","Me","Mn","N","Nd","Nl","No","P","Pc","Pd","Pe","Pf","Pi","Po","Ps","S","Sc","Sk","Sm","So","Z","Zl","Zp","Zs"],a=["Arabic","Armenian","Avestan","Balinese","Bamum","Batak","Bengali","Bopomofo","Brahmi","Braille","Buginese","Buhid","Canadian_Aboriginal","Carian","Chakma","Cham","Cherokee","Common","Coptic","Cuneiform","Cypriot","Cyrillic","Deseret","Devanagari","Egyptian_Hieroglyphs","Ethiopic","Georgian","Glagolitic","Gothic","Greek","Gujarati","Gurmukhi","Han","Hangul","Hanunoo","Hebrew","Hiragana","Imperial_Aramaic","Inherited","Inscriptional_Pahlavi","Inscriptional_Parthian","Javanese","Kaithi","Kannada","Katakana","Kayah_Li","Kharoshthi","Khmer","Lao","Latin","Lepcha","Limbu","Linear_B","Lisu","Lycian","Lydian","Malayalam","Mandaic","Meetei_Mayek","Meroitic_Cursive","Meroitic_Hieroglyphs","Miao","Mongolian","Myanmar","New_Tai_Lue","Nko","Ogham","Old_Italic","Old_Persian","Old_South_Arabian","Old_Turkic","Ol_Chiki","Oriya","Osmanya","Phags_Pa","Phoenician","Rejang","Runic","Samaritan","Saurashtra","Sharada","Shavian","Sinhala","Sora_Sompeng","Sundanese","Syloti_Nagri","Syriac","Tagalog","Tagbanwa","Tai_Le","Tai_Tham","Tai_Viet","Takri","Tamil","Telugu","Thaana","Thai","Tibetan","Tifinagh","Ugaritic","Vai","Yi"];class s{constructor(t){this.tokens=t}error(t){var e,n,i;const o=r.first(this.tokens),a=r.last(this.tokens);return{startLine:null!==(e=o.startLine)&&void 0!==e?e:NaN,startColumn:null!==(n=o.startColumn)&&void 0!==n?n:NaN,length:(null!==(i=a.endOffset)&&void 0!==i?i:a.startOffset)-o.startOffset,message:t}}}var c,l;e.H2RCST=s,function(t){t[t.Multiline=r.makeFlag(0)]="Multiline",t[t.Global=r.makeFlag(1)]="Global",t[t.Sensitive=r.makeFlag(2)]="Sensitive",t[t.Insensitive=r.makeFlag(3)]="Insensitive",t[t.Exact=r.makeFlag(4)]="Exact"}(c=e.UsingFlags||(e.UsingFlags={})),function(t){t[t.SingleString=0]="SingleString",t[t.Between=1]="Between",t[t.Anything=2]="Anything",t[t.Word=3]="Word",t[t.Digit=4]="Digit",t[t.Character=5]="Character",t[t.Whitespace=6]="Whitespace",t[t.Number=7]="Number",t[t.Tab=8]="Tab",t[t.Linefeed=9]="Linefeed",t[t.Newline=10]="Newline",t[t.CarriageReturn=11]="CarriageReturn",t[t.Boundary=12]="Boundary",t[t.Unicode=13]="Unicode",t[t.Letter=14]="Letter",t[t.Decimal=15]="Decimal",t[t.Integer=16]="Integer"}(l=e.MatchSubStatementType||(e.MatchSubStatementType={}));e.MatchSubStatementValue=class{constructor(t,e=null,n=null){this.type=t,this.from=e,this.to=n}};e.MatchStatementValue=class{constructor(t,e){this.optional=t,this.statement=e}};class u extends s{}e.StatementCST=u;e.MatchSubStatementCST=class extends s{constructor(t,e,n=!1,r){super(t),this.count=e,this.invert=n,this.values=r}validate(t){const e=[];this.count&&r.append(e,this.count.validate(t));for(const n of this.values)if(n.type===l.Between){let t=r.removeQuotes(n.from),i=r.removeQuotes(n.to);r.isSingleRegexCharacter(t)?(t.startsWith("\\u")||t.startsWith("\\U")||t.startsWith("\\"))&&(t=JSON.parse(`"${t}"`)):e.push(this.error("Between statement must begin with a single character")),r.isSingleRegexCharacter(i)?(i.startsWith("\\u")||i.startsWith("\\U")||i.startsWith("\\"))&&(i=JSON.parse(`"${i}"`)):e.push(this.error("Between statement must end with a single character")),t.charCodeAt(0)>=i.charCodeAt(0)&&e.push(this.error("Between statement range invalid"))}else if(n.type===l.Unicode){let s=r.removeQuotes(n.from);if(!o.includes(s)){if(t===i.DotNet||t===i.Java){if(!s.startsWith("Is")){e.push(this.error("This dialect requires script names to begin with Is, such as IsCyrillic rather than Cyrillic"));continue}s=s.substr(2)}a.includes(s)||e.push(this.error("Unknown unicode specifier "+n.from))}}return e}toRegex(t){const e=[];for(const n of this.values)switch(n.type){case l.SingleString:{const t=r.regexEscape(r.removeQuotes(n.from));e.push(this.invert?`(?!${t})`:t);break}case l.Between:{const t=r.removeQuotes(n.from),i=r.removeQuotes(n.to);e.push(this.invert?`[^${t}-${i}]`:`[${t}-${i}]`);break}case l.Unicode:{const t=r.removeQuotes(n.from);e.push(this.invert?`\\P{${t}}`:`\\p{${t}}`);break}case l.Boundary:e.push(this.invert?"\\B":"\\b");break;case l.Word:e.push(this.invert?"\\W+":"\\w+");break;case l.Letter:t===i.PCRE?e.push(this.invert?"[^[:alpha:]]":"[[:alpha:]]"):e.push(this.invert?"[^a-zA-Z]":"[a-zA-Z]");break;case l.Integer:e.push(this.invert?"(?![+-]?\\d+)":"[+-]?\\d+");break;case l.Decimal:e.push(this.invert?"(?![+-]?(?:(?:\\d+[,.]?\\d*)|(?:[,.]\\d+)))":"[+-]?(?:(?:\\d+[,.]?\\d*)|(?:[,.]\\d+))");break;case l.Digit:e.push(this.invert?"\\D":"\\d");break;case l.Character:e.push(this.invert?"\\W":"\\w");break;case l.Whitespace:e.push(this.invert?"\\S":"\\s");break;case l.Number:e.push(this.invert?"\\D+":"\\d+");break;case l.Tab:e.push(this.invert?"[^\\t]":"\\t");break;case l.Newline:case l.Linefeed:e.push(this.invert?"[^\\n]":"\\n");break;case l.CarriageReturn:e.push(this.invert?"[^\\r]":"\\r");break;default:e.push(this.invert?"[^.]":".")}let n="",o=!1,a=!1;if(1===e.length?(n=r.first(e),n.endsWith("+")&&(a=!0)):(n=h(e),!(n.length>1)||n.startsWith("(")&&n.endsWith("[")||(o=!0)),this.count)if(a){const e=this.count.toRegex(t);switch(e){case"*":case"?":n="(?:"+n+")"+e;break;case"+":break;default:e.startsWith("{0")?n="(?:"+n+")"+e:n.substring(0,n.length-1)}}else o&&(n="(?:"+n+")"),n+=this.count.toRegex(t);return n}};e.UsingStatementCST=class extends s{constructor(t,e){super(t),this.flags=e}validate(t){r.unusedParameter(t,"Using Statement does not change based on language");const e=[];let n=this.flags[0];for(let t=1;t<this.flags.length;t++)r.hasFlag(n,this.flags[t])&&e.push(this.error("Duplicate modifier: "+c[this.flags[t]])),n=r.combineFlags(n,this.flags[t]);return r.hasFlag(n,c.Sensitive)&&r.hasFlag(n,c.Insensitive)&&e.push(this.error("Cannot be both case sensitive and insensitive")),e}toRegex(t){r.unusedParameter(t,"Using Statement does not change based on language");let e="",n=!1;for(const t of this.flags)r.hasFlag(t,c.Multiline)?e+="m":r.hasFlag(t,c.Global)?e+="g":r.hasFlag(t,c.Insensitive)?e+="i":r.hasFlag(t,c.Exact)&&(n=!0);return n?"/^{regex}$/"+e:"/{regex}/"+e}};e.CountSubStatementCST=class extends s{constructor(t,e,n=null,r=null){super(t),this.from=e,this.to=n,this.opt=r}validate(t){r.unusedParameter(t,"Count does not need checking");const e=[];return this.from<0?e.push(this.error("Value cannot be negative")):null!==this.to&&("exclusive"===this.opt&&this.to-1<=this.from||this.to<=this.from)&&e.push(this.error("Values must be in range of eachother")),e}toRegex(t){r.unusedParameter(t,"Count does not change from language");const e=this.from;let n=this.to;if(null===n){if(1===e)return"+"===this.opt?"+":"*";if(0===e)return"+"===this.opt?"*":"{0}"}return null!==n?("exclusive"===this.opt&&n--,`{${e},${n}}`):"+"===this.opt?`{${e},}`:`{${e}}`}};e.MatchStatementCST=class extends u{constructor(t,e,n){super(t),this.completely_optional=e,this.matches=n}validate(t){const e=[];for(const n of this.matches)r.append(e,n.statement.validate(t));return e}toRegex(t){let e=this.matches.map(e=>{let n=e.statement.toRegex(t);return e.optional&&(r.isSingleRegexCharacter(n)||"("!==n[0]&&")"!==n[n.length-1]&&(n="(?:"+n+")"),n+="?"),n}).join("");return this.completely_optional&&(r.isSingleRegexCharacter(e)||"("!==e[0]&&")"!==e[e.length-1]&&(e="(?:"+e+")"),e+="?"),e}};e.RepeatStatementCST=class extends u{constructor(t,e,n,r){super(t),this.optional=e,this.count=n,this.statements=r}validate(t){const e=[];null!==this.count&&r.append(e,this.count.validate(t));for(const n of this.statements)r.append(e,n.validate(t));return e}toRegex(t){let e="(?:"+this.statements.map(e=>e.toRegex(t)).join("")+")";return this.count?(e+=this.count.toRegex(t),this.optional&&(e="(?:"+e+")?")):(e+="*",this.optional&&(e+="?")),e}};e.GroupStatementCST=class extends u{constructor(t,e,n,r){super(t),this.optional=e,this.name=n,this.statements=r}validate(t){const e=[];for(const n of this.statements)r.append(e,n.validate(t));return e}toRegex(t){let e="(";return null!==this.name&&(e+="?",t!==i.Python&&t!==i.PCRE||(e+="P"),e+=`<${this.name}>`),e+=this.statements.map(e=>e.toRegex(t)).join(""),e+=this.optional?")?":")",e}};function h(t){return function t(e,n=0){if(0===e.length)return"";if(1===e.length)return r.first(e)+"?";if(1===(e=[...new Set(e)]).length)return r.first(e);if(e.every(r.isSingleRegexCharacter))return"["+e.join("")+"]";let i=r.first(e),o=r.first(e);for(let t=1;t<e.length;t++){for(let n=0;n<i.length;n++)if(e[t].length<n||i[n]!==e[t][n]){i=i.substr(0,n);break}for(let n=0;n<o.length;n++)if(e[t].length-n<0||o[o.length-n-1]!==e[t][e[t].length-n-1]){o=o.substr(o.length-n,o.length);break}if(0===i.length&&0===o.length)break}if(0===i.length&&0===o.length)return n>0?"(?:"+e.join("|")+")":e.join("|");{const r=i.length,a=o.length,s=[];for(const t of e){const e=t.substring(r,t.length-a);0!==e.length&&s.push(e)}return i+t(s,n+1)+o}}(t,0)}e.RegularExpressionCST=class extends s{constructor(t,e,n){super(t),this.usings=e,this.statements=n}validate(t){const e=this.usings.validate(t);for(const n of this.statements)r.append(e,n.validate(t));return e}toRegex(t){const e=this.usings.toRegex(t),n=this.statements.map(e=>e.toRegex(t)).join("");return e.replace("{regex}",n)}},e.minimizeMatchString=h},function(t,e,n){"use strict";
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(8),o=n(9),a=n(6),s=n(2),c=r(n(3));n(10),n(11),n(12),n(13),n(14),n(15),n(16);const l=c.default;document.addEventListener("DOMContentLoaded",(function(){l.defineSimpleMode("human2regex",{start:[{token:"number",regex:/zero|one|two|three|four|five|six|seven|eight|nine|ten/i},{token:"qualifier",regex:/(optional(ly)?|possibl[ye]|maybe)/i},{token:"builtin",regex:/matching/i},{token:"keyword",regex:/match(es)?/i},{token:"operator",regex:/then/i},{token:"operator",regex:/not|anything but|any thing but|everything but|every thing but/i},{token:"builtin",regex:/(any thing|any|anything)(s)?/i},{token:"operator",regex:/or/i},{token:"operator",regex:/and|,/i},{token:"builtin",regex:/unicode( class)?/i},{token:"builtin",regex:/(word )?boundary/i},{token:"builtin",regex:/word(s)?/i},{token:"builtin",regex:/digit(s)?/i},{token:"builtin",regex:/character(s)?/i},{token:"builtin",regex:/letter(s)?/i},{token:"builtin",regex:/decimal(s)?/i},{token:"builtin",regex:/integer(s)?/i},{token:"builtin",regex:/(white space|whitespace)(s)?/i},{token:"builtin",regex:/number(s)?/i},{token:"keyword",regex:/using/i},{token:"builtin",regex:/global/i},{token:"builtin",regex:/(multi line|multiline)/i},{token:"builtin",regex:/exact/i},{token:"keyword",regex:/between/i},{token:"builtin",regex:/tab/i},{token:"builtin",regex:/(line feed|linefeed)/i},{token:"keyword",regex:/group/i},{token:"keyword",regex:/a(n)?/i},{token:"keyword",regex:/times/i},{token:"keyword",regex:/exact(ly)?/i},{token:"keyword",regex:/inclusive(ly)?/i},{token:"keyword",regex:/exclusive(ly)?/i},{token:"keyword",regex:/from/i},{token:"keyword",regex:/(to|through|thru|\-|\.\.\.?)/i},{token:"keyword",regex:/create(s)?/i},{token:"keyword",regex:/name(d)?|call(ed)?/i},{token:"keyword",regex:/repeat(s|ing)?/i},{token:"builtin",regex:/(new line|newline)/i},{token:"builtin",regex:/carriage return/i},{token:"builtin",regex:/case insensitive/i},{token:"builtin",regex:/case sensitive/i},{token:"operator",regex:/\+|or more/i},{token:"variable",regex:/[a-z]\w*/i},{token:"number",regex:/\d+/},{token:"string",regex:/"(?:[^\\"]|\\(?:[bfnrtv"\\/]|u[0-9a-f]{4}|U[0-9a-f]{8}))*"/i},{token:"comment",regex:/(#|\/\/).*/},{token:"comment",regex:/\/\*/,next:"comment"}],comment:[{regex:/.*?\*\//,token:"comment",next:"start"},{regex:/.*/,token:"comment"}],meta:{dontIndentStates:["comment"],lineComment:"//",blockComment:["/*","*/"]}});const t=document.getElementById("regex"),e=document.getElementById("dialect"),n=document.getElementById("clip"),r=document.getElementById("human"),c=document.getElementById("errors"),u=document.getElementsByTagName("code");for(let t=0;t<u.length;t++)l.runMode(u[t].innerText,"human2regex",u[t]);if(!(t&&e&&n&&r&&c))return;const h=new i.Human2RegexLexer(new i.Human2RegexLexerOptions(!0)),f=new o.Human2RegexParser(new o.Human2RegexParserOptions(!0));let p=[],d="",m=a.RegexDialect.JS;function g(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function v(e){if(!c||!t)return;g(c),c.appendChild(document.createTextNode("Compiling...")),p=[];const n=h.tokenize(e);if(n.errors.forEach(t=>p.push(t)),0===p.length){const e=f.parse(n.tokens);if(f.errors.map(s.CommonError.fromParseError).forEach(t=>p.push(t)),0===p.length){e.validate(m).forEach(t=>p.push(t)),0===p.length&&(d=e.toRegex(m),t.setAttribute("value",d))}}g(c);for(const t of p)c.appendChild(document.createTextNode(t.toString()+"\n"))}l.registerHelper("lint","human2regex",(function(t){s.unusedParameter(t,"Text is not needed in this instance as we do no parsing");const e=[];for(const t of p){const n=l.Pos(t.start_line-1,t.start_column-1),r=l.Pos(t.start_line-1,t.start_column-1+t.length);e.push({from:n,to:r,message:t.message})}return e}));const y=l.fromTextArea(r,{mode:"human2regex",lineNumbers:!1,indentUnit:4,viewportMargin:1/0,theme:"idea",lint:!0});y.on("change",()=>{v(y.getValue())}),e.addEventListener("change",()=>{const t=e.selectedIndex,n=e.options[t].value;m=function(t){switch(t){case"dotnet":return a.RegexDialect.DotNet;case"java":return a.RegexDialect.Java;case"pcre":return a.RegexDialect.PCRE;case"python":return a.RegexDialect.Python;case"boost":return a.RegexDialect.Boost;default:return a.RegexDialect.JS}}(n),v(y.getValue())}),n.addEventListener("click",()=>{t.select(),window.isSecureContext&&s.usefulConditional(navigator.clipboard,"clipboard may be undefined")&&s.usefulConditional(navigator.clipboard.writeText,"writeText may be undefined")?navigator.clipboard.writeText(d):document.execCommand("copy")}),v(y.getValue())}))},function(t,e,n){"use strict";
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */Object.defineProperty(e,"__esModule",{value:!0}),e.Human2RegexLexer=e.TokenizeResult=e.Human2RegexLexerOptions=e.IndentType=void 0;const r=n(4),i=n(2),o=n(5);var a;!function(t){t[t.Tabs=0]="Tabs",t[t.Spaces=1]="Spaces",t[t.Both=2]="Both"}(a=e.IndentType||(e.IndentType={}));class s{constructor(t=!1,e=a.Both,n=4){this.skip_validations=t,this.type=e,this.spaces_per_tab=n}}e.Human2RegexLexerOptions=s;class c{constructor(t,e){this.tokens=t,this.errors=e}}e.TokenizeResult=c;class l{constructor(t=new s){if(l.already_init)throw new Error("Only 1 instance of Human2RegexLexer allowed");l.already_init=!0,this.setOptions(t)}setOptions(t){this.options=t;let e=null;if(this.options.type===a.Tabs)e=/\t/y;else{let t=` {${this.options.spaces_per_tab}}`;this.options.type===a.Both&&(t+="|\\t"),e=new RegExp(t,"y")}o.Indent.PATTERN=e,this.lexer=new r.Lexer(o.AllTokens,{ensureOptimizations:!0,skipValidations:t.skip_validations})}lexError(t){var e,n,r;return{offset:t.startOffset,line:null!==(e=t.startLine)&&void 0!==e?e:NaN,column:null!==(n=t.startColumn)&&void 0!==n?n:NaN,length:null!==(r=t.endOffset)&&void 0!==r?r:NaN-t.startOffset,message:"Unexpected indentation found"}}tokenize(t){var e,n,a,s,l,u,h,f,p,d,m,g,v,y;const b=this.lexer.tokenize(t);if(0===b.tokens.length)return new c(b.tokens,b.errors.map(i.CommonError.fromLexError));const T=[],O=[0];let S=0,x=!0,E=!1;for(let t=0;t<b.tokens.length;t++)if(b.tokens[t].tokenType===o.EndOfLine)0===T.length||T[T.length-1].tokenType===o.EndOfLine||(x=!0,T.push(b.tokens[t]));else if(b.tokens[t].tokenType===o.Indent){E=!0,S=1;const c=b.tokens[t];let l=b.tokens[t].image.length;for(;b.tokens.length>t+1&&b.tokens[t+1].tokenType===o.Indent;)S++,t++,l+=b.tokens[t].image.length;if(c.endOffset=c.startOffset+l,c.endColumn=b.tokens[t].endColumn,b.tokens.length>t+1&&b.tokens[t+1].tokenType===o.EndOfLine);else if(!x||S>i.last(O)+1)b.errors.push(this.lexError(c));else if(S>i.last(O))O.push(S),T.push(c);else if(S<i.last(O)){const t=i.findLastIndex(O,S);if(t<0)b.errors.push(this.lexError(c));else{const i=O.length-t-1;for(let t=0;t<i;t++)O.pop(),T.push(r.createTokenInstance(o.Outdent,"",c.startOffset,c.startOffset+l,null!==(e=c.startLine)&&void 0!==e?e:NaN,null!==(n=c.endLine)&&void 0!==n?n:NaN,null!==(a=c.startColumn)&&void 0!==a?a:NaN,(null!==(s=c.startColumn)&&void 0!==s?s:NaN)+l))}}}else{if(x&&!E){const e=b.tokens[t];for(;O.length>1;)O.pop(),T.push(r.createTokenInstance(o.Outdent,"",e.startOffset,e.startOffset,null!==(l=e.startLine)&&void 0!==l?l:NaN,NaN,null!==(u=e.startColumn)&&void 0!==u?u:NaN,NaN))}x=!1,E=!1,T.push(b.tokens[t])}const C=i.last(T);for(T.length>0&&C.tokenType!==o.EndOfLine&&T.push(r.createTokenInstance(o.EndOfLine,"\n",null!==(h=C.endOffset)&&void 0!==h?h:NaN,null!==(f=C.endOffset)&&void 0!==f?f:NaN,null!==(p=C.startLine)&&void 0!==p?p:NaN,NaN,null!==(d=C.startColumn)&&void 0!==d?d:NaN,NaN));O.length>1;)O.pop(),T.push(r.createTokenInstance(o.Outdent,"",null!==(m=C.endOffset)&&void 0!==m?m:NaN,null!==(g=C.endOffset)&&void 0!==g?g:NaN,null!==(v=C.startLine)&&void 0!==v?v:NaN,NaN,null!==(y=C.startColumn)&&void 0!==y?y:NaN,NaN));return new c(T,b.errors.map(i.CommonError.fromLexError))}}e.Human2RegexLexer=l,l.already_init=!1},function(t,e,n){"use strict";
/*! Copyright (c) 2020 Patrick Demian; Licensed under MIT */var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n),Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[n]}})}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.Human2RegexParser=e.ParseResult=e.Human2RegexParserOptions=void 0;const a=n(4),s=o(n(5)),c=n(6),l=n(2);class u{constructor(t=!1){this.skip_validations=t}}e.Human2RegexParserOptions=u;class h{constructor(t,e){this.token=t,this.value=e}}class f{constructor(t,e){this.tokens=t,this.value=e}}class p{constructor(t,e){this.regexp_cst=t,this.errors=e}validate(t){return this.regexp_cst.validate(t).map(l.CommonError.fromSemanticError)}toRegex(t){return this.regexp_cst.toRegex(t)}toRegExp(t){return new RegExp(this.regexp_cst.toRegex(t))}}e.ParseResult=p;class d extends a.EmbeddedActionsParser{constructor(t=new u){if(super(s.AllTokens,{recoveryEnabled:!1,maxLookahead:2,skipValidations:t.skip_validations}),this.options=t,d.already_init)throw new Error("Only 1 instance of Human2RegexParser allowed");d.already_init=!0;const e=this;let n=null;const r=e.RULE("NumberSubStatement",()=>e.OR(n||(n=[{ALT:()=>new h(e.CONSUME(s.Zero),0)},{ALT:()=>new h(e.CONSUME(s.One),1)},{ALT:()=>new h(e.CONSUME(s.Two),2)},{ALT:()=>new h(e.CONSUME(s.Three),3)},{ALT:()=>new h(e.CONSUME(s.Four),4)},{ALT:()=>new h(e.CONSUME(s.Five),5)},{ALT:()=>new h(e.CONSUME(s.Six),6)},{ALT:()=>new h(e.CONSUME(s.Seven),7)},{ALT:()=>new h(e.CONSUME(s.Eight),8)},{ALT:()=>new h(e.CONSUME(s.Nine),9)},{ALT:()=>new h(e.CONSUME(s.Ten),10)},{ALT:()=>{const t=e.CONSUME(s.NumberLiteral);return new h(t,parseInt(t.image))}}]))),i=e.RULE("CountSubStatement",()=>e.OR([{ALT:()=>{const t=[];t.push(e.CONSUME(s.Between));const n=e.SUBRULE4(r);e.OR3([{ALT:()=>e.CONSUME2(s.To)},{ALT:()=>e.CONSUME(s.And)}]);const i=e.SUBRULE5(r);t.push(i.token),e.OPTION4(()=>t.push(e.CONSUME3(s.Times)));const o=e.OPTION5(()=>e.OR4([{ALT:()=>(t.push(e.CONSUME(s.Inclusive)),"inclusive")},{ALT:()=>(t.push(e.CONSUME(s.Exclusive)),"exclusive")}]));return new c.CountSubStatementCST(t,n.value,i.value,o)}},{ALT:()=>{const t=[];e.OPTION2(()=>t.push(e.CONSUME(s.From)));const n=e.SUBRULE2(r),i=e.OR2([{ALT:()=>new h(e.CONSUME(s.OrMore),[null,"+"])},{ALT:()=>{e.CONSUME(s.To);const t=e.SUBRULE3(r);let n=t.token;const i=e.OPTION7(()=>e.OR5([{ALT:()=>(n=e.CONSUME2(s.Inclusive),"inclusive")},{ALT:()=>(n=e.CONSUME2(s.Exclusive),"exclusive")}]));return new h(n,[t.value,i])}}]);return t.push(i.token),e.OPTION3(()=>t.push(e.CONSUME2(s.Times))),new c.CountSubStatementCST(t,n.value,i.value?i.value[0]:null,i.value?i.value[1]:null)}},{ALT:()=>{const t=[];e.OPTION(()=>t.push(e.CONSUME(s.Exactly)));const n=e.SUBRULE(r);return t.push(n.token),e.OPTION6(()=>t.push(e.CONSUME(s.Times))),new c.CountSubStatementCST(t,n.value)}}]));let o=null;const a=e.RULE("MatchSubStatement",()=>{let t=null,n=!1;const r=[];let a=null,u=null,h=null,f=c.MatchSubStatementType.Anything,p=[];return t=e.OPTION(()=>{const t=e.SUBRULE(i);return l.usefulConditional(t.tokens,"due to how chevrotain works, the first run produces a null value")&&p.push(l.first(t.tokens)),t}),n=e.OPTION2(()=>(p.push(e.CONSUME(s.Not)),!0)),e.AT_LEAST_ONE_SEP({SEP:s.Or,DEF:()=>{e.OPTION3(()=>e.CONSUME(s.A));const t=e.OR(o||(o=[{ALT:()=>{const t=e.OPTION4(()=>e.CONSUME(s.From)),n=e.CONSUME2(s.StringLiteral);a=n.image,e.CONSUME(s.To);const r=e.CONSUME3(s.StringLiteral);return h=r.image,f=c.MatchSubStatementType.Between,l.usefulConditional(t,"Bug in type definition. Option should return <T|undefined>, but it doesn't")?{tokens:[t,r],statement:new c.MatchSubStatementValue(f,a,h)}:{tokens:[n,r],statement:new c.MatchSubStatementValue(f,a,h)}}},{ALT:()=>{const t=e.CONSUME(s.Between);a=e.CONSUME4(s.StringLiteral).image,e.CONSUME(s.And);const n=e.CONSUME5(s.StringLiteral);return h=n.image,f=c.MatchSubStatementType.Between,{tokens:[t,n],statement:new c.MatchSubStatementValue(f,a,h)}}},{ALT:()=>{const t=e.CONSUME(s.StringLiteral);return u=t.image,f=c.MatchSubStatementType.SingleString,{tokens:[t],statement:new c.MatchSubStatementValue(f,u)}}},{ALT:()=>{const t=e.CONSUME(s.Unicode),n=e.CONSUME6(s.StringLiteral);return u=n.image,f=c.MatchSubStatementType.Unicode,{tokens:[t,n],statement:new c.MatchSubStatementValue(f,u)}}},{ALT:()=>{const t=e.CONSUME(s.Anything);return f=c.MatchSubStatementType.Anything,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Boundary);return f=c.MatchSubStatementType.Boundary,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Word);return f=c.MatchSubStatementType.Word,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Digit);return f=c.MatchSubStatementType.Digit,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Character);return f=c.MatchSubStatementType.Character,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Letter);return f=c.MatchSubStatementType.Letter,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Decimal);return f=c.MatchSubStatementType.Decimal,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Integer);return f=c.MatchSubStatementType.Integer,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Whitespace);return f=c.MatchSubStatementType.Whitespace,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Number);return f=c.MatchSubStatementType.Number,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Tab);return f=c.MatchSubStatementType.Tab,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Linefeed);return f=c.MatchSubStatementType.Linefeed,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Newline);return f=c.MatchSubStatementType.Newline,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.CarriageReturn);return f=c.MatchSubStatementType.CarriageReturn,{tokens:[t],statement:new c.MatchSubStatementValue(f)}}}]));p=p.concat(t.tokens),r.push(t.statement)}}),new c.MatchSubStatementCST(p,t,n,r)}),p=e.RULE("MatchStatement",()=>{let t=!1,n=!1;const r=[],i=[];return e.OPTION(()=>{i.push(e.CONSUME(s.Optional)),n=!0}),i.push(e.CONSUME(s.Match)),e.OPTION4(()=>{e.CONSUME3(s.Optional),t=!0}),r.push(new c.MatchStatementValue(t,e.SUBRULE(a))),e.MANY(()=>{e.OR([{ALT:()=>{e.OPTION2(()=>e.CONSUME2(s.And)),e.CONSUME(s.Then)}},{ALT:()=>e.CONSUME(s.And)}]),t=!1,e.OPTION3(()=>{e.CONSUME2(s.Optional),t=!0}),r.push(new c.MatchStatementValue(t,e.SUBRULE2(a)))}),i.push(e.CONSUME(s.EndOfLine)),new c.MatchStatementCST(i,n,r)});let m=null;const g=e.RULE("UsingStatement",()=>{const t=[],n=[e.CONSUME(s.Using)];return e.AT_LEAST_ONE_SEP({SEP:s.And,DEF:()=>{t.push(e.OR(m||(m=[{ALT:()=>(e.CONSUME(s.Multiline),c.UsingFlags.Multiline)},{ALT:()=>(e.CONSUME(s.Global),c.UsingFlags.Global)},{ALT:()=>(e.CONSUME(s.CaseInsensitive),c.UsingFlags.Insensitive)},{ALT:()=>(e.CONSUME(s.CaseSensitive),c.UsingFlags.Sensitive)},{ALT:()=>(e.CONSUME(s.Exact),c.UsingFlags.Exact)}]))),e.OPTION(()=>e.CONSUME(s.Matching))}}),n.push(e.CONSUME(s.EndOfLine)),new f(n,t)}),v=e.RULE("GroupStatement",()=>{const t=[];let n=!1,r=null;const i=[];return t.push(e.OR([{ALT:()=>{n=!0;const t=e.CONSUME(s.Optional);return e.CONSUME(s.Create),e.CONSUME(s.A),t}},{ALT:()=>{const t=e.CONSUME2(s.Create);return e.CONSUME2(s.A),e.OPTION2(()=>{e.CONSUME2(s.Optional),n=!0}),t}}])),e.CONSUME(s.Group),e.OPTION(()=>{e.CONSUME(s.Called),r=e.CONSUME(s.Identifier).image}),t.push(e.CONSUME2(s.EndOfLine)),e.CONSUME(s.Indent),e.AT_LEAST_ONE(()=>{i.push(e.SUBRULE(b))}),e.CONSUME(s.Outdent),new c.GroupStatementCST(t,n,r,i)}),y=e.RULE("RepeatStatement",()=>{const t=[];let n=!1,r=null;const o=[];return e.OPTION3(()=>{t.push(e.CONSUME(s.Optional)),n=!0}),t.push(e.CONSUME(s.Repeat)),e.OPTION(()=>r=e.SUBRULE(i)),e.CONSUME3(s.EndOfLine),e.CONSUME(s.Indent),e.AT_LEAST_ONE(()=>{o.push(e.SUBRULE(b))}),t.push(e.CONSUME(s.Outdent)),new c.RepeatStatementCST(t,n,r,o)}),b=e.RULE("Statement",()=>e.OR([{ALT:()=>e.SUBRULE(p)},{ALT:()=>e.SUBRULE(v)},{ALT:()=>e.SUBRULE(y)}])),T=e.RULE("Regex",()=>{let t=[],n=[];const r=[];return e.MANY(()=>{const r=e.SUBRULE(g);t=t.concat(r.tokens),n=n.concat(r.value)}),e.MANY2(()=>r.push(e.SUBRULE(b))),new c.RegularExpressionCST([],new c.UsingStatementCST(t,n),r)});this.performSelfAnalysis(),this.regexp=T}parse(t){return this.input=t,new p(this.regexp(),this.errors.map(l.CommonError.fromParseError))}setOptions(t){l.unusedParameter(t,"skip_validations is not valid to change once we've already initialized")}}e.Human2RegexParser=d,d.already_init=!1},function(t,e,n){!function(t){"use strict";function e(t,e){if(!t.hasOwnProperty(e))throw new Error("Undefined state "+e+" in simple mode")}function n(t,e){if(!t)return/(?:)/;var n="";return t instanceof RegExp?(t.ignoreCase&&(n="i"),t=t.source):t=String(t),new RegExp((!1===e?"":"^")+"(?:"+t+")",n)}function r(t,r){(t.next||t.push)&&e(r,t.next||t.push),this.regex=n(t.regex),this.token=function(t){if(!t)return null;if(t.apply)return t;if("string"==typeof t)return t.replace(/\./g," ");for(var e=[],n=0;n<t.length;n++)e.push(t[n]&&t[n].replace(/\./g," "));return e}(t.token),this.data=t}function i(t,e){return function(n,r){if(r.pending){var i=r.pending.shift();return 0==r.pending.length&&(r.pending=null),n.pos+=i.text.length,i.token}if(r.local){if(r.local.end&&n.match(r.local.end)){var o=r.local.endToken||null;return r.local=r.localState=null,o}var s;return o=r.local.mode.token(n,r.localState),r.local.endScan&&(s=r.local.endScan.exec(n.current()))&&(n.pos=n.start+s.index),o}for(var c=t[r.state],l=0;l<c.length;l++){var u=c[l],h=(!u.data.sol||n.sol())&&n.match(u.regex);if(h){u.data.next?r.state=u.data.next:u.data.push?((r.stack||(r.stack=[])).push(r.state),r.state=u.data.push):u.data.pop&&r.stack&&r.stack.length&&(r.state=r.stack.pop()),u.data.mode&&a(e,r,u.data.mode,u.token),u.data.indent&&r.indent.push(n.indentation()+e.indentUnit),u.data.dedent&&r.indent.pop();var f=u.token;if(f&&f.apply&&(f=f(h)),h.length>2&&u.token&&"string"!=typeof u.token){r.pending=[];for(var p=2;p<h.length;p++)h[p]&&r.pending.push({text:h[p],token:u.token[p-1]});return n.backUp(h[0].length-(h[1]?h[1].length:0)),f[0]}return f&&f.join?f[0]:f}}return n.next(),null}}function o(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;var n=0;for(var r in t)if(t.hasOwnProperty(r)){if(!e.hasOwnProperty(r)||!o(t[r],e[r]))return!1;n++}for(var r in e)e.hasOwnProperty(r)&&n--;return 0==n}function a(e,r,i,a){var s;if(i.persistent)for(var c=r.persistentStates;c&&!s;c=c.next)(i.spec?o(i.spec,c.spec):i.mode==c.mode)&&(s=c);var l=s?s.mode:i.mode||t.getMode(e,i.spec),u=s?s.state:t.startState(l);i.persistent&&!s&&(r.persistentStates={mode:l,spec:i.spec,state:u,next:r.persistentStates}),r.localState=u,r.local={mode:l,end:i.end&&n(i.end),endScan:i.end&&!1!==i.forceEnd&&n(i.end,!1),endToken:a&&a.join?a[a.length-1]:a}}function s(e,n){return function(r,i,o){if(r.local&&r.local.mode.indent)return r.local.mode.indent(r.localState,i,o);if(null==r.indent||r.local||n.dontIndentStates&&function(t,e){for(var n=0;n<e.length;n++)if(e[n]===t)return!0}(r.state,n.dontIndentStates)>-1)return t.Pass;var a=r.indent.length-1,s=e[r.state];t:for(;;){for(var c=0;c<s.length;c++){var l=s[c];if(l.data.dedent&&!1!==l.data.dedentIfLineStart){var u=l.regex.exec(i);if(u&&u[0]){a--,(l.next||l.push)&&(s=e[l.next||l.push]),i=i.slice(u[0].length);continue t}}}break}return a<0?0:r.indent[a]}}t.defineSimpleMode=function(e,n){t.defineMode(e,(function(e){return t.simpleMode(e,n)}))},t.simpleMode=function(n,o){e(o,"start");var a={},c=o.meta||{},l=!1;for(var u in o)if(u!=c&&o.hasOwnProperty(u))for(var h=a[u]=[],f=o[u],p=0;p<f.length;p++){var d=f[p];h.push(new r(d,o)),(d.indent||d.dedent)&&(l=!0)}var m={startState:function(){return{state:"start",pending:null,local:null,localState:null,indent:l?[]:null}},copyState:function(e){var n={state:e.state,pending:e.pending,local:e.local,localState:null,indent:e.indent&&e.indent.slice(0)};e.localState&&(n.localState=t.copyState(e.local.mode,e.localState)),e.stack&&(n.stack=e.stack.slice(0));for(var r=e.persistentStates;r;r=r.next)n.persistentStates={mode:r.mode,spec:r.spec,state:r.state==e.localState?n.localState:t.copyState(r.mode,r.state),next:n.persistentStates};return n},token:i(a,n),innerMode:function(t){return t.local&&{mode:t.local.mode,state:t.localState}},indent:s(a,c)};if(c)for(var g in c)c.hasOwnProperty(g)&&(m[g]=c[g]);return m}}(n(3))},function(t,e,n){!function(t){"use strict";t.runMode=function(e,n,r,i){var o=t.getMode(t.defaults,n),a=i&&i.tabSize||t.defaults.tabSize;if(r.appendChild){var s=/MSIE \d/.test(navigator.userAgent)&&(null==document.documentMode||document.documentMode<9),c=r,l=0;c.innerHTML="",r=function(t,e){if("\n"==t)return c.appendChild(document.createTextNode(s?"\r":t)),void(l=0);for(var n="",r=0;;){var i=t.indexOf("\t",r);if(-1==i){n+=t.slice(r),l+=t.length-r;break}l+=i-r,n+=t.slice(r,i);var o=a-l%a;l+=o;for(var u=0;u<o;++u)n+=" ";r=i+1}if(e){var h=c.appendChild(document.createElement("span"));h.className="cm-"+e.replace(/ +/g," cm-"),h.appendChild(document.createTextNode(n))}else c.appendChild(document.createTextNode(n))}}for(var u=t.splitLines(e),h=i&&i.state||t.startState(o),f=0,p=u.length;f<p;++f){f&&r("\n");var d=new t.StringStream(u[f],null,{lookAhead:function(t){return u[f+t]},baseToken:function(){}});for(!d.string&&o.blankLine&&o.blankLine(h);!d.eol();){var m=o.token(d,h);r(d.current(),m,f,d.start,h),d.start=d.pos}}}}(n(3))},function(t,e,n){!function(t){"use strict";var e="CodeMirror-lint-markers";function n(t){t.parentNode&&t.parentNode.removeChild(t)}function r(e,r,i,o){var a=function(e,n,r){var i=document.createElement("div");function o(e){if(!i.parentNode)return t.off(document,"mousemove",o);i.style.top=Math.max(0,e.clientY-i.offsetHeight-5)+"px",i.style.left=e.clientX+5+"px"}return i.className="CodeMirror-lint-tooltip cm-s-"+e.options.theme,i.appendChild(r.cloneNode(!0)),e.state.lint.options.selfContain?e.getWrapperElement().appendChild(i):document.body.appendChild(i),t.on(document,"mousemove",o),o(n),null!=i.style.opacity&&(i.style.opacity=1),i}(e,r,i);function s(){var e;t.off(o,"mouseout",s),a&&((e=a).parentNode&&(null==e.style.opacity&&n(e),e.style.opacity=0,setTimeout((function(){n(e)}),600)),a=null)}var c=setInterval((function(){if(a)for(var t=o;;t=t.parentNode){if(t&&11==t.nodeType&&(t=t.host),t==document.body)return;if(!t){s();break}}if(!a)return clearInterval(c)}),400);t.on(o,"mouseout",s)}function i(t,e,n){this.marked=[],this.options=e,this.timeout=null,this.hasGutter=n,this.onMouseOver=function(e){!function(t,e){var n=e.target||e.srcElement;if(/\bCodeMirror-lint-mark-/.test(n.className)){for(var i=n.getBoundingClientRect(),o=(i.left+i.right)/2,a=(i.top+i.bottom)/2,c=t.findMarksAt(t.coordsChar({left:o,top:a},"client")),l=[],u=0;u<c.length;++u){var h=c[u].__annotation;h&&l.push(h)}l.length&&function(t,e,n){for(var i=n.target||n.srcElement,o=document.createDocumentFragment(),a=0;a<e.length;a++){var c=e[a];o.appendChild(s(c))}r(t,n,o,i)}(t,l,e)}}(t,e)},this.waitingFor=0}function o(t){var n=t.state.lint;n.hasGutter&&t.clearGutter(e);for(var r=0;r<n.marked.length;++r)n.marked[r].clear();n.marked.length=0}function a(e,n,i,o,a){var s=document.createElement("div"),c=s;return s.className="CodeMirror-lint-marker CodeMirror-lint-marker-"+i,o&&((c=s.appendChild(document.createElement("div"))).className="CodeMirror-lint-marker CodeMirror-lint-marker-multiple"),0!=a&&t.on(c,"mouseover",(function(t){r(e,t,n,c)})),s}function s(t){var e=t.severity;e||(e="error");var n=document.createElement("div");return n.className="CodeMirror-lint-message CodeMirror-lint-message-"+e,void 0!==t.messageHTML?n.innerHTML=t.messageHTML:n.appendChild(document.createTextNode(t.message)),n}function c(e){var n=e.state.lint.options,r=n.options||n,i=n.getAnnotations||e.getHelper(t.Pos(0,0),"lint");if(i)if(n.async||i.async)!function(e,n,r){var i=e.state.lint,o=++i.waitingFor;function a(){o=-1,e.off("change",a)}e.on("change",a),n(e.getValue(),(function(n,r){e.off("change",a),i.waitingFor==o&&(r&&n instanceof t&&(n=r),e.operation((function(){l(e,n)})))}),r,e)}(e,i,r);else{var o=i(e.getValue(),r,e);if(!o)return;o.then?o.then((function(t){e.operation((function(){l(e,t)}))})):e.operation((function(){l(e,o)}))}}function l(t,n){o(t);for(var r,i,c=t.state.lint,l=c.options,u=function(t){for(var e=[],n=0;n<t.length;++n){var r=t[n],i=r.from.line;(e[i]||(e[i]=[])).push(r)}return e}(n),h=0;h<u.length;++h){var f=u[h];if(f){for(var p=null,d=c.hasGutter&&document.createDocumentFragment(),m=0;m<f.length;++m){var g=f[m],v=g.severity;v||(v="error"),i=v,p="error"==(r=p)?r:i,l.formatAnnotation&&(g=l.formatAnnotation(g)),c.hasGutter&&d.appendChild(s(g)),g.to&&c.marked.push(t.markText(g.from,g.to,{className:"CodeMirror-lint-mark CodeMirror-lint-mark-"+v,__annotation:g}))}c.hasGutter&&t.setGutterMarker(h,e,a(t,d,p,f.length>1,c.options.tooltips))}}l.onUpdateLinting&&l.onUpdateLinting(n,u,t)}function u(t){var e=t.state.lint;e&&(clearTimeout(e.timeout),e.timeout=setTimeout((function(){c(t)}),e.options.delay||500))}t.defineOption("lint",!1,(function(n,r,a){if(a&&a!=t.Init&&(o(n),!1!==n.state.lint.options.lintOnChange&&n.off("change",u),t.off(n.getWrapperElement(),"mouseover",n.state.lint.onMouseOver),clearTimeout(n.state.lint.timeout),delete n.state.lint),r){for(var s=n.getOption("gutters"),l=!1,h=0;h<s.length;++h)s[h]==e&&(l=!0);var f=n.state.lint=new i(n,(p=r)instanceof Function?{getAnnotations:p}:(p&&!0!==p||(p={}),p),l);!1!==f.options.lintOnChange&&n.on("change",u),0!=f.options.tooltips&&"gutter"!=f.options.tooltips&&t.on(n.getWrapperElement(),"mouseover",f.onMouseOver),c(n)}var p})),t.defineExtension("performLint",(function(){this.state.lint&&c(this)}))}(n(3))},function(t,e,n){"use strict";n.r(e)},function(t,e,n){"use strict";n.r(e)},function(t,e,n){"use strict";n.r(e)},function(t,e,n){"use strict";n.r(e)}]);