mirror of
https://github.com/pdemian/human2regex.git
synced 2025-05-15 20:10:19 -07:00
8 lines
347 KiB
JavaScript
8 lines
347 KiB
JavaScript
(()=>{var t={650:(t,e,n)=>{"use strict";n.r(e),n.d(e,{Alternation:()=>Ot,Alternative:()=>St,CstParser:()=>Ln,EMPTY_ALT:()=>Nn,EOF:()=>pt,EarlyExitException:()=>Fe,EmbeddedActionsParser:()=>An,GAstVisitor:()=>It,Lexer:()=>Z,LexerDefinitionErrorType:()=>q,MismatchedTokenException:()=>Pe,NoViableAltException:()=>Ue,NonTerminal:()=>yt,NotAllInputParsedException:()=>De,Option:()=>xt,Parser:()=>zn,ParserDefinitionErrorType:()=>bn,Repetition:()=>bt,RepetitionMandatory:()=>Et,RepetitionMandatoryWithSeparator:()=>Ct,RepetitionWithSeparator:()=>kt,Rule:()=>Tt,Terminal:()=>Nt,VERSION:()=>r,assignOccurrenceIndices:()=>Oe,clearCache:()=>Gn,createSyntaxDiagramsCode:()=>Rn,createToken:()=>ft,createTokenInstance:()=>dt,defaultGrammarResolverErrorProvider:()=>zt,defaultGrammarValidatorErrorProvider:()=>jt,defaultLexerErrorProvider:()=>Q,defaultParserErrorProvider:()=>Gt,generateParserFactory:()=>Bn,generateParserModule:()=>Hn,isRecognitionException:()=>Me,resolveGrammar:()=>be,serializeGrammar:()=>wt,serializeProduction:()=>Lt,tokenLabel:()=>tt,tokenMatcher:()=>mt,tokenName:()=>et,validateGrammar:()=>ke});var r="7.1.2",i=n(465),o=n(556),a={},s=new o.RegExpParser;function l(t){var e=t.toString();if(a.hasOwnProperty(e))return a[e];var n=s.pattern(e);return a[e]=n,n}var u,c=(u=function(t,e){return(u=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}u(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),h="Complement Sets are not supported for first char optimization",f='Unable to use "first char" lexer optimizations:\n';function p(t,e){void 0===e&&(e=!1);try{var n=l(t);return d(n.value,{},n.flags.ignoreCase)}catch(n){if(n.message===h)e&&(0,i.rr)(f+"\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://chevrotain.io/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://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),(0,i.WB)(f+"\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 d(t,e,n){switch(t.type){case"Disjunction":for(var r=0;r<t.value.length;r++)d(t.value[r],e,n);break;case"Alternative":var o=t.value;for(r=0;r<o.length;r++){var a=o[r];switch(a.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var s=a;switch(s.type){case"Character":m(s.value,e,n);break;case"Set":if(!0===s.complement)throw Error(h);(0,i.Ed)(s.value,(function(t){if("number"==typeof t)m(t,e,n);else{var r=t;if(!0===n)for(var i=r.from;i<=r.to;i++)m(i,e,n);else{for(i=r.from;i<=r.to&&i<F;i++)m(i,e,n);if(r.to>=F)for(var o=r.from>=F?r.from:F,a=r.to,s=W(o),l=W(a),u=s;u<=l;u++)e[u]=u}}}));break;case"Group":d(s.value,e,n);break;default:throw Error("Non Exhaustive Match")}var l=void 0!==s.quantifier&&0===s.quantifier.atLeast;if("Group"===s.type&&!1===v(s)||"Group"!==s.type&&!1===l)break}break;default:throw Error("non exhaustive match!")}return(0,i.VO)(e)}function m(t,e,n){var r=W(t);e[r]=r,!0===n&&function(t,e){var n=String.fromCharCode(t),r=n.toUpperCase();if(r!==n){e[i=W(r.charCodeAt(0))]=i}else{var i,o=n.toLowerCase();if(o!==n)e[i=W(o.charCodeAt(0))]=i}}(t,e)}function g(t,e){return(0,i.sE)(t.value,(function(t){if("number"==typeof t)return(0,i.r3)(e,t);var n=t;return void 0!==(0,i.sE)(e,(function(t){return n.from<=t&&t<=n.to}))}))}function v(t){return!(!t.quantifier||0!==t.quantifier.atLeast)||!!t.value&&((0,i.kJ)(t.value)?(0,i.yW)(t.value,v):v(t.value))}var y=function(t){function e(e){var n=t.call(this)||this;return n.targetCharCodes=e,n.found=!1,n}return c(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){(0,i.r3)(this.targetCharCodes,t.value)&&(this.found=!0)},e.prototype.visitSet=function(t){t.complement?void 0===g(t,this.targetCharCodes)&&(this.found=!0):void 0!==g(t,this.targetCharCodes)&&(this.found=!0)},e}(o.BaseRegExpVisitor);function T(t,e){if(e instanceof RegExp){var n=l(e),r=new y(t);return r.visit(n),r.found}return void 0!==(0,i.sE)(e,(function(e){return(0,i.r3)(t,e.charCodeAt(0))}))}var S=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)}}(),x="PATTERN",E="defaultMode",C="modes",b="boolean"==typeof new RegExp("(?:)").sticky;function k(t,e){var n,r=(e=(0,i.ce)(e,{useSticky:b,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:function(t,e){return e()}})).tracer;r("initCharCodeToOptimizedIndexMap",(function(){!function(){if((0,i.xb)(B)){B=new Array(65536);for(var t=0;t<65536;t++)B[t]=t>255?255+~~(t/255):t}}()})),r("Reject Lexer.NA",(function(){n=(0,i.d1)(t,(function(t){return t.PATTERN===Z.NA}))}));var o,a,s,l,u,c,h,d,m,g,v,y=!1;r("Transform Patterns",(function(){y=!1,o=(0,i.UI)(n,(function(t){var n=t.PATTERN;if((0,i.Kj)(n)){var r=n.source;return 1!==r.length||"^"===r||"$"===r||"."===r||n.ignoreCase?2!==r.length||"\\"!==r[0]||(0,i.r3)(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],r[1])?e.useSticky?A(n):L(n):r[1]:r}if((0,i.mf)(n))return y=!0,{exec:n};if((0,i.e$)(n,"exec"))return y=!0,n;if("string"==typeof n){if(1===n.length)return n;var o=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),a=new RegExp(o);return e.useSticky?A(a):L(a)}throw Error("non exhaustive match")}))})),r("misc mapping",(function(){a=(0,i.UI)(n,(function(t){return t.tokenTypeIdx})),s=(0,i.UI)(n,(function(t){var e=t.GROUP;if(e!==Z.SKIPPED){if((0,i.HD)(e))return e;if((0,i.o8)(e))return!1;throw Error("non exhaustive match")}})),l=(0,i.UI)(n,(function(t){var e=t.LONGER_ALT;if(e)return(0,i.cq)(n,e)})),u=(0,i.UI)(n,(function(t){return t.PUSH_MODE})),c=(0,i.UI)(n,(function(t){return(0,i.e$)(t,"POP_MODE")}))})),r("Line Terminator Handling",(function(){var t=U(e.lineTerminatorCharacters);h=(0,i.UI)(n,(function(t){return!1})),"onlyOffset"!==e.positionTracking&&(h=(0,i.UI)(n,(function(e){return(0,i.e$)(e,"LINE_BREAKS")?e.LINE_BREAKS:!1===P(e,t)?T(t,e.PATTERN):void 0})))})),r("Misc Mapping #2",(function(){d=(0,i.UI)(n,I),m=(0,i.UI)(o,M),g=(0,i.u4)(n,(function(t,e){var n=e.GROUP;return(0,i.HD)(n)&&n!==Z.SKIPPED&&(t[n]=[]),t}),{}),v=(0,i.UI)(o,(function(t,e){return{pattern:o[e],longerAlt:l[e],canLineTerminator:h[e],isCustom:d[e],short:m[e],group:s[e],push:u[e],pop:c[e],tokenTypeIdx:a[e],tokenType:n[e]}}))}));var S=!0,x=[];return e.safeMode||r("First Char Optimization",(function(){x=(0,i.u4)(n,(function(t,n,r){if("string"==typeof n.PATTERN){var o=W(n.PATTERN.charCodeAt(0));D(t,o,v[r])}else if((0,i.kJ)(n.START_CHARS_HINT)){var a;(0,i.Ed)(n.START_CHARS_HINT,(function(e){var n=W("string"==typeof e?e.charCodeAt(0):e);a!==n&&(a=n,D(t,n,v[r]))}))}else if((0,i.Kj)(n.PATTERN))if(n.PATTERN.unicode)S=!1,e.ensureOptimizations&&(0,i.WB)(f+"\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://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE");else{var s=p(n.PATTERN,e.ensureOptimizations);(0,i.xb)(s)&&(S=!1),(0,i.Ed)(s,(function(e){D(t,e,v[r])}))}else e.ensureOptimizations&&(0,i.WB)(f+"\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://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE"),S=!1;return t}),[])})),r("ArrayPacking",(function(){x=(0,i.X0)(x)})),{emptyGroups:g,patternIdxToConfig:v,charCodeToPatternIdxToConfig:x,hasCustom:y,canBeOptimized:S}}function O(t,e){var n=[],r=function(t){var e=(0,i.hX)(t,(function(t){return!(0,i.e$)(t,x)})),n=(0,i.UI)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- missing static 'PATTERN' property",type:q.MISSING_PATTERN,tokenTypes:[t]}})),r=(0,i.e5)(t,e);return{errors:n,valid:r}}(t);n=n.concat(r.errors);var a=function(t){var e=(0,i.hX)(t,(function(t){var e=t.PATTERN;return!((0,i.Kj)(e)||(0,i.mf)(e)||(0,i.e$)(e,"exec")||(0,i.HD)(e))})),n=(0,i.UI)(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:q.INVALID_PATTERN,tokenTypes:[t]}})),r=(0,i.e5)(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=(0,i.hX)(t,(function(t){return(0,i.Kj)(t.PATTERN)}));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 S(e,t),e.prototype.visitEndAnchor=function(t){this.found=!0},e}(o.BaseRegExpVisitor),n=(0,i.hX)(t,(function(t){var n=t.PATTERN;try{var r=l(n),i=new e;return i.visit(r),i.found}catch(t){return N.test(n.source)}}));return(0,i.UI)(n,(function(t){return{message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+t.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n\tSee chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:q.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 S(e,t),e.prototype.visitStartAnchor=function(t){this.found=!0},e}(o.BaseRegExpVisitor),n=(0,i.hX)(t,(function(t){var n=t.PATTERN;try{var r=l(n),i=new e;return i.visit(r),i.found}catch(t){return w.test(n.source)}}));return(0,i.UI)(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://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:q.SOI_ANCHOR_FOUND,tokenTypes:[t]}}))}(n))).concat(function(t){var e=(0,i.hX)(t,(function(t){var e=t.PATTERN;return e instanceof RegExp&&(e.multiline||e.global)}));return(0,i.UI)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:q.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[t]}}))}(n))).concat(function(t){var e=[],n=(0,i.UI)(t,(function(n){return(0,i.u4)(t,(function(t,r){return n.PATTERN.source!==r.PATTERN.source||(0,i.r3)(e,r)||r.PATTERN===Z.NA||(e.push(r),t.push(r)),t}),[])}));n=(0,i.oA)(n);var r=(0,i.hX)(n,(function(t){return t.length>1}));return(0,i.UI)(r,(function(t){var e=(0,i.UI)(t,(function(t){return t.name}));return{message:"The same RegExp pattern ->"+(0,i.Ps)(t).PATTERN+"<-has been used in all of the following Token Types: "+e.join(", ")+" <-",type:q.DUPLICATE_PATTERNS_FOUND,tokenTypes:t}}))}(n))).concat(function(t){var e=(0,i.hX)(t,(function(t){return t.PATTERN.test("")}));return(0,i.UI)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PATTERN' must not match an empty string",type:q.EMPTY_MATCH_PATTERN,tokenTypes:[t]}}))}(n))}(s))).concat(function(t){var e=(0,i.hX)(t,(function(t){if(!(0,i.e$)(t,"GROUP"))return!1;var e=t.GROUP;return e!==Z.SKIPPED&&e!==Z.NA&&!(0,i.HD)(e)}));return(0,i.UI)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:q.INVALID_GROUP_TYPE_FOUND,tokenTypes:[t]}}))}(s))).concat(function(t,e){var n=(0,i.hX)(t,(function(t){return void 0!==t.PUSH_MODE&&!(0,i.r3)(e,t.PUSH_MODE)}));return(0,i.UI)(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:q.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[t]}}))}(s,e))).concat(function(t){var e=[],n=(0,i.u4)(t,(function(t,e,n){var r,o,a=e.PATTERN;return a===Z.NA||((0,i.HD)(a)?t.push({str:a,idx:n,tokenType:e}):(0,i.Kj)(a)&&(r=a,o=[".","\\","[","]","|","^","$","(",")","?","*","+","{"],void 0===(0,i.sE)(o,(function(t){return-1!==r.source.indexOf(t)})))&&t.push({str:a.source,idx:n,tokenType:e})),t}),[]);return(0,i.Ed)(t,(function(t,r){(0,i.Ed)(n,(function(n){var o=n.str,a=n.idx,s=n.tokenType;if(r<a&&function(t,e){if((0,i.Kj)(e)){var n=e.exec(t);return null!==n&&0===n.index}if((0,i.mf)(e))return e(t,0,[],{});if((0,i.e$)(e,"exec"))return e.exec(t,0,[],{});if("string"==typeof e)return e===t;throw Error("non exhaustive match")}(o,t.PATTERN)){var l="Token: ->"+s.name+"<- can never be matched.\nBecause it appears AFTER the Token Type ->"+t.name+"<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE";e.push({message:l,type:q.UNREACHABLE_PATTERN,tokenTypes:[t,s]})}}))})),e}(s))}var N=/[^\\][\$]/;var w=/[^\\[][\^]|^\^/;function L(t){var e=t.ignoreCase?"i":"";return new RegExp("^(?:"+t.source+")",e)}function A(t){var e=t.ignoreCase?"iy":"y";return new RegExp(""+t.source,e)}function R(t,e,n){var r=[],o=!1,a=(0,i.oA)((0,i.xH)((0,i.Q8)(t.modes,(function(t){return t})))),s=(0,i.d1)(a,(function(t){return t.PATTERN===Z.NA})),l=U(n);return e&&(0,i.Ed)(s,(function(t){var e=P(t,l);if(!1!==e){var n={message:function(t,e){if(e.issue===q.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://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(e.issue===q.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://chevrotain.io/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(0,i.e$)(t,"LINE_BREAKS")?!0===t.LINE_BREAKS&&(o=!0):T(l,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://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n\tfor details.",type:q.NO_LINE_BREAKS_FLAGS}),r}function I(t){var e=t.PATTERN;if((0,i.Kj)(e))return!1;if((0,i.mf)(e))return!0;if((0,i.e$)(e,"exec"))return!0;if((0,i.HD)(e))return!1;throw Error("non exhaustive match")}function M(t){return!(!(0,i.HD)(t)||1!==t.length)&&t.charCodeAt(0)}var _={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 P(t,e){if((0,i.e$)(t,"LINE_BREAKS"))return!1;if((0,i.Kj)(t.PATTERN)){try{T(e,t.PATTERN)}catch(t){return{issue:q.IDENTIFY_TERMINATOR,errMsg:t.message}}return!1}if((0,i.HD)(t.PATTERN))return!1;if(I(t))return{issue:q.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function U(t){return(0,i.UI)(t,(function(t){return(0,i.HD)(t)&&t.length>0?t.charCodeAt(0):t}))}function D(t,e,n){void 0===t[e]?t[e]=[n]:t[e].push(n)}var F=256;function W(t){return t<F?t:B[t]}var B=[];function H(t,e){var n=t.tokenTypeIdx;return n===e.tokenTypeIdx||!0===e.isParent&&!0===e.categoryMatchesMap[n]}function G(t,e){return t.tokenTypeIdx===e.tokenTypeIdx}var z=1,j={};function V(t){var e=function(t){var e=(0,i.Qw)(t),n=t,r=!0;for(;r;){n=(0,i.oA)((0,i.xH)((0,i.UI)(n,(function(t){return t.CATEGORIES}))));var o=(0,i.e5)(n,e);e=e.concat(o),(0,i.xb)(o)?r=!1:n=o}return e}(t);!function(t){(0,i.Ed)(t,(function(t){var e;$(t)||(j[z]=t,t.tokenTypeIdx=z++),Y(t)&&!(0,i.kJ)(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),Y(t)||(t.CATEGORIES=[]),e=t,(0,i.e$)(e,"categoryMatches")||(t.categoryMatches=[]),function(t){return(0,i.e$)(t,"categoryMatchesMap")}(t)||(t.categoryMatchesMap={})}))}(e),function(t){(0,i.Ed)(t,(function(t){K([],t)}))}(e),function(t){(0,i.Ed)(t,(function(t){t.categoryMatches=[],(0,i.Ed)(t.categoryMatchesMap,(function(e,n){t.categoryMatches.push(j[n].tokenTypeIdx)}))}))}(e),(0,i.Ed)(e,(function(t){t.isParent=t.categoryMatches.length>0}))}function K(t,e){(0,i.Ed)(t,(function(t){e.categoryMatchesMap[t.tokenTypeIdx]=!0})),(0,i.Ed)(e.CATEGORIES,(function(n){var r=t.concat(e);(0,i.r3)(r,n)||K(r,n)}))}function $(t){return(0,i.e$)(t,"tokenTypeIdx")}function Y(t){return(0,i.e$)(t,"CATEGORIES")}function X(t){return(0,i.e$)(t,"tokenTypeIdx")}var q,Q={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"}(q||(q={}));var J={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:Q,traceInitPerf:!1,skipValidations:!1};Object.freeze(J);var Z=function(){function t(t,e){var n=this;if(void 0===e&&(e=J),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=(0,i.TS)(J,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===J.lineTerminatorsPattern)n.config.lineTerminatorsPattern=_;else if(n.config.lineTerminatorCharacters===J.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n\tFor details See: https://chevrotain.io/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),(0,i.kJ)(t)?((r={modes:{}}).modes.defaultMode=(0,i.Qw)(t),r.defaultMode=E):(o=!1,r=(0,i.Cl)(t))})),!1===n.config.skipValidations&&(n.TRACE_INIT("performRuntimeChecks",(function(){n.lexerDefinitionErrors=n.lexerDefinitionErrors.concat(function(t,e,n){var r=[];return(0,i.e$)(t,E)||r.push({message:"A MultiMode Lexer cannot be initialized without a <defaultMode> property in its definition\n",type:q.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),(0,i.e$)(t,C)||r.push({message:"A MultiMode Lexer cannot be initialized without a <modes> property in its definition\n",type:q.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),(0,i.e$)(t,C)&&(0,i.e$)(t,E)&&!(0,i.e$)(t.modes,t.defaultMode)&&r.push({message:"A MultiMode Lexer cannot be initialized with a defaultMode: <"+t.defaultMode+">which does not exist\n",type:q.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),(0,i.e$)(t,C)&&(0,i.Ed)(t.modes,(function(t,e){(0,i.Ed)(t,(function(t,n){(0,i.o8)(t)&&r.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:<"+e+"> at index: <"+n+">\n",type:q.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})}))})),r}(r,n.trackStartLines,n.config.lineTerminatorCharacters))})),n.TRACE_INIT("performWarningRuntimeChecks",(function(){n.lexerDefinitionWarning=n.lexerDefinitionWarning.concat(R(r,n.trackStartLines,n.config.lineTerminatorCharacters))}))),r.modes=r.modes?r.modes:{},(0,i.Ed)(r.modes,(function(t,e){r.modes[e]=(0,i.d1)(t,(function(t){return(0,i.o8)(t)}))}));var s=(0,i.XP)(r.modes);if((0,i.Ed)(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(O(t,s))})),(0,i.xb)(n.lexerDefinitionErrors))&&(V(t),n.TRACE_INIT("analyzeTokenTypes",(function(){o=k(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=(0,i.TS)(n.emptyGroups,o.emptyGroups),n.hasCustom=o.hasCustom||n.hasCustom,n.canModeBeOptimized[r]=o.canBeOptimized)}))})),n.defaultMode=r.defaultMode,!(0,i.xb)(n.lexerDefinitionErrors)&&!n.config.deferDefinitionErrorsHandling){var l=(0,i.UI)(n.lexerDefinitionErrors,(function(t){return t.message})).join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+l)}(0,i.Ed)(n.lexerDefinitionWarning,(function(t){(0,i.rr)(t.message)})),n.TRACE_INIT("Choosing sub-methods implementations",(function(){if(b?(n.chopInput=i.Wd,n.match=n.matchWithTest):(n.updateLastIndex=i.dG,n.match=n.matchWithExec),o&&(n.handleModes=i.dG),!1===n.trackStartLines&&(n.computeNewColumn=i.Wd),!1===n.trackEndLines&&(n.updateTokenEndLineColumnLocation=i.dG),/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=(0,i.u4)(n.canModeBeOptimized,(function(t,e,n){return!1===e&&t.push(n),t}),[]);if(e.ensureOptimizations&&!(0,i.xb)(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(){(0,i.SV)(n)}))}))}return t.prototype.tokenize=function(t,e){if(void 0===e&&(e=this.defaultMode),!(0,i.xb)(this.lexerDefinitionErrors)){var n=(0,i.UI)(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,l,u,c,h,f,p,d,m,g,v,y,T,S=this,x=t,E=x.length,C=0,b=0,k=this.hasCustom?0:Math.floor(t.length/10),O=new Array(k),N=[],w=this.trackStartLines?1:void 0,L=this.trackStartLines?1:void 0,A=(v=this.emptyGroups,y={},T=(0,i.XP)(v),(0,i.Ed)(T,(function(t){var e=v[t];if(!(0,i.kJ)(e))throw Error("non exhaustive match");y[t]=[]})),y),R=this.trackStartLines,I=this.config.lineTerminatorsPattern,M=0,_=[],P=[],U=[],D=[];Object.freeze(D);var F=void 0;function B(){return _}function H(t){var e=W(t),n=P[e];return void 0===n?D:n}var G,z=function(t){if(1===U.length&&void 0===t.tokenType.PUSH_MODE){var e=S.config.errorMessageProvider.buildUnableToPopLexerModeMessage(t);N.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{U.pop();var n=(0,i.Z$)(U);_=S.patternIdxToConfig[n],P=S.charCodeToPatternIdxToConfig[n],M=_.length;var r=S.canModeBeOptimized[n]&&!1===S.config.safeMode;F=P&&r?H:B}};function j(t){U.push(t),P=this.charCodeToPatternIdxToConfig[t],_=this.patternIdxToConfig[t],M=_.length,M=_.length;var e=this.canModeBeOptimized[t]&&!1===this.config.safeMode;F=P&&e?H:B}for(j.call(this,e);C<E;){s=null;var V=x.charCodeAt(C),K=F(V),$=K.length;for(n=0;n<$;n++){var Y=(G=K[n]).pattern;if(l=null,!1!==(it=G.short)?V===it&&(s=Y):!0===G.isCustom?null!==(g=Y.exec(x,C,O,A))?(s=g[0],void 0!==g.payload&&(l=g.payload)):s=null:(this.updateLastIndex(Y,C),s=this.match(Y,t,C)),null!==s){if(void 0!==(a=G.longerAlt)){var X=_[a],q=X.pattern;u=null,!0===X.isCustom?null!==(g=q.exec(x,C,O,A))?(o=g[0],void 0!==g.payload&&(u=g.payload)):o=null:(this.updateLastIndex(q,C),o=this.match(q,t,C)),o&&o.length>s.length&&(s=o,l=u,G=X)}break}}if(null!==s){if(c=s.length,void 0!==(h=G.group)&&(f=G.tokenTypeIdx,p=this.createTokenInstance(s,C,f,G.tokenType,w,L,c),this.handlePayload(p,l),!1===h?b=this.addToken(O,b,p):A[h].push(p)),t=this.chopInput(t,c),C+=c,L=this.computeNewColumn(L,c),!0===R&&!0===G.canLineTerminator){var Q=0,J=void 0,Z=void 0;I.lastIndex=0;do{!0===(J=I.test(s))&&(Z=I.lastIndex-1,Q++)}while(!0===J);0!==Q&&(w+=Q,L=c-Z,this.updateTokenEndLineColumnLocation(p,h,Z,Q,w,L,c))}this.handleModes(G,z,j,p)}else{for(var tt=C,et=w,nt=L,rt=!1;!rt&&C<E;)for(x.charCodeAt(C),t=this.chopInput(t,1),C++,r=0;r<M;r++){var it,ot=_[r];Y=ot.pattern;if(!1!==(it=ot.short)?x.charCodeAt(C)===it&&(rt=!0):!0===ot.isCustom?rt=null!==Y.exec(x,C,O,A):(this.updateLastIndex(Y,C),rt=null!==Y.exec(t)),!0===rt)break}d=C-tt,m=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(x,tt,d,et,nt),N.push({offset:tt,line:et,column:nt,length:d,message:m})}}return this.hasCustom||(O.length=b),{tokens:O,groups:A,errors:N}},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,l;void 0!==e&&(l=(s=n===a-1)?-1:0,1===r&&!0===s||(t.endLine=i+l,t.endColumn=o-1-l))},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=(0,i.HT)(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 tt(t){return nt(t)?t.LABEL:t.name}function et(t){return t.name}function nt(t){return(0,i.HD)(t.LABEL)&&""!==t.LABEL}var rt="parent",it="categories",ot="label",at="group",st="push_mode",lt="pop_mode",ut="longer_alt",ct="line_breaks",ht="start_chars_hint";function ft(t){return function(t){var e=t.pattern,n={};n.name=t.name,(0,i.o8)(e)||(n.PATTERN=e);if((0,i.e$)(t,rt))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";(0,i.e$)(t,it)&&(n.CATEGORIES=t.categories);V([n]),(0,i.e$)(t,ot)&&(n.LABEL=t.label);(0,i.e$)(t,at)&&(n.GROUP=t.group);(0,i.e$)(t,lt)&&(n.POP_MODE=t.pop_mode);(0,i.e$)(t,st)&&(n.PUSH_MODE=t.push_mode);(0,i.e$)(t,ut)&&(n.LONGER_ALT=t.longer_alt);(0,i.e$)(t,ct)&&(n.LINE_BREAKS=t.line_breaks);(0,i.e$)(t,ht)&&(n.START_CHARS_HINT=t.start_chars_hint);return n}(t)}var pt=ft({name:"EOF",pattern:Z.NA});function dt(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 mt(t,e){return H(t,e)}V([pt]);var gt=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)}}(),vt=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),(0,i.Ed)(this.definition,(function(e){e.accept(t)}))},t}(),yt=function(t){function e(e){var n=t.call(this,[])||this;return n.idx=1,(0,i.f0)(n,(0,i.ei)(e,(function(t){return void 0!==t}))),n}return gt(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}(vt),Tt=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.orgText="",(0,i.f0)(n,(0,i.ei)(e,(function(t){return void 0!==t}))),n}return gt(e,t),e}(vt),St=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.ignoreAmbiguities=!1,(0,i.f0)(n,(0,i.ei)(e,(function(t){return void 0!==t}))),n}return gt(e,t),e}(vt),xt=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,(0,i.f0)(n,(0,i.ei)(e,(function(t){return void 0!==t}))),n}return gt(e,t),e}(vt),Et=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,(0,i.f0)(n,(0,i.ei)(e,(function(t){return void 0!==t}))),n}return gt(e,t),e}(vt),Ct=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,(0,i.f0)(n,(0,i.ei)(e,(function(t){return void 0!==t}))),n}return gt(e,t),e}(vt),bt=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,(0,i.f0)(n,(0,i.ei)(e,(function(t){return void 0!==t}))),n}return gt(e,t),e}(vt),kt=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,(0,i.f0)(n,(0,i.ei)(e,(function(t){return void 0!==t}))),n}return gt(e,t),e}(vt),Ot=function(t){function e(e){var n=t.call(this,e.definition)||this;return n.idx=1,n.ignoreAmbiguities=!1,n.hasPredicates=!1,(0,i.f0)(n,(0,i.ei)(e,(function(t){return void 0!==t}))),n}return gt(e,t),Object.defineProperty(e.prototype,"definition",{get:function(){return this._definition},set:function(t){this._definition=t},enumerable:!1,configurable:!0}),e}(vt),Nt=function(){function t(t){this.idx=1,(0,i.f0)(this,(0,i.ei)(t,(function(t){return void 0!==t})))}return t.prototype.accept=function(t){t.visit(this)},t}();function wt(t){return(0,i.UI)(t,Lt)}function Lt(t){function e(t){return(0,i.UI)(t,Lt)}if(t instanceof yt)return{type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};if(t instanceof St)return{type:"Alternative",definition:e(t.definition)};if(t instanceof xt)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof Et)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof Ct)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:Lt(new Nt({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof kt)return{type:"RepetitionWithSeparator",idx:t.idx,separator:Lt(new Nt({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof bt)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof Ot)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof Nt){var n={type:"Terminal",name:t.terminalType.name,label:tt(t.terminalType),idx:t.idx},r=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(n.pattern=(0,i.Kj)(r)?r.source:r),n}if(t instanceof Tt)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}var At=function(){function t(){}return t.prototype.walk=function(t,e){var n=this;void 0===e&&(e=[]),(0,i.Ed)(t.definition,(function(r,o){var a=(0,i.Cw)(t.definition,o+1);if(r instanceof yt)n.walkProdRef(r,a,e);else if(r instanceof Nt)n.walkTerminal(r,a,e);else if(r instanceof St)n.walkFlat(r,a,e);else if(r instanceof xt)n.walkOption(r,a,e);else if(r instanceof Et)n.walkAtLeastOne(r,a,e);else if(r instanceof Ct)n.walkAtLeastOneSep(r,a,e);else if(r instanceof kt)n.walkManySep(r,a,e);else if(r instanceof bt)n.walkMany(r,a,e);else{if(!(r instanceof Ot))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 xt({definition:t.definition})].concat(e,n);this.walk(t,r)},t.prototype.walkAtLeastOneSep=function(t,e,n){var r=Rt(t,e,n);this.walk(t,r)},t.prototype.walkMany=function(t,e,n){var r=[new xt({definition:t.definition})].concat(e,n);this.walk(t,r)},t.prototype.walkManySep=function(t,e,n){var r=Rt(t,e,n);this.walk(t,r)},t.prototype.walkOr=function(t,e,n){var r=this,o=e.concat(n);(0,i.Ed)(t.definition,(function(t){var e=new St({definition:[t]});r.walk(e,o)}))},t}();function Rt(t,e,n){return[new xt({definition:[new Nt({terminalType:t.separator})].concat(t.definition)})].concat(e,n)}var It=function(){function t(){}return t.prototype.visit=function(t){var e=t;switch(e.constructor){case yt:return this.visitNonTerminal(e);case St:return this.visitAlternative(e);case xt:return this.visitOption(e);case Et:return this.visitRepetitionMandatory(e);case Ct:return this.visitRepetitionMandatoryWithSeparator(e);case kt:return this.visitRepetitionWithSeparator(e);case bt:return this.visitRepetition(e);case Ot:return this.visitAlternation(e);case Nt:return this.visitTerminal(e);case Tt: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}(),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)}}();function _t(t,e){return void 0===e&&(e=[]),!!(t instanceof xt||t instanceof bt||t instanceof kt)||(t instanceof Ot?(0,i.G)(t.definition,(function(t){return _t(t,e)})):!(t instanceof yt&&(0,i.r3)(e,t))&&(t instanceof vt&&(t instanceof yt&&e.push(t),(0,i.yW)(t.definition,(function(t){return _t(t,e)})))))}function Pt(t){if(t instanceof yt)return"SUBRULE";if(t instanceof xt)return"OPTION";if(t instanceof Ot)return"OR";if(t instanceof Et)return"AT_LEAST_ONE";if(t instanceof Ct)return"AT_LEAST_ONE_SEP";if(t instanceof kt)return"MANY_SEP";if(t instanceof bt)return"MANY";if(t instanceof Nt)return"CONSUME";throw Error("non exhaustive match")}var Ut=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 Mt(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";(0,i.e$)(this.dslMethods,e)||(this.dslMethods[e]=[]),this.dslMethods[e].push(t)},e.prototype.visitNonTerminal=function(t){var e=t.nonTerminalName+this.separator+"Terminal";(0,i.e$)(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}(It),Dt=new Ut;function Ft(t){if(t instanceof yt)return Ft(t.referencedRule);if(t instanceof Nt)return[t.terminalType];if(function(t){return t instanceof St||t instanceof xt||t instanceof bt||t instanceof Et||t instanceof Ct||t instanceof kt||t instanceof Nt||t instanceof Tt}(t))return function(t){var e,n=[],r=t.definition,o=0,a=r.length>o,s=!0;for(;a&&s;)s=_t(e=r[o]),n=n.concat(Ft(e)),o+=1,a=r.length>o;return(0,i.jj)(n)}(t);if(function(t){return t instanceof Ot}(t))return function(t){var e=(0,i.UI)(t.definition,(function(t){return Ft(t)}));return(0,i.jj)((0,i.xH)(e))}(t);throw Error("non exhaustive match")}var Wt="_~IN~_",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)}}(),Ht=function(t){function e(e){var n=t.call(this)||this;return n.topProd=e,n.follows={},n}return Bt(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+Wt+this.topProd.name),a=e.concat(n),s=Ft(new St({definition:a}));this.follows[o]=s},e}(At);var Gt={buildMismatchTokenMessage:function(t){var e=t.expected,n=t.actual;t.previous,t.ruleName;return"Expecting "+(nt(e)?"--\x3e "+tt(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,"Expecting: "),a="\nbut found: '"+(0,i.Ps)(n).image+"'";if(r)return o+r+a;var s=(0,i.u4)(e,(function(t,e){return t.concat(e)}),[]),l=(0,i.UI)(s,(function(t){return"["+(0,i.UI)(t,(function(t){return tt(t)})).join(", ")+"]"}));return o+("one of these possible Token sequences:\n"+(0,i.UI)(l,(function(t,e){return" "+(e+1)+". "+t})).join("\n"))+a},buildEarlyExitMessage:function(t){var e=t.expectedIterationPaths,n=t.actual,r=t.customUserDescription,o=(t.ruleName,"Expecting: "),a="\nbut found: '"+(0,i.Ps)(n).image+"'";return r?o+r+a:o+("expecting at least one iteration which starts with one of these possible Token sequences::\n <"+(0,i.UI)(e,(function(t){return"["+(0,i.UI)(t,(function(t){return tt(t)})).join(",")+"]"})).join(" ,")+">")+a}};Object.freeze(Gt);var zt={buildRuleNotFoundError:function(t,e){return"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+"<-\ninside top level rule: ->"+t.name+"<-"}},jt={buildDuplicateFoundError:function(t,e){var n,r=t.name,o=(0,i.Ps)(e),a=o.idx,s=Pt(o),l=(n=o)instanceof Nt?n.terminalType.name:n instanceof yt?n.nonTerminalName:"",u="->"+s+(a>0?a:"")+"<- "+(l?"with argument: ->"+l+"<-":"")+"\n appears more than once ("+e.length+" times) in the top level rule: ->"+r+"<-. \n For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES \n ";return u=(u=u.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=(0,i.UI)(t.prefixPath,(function(t){return tt(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://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details."},buildAlternationAmbiguityError:function(t){var e=(0,i.UI)(t.prefixPath,(function(t){return tt(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://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details."},buildEmptyRepetitionError:function(t){var e=Pt(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"deprecated"},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.UI(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"deprecated"},buildDuplicateRuleNameError:function(t){return"Duplicate definition, rule: ->"+(t.topLevelRule instanceof Tt?t.topLevelRule.name:t.topLevelRule)+"<- is already defined in the grammar: ->"+t.grammarName+"<-"}},Vt=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 Kt=function(t){function e(e,n){var r=t.call(this)||this;return r.nameToTopRule=e,r.errMsgProvider=n,r.errors=[],r}return Vt(e,t),e.prototype.resolveRefs=function(){var t=this;(0,i.Ed)((0,i.VO)(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:bn.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}},e}(It),$t=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)}}(),Yt=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 $t(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 St({definition:r});this.possibleTokTypes=Ft(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 $t(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=(0,i.Qw)(this.path.ruleStack).reverse(),this.occurrenceStack=(0,i.Qw)(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(){(0,i.xb)(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},e}(At)),Xt=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 $t(e,t),e.prototype.startWalking=function(){return this.walk(this.topRule),this.result},e}(At),qt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return $t(e,t),e.prototype.walkMany=function(e,n,r){if(e.idx===this.occurrence){var o=(0,i.Ps)(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof Nt&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else t.prototype.walkMany.call(this,e,n,r)},e}(Xt),Qt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return $t(e,t),e.prototype.walkManySep=function(e,n,r){if(e.idx===this.occurrence){var o=(0,i.Ps)(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof Nt&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else t.prototype.walkManySep.call(this,e,n,r)},e}(Xt),Jt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return $t(e,t),e.prototype.walkAtLeastOne=function(e,n,r){if(e.idx===this.occurrence){var o=(0,i.Ps)(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof Nt&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else t.prototype.walkAtLeastOne.call(this,e,n,r)},e}(Xt),Zt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return $t(e,t),e.prototype.walkAtLeastOneSep=function(e,n,r){if(e.idx===this.occurrence){var o=(0,i.Ps)(n.concat(r));this.result.isEndOfRule=void 0===o,o instanceof Nt&&(this.result.token=o.terminalType,this.result.occurrence=o.idx)}else t.prototype.walkAtLeastOneSep.call(this,e,n,r)},e}(Xt);function te(t,e,n){void 0===n&&(n=[]),n=(0,i.Qw)(n);var r=[],o=0;function a(a){var s=te(a.concat((0,i.Cw)(t,o+1)),e,n);return r.concat(s)}for(;n.length<e&&o<t.length;){var s=t[o];if(s instanceof St)return a(s.definition);if(s instanceof yt)return a(s.definition);if(s instanceof xt)r=a(s.definition);else{if(s instanceof Et)return a(l=s.definition.concat([new bt({definition:s.definition})]));if(s instanceof Ct)return a(l=[new St({definition:s.definition}),new bt({definition:[new Nt({terminalType:s.separator})].concat(s.definition)})]);if(s instanceof kt){var l=s.definition.concat([new bt({definition:[new Nt({terminalType:s.separator})].concat(s.definition)})]);r=a(l)}else if(s instanceof bt){l=s.definition.concat([new bt({definition:s.definition})]);r=a(l)}else{if(s instanceof Ot)return(0,i.Ed)(s.definition,(function(t){!1===(0,i.xb)(t.definition)&&(r=a(t.definition))})),r;if(!(s instanceof Nt))throw Error("non exhaustive match");n.push(s.terminalType)}}o++}return r.push({partialPath:n,suffixDef:(0,i.Cw)(t,o)}),r}function ee(t,e,n,r){var o="EXIT_NONE_TERMINAL",a=[o],s="EXIT_ALTERNATIVE",l=!1,u=e.length,c=u-r-1,h=[],f=[];for(f.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});!(0,i.xb)(f);){var p=f.pop();if(p!==s){var d=p.def,m=p.idx,g=p.ruleStack,v=p.occurrenceStack;if(!(0,i.xb)(d)){var y=d[0];if(y===o){var T={idx:m,def:(0,i.Cw)(d),ruleStack:(0,i.j7)(g),occurrenceStack:(0,i.j7)(v)};f.push(T)}else if(y instanceof Nt)if(m<u-1){var S=m+1;if(n(e[S],y.terminalType)){T={idx:S,def:(0,i.Cw)(d),ruleStack:g,occurrenceStack:v};f.push(T)}}else{if(m!==u-1)throw Error("non exhaustive match");h.push({nextTokenType:y.terminalType,nextTokenOccurrence:y.idx,ruleStack:g,occurrenceStack:v}),l=!0}else if(y instanceof yt){var x=(0,i.Qw)(g);x.push(y.nonTerminalName);var E=(0,i.Qw)(v);E.push(y.idx);T={idx:m,def:y.definition.concat(a,(0,i.Cw)(d)),ruleStack:x,occurrenceStack:E};f.push(T)}else if(y instanceof xt){var C={idx:m,def:(0,i.Cw)(d),ruleStack:g,occurrenceStack:v};f.push(C),f.push(s);var b={idx:m,def:y.definition.concat((0,i.Cw)(d)),ruleStack:g,occurrenceStack:v};f.push(b)}else if(y instanceof Et){var k=new bt({definition:y.definition,idx:y.idx});T={idx:m,def:y.definition.concat([k],(0,i.Cw)(d)),ruleStack:g,occurrenceStack:v};f.push(T)}else if(y instanceof Ct){var O=new Nt({terminalType:y.separator});k=new bt({definition:[O].concat(y.definition),idx:y.idx}),T={idx:m,def:y.definition.concat([k],(0,i.Cw)(d)),ruleStack:g,occurrenceStack:v};f.push(T)}else if(y instanceof kt){C={idx:m,def:(0,i.Cw)(d),ruleStack:g,occurrenceStack:v};f.push(C),f.push(s);O=new Nt({terminalType:y.separator});var N=new bt({definition:[O].concat(y.definition),idx:y.idx});b={idx:m,def:y.definition.concat([N],(0,i.Cw)(d)),ruleStack:g,occurrenceStack:v};f.push(b)}else if(y instanceof bt){C={idx:m,def:(0,i.Cw)(d),ruleStack:g,occurrenceStack:v};f.push(C),f.push(s);N=new bt({definition:y.definition,idx:y.idx}),b={idx:m,def:y.definition.concat([N],(0,i.Cw)(d)),ruleStack:g,occurrenceStack:v};f.push(b)}else if(y instanceof Ot)for(var w=y.definition.length-1;w>=0;w--){var L={idx:m,def:y.definition[w].definition.concat((0,i.Cw)(d)),ruleStack:g,occurrenceStack:v};f.push(L),f.push(s)}else if(y instanceof St)f.push({idx:m,def:y.definition.concat((0,i.Cw)(d)),ruleStack:g,occurrenceStack:v});else{if(!(y instanceof Tt))throw Error("non exhaustive match");f.push(ne(y,m,g,v))}}}else l&&(0,i.Z$)(f).idx<=c&&f.pop()}return h}function ne(t,e,n,r){var o=(0,i.Qw)(n);o.push(t.name);var a=(0,i.Qw)(r);return a.push(1),{idx:e,def:t.definition,ruleStack:o,occurrenceStack:a}}var re,ie=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"}(re||(re={}));var oe=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 ie(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,re.OPTION,n,r)||t.prototype.walkOption.call(this,e,n,r)},e.prototype.walkAtLeastOne=function(e,n,r){this.checkIsTarget(e,re.REPETITION_MANDATORY,n,r)||t.prototype.walkOption.call(this,e,n,r)},e.prototype.walkAtLeastOneSep=function(e,n,r){this.checkIsTarget(e,re.REPETITION_MANDATORY_WITH_SEPARATOR,n,r)||t.prototype.walkOption.call(this,e,n,r)},e.prototype.walkMany=function(e,n,r){this.checkIsTarget(e,re.REPETITION,n,r)||t.prototype.walkOption.call(this,e,n,r)},e.prototype.walkManySep=function(e,n,r){this.checkIsTarget(e,re.REPETITION_WITH_SEPARATOR,n,r)||t.prototype.walkOption.call(this,e,n,r)},e}(At),ae=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 ie(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,re.OPTION)},e.prototype.visitRepetition=function(t){this.checkIsTarget(t,re.REPETITION)},e.prototype.visitRepetitionMandatory=function(t){this.checkIsTarget(t,re.REPETITION_MANDATORY)},e.prototype.visitRepetitionMandatoryWithSeparator=function(t){this.checkIsTarget(t,re.REPETITION_MANDATORY_WITH_SEPARATOR)},e.prototype.visitRepetitionWithSeparator=function(t){this.checkIsTarget(t,re.REPETITION_WITH_SEPARATOR)},e.prototype.visitAlternation=function(t){this.checkIsTarget(t,re.ALTERNATION)},e}(It);function se(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=[];return e}function le(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 l="_"+r.categoryMatches[s];i.push(a+l)}}e=i}return e}function ue(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 ce(t,e){for(var n=(0,i.UI)(t,(function(t){return te([t],1)})),r=se(n.length),o=(0,i.UI)(n,(function(t){var e={};return(0,i.Ed)(t,(function(t){var n=le(t.partialPath);(0,i.Ed)(n,(function(t){e[t]=!0}))})),e})),a=n,s=1;s<=e;s++){var l=a;a=se(l.length);for(var u=function(t){for(var n=l[t],u=0;u<n.length;u++){var c=n[u].partialPath,h=n[u].suffixDef,f=le(c);if(ue(o,f,t)||(0,i.xb)(h)||c.length===e){var p=r[t];if(!1===pe(p,c)){p.push(c);for(var d=0;d<f.length;d++){var m=f[d];o[t][m]=!0}}}else{var g=te(h,s+1,c);a[t]=a[t].concat(g),(0,i.Ed)(g,(function(e){var n=le(e.partialPath);(0,i.Ed)(n,(function(e){o[t][e]=!0}))}))}}},c=0;c<l.length;c++)u(c)}return r}function he(t,e,n,r){var i=new ae(t,re.ALTERNATION,r);return e.accept(i),ce(i.result,n)}function fe(t,e,n,r){var i=new ae(t,n);e.accept(i);var o=i.result,a=new oe(e,t,n).startWalking();return ce([new St({definition:o}),new St({definition:a})],r)}function pe(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 de(t){return(0,i.yW)(t,(function(t){return(0,i.yW)(t,(function(t){return(0,i.yW)(t,(function(t){return(0,i.xb)(t.categoryMatches)}))}))}))}var me=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 ge(t,e,n,r,o){var a=i.UI(t,(function(t){return function(t,e){var n=new Te;t.accept(n);var r=n.allProductions,o=i.vM(r,ve),a=i.ei(o,(function(t){return t.length>1}));return i.UI(i.VO(a),(function(n){var r=i.Ps(n),o=e.buildDuplicateFoundError(t,n),a=Pt(r),s={message:o,type:bn.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:a,occurrence:r.idx},l=ye(r);return l&&(s.parameter=l),s}))}(t,r)})),s=i.UI(t,(function(t){return Se(t,t,r)})),l=[],u=[],c=[];(0,i.yW)(s,i.xb)&&(l=(0,i.UI)(t,(function(t){return function(t,e){var n=new Ee;t.accept(n);var r=n.alternations;return i.u4(r,(function(n,r){var o=i.j7(r.definition),a=i.UI(o,(function(n,o){var a=ee([n],[],null,1);return i.xb(a)?{message:e.buildEmptyAlternationError({topLevelRule:t,alternation:r,emptyChoiceIdx:o}),type:bn.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:r.idx,alternative:o+1}:null}));return n.concat(i.oA(a))}),[])}(t,r)})),u=(0,i.UI)(t,(function(t){return function(t,e,n){var r=new Ee;t.accept(r);var o=r.alternations;return o=(0,i.d1)(o,(function(t){return!0===t.ignoreAmbiguities})),i.u4(o,(function(r,o){var a=o.idx,s=o.maxLookahead||e,l=he(a,t,s,o),u=function(t,e,n,r){var o=[],a=(0,i.u4)(t,(function(n,r,a){return!0===e.definition[a].ignoreAmbiguities||(0,i.Ed)(r,(function(r){var s=[a];(0,i.Ed)(t,(function(t,n){a!==n&&pe(t,r)&&!0!==e.definition[n].ignoreAmbiguities&&s.push(n)})),s.length>1&&!pe(o,r)&&(o.push(r),n.push({alts:s,path:r}))})),n}),[]);return i.UI(a,(function(t){var o=(0,i.UI)(t.alts,(function(t){return t+1}));return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:o,prefixPath:t.path}),type:bn.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:e.idx,alternatives:[t.alts]}}))}(l,o,t,n),c=function(t,e,n,r){var o=[],a=(0,i.u4)(t,(function(t,e,n){var r=(0,i.UI)(e,(function(t){return{idx:n,path:t}}));return t.concat(r)}),[]);return(0,i.Ed)(a,(function(t){if(!0!==e.definition[t.idx].ignoreAmbiguities){var s=t.idx,l=t.path,u=(0,i.Oq)(a,(function(t){return!0!==e.definition[t.idx].ignoreAmbiguities&&t.idx<s&&(n=t.path,r=l,n.length<r.length&&(0,i.yW)(n,(function(t,e){var n=r[e];return t===n||n.categoryMatchesMap[t.tokenTypeIdx]})));var n,r})),c=(0,i.UI)(u,(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:bn.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:i}}));o=o.concat(c)}})),o}(l,o,t,n);return r.concat(u,c)}),[])}(t,e,r)})),c=function(t,e,n){var r=[];return(0,i.Ed)(t,(function(t){var o=new Ce;t.accept(o);var a=o.allProductions;(0,i.Ed)(a,(function(o){var a=function(t){if(t instanceof xt)return re.OPTION;if(t instanceof bt)return re.REPETITION;if(t instanceof Et)return re.REPETITION_MANDATORY;if(t instanceof Ct)return re.REPETITION_MANDATORY_WITH_SEPARATOR;if(t instanceof kt)return re.REPETITION_WITH_SEPARATOR;if(t instanceof Ot)return re.ALTERNATION;throw Error("non exhaustive match")}(o),s=o.maxLookahead||e,l=fe(o.idx,t,a,s)[0];if((0,i.xb)((0,i.xH)(l))){var u=n.buildEmptyRepetitionError({topLevelRule:t,repetition:o});r.push({message:u,type:bn.NO_NON_EMPTY_LOOKAHEAD,ruleName:t.name})}}))})),r}(t,e,r));var h=function(t,e,n){var r=[],o=(0,i.UI)(e,(function(t){return t.name}));return(0,i.Ed)(t,(function(t){var e=t.name;if((0,i.r3)(o,e)){var a=n.buildNamespaceConflictError(t);r.push({message:a,type:bn.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:e})}})),r}(t,n,r),f=(0,i.UI)(t,(function(t){return function(t,e){var n=new Ee;t.accept(n);var r=n.alternations;return i.u4(r,(function(n,r){return r.definition.length>255&&n.push({message:e.buildTooManyAlternativesError({topLevelRule:t,alternation:r}),type:bn.TOO_MANY_ALTS,ruleName:t.name,occurrence:r.idx}),n}),[])}(t,r)})),p=(0,i.UI)(t,(function(e){return function(t,e,n,r){var o=[];if((0,i.u4)(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:bn.DUPLICATE_RULE_NAME,ruleName:t.name})}return o}(e,t,o,r)}));return i.xH(a.concat(c,s,l,u,h,f,p))}function ve(t){return Pt(t)+"_#_"+t.idx+"_#_"+ye(t)}function ye(t){return t instanceof Nt?t.terminalType.name:t instanceof yt?t.nonTerminalName:""}var Te=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allProductions=[],e}return me(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}(It);function Se(t,e,n,r){void 0===r&&(r=[]);var o=[],a=xe(e.definition);if(i.xb(a))return[];var s=t.name;i.r3(a,t)&&o.push({message:n.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:r}),type:bn.LEFT_RECURSION,ruleName:s});var l=i.e5(a,r.concat([t])),u=i.UI(l,(function(e){var o=i.Qw(r);return o.push(e),Se(t,e,n,o)}));return o.concat(i.xH(u))}function xe(t){var e=[];if(i.xb(t))return e;var n=i.Ps(t);if(n instanceof yt)e.push(n.referencedRule);else if(n instanceof St||n instanceof xt||n instanceof Et||n instanceof Ct||n instanceof kt||n instanceof bt)e=e.concat(xe(n.definition));else if(n instanceof Ot)e=i.xH(i.UI(n.definition,(function(t){return xe(t.definition)})));else if(!(n instanceof Nt))throw Error("non exhaustive match");var r=_t(n),o=t.length>1;if(r&&o){var a=i.Cw(t);return e.concat(xe(a))}return e}var Ee=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.alternations=[],e}return me(e,t),e.prototype.visitAlternation=function(t){this.alternations.push(t)},e}(It);var Ce=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.allProductions=[],e}return me(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}(It);function be(t){t=(0,i.ce)(t,{errMsgProvider:zt});var e,n,r,o={};return(0,i.Ed)(t.rules,(function(t){o[t.name]=t})),e=o,n=t.errMsgProvider,(r=new Kt(e,n)).resolveRefs(),r.errors}function ke(t){return ge((t=(0,i.ce)(t,{errMsgProvider:jt})).rules,t.maxLookahead,t.tokenTypes,t.errMsgProvider,t.grammarName)}function Oe(t){(0,i.Ed)(t.rules,(function(t){var e=new Ut;t.accept(e),(0,i.Ed)(e.dslMethods,(function(t){(0,i.Ed)(t,(function(t,e){t.idx=e+1}))}))}))}var Ne=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)}}(),we="MismatchedTokenException",Le="NoViableAltException",Ae="EarlyExitException",Re="NotAllInputParsedException",Ie=[we,Le,Ae,Re];function Me(t){return(0,i.r3)(Ie,t.name)}Object.freeze(Ie);var _e=function(t){function e(e,n){var r=this.constructor,i=t.call(this,e)||this;return i.token=n,i.resyncedTokens=[],Object.setPrototypeOf(i,r.prototype),Error.captureStackTrace&&Error.captureStackTrace(i,i.constructor),i}return Ne(e,t),e}(Error),Pe=function(t){function e(e,n,r){var i=t.call(this,e,n)||this;return i.previousToken=r,i.name=we,i}return Ne(e,t),e}(_e),Ue=function(t){function e(e,n,r){var i=t.call(this,e,n)||this;return i.previousToken=r,i.name=Le,i}return Ne(e,t),e}(_e),De=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.name=Re,r}return Ne(e,t),e}(_e),Fe=function(t){function e(e,n,r){var i=t.call(this,e,n)||this;return i.previousToken=r,i.name=Ae,i}return Ne(e,t),e}(_e),We={},Be="InRuleRecoveryException";function He(t){this.name=Be,this.message=t}He.prototype=Error.prototype;var Ge=function(){function t(){}return t.prototype.initRecoverable=function(t){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=(0,i.e$)(t,"recoveryEnabled")?t.recoveryEnabled:kn.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=ze)},t.prototype.getTokenToInsert=function(t){var e=dt(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(),l=[],u=!1,c=this.LA(1),h=this.LA(1),f=function(){var t=o.LA(0),e=o.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:t,ruleName:o.getCurrRuleFullName()}),n=new Pe(e,c,o.LA(0));n.resyncedTokens=(0,i.j7)(l),o.SAVE_ERROR(n)};!u;){if(this.tokenMatcher(h,r))return void f();if(n.call(this))return f(),void t.apply(this,e);this.tokenMatcher(h,a)?u=!0:(h=this.SKIP_TOKEN(),this.addToResyncTokens(h,l))}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 He("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((0,i.xb)(e))return!1;var r=this.LA(1);return void 0!==(0,i.sE)(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(0,i.r3)(n,t)},t.prototype.findReSyncTokenType=function(){for(var t=this.flattenFollowSet(),e=this.LA(1),n=2;;){var r=e.tokenType;if((0,i.r3)(t,r))return r;e=this.LA(n),n++}},t.prototype.getCurrFollowKey=function(){if(1===this.RULE_STACK.length)return We;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(0,i.UI)(e,(function(r,i){return 0===i?We:{ruleName:t.shortRuleNameToFullName(r),idxInCallingRule:n[i],inRule:t.shortRuleNameToFullName(e[i-1])}}))},t.prototype.flattenFollowSet=function(){var t=this,e=(0,i.UI)(this.buildFullFollowKeyStack(),(function(e){return t.getFollowSetFromFollowKey(e)}));return(0,i.xH)(e)},t.prototype.getFollowSetFromFollowKey=function(t){if(t===We)return[pt];var e=t.ruleName+t.idxInCallingRule+Wt+t.inRule;return this.resyncFollows[e]},t.prototype.addToResyncTokens=function(t,e){return this.tokenMatcher(t,pt)||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(0,i.j7)(e)},t.prototype.attemptInRepetitionRecovery=function(t,e,n,r,i,o,a){},t.prototype.getCurrentGrammarPath=function(t,e){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:(0,i.Qw)(this.RULE_OCCURRENCE_STACK),lastTok:t,lastTokOccurrence:e}},t.prototype.getHumanReadableRuleStack=function(){var t=this;return(0,i.UI)(this.RULE_STACK,(function(e){return t.shortRuleNameToFullName(e)}))},t}();function ze(t,e,n,r,i,o,a){var s=this.getKeyForAutomaticLookahead(r,i),l=this.firstAfterRepMap[s];if(void 0===l){var u=this.getCurrRuleFullName();l=new o(this.getGAstProductions()[u],i).startWalking(),this.firstAfterRepMap[s]=l}var c=l.token,h=l.occurrence,f=l.isEndOfRule;1===this.RULE_STACK.length&&f&&void 0===c&&(c=pt,h=1),this.shouldInRepetitionRecoveryBeTried(c,h,a)&&this.tryInRepetitionRecovery(t,e,n,c)}var je=1024,Ve=1280,Ke=1536;function $e(t,e,n){return n|e|t}var Ye=function(){function t(){}return t.prototype.initLooksAhead=function(t){this.dynamicTokensEnabled=(0,i.e$)(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:kn.dynamicTokensEnabled,this.maxLookahead=(0,i.e$)(t,"maxLookahead")?t.maxLookahead:kn.maxLookahead,this.lookAheadFuncsCache=(0,i.dU)()?new Map:[],(0,i.dU)()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},t.prototype.preComputeLookaheadFunctions=function(t){var e=this;(0,i.Ed)(t,(function(t){e.TRACE_INIT(t.name+" Rule Lookahead",(function(){var n=function(t){Dt.reset(),t.accept(Dt);var e=Dt.dslMethods;return Dt.reset(),e}(t),r=n.alternation,o=n.repetition,a=n.option,s=n.repetitionMandatory,l=n.repetitionMandatoryWithSeparator,u=n.repetitionWithSeparator;(0,i.Ed)(r,(function(n){var r=0===n.idx?"":n.idx;e.TRACE_INIT(""+Pt(n)+r,(function(){var r,i,o,a,s,l,u,c=(r=n.idx,i=t,o=n.maxLookahead||e.maxLookahead,a=n.hasPredicates,s=e.dynamicTokensEnabled,l=e.lookAheadBuilderForAlternatives,u=he(r,i,o),l(u,a,de(u)?G:H,s)),h=$e(e.fullRuleNameToShort[t.name],256,n.idx);e.setLaFuncCache(h,c)}))})),(0,i.Ed)(o,(function(n){e.computeLookaheadFunc(t,n.idx,768,re.REPETITION,n.maxLookahead,Pt(n))})),(0,i.Ed)(a,(function(n){e.computeLookaheadFunc(t,n.idx,512,re.OPTION,n.maxLookahead,Pt(n))})),(0,i.Ed)(s,(function(n){e.computeLookaheadFunc(t,n.idx,je,re.REPETITION_MANDATORY,n.maxLookahead,Pt(n))})),(0,i.Ed)(l,(function(n){e.computeLookaheadFunc(t,n.idx,Ke,re.REPETITION_MANDATORY_WITH_SEPARATOR,n.maxLookahead,Pt(n))})),(0,i.Ed)(u,(function(n){e.computeLookaheadFunc(t,n.idx,Ve,re.REPETITION_WITH_SEPARATOR,n.maxLookahead,Pt(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=fe(t,e,i,n),s=de(a)?G:H;return o(a[0],s,r)}(e,t,i||a.maxLookahead,a.dynamicTokensEnabled,r,a.lookAheadBuilderForOptional),s=$e(a.fullRuleNameToShort[t.name],n,e);a.setLaFuncCache(s,o)}))},t.prototype.lookAheadBuilderForOptional=function(t,e,n){return function(t,e,n){var r=(0,i.yW)(t,(function(t){return 1===t.length})),o=t.length;if(r&&!n){var a=(0,i.xH)(t);if(1===a.length&&(0,i.xb)(a[0].categoryMatches)){var s=a[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===s}}var l=(0,i.u4)(a,(function(t,e,n){return t[e.tokenTypeIdx]=!0,(0,i.Ed)(e.categoryMatches,(function(e){t[e]=!0})),t}),[]);return function(){var t=this.LA(1);return!0===l[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=(0,i.yW)(t,(function(t){return(0,i.yW)(t,(function(t){return 1===t.length}))}));if(e)return function(e){for(var r=(0,i.UI)(e,(function(t){return t.GATE})),a=0;a<o;a++){var s=t[a],l=s.length,u=r[a];if(void 0===u||!1!==u.call(this))t:for(var c=0;c<l;c++){for(var h=s[c],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=(0,i.UI)(t,(function(t){return(0,i.xH)(t)})),l=(0,i.u4)(s,(function(t,e,n){return(0,i.Ed)(e,(function(e){(0,i.e$)(t,e.tokenTypeIdx)||(t[e.tokenTypeIdx]=n),(0,i.Ed)(e.categoryMatches,(function(e){(0,i.e$)(t,e)||(t[e]=n)}))})),t}),[]);return function(){var t=this.LA(1);return l[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],l=s.length,u=0;u<l;u++){var c=this.LA(u+1);if(!1===n(c,s[u]))continue t}return e}}}}(t,e,n,r)},t.prototype.getKeyForAutomaticLookahead=function(t,e){return $e(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 Xe(t,e){!0===isNaN(t.startOffset)?(t.startOffset=e.startOffset,t.endOffset=e.endOffset):t.endOffset<e.endOffset==!0&&(t.endOffset=e.endOffset)}function qe(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 Qe,Je="name";function Ze(t){var e=t.name;return e||"anonymous"}function tn(t,e){var n=Object.getOwnPropertyDescriptor(t,Je);return!(!(0,i.o8)(n)&&!n.configurable)&&(Object.defineProperty(t,Je,{enumerable:!1,configurable:!0,writable:!1,value:e}),!0)}function en(t,e){for(var n=(0,i.XP)(t),r=n.length,o=0;o<r;o++)for(var a=t[n[o]],s=a.length,l=0;l<s;l++){var u=a[l];void 0===u.tokenTypeIdx&&this[u.name](u.children,e)}}function nn(t,e){var n=function(){};return tn(n,t+"BaseSemantics"),(n.prototype={visit:function(t,e){if((0,i.kJ)(t)&&(t=t[0]),!(0,i.o8)(t))return this[t.name](t.children,e)},validateVisitor:function(){var t=function(t,e){var n=function(t,e){var n=(0,i.UI)(e,(function(e){if(!(0,i.mf)(t[e]))return{msg:"Missing visitor method: <"+e+"> on "+Ze(t.constructor)+" CST Visitor.",type:Qe.MISSING_METHOD,methodName:e}}));return(0,i.oA)(n)}(t,e),r=function(t,e){var n=[];for(var r in t)!(0,i.mf)(t[r])||(0,i.r3)(rn,r)||(0,i.r3)(e,r)||n.push({msg:"Redundant visitor method: <"+r+"> on "+Ze(t.constructor)+" CST Visitor\nThere is no Grammar Rule corresponding to this method's name.\n",type:Qe.REDUNDANT_METHOD,methodName:r});return n}(t,e);return n.concat(r)}(this,e);if(!(0,i.xb)(t)){var n=(0,i.UI)(t,(function(t){return t.msg}));throw Error("Errors Detected in CST Visitor <"+Ze(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"}(Qe||(Qe={}));var rn=["constructor","visit","validateVisitor"];var on=function(){function t(){}return t.prototype.initTreeBuilder=function(t){if(this.CST_STACK=[],this.outputCst=t.outputCst,this.nodeLocationTracking=(0,i.e$)(t,"nodeLocationTracking")?t.nodeLocationTracking:kn.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=qe,this.setNodeLocationFromNode=qe,this.cstPostRule=i.dG,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=i.dG,this.setNodeLocationFromNode=i.dG,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Xe,this.setNodeLocationFromNode=Xe,this.cstPostRule=i.dG,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=i.dG,this.setNodeLocationFromNode=i.dG,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.dG,this.setNodeLocationFromNode=i.dG,this.cstPostRule=i.dG,this.setInitialNodeLocation=i.dG}else this.cstInvocationStateUpdate=i.dG,this.cstFinallyStateUpdate=i.dG,this.cstPostTerminal=i.dG,this.cstPostNonTerminal=i.dG,this.cstPostRule=i.dG},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((0,i.o8)(this.baseCstVisitorConstructor)){var t=nn(this.className,(0,i.XP)(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor},t.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if((0,i.o8)(this.baseCstVisitorWithDefaultsConstructor)){var t=function(t,e,n){var r=function(){};tn(r,t+"BaseSemanticsWithDefaults");var o=Object.create(n.prototype);return(0,i.Ed)(e,(function(t){o[t]=en})),(r.prototype=o).constructor=r,r}(this.className,(0,i.XP)(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}(),an=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)):Cn},t.prototype.LA=function(t){var e=this.currIdx+t;return e<0||this.tokVectorLength<=e?Cn: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}(),sn=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=On),(0,i.r3)(this.definedRulesNames,t)){var r={message:jt.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:bn.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=On);var r,o,a,s,l,u=[];u=u.concat((r=t,o=this.definedRulesNames,a=this.className,l=[],i.r3(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 ",l.push({message:s,type:bn.INVALID_RULE_OVERRIDE,ruleName:r})),l)),this.definitionErrors.push.apply(this.definitionErrors,u);var c=this.defineRule(t,e,n);return this[t]=c,c},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(Me(t))return!1;throw t}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}},t.prototype.getGAstProductions=function(){return this.gastProductionsCache},t.prototype.getSerializedGastProductions=function(){return wt((0,i.VO)(this.gastProductionsCache))},t}(),ln=function(){function t(){}return t.prototype.initRecognizerEngine=function(t,e){if(this.className=Ze(this.constructor),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=G,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},(0,i.e$)(e,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n\tFor Further details.");if((0,i.kJ)(t)){if((0,i.xb)(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://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n\tFor Further details.")}if((0,i.kJ)(t))this.tokensMap=(0,i.u4)(t,(function(t,e){return t[e.name]=e,t}),{});else if((0,i.e$)(t,"modes")&&(0,i.yW)((0,i.xH)((0,i.VO)(t.modes)),X)){var n=(0,i.xH)((0,i.VO)(t.modes)),r=(0,i.jj)(n);this.tokensMap=(0,i.u4)(r,(function(t,e){return t[e.name]=e,t}),{})}else{if(!(0,i.Kn)(t))throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=(0,i.Cl)(t)}this.tokensMap.EOF=pt;var o=(0,i.yW)((0,i.VO)(t),(function(t){return(0,i.xb)(t.categoryMatches)}));this.tokenMatcher=o?G:H,V((0,i.VO)(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=(0,i.e$)(n,"resyncEnabled")?n.resyncEnabled:On.resyncEnabled,a=(0,i.e$)(n,"recoveryValueFunc")?n.recoveryValueFunc:On.recoveryValueFunc,s=this.ruleShortNameIdx<<12;function l(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),l.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(Me(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(je,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,re.REPETITION_MANDATORY,e.ERR_MSG);for(var l=this.doSingleRepetition(r);!0===a.call(this)&&!0===l;)l=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,e],a,je,t,Jt)},t.prototype.atLeastOneSepFirstInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(Ke,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,re.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,Zt],a,Ke,t,Zt)},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 l=!0;!0===a.call(this)&&!0===l;)l=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.manyInternal,[t,e],a,768,t,qt,l)},t.prototype.manySepFirstInternal=function(t,e){var n=this.getKeyForAutomaticLookahead(Ve,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,Qt],a,Ve,t,Qt)}},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,Ke,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=(0,i.kJ)(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 De(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 Me(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 Pe(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 t.name===Be?n:t}},t.prototype.saveRecogState=function(){var t=this.errors,e=(0,i.Qw)(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),pt)},t.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},t}(),un=function(){function t(){}return t.prototype.initErrorHandler=function(t){this._errors=[],this.errorMessageProvider=(0,i.e$)(t,"errorMessageProvider")?t.errorMessageProvider:kn.errorMessageProvider},t.prototype.SAVE_ERROR=function(t){if(Me(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:(0,i.Qw)(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(0,i.Qw)(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=fe(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 Fe(s,this.LA(1),this.LA(0)))},t.prototype.raiseNoAltException=function(t,e){for(var n=this.getCurrRuleFullName(),r=he(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 Ue(s,this.LA(1),a))},t}(),cn=function(){function t(){}return t.prototype.initContentAssist=function(){},t.prototype.computeContentAssist=function(t,e){var n=this.gastProductionsCache[t];if((0,i.o8)(n))throw Error("Rule ->"+t+"<- does not exist in this grammar.");return ee([n],e,this.tokenMatcher,this.maxLookahead)},t.prototype.getNextPossibleTokenTypes=function(t){var e=(0,i.Ps)(t.ruleStack),n=this.getGAstProductions()[e];return new Yt(n,t).startWalking()},t}(),hn={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(hn);var fn=Math.pow(2,8)-1,pn=ft({name:"RECORDING_PHASE_TOKEN",pattern:Z.NA});V([pn]);var dn=dt(pn,"This IToken indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(dn);var mn={name:"This CSTNode indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",children:{}},gn=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 Cn},t.prototype.topLevelRuleRecord=function(t,e){try{var n=new Tt({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://chevrotain.io/docs/guide/internals.html#grammar-recording'}catch(e){throw t}throw t}},t.prototype.optionInternalRecord=function(t,e){return vn.call(this,xt,t,e)},t.prototype.atLeastOneInternalRecord=function(t,e){vn.call(this,Et,e,t)},t.prototype.atLeastOneSepFirstInternalRecord=function(t,e){vn.call(this,Ct,e,t,true)},t.prototype.manyInternalRecord=function(t,e){vn.call(this,bt,e,t)},t.prototype.manySepFirstInternalRecord=function(t,e){vn.call(this,kt,e,t,true)},t.prototype.orInternalRecord=function(t,e){return yn.call(this,t,e)},t.prototype.subruleInternalRecord=function(t,e,n){if(Sn(e),!t||!1===(0,i.e$)(t,"ruleName")){var r=new Error("<SUBRULE"+Tn(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=(0,i.fj)(this.recordingProdStack),a=t.ruleName,s=new yt({idx:e,nonTerminalName:a,referencedRule:void 0});return o.definition.push(s),this.outputCst?mn:hn},t.prototype.consumeInternalRecord=function(t,e,n){if(Sn(e),!$(t)){var r=new Error("<CONSUME"+Tn(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=(0,i.fj)(this.recordingProdStack),a=new Nt({idx:e,terminalType:t});return o.definition.push(a),dn},t}();function vn(t,e,n,r){void 0===r&&(r=!1),Sn(n);var o=(0,i.fj)(this.recordingProdStack),a=(0,i.mf)(e)?e:e.DEF,s=new t({definition:[],idx:n});return r&&(s.separator=e.SEP),(0,i.e$)(e,"MAX_LOOKAHEAD")&&(s.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(s),a.call(this),o.definition.push(s),this.recordingProdStack.pop(),hn}function yn(t,e){var n=this;Sn(e);var r=(0,i.fj)(this.recordingProdStack),o=!1===(0,i.kJ)(t),a=!1===o?t:t.DEF,s=new Ot({definition:[],idx:e,ignoreAmbiguities:o&&!0===t.IGNORE_AMBIGUITIES});(0,i.e$)(t,"MAX_LOOKAHEAD")&&(s.maxLookahead=t.MAX_LOOKAHEAD);var l=(0,i.G)(a,(function(t){return(0,i.mf)(t.GATE)}));return s.hasPredicates=l,r.definition.push(s),(0,i.Ed)(a,(function(t){var e=new St({definition:[]});s.definition.push(e),(0,i.e$)(t,"IGNORE_AMBIGUITIES")?e.ignoreAmbiguities=t.IGNORE_AMBIGUITIES:(0,i.e$)(t,"GATE")&&(e.ignoreAmbiguities=!0),n.recordingProdStack.push(e),t.ALT.call(n),n.recordingProdStack.pop()})),hn}function Tn(t){return 0===t?"":""+t}function Sn(t){if(t<0||t>fn){var e=new Error("Invalid DSL Method idx value: <"+t+">\n\tIdx value must be a none negative value smaller than "+(fn+1));throw e.KNOWN_RECORDER_ERROR=!0,e}}var xn=function(){function t(){}return t.prototype.initPerformanceTracer=function(t){if((0,i.e$)(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=kn.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=(0,i.HT)(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}(),En=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)}}(),Cn=dt(pt,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Cn);var bn,kn=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Gt,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),On=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0});function Nn(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"}(bn||(bn={}));var wn=function(){function t(t,e){this.definitionErrors=[],this.selfAnalysisDone=!1;var n=this;if(n.initErrorHandler(e),n.initLexerAdapter(),n.initLooksAhead(e),n.initRecognizerEngine(t,e),n.initRecoverable(e),n.initTreeBuilder(e),n.initContentAssist(),n.initGastRecorder(e),n.initPerformanceTracer(e),(0,i.e$)(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://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\tFor further details.");this.skipValidations=(0,i.e$)(e,"skipValidations")?e.skipValidations:kn.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(){(0,i.SV)(e)})),e.TRACE_INIT("Grammar Recording",(function(){try{e.enableRecording(),(0,i.Ed)(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=be({rules:(0,i.VO)(e.gastProductionsCache)}),e.definitionErrors.push.apply(e.definitionErrors,o)})),e.TRACE_INIT("Grammar Validations",(function(){if((0,i.xb)(o)&&!1===e.skipValidations){var t=ke({rules:(0,i.VO)(e.gastProductionsCache),maxLookahead:e.maxLookahead,tokenTypes:(0,i.VO)(e.tokensMap),errMsgProvider:jt,grammarName:r});e.definitionErrors.push.apply(e.definitionErrors,t)}})),(0,i.xb)(e.definitionErrors)&&(e.recoveryEnabled&&e.TRACE_INIT("computeAllProdsFollows",(function(){var t,n,r=(t=(0,i.VO)(e.gastProductionsCache),n={},(0,i.Ed)(t,(function(t){var e=new Ht(t).startWalking();(0,i.f0)(n,e)})),n);e.resyncFollows=r})),e.TRACE_INIT("ComputeLookaheadFunctions",(function(){e.preComputeLookaheadFunctions((0,i.VO)(e.gastProductionsCache))}))),!t.DEFER_DEFINITION_ERRORS_HANDLING&&!(0,i.xb)(e.definitionErrors))throw n=(0,i.UI)(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}();(0,i.ef)(wn,[Ge,Ye,on,an,ln,sn,un,cn,gn,xn]);var Ln=function(t){function e(e,n){void 0===n&&(n=kn);var r=(0,i.Cl)(n);return r.outputCst=!0,t.call(this,e,r)||this}return En(e,t),e}(wn),An=function(t){function e(e,n){void 0===n&&(n=kn);var r=(0,i.Cl)(n);return r.outputCst=!1,t.call(this,e,r)||this}return En(e,t),e}(wn);function Rn(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 In="\n";function Mn(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,(0,i.UI)(e,(function(t){return function(t,e){var n=Wn(e,'$.RULE("'+t.name+'", function() {')+In;return n+=Fn(t.definition,e+1),n+=Wn(e+1,"})")+In}(t,1)})).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 _n(t,e){var n=Wn(e,"$.OR"+t.idx+"([")+In,r=(0,i.UI)(t.definition,(function(t){return function(t,e){var n=Wn(e,"{")+In;return n+=Wn(e+1,"ALT: function() {")+In,n+=Fn(t.definition,e+1),n+=Wn(e+1,"}")+In,n+=Wn(e,"}")}(t,e+1)}));return n+=r.join(",\n"),n+=In+Wn(e,"])\n")}function Pn(t,e){if(t instanceof yt)return function(t,e){return Wn(e,"$.SUBRULE"+t.idx+"($."+t.nonTerminalName+")"+In)}(t,e);if(t instanceof xt)return Un("OPTION",t,e);if(t instanceof Et)return Un("AT_LEAST_ONE",t,e);if(t instanceof Ct)return Un("AT_LEAST_ONE_SEP",t,e);if(t instanceof kt)return Un("MANY_SEP",t,e);if(t instanceof bt)return Un("MANY",t,e);if(t instanceof Ot)return _n(t,e);if(t instanceof Nt)return function(t,e){var n=t.terminalType.name;return Wn(e,"$.CONSUME"+t.idx+"(this.tokensMap."+n+")"+In)}(t,e);if(t instanceof St)return Fn(t.definition,e);throw Error("non exhaustive match")}function Un(t,e,n){var r=Wn(n,"$."+(t+e.idx)+"(");return e.separator?(r+="{\n",r+=Wn(n+1,"SEP: this.tokensMap."+e.separator.name)+","+In,r+="DEF: "+Dn(e.definition,n+2)+In,r+=Wn(n,"}")+In):r+=Dn(e.definition,n+1),r+=Wn(n,")")+In}function Dn(t,e){var n="function() {\n";return n+=Fn(t,e),n+=Wn(e,"}")+In}function Fn(t,e){var n="";return(0,i.Ed)(t,(function(t){n+=Pn(t,e+1)})),n}function Wn(t,e){return Array(4*t+1).join(" ")+e}function Bn(t){var e=function(t){return" \n"+Mn(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(650))}}function Hn(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"+Mn(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 zn=function(){throw new Error("The Parser class has been deprecated, use CstParser or EmbeddedActionsParser instead.\t\nSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0")}},465:(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 l(t){for(var e=[],n=0;n<t.length;n++){var r=t[n];Array.isArray(r)?e=e.concat(l(r)):e.push(r)}return e}function u(t){return r(t)?void 0:t[0]}function c(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(!I(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 T(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 S(t,e){return!!I(t)&&t.hasOwnProperty(e)}function x(t,e){return void 0!==b(t,(function(t){return t===e}))}function E(t){for(var e=[],n=0;n<t.length;n++)e.push(t[n]);return e}function C(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function b(t,e){for(var n=0;n<t.length;n++){var r=t[n];if(e.call(null,r))return r}}function k(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 O(t,e,n){for(var r=Array.isArray(t),a=r?t:o(t),s=r?[]:i(t),l=n,u=0;u<a.length;u++)l=e.call(null,l,a[u],r?u:s[u]);return l}function N(t){return y(t,(function(t){return null==t}))}function w(t,e){void 0===e&&(e=function(t){return t});var n=[];return O(t,(function(t,r){var i=e(r);return x(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 R(t){return t instanceof RegExp}function I(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 x(e,t)}))}function P(t,e){for(var n=0;n<t.length;n++)if(e(t[n]))return!0;return!1}function U(t,e){for(var n=0;n<t.length;n++)if(t[n]===e)return n;return-1}function D(t,e){var n=E(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 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 l=a[s];t[l]=o[l]}return t}function B(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 l=a[s];S(t,l)||(t[l]=o[l])}return t}function H(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return B.apply(null,[{}].concat(t))}function G(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 z(t,e){for(var n=C(t),r=i(e),o=0;o<r.length;o++){var a=r[o],s=e[a];n[a]=s}return n}function j(){}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 $(t){console&&console.error&&console.error("Error: "+t)}function Y(t){console&&console.warn&&console.warn("Warning: "+t)}function X(){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 Q(t){function e(){}e.prototype=t;var n=new e;function r(){return typeof n.bar}return r(),r(),t}function J(t){return t[t.length-1]}function Z(t){var e=(new Date).getTime(),n=t();return{time:(new Date).getTime()-e,value:n}}n.d(e,{xb:()=>r,XP:()=>i,VO:()=>o,Q8:()=>a,UI:()=>s,xH:()=>l,Ps:()=>u,Z$:()=>c,Ed:()=>h,HD:()=>f,o8:()=>p,mf:()=>d,Cw:()=>m,j7:()=>g,hX:()=>v,d1:()=>y,ei:()=>T,e$:()=>S,r3:()=>x,Qw:()=>E,Cl:()=>C,sE:()=>b,Oq:()=>k,u4:()=>O,oA:()=>N,jj:()=>w,kJ:()=>A,Kj:()=>R,Kn:()=>I,yW:()=>M,e5:()=>_,G:()=>P,cq:()=>U,f0:()=>W,ce:()=>H,vM:()=>G,TS:()=>z,dG:()=>j,Wd:()=>V,X0:()=>K,WB:()=>$,rr:()=>Y,dU:()=>X,ef:()=>q,SV:()=>Q,fj:()=>J,HT:()=>Z})},256:(t,e,n)=>{!function(t){"use strict";var e="CodeMirror-lint-markers",n="CodeMirror-lint-line-";function r(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}function i(t){t.parentNode&&t.parentNode.removeChild(t)}function o(t){t.parentNode&&(null==t.style.opacity&&i(t),t.style.opacity=0,setTimeout((function(){i(t)}),600))}function a(e,n,i,a){var s=r(e,n,i);function l(){t.off(a,"mouseout",l),s&&(o(s),s=null)}var u=setInterval((function(){if(s)for(var t=a;;t=t.parentNode){if(t&&11==t.nodeType&&(t=t.host),t==document.body)return;if(!t){l();break}}if(!s)return clearInterval(u)}),400);t.on(a,"mouseout",l)}function s(t,e,n){this.marked=[],this.options=e,this.timeout=null,this.hasGutter=n,this.onMouseOver=function(e){x(t,e)},this.waitingFor=0}function l(t,e){return e instanceof Function?{getAnnotations:e}:(e&&!0!==e||(e={}),e)}function u(t){var n=t.state.lint;n.hasGutter&&t.clearGutter(e),h(n)&&c(t);for(var r=0;r<n.marked.length;++r)n.marked[r].clear();n.marked.length=0}function c(t){t.eachLine((function(e){var n=e.wrapClass&&/\bCodeMirror-lint-line-\w+\b/.exec(e.wrapClass);n&&t.removeLineClass(e,"wrap",n[0])}))}function h(t){return t.options.highlightLines}function f(e,n,r,i,o){var s=document.createElement("div"),l=s;return s.className="CodeMirror-lint-marker CodeMirror-lint-marker-"+r,i&&((l=s.appendChild(document.createElement("div"))).className="CodeMirror-lint-marker CodeMirror-lint-marker-multiple"),0!=o&&t.on(l,"mouseover",(function(t){a(e,t,n,l)})),s}function p(t,e){return"error"==t?t:e}function d(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}function m(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 g(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(){y(e,n)})))}),r,e)}function v(e){var n=e.state.lint;if(n){var r=n.options,i=r.options||r,o=r.getAnnotations||e.getHelper(t.Pos(0,0),"lint");if(o)if(r.async||o.async)g(e,o,i);else{var a=o(e.getValue(),i,e);if(!a)return;a.then?a.then((function(t){e.operation((function(){y(e,t)}))})):e.operation((function(){y(e,a)}))}}}function y(t,r){var i=t.state.lint;if(i){var o=i.options;u(t);for(var a=d(r),s=0;s<a.length;++s){var l=a[s];if(l){var c=[];l=l.filter((function(t){return!(c.indexOf(t.message)>-1)&&c.push(t.message)}));for(var g=null,v=i.hasGutter&&document.createDocumentFragment(),y=0;y<l.length;++y){var T=l[y],S=T.severity;S||(S="error"),g=p(g,S),o.formatAnnotation&&(T=o.formatAnnotation(T)),i.hasGutter&&v.appendChild(m(T)),T.to&&i.marked.push(t.markText(T.from,T.to,{className:"CodeMirror-lint-mark CodeMirror-lint-mark-"+S,__annotation:T}))}i.hasGutter&&t.setGutterMarker(s,e,f(t,v,g,a[s].length>1,i.options.tooltips)),h(i)&&t.addLineClass(s,"wrap",n+g)}}o.onUpdateLinting&&o.onUpdateLinting(r,a,t)}}function T(t){var e=t.state.lint;e&&(clearTimeout(e.timeout),e.timeout=setTimeout((function(){v(t)}),e.options.delay||500))}function S(t,e,n){for(var r=n.target||n.srcElement,i=document.createDocumentFragment(),o=0;o<e.length;o++){var s=e[o];i.appendChild(m(s))}a(t,n,i,r)}function x(t,e){var n=e.target||e.srcElement;if(/\bCodeMirror-lint-mark-/.test(n.className)){for(var r=n.getBoundingClientRect(),i=(r.left+r.right)/2,o=(r.top+r.bottom)/2,a=t.findMarksAt(t.coordsChar({left:i,top:o},"client")),s=[],l=0;l<a.length;++l){var u=a[l].__annotation;u&&s.push(u)}s.length&&S(t,s,e)}}t.defineOption("lint",!1,(function(n,r,i){if(i&&i!=t.Init&&(u(n),!1!==n.state.lint.options.lintOnChange&&n.off("change",T),t.off(n.getWrapperElement(),"mouseover",n.state.lint.onMouseOver),clearTimeout(n.state.lint.timeout),delete n.state.lint),r){for(var o=n.getOption("gutters"),a=!1,c=0;c<o.length;++c)o[c]==e&&(a=!0);var h=n.state.lint=new s(n,l(n,r),a);!1!==h.options.lintOnChange&&n.on("change",T),0!=h.options.tooltips&&"gutter"!=h.options.tooltips&&t.on(n.getWrapperElement(),"mouseover",h.onMouseOver),v(n)}})),t.defineExtension("performLint",(function(){v(this)}))}(n(631))},790:(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.unicode&&(n+="u"),t=t.source):t=String(t),new RegExp((!1===e?"":"^")+"(?:"+t+")",n)}function r(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}function i(t,i){(t.next||t.push)&&e(i,t.next||t.push),this.regex=n(t.regex),this.token=r(t.token),this.data=t}function o(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 a;return o=r.local.mode.token(n,r.localState),r.local.endScan&&(a=r.local.endScan.exec(n.current()))&&(n.pos=n.start+a.index),o}for(var l=t[r.state],u=0;u<l.length;u++){var c=l[u],h=(!c.data.sol||n.sol())&&n.match(c.regex);if(h){c.data.next?r.state=c.data.next:c.data.push?((r.stack||(r.stack=[])).push(r.state),r.state=c.data.push):c.data.pop&&r.stack&&r.stack.length&&(r.state=r.stack.pop()),c.data.mode&&s(e,r,c.data.mode,c.token),c.data.indent&&r.indent.push(n.indentation()+e.indentUnit),c.data.dedent&&r.indent.pop();var f=c.token;if(f&&f.apply&&(f=f(h)),h.length>2&&c.token&&"string"!=typeof c.token){for(var p=2;p<h.length;p++)h[p]&&(r.pending||(r.pending=[])).push({text:h[p],token:c.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 a(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)||!a(t[r],e[r]))return!1;n++}for(var r in e)e.hasOwnProperty(r)&&n--;return 0==n}function s(e,r,i,o){var s;if(i.persistent)for(var l=r.persistentStates;l&&!s;l=l.next)(i.spec?a(i.spec,l.spec):i.mode==l.mode)&&(s=l);var u=s?s.mode:i.mode||t.getMode(e,i.spec),c=s?s.state:t.startState(u);i.persistent&&!s&&(r.persistentStates={mode:u,spec:i.spec,state:c,next:r.persistentStates}),r.localState=c,r.local={mode:u,end:i.end&&n(i.end),endScan:i.end&&!1!==i.forceEnd&&n(i.end,!1),endToken:o&&o.join?o[o.length-1]:o}}function l(t,e){for(var n=0;n<e.length;n++)if(e[n]===t)return!0}function u(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&&l(r.state,n.dontIndentStates)>-1)return t.Pass;var a=r.indent.length-1,s=e[r.state];t:for(;;){for(var u=0;u<s.length;u++){var c=s[u];if(c.data.dedent&&!1!==c.data.dedentIfLineStart){var h=c.regex.exec(i);if(h&&h[0]){a--,(c.next||c.push)&&(s=e[c.next||c.push]),i=i.slice(h[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,r){e(r,"start");var a={},s=r.meta||{},l=!1;for(var c in r)if(c!=s&&r.hasOwnProperty(c))for(var h=a[c]=[],f=r[c],p=0;p<f.length;p++){var d=f[p];h.push(new i(d,r)),(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:o(a,n),innerMode:function(t){return t.local&&{mode:t.local.mode,state:t.localState}},indent:u(a,s)};if(s)for(var g in s)s.hasOwnProperty(g)&&(m[g]=s[g]);return m}}(n(631))},165:(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),l=r,u=0;l.innerHTML="",r=function(t,e){if("\n"==t)return l.appendChild(document.createTextNode(s?"\r":t)),void(u=0);for(var n="",r=0;;){var i=t.indexOf("\t",r);if(-1==i){n+=t.slice(r),u+=t.length-r;break}u+=i-r,n+=t.slice(r,i);var o=a-u%a;u+=o;for(var c=0;c<o;++c)n+=" ";r=i+1}if(e){var h=l.appendChild(document.createElement("span"));h.className="cm-"+e.replace(/ +/g," cm-"),h.appendChild(document.createTextNode(n))}else l.appendChild(document.createTextNode(n))}}for(var c=t.splitLines(e),h=i&&i.state||t.startState(o),f=0,p=c.length;f<p;++f){f&&r("\n");var d=new t.StringStream(c[f],null,{lookAhead:function(t){return c[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,o),d.start=d.pos}}}}(n(631))},631:function(t){t.exports=function(){"use strict";var t=navigator.userAgent,e=navigator.platform,n=/gecko\/\d/i.test(t),r=/MSIE \d/.test(t),i=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(t),o=/Edge\/(\d+)/.exec(t),a=r||i||o,s=a&&(r?document.documentMode||6:+(o||i)[1]),l=!o&&/WebKit\//.test(t),u=l&&/Qt\/\d+\.\d+/.test(t),c=!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=f&&(/Mobile\/\w+/.test(t)||navigator.maxTouchPoints>2),g=/Android/.test(t),v=m||g||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(t),y=m||/Mac/.test(e),T=/\bCrOS\b/.test(t),S=/win/i.test(e),x=h&&t.match(/Version\/(\d*\.\d*)/);x&&(x=Number(x[1])),x&&x>=15&&(h=!1,l=!0);var E=y&&(u||h&&(null==x||x<12.11)),C=n||a&&s>=9;function b(t){return new RegExp("(^|\\s)"+t+"(?:$|\\s)\\s*")}var k,O=function(t,e){var n=t.className,r=b(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 N(t){for(var e=t.childNodes.length;e>0;--e)t.removeChild(t.firstChild);return t}function w(t,e){return N(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 R(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 I(){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;b(e).test(n)||(t.className+=(n?" ":"")+e)}function _(t,e){for(var n=t.split(" "),r=0;r<n.length;r++)n[r]&&!b(n[r]).test(e)&&(e+=" "+n[r]);return e}k=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 U(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 W=function(){this.id=null,this.f=null,this.time=0,this.handler=U(this.onTimeout,this)};function B(t,e){for(var n=0;n<t.length;++n)if(t[n]==e)return n;return-1}W.prototype.onTimeout=function(t){t.id=0,t.time<=+new Date?t.f():setTimeout(t.handler,t.time-+new Date)},W.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 H=50,G={toString:function(){return"CodeMirror.Pass"}},z={scroll:!1},j={origin:"*mouse"},V={origin:"+move"};function K(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 $=[""];function Y(t){for(;$.length<=t;)$.push(X($)+" ");return $[t]}function X(t){return t[t.length-1]}function q(t,e){for(var n=[],r=0;r<t.length;r++)n[r]=e(t[r],r);return n}function Q(t,e,n){for(var r=0,i=n(e);r<t.length&&n(t[r])<=i;)r++;t.splice(r,0,e)}function J(){}function Z(t,e){var n;return Object.create?n=Object.create(t):(J.prototype=t,n=new J),e&&D(e,n),n}var tt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;function et(t){return/\w/.test(t)||t>""&&(t.toUpperCase()!=t.toLowerCase()||tt.test(t))}function nt(t,e){return e?!!(e.source.indexOf("\\w")>-1&&et(t))||e.test(t):et(t)}function rt(t){for(var e in t)if(t.hasOwnProperty(e)&&t[e])return!1;return!0}var it=/[\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 ot(t){return t.charCodeAt(0)>=768&&it.test(t)}function at(t,e,n){for(;(n<0?e>0:e<t.length)&&ot(t.charAt(e));)e+=n;return e}function st(t,e,n){for(var r=e>n?-1:1;;){if(e==n)return e;var i=(e+n)/2,o=r<0?Math.ceil(i):Math.floor(i);if(o==e)return t(o)?e:n;t(o)?n=o:e=o+r}}function lt(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")}var ut=null;function ct(t,e,n){var r;ut=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:ut=i),o.from==e&&(o.from!=o.to&&"before"!=n?r=i:ut=i)}return null!=r?r:ut}var ht=function(){var t="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",e="nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";function n(n){return n<=247?t.charAt(n):1424<=n&&n<=1524?"R":1536<=n&&n<=1785?e.charAt(n-1536):1774<=n&&n<=2220?"r":8192<=n&&n<=8203?"w":8204==n?"b":"L"}var r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,i=/[stwN]/,o=/[LRr]/,a=/[Lb1n]/,s=/[1n]/;function l(t,e,n){this.level=t,this.from=e,this.to=n}return function(t,e){var u="ltr"==e?"L":"R";if(0==t.length||"ltr"==e&&!r.test(t))return!1;for(var c=t.length,h=[],f=0;f<c;++f)h.push(n(t.charCodeAt(f)));for(var p=0,d=u;p<c;++p){var m=h[p];"m"==m?h[p]=d:d=m}for(var g=0,v=u;g<c;++g){var y=h[g];"1"==y&&"r"==v?h[g]="n":o.test(y)&&(v=y,"r"==y&&(h[g]="R"))}for(var T=1,S=h[0];T<c-1;++T){var x=h[T];"+"==x&&"1"==S&&"1"==h[T+1]?h[T]="1":","!=x||S!=h[T+1]||"1"!=S&&"n"!=S||(h[T]=S),S=x}for(var E=0;E<c;++E){var C=h[E];if(","==C)h[E]="N";else if("%"==C){var b=void 0;for(b=E+1;b<c&&"%"==h[b];++b);for(var k=E&&"!"==h[E-1]||b<c&&"1"==h[b]?"1":"N",O=E;O<b;++O)h[O]=k;E=b-1}}for(var N=0,w=u;N<c;++N){var L=h[N];"L"==w&&"1"==L?h[N]="L":o.test(L)&&(w=L)}for(var A=0;A<c;++A)if(i.test(h[A])){var R=void 0;for(R=A+1;R<c&&i.test(h[R]);++R);for(var I="L"==(A?h[A-1]:u),M=I==("L"==(R<c?h[R]:u))?I?"L":"R":u,_=A;_<R;++_)h[_]=M;A=R-1}for(var P,U=[],D=0;D<c;)if(a.test(h[D])){var F=D;for(++D;D<c&&a.test(h[D]);++D);U.push(new l(0,F,D))}else{var W=D,B=U.length,H="rtl"==e?1:0;for(++D;D<c&&"L"!=h[D];++D);for(var G=W;G<D;)if(s.test(h[G])){W<G&&(U.splice(B,0,new l(1,W,G)),B+=H);var z=G;for(++G;G<D&&s.test(h[G]);++G);U.splice(B,0,new l(2,z,G)),B+=H,W=G}else++G;W<D&&U.splice(B,0,new l(1,W,D))}return"ltr"==e&&(1==U[0].level&&(P=t.match(/^\s+/))&&(U[0].from=P[0].length,U.unshift(new l(0,0,P[0].length))),1==X(U).level&&(P=t.match(/\s+$/))&&(X(U).to-=P[0].length,U.push(new l(0,c-P[0].length,c)))),"rtl"==e?U.reverse():U}}();function ft(t,e){var n=t.order;return null==n&&(n=t.order=ht(t.text,e)),n}var pt=[],dt=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]||pt).concat(n)}};function mt(t,e){return t._handlers&&t._handlers[e]||pt}function gt(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=B(i,n);o>-1&&(r[e]=i.slice(0,o).concat(i.slice(o+1)))}}}function vt(t,e){var n=mt(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 yt(t,e,n){return"string"==typeof e&&(e={type:e,preventDefault:function(){this.defaultPrevented=!0}}),vt(t,n||e.type,t,e),bt(e)||e.codemirrorIgnore}function Tt(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==B(n,e[r])&&n.push(e[r])}function St(t,e){return mt(t,e).length>0}function xt(t){t.prototype.on=function(t,e){dt(this,t,e)},t.prototype.off=function(t,e){gt(this,t,e)}}function Et(t){t.preventDefault?t.preventDefault():t.returnValue=!1}function Ct(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0}function bt(t){return null!=t.defaultPrevented?t.defaultPrevented:0==t.returnValue}function kt(t){Et(t),Ct(t)}function Ot(t){return t.target||t.srcElement}function Nt(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 wt,Lt,At=function(){if(a&&s<9)return!1;var t=L("div");return"draggable"in t||"dragDrop"in t}();function Rt(t){if(null==wt){var e=L("span","");w(t,L("span",[e,document.createTextNode("x")])),0!=t.firstChild.offsetHeight&&(wt=e.offsetWidth<=1&&e.offsetHeight>2&&!(a&&s<8))}var n=wt?L("span",""):L("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function It(t){if(null!=Lt)return Lt;var e=w(t,document.createTextNode("AخA")),n=k(e,0,1).getBoundingClientRect(),r=k(e,1,2).getBoundingClientRect();return N(t),!(!n||n.left==n.right)&&(Lt=r.right-n.right<3)}var Mt,_t=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/)},Pt=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)},Ut="oncopy"in(Mt=L("div"))||(Mt.setAttribute("oncopy","return;"),"function"==typeof Mt.oncopy),Dt=null;function Ft(t){if(null!=Dt)return Dt;var e=w(t,L("span","x")),n=e.getBoundingClientRect(),r=k(e,0,1).getBoundingClientRect();return Dt=Math.abs(n.left-r.left)>1}var Wt={},Bt={};function Ht(t,e){arguments.length>2&&(e.dependencies=Array.prototype.slice.call(arguments,2)),Wt[t]=e}function Gt(t,e){Bt[t]=e}function zt(t){if("string"==typeof t&&Bt.hasOwnProperty(t))t=Bt[t];else if(t&&"string"==typeof t.name&&Bt.hasOwnProperty(t.name)){var e=Bt[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 zt("application/xml");if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+json$/.test(t))return zt("application/json")}return"string"==typeof t?{name:t}:t||{name:"null"}}function jt(t,e){e=zt(e);var n=Wt[e.name];if(!n)return jt(t,"text/plain");var r=n(t,e);if(Vt.hasOwnProperty(e.name)){var i=Vt[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 Vt={};function Kt(t,e){D(e,Vt.hasOwnProperty(t)?Vt[t]:Vt[t]={})}function $t(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 Yt(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 Xt(t,e,n){return!t.startState||t.startState(e,n)}var qt=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 Qt(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 Jt(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 Zt(t,e,n){var r=[];return t.iter(e,n,(function(t){r.push(t.text)})),r}function te(t,e){var n=e-t.height;if(n)for(var r=t;r;r=r.parent)r.height+=n}function ee(t){if(null==t.parent)return null;for(var e=t.parent,n=B(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 ne(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 re(t,e){return e>=t.first&&e<t.first+t.size}function ie(t,e){return String(t.lineNumberFormatter(e+t.firstLineNumber))}function oe(t,e,n){if(void 0===n&&(n=null),!(this instanceof oe))return new oe(t,e,n);this.line=t,this.ch=e,this.sticky=n}function ae(t,e){return t.line-e.line||t.ch-e.ch}function se(t,e){return t.sticky==e.sticky&&0==ae(t,e)}function le(t){return oe(t.line,t.ch)}function ue(t,e){return ae(t,e)<0?e:t}function ce(t,e){return ae(t,e)<0?t:e}function he(t,e){return Math.max(t.first,Math.min(e,t.first+t.size-1))}function fe(t,e){if(e.line<t.first)return oe(t.first,0);var n=t.first+t.size-1;return e.line>n?oe(n,Qt(t,n).text.length):pe(e,Qt(t,e.line).text.length)}function pe(t,e){var n=t.ch;return null==n||n>e?oe(t.line,e):n<0?oe(t.line,0):t}function de(t,e){for(var n=[],r=0;r<e.length;r++)n[r]=fe(t,e[r]);return n}qt.prototype.eol=function(){return this.pos>=this.string.length},qt.prototype.sol=function(){return this.pos==this.lineStart},qt.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},qt.prototype.next=function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},qt.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},qt.prototype.eatWhile=function(t){for(var e=this.pos;this.eat(t););return this.pos>e},qt.prototype.eatSpace=function(){for(var t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t},qt.prototype.skipToEnd=function(){this.pos=this.string.length},qt.prototype.skipTo=function(t){var e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0},qt.prototype.backUp=function(t){this.pos-=t},qt.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)},qt.prototype.indentation=function(){return F(this.string,null,this.tabSize)-(this.lineStart?F(this.string,this.lineStart,this.tabSize):0)},qt.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},qt.prototype.current=function(){return this.string.slice(this.start,this.pos)},qt.prototype.hideFirstChars=function(t,e){this.lineStart+=t;try{return e()}finally{this.lineStart-=t}},qt.prototype.lookAhead=function(t){var e=this.lineOracle;return e&&e.lookAhead(t)},qt.prototype.baseToken=function(){var t=this.lineOracle;return t&&t.baseToken(this.pos)};var me=function(t,e){this.state=t,this.lookAhead=e},ge=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 ve(t,e,n,r){var i=[t.state.modeGen],o={};Oe(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],l=1,u=0;n.state=!0,Oe(t,e.text,s.mode,n,(function(t,e){for(var n=l;u<t;){var r=i[l];r>t&&i.splice(l,1,t,i[l+1],r),l+=2,u=Math.min(t,r)}if(e)if(s.opaque)i.splice(n,l-n,t,"overlay "+e),l=n+2;else for(;n<l;n+=2){var o=i[n+1];i[n+1]=(o?o+" ":"")+"overlay "+e}}),o),n.state=a,n.baseTokens=null,n.baseTokenPos=1},l=0;l<t.state.overlays.length;++l)s(l);return{styles:i,classes:o.bgClass||o.textClass?o:null}}function ye(t,e,n){if(!e.styles||e.styles[0]!=t.state.modeGen){var r=Te(t,ee(e)),i=e.text.length>t.options.maxHighlightLength&&$t(t.doc.mode,r.state),o=ve(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 Te(t,e,n){var r=t.doc,i=t.display;if(!r.mode.startState)return new ge(r,!0,e);var o=Ne(t,e,n),a=o>r.first&&Qt(r,o-1).stateAfter,s=a?ge.fromSaved(r,a,o):new ge(r,Xt(r.mode),o);return r.iter(o,e,(function(n){Se(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 Se(t,e,n,r){var i=t.doc.mode,o=new qt(e,t.options.tabSize,n);for(o.start=o.pos=r||0,""==e&&xe(i,n.state);!o.eol();)Ee(i,o,n.state),o.start=o.pos}function xe(t,e){if(t.blankLine)return t.blankLine(e);if(t.innerMode){var n=Yt(t,e);return n.mode.blankLine?n.mode.blankLine(n.state):void 0}}function Ee(t,e,n,r){for(var i=0;i<10;i++){r&&(r[0]=Yt(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.")}ge.prototype.lookAhead=function(t){var e=this.doc.getLine(this.line+t);return null!=e&&t>this.maxLookAhead&&(this.maxLookAhead=t),e},ge.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}},ge.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},ge.fromSaved=function(t,e,n){return e instanceof me?new ge(t,$t(t.mode,e.state),n,e.lookAhead):new ge(t,$t(t.mode,e),n)},ge.prototype.save=function(t){var e=!1!==t?$t(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new me(e,this.maxLookAhead):e};var Ce=function(t,e,n){this.start=t.start,this.end=t.pos,this.string=t.current(),this.type=e||null,this.state=n};function be(t,e,n,r){var i,o,a=t.doc,s=a.mode,l=Qt(a,(e=fe(a,e)).line),u=Te(t,e.line,n),c=new qt(l.text,t.options.tabSize,u);for(r&&(o=[]);(r||c.pos<e.ch)&&!c.eol();)c.start=c.pos,i=Ee(s,c,u.state),r&&o.push(new Ce(c,i,$t(a.mode,u.state)));return r?o:new Ce(c,i,u.state)}function ke(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 Oe(t,e,n,r,i,o,a){var s=n.flattenSpans;null==s&&(s=t.options.flattenSpans);var l,u=0,c=null,h=new qt(e,t.options.tabSize,r),f=t.options.addModeClass&&[null];for(""==e&&ke(xe(n,r.state),o);!h.eol();){if(h.pos>t.options.maxHighlightLength?(s=!1,a&&Se(t,e,r,h.pos),h.pos=e.length,l=null):l=ke(Ee(n,h,r.state,f),o),f){var p=f[0].name;p&&(l="m-"+(l?p+" "+l:p))}if(!s||c!=l){for(;u<h.start;)i(u=Math.min(h.start,u+5e3),c);c=l}h.start=h.pos}for(;u<h.pos;){var d=Math.min(h.pos,u+5e3);i(d,c),u=d}}function Ne(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 l=Qt(o,s-1),u=l.stateAfter;if(u&&(!n||s+(u instanceof me?u.lookAhead:0)<=o.modeFrontier))return s;var c=F(l.text,null,t.options.tabSize);(null==i||r>c)&&(i=s-1,r=c)}return i}function we(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=Qt(t,r).stateAfter;if(i&&(!(i instanceof me)||r+i.lookAhead<e)){n=r+1;break}}t.highlightFrontier=Math.min(t.highlightFrontier,n)}}var Le=!1,Ae=!1;function Re(){Le=!0}function Ie(){Ae=!0}function Me(t,e,n){this.marker=t,this.from=e,this.to=n}function _e(t,e){if(t)for(var n=0;n<t.length;++n){var r=t[n];if(r.marker==e)return r}}function Pe(t,e){for(var n,r=0;r<t.length;++r)t[r]!=e&&(n||(n=[])).push(t[r]);return n}function Ue(t,e,n){var r=n&&window.WeakSet&&(n.markedSpans||(n.markedSpans=new WeakSet));r&&r.has(t.markedSpans)?t.markedSpans.push(e):(t.markedSpans=t.markedSpans?t.markedSpans.concat([e]):[e],r&&r.add(t.markedSpans)),e.marker.attachLine(t)}function De(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 Me(a,o.from,s?null:o.to))}}return r}function Fe(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 Me(a,s?null:o.from-e,null==o.to?null:o.to-e))}}return r}function We(t,e){if(e.full)return null;var n=re(t,e.from.line)&&Qt(t,e.from.line).markedSpans,r=re(t,e.to.line)&&Qt(t,e.to.line).markedSpans;if(!n&&!r)return null;var i=e.from.ch,o=e.to.ch,a=0==ae(e.from,e.to),s=De(n,i,a),l=Fe(r,o,a),u=1==e.text.length,c=X(e.text).length+(u?i:0);if(s)for(var h=0;h<s.length;++h){var f=s[h];if(null==f.to){var p=_e(l,f.marker);p?u&&(f.to=null==p.to?null:p.to+c):f.to=i}}if(l)for(var d=0;d<l.length;++d){var m=l[d];null!=m.to&&(m.to+=c),null==m.from?_e(s,m.marker)||(m.from=c,u&&(s||(s=[])).push(m)):(m.from+=c,u&&(s||(s=[])).push(m))}s&&(s=Be(s)),l&&l!=s&&(l=Be(l));var g=[s];if(!u){var v,y=e.text.length-2;if(y>0&&s)for(var T=0;T<s.length;++T)null==s[T].to&&(v||(v=[])).push(new Me(s[T].marker,null,null));for(var S=0;S<y;++S)g.push(v);g.push(l)}return g}function Be(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 He(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!=B(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),l=0;l<i.length;++l){var u=i[l];if(!(ae(u.to,s.from)<0||ae(u.from,s.to)>0)){var c=[l,1],h=ae(u.from,s.from),f=ae(u.to,s.to);(h<0||!a.inclusiveLeft&&!h)&&c.push({from:u.from,to:s.from}),(f>0||!a.inclusiveRight&&!f)&&c.push({from:s.to,to:u.to}),i.splice.apply(i,c),l+=c.length-3}}return i}function Ge(t){var e=t.markedSpans;if(e){for(var n=0;n<e.length;++n)e[n].marker.detachLine(t);t.markedSpans=null}}function ze(t,e){if(e){for(var n=0;n<e.length;++n)e[n].marker.attachLine(t);t.markedSpans=e}}function je(t){return t.inclusiveLeft?-1:0}function Ve(t){return t.inclusiveRight?1:0}function Ke(t,e){var n=t.lines.length-e.lines.length;if(0!=n)return n;var r=t.find(),i=e.find(),o=ae(r.from,i.from)||je(t)-je(e);if(o)return-o;var a=ae(r.to,i.to)||Ve(t)-Ve(e);return a||e.id-t.id}function $e(t,e){var n,r=Ae&&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||Ke(n,i.marker)<0)&&(n=i.marker);return n}function Ye(t){return $e(t,!0)}function Xe(t){return $e(t,!1)}function qe(t,e){var n,r=Ae&&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||Ke(n,o.marker)<0)&&(n=o.marker)}return n}function Qe(t,e,n,r,i){var o=Qt(t,e),a=Ae&&o.markedSpans;if(a)for(var s=0;s<a.length;++s){var l=a[s];if(l.marker.collapsed){var u=l.marker.find(0),c=ae(u.from,n)||je(l.marker)-je(i),h=ae(u.to,r)||Ve(l.marker)-Ve(i);if(!(c>=0&&h<=0||c<=0&&h>=0)&&(c<=0&&(l.marker.inclusiveRight&&i.inclusiveLeft?ae(u.to,n)>=0:ae(u.to,n)>0)||c>=0&&(l.marker.inclusiveRight&&i.inclusiveLeft?ae(u.from,r)<=0:ae(u.from,r)<0)))return!0}}}function Je(t){for(var e;e=Ye(t);)t=e.find(-1,!0).line;return t}function Ze(t){for(var e;e=Xe(t);)t=e.find(1,!0).line;return t}function tn(t){for(var e,n;e=Xe(t);)t=e.find(1,!0).line,(n||(n=[])).push(t);return n}function en(t,e){var n=Qt(t,e),r=Je(n);return n==r?e:ee(r)}function nn(t,e){if(e>t.lastLine())return e;var n,r=Qt(t,e);if(!rn(t,r))return e;for(;n=Xe(r);)r=n.find(1,!0).line;return ee(r)+1}function rn(t,e){var n=Ae&&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&&on(t,e,r))return!0}}function on(t,e,n){if(null==n.to){var r=n.marker.find(1,!0);return on(t,r.line,_e(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)&&on(t,e,i))return!0}function an(t){for(var e=0,n=(t=Je(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 sn(t){if(0==t.height)return 0;for(var e,n=t.text.length,r=t;e=Ye(r);){var i=e.find(0,!0);r=i.from.line,n+=i.from.ch-i.to.ch}for(r=t;e=Xe(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 ln(t){var e=t.display,n=t.doc;e.maxLine=Qt(n,n.first),e.maxLineLength=sn(e.maxLine),e.maxLineChanged=!0,n.iter((function(t){var n=sn(t);n>e.maxLineLength&&(e.maxLineLength=n,e.maxLine=t)}))}var un=function(t,e,n){this.text=t,ze(this,e),this.height=n?n(this):1};function cn(t,e,n,r){t.text=e,t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null),null!=t.order&&(t.order=null),Ge(t),ze(t,n);var i=r?r(t):1;i!=t.height&&te(t,i)}function hn(t){t.parent=null,Ge(t)}un.prototype.lineNo=function(){return ee(this)},xt(un);var fn={},pn={};function dn(t,e){if(!t||/^\s*$/.test(t))return null;var n=e.addModeClass?pn:fn;return n[t]||(n[t]=t.replace(/\S+/g,"cm-$&"))}function mn(t,e){var n=A("span",null,null,l?"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=vn,It(t.display.measure)&&(a=ft(o,t.doc.direction))&&(r.addToken=Tn(r.addToken,a)),r.map=[],xn(o,r,ye(t,o,e!=t.display.externalMeasured&&ee(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(Rt(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(l){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 vt(t,"renderLine",t,e.line,r.pre),r.pre.className&&(r.textClass=_(r.pre.className,r.textClass||"")),r}function gn(t){var e=L("span","•","cm-invalidchar");return e.title="\\u"+t.charCodeAt(0).toString(16),e.setAttribute("aria-label",e.title),e}function vn(t,e,n,r,i,o,l){if(e){var u,c=t.splitSpaces?yn(e,t.trailingSpace):e,h=t.cm.state.specialChars,f=!1;if(h.test(e)){u=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(c.slice(p,p+m));a&&s<9?u.appendChild(L("span",[g])):u.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,T=y-t.col%y;(v=u.appendChild(L("span",Y(T),"cm-tab"))).setAttribute("role","presentation"),v.setAttribute("cm-text","\t"),t.col+=T}else"\r"==d[0]||"\n"==d[0]?((v=u.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?u.appendChild(L("span",[v])):u.appendChild(v),t.col+=1);t.map.push(t.pos,t.pos+1,v),t.pos++}}else t.col+=e.length,u=document.createTextNode(c),t.map.push(t.pos,t.pos+e.length,u),a&&s<9&&(f=!0),t.pos+=e.length;if(t.trailingSpace=32==c.charCodeAt(e.length-1),n||r||i||f||o||l){var S=n||"";r&&(S+=r),i&&(S+=i);var x=L("span",[u],S,o);if(l)for(var E in l)l.hasOwnProperty(E)&&"style"!=E&&"class"!=E&&x.setAttribute(E,l[E]);return t.content.appendChild(x)}t.content.appendChild(u)}}function yn(t,e){if(t.length>1&&!/ /.test(t))return t;for(var n=e,r="",i=0;i<t.length;i++){var o=t.charAt(i);" "!=o||!n||i!=t.length-1&&32!=t.charCodeAt(i+1)||(o=" "),r+=o,n=" "==o}return r}function Tn(t,e){return function(n,r,i,o,a,s,l){i=i?i+" cm-force-border":"cm-force-border";for(var u=n.pos,c=u+r.length;;){for(var h=void 0,f=0;f<e.length&&!((h=e[f]).to>u&&h.from<=u);f++);if(h.to>=c)return t(n,r,i,o,a,s,l);t(n,r.slice(0,h.to-u),i,o,null,s,l),o=null,r=r.slice(h.to-u),u=h.to}}}function Sn(t,e,n,r){var i=!r&&n.widgetNode;i&&t.map.push(t.pos,t.pos+e,i),!r&&t.cm.display.input.needsContentAttribute&&(i||(i=t.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(t.cm.display.input.setUneditable(i),t.content.appendChild(i)),t.pos+=e,t.trailingSpace=!1}function xn(t,e,n){var r=t.markedSpans,i=t.text,o=0;if(r)for(var a,s,l,u,c,h,f,p=i.length,d=0,m=1,g="",v=0;;){if(v==d){l=u=c=s="",f=null,h=null,v=1/0;for(var y=[],T=void 0,S=0;S<r.length;++S){var x=r[S],E=x.marker;if("bookmark"==E.type&&x.from==d&&E.widgetNode)y.push(E);else if(x.from<=d&&(null==x.to||x.to>d||E.collapsed&&x.to==d&&x.from==d)){if(null!=x.to&&x.to!=d&&v>x.to&&(v=x.to,u=""),E.className&&(l+=" "+E.className),E.css&&(s=(s?s+";":"")+E.css),E.startStyle&&x.from==d&&(c+=" "+E.startStyle),E.endStyle&&x.to==v&&(T||(T=[])).push(E.endStyle,x.to),E.title&&((f||(f={})).title=E.title),E.attributes)for(var C in E.attributes)(f||(f={}))[C]=E.attributes[C];E.collapsed&&(!h||Ke(h.marker,E)<0)&&(h=x)}else x.from>d&&v>x.from&&(v=x.from)}if(T)for(var b=0;b<T.length;b+=2)T[b+1]==v&&(u+=" "+T[b]);if(!h||h.from==d)for(var k=0;k<y.length;++k)Sn(e,0,y[k]);if(h&&(h.from||0)==d){if(Sn(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 O=Math.min(p,v);;){if(g){var N=d+g.length;if(!h){var w=N>O?g.slice(0,O-d):g;e.addToken(e,w,a?a+l:l,c,d+w.length==v?u:"",s,f)}if(N>=O){g=g.slice(O-d),d=O;break}d=N,c=""}g=i.slice(o,o=n[m++]),a=dn(n[m++],e.cm.options)}}else for(var L=1;L<n.length;L+=2)e.addToken(e,i.slice(o,o=n[L]),dn(n[L+1],e.cm.options))}function En(t,e,n){this.line=e,this.rest=tn(e),this.size=this.rest?ee(X(this.rest))-n+1:1,this.node=this.text=null,this.hidden=rn(t,e)}function Cn(t,e,n){for(var r,i=[],o=e;o<n;o=r){var a=new En(t.doc,Qt(t.doc,o),o);r=o+a.size,i.push(a)}return i}var bn=null;function kn(t){bn?bn.ops.push(t):t.ownsGroup=bn={ops:[t],delayedCallbacks:[]}}function On(t){var e=t.delayedCallbacks,n=0;do{for(;n<e.length;n++)e[n].call(null);for(var r=0;r<t.ops.length;r++){var i=t.ops[r];if(i.cursorActivityHandlers)for(;i.cursorActivityCalled<i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null,i.cm)}}while(n<e.length)}function Nn(t,e){var n=t.ownsGroup;if(n)try{On(n)}finally{bn=null,e(n)}}var wn=null;function Ln(t,e){var n=mt(t,e);if(n.length){var r,i=Array.prototype.slice.call(arguments,2);bn?r=bn.delayedCallbacks:wn?r=wn:(r=wn=[],setTimeout(An,0));for(var o=function(t){r.push((function(){return n[t].apply(null,i)}))},a=0;a<n.length;++a)o(a)}}function An(){var t=wn;wn=null;for(var e=0;e<t.length;++e)t[e]()}function Rn(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?Dn(t,e,n,r):"class"==o?Un(t,e):"widget"==o&&Fn(t,e,r)}e.changes=null}function In(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 Mn(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=In(e);e.background=r.insertBefore(L("div",null,n),r.firstChild),t.display.input.setUneditable(e.background)}}function _n(t,e){var n=t.display.externalMeasured;return n&&n.line==e.line?(t.display.externalMeasured=null,e.measure=n.measure,n.built):mn(t,e)}function Pn(t,e){var n=e.text.className,r=_n(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,Un(t,e)):n&&(e.text.className=n)}function Un(t,e){Mn(t,e),e.line.wrapClass?In(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 Dn(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=In(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=In(e),s=e.gutter=L("div",null,"CodeMirror-gutter-wrapper","left: "+(t.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(s.setAttribute("aria-hidden","true"),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",ie(t.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+t.display.lineNumInnerWidth+"px"))),o)for(var l=0;l<t.display.gutterSpecs.length;++l){var u=t.display.gutterSpecs[l].className,c=o.hasOwnProperty(u)&&o[u];c&&s.appendChild(L("div",[c],"CodeMirror-gutter-elt","left: "+r.gutterLeft[u]+"px; width: "+r.gutterWidth[u]+"px"))}}}function Fn(t,e,n){e.alignable&&(e.alignable=null);for(var r=b("CodeMirror-linewidget"),i=e.node.firstChild,o=void 0;i;i=o)o=i.nextSibling,r.test(i.className)&&e.node.removeChild(i);Bn(t,e,n)}function Wn(t,e,n,r){var i=_n(t,e);return e.text=e.node=i.pre,i.bgClass&&(e.bgClass=i.bgClass),i.textClass&&(e.textClass=i.textClass),Un(t,e),Dn(t,e,n,r),Bn(t,e,r),e.node}function Bn(t,e,n){if(Hn(t,e.line,e,n,!0),e.rest)for(var r=0;r<e.rest.length;r++)Hn(t,e.rest[r],e,n,!1)}function Hn(t,e,n,r,i){if(e.widgets)for(var o=In(n),a=0,s=e.widgets;a<s.length;++a){var l=s[a],u=L("div",[l.node],"CodeMirror-linewidget"+(l.className?" "+l.className:""));l.handleMouseEvents||u.setAttribute("cm-ignore-events","true"),Gn(l,u,n,r),t.display.input.setUneditable(u),i&&l.above?o.insertBefore(u,n.gutter||n.text):o.appendChild(u),Ln(l,"redraw")}}function Gn(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 zn(t){if(null!=t.height)return t.height;var e=t.doc.cm;if(!e)return 0;if(!R(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;"),w(e.display.measure,L("div",[t.node],null,n))}return t.height=t.node.parentNode.offsetHeight}function jn(t,e){for(var n=Ot(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 Vn(t){return t.lineSpace.offsetTop}function Kn(t){return t.mover.offsetHeight-t.lineSpace.offsetHeight}function $n(t){if(t.cachedPaddingH)return t.cachedPaddingH;var e=w(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 Yn(t){return H-t.display.nativeBarWidth}function Xn(t){return t.display.scroller.clientWidth-Yn(t)-t.display.barWidth}function qn(t){return t.display.scroller.clientHeight-Yn(t)-t.display.barHeight}function Qn(t,e,n){var r=t.options.lineWrapping,i=r&&Xn(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 l=a[s],u=a[s+1];Math.abs(l.bottom-u.bottom)>2&&o.push((l.bottom+u.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Jn(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(ee(t.rest[i])>n)return{map:t.measure.maps[i],cache:t.measure.caches[i],before:!0}}function Zn(t,e){var n=ee(e=Je(e)),r=t.display.externalMeasured=new En(t.doc,e,n);r.lineN=n;var i=r.built=mn(t,r);return r.text=i.pre,w(t.display.lineMeasure,i.pre),r}function tr(t,e,n,r){return rr(t,nr(t,e),n,r)}function er(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 nr(t,e){var n=ee(e),r=er(t,n);r&&!r.text?r=null:r&&r.changes&&(Rn(t,r,n,Rr(t)),t.curOp.forceUpdate=!0),r||(r=Zn(t,e));var i=Jn(r,e,n);return{line:e,view:r,rect:null,map:i.map,cache:i.cache,before:i.before,hasHeights:!1}}function rr(t,e,n,r,i){e.before&&(n=-1);var o,a=n+(r||"");return e.cache.hasOwnProperty(a)?o=e.cache[a]:(e.rect||(e.rect=e.view.text.getBoundingClientRect()),e.hasHeights||(Qn(t,e.view,e.rect),e.hasHeights=!0),(o=lr(t,e,n,r)).bogus||(e.cache[a]=o)),{left:o.left,right:o.right,top:i?o.rtop:o.top,bottom:i?o.rbottom:o.bottom}}var ir,or={left:0,right:0,top:0,bottom:0};function ar(t,e,n){for(var r,i,o,a,s,l,u=0;u<t.length;u+=3)if(s=t[u],l=t[u+1],e<s?(i=0,o=1,a="left"):e<l?o=1+(i=e-s):(u==t.length-3||e==l&&t[u+3]>e)&&(i=(o=l-s)-1,e>=l&&(a="right")),null!=i){if(r=t[u+2],s==l&&n==(r.insertLeft?"left":"right")&&(a=n),"left"==n&&0==i)for(;u&&t[u-2]==t[u-3]&&t[u-1].insertLeft;)r=t[2+(u-=3)],a="left";if("right"==n&&i==l-s)for(;u<t.length-3&&t[u+3]==t[u+4]&&!t[u+5].insertLeft;)r=t[(u+=3)+2],a="right";break}return{node:r,start:i,end:o,collapse:a,coverStart:s,coverEnd:l}}function sr(t,e){var n=or;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 lr(t,e,n,r){var i,o=ar(e.map,n,r),l=o.node,u=o.start,c=o.end,h=o.collapse;if(3==l.nodeType){for(var f=0;f<4;f++){for(;u&&ot(e.line.text.charAt(o.coverStart+u));)--u;for(;o.coverStart+c<o.coverEnd&&ot(e.line.text.charAt(o.coverStart+c));)++c;if((i=a&&s<9&&0==u&&c==o.coverEnd-o.coverStart?l.parentNode.getBoundingClientRect():sr(k(l,u,c).getClientRects(),r)).left||i.right||0==u)break;c=u,u-=1,h="right"}a&&s<11&&(i=ur(t.display.measure,i))}else{var p;u>0&&(h=r="right"),i=t.options.lineWrapping&&(p=l.getClientRects()).length>1?p["right"==r?p.length-1:0]:l.getBoundingClientRect()}if(a&&s<9&&!u&&(!i||!i.left&&!i.right)){var d=l.parentNode.getClientRects()[0];i=d?{left:d.left,right:d.left+Ar(t.display),top:d.top,bottom:d.bottom}:or}for(var m=i.top-e.rect.top,g=i.bottom-e.rect.top,v=(m+g)/2,y=e.view.measure.heights,T=0;T<y.length-1&&!(v<y[T]);T++);var S=T?y[T-1]:0,x=y[T],E={left:("right"==h?i.right:i.left)-e.rect.left,right:("left"==h?i.left:i.right)-e.rect.left,top:S,bottom:x};return i.left||i.right||(E.bogus=!0),t.options.singleCursorHeightPerLine||(E.rtop=m,E.rbottom=g),E}function ur(t,e){if(!window.screen||null==screen.logicalXDPI||screen.logicalXDPI==screen.deviceXDPI||!Ft(t))return e;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:e.left*n,right:e.right*n,top:e.top*r,bottom:e.bottom*r}}function cr(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 hr(t){t.display.externalMeasure=null,N(t.display.lineMeasure);for(var e=0;e<t.display.view.length;e++)cr(t.display.view[e])}function fr(t){hr(t),t.display.cachedCharWidth=t.display.cachedTextHeight=t.display.cachedPaddingH=null,t.options.lineWrapping||(t.display.maxLineChanged=!0),t.display.lineNumChars=null}function pr(){return c&&g?-(document.body.getBoundingClientRect().left-parseInt(getComputedStyle(document.body).marginLeft)):window.pageXOffset||(document.documentElement||document.body).scrollLeft}function dr(){return c&&g?-(document.body.getBoundingClientRect().top-parseInt(getComputedStyle(document.body).marginTop)):window.pageYOffset||(document.documentElement||document.body).scrollTop}function mr(t){var e=0;if(t.widgets)for(var n=0;n<t.widgets.length;++n)t.widgets[n].above&&(e+=zn(t.widgets[n]));return e}function gr(t,e,n,r,i){if(!i){var o=mr(e);n.top+=o,n.bottom+=o}if("line"==r)return n;r||(r="local");var a=an(e);if("local"==r?a+=Vn(t.display):a-=t.display.viewOffset,"page"==r||"window"==r){var s=t.display.lineSpace.getBoundingClientRect();a+=s.top+("window"==r?0:dr());var l=s.left+("window"==r?0:pr());n.left+=l,n.right+=l}return n.top+=a,n.bottom+=a,n}function vr(t,e,n){if("div"==n)return e;var r=e.left,i=e.top;if("page"==n)r-=pr(),i-=dr();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 yr(t,e,n,r,i){return r||(r=Qt(t.doc,e.line)),gr(t,r,tr(t,r,e.ch,i),n)}function Tr(t,e,n,r,i,o){function a(e,a){var s=rr(t,i,e,a?"right":"left",o);return a?s.left=s.right:s.right=s.left,gr(t,r,s,n)}r=r||Qt(t.doc,e.line),i||(i=nr(t,r));var s=ft(r,t.doc.direction),l=e.ch,u=e.sticky;if(l>=r.text.length?(l=r.text.length,u="before"):l<=0&&(l=0,u="after"),!s)return a("before"==u?l-1:l,"before"==u);function c(t,e,n){return a(n?t-1:t,1==s[e].level!=n)}var h=ct(s,l,u),f=ut,p=c(l,h,"before"==u);return null!=f&&(p.other=c(l,f,"before"!=u)),p}function Sr(t,e){var n=0;e=fe(t.doc,e),t.options.lineWrapping||(n=Ar(t.display)*e.ch);var r=Qt(t.doc,e.line),i=an(r)+Vn(t.display);return{left:n,right:n,top:i,bottom:i+r.height}}function xr(t,e,n,r,i){var o=oe(t,e,n);return o.xRel=i,r&&(o.outside=r),o}function Er(t,e,n){var r=t.doc;if((n+=t.display.viewOffset)<0)return xr(r.first,0,null,-1,-1);var i=ne(r,n),o=r.first+r.size-1;if(i>o)return xr(r.first+r.size-1,Qt(r,o).text.length,null,1,1);e<0&&(e=0);for(var a=Qt(r,i);;){var s=Or(t,a,i,e,n),l=qe(a,s.ch+(s.xRel>0||s.outside>0?1:0));if(!l)return s;var u=l.find(1);if(u.line==i)return u;a=Qt(r,i=u.line)}}function Cr(t,e,n,r){r-=mr(e);var i=e.text.length,o=st((function(e){return rr(t,n,e-1).bottom<=r}),i,0);return{begin:o,end:i=st((function(e){return rr(t,n,e).top>r}),o,i)}}function br(t,e,n,r){return n||(n=nr(t,e)),Cr(t,e,n,gr(t,e,rr(t,n,r),"line").top)}function kr(t,e,n,r){return!(t.bottom<=n)&&(t.top>n||(r?t.left:t.right)>e)}function Or(t,e,n,r,i){i-=an(e);var o=nr(t,e),a=mr(e),s=0,l=e.text.length,u=!0,c=ft(e,t.doc.direction);if(c){var h=(t.options.lineWrapping?wr:Nr)(t,e,n,o,c,r,i);s=(u=1!=h.level)?h.from:h.to-1,l=u?h.to:h.from-1}var f,p,d=null,m=null,g=st((function(e){var n=rr(t,o,e);return n.top+=a,n.bottom+=a,!!kr(n,r,i,!1)&&(n.top<=i&&n.left<=r&&(d=e,m=n),!0)}),s,l),v=!1;if(m){var y=r-m.left<m.right-r,T=y==u;g=d+(T?0:1),p=T?"after":"before",f=y?m.left:m.right}else{u||g!=l&&g!=s||g++,p=0==g?"after":g==e.text.length?"before":rr(t,o,g-(u?1:0)).bottom+a<=i==u?"after":"before";var S=Tr(t,oe(n,g,p),"line",e,o);f=S.left,v=i<S.top?-1:i>=S.bottom?1:0}return xr(n,g=at(e.text,g,1),p,v,r-f)}function Nr(t,e,n,r,i,o,a){var s=st((function(s){var l=i[s],u=1!=l.level;return kr(Tr(t,oe(n,u?l.to:l.from,u?"before":"after"),"line",e,r),o,a,!0)}),0,i.length-1),l=i[s];if(s>0){var u=1!=l.level,c=Tr(t,oe(n,u?l.from:l.to,u?"after":"before"),"line",e,r);kr(c,o,a,!0)&&c.top>a&&(l=i[s-1])}return l}function wr(t,e,n,r,i,o,a){var s=Cr(t,e,r,a),l=s.begin,u=s.end;/\s/.test(e.text.charAt(u-1))&&u--;for(var c=null,h=null,f=0;f<i.length;f++){var p=i[f];if(!(p.from>=u||p.to<=l)){var d=rr(t,r,1!=p.level?Math.min(u,p.to)-1:Math.max(l,p.from)).right,m=d<o?o-d+1e9:d-o;(!c||h>m)&&(c=p,h=m)}}return c||(c=i[i.length-1]),c.from<l&&(c={from:l,to:c.to,level:c.level}),c.to>u&&(c={from:c.from,to:u,level:c.level}),c}function Lr(t){if(null!=t.cachedTextHeight)return t.cachedTextHeight;if(null==ir){ir=L("pre",null,"CodeMirror-line-like");for(var e=0;e<49;++e)ir.appendChild(document.createTextNode("x")),ir.appendChild(L("br"));ir.appendChild(document.createTextNode("x"))}w(t.measure,ir);var n=ir.offsetHeight/50;return n>3&&(t.cachedTextHeight=n),N(t.measure),n||1}function Ar(t){if(null!=t.cachedCharWidth)return t.cachedCharWidth;var e=L("span","xxxxxxxxxx"),n=L("pre",[e],"CodeMirror-line-like");w(t.measure,n);var r=e.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(t.cachedCharWidth=i),i||10}function Rr(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:Ir(e),gutterTotalWidth:e.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:e.wrapper.clientWidth}}function Ir(t){return t.scroller.getBoundingClientRect().left-t.sizer.getBoundingClientRect().left}function Mr(t){var e=Lr(t.display),n=t.options.lineWrapping,r=n&&Math.max(5,t.display.scroller.clientWidth/Ar(t.display)-3);return function(i){if(rn(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 _r(t){var e=t.doc,n=Mr(t);e.iter((function(t){var e=n(t);e!=t.height&&te(t,e)}))}function Pr(t,e,n,r){var i=t.display;if(!n&&"true"==Ot(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 l,u=Er(t,o,a);if(r&&u.xRel>0&&(l=Qt(t.doc,u.line).text).length==u.ch){var c=F(l,l.length,t.options.tabSize)-l.length;u=oe(u.line,Math.max(0,Math.round((o-$n(t.display).left)/Ar(t.display))-c))}return u}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 Dr(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)Ae&&en(t.doc,e)<i.viewTo&&Wr(t);else if(n<=i.viewFrom)Ae&&nn(t.doc,n+r)>i.viewFrom?Wr(t):(i.viewFrom+=r,i.viewTo+=r);else if(e<=i.viewFrom&&n>=i.viewTo)Wr(t);else if(e<=i.viewFrom){var o=Br(t,n,n+r,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=r):Wr(t)}else if(n>=i.viewTo){var a=Br(t,e,e,-1);a?(i.view=i.view.slice(0,a.index),i.viewTo=a.lineN):Wr(t)}else{var s=Br(t,e,e,-1),l=Br(t,n,n+r,1);s&&l?(i.view=i.view.slice(0,s.index).concat(Cn(t,s.lineN,l.lineN)).concat(i.view.slice(l.index)),i.viewTo+=r):Wr(t)}var u=i.externalMeasured;u&&(n<u.lineN?u.lineN+=r:e<u.lineN+u.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==B(a,n)&&a.push(n)}}}function Wr(t){t.display.viewFrom=t.display.viewTo=t.doc.first,t.display.view=[],t.display.viewOffset=0}function Br(t,e,n,r){var i,o=Ur(t,e),a=t.display.view;if(!Ae||n==t.doc.first+t.doc.size)return{index:o,lineN:n};for(var s=t.display.viewFrom,l=0;l<o;l++)s+=a[l].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(;en(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 Hr(t,e,n){var r=t.display;0==r.view.length||e>=r.viewTo||n<=r.viewFrom?(r.view=Cn(t,e,n),r.viewFrom=e):(r.viewFrom>e?r.view=Cn(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(Cn(t,r.viewTo,n)):r.viewTo>n&&(r.view=r.view.slice(0,Ur(t,n)))),r.viewTo=n}function Gr(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 zr(t){t.display.input.showSelection(t.display.input.prepareSelection())}function jr(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 l=s.empty();(l||t.options.showCursorWhenSelecting)&&Vr(t,s.head,i),l||$r(t,s,o)}}return r}function Vr(t,e,n){var r=Tr(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 Kr(t,e){return t.top-e.top||t.left-e.left}function $r(t,e,n){var r=t.display,i=t.doc,o=document.createDocumentFragment(),a=$n(t.display),s=a.left,l=Math.max(r.sizerWidth,Xn(t)-r.sizer.offsetLeft)-a.right,u="ltr"==i.direction;function c(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?l-t:n)+"px;\n height: "+(r-e)+"px"))}function h(e,n,r){var o,a,h=Qt(i,e),f=h.text.length;function p(n,r){return yr(t,oe(e,n),"div",h,r)}function d(e,n,r){var i=br(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=ft(h,i.direction);return lt(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"),T=null==n&&0==t,S=null==r&&e==f,x=0==h,E=!m||h==m.length-1;if(y.top-v.top<=3){var C=(u?S:T)&&E,b=(u?T:S)&&x?s:(g?v:y).left,k=C?l:(g?y:v).right;c(b,v.top,k-b,v.bottom)}else{var O,N,w,L;g?(O=u&&T&&x?s:v.left,N=u?l:d(t,i,"before"),w=u?s:d(e,i,"after"),L=u&&S&&E?l:y.right):(O=u?d(t,i,"before"):s,N=!u&&T&&x?l:v.right,w=!u&&S&&E?s:y.left,L=u?d(e,i,"after"):l),c(O,v.top,N-O,v.bottom),v.bottom<y.top&&c(s,v.bottom,null,y.top),c(w,y.top,L-w,y.bottom)}(!o||Kr(v,o)<0)&&(o=v),Kr(y,o)<0&&(o=y),(!a||Kr(v,a)<0)&&(a=v),Kr(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=Qt(i,f.line),m=Qt(i,p.line),g=Je(d)==Je(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?(c(v.right,v.top,null,v.bottom),c(s,y.top,y.left,y.bottom)):c(v.right,v.top,y.left-v.right,v.bottom)),v.bottom<y.top&&c(s,v.bottom,null,y.top)}n.appendChild(o)}function Yr(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()||Jr(t),e.cursorDiv.style.visibility=(n=!n)?"":"hidden"}),t.options.cursorBlinkRate):t.options.cursorBlinkRate<0&&(e.cursorDiv.style.visibility="hidden")}}function Xr(t){t.hasFocus()||(t.display.input.focus(),t.state.focused||Qr(t))}function qr(t){t.state.delayingBlurEvent=!0,setTimeout((function(){t.state.delayingBlurEvent&&(t.state.delayingBlurEvent=!1,t.state.focused&&Jr(t))}),100)}function Qr(t,e){t.state.delayingBlurEvent&&!t.state.draggingText&&(t.state.delayingBlurEvent=!1),"nocursor"!=t.options.readOnly&&(t.state.focused||(vt(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(),l&&setTimeout((function(){return t.display.input.reset(!0)}),20)),t.display.input.receivedFocus()),Yr(t))}function Jr(t,e){t.state.delayingBlurEvent||(t.state.focused&&(vt(t,"blur",t,e),t.state.focused=!1,O(t.display.wrapper,"CodeMirror-focused")),clearInterval(t.display.blinker),setTimeout((function(){t.state.focused||(t.display.shift=!1)}),150))}function Zr(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,l=void 0,u=0;if(!i.hidden){if(a&&s<8){var c=i.node.offsetTop+i.node.offsetHeight;l=c-n,n=c}else{var h=i.node.getBoundingClientRect();l=h.bottom-h.top,!o&&i.text.firstChild&&(u=i.text.firstChild.getBoundingClientRect().right-h.left-1)}var f=i.line.height-l;if((f>.005||f<-.005)&&(te(i.line,l),ti(i.line),i.rest))for(var p=0;p<i.rest.length;p++)ti(i.rest[p]);if(u>t.display.sizerWidth){var d=Math.ceil(u/Ar(t.display));d>t.display.maxLineLength&&(t.display.maxLineLength=d,t.display.maxLine=i.line,t.display.maxLineChanged=!0)}}}}function ti(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 ei(t,e,n){var r=n&&null!=n.top?Math.max(0,n.top):t.scroller.scrollTop;r=Math.floor(r-Vn(t));var i=n&&null!=n.bottom?n.bottom:r+t.wrapper.clientHeight,o=ne(e,r),a=ne(e,i);if(n&&n.ensure){var s=n.ensure.from.line,l=n.ensure.to.line;s<o?(o=s,a=ne(e,an(Qt(e,s))+t.wrapper.clientHeight)):Math.min(l,e.lastLine())>=a&&(o=ne(e,an(Qt(e,l))-t.wrapper.clientHeight),a=l)}return{from:o,to:Math.max(a,o+1)}}function ni(t,e){if(!yt(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-Vn(t.display))+"px;\n height: "+(e.bottom-e.top+Yn(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)}}}function ri(t,e,n,r){var i;null==r&&(r=0),t.options.lineWrapping||e!=n||(n="before"==e.sticky?oe(e.line,e.ch+1,"before"):e,e=e.ch?oe(e.line,"before"==e.sticky?e.ch-1:e.ch,"after"):e);for(var o=0;o<5;o++){var a=!1,s=Tr(t,e),l=n&&n!=e?Tr(t,n):s,u=oi(t,i={left:Math.min(s.left,l.left),top:Math.min(s.top,l.top)-r,right:Math.max(s.left,l.left),bottom:Math.max(s.bottom,l.bottom)+r}),c=t.doc.scrollTop,h=t.doc.scrollLeft;if(null!=u.scrollTop&&(fi(t,u.scrollTop),Math.abs(t.doc.scrollTop-c)>1&&(a=!0)),null!=u.scrollLeft&&(di(t,u.scrollLeft),Math.abs(t.doc.scrollLeft-h)>1&&(a=!0)),!a)break}return i}function ii(t,e){var n=oi(t,e);null!=n.scrollTop&&fi(t,n.scrollTop),null!=n.scrollLeft&&di(t,n.scrollLeft)}function oi(t,e){var n=t.display,r=Lr(t.display);e.top<0&&(e.top=0);var i=t.curOp&&null!=t.curOp.scrollTop?t.curOp.scrollTop:n.scroller.scrollTop,o=qn(t),a={};e.bottom-e.top>o&&(e.bottom=e.top+o);var s=t.doc.height+Kn(n),l=e.top<r,u=e.bottom>s-r;if(e.top<i)a.scrollTop=l?0:e.top;else if(e.bottom>i+o){var c=Math.min(e.top,(u?s:e.bottom)-o);c!=i&&(a.scrollTop=c)}var h=t.options.fixedGutter?0:n.gutters.offsetWidth,f=t.curOp&&null!=t.curOp.scrollLeft?t.curOp.scrollLeft:n.scroller.scrollLeft-h,p=Xn(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 ai(t,e){null!=e&&(ci(t),t.curOp.scrollTop=(null==t.curOp.scrollTop?t.doc.scrollTop:t.curOp.scrollTop)+e)}function si(t){ci(t);var e=t.getCursor();t.curOp.scrollToPos={from:e,to:e,margin:t.options.cursorScrollMargin}}function li(t,e,n){null==e&&null==n||ci(t),null!=e&&(t.curOp.scrollLeft=e),null!=n&&(t.curOp.scrollTop=n)}function ui(t,e){ci(t),t.curOp.scrollToPos=e}function ci(t){var e=t.curOp.scrollToPos;e&&(t.curOp.scrollToPos=null,hi(t,Sr(t,e.from),Sr(t,e.to),e.margin))}function hi(t,e,n,r){var i=oi(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});li(t,i.scrollLeft,i.scrollTop)}function fi(t,e){Math.abs(t.doc.scrollTop-e)<2||(n||zi(t,{top:e}),pi(t,e,!0),n&&zi(t),Pi(t,100))}function pi(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 di(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,$i(t),t.display.scroller.scrollLeft!=e&&(t.display.scroller.scrollLeft=e),t.display.scrollbars.setScrollLeft(e))}function mi(t){var e=t.display,n=e.gutters.offsetWidth,r=Math.round(t.doc.height+Kn(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+Yn(t)+e.barHeight,nativeBarWidth:e.nativeBarWidth,gutterWidth:n}}var gi=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),dt(r,"scroll",(function(){r.clientHeight&&e(r.scrollTop,"vertical")})),dt(i,"scroll",(function(){i.clientWidth&&e(i.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,a&&s<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};gi.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}},gi.prototype.setScrollLeft=function(t){this.horiz.scrollLeft!=t&&(this.horiz.scrollLeft=t),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},gi.prototype.setScrollTop=function(t){this.vert.scrollTop!=t&&(this.vert.scrollTop=t),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},gi.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 W,this.disableVert=new W},gi.prototype.enableZeroWidthBar=function(t,e,n){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)}t.style.pointerEvents="auto",e.set(1e3,r)},gi.prototype.clear=function(){var t=this.horiz.parentNode;t.removeChild(this.horiz),t.removeChild(this.vert)};var vi=function(){};function yi(t,e){e||(e=mi(t));var n=t.display.barWidth,r=t.display.barHeight;Ti(t,e);for(var i=0;i<4&&n!=t.display.barWidth||r!=t.display.barHeight;i++)n!=t.display.barWidth&&t.options.lineWrapping&&Zr(t),Ti(t,mi(t)),n=t.display.barWidth,r=t.display.barHeight}function Ti(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=""}vi.prototype.update=function(){return{bottom:0,right:0}},vi.prototype.setScrollLeft=function(){},vi.prototype.setScrollTop=function(){},vi.prototype.clear=function(){};var Si={native:gi,null:vi};function xi(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&O(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new Si[t.options.scrollbarStyle]((function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),dt(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?di(t,e):fi(t,e)}),t),t.display.scrollbars.addClass&&M(t.display.wrapper,t.display.scrollbars.addClass)}var Ei=0;function Ci(t){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:++Ei,markArrays:null},kn(t.curOp)}function bi(t){var e=t.curOp;e&&Nn(e,(function(t){for(var e=0;e<t.ops.length;e++)t.ops[e].cm.curOp=null;ki(t)}))}function ki(t){for(var e=t.ops,n=0;n<e.length;n++)Oi(e[n]);for(var r=0;r<e.length;r++)Ni(e[r]);for(var i=0;i<e.length;i++)wi(e[i]);for(var o=0;o<e.length;o++)Li(e[o]);for(var a=0;a<e.length;a++)Ai(e[a])}function Oi(t){var e=t.cm,n=e.display;Fi(e),t.updateMaxLine&&ln(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 Di(e,t.mustUpdate&&{top:t.scrollTop,ensure:t.scrollToPos},t.forceUpdate)}function Ni(t){t.updatedDisplay=t.mustUpdate&&Hi(t.cm,t.update)}function wi(t){var e=t.cm,n=e.display;t.updatedDisplay&&Zr(e),t.barMeasure=mi(e),n.maxLineChanged&&!e.options.lineWrapping&&(t.adjustWidthTo=tr(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+Yn(e)+e.display.barWidth),t.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+t.adjustWidthTo-Xn(e))),(t.updatedDisplay||t.selectionChanged)&&(t.preparedSelection=n.input.prepareSelection())}function Li(t){var e=t.cm;null!=t.adjustWidthTo&&(e.display.sizer.style.minWidth=t.adjustWidthTo+"px",t.maxScrollLeft<e.doc.scrollLeft&&di(e,Math.min(e.display.scroller.scrollLeft,t.maxScrollLeft),!0),e.display.maxLineChanged=!1);var n=t.focus&&t.focus==I();t.preparedSelection&&e.display.input.showSelection(t.preparedSelection,n),(t.updatedDisplay||t.startHeight!=e.doc.height)&&yi(e,t.barMeasure),t.updatedDisplay&&Ki(e,t.barMeasure),t.selectionChanged&&Yr(e),e.state.focused&&t.updateInput&&e.display.input.reset(t.typing),n&&Xr(t.cm)}function Ai(t){var e=t.cm,n=e.display,r=e.doc;t.updatedDisplay&&Gi(e,t.update),null==n.wheelStartX||null==t.scrollTop&&null==t.scrollLeft&&!t.scrollToPos||(n.wheelStartX=n.wheelStartY=null),null!=t.scrollTop&&pi(e,t.scrollTop,t.forceScroll),null!=t.scrollLeft&&di(e,t.scrollLeft,!0,!0),t.scrollToPos&&ni(e,ri(e,fe(r,t.scrollToPos.from),fe(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||vt(i[a],"hide");if(o)for(var s=0;s<o.length;++s)o[s].lines.length&&vt(o[s],"unhide");n.wrapper.offsetHeight&&(r.scrollTop=e.display.scroller.scrollTop),t.changeObjs&&vt(e,"changes",e,t.changeObjs),t.update&&t.update.finish()}function Ri(t,e){if(t.curOp)return e();Ci(t);try{return e()}finally{bi(t)}}function Ii(t,e){return function(){if(t.curOp)return e.apply(t,arguments);Ci(t);try{return e.apply(t,arguments)}finally{bi(t)}}}function Mi(t){return function(){if(this.curOp)return t.apply(this,arguments);Ci(this);try{return t.apply(this,arguments)}finally{bi(this)}}}function _i(t){return function(){var e=this.cm;if(!e||e.curOp)return t.apply(this,arguments);Ci(e);try{return t.apply(this,arguments)}finally{bi(e)}}}function Pi(t,e){t.doc.highlightFrontier<t.display.viewTo&&t.state.highlight.set(e,U(Ui,t))}function Ui(t){var e=t.doc;if(!(e.highlightFrontier>=t.display.viewTo)){var n=+new Date+t.options.workTime,r=Te(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?$t(e.mode,r.state):null,l=ve(t,o,r,!0);s&&(r.state=s),o.styles=l.styles;var u=o.styleClasses,c=l.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var h=!a||a.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.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&&Se(t,o.text,r),o.stateAfter=r.line%5==0?r.save():null,r.nextLine();if(+new Date>n)return Pi(t,t.options.workDelay),!0})),e.highlightFrontier=r.line,e.modeFrontier=Math.max(e.modeFrontier,r.line),i.length&&Ri(t,(function(){for(var e=0;e<i.length;e++)Fr(t,i[e],"text")}))}}var Di=function(t,e,n){var r=t.display;this.viewport=e,this.visible=ei(r,t.doc,e),this.editorIsHidden=!r.wrapper.offsetWidth,this.wrapperHeight=r.wrapper.clientHeight,this.wrapperWidth=r.wrapper.clientWidth,this.oldDisplayWidth=Xn(t),this.force=n,this.dims=Rr(t),this.events=[]};function Fi(t){var e=t.display;!e.scrollbarsClipped&&e.scroller.offsetWidth&&(e.nativeBarWidth=e.scroller.offsetWidth-e.scroller.clientWidth,e.heightForcer.style.height=Yn(t)+"px",e.sizer.style.marginBottom=-e.nativeBarWidth+"px",e.sizer.style.borderRightWidth=Yn(t)+"px",e.scrollbarsClipped=!0)}function Wi(t){if(t.hasFocus())return null;var e=I();if(!e||!R(t.display.lineDiv,e))return null;var n={activeElt:e};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&R(t.display.lineDiv,r.anchorNode)&&(n.anchorNode=r.anchorNode,n.anchorOffset=r.anchorOffset,n.focusNode=r.focusNode,n.focusOffset=r.focusOffset)}return n}function Bi(t){if(t&&t.activeElt&&t.activeElt!=I()&&(t.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(t.activeElt.nodeName)&&t.anchorNode&&R(document.body,t.anchorNode)&&R(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)}}function Hi(t,e){var n=t.display,r=t.doc;if(e.editorIsHidden)return Wr(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==Gr(t))return!1;Yi(t)&&(Wr(t),e.dims=Rr(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)),Ae&&(o=en(t.doc,o),a=nn(t.doc,a));var s=o!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=e.wrapperHeight||n.lastWrapWidth!=e.wrapperWidth;Hr(t,o,a),n.viewOffset=an(Qt(t.doc,n.viewFrom)),t.display.mover.style.top=n.viewOffset+"px";var l=Gr(t);if(!s&&0==l&&!e.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var u=Wi(t);return l>4&&(n.lineDiv.style.display="none"),ji(t,n.updateLineNumbers,e.dims),l>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,Bi(u),N(n.cursorDiv),N(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,s&&(n.lastWrapHeight=e.wrapperHeight,n.lastWrapWidth=e.wrapperWidth,Pi(t,400)),n.updateLineNumbers=null,!0}function Gi(t,e){for(var n=e.viewport,r=!0;;r=!1){if(r&&t.options.lineWrapping&&e.oldDisplayWidth!=Xn(t))r&&(e.visible=ei(t.display,t.doc,n));else if(n&&null!=n.top&&(n={top:Math.min(t.doc.height+Kn(t.display)-qn(t),n.top)}),e.visible=ei(t.display,t.doc,n),e.visible.from>=t.display.viewFrom&&e.visible.to<=t.display.viewTo)break;if(!Hi(t,e))break;Zr(t);var i=mi(t);zr(t),yi(t,i),Ki(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 zi(t,e){var n=new Di(t,e);if(Hi(t,n)){Zr(t),Gi(t,n);var r=mi(t);zr(t),yi(t,r),Ki(t,r),n.finish()}}function ji(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 l&&y&&t.display.currentWheelTarget==e?e.style.display="none":e.parentNode.removeChild(e),n}for(var u=r.view,c=r.viewFrom,h=0;h<u.length;h++){var f=u[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<=c&&f.lineNumber;f.changes&&(B(f.changes,"gutter")>-1&&(p=!1),Rn(t,f,c,n)),p&&(N(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(ie(t.options,c)))),a=f.node.nextSibling}else{var d=Wn(t,f,c,n);o.insertBefore(d,a)}c+=f.size}for(;a;)a=s(a)}function Vi(t){var e=t.gutters.offsetWidth;t.sizer.style.marginLeft=e+"px",Ln(t,"gutterChanged",t)}function Ki(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+Yn(t)+"px"}function $i(t){var e=t.display,n=e.view;if(e.alignWidgets||e.gutters.firstChild&&t.options.fixedGutter){for(var r=Ir(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 l=0;l<s.length;l++)s[l].style.left=o}t.options.fixedGutter&&(e.gutters.style.left=r+i+"px")}}function Yi(t){if(!t.options.lineNumbers)return!1;var e=t.doc,n=ie(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",Vi(t.display),!0}return!1}function Xi(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 qi(t){var e=t.gutters,n=t.gutterSpecs;N(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",Vi(t)}function Qi(t){qi(t.display),Dr(t),$i(t)}function Ji(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 u=A("div",[o.lineSpace],"CodeMirror-lines");o.mover=L("div",[u],null,"position: relative"),o.sizer=L("div",[o.mover],"CodeMirror-sizer"),o.sizerWidth=null,o.heightForcer=L("div",null,null,"position: absolute; height: "+H+"px; 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),l||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=Xi(i.gutters,i.lineNumbers),qi(o),r.init(o)}Di.prototype.signal=function(t,e){St(t,e)&&this.events.push(arguments)},Di.prototype.finish=function(){for(var t=0;t<this.events.length;t++)vt.apply(null,this.events[t])};var Zi=0,to=null;function eo(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 no(t){var e=eo(t);return e.x*=to,e.y*=to,e}function ro(t,e){var r=eo(e),i=r.x,o=r.y,a=t.display,s=a.scroller,u=s.scrollWidth>s.clientWidth,c=s.scrollHeight>s.clientHeight;if(i&&u||o&&c){if(o&&y&&l)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!=to)return o&&c&&fi(t,Math.max(0,s.scrollTop+o*to)),di(t,Math.max(0,s.scrollLeft+i*to)),(!o||o&&c)&&Et(e),void(a.wheelStartX=null);if(o&&null!=to){var m=o*to,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),zi(t,{top:g,bottom:v})}Zi<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&&(to=(to*Zi+n)/(Zi+1),++Zi)}}),200)):(a.wheelDX+=i,a.wheelDY+=o))}}a?to=-.53:n?to=15:c?to=-.7:f&&(to=-1/3);var io=function(t,e){this.ranges=t,this.primIndex=e};io.prototype.primary=function(){return this.ranges[this.primIndex]},io.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(!se(n.anchor,r.anchor)||!se(n.head,r.head))return!1}return!0},io.prototype.deepCopy=function(){for(var t=[],e=0;e<this.ranges.length;e++)t[e]=new oo(le(this.ranges[e].anchor),le(this.ranges[e].head));return new io(t,this.primIndex)},io.prototype.somethingSelected=function(){for(var t=0;t<this.ranges.length;t++)if(!this.ranges[t].empty())return!0;return!1},io.prototype.contains=function(t,e){e||(e=t);for(var n=0;n<this.ranges.length;n++){var r=this.ranges[n];if(ae(e,r.from())>=0&&ae(t,r.to())<=0)return n}return-1};var oo=function(t,e){this.anchor=t,this.head=e};function ao(t,e,n){var r=t&&t.options.selectionsMayTouch,i=e[n];e.sort((function(t,e){return ae(t.from(),e.from())})),n=B(e,i);for(var o=1;o<e.length;o++){var a=e[o],s=e[o-1],l=ae(s.to(),a.from());if(r&&!a.empty()?l>0:l>=0){var u=ce(s.from(),a.from()),c=ue(s.to(),a.to()),h=s.empty()?a.from()==a.head:s.from()==s.head;o<=n&&--n,e.splice(--o,2,new oo(h?c:u,h?u:c))}}return new io(e,n)}function so(t,e){return new io([new oo(t,e||t)],0)}function lo(t){return t.text?oe(t.from.line+t.text.length-1,X(t.text).length+(1==t.text.length?t.from.ch:0)):t.to}function uo(t,e){if(ae(t,e.from)<0)return t;if(ae(t,e.to)<=0)return lo(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+=lo(e).ch-e.to.ch),oe(n,r)}function co(t,e){for(var n=[],r=0;r<t.sel.ranges.length;r++){var i=t.sel.ranges[r];n.push(new oo(uo(i.anchor,e),uo(i.head,e)))}return ao(t.cm,n,t.sel.primIndex)}function ho(t,e,n){return t.line==e.line?oe(n.line,t.ch-e.ch+n.ch):oe(n.line+(t.line-e.line),t.ch)}function fo(t,e,n){for(var r=[],i=oe(t.first,0),o=i,a=0;a<e.length;a++){var s=e[a],l=ho(s.from,i,o),u=ho(lo(s),i,o);if(i=s.to,o=u,"around"==n){var c=t.sel.ranges[a],h=ae(c.head,c.anchor)<0;r[a]=new oo(h?u:l,h?l:u)}else r[a]=new oo(l,l)}return new io(r,t.sel.primIndex)}function po(t){t.doc.mode=jt(t.options,t.doc.modeOption),mo(t)}function mo(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,Pi(t,100),t.state.modeGen++,t.curOp&&Dr(t)}function go(t,e){return 0==e.from.ch&&0==e.to.ch&&""==X(e.text)&&(!t.cm||t.cm.options.wholeLineUpdateBefore)}function vo(t,e,n,r){function i(t){return n?n[t]:null}function o(t,n,i){cn(t,n,i,r),Ln(t,"change",t,e)}function a(t,e){for(var n=[],o=t;o<e;++o)n.push(new un(u[o],i(o),r));return n}var s=e.from,l=e.to,u=e.text,c=Qt(t,s.line),h=Qt(t,l.line),f=X(u),p=i(u.length-1),d=l.line-s.line;if(e.full)t.insert(0,a(0,u.length)),t.remove(u.length,t.size-u.length);else if(go(t,e)){var m=a(0,u.length-1);o(h,h.text,p),d&&t.remove(s.line,d),m.length&&t.insert(s.line,m)}else if(c==h)if(1==u.length)o(c,c.text.slice(0,s.ch)+f+c.text.slice(l.ch),p);else{var g=a(1,u.length-1);g.push(new un(f+c.text.slice(l.ch),p,r)),o(c,c.text.slice(0,s.ch)+u[0],i(0)),t.insert(s.line+1,g)}else if(1==u.length)o(c,c.text.slice(0,s.ch)+u[0]+h.text.slice(l.ch),i(0)),t.remove(s.line+1,d);else{o(c,c.text.slice(0,s.ch)+u[0],i(0)),o(h,f+h.text.slice(l.ch),p);var v=a(1,u.length-1);d>1&&t.remove(s.line+1,d-1),t.insert(s.line+1,v)}Ln(t,"change",t,e)}function yo(t,e,n){function r(t,i,o){if(t.linked)for(var a=0;a<t.linked.length;++a){var s=t.linked[a];if(s.doc!=i){var l=o&&s.sharedHist;n&&!l||(e(s.doc,l),r(s.doc,t,l))}}}r(t,null,!0)}function To(t,e){if(e.cm)throw new Error("This document is already in use.");t.doc=e,e.cm=t,_r(t),po(t),So(t),t.options.direction=e.direction,t.options.lineWrapping||ln(t),t.options.mode=e.modeOption,Dr(t)}function So(t){("rtl"==t.doc.direction?M:O)(t.display.lineDiv,"CodeMirror-rtl")}function xo(t){Ri(t,(function(){So(t),Dr(t)}))}function Eo(t){this.done=[],this.undone=[],this.undoDepth=t?t.undoDepth:1/0,this.lastModTime=this.lastSelTime=0,this.lastOp=this.lastSelOp=null,this.lastOrigin=this.lastSelOrigin=null,this.generation=this.maxGeneration=t?t.maxGeneration:1}function Co(t,e){var n={from:le(e.from),to:lo(e),text:Jt(t,e.from,e.to)};return Ao(t,n,e.from.line,e.to.line+1),yo(t,(function(t){return Ao(t,n,e.from.line,e.to.line+1)}),!0),n}function bo(t){for(;t.length&&X(t).ranges;)t.pop()}function ko(t,e){return e?(bo(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}function Oo(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=ko(i,i.lastOp==r)))a=X(o.changes),0==ae(e.from,e.to)&&0==ae(e.from,a.to)?a.to=lo(e):o.changes.push(Co(t,e));else{var l=X(i.done);for(l&&l.ranges||Lo(t.sel,i.done),o={changes:[Co(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||vt(t,"historyAdded")}function No(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)}function wo(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||No(t,o,X(i.done),e))?i.done[i.done.length-1]=e:Lo(e,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=n,r&&!1!==r.clearRedo&&bo(i.undone)}function Lo(t,e){var n=X(e);n&&n.ranges&&n.equals(t)||e.push(t)}function Ao(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 Ro(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 Io(t,e){var n=e["spans_"+t.id];if(!n)return null;for(var r=[],i=0;i<e.text.length;++i)r.push(Ro(n[i]));return r}function Mo(t,e){var n=Io(t,e),r=We(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 l=a[s],u=0;u<o.length;++u)if(o[u].marker==l.marker)continue t;o.push(l)}else a&&(n[i]=a)}return n}function _o(t,e,n){for(var r=[],i=0;i<t.length;++i){var o=t[i];if(o.ranges)r.push(n?io.prototype.deepCopy.call(o):o);else{var a=o.changes,s=[];r.push({changes:s});for(var l=0;l<a.length;++l){var u=a[l],c=void 0;if(s.push({from:u.from,to:u.to,text:u.text}),e)for(var h in u)(c=h.match(/^spans_(\d+)$/))&&B(e,Number(c[1]))>-1&&(X(s)[h]=u[h],delete u[h])}}}return r}function Po(t,e,n,r){if(r){var i=t.anchor;if(n){var o=ae(e,i)<0;o!=ae(n,i)<0?(i=e,e=n):o!=ae(e,n)<0&&(e=n)}return new oo(i,e)}return new oo(n||e,e)}function Uo(t,e,n,r,i){null==i&&(i=t.cm&&(t.cm.display.shift||t.extend)),Go(t,new io([Po(t.sel.primary(),e,n,i)],0),r)}function Do(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]=Po(t.sel.ranges[o],e[o],null,i);Go(t,ao(t.cm,r,t.sel.primIndex),n)}function Fo(t,e,n,r){var i=t.sel.ranges.slice(0);i[e]=n,Go(t,ao(t.cm,i,t.sel.primIndex),r)}function Wo(t,e,n,r){Go(t,so(e,n),r)}function Bo(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 oo(fe(t,e[n].anchor),fe(t,e[n].head))},origin:n&&n.origin};return vt(t,"beforeSelectionChange",t,r),t.cm&&vt(t.cm,"beforeSelectionChange",t.cm,r),r.ranges!=e.ranges?ao(t.cm,r.ranges,r.ranges.length-1):e}function Ho(t,e,n){var r=t.history.done,i=X(r);i&&i.ranges?(r[r.length-1]=e,zo(t,e,n)):Go(t,e,n)}function Go(t,e,n){zo(t,e,n),wo(t,t.sel,t.cm?t.cm.curOp.id:NaN,n)}function zo(t,e,n){(St(t,"beforeSelectionChange")||t.cm&&St(t.cm,"beforeSelectionChange"))&&(e=Bo(t,e,n));var r=n&&n.bias||(ae(e.primary().head,t.sel.primary().head)<0?-1:1);jo(t,Ko(t,e,r,!0)),n&&!1===n.scroll||!t.cm||"nocursor"==t.cm.getOption("readOnly")||si(t.cm)}function jo(t,e){e.equals(t.sel)||(t.sel=e,t.cm&&(t.cm.curOp.updateInput=1,t.cm.curOp.selectionChanged=!0,Tt(t.cm)),Ln(t,"cursorActivity",t))}function Vo(t){jo(t,Ko(t,t.sel,null,!1))}function Ko(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],l=Yo(t,a.anchor,s&&s.anchor,n,r),u=Yo(t,a.head,s&&s.head,n,r);(i||l!=a.anchor||u!=a.head)&&(i||(i=e.ranges.slice(0,o)),i[o]=new oo(l,u))}return i?ao(t.cm,i,e.primIndex):e}function $o(t,e,n,r,i){var o=Qt(t,e.line);if(o.markedSpans)for(var a=0;a<o.markedSpans.length;++a){var s=o.markedSpans[a],l=s.marker,u="selectLeft"in l?!l.selectLeft:l.inclusiveLeft,c="selectRight"in l?!l.selectRight:l.inclusiveRight;if((null==s.from||(u?s.from<=e.ch:s.from<e.ch))&&(null==s.to||(c?s.to>=e.ch:s.to>e.ch))){if(i&&(vt(l,"beforeCursorEnter"),l.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!l.atomic)continue;if(n){var h=l.find(r<0?1:-1),f=void 0;if((r<0?c:u)&&(h=Xo(t,h,-r,h&&h.line==e.line?o:null)),h&&h.line==e.line&&(f=ae(h,n))&&(r<0?f<0:f>0))return $o(t,h,e,r,i)}var p=l.find(r<0?-1:1);return(r<0?u:c)&&(p=Xo(t,p,r,p.line==e.line?o:null)),p?$o(t,p,e,r,i):null}}return e}function Yo(t,e,n,r,i){var o=r||1,a=$o(t,e,n,o,i)||!i&&$o(t,e,n,o,!0)||$o(t,e,n,-o,i)||!i&&$o(t,e,n,-o,!0);return a||(t.cantEdit=!0,oe(t.first,0))}function Xo(t,e,n,r){return n<0&&0==e.ch?e.line>t.first?fe(t,oe(e.line-1)):null:n>0&&e.ch==(r||Qt(t,e.line)).text.length?e.line<t.first+t.size-1?oe(e.line+1,0):null:new oe(e.line,e.ch+n)}function qo(t){t.setSelection(oe(t.firstLine(),0),oe(t.lastLine()),z)}function Qo(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=fe(t,e)),n&&(r.to=fe(t,n)),i&&(r.text=i),void 0!==o&&(r.origin=o)}),vt(t,"beforeChange",t,r),t.cm&&vt(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 Jo(t,e,n){if(t.cm){if(!t.cm.curOp)return Ii(t.cm,Jo)(t,e,n);if(t.cm.state.suppressEdits)return}if(!(St(t,"beforeChange")||t.cm&&St(t.cm,"beforeChange"))||(e=Qo(t,e,!0))){var r=Le&&!n&&He(t,e.from,e.to);if(r)for(var i=r.length-1;i>=0;--i)Zo(t,{from:r[i].from,to:r[i].to,text:i?[""]:e.text,origin:e.origin});else Zo(t,e)}}function Zo(t,e){if(1!=e.text.length||""!=e.text[0]||0!=ae(e.from,e.to)){var n=co(t,e);Oo(t,e,n,t.cm?t.cm.curOp.id:NaN),na(t,e,n,We(t,e));var r=[];yo(t,(function(t,n){n||-1!=B(r,t.history)||(sa(t.history,e),r.push(t.history)),na(t,e,null,We(t,e))}))}}function ta(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,l="undo"==e?o.undone:o.done,u=0;u<s.length&&(i=s[u],n?!i.ranges||i.equals(t.sel):i.ranges);u++);if(u!=s.length){for(o.lastOrigin=o.lastSelOrigin=null;;){if(!(i=s.pop()).ranges){if(r)return void s.push(i);break}if(Lo(i,l),n&&!i.equals(t.sel))return void Go(t,i,{clearRedo:!1});a=i}var c=[];Lo(a,l),l.push({changes:c,generation:o.generation}),o.generation=i.generation||++o.maxGeneration;for(var h=St(t,"beforeChange")||t.cm&&St(t.cm,"beforeChange"),f=function(n){var r=i.changes[n];if(r.origin=e,h&&!Qo(t,r,!1))return s.length=0,{};c.push(Co(t,r));var o=n?co(t,r):X(s);na(t,r,o,Mo(t,r)),!n&&t.cm&&t.cm.scrollIntoView({from:r.from,to:lo(r)});var a=[];yo(t,(function(t,e){e||-1!=B(a,t.history)||(sa(t.history,r),a.push(t.history)),na(t,r,null,Mo(t,r))}))},p=i.changes.length-1;p>=0;--p){var d=f(p);if(d)return d.v}}}}function ea(t,e){if(0!=e&&(t.first+=e,t.sel=new io(q(t.sel.ranges,(function(t){return new oo(oe(t.anchor.line+e,t.anchor.ch),oe(t.head.line+e,t.head.ch))})),t.sel.primIndex),t.cm)){Dr(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 na(t,e,n,r){if(t.cm&&!t.cm.curOp)return Ii(t.cm,na)(t,e,n,r);if(e.to.line<t.first)ea(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);ea(t,i),e={from:oe(t.first,0),to:oe(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:oe(o,Qt(t,o).text.length),text:[e.text[0]],origin:e.origin}),e.removed=Jt(t,e.from,e.to),n||(n=co(t,e)),t.cm?ra(t.cm,e,r):vo(t,e,r),zo(t,n,z),t.cantEdit&&Yo(t,oe(t.firstLine(),0))&&(t.cantEdit=!1)}}function ra(t,e,n){var r=t.doc,i=t.display,o=e.from,a=e.to,s=!1,l=o.line;t.options.lineWrapping||(l=ee(Je(Qt(r,o.line))),r.iter(l,a.line+1,(function(t){if(t==i.maxLine)return s=!0,!0}))),r.sel.contains(e.from,e.to)>-1&&Tt(t),vo(r,e,n,Mr(t)),t.options.lineWrapping||(r.iter(l,o.line+e.text.length,(function(t){var e=sn(t);e>i.maxLineLength&&(i.maxLine=t,i.maxLineLength=e,i.maxLineChanged=!0,s=!1)})),s&&(t.curOp.updateMaxLine=!0)),we(r,o.line),Pi(t,400);var u=e.text.length-(a.line-o.line)-1;e.full?Dr(t):o.line!=a.line||1!=e.text.length||go(t.doc,e)?Dr(t,o.line,a.line+1,u):Fr(t,o.line,"text");var c=St(t,"changes"),h=St(t,"change");if(h||c){var f={from:o,to:a,text:e.text,removed:e.removed,origin:e.origin};h&&Ln(t,"change",t,f),c&&(t.curOp.changeObjs||(t.curOp.changeObjs=[])).push(f)}t.display.selForContextMenu=null}function ia(t,e,n,r,i){var o;r||(r=n),ae(r,n)<0&&(n=(o=[r,n])[0],r=o[1]),"string"==typeof e&&(e=t.splitLines(e)),Jo(t,{from:n,to:r,text:e,origin:i})}function oa(t,e,n,r){n<t.line?t.line+=r:e<t.line&&(t.line=e,t.ch=0)}function aa(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++)oa(o.ranges[s].anchor,e,n,r),oa(o.ranges[s].head,e,n,r)}else{for(var l=0;l<o.changes.length;++l){var u=o.changes[l];if(n<u.from.line)u.from=oe(u.from.line+r,u.from.ch),u.to=oe(u.to.line+r,u.to.ch);else if(e<=u.to.line){a=!1;break}}a||(t.splice(0,i+1),i=0)}}}function sa(t,e){var n=e.from.line,r=e.to.line,i=e.text.length-(r-n)-1;aa(t.done,n,r,i),aa(t.undone,n,r,i)}function la(t,e,n,r){var i=e,o=e;return"number"==typeof e?o=Qt(t,he(t,e)):i=ee(e),null==i?null:(r(o,i)&&t.cm&&Fr(t.cm,i,n),o)}function ua(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 ca(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}oo.prototype.from=function(){return ce(this.anchor,this.head)},oo.prototype.to=function(){return ue(this.anchor,this.head)},oo.prototype.empty=function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch},ua.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,hn(i),Ln(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}},ca.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 ua))){var s=[];this.collapse(s),this.children=[new ua(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 l=new ua(i.lines.slice(s,s+=25));i.height-=l.height,this.children.splice(++r,0,l),l.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 ca(t.children.splice(t.children.length-5,5));if(t.parent){t.size-=e.size,t.height-=e.height;var n=B(t.parent.children,t);t.parent.children.splice(n+1,0,e)}else{var r=new ca(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 ha=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 fa(t,e,n){an(e)<(t.curOp&&t.curOp.scrollTop||t.doc.scrollTop)&&ai(t,n)}function pa(t,e,n,r){var i=new ha(t,n,r),o=t.cm;return o&&i.noHScroll&&(o.display.alignWidgets=!0),la(t,e,"widget",(function(e){var n=e.widgets||(e.widgets=[]);if(null==i.insertAt?n.push(i):n.splice(Math.min(n.length,Math.max(0,i.insertAt)),0,i),i.line=e,o&&!rn(t,e)){var r=an(e)<t.scrollTop;te(e,e.height+zn(i)),r&&ai(o,i.height),o.curOp.forceUpdate=!0}return!0})),o&&Ln(o,"lineWidgetAdded",o,i,"number"==typeof e?e:ee(e)),i}ha.prototype.clear=function(){var t=this.doc.cm,e=this.line.widgets,n=this.line,r=ee(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=zn(this);te(n,Math.max(0,n.height-o)),t&&(Ri(t,(function(){fa(t,n,-o),Fr(t,r,"widget")})),Ln(t,"lineWidgetCleared",t,this,r))}},ha.prototype.changed=function(){var t=this,e=this.height,n=this.doc.cm,r=this.line;this.height=null;var i=zn(this)-e;i&&(rn(this.doc,r)||te(r,r.height+i),n&&Ri(n,(function(){n.curOp.forceUpdate=!0,fa(n,r,i),Ln(n,"lineWidgetChanged",n,t,ee(r))})))},xt(ha);var da=0,ma=function(t,e){this.lines=[],this.type=e,this.doc=t,this.id=++da};function ga(t,e,n,r,i){if(r&&r.shared)return ya(t,e,n,r,i);if(t.cm&&!t.cm.curOp)return Ii(t.cm,ga)(t,e,n,r,i);var o=new ma(t,i),a=ae(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(Qe(t,e.line,e,n,o)||e.line!=n.line&&Qe(t,n.line,e,n,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ie()}o.addToHistory&&Oo(t,{from:e,to:n,origin:"markText"},t.sel,NaN);var s,l=e.line,u=t.cm;if(t.iter(l,n.line+1,(function(r){u&&o.collapsed&&!u.options.lineWrapping&&Je(r)==u.display.maxLine&&(s=!0),o.collapsed&&l!=e.line&&te(r,0),Ue(r,new Me(o,l==e.line?e.ch:null,l==n.line?n.ch:null),t.cm&&t.cm.curOp),++l})),o.collapsed&&t.iter(e.line,n.line+1,(function(e){rn(t,e)&&te(e,0)})),o.clearOnEnter&&dt(o,"beforeCursorEnter",(function(){return o.clear()})),o.readOnly&&(Re(),(t.history.done.length||t.history.undone.length)&&t.clearHistory()),o.collapsed&&(o.id=++da,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)Dr(u,e.line,n.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(var c=e.line;c<=n.line;c++)Fr(u,c,"text");o.atomic&&Vo(u.doc),Ln(u,"markerAdded",u,o)}return o}ma.prototype.clear=function(){if(!this.explicitlyCleared){var t=this.doc.cm,e=t&&!t.curOp;if(e&&Ci(t),St(this,"clear")){var n=this.find();n&&Ln(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=_e(a.markedSpans,this);t&&!this.collapsed?Fr(t,ee(a),"text"):t&&(null!=s.to&&(i=ee(a)),null!=s.from&&(r=ee(a))),a.markedSpans=Pe(a.markedSpans,s),null==s.from&&this.collapsed&&!rn(this.doc,a)&&t&&te(a,Lr(t.display))}if(t&&this.collapsed&&!t.options.lineWrapping)for(var l=0;l<this.lines.length;++l){var u=Je(this.lines[l]),c=sn(u);c>t.display.maxLineLength&&(t.display.maxLine=u,t.display.maxLineLength=c,t.display.maxLineChanged=!0)}null!=r&&t&&this.collapsed&&Dr(t,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&Vo(t.doc)),t&&Ln(t,"markerCleared",t,this,r,i),e&&bi(t),this.parent&&this.parent.clear()}},ma.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=_e(o.markedSpans,this);if(null!=a.from&&(n=oe(e?o:ee(o),a.from),-1==t))return n;if(null!=a.to&&(r=oe(e?o:ee(o),a.to),1==t))return r}return n&&{from:n,to:r}},ma.prototype.changed=function(){var t=this,e=this.find(-1,!0),n=this,r=this.doc.cm;e&&r&&Ri(r,(function(){var i=e.line,o=ee(e.line),a=er(r,o);if(a&&(cr(a),r.curOp.selectionChanged=r.curOp.forceUpdate=!0),r.curOp.updateMaxLine=!0,!rn(n.doc,i)&&null!=n.height){var s=n.height;n.height=null;var l=zn(n)-s;l&&te(i,i.height+l)}Ln(r,"markerChanged",r,t)}))},ma.prototype.attachLine=function(t){if(!this.lines.length&&this.doc.cm){var e=this.doc.cm.curOp;e.maybeHiddenMarkers&&-1!=B(e.maybeHiddenMarkers,this)||(e.maybeUnhiddenMarkers||(e.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(t)},ma.prototype.detachLine=function(t){if(this.lines.splice(B(this.lines,t),1),!this.lines.length&&this.doc.cm){var e=this.doc.cm.curOp;(e.maybeHiddenMarkers||(e.maybeHiddenMarkers=[])).push(this)}},xt(ma);var va=function(t,e){this.markers=t,this.primary=e;for(var n=0;n<t.length;++n)t[n].parent=this};function ya(t,e,n,r,i){(r=D(r)).shared=!1;var o=[ga(t,e,n,r,i)],a=o[0],s=r.widgetNode;return yo(t,(function(t){s&&(r.widgetNode=s.cloneNode(!0)),o.push(ga(t,fe(t,e),fe(t,n),r,i));for(var l=0;l<t.linked.length;++l)if(t.linked[l].isParent)return;a=X(o)})),new va(o,a)}function Ta(t){return t.findMarks(oe(t.first,0),t.clipPos(oe(t.lastLine())),(function(t){return t.parent}))}function Sa(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(ae(o,a)){var s=ga(t,o,a,r.primary,r.primary.type);r.markers.push(s),s.parent=r}}}function xa(t){for(var e=function(e){var n=t[e],r=[n.primary.doc];yo(n.primary.doc,(function(t){return r.push(t)}));for(var i=0;i<n.markers.length;i++){var o=n.markers[i];-1==B(r,o.doc)&&(o.parent=null,n.markers.splice(i--,1))}},n=0;n<t.length;n++)e(n)}va.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var t=0;t<this.markers.length;++t)this.markers[t].clear();Ln(this,"clear")}},va.prototype.find=function(t,e){return this.primary.find(t,e)},xt(va);var Ea=0,Ca=function(t,e,n,r,i){if(!(this instanceof Ca))return new Ca(t,e,n,r,i);null==n&&(n=0),ca.call(this,[new ua([new un("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.modeFrontier=this.highlightFrontier=n;var o=oe(n,0);this.sel=so(o),this.history=new Eo(null),this.id=++Ea,this.modeOption=e,this.lineSep=r,this.direction="rtl"==i?"rtl":"ltr",this.extend=!1,"string"==typeof t&&(t=this.splitLines(t)),vo(this,{from:o,to:o,text:t}),Go(this,so(o),z)};Ca.prototype=Z(ca.prototype,{constructor:Ca,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=Zt(this,this.first,this.first+this.size);return!1===t?e:e.join(t||this.lineSeparator())},setValue:_i((function(t){var e=oe(this.first,0),n=this.first+this.size-1;Jo(this,{from:e,to:oe(n,Qt(this,n).text.length),text:this.splitLines(t),origin:"setValue",full:!0},!0),this.cm&&li(this.cm,0,0),Go(this,so(e),z)})),replaceRange:function(t,e,n,r){ia(this,t,e=fe(this,e),n=n?fe(this,n):e,r)},getRange:function(t,e,n){var r=Jt(this,fe(this,t),fe(this,e));return!1===n?r:""===n?r.join(""):r.join(n||this.lineSeparator())},getLine:function(t){var e=this.getLineHandle(t);return e&&e.text},getLineHandle:function(t){if(re(this,t))return Qt(this,t)},getLineNumber:function(t){return ee(t)},getLineHandleVisualStart:function(t){return"number"==typeof t&&(t=Qt(this,t)),Je(t)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(t){return fe(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:_i((function(t,e,n){Wo(this,fe(this,"number"==typeof t?oe(t,e||0):t),null,n)})),setSelection:_i((function(t,e,n){Wo(this,fe(this,t),fe(this,e||t),n)})),extendSelection:_i((function(t,e,n){Uo(this,fe(this,t),e&&fe(this,e),n)})),extendSelections:_i((function(t,e){Do(this,de(this,t),e)})),extendSelectionsBy:_i((function(t,e){Do(this,de(this,q(this.sel.ranges,t)),e)})),setSelections:_i((function(t,e,n){if(t.length){for(var r=[],i=0;i<t.length;i++)r[i]=new oo(fe(this,t[i].anchor),fe(this,t[i].head||t[i].anchor));null==e&&(e=Math.min(t.length-1,this.sel.primIndex)),Go(this,ao(this.cm,r,e),n)}})),addSelection:_i((function(t,e,n){var r=this.sel.ranges.slice(0);r.push(new oo(fe(this,t),fe(this,e||t))),Go(this,ao(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=Jt(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=Jt(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:_i((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&&fo(this,r,e),l=r.length-1;l>=0;l--)Jo(this,r[l]);s?Ho(this,s):this.cm&&si(this.cm)})),undo:_i((function(){ta(this,"undo")})),redo:_i((function(){ta(this,"redo")})),undoSelection:_i((function(){ta(this,"undo",!0)})),redoSelection:_i((function(){ta(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 Eo(this.history),yo(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:_o(this.history.done),undone:_o(this.history.undone)}},setHistory:function(t){var e=this.history=new Eo(this.history);e.done=_o(t.done.slice(0),null,!0),e.undone=_o(t.undone.slice(0),null,!0)},setGutterMarker:_i((function(t,e,n){return la(this,t,"gutter",(function(t){var r=t.gutterMarkers||(t.gutterMarkers={});return r[e]=n,!n&&rt(r)&&(t.gutterMarkers=null),!0}))})),clearGutter:_i((function(t){var e=this;this.iter((function(n){n.gutterMarkers&&n.gutterMarkers[t]&&la(e,n,"gutter",(function(){return n.gutterMarkers[t]=null,rt(n.gutterMarkers)&&(n.gutterMarkers=null),!0}))}))})),lineInfo:function(t){var e;if("number"==typeof t){if(!re(this,t))return null;if(e=t,!(t=Qt(this,t)))return null}else if(null==(e=ee(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:_i((function(t,e,n){return la(this,t,"gutter"==e?"gutter":"class",(function(t){var r="text"==e?"textClass":"background"==e?"bgClass":"gutter"==e?"gutterClass":"wrapClass";if(t[r]){if(b(n).test(t[r]))return!1;t[r]+=" "+n}else t[r]=n;return!0}))})),removeLineClass:_i((function(t,e,n){return la(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(b(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:_i((function(t,e,n){return pa(this,t,e,n)})),removeLineWidget:function(t){t.clear()},markText:function(t,e,n){return ga(this,fe(this,t),fe(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 ga(this,t=fe(this,t),t,n,"bookmark")},findMarksAt:function(t){var e=[],n=Qt(this,(t=fe(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=fe(this,t),e=fe(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 l=a[s];null!=l.to&&i==t.line&&t.ch>=l.to||null==l.from&&i!=t.line||null!=l.from&&i==e.line&&l.from>=e.ch||n&&!n(l.marker)||r.push(l.marker.parent||l.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})),fe(this,oe(n,e))},indexFromPos:function(t){var e=(t=fe(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 Ca(Zt(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 Ca(Zt(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}],Sa(r,Ta(this)),r},unlinkDoc:function(t){if(t instanceof Ds&&(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),xa(Ta(this));break}if(t.history==this.history){var n=[t.id];yo(t,(function(t){return n.push(t.id)}),!0),t.history=new Eo(null),t.history.done=_o(this.history.done,n),t.history.undone=_o(this.history.undone,n)}},iterLinkedDocs:function(t){yo(this,t)},getMode:function(){return this.mode},getEditor:function(){return this.cm},splitLines:function(t){return this.lineSep?t.split(this.lineSep):_t(t)},lineSeparator:function(){return this.lineSep||"\n"},setDirection:_i((function(t){"rtl"!=t&&(t="ltr"),t!=this.direction&&(this.direction=t,this.iter((function(t){return t.order=null})),this.cm&&xo(this.cm))}))}),Ca.prototype.eachLine=Ca.prototype.iter;var ba=0;function ka(t){var e=this;if(wa(e),!yt(e,t)&&!jn(e.display,t)){Et(t),a&&(ba=+new Date);var n=Pr(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,l=function(){++s==i&&Ii(e,(function(){var t={from:n=fe(e.doc,n),to:n,text:e.doc.splitLines(o.filter((function(t){return null!=t})).join(e.doc.lineSeparator())),origin:"paste"};Jo(e.doc,t),Ho(e.doc,so(fe(e.doc,n),fe(e.doc,lo(t))))}))()},u=function(t,n){if(e.options.allowDropFileTypes&&-1==B(e.options.allowDropFileTypes,t.type))l();else{var r=new FileReader;r.onerror=function(){return l()},r.onload=function(){var t=r.result;/[\x00-\x08\x0e-\x1f]{2}/.test(t)||(o[n]=t),l()},r.readAsText(t)}},c=0;c<r.length;c++)u(r[c],c);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()),zo(e.doc,so(n,n)),f)for(var p=0;p<f.length;++p)ia(e.doc,"",f[p].anchor,f[p].head,"drag");e.replaceSelection(h,"around","paste"),e.display.input.focus()}}catch(t){}}}}function Oa(t,e){if(a&&(!t.state.draggingText||+new Date-ba<100))kt(e);else if(!yt(t,e)&&!jn(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)}}function Na(t,e){var n=Pr(t,e);if(n){var r=document.createDocumentFragment();Vr(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)),w(t.display.dragCursor,r)}}function wa(t){t.display.dragCursor&&(t.display.lineSpace.removeChild(t.display.dragCursor),t.display.dragCursor=null)}function La(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 Aa=!1;function Ra(){Aa||(Ia(),Aa=!0)}function Ia(){var t;dt(window,"resize",(function(){null==t&&(t=setTimeout((function(){t=null,La(Ma)}),100))})),dt(window,"blur",(function(){return La(Jr)}))}function Ma(t){var e=t.display;e.cachedCharWidth=e.cachedTextHeight=e.cachedPaddingH=null,e.scrollbarsClipped=!1,t.setSize()}for(var _a={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"},Pa=0;Pa<10;Pa++)_a[Pa+48]=_a[Pa+96]=String(Pa);for(var Ua=65;Ua<=90;Ua++)_a[Ua]=String.fromCharCode(Ua);for(var Da=1;Da<=12;Da++)_a[Da+111]=_a[Da+63235]="F"+Da;var Fa={};function Wa(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 Ba(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=q(n.split(" "),Wa),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 l=e[s];if(l){if(l!=a)throw new Error("Inconsistent bindings for "+s)}else e[s]=a}delete t[n]}for(var u in e)t[u]=e[u];return t}function Ha(t,e,n,r){var i=(e=Va(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 Ha(t,e.fallthrough,n,r);for(var o=0;o<e.fallthrough.length;o++){var a=Ha(t,e.fallthrough[o],n,r);if(a)return a}}}function Ga(t){var e="string"==typeof t?t:_a[t.keyCode];return"Ctrl"==e||"Alt"==e||"Shift"==e||"Mod"==e}function za(t,e,n){var r=t;return e.altKey&&"Alt"!=r&&(t="Alt-"+t),(E?e.metaKey:e.ctrlKey)&&"Ctrl"!=r&&(t="Ctrl-"+t),(E?e.ctrlKey:e.metaKey)&&"Mod"!=r&&(t="Cmd-"+t),!n&&e.shiftKey&&"Shift"!=r&&(t="Shift-"+t),t}function ja(t,e){if(h&&34==t.keyCode&&t.char)return!1;var n=_a[t.keyCode];return null!=n&&!t.altGraphKey&&(3==t.keyCode&&t.code&&(n=t.code),za(n,t,e))}function Va(t){return"string"==typeof t?Fa[t]:t}function Ka(t,e){for(var n=t.doc.sel.ranges,r=[],i=0;i<n.length;i++){for(var o=e(n[i]);r.length&&ae(o.from,X(r).to)<=0;){var a=r.pop();if(ae(a.from,o.from)<0){o.from=a.from;break}}r.push(o)}Ri(t,(function(){for(var e=r.length-1;e>=0;e--)ia(t.doc,"",r[e].from,r[e].to,"+delete");si(t)}))}function $a(t,e,n){var r=at(t.text,e+n,n);return r<0||r>t.text.length?null:r}function Ya(t,e,n){var r=$a(t,e.ch,n);return null==r?null:new oe(e.line,r,n<0?"after":"before")}function Xa(t,e,n,r,i){if(t){"rtl"==e.doc.direction&&(i=-i);var o=ft(n,e.doc.direction);if(o){var a,s=i<0?X(o):o[0],l=i<0==(1==s.level)?"after":"before";if(s.level>0||"rtl"==e.doc.direction){var u=nr(e,n);a=i<0?n.text.length-1:0;var c=rr(e,u,a).top;a=st((function(t){return rr(e,u,t).top==c}),i<0==(1==s.level)?s.from:s.to-1,a),"before"==l&&(a=$a(n,a,1))}else a=i<0?s.to:s.from;return new oe(r,a,l)}}return new oe(r,i<0?n.text.length:0,i<0?"before":"after")}function qa(t,e,n,r){var i=ft(e,t.doc.direction);if(!i)return Ya(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=ct(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 Ya(e,n,r);var s,l=function(t,n){return $a(e,t instanceof oe?t.ch:t,n)},u=function(n){return t.options.lineWrapping?(s=s||nr(t,e),br(t,e,s,n)):{begin:0,end:e.text.length}},c=u("before"==n.sticky?l(n,-1):n.ch);if("rtl"==t.doc.direction||1==a.level){var h=1==a.level==r<0,f=l(n,h?1:-1);if(null!=f&&(h?f<=a.to&&f<=c.end:f>=a.from&&f>=c.begin)){var p=h?"before":"after";return new oe(n.line,f,p)}}var d=function(t,e,r){for(var o=function(t,e){return e?new oe(n.line,l(t,1),"before"):new oe(n.line,t,"after")};t>=0&&t<i.length;t+=e){var a=i[t],s=e>0==(1!=a.level),u=s?r.begin:l(r.end,-1);if(a.from<=u&&u<a.to)return o(u,s);if(u=s?a.from:l(a.to,-1),r.begin<=u&&u<r.end)return o(u,s)}},m=d(o+r,r,c);if(m)return m;var g=r>0?c.end:l(c.begin,-1);return null==g||r>0&&g==e.text.length||!(m=d(r>0?0:i.length-1,r,u(g)))?null:m}Fa.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"},Fa.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"},Fa.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},Fa.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"]},Fa.default=y?Fa.macDefault:Fa.pcDefault;var Qa={selectAll:qo,singleSelection:function(t){return t.setSelection(t.getCursor("anchor"),t.getCursor("head"),z)},killLine:function(t){return Ka(t,(function(e){if(e.empty()){var n=Qt(t.doc,e.head.line).text.length;return e.head.ch==n&&e.head.line<t.lastLine()?{from:e.head,to:oe(e.head.line+1,0)}:{from:e.head,to:oe(e.head.line,n)}}return{from:e.from(),to:e.to()}}))},deleteLine:function(t){return Ka(t,(function(e){return{from:oe(e.from().line,0),to:fe(t.doc,oe(e.to().line+1,0))}}))},delLineLeft:function(t){return Ka(t,(function(t){return{from:oe(t.from().line,0),to:t.from()}}))},delWrappedLineLeft:function(t){return Ka(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 Ka(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(oe(t.firstLine(),0))},goDocEnd:function(t){return t.extendSelection(oe(t.lastLine()))},goLineStart:function(t){return t.extendSelectionsBy((function(e){return Ja(t,e.head.line)}),{origin:"+move",bias:1})},goLineStartSmart:function(t){return t.extendSelectionsBy((function(e){return ts(t,e.head)}),{origin:"+move",bias:1})},goLineEnd:function(t){return t.extendSelectionsBy((function(e){return Za(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")}),V)},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")}),V)},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/)?ts(t,e.head):r}),V)},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 Ri(t,(function(){for(var e=t.listSelections(),n=[],r=0;r<e.length;r++)if(e[r].empty()){var i=e[r].head,o=Qt(t.doc,i.line).text;if(o)if(i.ch==o.length&&(i=new oe(i.line,i.ch-1)),i.ch>0)i=new oe(i.line,i.ch+1),t.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),oe(i.line,i.ch-2),i,"+transpose");else if(i.line>t.doc.first){var a=Qt(t.doc,i.line-1).text;a&&(i=new oe(i.line,1),t.replaceRange(o.charAt(0)+t.doc.lineSeparator()+a.charAt(a.length-1),oe(i.line-1,a.length-1),i,"+transpose"))}n.push(new oo(i,i))}t.setSelections(n)}))},newlineAndIndent:function(t){return Ri(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);si(t)}))},openLine:function(t){return t.replaceSelection("\n","start")},toggleOverwrite:function(t){return t.toggleOverwrite()}};function Ja(t,e){var n=Qt(t.doc,e),r=Je(n);return r!=n&&(e=ee(r)),Xa(!0,t,r,e,1)}function Za(t,e){var n=Qt(t.doc,e),r=Ze(n);return r!=n&&(e=ee(r)),Xa(!0,t,n,e,-1)}function ts(t,e){var n=Ja(t,e.line),r=Qt(t.doc,n.line),i=ft(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 oe(n.line,a?0:o,n.sticky)}return n}function es(t,e,n){if("string"==typeof e&&!(e=Qa[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)!=G}finally{t.display.shift=r,t.state.suppressEdits=!1}return i}function ns(t,e,n){for(var r=0;r<t.state.keyMaps.length;r++){var i=Ha(e,t.state.keyMaps[r],n,t);if(i)return i}return t.options.extraKeys&&Ha(e,t.options.extraKeys,n,t)||Ha(e,t.options.keyMap,n,t)}var rs=new W;function is(t,e,n,r){var i=t.state.keySeq;if(i){if(Ga(e))return"handled";if(/\'$/.test(e)?t.state.keySeq=null:rs.set(50,(function(){t.state.keySeq==i&&(t.state.keySeq=null,t.display.input.reset())})),os(t,i+" "+e,n,r))return!0}return os(t,e,n,r)}function os(t,e,n,r){var i=ns(t,e,r);return"multi"==i&&(t.state.keySeq=e),"handled"==i&&Ln(t,"keyHandled",t,e,n),"handled"!=i&&"multi"!=i||(Et(n),Yr(t)),!!i}function as(t,e){var n=ja(e,!0);return!!n&&(e.shiftKey&&!t.state.keySeq?is(t,"Shift-"+n,e,(function(e){return es(t,e,!0)}))||is(t,n,e,(function(e){if("string"==typeof e?/^go[A-Z]/.test(e):e.motion)return es(t,e)})):is(t,n,e,(function(e){return es(t,e)})))}function ss(t,e,n){return is(t,"'"+n+"'",e,(function(e){return es(t,e,!0)}))}var ls=null;function us(t){var e=this;if(!(t.target&&t.target!=e.display.input.getField()||(e.curOp.focus=I(),yt(e,t)))){a&&s<11&&27==t.keyCode&&(t.returnValue=!1);var r=t.keyCode;e.display.shift=16==r||t.shiftKey;var i=as(e,t);h&&(ls=i?r:null,i||88!=r||Ut||!(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)||cs(e)}}function cs(t){var e=t.display.lineDiv;function n(t){18!=t.keyCode&&t.altKey||(O(e,"CodeMirror-crosshair"),gt(document,"keyup",n),gt(document,"mouseover",n))}M(e,"CodeMirror-crosshair"),dt(document,"keyup",n),dt(document,"mouseover",n)}function hs(t){16==t.keyCode&&(this.doc.sel.shift=!1),yt(this,t)}function fs(t){var e=this;if(!(t.target&&t.target!=e.display.input.getField()||jn(e.display,t)||yt(e,t)||t.ctrlKey&&!t.altKey||y&&t.metaKey)){var n=t.keyCode,r=t.charCode;if(h&&n==ls)return ls=null,void Et(t);if(!h||t.which&&!(t.which<10)||!as(e,t)){var i=String.fromCharCode(null==r?n:r);"\b"!=i&&(ss(e,t,i)||e.display.input.onKeyPress(t))}}}var ps,ds,ms=400,gs=function(t,e,n){this.time=t,this.pos=e,this.button=n};function vs(t,e){var n=+new Date;return ds&&ds.compare(n,t,e)?(ps=ds=null,"triple"):ps&&ps.compare(n,t,e)?(ds=new gs(n,t,e),ps=null,"double"):(ps=new gs(n,t,e),ds=null,"single")}function ys(t){var e=this,n=e.display;if(!(yt(e,t)||n.activeTouch&&n.input.supportsTouch()))if(n.input.ensurePolled(),n.shift=t.shiftKey,jn(n,t))l||(n.scroller.draggable=!1,setTimeout((function(){return n.scroller.draggable=!0}),100));else if(!Ns(e,t)){var r=Pr(e,t),i=Nt(t),o=r?vs(r,i):"single";window.focus(),1==i&&e.state.selectingText&&e.state.selectingText(t),r&&Ts(e,i,r,o,t)||(1==i?r?xs(e,r,o,t):Ot(t)==n.scroller&&Et(t):2==i?(r&&Uo(e.doc,r),setTimeout((function(){return n.input.focus()}),20)):3==i&&(C?e.display.input.onContextMenu(t):qr(e)))}}function Ts(t,e,n,r,i){var o="Click";return"double"==r?o="Double"+o:"triple"==r&&(o="Triple"+o),is(t,za(o=(1==e?"Left":2==e?"Middle":"Right")+o,i),i,(function(e){if("string"==typeof e&&(e=Qa[e]),!e)return!1;var r=!1;try{t.isReadOnly()&&(t.state.suppressEdits=!0),r=e(t,n)!=G}finally{t.state.suppressEdits=!1}return r}))}function Ss(t,e,n){var r=t.getOption("configureMouse"),i=r?r(t,e,n):{};if(null==i.unit){var o=T?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}function xs(t,e,n,r){a?setTimeout(U(Xr,t),0):t.curOp.focus=I();var i,o=Ss(t,n,r),s=t.doc.sel;t.options.dragDrop&&At&&!t.isReadOnly()&&"single"==n&&(i=s.contains(e))>-1&&(ae((i=s.ranges[i]).from(),e)<0||e.xRel>0)&&(ae(i.to(),e)>0||e.xRel<0)?Es(t,r,e,o):bs(t,r,e,o)}function Es(t,e,n,r){var i=t.display,o=!1,u=Ii(t,(function(e){l&&(i.scroller.draggable=!1),t.state.draggingText=!1,t.state.delayingBlurEvent&&(t.hasFocus()?t.state.delayingBlurEvent=!1:qr(t)),gt(i.wrapper.ownerDocument,"mouseup",u),gt(i.wrapper.ownerDocument,"mousemove",c),gt(i.scroller,"dragstart",h),gt(i.scroller,"drop",u),o||(Et(e),r.addNew||Uo(t.doc,n,null,null,r.extend),l&&!f||a&&9==s?setTimeout((function(){i.wrapper.ownerDocument.body.focus({preventScroll:!0}),i.input.focus()}),20):i.input.focus())})),c=function(t){o=o||Math.abs(e.clientX-t.clientX)+Math.abs(e.clientY-t.clientY)>=10},h=function(){return o=!0};l&&(i.scroller.draggable=!0),t.state.draggingText=u,u.copy=!r.moveOnDrag,dt(i.wrapper.ownerDocument,"mouseup",u),dt(i.wrapper.ownerDocument,"mousemove",c),dt(i.scroller,"dragstart",h),dt(i.scroller,"drop",u),t.state.delayingBlurEvent=!0,setTimeout((function(){return i.input.focus()}),20),i.scroller.dragDrop&&i.scroller.dragDrop()}function Cs(t,e,n){if("char"==n)return new oo(e,e);if("word"==n)return t.findWordAt(e);if("line"==n)return new oo(oe(e.line,0),fe(t.doc,oe(e.line+1,0)));var r=n(t,e);return new oo(r.from,r.to)}function bs(t,e,n,r){a&&qr(t);var i=t.display,o=t.doc;Et(e);var s,l,u=o.sel,c=u.ranges;if(r.addNew&&!r.extend?(l=o.sel.contains(n),s=l>-1?c[l]:new oo(n,n)):(s=o.sel.primary(),l=o.sel.primIndex),"rectangle"==r.unit)r.addNew||(s=new oo(n,n)),n=Pr(t,e,!0,!0),l=-1;else{var h=Cs(t,n,r.unit);s=r.extend?Po(s,h.anchor,h.head,r.extend):h}r.addNew?-1==l?(l=c.length,Go(o,ao(t,c.concat([s]),l),{scroll:!1,origin:"*mouse"})):c.length>1&&c[l].empty()&&"char"==r.unit&&!r.extend?(Go(o,ao(t,c.slice(0,l).concat(c.slice(l+1)),0),{scroll:!1,origin:"*mouse"}),u=o.sel):Fo(o,l,s,j):(l=0,Go(o,new io([s],0),j),u=o.sel);var f=n;function p(e){if(0!=ae(f,e))if(f=e,"rectangle"==r.unit){for(var i=[],a=t.options.tabSize,c=F(Qt(o,n.line).text,n.ch,a),h=F(Qt(o,e.line).text,e.ch,a),p=Math.min(c,h),d=Math.max(c,h),m=Math.min(n.line,e.line),g=Math.min(t.lastLine(),Math.max(n.line,e.line));m<=g;m++){var v=Qt(o,m).text,y=K(v,p,a);p==d?i.push(new oo(oe(m,y),oe(m,y))):v.length>y&&i.push(new oo(oe(m,y),oe(m,K(v,d,a))))}i.length||i.push(new oo(n,n)),Go(o,ao(t,u.ranges.slice(0,l).concat(i),l),{origin:"*mouse",scroll:!1}),t.scrollIntoView(e)}else{var T,S=s,x=Cs(t,e,r.unit),E=S.anchor;ae(x.anchor,E)>0?(T=x.head,E=ce(S.from(),x.anchor)):(T=x.anchor,E=ue(S.to(),x.head));var C=u.ranges.slice(0);C[l]=ks(t,new oo(fe(o,E),T)),Go(o,ao(t,C,l),j)}}var d=i.wrapper.getBoundingClientRect(),m=0;function g(e){var n=++m,a=Pr(t,e,!0,"rectangle"==r.unit);if(a)if(0!=ae(a,f)){t.curOp.focus=I(),p(a);var s=ei(i,o);(a.line>=s.to||a.line<s.from)&&setTimeout(Ii(t,(function(){m==n&&g(e)})),150)}else{var l=e.clientY<d.top?-20:e.clientY>d.bottom?20:0;l&&setTimeout(Ii(t,(function(){m==n&&(i.scroller.scrollTop+=l,g(e))})),50)}}function v(e){t.state.selectingText=!1,m=1/0,e&&(Et(e),i.input.focus()),gt(i.wrapper.ownerDocument,"mousemove",y),gt(i.wrapper.ownerDocument,"mouseup",T),o.history.lastSelOrigin=null}var y=Ii(t,(function(t){0!==t.buttons&&Nt(t)?g(t):v(t)})),T=Ii(t,v);t.state.selectingText=T,dt(i.wrapper.ownerDocument,"mousemove",y),dt(i.wrapper.ownerDocument,"mouseup",T)}function ks(t,e){var n=e.anchor,r=e.head,i=Qt(t.doc,n.line);if(0==ae(n,r)&&n.sticky==r.sticky)return e;var o=ft(i);if(!o)return e;var a=ct(o,n.ch,n.sticky),s=o[a];if(s.from!=n.ch&&s.to!=n.ch)return e;var l,u=a+(s.from==n.ch==(1!=s.level)?0:1);if(0==u||u==o.length)return e;if(r.line!=n.line)l=(r.line-n.line)*("ltr"==t.doc.direction?1:-1)>0;else{var c=ct(o,r.ch,r.sticky),h=c-a||(r.ch-n.ch)*(1==s.level?-1:1);l=c==u-1||c==u?h<0:h>0}var f=o[u+(l?-1:0)],p=l==(1==f.level),d=p?f.from:f.to,m=p?"after":"before";return n.ch==d&&n.sticky==m?e:new oo(new oe(n.line,d,m),r)}function Os(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&&Et(e);var a=t.display,s=a.lineDiv.getBoundingClientRect();if(o>s.bottom||!St(t,n))return bt(e);o-=s.top-a.viewOffset;for(var l=0;l<t.display.gutterSpecs.length;++l){var u=a.gutters.childNodes[l];if(u&&u.getBoundingClientRect().right>=i)return vt(t,n,t,ne(t.doc,o),t.display.gutterSpecs[l].className,e),bt(e)}}function Ns(t,e){return Os(t,e,"gutterClick",!0)}function ws(t,e){jn(t.display,e)||Ls(t,e)||yt(t,e,"contextmenu")||C||t.display.input.onContextMenu(e)}function Ls(t,e){return!!St(t,"gutterContextMenu")&&Os(t,e,"gutterContextMenu",!1)}function As(t){t.display.wrapper.className=t.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+t.options.theme.replace(/(^|\s)\s*/g," cm-s-"),fr(t)}gs.prototype.compare=function(t,e,n){return this.time+ms>t&&0==ae(e,this.pos)&&n==this.button};var Rs={toString:function(){return"CodeMirror.Init"}},Is={},Ms={};function _s(t){var e=t.optionHandlers;function n(n,r,i,o){t.defaults[n]=r,i&&(e[n]=o?function(t,e,n){n!=Rs&&i(t,e,n)}:i)}t.defineOption=n,t.Init=Rs,n("value","",(function(t,e){return t.setValue(e)}),!0),n("mode",null,(function(t,e){t.doc.modeOption=e,po(t)}),!0),n("indentUnit",2,po,!0),n("indentWithTabs",!1),n("smartIndent",!0),n("tabSize",4,(function(t){mo(t),fr(t),Dr(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(oe(r,o))}r++}));for(var i=n.length-1;i>=0;i--)ia(t.doc,e,n[i],oe(n[i].line,n[i].ch+e.length))}})),n("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\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!=Rs&&t.refresh()})),n("specialCharPlaceholder",gn,(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",!S),n("wholeLineUpdateBefore",!0),n("theme","default",(function(t){As(t),Qi(t)}),!0),n("keyMap","default",(function(t,e,n){var r=Va(e),i=n!=Rs&&Va(n);i&&i.detach&&i.detach(t,r),r.attach&&r.attach(t,i||null)})),n("extraKeys",null),n("configureMouse",null),n("lineWrapping",!1,Us,!0),n("gutters",[],(function(t,e){t.display.gutterSpecs=Xi(e,t.options.lineNumbers),Qi(t)}),!0),n("fixedGutter",!0,(function(t,e){t.display.gutters.style.left=e?Ir(t.display)+"px":"0",t.refresh()}),!0),n("coverGutterNextToScrollbar",!1,(function(t){return yi(t)}),!0),n("scrollbarStyle","native",(function(t){xi(t),yi(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=Xi(t.options.gutters,e),Qi(t)}),!0),n("firstLineNumber",1,Qi,!0),n("lineNumberFormatter",(function(t){return t}),Qi,!0),n("showCursorWhenSelecting",!1,zr,!0),n("resetSelectionOnContextMenu",!0),n("lineWiseCopyCut",!0),n("pasteLinesPerSelection",!0),n("selectionsMayTouch",!1),n("readOnly",!1,(function(t,e){"nocursor"==e&&(Jr(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,Ps),n("allowDropFileTypes",null),n("cursorBlinkRate",530),n("cursorScrollMargin",0),n("cursorHeight",1,zr,!0),n("singleCursorHeightPerLine",!0,zr,!0),n("workTime",100),n("workDelay",100),n("flattenSpans",!0,mo,!0),n("addModeClass",!1,mo,!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,mo,!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)}function Ps(t,e,n){if(!e!=!(n&&n!=Rs)){var r=t.display.dragFunctions,i=e?dt:gt;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 Us(t){t.options.lineWrapping?(M(t.display.wrapper,"CodeMirror-wrap"),t.display.sizer.style.minWidth="",t.display.sizerWidth=null):(O(t.display.wrapper,"CodeMirror-wrap"),ln(t)),_r(t),Dr(t),fr(t),setTimeout((function(){return yi(t)}),100)}function Ds(t,e){var n=this;if(!(this instanceof Ds))return new Ds(t,e);this.options=e=e?D(e):{},D(Is,e,!1);var r=e.value;"string"==typeof r?r=new Ca(r,e.mode,null,e.lineSeparator,e.direction):e.mode&&(r.modeOption=e.mode),this.doc=r;var i=new Ds.inputStyles[e.inputStyle](this),o=this.display=new Ji(t,r,i,e);for(var u in o.wrapper.CodeMirror=this,As(this),e.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),xi(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 W,keySeq:null,specialChars:null},e.autofocus&&!v&&o.input.focus(),a&&s<11&&setTimeout((function(){return n.display.input.reset(!0)}),20),Fs(this),Ra(),Ci(this),this.curOp.forceUpdate=!0,To(this,r),e.autofocus&&!v||this.hasFocus()?setTimeout((function(){n.hasFocus()&&!n.state.focused&&Qr(n)}),20):Jr(this),Ms)Ms.hasOwnProperty(u)&&Ms[u](this,e[u],Rs);Yi(this),e.finishInit&&e.finishInit(this);for(var c=0;c<Ws.length;++c)Ws[c](this);bi(this),l&&e.lineWrapping&&"optimizelegibility"==getComputedStyle(o.lineDiv).textRendering&&(o.lineDiv.style.textRendering="auto")}function Fs(t){var e=t.display;dt(e.scroller,"mousedown",Ii(t,ys)),dt(e.scroller,"dblclick",a&&s<11?Ii(t,(function(e){if(!yt(t,e)){var n=Pr(t,e);if(n&&!Ns(t,e)&&!jn(t.display,e)){Et(e);var r=t.findWordAt(n);Uo(t.doc,r.anchor,r.head)}}})):function(e){return yt(t,e)||Et(e)}),dt(e.scroller,"contextmenu",(function(e){return ws(t,e)})),dt(e.input.getField(),"contextmenu",(function(n){e.scroller.contains(n.target)||ws(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){if(1!=t.touches.length)return!1;var e=t.touches[0];return e.radiusX<=1&&e.radiusY<=1}function l(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}dt(e.scroller,"touchstart",(function(i){if(!yt(t,i)&&!o(i)&&!Ns(t,i)){e.input.ensurePolled(),clearTimeout(n);var a=+new Date;e.activeTouch={start:a,moved:!1,prev:a-r.end<=300?r:null},1==i.touches.length&&(e.activeTouch.left=i.touches[0].pageX,e.activeTouch.top=i.touches[0].pageY)}})),dt(e.scroller,"touchmove",(function(){e.activeTouch&&(e.activeTouch.moved=!0)})),dt(e.scroller,"touchend",(function(n){var r=e.activeTouch;if(r&&!jn(e,n)&&null!=r.left&&!r.moved&&new Date-r.start<300){var o,a=t.coordsChar(e.activeTouch,"page");o=!r.prev||l(r,r.prev)?new oo(a,a):!r.prev.prev||l(r,r.prev.prev)?t.findWordAt(a):new oo(oe(a.line,0),fe(t.doc,oe(a.line+1,0))),t.setSelection(o.anchor,o.head),t.focus(),Et(n)}i()})),dt(e.scroller,"touchcancel",i),dt(e.scroller,"scroll",(function(){e.scroller.clientHeight&&(fi(t,e.scroller.scrollTop),di(t,e.scroller.scrollLeft,!0),vt(t,"scroll",t))})),dt(e.scroller,"mousewheel",(function(e){return ro(t,e)})),dt(e.scroller,"DOMMouseScroll",(function(e){return ro(t,e)})),dt(e.wrapper,"scroll",(function(){return e.wrapper.scrollTop=e.wrapper.scrollLeft=0})),e.dragFunctions={enter:function(e){yt(t,e)||kt(e)},over:function(e){yt(t,e)||(Na(t,e),kt(e))},start:function(e){return Oa(t,e)},drop:Ii(t,ka),leave:function(e){yt(t,e)||wa(t)}};var u=e.input.getField();dt(u,"keyup",(function(e){return hs.call(t,e)})),dt(u,"keydown",Ii(t,us)),dt(u,"keypress",Ii(t,fs)),dt(u,"focus",(function(e){return Qr(t,e)})),dt(u,"blur",(function(e){return Jr(t,e)}))}Ds.defaults=Is,Ds.optionHandlers=Ms;var Ws=[];function Bs(t,e,n,r){var i,o=t.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?i=Te(t,e).state:n="prev");var a=t.options.tabSize,s=Qt(o,e),l=F(s.text,null,a);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(r||/\S/.test(s.text)){if("smart"==n&&((u=o.mode.indent(i,s.text.slice(c.length),s.text))==G||u>150)){if(!r)return;n="prev"}}else u=0,n="not";"prev"==n?u=e>o.first?F(Qt(o,e-1).text,null,a):0:"add"==n?u=l+t.options.indentUnit:"subtract"==n?u=l-t.options.indentUnit:"number"==typeof n&&(u=l+n),u=Math.max(0,u);var h="",f=0;if(t.options.indentWithTabs)for(var p=Math.floor(u/a);p;--p)f+=a,h+="\t";if(f<u&&(h+=Y(u-f)),h!=c)return ia(o,h,oe(e,0),oe(e,c.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<c.length){var g=oe(e,c.length);Fo(o,d,new oo(g,g));break}}}Ds.defineInitHook=function(t){return Ws.push(t)};var Hs=null;function Gs(t){Hs=t}function zs(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,l=_t(e),u=null;if(s&&r.ranges.length>1)if(Hs&&Hs.text.join("\n")==e){if(r.ranges.length%Hs.text.length==0){u=[];for(var c=0;c<Hs.text.length;c++)u.push(o.splitLines(Hs.text[c]))}}else l.length==r.ranges.length&&t.options.pasteLinesPerSelection&&(u=q(l,(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=oe(d.line,d.ch-n):t.state.overwrite&&!s?m=oe(m.line,Math.min(Qt(o,m.line).text.length,m.ch+X(l).length)):s&&Hs&&Hs.lineWise&&Hs.text.join("\n")==l.join("\n")&&(d=m=oe(d.line,0)));var g={from:d,to:m,text:u?u[f%u.length]:l,origin:i||(s?"paste":t.state.cutIncoming>a?"cut":"+input")};Jo(t.doc,g),Ln(t,"inputRead",t,g)}e&&!s&&Vs(t,e),si(t),t.curOp.updateInput<2&&(t.curOp.updateInput=h),t.curOp.typing=!0,t.state.pasteIncoming=t.state.cutIncoming=-1}function js(t,e){var n=t.clipboardData&&t.clipboardData.getData("Text");if(n)return t.preventDefault(),e.isReadOnly()||e.options.disableInput||Ri(e,(function(){return zs(e,n,0,null,"paste")})),!0}function Vs(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=Bs(t,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Qt(t.doc,i.head.line).text.slice(0,i.head.ch))&&(a=Bs(t,i.head.line,"smart"));a&&Ln(t,"electricInput",t,i.head.line)}}}function Ks(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:oe(i,0),head:oe(i+1,0)};n.push(o),e.push(t.getRange(o.anchor,o.head))}return{text:e,ranges:n}}function $s(t,e,n,r){t.setAttribute("autocorrect",n?"":"off"),t.setAttribute("autocapitalize",r?"":"off"),t.setAttribute("spellcheck",!!e)}function Ys(){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 l?t.style.width="1000px":t.setAttribute("wrap","off"),m&&(t.style.border="1px solid black"),$s(t),e}function Xs(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)&&Ii(this,e[t])(this,n,i),vt(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"](Va(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:Mi((function(e,n){var r=e.token?e:t.getMode(this.options,e);if(r.startState)throw new Error("Overlays may not be stateful.");Q(this.state.overlays,{mode:r,modeSpec:e,opaque:n&&n.opaque,priority:n&&n.priority||0},(function(t){return t.priority})),this.state.modeGen++,Dr(this)})),removeOverlay:Mi((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 Dr(this)}})),indentLine:Mi((function(t,e,n){"string"!=typeof e&&"number"!=typeof e&&(e=null==e?this.options.smartIndent?"smart":"prev":e?"add":"subtract"),re(this.doc,t)&&Bs(this,t,e,n)})),indentSelection:Mi((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&&(Bs(this,i.head.line,t,!0),n=i.head.line,r==this.doc.sel.primIndex&&si(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 l=s;l<n;++l)Bs(this,l,t);var u=this.doc.sel.ranges;0==o.ch&&e.length==u.length&&u[r].from().ch>0&&Fo(this.doc,r,new oo(o,u[r].to()),z)}}})),getTokenAt:function(t,e){return be(this,t,e)},getLineTokens:function(t,e){return be(this,oe(t),e,!0)},getTokenTypeAt:function(t){t=fe(this.doc,t);var e,n=ye(this,Qt(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 l=0;l<i._global.length;l++){var u=i._global[l];u.pred(o,this)&&-1==B(r,u.val)&&r.push(u.val)}return r},getStateAfter:function(t,e){var n=this.doc;return Te(this,(t=he(n,null==t?n.first+n.size-1:t))+1,e).state},cursorCoords:function(t,e){var n=this.doc.sel.primary();return Tr(this,null==t?n.head:"object"==typeof t?fe(this.doc,t):t?n.from():n.to(),e||"page")},charCoords:function(t,e){return yr(this,fe(this.doc,t),e||"page")},coordsChar:function(t,e){return Er(this,(t=vr(this,t,e||"page")).left,t.top)},lineAtHeight:function(t,e){return t=vr(this,{top:t,left:0},e||"page").top,ne(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=Qt(this.doc,t)}else r=t;return gr(this,r,{top:0,left:0},e||"page",n||i).top+(i?this.doc.height-an(r):0)},defaultTextHeight:function(){return Lr(this.display)},defaultCharWidth:function(){return Ar(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(t,e,n,r,i){var o=this.display,a=(t=Tr(this,fe(this.doc,t))).bottom,s=t.left;if(e.style.position="absolute",e.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(e),o.sizer.appendChild(e),"over"==r)a=t.top;else if("above"==r||"near"==r){var l=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==r||t.bottom+e.offsetHeight>l)&&t.top>e.offsetHeight?a=t.top-e.offsetHeight:t.bottom+e.offsetHeight<=l&&(a=t.bottom),s+e.offsetWidth>u&&(s=u-e.offsetWidth)}e.style.top=a+"px",e.style.left=e.style.right="","right"==i?(s=o.sizer.clientWidth-e.offsetWidth,e.style.right="0px"):("left"==i?s=0:"middle"==i&&(s=(o.sizer.clientWidth-e.offsetWidth)/2),e.style.left=s+"px"),n&&ii(this,{left:s,top:a,right:s+e.offsetWidth,bottom:a+e.offsetHeight})},triggerOnKeyDown:Mi(us),triggerOnKeyPress:Mi(fs),triggerOnKeyUp:hs,triggerOnMouseDown:Mi(ys),execCommand:function(t){if(Qa.hasOwnProperty(t))return Qa[t].call(null,this)},triggerElectric:Mi((function(t){Vs(this,t)})),findPosH:function(t,e,n,r){var i=1;e<0&&(i=-1,e=-e);for(var o=fe(this.doc,t),a=0;a<e&&!(o=qs(this.doc,o,i,n,r)).hitSide;++a);return o},moveH:Mi((function(t,e){var n=this;this.extendSelectionsBy((function(r){return n.display.shift||n.doc.extend||r.empty()?qs(n.doc,r.head,t,e,n.options.rtlMoveVisually):t<0?r.from():r.to()}),V)})),deleteH:Mi((function(t,e){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):Ka(this,(function(n){var i=qs(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=fe(this.doc,t),s=0;s<e;++s){var l=Tr(this,a,"div");if(null==o?o=l.left:l.left=o,(a=Qs(this,l,i,n)).hitSide)break}return a},moveV:Mi((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=Tr(n,a.head,"div");null!=a.goalColumn&&(s.left=a.goalColumn),i.push(s.left);var l=Qs(n,s,t,e);return"page"==e&&a==r.sel.primary()&&ai(n,yr(n,l,"div").top-s.top),l}),V),i.length)for(var a=0;a<r.sel.ranges.length;a++)r.sel.ranges[a].goalColumn=i[a]})),findWordAt:function(t){var e=Qt(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=nt(o,i)?function(t){return nt(t,i)}:/\s/.test(o)?function(t){return/\s/.test(t)}:function(t){return!/\s/.test(t)&&!nt(t)};n>0&&a(e.charAt(n-1));)--n;for(;r<e.length&&a(e.charAt(r));)++r}return new oo(oe(t.line,n),oe(t.line,r))},toggleOverwrite:function(t){null!=t&&t==this.state.overwrite||((this.state.overwrite=!this.state.overwrite)?M(this.display.cursorDiv,"CodeMirror-overwrite"):O(this.display.cursorDiv,"CodeMirror-overwrite"),vt(this,"overwriteToggle",this,this.state.overwrite))},hasFocus:function(){return this.display.input.getField()==I()},isReadOnly:function(){return!(!this.options.readOnly&&!this.doc.cantEdit)},scrollTo:Mi((function(t,e){li(this,t,e)})),getScrollInfo:function(){var t=this.display.scroller;return{left:t.scrollLeft,top:t.scrollTop,height:t.scrollHeight-Yn(this)-this.display.barHeight,width:t.scrollWidth-Yn(this)-this.display.barWidth,clientHeight:qn(this),clientWidth:Xn(this)}},scrollIntoView:Mi((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:oe(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?ui(this,t):hi(this,t.from,t.to,t.margin)})),setSize:Mi((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&&hr(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,vt(this,"refresh",this)})),operation:function(t){return Ri(this,t)},startOperation:function(){return Ci(this)},endOperation:function(){return bi(this)},refresh:Mi((function(){var t=this.display.cachedTextHeight;Dr(this),this.curOp.forceUpdate=!0,fr(this),li(this,this.doc.scrollLeft,this.doc.scrollTop),Vi(this.display),(null==t||Math.abs(t-Lr(this.display))>.5||this.options.lineWrapping)&&_r(this),vt(this,"refresh",this)})),swapDoc:Mi((function(t){var e=this.doc;return e.cm=null,this.state.selectingText&&this.state.selectingText(),To(this,t),fr(this),this.display.input.reset(),li(this,t.scrollLeft,t.scrollTop),this.curOp.forceScroll=!0,Ln(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}},xt(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})}}function qs(t,e,n,r,i){var o=e,a=n,s=Qt(t,e.line),l=i&&"rtl"==t.direction?-n:n;function u(){var n=e.line+l;return!(n<t.first||n>=t.first+t.size)&&(e=new oe(n,e.ch,e.sticky),s=Qt(t,n))}function c(o){var a;if("codepoint"==r){var c=s.text.charCodeAt(e.ch+(n>0?0:-1));if(isNaN(c))a=null;else{var h=n>0?c>=55296&&c<56320:c>=56320&&c<57343;a=new oe(e.line,Math.max(0,Math.min(s.text.length,e.ch+n*(h?2:1))),-n)}}else a=i?qa(t.cm,s,e,n):Ya(s,e,n);if(null==a){if(o||!u())return!1;e=Xa(i,t.cm,s,e.line,l)}else e=a;return!0}if("char"==r||"codepoint"==r)c();else if("column"==r)c(!0);else if("word"==r||"group"==r)for(var h=null,f="group"==r,p=t.cm&&t.cm.getHelper(e,"wordChars"),d=!0;!(n<0)||c(!d);d=!1){var m=s.text.charAt(e.ch)||"\n",g=nt(m,p)?"w":f&&"\n"==m?"n":!f||/\s/.test(m)?null:"p";if(!f||d||g||(g="s"),h&&h!=g){n<0&&(n=1,c(),e.sticky="after");break}if(g&&(h=g),n>0&&!c(!d))break}var v=Yo(t,e,o,a,!0);return se(o,v)&&(v.hitSide=!0),v}function Qs(t,e,n,r){var i,o,a=t.doc,s=e.left;if("page"==r){var l=Math.min(t.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),u=Math.max(l-.5*Lr(t.display),3);i=(n>0?e.bottom:e.top)+n*u}else"line"==r&&(i=n>0?e.bottom+3:e.top-3);for(;(o=Er(t,s,i)).outside;){if(n<0?i<=0:i>=a.height){o.hitSide=!0;break}i+=5*n}return o}var Js=function(t){this.cm=t,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new W,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function Zs(t,e){var n=er(t,e.line);if(!n||n.hidden)return null;var r=Qt(t.doc,e.line),i=Jn(n,r,e.line),o=ft(r,t.doc.direction),a="left";o&&(a=ct(o,e.ch)%2?"right":"left");var s=ar(i.map,e.ch,a);return s.offset="right"==s.collapse?s.end:s.start,s}function tl(t){for(var e=t;e;e=e.parentNode)if(/CodeMirror-gutter-wrapper/.test(e.className))return!0;return!1}function el(t,e){return e&&(t.bad=!0),t}function nl(t,e,n,r,i){var o="",a=!1,s=t.doc.lineSeparator(),l=!1;function u(t){return function(e){return e.id==t}}function c(){a&&(o+=s,l&&(o+=s),a=l=!1)}function h(t){t&&(c(),o+=t)}function f(e){if(1==e.nodeType){var n=e.getAttribute("cm-text");if(n)return void h(n);var o,p=e.getAttribute("cm-marker");if(p){var d=t.findMarks(oe(r,0),oe(i+1,0),u(+p));return void(d.length&&(o=d[0].find(0))&&h(Jt(t.doc,o.from,o.to).join(s)))}if("false"==e.getAttribute("contenteditable"))return;var m=/^(pre|div|p|li|table|br)$/i.test(e.nodeName);if(!/^br$/i.test(e.nodeName)&&0==e.textContent.length)return;m&&c();for(var g=0;g<e.childNodes.length;g++)f(e.childNodes[g]);/^(pre|p)$/i.test(e.nodeName)&&(l=!0),m&&(a=!0)}else 3==e.nodeType&&h(e.nodeValue.replace(/\u200b/g,"").replace(/\u00a0/g," "))}for(;f(e),e!=n;)e=e.nextSibling,l=!1;return o}function rl(t,e,n){var r;if(e==t.display.lineDiv){if(!(r=t.display.lineDiv.childNodes[n]))return el(t.clipPos(oe(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 il(o,e,n)}}function il(t,e,n){var r=t.text.firstChild,i=!1;if(!e||!R(r,e))return el(oe(ee(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 el(oe(ee(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 l=t.measure,u=l.maps;function c(e,n,r){for(var i=-1;i<(u?u.length:0);i++)for(var o=i<0?l.map:u[i],a=0;a<o.length;a+=3){var s=o[a+2];if(s==e||s==n){var c=ee(i<0?t.line:t.rest[i]),h=o[a]+r;return(r<0||s!=e)&&(h=o[a+(r?1:0)]),oe(c,h)}}}var h=c(a,s,n);if(h)return el(h,i);for(var f=s.nextSibling,p=a?a.nodeValue.length-n:0;f;f=f.nextSibling){if(h=c(f,f.firstChild,0))return el(oe(h.line,h.ch-p),i);p+=f.textContent.length}for(var d=s.previousSibling,m=n;d;d=d.previousSibling){if(h=c(d,d.firstChild,-1))return el(oe(h.line,h.ch+m),i);m+=d.textContent.length}}Js.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)&&!yt(r,t)){if(r.somethingSelected())Gs({lineWise:!1,text:r.getSelections()}),"cut"==t.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var e=Ks(r);Gs({lineWise:!0,text:e.text}),"cut"==t.type&&r.operation((function(){r.setSelections(e.ranges,0,z),r.replaceSelection("",null,"cut")}))}if(t.clipboardData){t.clipboardData.clearData();var a=Hs.text.join("\n");if(t.clipboardData.setData("Text",a),t.clipboardData.getData("Text")==a)return void t.preventDefault()}var s=Ys(),l=s.firstChild;r.display.lineSpace.insertBefore(s,r.display.lineSpace.firstChild),l.value=Hs.text.join("\n");var u=I();P(l),setTimeout((function(){r.display.lineSpace.removeChild(s),u.focus(),u==i&&n.showPrimarySelection()}),50)}}i.contentEditable=!0,$s(i,r.options.spellcheck,r.options.autocorrect,r.options.autocapitalize),dt(i,"paste",(function(t){!o(t)||yt(r,t)||js(t,r)||s<=11&&setTimeout(Ii(r,(function(){return e.updateFromDOM()})),20)})),dt(i,"compositionstart",(function(t){e.composing={data:t.data,done:!1}})),dt(i,"compositionupdate",(function(t){e.composing||(e.composing={data:t.data,done:!1})})),dt(i,"compositionend",(function(t){e.composing&&(t.data!=e.composing.data&&e.readFromDOMSoon(),e.composing.done=!0)})),dt(i,"touchstart",(function(){return n.forceCompositionEnd()})),dt(i,"input",(function(){e.composing||e.readFromDOMSoon()})),dt(i,"copy",a),dt(i,"cut",a)},Js.prototype.screenReaderLabelChanged=function(t){t?this.div.setAttribute("aria-label",t):this.div.removeAttribute("aria-label")},Js.prototype.prepareSelection=function(){var t=jr(this.cm,!1);return t.focus=I()==this.div,t},Js.prototype.showSelection=function(t,e){t&&this.cm.display.view.length&&((t.focus||e)&&this.showPrimarySelection(),this.showMultipleSelections(t))},Js.prototype.getSelection=function(){return this.cm.display.wrapper.ownerDocument.getSelection()},Js.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=rl(e,t.anchorNode,t.anchorOffset),s=rl(e,t.focusNode,t.focusOffset);if(!a||a.bad||!s||s.bad||0!=ae(ce(a,s),i)||0!=ae(ue(a,s),o)){var l=e.display.view,u=i.line>=e.display.viewFrom&&Zs(e,i)||{node:l[0].measure.map[2],offset:0},c=o.line<e.display.viewTo&&Zs(e,o);if(!c){var h=l[l.length-1].measure,f=h.maps?h.maps[h.maps.length-1]:h.map;c={node:f[f.length-1],offset:f[f.length-2]-f[f.length-3]}}if(u&&c){var p,d=t.rangeCount&&t.getRangeAt(0);try{p=k(u.node,u.offset,c.offset,c.node)}catch(t){}p&&(!n&&e.state.focused?(t.collapse(u.node,u.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()}}},Js.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)},Js.prototype.showMultipleSelections=function(t){w(this.cm.display.cursorDiv,t.cursors),w(this.cm.display.selectionDiv,t.selection)},Js.prototype.rememberSelection=function(){var t=this.getSelection();this.lastAnchorNode=t.anchorNode,this.lastAnchorOffset=t.anchorOffset,this.lastFocusNode=t.focusNode,this.lastFocusOffset=t.focusOffset},Js.prototype.selectionInEditor=function(){var t=this.getSelection();if(!t.rangeCount)return!1;var e=t.getRangeAt(0).commonAncestorContainer;return R(this.div,e)},Js.prototype.focus=function(){"nocursor"!=this.cm.options.readOnly&&(this.selectionInEditor()&&I()==this.div||this.showSelection(this.prepareSelection(),!0),this.div.focus())},Js.prototype.blur=function(){this.div.blur()},Js.prototype.getField=function(){return this.div},Js.prototype.supportsTouch=function(){return!0},Js.prototype.receivedFocus=function(){var t=this;function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}this.selectionInEditor()?this.pollSelection():Ri(this.cm,(function(){return t.cm.curOp.selectionChanged=!0})),this.polling.set(this.cm.options.pollInterval,e)},Js.prototype.selectionChanged=function(){var t=this.getSelection();return t.anchorNode!=this.lastAnchorNode||t.anchorOffset!=this.lastAnchorOffset||t.focusNode!=this.lastFocusNode||t.focusOffset!=this.lastFocusOffset},Js.prototype.pollSelection=function(){if(null==this.readDOMTimeout&&!this.gracePeriod&&this.selectionChanged()){var t=this.getSelection(),e=this.cm;if(g&&c&&this.cm.display.gutterSpecs.length&&tl(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=rl(e,t.anchorNode,t.anchorOffset),r=rl(e,t.focusNode,t.focusOffset);n&&r&&Ri(e,(function(){Go(e.doc,so(n,r),z),(n.bad||r.bad)&&(e.curOp.selectionChanged=!0)}))}}},Js.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=oe(a.line-1,Qt(r.doc,a.line-1).length)),s.ch==Qt(r.doc,s.line).text.length&&s.line<r.lastLine()&&(s=oe(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=ee(i.view[0].line),n=i.view[0].node):(e=ee(i.view[t].line),n=i.view[t-1].node.nextSibling);var l,u,c=Ur(r,s.line);if(c==i.view.length-1?(l=i.viewTo-1,u=i.lineDiv.lastChild):(l=ee(i.view[c+1].line)-1,u=i.view[c+1].node.previousSibling),!n)return!1;for(var h=r.doc.splitLines(nl(r,n,u,e,l)),f=Jt(r.doc,oe(e,0),oe(l,Qt(r.doc,l).text.length));h.length>1&&f.length>1;)if(X(h)==X(f))h.pop(),f.pop(),l--;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),T=X(f),S=Math.min(y.length-(1==h.length?p:0),T.length-(1==f.length?p:0));d<S&&y.charCodeAt(y.length-d-1)==T.charCodeAt(T.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)==T.charCodeAt(T.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 x=oe(e,p),E=oe(l,f.length?X(f).length-d:0);return h.length>1||h[0]||ae(x,E)?(ia(r.doc,h,x,E,"+input"),!0):void 0},Js.prototype.ensurePolled=function(){this.forceCompositionEnd()},Js.prototype.reset=function(){this.forceCompositionEnd()},Js.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},Js.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))},Js.prototype.updateFromDOM=function(){var t=this;!this.cm.isReadOnly()&&this.pollContent()||Ri(this.cm,(function(){return Dr(t.cm)}))},Js.prototype.setUneditable=function(t){t.contentEditable="false"},Js.prototype.onKeyPress=function(t){0==t.charCode||this.composing||(t.preventDefault(),this.cm.isReadOnly()||Ii(this.cm,zs)(this.cm,String.fromCharCode(null==t.charCode?t.keyCode:t.charCode),0))},Js.prototype.readOnlyChanged=function(t){this.div.contentEditable=String("nocursor"!=t)},Js.prototype.onContextMenu=function(){},Js.prototype.resetPosition=function(){},Js.prototype.needsContentAttribute=!0;var ol=function(t){this.cm=t,this.prevInput="",this.pollingFast=!1,this.polling=new W,this.hasSelection=!1,this.composing=null};function al(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=I();e.autofocus=n==t||null!=t.getAttribute("autofocus")&&n==document.body}function r(){t.value=s.getValue()}var i;if(t.form&&(dt(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&&(gt(t.form,"submit",r),e.leaveSubmitMethodAlone||"function"!=typeof t.form.submit||(t.form.submit=i))}},t.style.display="none";var s=Ds((function(e){return t.parentNode.insertBefore(e,t.nextSibling)}),e);return s}function sl(t){t.off=gt,t.on=dt,t.wheelEventPixels=no,t.Doc=Ca,t.splitLines=_t,t.countColumn=F,t.findColumn=K,t.isWordChar=et,t.Pass=G,t.signal=vt,t.Line=un,t.changeEnd=lo,t.scrollbarModel=Si,t.Pos=oe,t.cmpPos=ae,t.modes=Wt,t.mimeModes=Bt,t.resolveMode=zt,t.getMode=jt,t.modeExtensions=Vt,t.extendMode=Kt,t.copyState=$t,t.startState=Xt,t.innerMode=Yt,t.commands=Qa,t.keyMap=Fa,t.keyName=ja,t.isModifierKey=Ga,t.lookupKey=Ha,t.normalizeKeyMap=Ba,t.StringStream=qt,t.SharedTextMarker=va,t.TextMarker=ma,t.LineWidget=ha,t.e_preventDefault=Et,t.e_stopPropagation=Ct,t.e_stop=kt,t.addClass=M,t.contains=R,t.rmClass=O,t.keyNames=_a}ol.prototype.init=function(t){var e=this,n=this,r=this.cm;this.createField(t);var i=this.textarea;function o(t){if(!yt(r,t)){if(r.somethingSelected())Gs({lineWise:!1,text:r.getSelections()});else{if(!r.options.lineWiseCopyCut)return;var e=Ks(r);Gs({lineWise:!0,text:e.text}),"cut"==t.type?r.setSelections(e.ranges,null,z):(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"),dt(i,"input",(function(){a&&s>=9&&e.hasSelection&&(e.hasSelection=null),n.poll()})),dt(i,"paste",(function(t){yt(r,t)||js(t,r)||(r.state.pasteIncoming=+new Date,n.fastPoll())})),dt(i,"cut",o),dt(i,"copy",o),dt(t.scroller,"paste",(function(e){if(!jn(t,e)&&!yt(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)}})),dt(t.lineSpace,"selectstart",(function(e){jn(t,e)||Et(e)})),dt(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"})}})),dt(i,"compositionend",(function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)}))},ol.prototype.createField=function(t){this.wrapper=Ys(),this.textarea=this.wrapper.firstChild},ol.prototype.screenReaderLabelChanged=function(t){t?this.textarea.setAttribute("aria-label",t):this.textarea.removeAttribute("aria-label")},ol.prototype.prepareSelection=function(){var t=this.cm,e=t.display,n=t.doc,r=jr(t);if(t.options.moveInputWithCursor){var i=Tr(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},ol.prototype.showSelection=function(t){var e=this.cm.display;w(e.cursorDiv,t.cursors),w(e.selectionDiv,t.selection),null!=t.teTop&&(this.wrapper.style.top=t.teTop+"px",this.wrapper.style.left=t.teLeft+"px")},ol.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))}},ol.prototype.getField=function(){return this.textarea},ol.prototype.supportsTouch=function(){return!1},ol.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!v||I()!=this.textarea))try{this.textarea.focus()}catch(t){}},ol.prototype.blur=function(){this.textarea.blur()},ol.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},ol.prototype.receivedFocus=function(){this.slowPoll()},ol.prototype.slowPoll=function(){var t=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,(function(){t.poll(),t.cm.state.focused&&t.slowPoll()}))},ol.prototype.fastPoll=function(){var t=!1,e=this;function n(){e.poll()||t?(e.pollingFast=!1,e.slowPoll()):(t=!0,e.polling.set(60,n))}e.pollingFast=!0,e.polling.set(20,n)},ol.prototype.poll=function(){var t=this,e=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||!e.state.focused||Pt(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 l=0,u=Math.min(r.length,i.length);l<u&&r.charCodeAt(l)==i.charCodeAt(l);)++l;return Ri(e,(function(){zs(e,i.slice(l),r.length-l,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},ol.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},ol.prototype.onKeyPress=function(){a&&s>=9&&(this.hasSelection=null),this.fastPoll()},ol.prototype.onContextMenu=function(t){var e=this,n=e.cm,r=n.display,i=e.textarea;e.contextMenuPending&&e.contextMenuPending();var o=Pr(n,t),u=r.scroller.scrollTop;if(o&&!h){n.options.resetSelectionOnContextMenu&&-1==n.doc.sel.contains(o)&&Ii(n,Go)(n.doc,so(o),z);var c,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);",l&&(c=window.scrollY),r.input.focus(),l&&window.scrollTo(null,c),r.input.reset(),n.somethingSelected()||(i.value=e.prevInput=" "),e.contextMenuPending=v,r.selForContextMenu=n.doc.sel,clearTimeout(r.detectingSelectAll),a&&s>=9&&g(),C){kt(t);var m=function(){gt(window,"mouseup",m),setTimeout(v,20)};dt(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=u),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?Ii(n,qo)(n):t++<10?r.detectingSelectAll=setTimeout(o,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(o,200)}}},ol.prototype.readOnlyChanged=function(t){t||this.reset(),this.textarea.disabled="nocursor"==t,this.textarea.readOnly=!!t},ol.prototype.setUneditable=function(){},ol.prototype.needsContentAttribute=!1,_s(Ds),Xs(Ds);var ll="iter insert remove copy getEditor constructor".split(" ");for(var ul in Ca.prototype)Ca.prototype.hasOwnProperty(ul)&&B(ll,ul)<0&&(Ds.prototype[ul]=function(t){return function(){return t.apply(this.doc,arguments)}}(Ca.prototype[ul]));return xt(Ca),Ds.inputStyles={textarea:ol,contenteditable:Js},Ds.defineMode=function(t){Ds.defaults.mode||"null"==t||(Ds.defaults.mode=t),Ht.apply(this,arguments)},Ds.defineMIME=Gt,Ds.defineMode("null",(function(){return{token:function(t){return t.skipToEnd()}}})),Ds.defineMIME("text/plain","null"),Ds.defineExtension=function(t,e){Ds.prototype[t]=e},Ds.defineDocExtension=function(t,e){Ca.prototype[t]=e},Ds.fromTextArea=al,sl(Ds),Ds.version="5.62.0",Ds}()},217:(t,e,n)=>{"use strict";n.r(e)},977:(t,e,n)=>{"use strict";n.r(e)},324:(t,e,n)=>{"use strict";n.r(e)},521:(t,e,n)=>{"use strict";n.r(e)},556:function(t,e){var n,r,i;"undefined"!=typeof self&&self,r=[],void 0===(i="function"==typeof(n=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"}l(e);var n=this.disjunction();return this.consumeChar(")"),{type:e,value:n,loc:this.loc(t)}}u()},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;l(e)}if(!0!==t||void 0!==e)return l(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()),l(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=c;break;case"D":t=c,e=!0;break;case"s":t=f;break;case"S":t=f,e=!0;break;case"w":t=h;break;case"W":t=h,e=!0}return l(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 l(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 l(t){if(void 0===t)throw Error("Internal Error - Should never get here!")}function u(){throw Error("Internal Error - Should never get here!")}var c=[];for(e=o("0");e<=o("9");e++)c.push(e);var h=[o("_")].concat(c);for(e=o("a");e<=o("z");e++)h.push(e);for(e=o("A");e<=o("Z");e++)h.push(e);var f=[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 p(){}return p.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))}},p.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)},p.prototype.visitPattern=function(t){},p.prototype.visitFlags=function(t){},p.prototype.visitDisjunction=function(t){},p.prototype.visitAlternative=function(t){},p.prototype.visitStartAnchor=function(t){},p.prototype.visitEndAnchor=function(t){},p.prototype.visitWordBoundary=function(t){},p.prototype.visitNonWordBoundary=function(t){},p.prototype.visitLookahead=function(t){},p.prototype.visitNegativeLookahead=function(t){},p.prototype.visitCharacter=function(t){},p.prototype.visitSet=function(t){},p.prototype.visitGroup=function(t){},p.prototype.visitGroupBackReference=function(t){},p.prototype.visitQuantifier=function(t){},{RegExpParser:t,BaseRegExpVisitor:p,VERSION:"0.5.0"}})?n.apply(e,r):n)||(t.exports=i)},236:(t,e,n)=>{"use strict";
|
||
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */Object.defineProperty(e,"__esModule",{value:!0}),e.RegularExpressionCST=e.IfIdentStatementCST=e.IfPatternStatementCST=e.BackrefStatementCST=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.GeneratorContext=e.RegexDialect=void 0;const r=n(5),i=n(953);var o;!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"}(o=e.RegexDialect||(e.RegexDialect={}));const a=["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"],s=["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"];e.GeneratorContext=class{constructor(){this.groups={}}hasGroup(t){return Object.prototype.hasOwnProperty.call(this.groups,t)}addGroup(t,e){var n,i,o;const a=r.first(e),s=r.last(e);this.groups[t]={startLine:null!==(n=a.startLine)&&void 0!==n?n:NaN,startColumn:null!==(i=a.startColumn)&&void 0!==i?i:NaN,length:(null!==(o=s.endOffset)&&void 0!==o?o:s.startOffset)-a.startOffset}}};class l{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 u,c;e.H2RCST=l,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"}(u=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"}(c=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}validate(t,e){return this.statement.validate(t,e)}toRegex(t,e){let n=this.statement.toRegex(t,e);return this.optional&&(n=i.groupIfRequired(n)+"?"),n}};class h extends l{}e.StatementCST=h;e.MatchSubStatementCST=class extends l{constructor(t,e,n=!1,r){super(t),this.count=e,this.invert=n,this.values=r}validate(t,e){const n=[];this.count&&r.append(n,this.count.validate(t,e));for(const e of this.values)if(e.type===c.Between){let t=r.removeQuotes(e.from),i=r.removeQuotes(e.to);r.isSingleRegexCharacter(t)?(t.startsWith("\\u")||t.startsWith("\\U")||t.startsWith("\\"))&&(t=JSON.parse(`"${t}"`)):n.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}"`)):n.push(this.error("Between statement must end with a single character")),t.charCodeAt(0)>=i.charCodeAt(0)&&n.push(this.error("Between statement range invalid"))}else if(e.type===c.Unicode){let i=r.removeQuotes(e.from);if(!a.includes(i)){if(t===o.DotNet||t===o.Java){if(!i.startsWith("Is")){n.push(this.error("This dialect requires script names to begin with Is, such as IsCyrillic rather than Cyrillic"));continue}i=i.substr(2)}s.includes(i)||n.push(this.error(`Unknown unicode specifier ${e.from}`))}}return n}toRegex(t,e){const n=[];for(const e of this.values)switch(e.type){case c.SingleString:{const t=r.regexEscape(r.removeQuotes(e.from));r.isSingleRegexCharacter(t)?n.push(this.invert?`[^${t}]`:t):n.push(this.invert?`(?!${t})`:t);break}case c.Between:{const t=r.removeQuotes(e.from),i=r.removeQuotes(e.to);n.push(this.invert?`[^${t}-${i}]`:`[${t}-${i}]`);break}case c.Unicode:{const t=r.removeQuotes(e.from);n.push(this.invert?`\\P{${t}}`:`\\p{${t}}`);break}case c.Boundary:n.push(this.invert?"\\B":"\\b");break;case c.Word:n.push(this.invert?"\\W+":"\\w+");break;case c.Letter:t===o.PCRE?n.push(this.invert?"[^[:alpha:]]":"[[:alpha:]]"):n.push(this.invert?"[^a-zA-Z]":"[a-zA-Z]");break;case c.Integer:n.push(this.invert?"(?![+-]?\\d+)":"[+-]?\\d+");break;case c.Decimal:n.push(this.invert?"(?![+-]?(?:(?:\\d+[,.]?\\d*)|(?:[,.]\\d+)))":"[+-]?(?:(?:\\d+[,.]?\\d*)|(?:[,.]\\d+))");break;case c.Digit:n.push(this.invert?"\\D":"\\d");break;case c.Character:n.push(this.invert?"\\W":"\\w");break;case c.Whitespace:n.push(this.invert?"\\S":"\\s");break;case c.Number:n.push(this.invert?"\\D+":"\\d+");break;case c.Tab:n.push(this.invert?"[^\\t]":"\\t");break;case c.Newline:case c.Linefeed:n.push(this.invert?"[^\\n]":"\\n");break;case c.CarriageReturn:n.push(this.invert?"[^\\r]":"\\r");break;default:n.push(this.invert?"[^.]":".")}let a="";if(a=(null==e?void 0:e.has_neighbours)?i.minimizeMatchString(n,!0):i.minimizeMatchString(n),this.count)if(1===n.length)a=i.dontClobberRepetition(a,this.count.toRegex(t,null));else{const e=this.count.toRegex(t,{dont_loop_one:!0});""!==e&&(a=i.groupIfRequired(a)+e)}return a}};e.UsingStatementCST=class extends l{constructor(t,e){super(t),this.flags=e}validate(t,e){r.unusedParameter(t,"Count does not need checking"),r.unusedParameter(e,"Context is not needed");const n=[];let i=this.flags[0];for(let t=1;t<this.flags.length;t++)r.hasFlag(i,this.flags[t])&&n.push(this.error("Duplicate modifier: "+u[this.flags[t]])),i=r.combineFlags(i,this.flags[t]);return r.hasFlag(i,u.Sensitive)&&r.hasFlag(i,u.Insensitive)&&n.push(this.error("Cannot be both case sensitive and insensitive")),n}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,u.Multiline)?e+="m":r.hasFlag(t,u.Global)?e+="g":r.hasFlag(t,u.Insensitive)?e+="i":r.hasFlag(t,u.Exact)&&(n=!0);return n?"/^{regex}$/"+e:"/{regex}/"+e}};e.CountSubStatementCST=class extends l{constructor(t,e,n=null,r=null){super(t),this.from=e,this.to=n,this.opt=r}validate(t,e){r.unusedParameter(t,"Count does not need checking"),r.unusedParameter(e,"Context is not needed");const n=[];return null!==this.to&&("exclusive"===this.opt&&this.to-1<=this.from||this.to<=this.from)?n.push(this.error("Values must be in range of each other")):null===this.to&&0===this.from&&null===this.opt&&n.push(this.error("Count cannot be 0. This will match nothing. Use comments if you meant to ignore the next match.")),n}toRegex(t,e){r.unusedParameter(t,"Count does not change from language");const n=this.from;let i=this.to;if(null===i){if(1===n)return(null==e?void 0:e.dont_loop_one)?"+"===this.opt?"+":"":"+"===this.opt?"+":"*";if(0===n)return"*"}return null!==i?("exclusive"===this.opt&&i--,`{${n},${i}}`):"+"===this.opt?`{${n},}`:`{${n}}`}};e.MatchStatementCST=class extends h{constructor(t,e,n){super(t),this.completely_optional=e,this.matches=n}validate(t,e){const n=[];for(const i of this.matches)r.append(n,i.statement.validate(t,e));return n}toRegex(t){let e="";return e=1===this.matches.length?this.matches[0].toRegex(t,null):this.matches.map((e=>e.toRegex(t,{has_neighbours:!0}))).join(""),this.completely_optional&&(e=i.groupIfRequired(e)+"?"),e}};e.RepeatStatementCST=class extends h{constructor(t,e,n,r){super(t),this.optional=e,this.count=n,this.statements=r}validate(t,e){const n=[];null!==this.count&&r.append(n,this.count.validate(t,e));for(const i of this.statements)r.append(n,i.validate(t,e));return n}toRegex(t){let e=i.groupIfRequired(this.statements.map((e=>e.toRegex(t,null))).join(""));return this.count?(e+=this.count.toRegex(t,null),this.optional&&(e="(?:"+e+")?")):(e+="*",this.optional&&(e+="?")),e}};e.GroupStatementCST=class extends h{constructor(t,e,n,r){super(t),this.optional=e,this.name=n,this.statements=r}validate(t,e){const n=[];if(null!==this.name)if(e.hasGroup(this.name)){const t=e.groups[this.name];n.push(this.error(`Group with name "${this.name}" was already defined here: ${t.startLine}:${t.startLine}-${t.startLine}:${t.startLine+t.length}`))}else e.addGroup(this.name,this.tokens);for(const i of this.statements)r.append(n,i.validate(t,e));return n}toRegex(t){let e="(";return null!==this.name&&(e+="?",t!==o.Python&&t!==o.PCRE||(e+="P"),e+=`<${this.name}>`),e+=this.statements.map((e=>e.toRegex(t,null))).join(""),e+=this.optional?")?":")",e}};e.BackrefStatementCST=class extends h{constructor(t,e,n,r){super(t),this.optional=e,this.count=n,this.name=r}validate(t,e){const n=[];return e.hasGroup(this.name)||n.push(this.error(`Cannot call group with name "${this.name}" as it was never previously defined`)),null!==this.count&&r.append(n,this.count.validate(t,e)),n}toRegex(t){let e="";switch(t){case o.Python:e=`(?P=${this.name})`;break;case o.DotNet:case o.Java:e=`\\k<${this.name}>`;break;default:e=`\\g<${this.name}>`}return this.count?(e+=this.count.toRegex(t,null),this.optional&&(e="(?:"+e+")?")):this.optional&&(e+="?"),e}};e.IfPatternStatementCST=class extends h{constructor(t,e,n,r){super(t),this.matches=e,this.true_statements=n,this.false_statements=r}validate(t,e){const n=[];t!==o.Java&&t!==o.JS||n.push(this.error("This language does not support conditionals")),t===o.Python&&n.push(this.error("This language does not support pattern conditionals"));for(const i of this.matches)r.append(n,i.validate(t,e));for(const i of this.true_statements)r.append(n,i.validate(t,e));for(const i of this.false_statements)r.append(n,i.validate(t,e));return n}toRegex(t){const e=this.matches.map((e=>e.toRegex(t,null))).join(""),n=i.groupIfRequired(this.true_statements.map((e=>e.toRegex(t,null))).join(""));if(this.false_statements.length>0){return`(?(${e})${n}|${i.groupIfRequired(this.false_statements.map((e=>e.toRegex(t,null))).join(""))})`}return`(?(${e})${n})`}};e.IfIdentStatementCST=class extends h{constructor(t,e,n,r){super(t),this.identifier=e,this.true_statements=n,this.false_statements=r}validate(t,e){const n=[];t!==o.Java&&t!==o.JS||n.push(this.error("This language does not support conditionals")),e.hasGroup(this.identifier)||n.push(this.error(`Group with name "${this.identifier}" does not exist`));for(const i of this.true_statements)r.append(n,i.validate(t,e));for(const i of this.false_statements)r.append(n,i.validate(t,e));return n}toRegex(t){let e=this.identifier;t===o.Boost&&(e="<"+e+">");const n=i.groupIfRequired(this.true_statements.map((e=>e.toRegex(t,null))).join(""));if(this.false_statements.length>0){return`(?(${e})${n}|${i.groupIfRequired(this.false_statements.map((e=>e.toRegex(t,null))).join(""))})`}return`(?(${e})${n})`}};e.RegularExpressionCST=class extends l{constructor(t,e,n){super(t),this.usings=e,this.statements=n}validate(t,e){const n=this.usings.validate(t,e);for(const i of this.statements)r.append(n,i.validate(t,e));return n}toRegex(t){const e=this.usings.toRegex(t),n=this.statements.map((e=>e.toRegex(t,null))).join("");return e.replace("{regex}",n)}}},953:(t,e,n)=>{"use strict";
|
||
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */Object.defineProperty(e,"__esModule",{value:!0}),e.dontClobberRepetition=e.groupIfRequired=e.minimizeMatchString=void 0;const r=n(5);function i(t,e=0){if(0===t.length)return"";if(1===t.length)return r.first(t)+"?";if(1===(t=[...new Set(t)]).length)return r.first(t);if(t.every((t=>r.isSingleRegexCharacter(t)||r.isRangeRegex(t))))return"["+t.map((t=>r.isSingleRegexCharacter(t)?t:t.substring(1,t.length-1))).join("")+"]";let n=r.first(t),o=r.first(t);for(let e=1;e<t.length;e++){for(let r=0;r<n.length;r++)if(t[e].length<r||n[r]!==t[e][r]){n=n.substr(0,r);break}for(let n=0;n<o.length;n++)if(t[e].length-n<0||o[o.length-n-1]!==t[e][t[e].length-n-1]){o=o.substr(o.length-n,o.length);break}if(0===n.length&&0===o.length)break}if(0===n.length&&0===o.length)return e>0?"(?:"+t.join("|")+")":t.join("|");{const r=n.length,a=o.length,s=[];for(const e of t){const t=e.substring(r,e.length-a);0!==t.length&&s.push(t)}return n+i(s,e+1)+o}}function o(t){if(r.isSingleRegexCharacter(t))return t;if(("*"===t[t.length-1]||"+"===t[t.length-1])&&r.isSingleRegexCharacter(t.substring(0,t.length-1)))return t;if("("===t[0]&&")"===t[t.length-1]){let e=0;for(let n=1;n<t.length-2;n++)if("\\"===t[n])n++;else if("("===t[n])e++;else if(")"===t[n]&&(e--,-1===e))break;return 0===e?t:"(?:"+t+")"}if("["===t[0]&&"]"===t[t.length-1]){let e=0;for(let n=1;n<t.length-2;n++)if("\\"===t[n])n++;else if("]"===t[n]&&(e--,-1===e))break;return 0===e?t:"(?:"+t+")"}return"(?:"+t+")"}e.minimizeMatchString=function(t,e=!1){return 1===t.length?r.first(t):i(t,e?1:0)},e.groupIfRequired=o,e.dontClobberRepetition=function(t,e){if(t.endsWith("+"))switch(e){case"*":break;case"?":t+=e;break;case"+":break;default:t=e.startsWith("{0")?"(?:"+t+")"+e:t.substring(0,t.length-1)+e}else if(t.endsWith("*"))switch(e){case"*":break;case"?":t+=e;break;default:t=t.substring(0,t.length-1)+e}else t=o(t)+e;return t}},403:(t,e,n)=>{"use strict";
|
||
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */Object.defineProperty(e,"__esModule",{value:!0}),e.Human2RegexLexer=e.TokenizeResult=e.Human2RegexLexerOptions=e.IndentType=void 0;const r=n(650),i=n(5),o=n(534);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 l{constructor(t,e){this.tokens=t,this.errors=e}}e.TokenizeResult=l;class u{constructor(t=new s){if(u.already_init)throw new Error("Only 1 instance of Human2RegexLexer allowed");u.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,u,c,h,f,p,d,m,g,v,y;const T=this.lexer.tokenize(t);if(0===T.tokens.length)return new l(T.tokens,T.errors.map(i.CommonError.fromLexError));const S=[],x=[0];let E=0,C=!0,b=!1;for(let t=0;t<T.tokens.length;t++)if(T.tokens[t].tokenType===o.EndOfLine)0===S.length||S[S.length-1].tokenType===o.EndOfLine||(C=!0,S.push(T.tokens[t]));else if(T.tokens[t].tokenType===o.Indent){b=!0,E=1;const l=T.tokens[t];let u=T.tokens[t].image.length;for(;T.tokens.length>t+1&&T.tokens[t+1].tokenType===o.Indent;)E++,t++,u+=T.tokens[t].image.length;if(l.endOffset=l.startOffset+u,l.endColumn=T.tokens[t].endColumn,T.tokens.length>t+1&&T.tokens[t+1].tokenType===o.EndOfLine);else if(!C||E>i.last(x)+1)T.errors.push(this.lexError(l));else if(E>i.last(x))x.push(E),S.push(l);else if(E<i.last(x)){const t=i.findLastIndex(x,E),c=x.length-t-1;for(let t=0;t<c;t++)x.pop(),S.push(r.createTokenInstance(o.Outdent,"",l.startOffset,l.startOffset+u,null!==(e=l.startLine)&&void 0!==e?e:NaN,null!==(n=l.endLine)&&void 0!==n?n:NaN,null!==(a=l.startColumn)&&void 0!==a?a:NaN,(null!==(s=l.startColumn)&&void 0!==s?s:NaN)+u))}}else{if(C&&!b){const e=T.tokens[t];for(;x.length>1;)x.pop(),S.push(r.createTokenInstance(o.Outdent,"",e.startOffset,e.startOffset,null!==(u=e.startLine)&&void 0!==u?u:NaN,NaN,null!==(c=e.startColumn)&&void 0!==c?c:NaN,NaN))}C=!1,b=!1,S.push(T.tokens[t])}const k=i.last(S);for(S.length>0&&k.tokenType!==o.EndOfLine&&S.push(r.createTokenInstance(o.EndOfLine,"\n",null!==(h=k.endOffset)&&void 0!==h?h:NaN,null!==(f=k.endOffset)&&void 0!==f?f:NaN,null!==(p=k.startLine)&&void 0!==p?p:NaN,NaN,null!==(d=k.startColumn)&&void 0!==d?d:NaN,NaN));x.length>1;)x.pop(),S.push(r.createTokenInstance(o.Outdent,"",null!==(m=k.endOffset)&&void 0!==m?m:NaN,null!==(g=k.endOffset)&&void 0!==g?g:NaN,null!==(v=k.startLine)&&void 0!==v?v:NaN,NaN,null!==(y=k.startColumn)&&void 0!==y?y:NaN,NaN));return new l(S,T.errors.map(i.CommonError.fromLexError))}}e.Human2RegexLexer=u,u.already_init=!1},215:function(t,e,n){"use strict";
|
||
/*! Copyright (c) 2021 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(650),s=o(n(534)),l=n(236),u=n(5);class c{constructor(t=!1){this.skip_validations=t}}e.Human2RegexParserOptions=c;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,new l.GeneratorContext).map(u.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 c){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 l.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 l.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 l.CountSubStatementCST(t,n.value)}}])));let o=null;const a=e.RULE("MatchSubStatement",(()=>{let t=null,n=!1;const r=[];let a=null,c=null,h=null,f=l.MatchSubStatementType.Anything,p=[];return t=e.OPTION((()=>{const t=e.SUBRULE(i);return u.usefulConditional(t.tokens,"due to how chevrotain works, the first run produces a null value")&&p.push(u.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=l.MatchSubStatementType.Between,u.usefulConditional(t,"Bug in type definition. Option should return <T|undefined>, but it doesn't")?{tokens:[t,r],statement:new l.MatchSubStatementValue(f,a,h)}:{tokens:[n,r],statement:new l.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=l.MatchSubStatementType.Between,{tokens:[t,n],statement:new l.MatchSubStatementValue(f,a,h)}}},{ALT:()=>{const t=e.CONSUME(s.StringLiteral);return c=t.image,f=l.MatchSubStatementType.SingleString,{tokens:[t],statement:new l.MatchSubStatementValue(f,c)}}},{ALT:()=>{const t=e.CONSUME(s.Unicode),n=e.CONSUME6(s.StringLiteral);return c=n.image,f=l.MatchSubStatementType.Unicode,{tokens:[t,n],statement:new l.MatchSubStatementValue(f,c)}}},{ALT:()=>{const t=e.CONSUME(s.Anything);return f=l.MatchSubStatementType.Anything,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Boundary);return f=l.MatchSubStatementType.Boundary,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Word);return f=l.MatchSubStatementType.Word,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Digit);return f=l.MatchSubStatementType.Digit,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Character);return f=l.MatchSubStatementType.Character,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Letter);return f=l.MatchSubStatementType.Letter,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Decimal);return f=l.MatchSubStatementType.Decimal,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Integer);return f=l.MatchSubStatementType.Integer,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Whitespace);return f=l.MatchSubStatementType.Whitespace,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Number);return f=l.MatchSubStatementType.Number,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Tab);return f=l.MatchSubStatementType.Tab,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Linefeed);return f=l.MatchSubStatementType.Linefeed,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.Newline);return f=l.MatchSubStatementType.Newline,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}},{ALT:()=>{const t=e.CONSUME(s.CarriageReturn);return f=l.MatchSubStatementType.CarriageReturn,{tokens:[t],statement:new l.MatchSubStatementValue(f)}}}]));p=p.concat(t.tokens),r.push(t.statement)}}),new l.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 l.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 l.MatchStatementValue(t,e.SUBRULE2(a)))})),i.push(e.CONSUME(s.EndOfLine)),new l.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),l.UsingFlags.Multiline)},{ALT:()=>(e.CONSUME(s.Global),l.UsingFlags.Global)},{ALT:()=>(e.CONSUME(s.CaseInsensitive),l.UsingFlags.Insensitive)},{ALT:()=>(e.CONSUME(s.CaseSensitive),l.UsingFlags.Sensitive)},{ALT:()=>(e.CONSUME(s.Exact),l.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 e.OPTION4((()=>{t.push(e.OR3([{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}},{ALT:()=>(n=!0,e.CONSUME3(s.Optional))}]))})),t.push(e.CONSUME(s.Group)),e.OPTION5((()=>{r=e.OR([{ALT:()=>{e.CONSUME(s.Called);const t=e.CONSUME(s.Identifier).image;return e.OPTION((()=>e.CONSUME(s.Is))),t}},{ALT:()=>{const t=e.CONSUME2(s.Identifier).image;return e.CONSUME2(s.Is),t}}])})),t.push(e.CONSUME2(s.EndOfLine)),e.CONSUME(s.Indent),e.AT_LEAST_ONE((()=>{i.push(e.SUBRULE(x))})),e.CONSUME(s.Outdent),new l.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(x))})),t.push(e.CONSUME(s.Outdent)),new l.RepeatStatementCST(t,n,r,o)})),T=e.RULE("BackrefStatement",(()=>{const t=[];let n=!1,r=null;e.OPTION5((()=>{t.push(e.CONSUME(s.Optional)),n=!0})),t.push(e.CONSUME(s.Rerun)),e.OPTION6((()=>r=e.SUBRULE(i))),e.OPTION7((()=>{e.OPTION((()=>e.CONSUME(s.The))),e.CONSUME(s.Group),e.OPTION2((()=>e.CONSUME(s.Called)))}));const o=e.CONSUME(s.Identifier).image;return t.push(e.CONSUME4(s.EndOfLine)),new l.BackrefStatementCST(t,n,r,o)})),S=e.RULE("IfStatement",(()=>{const t=[],n=[];let r=!1;const i=[],o=[];let u="";return t.push(e.CONSUME(s.If)),e.OR2([{ALT:()=>{u=e.CONSUME(s.Identifier).image}},{ALT:()=>{e.CONSUME(s.Match),e.OPTION4((()=>{e.CONSUME3(s.Optional),r=!0})),n.push(new l.MatchStatementValue(r,e.SUBRULE(a))),e.MANY((()=>{e.OR([{ALT:()=>{e.OPTION2((()=>e.CONSUME2(s.And))),e.CONSUME(s.Then)}},{ALT:()=>e.CONSUME(s.And)}]),r=!1,e.OPTION3((()=>{e.CONSUME2(s.Optional),r=!0})),n.push(new l.MatchStatementValue(r,e.SUBRULE2(a)))}))}}]),t.push(e.CONSUME3(s.EndOfLine)),e.CONSUME2(s.Indent),e.AT_LEAST_ONE2((()=>{i.push(e.SUBRULE(x))})),e.CONSUME2(s.Outdent),e.OPTION((()=>{e.CONSUME(s.Else),e.CONSUME4(s.EndOfLine),e.CONSUME3(s.Indent),e.AT_LEAST_ONE3((()=>{o.push(e.SUBRULE2(x))})),e.CONSUME3(s.Outdent)})),""===u?new l.IfPatternStatementCST(t,n,i,o):new l.IfIdentStatementCST(t,u,i,o)})),x=e.RULE("Statement",(()=>e.OR([{ALT:()=>e.SUBRULE(p)},{ALT:()=>e.SUBRULE(v)},{ALT:()=>e.SUBRULE(y)},{ALT:()=>e.SUBRULE(T)},{ALT:()=>e.SUBRULE(S)}]))),E=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(x)))),new l.RegularExpressionCST([],new l.UsingStatementCST(t,n),r)}));this.performSelfAnalysis(),this.regexp=E}parse(t){return this.input=t,new p(this.regexp(),this.errors.map(u.CommonError.fromParseError))}setOptions(t){throw new Error("skip_validations is not valid to change once we've already initialized")}}e.Human2RegexParser=d,d.already_init=!1},550:function(t,e,n){"use strict";
|
||
/*! Copyright (c) 2021 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(403),o=n(215),a=n(236),s=n(5),l=r(n(631));n(790),n(165),n(256),n(217),n(977),n(324),n(521);const u=l.default;document.addEventListener("DOMContentLoaded",(function(){u.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)?\b/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:"keyword",regex:/re( |-)?(run|capture)/i},{token:"operator",regex:/the/i},{token:"keyword",regex:/if/i},{token:"keyword",regex:/else|otherwise/i},{token:"keyword",regex:/is|:/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"),l=document.getElementById("errors"),c=document.getElementsByTagName("code");for(let t=0;t<c.length;t++)u.runMode(c[t].innerText,"human2regex",c[t]);if(!(t&&e&&n&&r&&l))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(!l||!t)return;g(l),l.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(l);for(const t of p)l.appendChild(document.createTextNode(`${t.toString()}\n`))}u.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=u.Pos(t.start_line-1,t.start_column-1),r=u.Pos(t.start_line-1,t.start_column-1+t.length);e.push({from:n,to:r,message:t.message})}return e}));const y=u.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())}))},534:(t,e,n)=>{"use strict";
|
||
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */Object.defineProperty(e,"__esModule",{value:!0}),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.Anything=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.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,e.AllTokens=e.Outdent=e.Indent=e.StringLiteral=e.NumberLiteral=e.Identifier=e.MultilineComment=e.SingleLineComment=e.WS=e.EndOfLine=e.Is=e.Else=e.If=e.The=e.Rerun=e.OrMore=e.CaseSensitive=void 0;const r=n(650);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.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.Anything=r.createToken({name:"Anything",pattern:/(anything|any thing|any|everything|every thing)(s)?/i,longer_alt:e.Not}),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)?\b/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:/named|called/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.Rerun=r.createToken({name:"Rerun",pattern:/re( |-)?(run|capture)/i}),e.The=r.createToken({name:"The",pattern:/the/i}),e.If=r.createToken({name:"If",pattern:/if/i}),e.Else=r.createToken({name:"Else",pattern:/else|otherwise/i}),e.Is=r.createToken({name:"Is",pattern:/is|:/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:/\/\*(.|\n|\r)*\*\//,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.Anything,e.Not,e.And,e.Boundary,e.Word,e.Digit,e.Letter,e.Decimal,e.Integer,e.Character,e.Whitespace,e.Number,e.Unicode,e.Called,e.Rerun,e.If,e.Else,e.Is,e.The,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.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]},5:(t,e)=>{"use strict";
|
||
/*! Copyright (c) 2021 Patrick Demian; Licensed under MIT */function n(t){return t.startsWith("\\u")&&6===t.length||t.startsWith("\\U")&&8===t.length||t.startsWith("\\")&&2===t.length||1===t.length}Object.defineProperty(e,"__esModule",{value:!0}),e.CommonError=e.append=e.regexEscape=e.removeQuotes=e.findLastIndex=e.last=e.first=e.isRangeRegex=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=n,e.isRangeRegex=function(t){if(!t.startsWith("[")&&!t.endsWith("]"))return!1;const e=t.substring(1,t.length-1).split("-");return 2===e.length&&((!e[0].endsWith("\\")||"\\\\"===e[0])&&(n(e[0])&&n(e[1])))},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('\\"','"').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}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={exports:{}};return t[r].call(o.exports,o,o.exports,n),o.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r=n(550)})(); |