diff --git a/ads.txt b/ads.txt
new file mode 100644
index 00000000..dd7ee787
--- /dev/null
+++ b/ads.txt
@@ -0,0 +1 @@
+google.com, pub-7505521340110301, DIRECT, f08c47fec0942fa0
diff --git a/index.html b/index.html
index b50793da..c49e51f3 100644
--- a/index.html
+++ b/index.html
@@ -16,14 +16,18 @@
-
-
+
+
+
+
-
-
+
+
+
+
WhiteSpider
diff --git a/main.js b/main.js
index 8f4adb43..e9487c1e 100644
--- a/main.js
+++ b/main.js
@@ -1,2 +1,2 @@
/*! For license information please see out.js.LICENSE.txt */
-(()=>{"use strict";var t={984:(t,e)=>{function i(t,e){if(null==t)return{};var i,s,n={},o=Object.keys(t);for(s=0;s=0||(n[i]=t[i]);return n}class s{constructor(t,e,i){this.line=void 0,this.column=void 0,this.index=void 0,this.line=t,this.column=e,this.index=i}}class n{constructor(t,e){this.start=void 0,this.end=void 0,this.filename=void 0,this.identifierName=void 0,this.start=t,this.end=e}}function o(t,e){const{line:i,column:n,index:o}=t;return new s(i,n+e,o+e)}const a="BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";var r={ImportMetaOutsideModule:{message:"import.meta may appear only with 'sourceType: \"module\"'",code:a},ImportOutsideModule:{message:"'import' and 'export' may appear only with 'sourceType: \"module\"'",code:a}};const l={ArrayPattern:"array destructuring pattern",AssignmentExpression:"assignment expression",AssignmentPattern:"assignment expression",ArrowFunctionExpression:"arrow function expression",ConditionalExpression:"conditional expression",CatchClause:"catch clause",ForOfStatement:"for-of statement",ForInStatement:"for-in statement",ForStatement:"for-loop",FormalParameters:"function parameter list",Identifier:"identifier",ImportSpecifier:"import specifier",ImportDefaultSpecifier:"import default specifier",ImportNamespaceSpecifier:"import namespace specifier",ObjectPattern:"object destructuring pattern",ParenthesizedExpression:"parenthesized expression",RestElement:"rest element",UpdateExpression:{true:"prefix operation",false:"postfix operation"},VariableDeclarator:"variable declaration",YieldExpression:"yield expression"},h=({type:t,prefix:e})=>"UpdateExpression"===t?l.UpdateExpression[String(e)]:l[t];var c={AccessorIsGenerator:({kind:t})=>`A ${t}ter cannot be a generator.`,ArgumentsInClass:"'arguments' is only allowed in functions and class methods.",AsyncFunctionInSingleStatementContext:"Async functions can only be declared at the top level or inside a block.",AwaitBindingIdentifier:"Can not use 'await' as identifier inside an async function.",AwaitBindingIdentifierInStaticBlock:"Can not use 'await' as identifier inside a static block.",AwaitExpressionFormalParameter:"'await' is not allowed in async function parameters.",AwaitUsingNotInAsyncContext:"'await using' is only allowed within async functions and at the top levels of modules.",AwaitNotInAsyncContext:"'await' is only allowed within async functions and at the top levels of modules.",AwaitNotInAsyncFunction:"'await' is only allowed within async functions.",BadGetterArity:"A 'get' accessor must not have any formal parameters.",BadSetterArity:"A 'set' accessor must have exactly one formal parameter.",BadSetterRestParameter:"A 'set' accessor function argument must not be a rest parameter.",ConstructorClassField:"Classes may not have a field named 'constructor'.",ConstructorClassPrivateField:"Classes may not have a private field named '#constructor'.",ConstructorIsAccessor:"Class constructor may not be an accessor.",ConstructorIsAsync:"Constructor can't be an async function.",ConstructorIsGenerator:"Constructor can't be a generator.",DeclarationMissingInitializer:({kind:t})=>`Missing initializer in ${t} declaration.`,DecoratorArgumentsOutsideParentheses:"Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",DecoratorBeforeExport:"Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",DecoratorsBeforeAfterExport:"Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",DecoratorConstructor:"Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",DecoratorExportClass:"Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",DecoratorSemicolon:"Decorators must not be followed by a semicolon.",DecoratorStaticBlock:"Decorators can't be used with a static block.",DeferImportRequiresNamespace:'Only `import defer * as x from "./module"` is valid.',DeletePrivateField:"Deleting a private field is not allowed.",DestructureNamedImport:"ES2015 named imports do not destructure. Use another statement for destructuring after the import.",DuplicateConstructor:"Duplicate constructor in the same class.",DuplicateDefaultExport:"Only one default export allowed per module.",DuplicateExport:({exportName:t})=>`\`${t}\` has already been exported. Exported identifiers must be unique.`,DuplicateProto:"Redefinition of __proto__ property.",DuplicateRegExpFlags:"Duplicate regular expression flag.",DynamicImportPhaseRequiresImportExpressions:({phase:t})=>`'import.${t}(...)' can only be parsed when using the 'createImportExpressions' option.`,ElementAfterRest:"Rest element must be last element.",EscapedCharNotAnIdentifier:"Invalid Unicode escape.",ExportBindingIsString:({localName:t,exportName:e})=>`A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${t}' as '${e}' } from 'some-module'\`?`,ExportDefaultFromAsIdentifier:"'from' is not allowed as an identifier after 'export default'.",ForInOfLoopInitializer:({type:t})=>`'${"ForInStatement"===t?"for-in":"for-of"}' loop variable declaration may not have an initializer.`,ForInUsing:"For-in loop may not start with 'using' declaration.",ForOfAsync:"The left-hand side of a for-of loop may not be 'async'.",ForOfLet:"The left-hand side of a for-of loop may not start with 'let'.",GeneratorInSingleStatementContext:"Generators can only be declared at the top level or inside a block.",IllegalBreakContinue:({type:t})=>`Unsyntactic ${"BreakStatement"===t?"break":"continue"}.`,IllegalLanguageModeDirective:"Illegal 'use strict' directive in function with non-simple parameter list.",IllegalReturn:"'return' outside of function.",ImportAttributesUseAssert:"The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedAssertSyntax: true` option in the import attributes plugin to suppress this error.",ImportBindingIsString:({importName:t})=>`A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${t}" as foo }\`?`,ImportCallArgumentTrailingComma:"Trailing comma is disallowed inside import(...) arguments.",ImportCallArity:({maxArgumentCount:t})=>`\`import()\` requires exactly ${1===t?"one argument":"one or two arguments"}.`,ImportCallNotNewExpression:"Cannot use new with import(...).",ImportCallSpreadArgument:"`...` is not allowed in `import()`.",ImportJSONBindingNotDefault:"A JSON module can only be imported with `default`.",ImportReflectionHasAssertion:"`import module x` cannot have assertions.",ImportReflectionNotBinding:'Only `import module x from "./module"` is valid.',IncompatibleRegExpUVFlags:"The 'u' and 'v' regular expression flags cannot be enabled at the same time.",InvalidBigIntLiteral:"Invalid BigIntLiteral.",InvalidCodePoint:"Code point out of bounds.",InvalidCoverInitializedName:"Invalid shorthand property initializer.",InvalidDecimal:"Invalid decimal.",InvalidDigit:({radix:t})=>`Expected number in radix ${t}.`,InvalidEscapeSequence:"Bad character escape sequence.",InvalidEscapeSequenceTemplate:"Invalid escape sequence in template.",InvalidEscapedReservedWord:({reservedWord:t})=>`Escape sequence in keyword ${t}.`,InvalidIdentifier:({identifierName:t})=>`Invalid identifier ${t}.`,InvalidLhs:({ancestor:t})=>`Invalid left-hand side in ${h(t)}.`,InvalidLhsBinding:({ancestor:t})=>`Binding invalid left-hand side in ${h(t)}.`,InvalidLhsOptionalChaining:({ancestor:t})=>`Invalid optional chaining in the left-hand side of ${h(t)}.`,InvalidNumber:"Invalid number.",InvalidOrMissingExponent:"Floating-point numbers require a valid exponent after the 'e'.",InvalidOrUnexpectedToken:({unexpected:t})=>`Unexpected character '${t}'.`,InvalidParenthesizedAssignment:"Invalid parenthesized assignment pattern.",InvalidPrivateFieldResolution:({identifierName:t})=>`Private name #${t} is not defined.`,InvalidPropertyBindingPattern:"Binding member expression.",InvalidRecordProperty:"Only properties and spread elements are allowed in record definitions.",InvalidRestAssignmentPattern:"Invalid rest operator's argument.",LabelRedeclaration:({labelName:t})=>`Label '${t}' is already declared.`,LetInLexicalBinding:"'let' is disallowed as a lexically bound name.",LineTerminatorBeforeArrow:"No line break is allowed before '=>'.",MalformedRegExpFlags:"Invalid regular expression flag.",MissingClassName:"A class name is required.",MissingEqInAssignment:"Only '=' operator can be used for specifying default value.",MissingSemicolon:"Missing semicolon.",MissingPlugin:({missingPlugin:t})=>`This experimental syntax requires enabling the parser plugin: ${t.map((t=>JSON.stringify(t))).join(", ")}.`,MissingOneOfPlugins:({missingPlugin:t})=>`This experimental syntax requires enabling one of the following parser plugin(s): ${t.map((t=>JSON.stringify(t))).join(", ")}.`,MissingUnicodeEscape:"Expecting Unicode escape sequence \\uXXXX.",MixingCoalesceWithLogical:"Nullish coalescing operator(??) requires parens when mixing with logical operators.",ModuleAttributeDifferentFromType:"The only accepted module attribute is `type`.",ModuleAttributeInvalidValue:"Only string literals are allowed as module attribute values.",ModuleAttributesWithDuplicateKeys:({key:t})=>`Duplicate key "${t}" is not allowed in module attributes.`,ModuleExportNameHasLoneSurrogate:({surrogateCharCode:t})=>`An export name cannot include a lone surrogate, found '\\u${t.toString(16)}'.`,ModuleExportUndefined:({localName:t})=>`Export '${t}' is not defined.`,MultipleDefaultsInSwitch:"Multiple default clauses.",NewlineAfterThrow:"Illegal newline after throw.",NoCatchOrFinally:"Missing catch or finally clause.",NumberIdentifier:"Identifier directly after number.",NumericSeparatorInEscapeSequence:"Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",ObsoleteAwaitStar:"'await*' has been removed from the async functions proposal. Use Promise.all() instead.",OptionalChainingNoNew:"Constructors in/after an Optional Chain are not allowed.",OptionalChainingNoTemplate:"Tagged Template Literals are not allowed in optionalChain.",OverrideOnConstructor:"'override' modifier cannot appear on a constructor declaration.",ParamDupe:"Argument name clash.",PatternHasAccessor:"Object pattern can't contain getter or setter.",PatternHasMethod:"Object pattern can't contain methods.",PrivateInExpectedIn:({identifierName:t})=>`Private names are only allowed in property accesses (\`obj.#${t}\`) or in \`in\` expressions (\`#${t} in obj\`).`,PrivateNameRedeclaration:({identifierName:t})=>`Duplicate private name #${t}.`,RecordExpressionBarIncorrectEndSyntaxType:"Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",RecordExpressionBarIncorrectStartSyntaxType:"Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",RecordExpressionHashIncorrectStartSyntaxType:"Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",RecordNoProto:"'__proto__' is not allowed in Record expressions.",RestTrailingComma:"Unexpected trailing comma after rest element.",SloppyFunction:"In non-strict mode code, functions can only be declared at top level or inside a block.",SloppyFunctionAnnexB:"In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",SourcePhaseImportRequiresDefault:'Only `import source x from "./module"` is valid.',StaticPrototype:"Classes may not have static property named prototype.",SuperNotAllowed:"`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",SuperPrivateField:"Private fields can't be accessed on super.",TrailingDecorator:"Decorators must be attached to a class element.",TupleExpressionBarIncorrectEndSyntaxType:"Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",TupleExpressionBarIncorrectStartSyntaxType:"Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",TupleExpressionHashIncorrectStartSyntaxType:"Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",UnexpectedArgumentPlaceholder:"Unexpected argument placeholder.",UnexpectedAwaitAfterPipelineBody:'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',UnexpectedDigitAfterHash:"Unexpected digit after hash token.",UnexpectedImportExport:"'import' and 'export' may only appear at the top level.",UnexpectedKeyword:({keyword:t})=>`Unexpected keyword '${t}'.`,UnexpectedLeadingDecorator:"Leading decorators must be attached to a class declaration.",UnexpectedLexicalDeclaration:"Lexical declaration cannot appear in a single-statement context.",UnexpectedNewTarget:"`new.target` can only be used in functions or class properties.",UnexpectedNumericSeparator:"A numeric separator is only allowed between two digits.",UnexpectedPrivateField:"Unexpected private name.",UnexpectedReservedWord:({reservedWord:t})=>`Unexpected reserved word '${t}'.`,UnexpectedSuper:"'super' is only allowed in object methods and classes.",UnexpectedToken:({expected:t,unexpected:e})=>`Unexpected token${e?` '${e}'.`:""}${t?`, expected "${t}"`:""}`,UnexpectedTokenUnaryExponentiation:"Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",UnexpectedUsingDeclaration:"Using declaration cannot appear in the top level when source type is `script`.",UnsupportedBind:"Binding should be performed on object property.",UnsupportedDecoratorExport:"A decorated export must export a class declaration.",UnsupportedDefaultExport:"Only expressions, functions or classes are allowed as the `default` export.",UnsupportedImport:"`import` can only be used in `import()` or `import.meta`.",UnsupportedMetaProperty:({target:t,onlyValidPropertyName:e})=>`The only valid meta property for ${t} is ${t}.${e}.`,UnsupportedParameterDecorator:"Decorators cannot be used to decorate parameters.",UnsupportedPropertyDecorator:"Decorators cannot be used to decorate object literal properties.",UnsupportedSuper:"'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",UnterminatedComment:"Unterminated comment.",UnterminatedRegExp:"Unterminated regular expression.",UnterminatedString:"Unterminated string constant.",UnterminatedTemplate:"Unterminated template.",UsingDeclarationHasBindingPattern:"Using declaration cannot have destructuring patterns.",VarRedeclaration:({identifierName:t})=>`Identifier '${t}' has already been declared.`,YieldBindingIdentifier:"Can not use 'yield' as identifier inside a generator.",YieldInParameter:"Yield expression is not allowed in formal parameters.",ZeroDigitNumericSeparator:"Numeric separator can not be used after leading 0."};const d=new Set(["ArrowFunctionExpression","AssignmentExpression","ConditionalExpression","YieldExpression"]);var I={PipeBodyIsTighter:"Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",PipeTopicRequiresHackPipes:'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.',PipeTopicUnbound:"Topic reference is unbound; it must be inside a pipe body.",PipeTopicUnconfiguredToken:({token:t})=>`Invalid topic token ${t}. In order to use ${t} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${t}" }.`,PipeTopicUnused:"Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",PipeUnparenthesizedBody:({type:t})=>`Hack-style pipe body cannot be an unparenthesized ${h({type:t})}; please wrap it in parentheses.`,PipelineBodyNoArrow:'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.',PipelineBodySequenceExpression:"Pipeline body may not be a comma-separated sequence expression.",PipelineHeadSequenceExpression:"Pipeline head should not be a comma-separated sequence expression.",PipelineTopicUnused:"Pipeline is in topic style but does not use topic reference.",PrimaryTopicNotAllowed:"Topic reference was used in a lexical context without topic binding.",PrimaryTopicRequiresSmartPipeline:'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'};const u=["toMessage"],p=["message"];function b(t,e,i){Object.defineProperty(t,e,{enumerable:!1,configurable:!0,value:i})}function m(t){let{toMessage:e}=t,n=i(t,u);return function t(i,o){const a=new SyntaxError;return Object.assign(a,n,{loc:i,pos:i.index}),"missingPlugin"in o&&Object.assign(a,{missingPlugin:o.missingPlugin}),b(a,"clone",(function(e={}){var n;const{line:a,column:r,index:l}=null!=(n=e.loc)?n:i;return t(new s(a,r,l),Object.assign({},o,e.details))})),b(a,"details",o),Object.defineProperty(a,"message",{configurable:!0,get(){const t=`${e(o)} (${i.line}:${i.column})`;return this.message=t,t},set(t){Object.defineProperty(this,"message",{value:t,writable:!0})}}),a}}function y(t,e){if(Array.isArray(t))return e=>y(e,t[0]);const s={};for(const n of Object.keys(t)){const o=t[n],a="string"==typeof o?{message:()=>o}:"function"==typeof o?{message:o}:o,{message:r}=a,l=i(a,p),h="string"==typeof r?()=>r:r;s[n]=m(Object.assign({code:"BABEL_PARSER_SYNTAX_ERROR",reasonCode:n,toMessage:h},e?{syntaxPlugin:e}:{},l))}return s}const L=Object.assign({},y(r),y(c),y({StrictDelete:"Deleting local variable in strict mode.",StrictEvalArguments:({referenceName:t})=>`Assigning to '${t}' in strict mode.`,StrictEvalArgumentsBinding:({bindingName:t})=>`Binding '${t}' in strict mode.`,StrictFunction:"In strict mode code, functions can only be declared at top level or inside a block.",StrictNumericEscape:"The only valid numeric escape in strict mode is '\\0'.",StrictOctalLiteral:"Legacy octal literals are not allowed in strict mode.",StrictWith:"'with' in strict mode."}),y`pipelineOperator`(I)),{defineProperty:M}=Object,W=(t,e)=>M(t,e,{enumerable:!1,value:t[e]});function w(t){return t.loc.start&&W(t.loc.start,"index"),t.loc.end&&W(t.loc.end,"index"),t}class v{constructor(t,e){this.token=void 0,this.preserveSpace=void 0,this.token=t,this.preserveSpace=!!e}}const j={brace:new v("{"),j_oTag:new v("... ",!0)};j.template=new v("`",!0);const Z=!0,C=!0,G=!0,f=!0,N=!0;class x{constructor(t,e={}){this.label=void 0,this.keyword=void 0,this.beforeExpr=void 0,this.startsExpr=void 0,this.rightAssociative=void 0,this.isLoop=void 0,this.isAssign=void 0,this.prefix=void 0,this.postfix=void 0,this.binop=void 0,this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.rightAssociative=!!e.rightAssociative,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=null!=e.binop?e.binop:null,this.updateContext=null}}const Y=new Map;function R(t,e={}){e.keyword=t;const i=O(t,e);return Y.set(t,i),i}function H(t,e){return O(t,{beforeExpr:Z,binop:e})}let g=-1;const A=[],S=[],z=[],V=[],T=[],k=[];function O(t,e={}){var i,s,n,o;return++g,S.push(t),z.push(null!=(i=e.binop)?i:-1),V.push(null!=(s=e.beforeExpr)&&s),T.push(null!=(n=e.startsExpr)&&n),k.push(null!=(o=e.prefix)&&o),A.push(new x(t,e)),g}function F(t,e={}){var i,s,n,o;return++g,Y.set(t,g),S.push(t),z.push(null!=(i=e.binop)?i:-1),V.push(null!=(s=e.beforeExpr)&&s),T.push(null!=(n=e.startsExpr)&&n),k.push(null!=(o=e.prefix)&&o),A.push(new x("name",e)),g}const J={bracketL:O("[",{beforeExpr:Z,startsExpr:C}),bracketHashL:O("#[",{beforeExpr:Z,startsExpr:C}),bracketBarL:O("[|",{beforeExpr:Z,startsExpr:C}),bracketR:O("]"),bracketBarR:O("|]"),braceL:O("{",{beforeExpr:Z,startsExpr:C}),braceBarL:O("{|",{beforeExpr:Z,startsExpr:C}),braceHashL:O("#{",{beforeExpr:Z,startsExpr:C}),braceR:O("}"),braceBarR:O("|}"),parenL:O("(",{beforeExpr:Z,startsExpr:C}),parenR:O(")"),comma:O(",",{beforeExpr:Z}),semi:O(";",{beforeExpr:Z}),colon:O(":",{beforeExpr:Z}),doubleColon:O("::",{beforeExpr:Z}),dot:O("."),question:O("?",{beforeExpr:Z}),questionDot:O("?."),arrow:O("=>",{beforeExpr:Z}),template:O("template"),ellipsis:O("...",{beforeExpr:Z}),backQuote:O("`",{startsExpr:C}),dollarBraceL:O("${",{beforeExpr:Z,startsExpr:C}),templateTail:O("...`",{startsExpr:C}),templateNonTail:O("...${",{beforeExpr:Z,startsExpr:C}),at:O("@"),hash:O("#",{startsExpr:C}),interpreterDirective:O("#!..."),eq:O("=",{beforeExpr:Z,isAssign:f}),assign:O("_=",{beforeExpr:Z,isAssign:f}),slashAssign:O("_=",{beforeExpr:Z,isAssign:f}),xorAssign:O("_=",{beforeExpr:Z,isAssign:f}),moduloAssign:O("_=",{beforeExpr:Z,isAssign:f}),incDec:O("++/--",{prefix:N,postfix:!0,startsExpr:C}),bang:O("!",{beforeExpr:Z,prefix:N,startsExpr:C}),tilde:O("~",{beforeExpr:Z,prefix:N,startsExpr:C}),doubleCaret:O("^^",{startsExpr:C}),doubleAt:O("@@",{startsExpr:C}),pipeline:H("|>",0),nullishCoalescing:H("??",1),logicalOR:H("||",1),logicalAND:H("&&",2),bitwiseOR:H("|",3),bitwiseXOR:H("^",4),bitwiseAND:H("&",5),equality:H("==/!=/===/!==",6),lt:H(">/<=/>=",7),gt:H(">/<=/>=",7),relational:H(">/<=/>=",7),bitShift:H("<>>/>>>",8),bitShiftL:H("<>>/>>>",8),bitShiftR:H("<>>/>>>",8),plusMin:O("+/-",{beforeExpr:Z,binop:9,prefix:N,startsExpr:C}),modulo:O("%",{binop:10,startsExpr:C}),star:O("*",{binop:10}),slash:H("/",10),exponent:O("**",{beforeExpr:Z,binop:11,rightAssociative:!0}),_in:R("in",{beforeExpr:Z,binop:7}),_instanceof:R("instanceof",{beforeExpr:Z,binop:7}),_break:R("break"),_case:R("case",{beforeExpr:Z}),_catch:R("catch"),_continue:R("continue"),_debugger:R("debugger"),_default:R("default",{beforeExpr:Z}),_else:R("else",{beforeExpr:Z}),_finally:R("finally"),_function:R("function",{startsExpr:C}),_if:R("if"),_return:R("return",{beforeExpr:Z}),_switch:R("switch"),_throw:R("throw",{beforeExpr:Z,prefix:N,startsExpr:C}),_try:R("try"),_var:R("var"),_const:R("const"),_with:R("with"),_new:R("new",{beforeExpr:Z,startsExpr:C}),_this:R("this",{startsExpr:C}),_super:R("super",{startsExpr:C}),_class:R("class",{startsExpr:C}),_extends:R("extends",{beforeExpr:Z}),_export:R("export"),_import:R("import",{startsExpr:C}),_null:R("null",{startsExpr:C}),_true:R("true",{startsExpr:C}),_false:R("false",{startsExpr:C}),_typeof:R("typeof",{beforeExpr:Z,prefix:N,startsExpr:C}),_void:R("void",{beforeExpr:Z,prefix:N,startsExpr:C}),_delete:R("delete",{beforeExpr:Z,prefix:N,startsExpr:C}),_do:R("do",{isLoop:G,beforeExpr:Z}),_for:R("for",{isLoop:G}),_while:R("while",{isLoop:G}),_as:F("as",{startsExpr:C}),_assert:F("assert",{startsExpr:C}),_async:F("async",{startsExpr:C}),_await:F("await",{startsExpr:C}),_defer:F("defer",{startsExpr:C}),_from:F("from",{startsExpr:C}),_get:F("get",{startsExpr:C}),_let:F("let",{startsExpr:C}),_meta:F("meta",{startsExpr:C}),_of:F("of",{startsExpr:C}),_sent:F("sent",{startsExpr:C}),_set:F("set",{startsExpr:C}),_source:F("source",{startsExpr:C}),_static:F("static",{startsExpr:C}),_using:F("using",{startsExpr:C}),_yield:F("yield",{startsExpr:C}),_asserts:F("asserts",{startsExpr:C}),_checks:F("checks",{startsExpr:C}),_exports:F("exports",{startsExpr:C}),_global:F("global",{startsExpr:C}),_implements:F("implements",{startsExpr:C}),_intrinsic:F("intrinsic",{startsExpr:C}),_infer:F("infer",{startsExpr:C}),_is:F("is",{startsExpr:C}),_mixins:F("mixins",{startsExpr:C}),_proto:F("proto",{startsExpr:C}),_require:F("require",{startsExpr:C}),_satisfies:F("satisfies",{startsExpr:C}),_keyof:F("keyof",{startsExpr:C}),_readonly:F("readonly",{startsExpr:C}),_unique:F("unique",{startsExpr:C}),_abstract:F("abstract",{startsExpr:C}),_declare:F("declare",{startsExpr:C}),_enum:F("enum",{startsExpr:C}),_module:F("module",{startsExpr:C}),_namespace:F("namespace",{startsExpr:C}),_interface:F("interface",{startsExpr:C}),_type:F("type",{startsExpr:C}),_opaque:F("opaque",{startsExpr:C}),name:O("name",{startsExpr:C}),string:O("string",{startsExpr:C}),num:O("num",{startsExpr:C}),bigint:O("bigint",{startsExpr:C}),decimal:O("decimal",{startsExpr:C}),regexp:O("regexp",{startsExpr:C}),privateName:O("#name",{startsExpr:C}),eof:O("eof"),jsxName:O("jsxName"),jsxText:O("jsxText",{beforeExpr:!0}),jsxTagStart:O("jsxTagStart",{startsExpr:!0}),jsxTagEnd:O("jsxTagEnd"),placeholder:O("%%",{startsExpr:!0})};function X(t){return t>=93&&t<=132}function E(t){return t>=58&&t<=132}function D(t){return t>=58&&t<=136}function U(t){return T[t]}function B(t){return t>=129&&t<=131}function P(t){return t>=58&&t<=92}function _(t){return S[t]}function Q(t){return z[t]}function q(t){return t>=24&&t<=25}function $(t){return A[t]}A[8].updateContext=t=>{t.pop()},A[5].updateContext=A[7].updateContext=A[23].updateContext=t=>{t.push(j.brace)},A[22].updateContext=t=>{t[t.length-1]===j.template?t.pop():t.push(j.template)},A[142].updateContext=t=>{t.push(j.j_expr,j.j_oTag)};let K="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟊꟐꟑꟓꟕ-ꟙꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",tt="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࢘-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・";const et=new RegExp("["+K+"]"),it=new RegExp("["+K+tt+"]");K=tt=null;const st=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,68,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,4026,582,8634,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,757,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],nt=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,81,2,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,9,5351,0,7,14,13835,9,87,9,39,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,4706,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,983,6,110,6,6,9,4759,9,787719,239];function ot(t,e){let i=65536;for(let s=0,n=e.length;st)return!1;if(i+=e[s+1],i>=t)return!0}return!1}function at(t){return t<65?36===t:t<=90||(t<97?95===t:t<=122||(t<=65535?t>=170&&et.test(String.fromCharCode(t)):ot(t,st)))}function rt(t){return t<48?36===t:t<58||!(t<65)&&(t<=90||(t<97?95===t:t<=122||(t<=65535?t>=170&&it.test(String.fromCharCode(t)):ot(t,st)||ot(t,nt))))}const lt=new Set(["break","case","catch","continue","debugger","default","do","else","finally","for","function","if","return","switch","throw","try","var","const","while","with","new","this","super","class","extends","export","import","null","true","false","in","instanceof","typeof","void","delete"]),ht=new Set(["implements","interface","let","package","private","protected","public","static","yield"]),ct=new Set(["eval","arguments"]);function dt(t,e){return e&&"await"===t||"enum"===t}function It(t,e){return dt(t,e)||ht.has(t)}function ut(t){return ct.has(t)}function pt(t,e){return It(t,e)||ut(t)}const bt=new Set(["break","case","catch","continue","debugger","default","do","else","finally","for","function","if","return","switch","throw","try","var","const","while","with","new","this","super","class","extends","export","import","null","true","false","in","instanceof","typeof","void","delete","implements","interface","let","package","private","protected","public","static","yield","eval","arguments","enum","await"]);class mt{constructor(t){this.flags=0,this.names=new Map,this.firstLexicalName="",this.flags=t}}class yt{constructor(t,e){this.parser=void 0,this.scopeStack=[],this.inModule=void 0,this.undefinedExports=new Map,this.parser=t,this.inModule=e}get inTopLevel(){return(1&this.currentScope().flags)>0}get inFunction(){return(2&this.currentVarScopeFlags())>0}get allowSuper(){return(16&this.currentThisScopeFlags())>0}get allowDirectSuper(){return(32&this.currentThisScopeFlags())>0}get inClass(){return(64&this.currentThisScopeFlags())>0}get inClassAndNotInNonArrowFunction(){const t=this.currentThisScopeFlags();return(64&t)>0&&0==(2&t)}get inStaticBlock(){for(let t=this.scopeStack.length-1;;t--){const{flags:e}=this.scopeStack[t];if(128&e)return!0;if(451&e)return!1}}get inNonArrowFunction(){return(2&this.currentThisScopeFlags())>0}get treatFunctionsAsVar(){return this.treatFunctionsAsVarInScope(this.currentScope())}createScope(t){return new mt(t)}enter(t){this.scopeStack.push(this.createScope(t))}exit(){return this.scopeStack.pop().flags}treatFunctionsAsVarInScope(t){return!!(130&t.flags||!this.parser.inModule&&1&t.flags)}declareName(t,e,i){let s=this.currentScope();if(8&e||16&e){this.checkRedeclarationInScope(s,t,e,i);let n=s.names.get(t)||0;16&e?n|=4:(s.firstLexicalName||(s.firstLexicalName=t),n|=2),s.names.set(t,n),8&e&&this.maybeExportDefined(s,t)}else if(4&e)for(let n=this.scopeStack.length-1;n>=0&&(s=this.scopeStack[n],this.checkRedeclarationInScope(s,t,e,i),s.names.set(t,1|(s.names.get(t)||0)),this.maybeExportDefined(s,t),!(387&s.flags));--n);this.parser.inModule&&1&s.flags&&this.undefinedExports.delete(t)}maybeExportDefined(t,e){this.parser.inModule&&1&t.flags&&this.undefinedExports.delete(e)}checkRedeclarationInScope(t,e,i,s){this.isRedeclaredInScope(t,e,i)&&this.parser.raise(L.VarRedeclaration,s,{identifierName:e})}isRedeclaredInScope(t,e,i){if(!(1&i))return!1;if(8&i)return t.names.has(e);const s=t.names.get(e);return 16&i?(2&s)>0||!this.treatFunctionsAsVarInScope(t)&&(1&s)>0:(2&s)>0&&!(8&t.flags&&t.firstLexicalName===e)||!this.treatFunctionsAsVarInScope(t)&&(4&s)>0}checkLocalExport(t){const{name:e}=t;this.scopeStack[0].names.has(e)||this.undefinedExports.set(e,t.loc.start)}currentScope(){return this.scopeStack[this.scopeStack.length-1]}currentVarScopeFlags(){for(let t=this.scopeStack.length-1;;t--){const{flags:e}=this.scopeStack[t];if(387&e)return e}}currentThisScopeFlags(){for(let t=this.scopeStack.length-1;;t--){const{flags:e}=this.scopeStack[t];if(451&e&&!(4&e))return e}}}class Lt extends mt{constructor(...t){super(...t),this.declareFunctions=new Set}}class Mt extends yt{createScope(t){return new Lt(t)}declareName(t,e,i){const s=this.currentScope();if(2048&e)return this.checkRedeclarationInScope(s,t,e,i),this.maybeExportDefined(s,t),void s.declareFunctions.add(t);super.declareName(t,e,i)}isRedeclaredInScope(t,e,i){if(super.isRedeclaredInScope(t,e,i))return!0;if(2048&i&&!t.declareFunctions.has(e)){const i=t.names.get(e);return(4&i)>0||(2&i)>0}return!1}checkLocalExport(t){this.scopeStack[0].declareFunctions.has(t.name)||super.checkLocalExport(t)}}class Wt{constructor(){this.sawUnambiguousESM=!1,this.ambiguousScriptDifferentAst=!1}hasPlugin(t){if("string"==typeof t)return this.plugins.has(t);{const[e,i]=t;if(!this.hasPlugin(e))return!1;const s=this.plugins.get(e);for(const t of Object.keys(i))if((null==s?void 0:s[t])!==i[t])return!1;return!0}}getPluginOption(t,e){var i;return null==(i=this.plugins.get(t))?void 0:i[e]}}function wt(t,e){void 0===t.trailingComments?t.trailingComments=e:t.trailingComments.unshift(...e)}function vt(t,e){void 0===t.innerComments?t.innerComments=e:t.innerComments.unshift(...e)}function jt(t,e,i){let s=null,n=e.length;for(;null===s&&n>0;)s=e[--n];null===s||s.start>i.start?vt(t,i.comments):wt(s,i.comments)}class Zt extends Wt{addComment(t){this.filename&&(t.loc.filename=this.filename);const{commentsLen:e}=this.state;this.comments.length!=e&&(this.comments.length=e),this.comments.push(t),this.state.commentsLen++}processComment(t){const{commentStack:e}=this.state,i=e.length;if(0===i)return;let s=i-1;const n=e[s];n.start===t.end&&(n.leadingNode=t,s--);const{start:o}=t;for(;s>=0;s--){const i=e[s],n=i.end;if(!(n>o)){n===o&&(i.trailingNode=t);break}i.containingNode=t,this.finalizeComment(i),e.splice(s,1)}}finalizeComment(t){const{comments:e}=t;if(null!==t.leadingNode||null!==t.trailingNode)null!==t.leadingNode&&wt(t.leadingNode,e),null!==t.trailingNode&&function(t,e){void 0===t.leadingComments?t.leadingComments=e:t.leadingComments.unshift(...e)}(t.trailingNode,e);else{const{containingNode:i,start:s}=t;if(44===this.input.charCodeAt(s-1))switch(i.type){case"ObjectExpression":case"ObjectPattern":case"RecordExpression":jt(i,i.properties,t);break;case"CallExpression":case"OptionalCallExpression":jt(i,i.arguments,t);break;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"ObjectMethod":case"ClassMethod":case"ClassPrivateMethod":jt(i,i.params,t);break;case"ArrayExpression":case"ArrayPattern":case"TupleExpression":jt(i,i.elements,t);break;case"ExportNamedDeclaration":case"ImportDeclaration":jt(i,i.specifiers,t);break;default:vt(i,e)}else vt(i,e)}}finalizeRemainingComments(){const{commentStack:t}=this.state;for(let e=t.length-1;e>=0;e--)this.finalizeComment(t[e]);this.state.commentStack=[]}resetPreviousNodeTrailingComments(t){const{commentStack:e}=this.state,{length:i}=e;if(0===i)return;const s=e[i-1];s.leadingNode===t&&(s.leadingNode=null)}resetPreviousIdentifierLeadingComments(t){const{commentStack:e}=this.state,{length:i}=e;0!==i&&(e[i-1].trailingNode===t?e[i-1].trailingNode=null:i>=2&&e[i-2].trailingNode===t&&(e[i-2].trailingNode=null))}takeSurroundingComments(t,e,i){const{commentStack:s}=this.state,n=s.length;if(0===n)return;let o=n-1;for(;o>=0;o--){const n=s[o],a=n.end;if(n.start===i)n.leadingNode=t;else if(a===e)n.trailingNode=t;else if(a0}set strict(t){t?this.flags|=1:this.flags&=-2}init({strictMode:t,sourceType:e,startLine:i,startColumn:n}){this.strict=!1!==t&&(!0===t||"module"===e),this.curLine=i,this.lineStart=-n,this.startLoc=this.endLoc=new s(i,n,0)}get maybeInArrowParameters(){return(2&this.flags)>0}set maybeInArrowParameters(t){t?this.flags|=2:this.flags&=-3}get inType(){return(4&this.flags)>0}set inType(t){t?this.flags|=4:this.flags&=-5}get noAnonFunctionType(){return(8&this.flags)>0}set noAnonFunctionType(t){t?this.flags|=8:this.flags&=-9}get hasFlowComment(){return(16&this.flags)>0}set hasFlowComment(t){t?this.flags|=16:this.flags&=-17}get isAmbientContext(){return(32&this.flags)>0}set isAmbientContext(t){t?this.flags|=32:this.flags&=-33}get inAbstractClass(){return(64&this.flags)>0}set inAbstractClass(t){t?this.flags|=64:this.flags&=-65}get inDisallowConditionalTypesContext(){return(128&this.flags)>0}set inDisallowConditionalTypesContext(t){t?this.flags|=128:this.flags&=-129}get soloAwait(){return(256&this.flags)>0}set soloAwait(t){t?this.flags|=256:this.flags&=-257}get inFSharpPipelineDirectBody(){return(512&this.flags)>0}set inFSharpPipelineDirectBody(t){t?this.flags|=512:this.flags&=-513}get canStartJSXElement(){return(1024&this.flags)>0}set canStartJSXElement(t){t?this.flags|=1024:this.flags&=-1025}get containsEsc(){return(2048&this.flags)>0}set containsEsc(t){t?this.flags|=2048:this.flags&=-2049}curPosition(){return new s(this.curLine,this.pos-this.lineStart,this.pos)}clone(){const t=new Ht;return t.flags=this.flags,t.curLine=this.curLine,t.lineStart=this.lineStart,t.startLoc=this.startLoc,t.endLoc=this.endLoc,t.errors=this.errors.slice(),t.potentialArrowAt=this.potentialArrowAt,t.noArrowAt=this.noArrowAt.slice(),t.noArrowParamsConversionAt=this.noArrowParamsConversionAt.slice(),t.topicContext=this.topicContext,t.labels=this.labels.slice(),t.commentsLen=this.commentsLen,t.commentStack=this.commentStack.slice(),t.pos=this.pos,t.type=this.type,t.value=this.value,t.start=this.start,t.end=this.end,t.lastTokEndLoc=this.lastTokEndLoc,t.lastTokStartLoc=this.lastTokStartLoc,t.context=this.context.slice(),t.firstInvalidTemplateEscapePos=this.firstInvalidTemplateEscapePos,t.strictErrors=this.strictErrors,t.tokensLength=this.tokensLength,t}}var gt=function(t){return t>=48&&t<=57};const At={decBinOct:new Set([46,66,69,79,95,98,101,111]),hex:new Set([46,88,95,120])},St={bin:t=>48===t||49===t,oct:t=>t>=48&&t<=55,dec:t=>t>=48&&t<=57,hex:t=>t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102};function zt(t,e,i,s,n,o){const a=i,r=s,l=n;let h="",c=null,d=i;const{length:I}=e;for(;;){if(i>=I){o.unterminated(a,r,l),h+=e.slice(d,i);break}const u=e.charCodeAt(i);if(Vt(t,u,e,i)){h+=e.slice(d,i);break}if(92===u){h+=e.slice(d,i);const a=Tt(e,i,s,n,"template"===t,o);null!==a.ch||c?h+=a.ch:c={pos:i,lineStart:s,curLine:n},({pos:i,lineStart:s,curLine:n}=a),d=i}else 8232===u||8233===u?(++n,s=++i):10===u||13===u?"template"===t?(h+=e.slice(d,i)+"\n",++i,13===u&&10===e.charCodeAt(i)&&++i,++n,d=s=i):o.unterminated(a,r,l):++i}return{pos:i,str:h,firstInvalidLoc:c,lineStart:s,curLine:n,containsInvalid:!!c}}function Vt(t,e,i,s){return"template"===t?96===e||36===e&&123===i.charCodeAt(s+1):e===("double"===t?34:39)}function Tt(t,e,i,s,n,o){const a=!n;e++;const r=t=>({pos:e,ch:t,lineStart:i,curLine:s}),l=t.charCodeAt(e++);switch(l){case 110:return r("\n");case 114:return r("\r");case 120:{let n;return({code:n,pos:e}=kt(t,e,i,s,2,!1,a,o)),r(null===n?null:String.fromCharCode(n))}case 117:{let n;return({code:n,pos:e}=Ft(t,e,i,s,a,o)),r(null===n?null:String.fromCodePoint(n))}case 116:return r("\t");case 98:return r("\b");case 118:return r("\v");case 102:return r("\f");case 13:10===t.charCodeAt(e)&&++e;case 10:i=e,++s;case 8232:case 8233:return r("");case 56:case 57:if(n)return r(null);o.strictNumericEscape(e-1,i,s);default:if(l>=48&&l<=55){const a=e-1;let l=t.slice(a,e+2).match(/^[0-7]+/)[0],h=parseInt(l,8);h>255&&(l=l.slice(0,-1),h=parseInt(l,8)),e+=l.length-1;const c=t.charCodeAt(e);if("0"!==l||56===c||57===c){if(n)return r(null);o.strictNumericEscape(a,i,s)}return r(String.fromCharCode(h))}return r(String.fromCharCode(l))}}function kt(t,e,i,s,n,o,a,r){const l=e;let h;return({n:h,pos:e}=Ot(t,e,i,s,16,n,o,!1,r,!a)),null===h&&(a?r.invalidEscapeSequence(l,i,s):e=l-1),{code:h,pos:e}}function Ot(t,e,i,s,n,o,a,r,l,h){const c=e,d=16===n?At.hex:At.decBinOct,I=16===n?St.hex:10===n?St.dec:8===n?St.oct:St.bin;let u=!1,p=0;for(let c=0,b=null==o?1/0:o;c=97?o-97+10:o>=65?o-65+10:gt(o)?o-48:1/0,c>=n){if(c<=9&&h)return{n:null,pos:e};if(c<=9&&l.invalidDigit(e,i,s,n))c=0;else{if(!a)break;c=0,u=!0}}++e,p=p*n+c}else{const n=t.charCodeAt(e-1),o=t.charCodeAt(e+1);if(r){if(Number.isNaN(o)||!I(o)||d.has(n)||d.has(o)){if(h)return{n:null,pos:e};l.unexpectedNumericSeparator(e,i,s)}}else{if(h)return{n:null,pos:e};l.numericSeparatorInEscapeSequence(e,i,s)}++e}}return e===c||null!=o&&e-c!==o||u?{n:null,pos:e}:{n:p,pos:e}}function Ft(t,e,i,s,n,o){let a;if(123===t.charCodeAt(e)){if(++e,({code:a,pos:e}=kt(t,e,i,s,t.indexOf("}",e)-e,!0,n,o)),++e,null!==a&&a>1114111){if(!n)return{code:null,pos:e};o.invalidCodePoint(e,i,s)}}else({code:a,pos:e}=kt(t,e,i,s,4,!1,n,o));return{code:a,pos:e}}function Jt(t,e,i){return new s(i,t-e,t)}const Xt=new Set([103,109,115,105,121,117,100,118]);class Et{constructor(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,this.loc=new n(t.startLoc,t.endLoc)}}class Dt extends Zt{constructor(t,e){super(),this.isLookahead=void 0,this.tokens=[],this.errorHandlers_readInt={invalidDigit:(t,e,i,s)=>!!this.options.errorRecovery&&(this.raise(L.InvalidDigit,Jt(t,e,i),{radix:s}),!0),numericSeparatorInEscapeSequence:this.errorBuilder(L.NumericSeparatorInEscapeSequence),unexpectedNumericSeparator:this.errorBuilder(L.UnexpectedNumericSeparator)},this.errorHandlers_readCodePoint=Object.assign({},this.errorHandlers_readInt,{invalidEscapeSequence:this.errorBuilder(L.InvalidEscapeSequence),invalidCodePoint:this.errorBuilder(L.InvalidCodePoint)}),this.errorHandlers_readStringContents_string=Object.assign({},this.errorHandlers_readCodePoint,{strictNumericEscape:(t,e,i)=>{this.recordStrictModeErrors(L.StrictNumericEscape,Jt(t,e,i))},unterminated:(t,e,i)=>{throw this.raise(L.UnterminatedString,Jt(t-1,e,i))}}),this.errorHandlers_readStringContents_template=Object.assign({},this.errorHandlers_readCodePoint,{strictNumericEscape:this.errorBuilder(L.StrictNumericEscape),unterminated:(t,e,i)=>{throw this.raise(L.UnterminatedTemplate,Jt(t,e,i))}}),this.state=new Ht,this.state.init(t),this.input=e,this.length=e.length,this.comments=[],this.isLookahead=!1}pushToken(t){this.tokens.length=this.state.tokensLength,this.tokens.push(t),++this.state.tokensLength}next(){this.checkKeywordEscapes(),this.options.tokens&&this.pushToken(new Et(this.state)),this.state.lastTokEndLoc=this.state.endLoc,this.state.lastTokStartLoc=this.state.startLoc,this.nextToken()}eat(t){return!!this.match(t)&&(this.next(),!0)}match(t){return this.state.type===t}createLookaheadState(t){return{pos:t.pos,value:null,type:t.type,start:t.start,end:t.end,context:[this.curContext()],inType:t.inType,startLoc:t.startLoc,lastTokEndLoc:t.lastTokEndLoc,curLine:t.curLine,lineStart:t.lineStart,curPosition:t.curPosition}}lookahead(){const t=this.state;this.state=this.createLookaheadState(t),this.isLookahead=!0,this.nextToken(),this.isLookahead=!1;const e=this.state;return this.state=t,e}nextTokenStart(){return this.nextTokenStartSince(this.state.pos)}nextTokenStartSince(t){return Nt.lastIndex=t,Nt.test(this.input)?Nt.lastIndex:t}lookaheadCharCode(){return this.input.charCodeAt(this.nextTokenStart())}nextTokenInLineStart(){return this.nextTokenInLineStartSince(this.state.pos)}nextTokenInLineStartSince(t){return xt.lastIndex=t,xt.test(this.input)?xt.lastIndex:t}lookaheadInLineCharCode(){return this.input.charCodeAt(this.nextTokenInLineStart())}codePointAtPos(t){let e=this.input.charCodeAt(t);if(55296==(64512&e)&&++tthis.raise(t,e))),this.state.strictErrors.clear())}curContext(){return this.state.context[this.state.context.length-1]}nextToken(){this.skipSpace(),this.state.start=this.state.pos,this.isLookahead||(this.state.startLoc=this.state.curPosition()),this.state.pos>=this.length?this.finishToken(139):this.getTokenFromCode(this.codePointAtPos(this.state.pos))}skipBlockComment(t){let e;this.isLookahead||(e=this.state.curPosition());const i=this.state.pos,s=this.input.indexOf(t,i+2);if(-1===s)throw this.raise(L.UnterminatedComment,this.state.curPosition());for(this.state.pos=s+t.length,Gt.lastIndex=i+2;Gt.test(this.input)&&Gt.lastIndex<=s;)++this.state.curLine,this.state.lineStart=Gt.lastIndex;if(this.isLookahead)return;const o={type:"CommentBlock",value:this.input.slice(i+2,s),start:i,end:s+t.length,loc:new n(e,this.state.curPosition())};return this.options.tokens&&this.pushToken(o),o}skipLineComment(t){const e=this.state.pos;let i;this.isLookahead||(i=this.state.curPosition());let s=this.input.charCodeAt(this.state.pos+=t);if(this.state.post))break t;{const t=this.skipLineComment(3);void 0!==t&&(this.addComment(t),this.options.attachComment&&e.push(t))}}else{if(60!==i||this.inModule||!this.options.annexB)break t;{const t=this.state.pos;if(33!==this.input.charCodeAt(t+1)||45!==this.input.charCodeAt(t+2)||45!==this.input.charCodeAt(t+3))break t;{const t=this.skipLineComment(4);void 0!==t&&(this.addComment(t),this.options.attachComment&&e.push(t))}}}}}if(e.length>0){const i={start:t,end:this.state.pos,comments:e,leadingNode:null,trailingNode:null,containingNode:null};this.state.commentStack.push(i)}}finishToken(t,e){this.state.end=this.state.pos,this.state.endLoc=this.state.curPosition();const i=this.state.type;this.state.type=t,this.state.value=e,this.isLookahead||this.updateContext(i)}replaceToken(t){this.state.type=t,this.updateContext()}readToken_numberSign(){if(0===this.state.pos&&this.readToken_interpreter())return;const t=this.state.pos+1,e=this.codePointAtPos(t);if(e>=48&&e<=57)throw this.raise(L.UnexpectedDigitAfterHash,this.state.curPosition());if(123===e||91===e&&this.hasPlugin("recordAndTuple")){if(this.expectPlugin("recordAndTuple"),"bar"===this.getPluginOption("recordAndTuple","syntaxType"))throw this.raise(123===e?L.RecordExpressionHashIncorrectStartSyntaxType:L.TupleExpressionHashIncorrectStartSyntaxType,this.state.curPosition());this.state.pos+=2,123===e?this.finishToken(7):this.finishToken(1)}else at(e)?(++this.state.pos,this.finishToken(138,this.readWord1(e))):92===e?(++this.state.pos,this.finishToken(138,this.readWord1())):this.finishOp(27,1)}readToken_dot(){const t=this.input.charCodeAt(this.state.pos+1);t>=48&&t<=57?this.readNumber(!0):46===t&&46===this.input.charCodeAt(this.state.pos+2)?(this.state.pos+=3,this.finishToken(21)):(++this.state.pos,this.finishToken(16))}readToken_slash(){61===this.input.charCodeAt(this.state.pos+1)?this.finishOp(31,2):this.finishOp(56,1)}readToken_interpreter(){if(0!==this.state.pos||this.length<2)return!1;let t=this.input.charCodeAt(this.state.pos+1);if(33!==t)return!1;const e=this.state.pos;for(this.state.pos+=1;!ft(t)&&++this.state.pos=48&&e<=57?(++this.state.pos,this.finishToken(17)):(this.state.pos+=2,this.finishToken(18))}getTokenFromCode(t){switch(t){case 46:return void this.readToken_dot();case 40:return++this.state.pos,void this.finishToken(10);case 41:return++this.state.pos,void this.finishToken(11);case 59:return++this.state.pos,void this.finishToken(13);case 44:return++this.state.pos,void this.finishToken(12);case 91:if(this.hasPlugin("recordAndTuple")&&124===this.input.charCodeAt(this.state.pos+1)){if("bar"!==this.getPluginOption("recordAndTuple","syntaxType"))throw this.raise(L.TupleExpressionBarIncorrectStartSyntaxType,this.state.curPosition());this.state.pos+=2,this.finishToken(2)}else++this.state.pos,this.finishToken(0);return;case 93:return++this.state.pos,void this.finishToken(3);case 123:if(this.hasPlugin("recordAndTuple")&&124===this.input.charCodeAt(this.state.pos+1)){if("bar"!==this.getPluginOption("recordAndTuple","syntaxType"))throw this.raise(L.RecordExpressionBarIncorrectStartSyntaxType,this.state.curPosition());this.state.pos+=2,this.finishToken(6)}else++this.state.pos,this.finishToken(5);return;case 125:return++this.state.pos,void this.finishToken(8);case 58:return void(this.hasPlugin("functionBind")&&58===this.input.charCodeAt(this.state.pos+1)?this.finishOp(15,2):(++this.state.pos,this.finishToken(14)));case 63:return void this.readToken_question();case 96:return void this.readTemplateToken();case 48:{const t=this.input.charCodeAt(this.state.pos+1);if(120===t||88===t)return void this.readRadixNumber(16);if(111===t||79===t)return void this.readRadixNumber(8);if(98===t||66===t)return void this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return void this.readNumber(!1);case 34:case 39:return void this.readString(t);case 47:return void this.readToken_slash();case 37:case 42:return void this.readToken_mult_modulo(t);case 124:case 38:return void this.readToken_pipe_amp(t);case 94:return void this.readToken_caret();case 43:case 45:return void this.readToken_plus_min(t);case 60:return void this.readToken_lt();case 62:return void this.readToken_gt();case 61:case 33:return void this.readToken_eq_excl(t);case 126:return void this.finishOp(36,1);case 64:return void this.readToken_atSign();case 35:return void this.readToken_numberSign();case 92:return void this.readWord();default:if(at(t))return void this.readWord(t)}throw this.raise(L.InvalidOrUnexpectedToken,this.state.curPosition(),{unexpected:String.fromCodePoint(t)})}finishOp(t,e){const i=this.input.slice(this.state.pos,this.state.pos+e);this.state.pos+=e,this.finishToken(t,i)}readRegexp(){const t=this.state.startLoc,e=this.state.start+1;let i,s,{pos:n}=this.state;for(;;++n){if(n>=this.length)throw this.raise(L.UnterminatedRegExp,o(t,1));const e=this.input.charCodeAt(n);if(ft(e))throw this.raise(L.UnterminatedRegExp,o(t,1));if(i)i=!1;else{if(91===e)s=!0;else if(93===e&&s)s=!1;else if(47===e&&!s)break;i=92===e}}const a=this.input.slice(e,n);++n;let r="";const l=()=>o(t,n+2-e);for(;n=2&&48===this.input.charCodeAt(e);if(h){const t=this.input.slice(e,this.state.pos);if(this.recordStrictModeErrors(L.StrictOctalLiteral,i),!this.state.strict){const e=t.indexOf("_");e>0&&this.raise(L.ZeroDigitNumericSeparator,o(i,e))}l=h&&!/[89]/.test(t)}let c=this.input.charCodeAt(this.state.pos);if(46!==c||l||(++this.state.pos,this.readInt(10),s=!0,c=this.input.charCodeAt(this.state.pos)),69!==c&&101!==c||l||(c=this.input.charCodeAt(++this.state.pos),43!==c&&45!==c||++this.state.pos,null===this.readInt(10)&&this.raise(L.InvalidOrMissingExponent,i),s=!0,r=!0,c=this.input.charCodeAt(this.state.pos)),110===c&&((s||h)&&this.raise(L.InvalidBigIntLiteral,i),++this.state.pos,n=!0),109===c&&(this.expectPlugin("decimal",this.state.curPosition()),(r||h)&&this.raise(L.InvalidDecimal,i),++this.state.pos,a=!0),at(this.codePointAtPos(this.state.pos)))throw this.raise(L.NumberIdentifier,this.state.curPosition());const d=this.input.slice(e,this.state.pos).replace(/[_mn]/g,"");if(n)return void this.finishToken(135,d);if(a)return void this.finishToken(136,d);const I=l?parseInt(d,8):parseFloat(d);this.finishToken(134,I)}readCodePoint(t){const{code:e,pos:i}=Ft(this.input,this.state.pos,this.state.lineStart,this.state.curLine,t,this.errorHandlers_readCodePoint);return this.state.pos=i,e}readString(t){const{str:e,pos:i,curLine:s,lineStart:n}=zt(34===t?"double":"single",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_string);this.state.pos=i+1,this.state.lineStart=n,this.state.curLine=s,this.finishToken(133,e)}readTemplateContinuation(){this.match(8)||this.unexpected(null,8),this.state.pos--,this.readTemplateToken()}readTemplateToken(){const t=this.input[this.state.pos],{str:e,firstInvalidLoc:i,pos:n,curLine:o,lineStart:a}=zt("template",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_template);this.state.pos=n+1,this.state.lineStart=a,this.state.curLine=o,i&&(this.state.firstInvalidTemplateEscapePos=new s(i.curLine,i.pos-i.lineStart,i.pos)),96===this.input.codePointAt(n)?this.finishToken(24,i?null:t+e+"`"):(this.state.pos++,this.finishToken(25,i?null:t+e+"${"))}recordStrictModeErrors(t,e){const i=e.index;this.state.strict&&!this.state.strictErrors.has(i)?this.raise(t,e):this.state.strictErrors.set(i,[t,e])}readWord1(t){this.state.containsEsc=!1;let e="";const i=this.state.pos;let s=this.state.pos;for(void 0!==t&&(this.state.pos+=t<=65535?1:2);this.state.pos=0;e--){const s=a[e];if(s.loc.index===o)return a[e]=t(n,i);if(s.loc.indexthis.hasPlugin(t))))throw this.raise(L.MissingOneOfPlugins,this.state.startLoc,{missingPlugin:t})}errorBuilder(t){return(e,i,s)=>{this.raise(t,Jt(e,i,s))}}}class Ut{constructor(){this.privateNames=new Set,this.loneAccessors=new Map,this.undefinedPrivateNames=new Map}}class Bt{constructor(t){this.parser=void 0,this.stack=[],this.undefinedPrivateNames=new Map,this.parser=t}current(){return this.stack[this.stack.length-1]}enter(){this.stack.push(new Ut)}exit(){const t=this.stack.pop(),e=this.current();for(const[i,s]of Array.from(t.undefinedPrivateNames))e?e.undefinedPrivateNames.has(i)||e.undefinedPrivateNames.set(i,s):this.parser.raise(L.InvalidPrivateFieldResolution,s,{identifierName:i})}declarePrivateName(t,e,i){const{privateNames:s,loneAccessors:n,undefinedPrivateNames:o}=this.current();let a=s.has(t);if(3&e){const i=a&&n.get(t);i?(a=(3&i)==(3&e)||(4&i)!=(4&e),a||n.delete(t)):a||n.set(t,e)}a&&this.parser.raise(L.PrivateNameRedeclaration,i,{identifierName:t}),s.add(t),o.delete(t)}usePrivateName(t,e){let i;for(i of this.stack)if(i.privateNames.has(t))return;i?i.undefinedPrivateNames.set(t,e):this.parser.raise(L.InvalidPrivateFieldResolution,e,{identifierName:t})}}class Pt{constructor(t=0){this.type=t}canBeArrowParameterDeclaration(){return 2===this.type||1===this.type}isCertainlyParameterDeclaration(){return 3===this.type}}class _t extends Pt{constructor(t){super(t),this.declarationErrors=new Map}recordDeclarationError(t,e){const i=e.index;this.declarationErrors.set(i,[t,e])}clearDeclarationError(t){this.declarationErrors.delete(t)}iterateErrors(t){this.declarationErrors.forEach(t)}}class Qt{constructor(t){this.parser=void 0,this.stack=[new Pt],this.parser=t}enter(t){this.stack.push(t)}exit(){this.stack.pop()}recordParameterInitializerError(t,e){const i=e.loc.start,{stack:s}=this;let n=s.length-1,o=s[n];for(;!o.isCertainlyParameterDeclaration();){if(!o.canBeArrowParameterDeclaration())return;o.recordDeclarationError(t,i),o=s[--n]}this.parser.raise(t,i)}recordArrowParameterBindingError(t,e){const{stack:i}=this,s=i[i.length-1],n=e.loc.start;if(s.isCertainlyParameterDeclaration())this.parser.raise(t,n);else{if(!s.canBeArrowParameterDeclaration())return;s.recordDeclarationError(t,n)}}recordAsyncArrowParametersError(t){const{stack:e}=this;let i=e.length-1,s=e[i];for(;s.canBeArrowParameterDeclaration();)2===s.type&&s.recordDeclarationError(L.AwaitBindingIdentifier,t),s=e[--i]}validateAsPattern(){const{stack:t}=this,e=t[t.length-1];e.canBeArrowParameterDeclaration()&&e.iterateErrors((([e,i])=>{this.parser.raise(e,i);let s=t.length-2,n=t[s];for(;n.canBeArrowParameterDeclaration();)n.clearDeclarationError(i.index),n=t[--s]}))}}function qt(){return new Pt}class $t{constructor(){this.stacks=[]}enter(t){this.stacks.push(t)}exit(){this.stacks.pop()}currentFlags(){return this.stacks[this.stacks.length-1]}get hasAwait(){return(2&this.currentFlags())>0}get hasYield(){return(1&this.currentFlags())>0}get hasReturn(){return(4&this.currentFlags())>0}get hasIn(){return(8&this.currentFlags())>0}}function Kt(t,e){return(t?2:0)|(e?1:0)}class te extends Dt{addExtra(t,e,i,s=!0){if(!t)return;const n=t.extra=t.extra||{};s?n[e]=i:Object.defineProperty(n,e,{enumerable:s,value:i})}isContextual(t){return this.state.type===t&&!this.state.containsEsc}isUnparsedContextual(t,e){const i=t+e.length;if(this.input.slice(t,i)===e){const t=this.input.charCodeAt(i);return!(rt(t)||55296==(64512&t))}return!1}isLookaheadContextual(t){const e=this.nextTokenStart();return this.isUnparsedContextual(e,t)}eatContextual(t){return!!this.isContextual(t)&&(this.next(),!0)}expectContextual(t,e){if(!this.eatContextual(t)){if(null!=e)throw this.raise(e,this.state.startLoc);this.unexpected(null,t)}}canInsertSemicolon(){return this.match(139)||this.match(8)||this.hasPrecedingLineBreak()}hasPrecedingLineBreak(){return Ct.test(this.input.slice(this.state.lastTokEndLoc.index,this.state.start))}hasFollowingLineBreak(){return Yt.lastIndex=this.state.end,Yt.test(this.input)}isLineTerminator(){return this.eat(13)||this.canInsertSemicolon()}semicolon(t=!0){(t?this.isLineTerminator():this.eat(13))||this.raise(L.MissingSemicolon,this.state.lastTokEndLoc)}expect(t,e){this.eat(t)||this.unexpected(e,t)}tryParse(t,e=this.state.clone()){const i={node:null};try{const s=t(((t=null)=>{throw i.node=t,i}));if(this.state.errors.length>e.errors.length){const t=this.state;return this.state=e,this.state.tokensLength=t.tokensLength,{node:s,error:t.errors[e.errors.length],thrown:!1,aborted:!1,failState:t}}return{node:s,error:null,thrown:!1,aborted:!1,failState:null}}catch(t){const s=this.state;if(this.state=e,t instanceof SyntaxError)return{node:null,error:t,thrown:!0,aborted:!1,failState:s};if(t===i)return{node:i.node,error:null,thrown:!1,aborted:!0,failState:s};throw t}}checkExpressionErrors(t,e){if(!t)return!1;const{shorthandAssignLoc:i,doubleProtoLoc:s,privateKeyLoc:n,optionalParametersLoc:o}=t;if(!e)return!!(i||s||o||n);null!=i&&this.raise(L.InvalidCoverInitializedName,i),null!=s&&this.raise(L.DuplicateProto,s),null!=n&&this.raise(L.UnexpectedPrivateField,n),null!=o&&this.unexpected(o)}isLiteralPropertyName(){return D(this.state.type)}isPrivateName(t){return"PrivateName"===t.type}getPrivateNameSV(t){return t.id.name}hasPropertyAsPrivateName(t){return("MemberExpression"===t.type||"OptionalMemberExpression"===t.type)&&this.isPrivateName(t.property)}isObjectProperty(t){return"ObjectProperty"===t.type}isObjectMethod(t){return"ObjectMethod"===t.type}initializeScopes(t="module"===this.options.sourceType){const e=this.state.labels;this.state.labels=[];const i=this.exportedIdentifiers;this.exportedIdentifiers=new Set;const s=this.inModule;this.inModule=t;const n=this.scope,o=this.getScopeHandler();this.scope=new o(this,t);const a=this.prodParam;this.prodParam=new $t;const r=this.classScope;this.classScope=new Bt(this);const l=this.expressionScope;return this.expressionScope=new Qt(this),()=>{this.state.labels=e,this.exportedIdentifiers=i,this.inModule=s,this.scope=n,this.prodParam=a,this.classScope=r,this.expressionScope=l}}enterInitialScopes(){let t=0;this.inModule&&(t|=2),this.scope.enter(1),this.prodParam.enter(t)}checkDestructuringPrivate(t){const{privateKeyLoc:e}=t;null!==e&&this.expectPlugin("destructuringPrivate",e)}}class ee{constructor(){this.shorthandAssignLoc=null,this.doubleProtoLoc=null,this.privateKeyLoc=null,this.optionalParametersLoc=null}}class ie{constructor(t,e,i){this.type="",this.start=e,this.end=0,this.loc=new n(i),null!=t&&t.options.ranges&&(this.range=[e,0]),null!=t&&t.filename&&(this.loc.filename=t.filename)}}const se=ie.prototype;function ne(t){const{type:e,start:i,end:s,loc:n,range:o,extra:a,name:r}=t,l=Object.create(se);return l.type=e,l.start=i,l.end=s,l.loc=n,l.range=o,l.extra=a,l.name=r,"Placeholder"===e&&(l.expectedNode=t.expectedNode),l}se.__clone=function(){const t=new ie(void 0,this.start,this.loc.start),e=Object.keys(this);for(let i=0,s=e.length;i`Cannot overwrite reserved type ${t}.`,DeclareClassElement:"The `declare` modifier can only appear on class fields.",DeclareClassFieldInitializer:"Initializers are not allowed in fields with the `declare` modifier.",DuplicateDeclareModuleExports:"Duplicate `declare module.exports` statement.",EnumBooleanMemberNotInitialized:({memberName:t,enumName:e})=>`Boolean enum members need to be initialized. Use either \`${t} = true,\` or \`${t} = false,\` in enum \`${e}\`.`,EnumDuplicateMemberName:({memberName:t,enumName:e})=>`Enum member names need to be unique, but the name \`${t}\` has already been used before in enum \`${e}\`.`,EnumInconsistentMemberValues:({enumName:t})=>`Enum \`${t}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,EnumInvalidExplicitType:({invalidEnumType:t,enumName:e})=>`Enum type \`${t}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${e}\`.`,EnumInvalidExplicitTypeUnknownSupplied:({enumName:t})=>`Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${t}\`.`,EnumInvalidMemberInitializerPrimaryType:({enumName:t,memberName:e,explicitType:i})=>`Enum \`${t}\` has type \`${i}\`, so the initializer of \`${e}\` needs to be a ${i} literal.`,EnumInvalidMemberInitializerSymbolType:({enumName:t,memberName:e})=>`Symbol enum members cannot be initialized. Use \`${e},\` in enum \`${t}\`.`,EnumInvalidMemberInitializerUnknownType:({enumName:t,memberName:e})=>`The enum member initializer for \`${e}\` needs to be a literal (either a boolean, number, or string) in enum \`${t}\`.`,EnumInvalidMemberName:({enumName:t,memberName:e,suggestion:i})=>`Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${e}\`, consider using \`${i}\`, in enum \`${t}\`.`,EnumNumberMemberNotInitialized:({enumName:t,memberName:e})=>`Number enum members need to be initialized, e.g. \`${e} = 1\` in enum \`${t}\`.`,EnumStringMemberInconsistentlyInitialized:({enumName:t})=>`String enum members need to consistently either all use initializers, or use no initializers, in enum \`${t}\`.`,GetterMayNotHaveThisParam:"A getter cannot have a `this` parameter.",ImportReflectionHasImportType:"An `import module` declaration can not use `type` or `typeof` keyword.",ImportTypeShorthandOnlyInPureImport:"The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements.",InexactInsideExact:"Explicit inexact syntax cannot appear inside an explicit exact object type.",InexactInsideNonObject:"Explicit inexact syntax cannot appear in class or interface definitions.",InexactVariance:"Explicit inexact syntax cannot have variance.",InvalidNonTypeImportInDeclareModule:"Imports within a `declare module` body must always be `import type` or `import typeof`.",MissingTypeParamDefault:"Type parameter declaration needs a default, since a preceding type parameter declaration has a default.",NestedDeclareModule:"`declare module` cannot be used inside another `declare module`.",NestedFlowComment:"Cannot have a flow comment inside another flow comment.",PatternIsOptional:Object.assign({message:"A binding pattern parameter cannot be optional in an implementation signature."},{reasonCode:"OptionalBindingPattern"}),SetterMayNotHaveThisParam:"A setter cannot have a `this` parameter.",SpreadVariance:"Spread properties cannot have variance.",ThisParamAnnotationRequired:"A type annotation is required for the `this` parameter.",ThisParamBannedInConstructor:"Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",ThisParamMayNotBeOptional:"The `this` parameter cannot be optional.",ThisParamMustBeFirst:"The `this` parameter must be the first function parameter.",ThisParamNoDefault:"The `this` parameter may not have a default value.",TypeBeforeInitializer:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeCastInPattern:"The type cast expression is expected to be wrapped with parenthesis.",UnexpectedExplicitInexactInObject:"Explicit inexact syntax must appear at the end of an inexact object.",UnexpectedReservedType:({reservedType:t})=>`Unexpected reserved type ${t}.`,UnexpectedReservedUnderscore:"`_` is only allowed as a type argument to call or new.",UnexpectedSpaceBetweenModuloChecks:"Spaces between `%` and `checks` are not allowed here.",UnexpectedSpreadType:"Spread operator cannot appear in class or interface definitions.",UnexpectedSubtractionOperand:'Unexpected token, expected "number" or "bigint".',UnexpectedTokenAfterTypeParameter:"Expected an arrow function after this type parameter declaration.",UnexpectedTypeParameterBeforeAsyncArrowFunction:"Type parameters must come after the async keyword, e.g. instead of ` async () => {}`, use `async () => {}`.",UnsupportedDeclareExportKind:({unsupportedExportKind:t,suggestion:e})=>`\`declare export ${t}\` is not supported. Use \`${e}\` instead.`,UnsupportedStatementInDeclareModule:"Only declares and type imports are allowed inside declare module.",UnterminatedFlowComment:"Unterminated flow-comment."});function le(t){return"type"===t.importKind||"typeof"===t.importKind}const he={const:"declare export var",let:"declare export var",type:"export type",interface:"export interface"},ce=/\*?\s*@((?:no)?flow)\b/,de={__proto__:null,quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"},Ie=y`jsx`({AttributeIsEmpty:"JSX attributes must only be assigned a non-empty expression.",MissingClosingTagElement:({openingTagName:t})=>`Expected corresponding JSX closing tag for <${t}>.`,MissingClosingTagFragment:"Expected corresponding JSX closing tag for <>.",UnexpectedSequenceExpression:"Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",UnexpectedToken:({unexpected:t,HTMLEntity:e})=>`Unexpected token \`${t}\`. Did you mean \`${e}\` or \`{'${t}'}\`?`,UnsupportedJsxValue:"JSX value should be either an expression or a quoted JSX text.",UnterminatedJsxContent:"Unterminated JSX contents.",UnwrappedAdjacentJSXElements:"Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...>?"});function ue(t){return!!t&&("JSXOpeningFragment"===t.type||"JSXClosingFragment"===t.type)}function pe(t){if("JSXIdentifier"===t.type)return t.name;if("JSXNamespacedName"===t.type)return t.namespace.name+":"+t.name.name;if("JSXMemberExpression"===t.type)return pe(t.object)+"."+pe(t.property);throw new Error("Node had unexpected type: "+t.type)}class be extends mt{constructor(...t){super(...t),this.tsNames=new Map}}class me extends yt{constructor(...t){super(...t),this.importsStack=[]}createScope(t){return this.importsStack.push(new Set),new be(t)}enter(t){256==t&&this.importsStack.push(new Set),super.enter(t)}exit(){const t=super.exit();return 256==t&&this.importsStack.pop(),t}hasImport(t,e){const i=this.importsStack.length;if(this.importsStack[i-1].has(t))return!0;if(!e&&i>1)for(let e=0;e0?!(256&i)||!!(512&i)!=(4&s)>0:128&i&&(8&s)>0?!!(2&t.names.get(e))&&!!(1&i):!!(2&i&&(1&s)>0)||super.isRedeclaredInScope(t,e,i)}checkLocalExport(t){const{name:e}=t;if(!this.hasImport(e)){for(let t=this.scopeStack.length-1;t>=0;t--){const i=this.scopeStack[t].tsNames.get(e);if((1&i)>0||(16&i)>0)return}super.checkLocalExport(t)}}}const ye=t=>"ParenthesizedExpression"===t.type?ye(t.expression):t;class Le extends oe{toAssignable(t,e=!1){var i,s;let n;switch(("ParenthesizedExpression"===t.type||null!=(i=t.extra)&&i.parenthesized)&&(n=ye(t),e?"Identifier"===n.type?this.expressionScope.recordArrowParameterBindingError(L.InvalidParenthesizedAssignment,t):"MemberExpression"===n.type||this.isOptionalMemberExpression(n)||this.raise(L.InvalidParenthesizedAssignment,t):this.raise(L.InvalidParenthesizedAssignment,t)),t.type){case"Identifier":case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern";for(let i=0,s=t.properties.length,n=s-1;i"ObjectMethod"!==t.type&&(i===e||"SpreadElement"!==t.type)&&this.isAssignable(t)))}case"ObjectProperty":return this.isAssignable(t.value);case"SpreadElement":return this.isAssignable(t.argument);case"ArrayExpression":return t.elements.every((t=>null===t||this.isAssignable(t)));case"AssignmentExpression":return"="===t.operator;case"ParenthesizedExpression":return this.isAssignable(t.expression);case"MemberExpression":case"OptionalMemberExpression":return!e;default:return!1}}toReferencedList(t,e){return t}toReferencedListDeep(t,e){this.toReferencedList(t,e);for(const e of t)"ArrayExpression"===(null==e?void 0:e.type)&&this.toReferencedListDeep(e.elements)}parseSpread(t){const e=this.startNode();return this.next(),e.argument=this.parseMaybeAssignAllowIn(t,void 0),this.finishNode(e,"SpreadElement")}parseRestBinding(){const t=this.startNode();return this.next(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")}parseBindingAtom(){switch(this.state.type){case 0:{const t=this.startNode();return this.next(),t.elements=this.parseBindingList(3,93,1),this.finishNode(t,"ArrayPattern")}case 5:return this.parseObjectLike(8,!0)}return this.parseIdentifier()}parseBindingList(t,e,i){const s=1&i,n=[];let o=!0;for(;!this.eat(t);)if(o?o=!1:this.expect(12),s&&this.match(12))n.push(null);else{if(this.eat(t))break;if(this.match(21)){if(n.push(this.parseAssignableListItemTypes(this.parseRestBinding(),i)),!this.checkCommaAfterRest(e)){this.expect(t);break}}else{const t=[];for(this.match(26)&&this.hasPlugin("decorators")&&this.raise(L.UnsupportedParameterDecorator,this.state.startLoc);this.match(26);)t.push(this.parseDecorator());n.push(this.parseAssignableListItem(i,t))}}return n}parseBindingRestProperty(t){return this.next(),t.argument=this.parseIdentifier(),this.checkCommaAfterRest(125),this.finishNode(t,"RestElement")}parseBindingProperty(){const t=this.startNode(),{type:e,startLoc:i}=this.state;return 21===e?this.parseBindingRestProperty(t):(138===e?(this.expectPlugin("destructuringPrivate",i),this.classScope.usePrivateName(this.state.value,i),t.key=this.parsePrivateName()):this.parsePropertyName(t),t.method=!1,this.parseObjPropValue(t,i,!1,!1,!0,!1))}parseAssignableListItem(t,e){const i=this.parseMaybeDefault();this.parseAssignableListItemTypes(i,t);const s=this.parseMaybeDefault(i.loc.start,i);return e.length&&(i.decorators=e),s}parseAssignableListItemTypes(t,e){return t}parseMaybeDefault(t,e){var i;if(null!=t||(t=this.state.startLoc),e=null!=(i=e)?i:this.parseBindingAtom(),!this.eat(29))return e;const s=this.startNodeAt(t);return s.left=e,s.right=this.parseMaybeAssignAllowIn(),this.finishNode(s,"AssignmentPattern")}isValidLVal(t,e,i){return s={AssignmentPattern:"left",RestElement:"argument",ObjectProperty:"value",ParenthesizedExpression:"expression",ArrayPattern:"elements",ObjectPattern:"properties"},n=t,Object.hasOwnProperty.call(s,n)&&s[n];var s,n}isOptionalMemberExpression(t){return"OptionalMemberExpression"===t.type}checkLVal(t,{in:e,binding:i=64,checkClashes:s=!1,strictModeChanged:n=!1,hasParenthesizedAncestor:o=!1}){var a;const r=t.type;if(this.isObjectMethod(t))return;const l=this.isOptionalMemberExpression(t);if(l||"MemberExpression"===r)return l&&(this.expectPlugin("optionalChainingAssign",t.loc.start),"AssignmentExpression"!==e.type&&this.raise(L.InvalidLhsOptionalChaining,t,{ancestor:e})),void(64!==i&&this.raise(L.InvalidPropertyBindingPattern,t));if("Identifier"===r){this.checkIdentifier(t,i,n);const{name:e}=t;return void(s&&(s.has(e)?this.raise(L.ParamDupe,t):s.add(e)))}const h=this.isValidLVal(r,!(o||null!=(a=t.extra)&&a.parenthesized)&&"AssignmentExpression"===e.type,i);if(!0===h)return;if(!1===h){const s=64===i?L.InvalidLhs:L.InvalidLhsBinding;return void this.raise(s,t,{ancestor:e})}const[c,d]=Array.isArray(h)?h:[h,"ParenthesizedExpression"===r],I="ArrayPattern"===r||"ObjectPattern"===r?{type:r}:e;for(const e of[].concat(t[c]))e&&this.checkLVal(e,{in:I,binding:i,checkClashes:s,strictModeChanged:n,hasParenthesizedAncestor:d})}checkIdentifier(t,e,i=!1){this.state.strict&&(i?pt(t.name,this.inModule):ut(t.name))&&(64===e?this.raise(L.StrictEvalArguments,t,{referenceName:t.name}):this.raise(L.StrictEvalArgumentsBinding,t,{bindingName:t.name})),8192&e&&"let"===t.name&&this.raise(L.LetInLexicalBinding,t),64&e||this.declareNameFromIdentifier(t,e)}declareNameFromIdentifier(t,e){this.scope.declareName(t.name,e,t.loc.start)}checkToRestConversion(t,e){switch(t.type){case"ParenthesizedExpression":this.checkToRestConversion(t.expression,e);break;case"Identifier":case"MemberExpression":break;case"ArrayExpression":case"ObjectExpression":if(e)break;default:this.raise(L.InvalidRestAssignmentPattern,t)}}checkCommaAfterRest(t){return!!this.match(12)&&(this.raise(this.lookaheadCharCode()===t?L.RestTrailingComma:L.ElementAfterRest,this.state.startLoc),!0)}}function Me(t){if(!t)throw new Error("Assert fail")}const We=y`typescript`({AbstractMethodHasImplementation:({methodName:t})=>`Method '${t}' cannot have an implementation because it is marked abstract.`,AbstractPropertyHasInitializer:({propertyName:t})=>`Property '${t}' cannot have an initializer because it is marked abstract.`,AccesorCannotDeclareThisParameter:"'get' and 'set' accessors cannot declare 'this' parameters.",AccesorCannotHaveTypeParameters:"An accessor cannot have type parameters.",AccessorCannotBeOptional:"An 'accessor' property cannot be declared optional.",ClassMethodHasDeclare:"Class methods cannot have the 'declare' modifier.",ClassMethodHasReadonly:"Class methods cannot have the 'readonly' modifier.",ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference:"A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",ConstructorHasTypeParameters:"Type parameters cannot appear on a constructor declaration.",DeclareAccessor:({kind:t})=>`'declare' is not allowed in ${t}ters.`,DeclareClassFieldHasInitializer:"Initializers are not allowed in ambient contexts.",DeclareFunctionHasImplementation:"An implementation cannot be declared in ambient contexts.",DuplicateAccessibilityModifier:({modifier:t})=>"Accessibility modifier already seen.",DuplicateModifier:({modifier:t})=>`Duplicate modifier: '${t}'.`,EmptyHeritageClauseType:({token:t})=>`'${t}' list cannot be empty.`,EmptyTypeArguments:"Type argument list cannot be empty.",EmptyTypeParameters:"Type parameter list cannot be empty.",ExpectedAmbientAfterExportDeclare:"'export declare' must be followed by an ambient declaration.",ImportAliasHasImportType:"An import alias can not use 'import type'.",ImportReflectionHasImportType:"An `import module` declaration can not use `type` modifier",IncompatibleModifiers:({modifiers:t})=>`'${t[0]}' modifier cannot be used with '${t[1]}' modifier.`,IndexSignatureHasAbstract:"Index signatures cannot have the 'abstract' modifier.",IndexSignatureHasAccessibility:({modifier:t})=>`Index signatures cannot have an accessibility modifier ('${t}').`,IndexSignatureHasDeclare:"Index signatures cannot have the 'declare' modifier.",IndexSignatureHasOverride:"'override' modifier cannot appear on an index signature.",IndexSignatureHasStatic:"Index signatures cannot have the 'static' modifier.",InitializerNotAllowedInAmbientContext:"Initializers are not allowed in ambient contexts.",InvalidModifierOnTypeMember:({modifier:t})=>`'${t}' modifier cannot appear on a type member.`,InvalidModifierOnTypeParameter:({modifier:t})=>`'${t}' modifier cannot appear on a type parameter.`,InvalidModifierOnTypeParameterPositions:({modifier:t})=>`'${t}' modifier can only appear on a type parameter of a class, interface or type alias.`,InvalidModifiersOrder:({orderedModifiers:t})=>`'${t[0]}' modifier must precede '${t[1]}' modifier.`,InvalidPropertyAccessAfterInstantiationExpression:"Invalid property access after an instantiation expression. You can either wrap the instantiation expression in parentheses, or delete the type arguments.",InvalidTupleMemberLabel:"Tuple members must be labeled with a simple identifier.",MissingInterfaceName:"'interface' declarations must be followed by an identifier.",NonAbstractClassHasAbstractMethod:"Abstract methods can only appear within an abstract class.",NonClassMethodPropertyHasAbstractModifer:"'abstract' modifier can only appear on a class, method, or property declaration.",OptionalTypeBeforeRequired:"A required element cannot follow an optional element.",OverrideNotInSubClass:"This member cannot have an 'override' modifier because its containing class does not extend another class.",PatternIsOptional:"A binding pattern parameter cannot be optional in an implementation signature.",PrivateElementHasAbstract:"Private elements cannot have the 'abstract' modifier.",PrivateElementHasAccessibility:({modifier:t})=>`Private elements cannot have an accessibility modifier ('${t}').`,ReadonlyForMethodSignature:"'readonly' modifier can only appear on a property declaration or index signature.",ReservedArrowTypeParam:"This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `() => ...`.",ReservedTypeAssertion:"This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",SetAccesorCannotHaveOptionalParameter:"A 'set' accessor cannot have an optional parameter.",SetAccesorCannotHaveRestParameter:"A 'set' accessor cannot have rest parameter.",SetAccesorCannotHaveReturnType:"A 'set' accessor cannot have a return type annotation.",SingleTypeParameterWithoutTrailingComma:({typeParameterName:t})=>`Single type parameter ${t} should have a trailing comma. Example usage: <${t},>.`,StaticBlockCannotHaveModifier:"Static class blocks cannot have any modifier.",TupleOptionalAfterType:"A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",TypeAnnotationAfterAssign:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeImportCannotSpecifyDefaultAndNamed:"A type-only import can specify a default import or named bindings, but not both.",TypeModifierIsUsedInTypeExports:"The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",TypeModifierIsUsedInTypeImports:"The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",UnexpectedParameterModifier:"A parameter property is only allowed in a constructor implementation.",UnexpectedReadonly:"'readonly' type modifier is only permitted on array and tuple literal types.",UnexpectedTypeAnnotation:"Did not expect a type annotation here.",UnexpectedTypeCastInParameter:"Unexpected type cast in parameter position.",UnsupportedImportTypeArgument:"Argument in a type import must be a string literal.",UnsupportedParameterPropertyKind:"A parameter property may not be declared using a binding pattern.",UnsupportedSignatureParameterKind:({type:t})=>`Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${t}.`});function we(t){return"private"===t||"public"===t||"protected"===t}function ve(t){return"in"===t||"out"===t}function je(t){if("MemberExpression"!==t.type)return!1;const{computed:e,property:i}=t;return(!e||"StringLiteral"===i.type||!("TemplateLiteral"!==i.type||i.expressions.length>0))&&Ge(t.object)}function Ze(t,e){var i;const{type:s}=t;if(null!=(i=t.extra)&&i.parenthesized)return!1;if(e){if("Literal"===s){const{value:e}=t;if("string"==typeof e||"boolean"==typeof e)return!0}}else if("StringLiteral"===s||"BooleanLiteral"===s)return!0;return!(!Ce(t,e)&&!function(t,e){if("UnaryExpression"===t.type){const{operator:i,argument:s}=t;if("-"===i&&Ce(s,e))return!0}return!1}(t,e))||"TemplateLiteral"===s&&0===t.expressions.length||!!je(t)}function Ce(t,e){return e?"Literal"===t.type&&("number"==typeof t.value||"bigint"in t):"NumericLiteral"===t.type||"BigIntLiteral"===t.type}function Ge(t){return"Identifier"===t.type||"MemberExpression"===t.type&&!t.computed&&Ge(t.object)}const fe=y`placeholders`({ClassNameIsRequired:"A class name is required.",UnexpectedSpace:"Unexpected space in placeholder."});function Ne(t,e){const[i,s]="string"==typeof e?[e,{}]:e,n=Object.keys(s),o=0===n.length;return t.some((t=>{if("string"==typeof t)return o&&t===i;{const[e,o]=t;if(e!==i)return!1;for(const t of n)if(o[t]!==s[t])return!1;return!0}}))}function xe(t,e,i){const s=t.find((t=>Array.isArray(t)?t[0]===e:t===e));return s&&Array.isArray(s)&&s.length>1?s[1][i]:null}const Ye=["minimal","fsharp","hack","smart"],Re=["^^","@@","^","%","#"],He=["hash","bar"],ge={estree:t=>class extends t{parse(){const t=w(super.parse());return this.options.tokens&&(t.tokens=t.tokens.map(w)),t}parseRegExpLiteral({pattern:t,flags:e}){let i=null;try{i=new RegExp(t,e)}catch(t){}const s=this.estreeParseLiteral(i);return s.regex={pattern:t,flags:e},s}parseBigIntLiteral(t){let e;try{e=BigInt(t)}catch(t){e=null}const i=this.estreeParseLiteral(e);return i.bigint=String(i.value||t),i}parseDecimalLiteral(t){const e=this.estreeParseLiteral(null);return e.decimal=String(e.value||t),e}estreeParseLiteral(t){return this.parseLiteral(t,"Literal")}parseStringLiteral(t){return this.estreeParseLiteral(t)}parseNumericLiteral(t){return this.estreeParseLiteral(t)}parseNullLiteral(){return this.estreeParseLiteral(null)}parseBooleanLiteral(t){return this.estreeParseLiteral(t)}directiveToStmt(t){const e=t.value;delete t.value,e.type="Literal",e.raw=e.extra.raw,e.value=e.extra.expressionValue;const i=t;return i.type="ExpressionStatement",i.expression=e,i.directive=e.extra.rawValue,delete e.extra,i}initFunction(t,e){super.initFunction(t,e),t.expression=!1}checkDeclaration(t){null!=t&&this.isObjectProperty(t)?this.checkDeclaration(t.value):super.checkDeclaration(t)}getObjectOrClassMethodParams(t){return t.value.params}isValidDirective(t){var e;return"ExpressionStatement"===t.type&&"Literal"===t.expression.type&&"string"==typeof t.expression.value&&!(null!=(e=t.expression.extra)&&e.parenthesized)}parseBlockBody(t,e,i,s,n){super.parseBlockBody(t,e,i,s,n);const o=t.directives.map((t=>this.directiveToStmt(t)));t.body=o.concat(t.body),delete t.directives}pushClassMethod(t,e,i,s,n,o){this.parseMethod(e,i,s,n,o,"ClassMethod",!0),e.typeParameters&&(e.value.typeParameters=e.typeParameters,delete e.typeParameters),t.body.push(e)}parsePrivateName(){const t=super.parsePrivateName();return this.getPluginOption("estree","classFeatures")?this.convertPrivateNameToPrivateIdentifier(t):t}convertPrivateNameToPrivateIdentifier(t){const e=super.getPrivateNameSV(t);return delete t.id,t.name=e,t.type="PrivateIdentifier",t}isPrivateName(t){return this.getPluginOption("estree","classFeatures")?"PrivateIdentifier"===t.type:super.isPrivateName(t)}getPrivateNameSV(t){return this.getPluginOption("estree","classFeatures")?t.name:super.getPrivateNameSV(t)}parseLiteral(t,e){const i=super.parseLiteral(t,e);return i.raw=i.extra.raw,delete i.extra,i}parseFunctionBody(t,e,i=!1){super.parseFunctionBody(t,e,i),t.expression="BlockStatement"!==t.body.type}parseMethod(t,e,i,s,n,o,a=!1){let r=this.startNode();return r.kind=t.kind,r=super.parseMethod(r,e,i,s,n,o,a),r.type="FunctionExpression",delete r.kind,t.value=r,"ClassPrivateMethod"===o&&(t.computed=!1),this.finishNode(t,"MethodDefinition")}parseClassProperty(...t){const e=super.parseClassProperty(...t);return this.getPluginOption("estree","classFeatures")?(e.type="PropertyDefinition",e):e}parseClassPrivateProperty(...t){const e=super.parseClassPrivateProperty(...t);return this.getPluginOption("estree","classFeatures")?(e.type="PropertyDefinition",e.computed=!1,e):e}parseObjectMethod(t,e,i,s,n){const o=super.parseObjectMethod(t,e,i,s,n);return o&&(o.type="Property","method"===o.kind&&(o.kind="init"),o.shorthand=!1),o}parseObjectProperty(t,e,i,s){const n=super.parseObjectProperty(t,e,i,s);return n&&(n.kind="init",n.type="Property"),n}isValidLVal(t,e,i){return"Property"===t?"value":super.isValidLVal(t,e,i)}isAssignable(t,e){return null!=t&&this.isObjectProperty(t)?this.isAssignable(t.value,e):super.isAssignable(t,e)}toAssignable(t,e=!1){if(null!=t&&this.isObjectProperty(t)){const{key:i,value:s}=t;this.isPrivateName(i)&&this.classScope.usePrivateName(this.getPrivateNameSV(i),i.loc.start),this.toAssignable(s,e)}else super.toAssignable(t,e)}toAssignableObjectExpressionProp(t,e,i){"get"===t.kind||"set"===t.kind?this.raise(L.PatternHasAccessor,t.key):t.method?this.raise(L.PatternHasMethod,t.key):super.toAssignableObjectExpressionProp(t,e,i)}finishCallExpression(t,e){const i=super.finishCallExpression(t,e);var s,n;"Import"===i.callee.type&&(i.type="ImportExpression",i.source=i.arguments[0],(this.hasPlugin("importAttributes")||this.hasPlugin("importAssertions"))&&(i.options=null!=(s=i.arguments[1])?s:null,i.attributes=null!=(n=i.arguments[1])?n:null),delete i.arguments,delete i.callee);return i}toReferencedArguments(t){"ImportExpression"!==t.type&&super.toReferencedArguments(t)}parseExport(t,e){const i=this.state.lastTokStartLoc,s=super.parseExport(t,e);switch(s.type){case"ExportAllDeclaration":s.exported=null;break;case"ExportNamedDeclaration":1===s.specifiers.length&&"ExportNamespaceSpecifier"===s.specifiers[0].type&&(s.type="ExportAllDeclaration",s.exported=s.specifiers[0].exported,delete s.specifiers);case"ExportDefaultDeclaration":{var n;const{declaration:t}=s;"ClassDeclaration"===(null==t?void 0:t.type)&&(null==(n=t.decorators)?void 0:n.length)>0&&t.start===s.start&&this.resetStartLocation(s,i)}}return s}parseSubscript(t,e,i,s){const n=super.parseSubscript(t,e,i,s);if(s.optionalChainMember){if("OptionalMemberExpression"!==n.type&&"OptionalCallExpression"!==n.type||(n.type=n.type.substring(8)),s.stop){const t=this.startNodeAtNode(n);return t.expression=n,this.finishNode(t,"ChainExpression")}}else"MemberExpression"!==n.type&&"CallExpression"!==n.type||(n.optional=!1);return n}isOptionalMemberExpression(t){return"ChainExpression"===t.type?"MemberExpression"===t.expression.type:super.isOptionalMemberExpression(t)}hasPropertyAsPrivateName(t){return"ChainExpression"===t.type&&(t=t.expression),super.hasPropertyAsPrivateName(t)}isObjectProperty(t){return"Property"===t.type&&"init"===t.kind&&!t.method}isObjectMethod(t){return t.method||"get"===t.kind||"set"===t.kind}finishNodeAt(t,e,i){return w(super.finishNodeAt(t,e,i))}resetStartLocation(t,e){super.resetStartLocation(t,e),w(t)}resetEndLocation(t,e=this.state.lastTokEndLoc){super.resetEndLocation(t,e),w(t)}},jsx:t=>class extends t{jsxReadToken(){let t="",e=this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(Ie.UnterminatedJsxContent,this.state.startLoc);const i=this.input.charCodeAt(this.state.pos);switch(i){case 60:case 123:return this.state.pos===this.state.start?void(60===i&&this.state.canStartJSXElement?(++this.state.pos,this.finishToken(142)):super.getTokenFromCode(i)):(t+=this.input.slice(e,this.state.pos),void this.finishToken(141,t));case 38:t+=this.input.slice(e,this.state.pos),t+=this.jsxReadEntity(),e=this.state.pos;break;default:ft(i)?(t+=this.input.slice(e,this.state.pos),t+=this.jsxReadNewLine(!0),e=this.state.pos):++this.state.pos}}}jsxReadNewLine(t){const e=this.input.charCodeAt(this.state.pos);let i;return++this.state.pos,13===e&&10===this.input.charCodeAt(this.state.pos)?(++this.state.pos,i=t?"\n":"\r\n"):i=String.fromCharCode(e),++this.state.curLine,this.state.lineStart=this.state.pos,i}jsxReadString(t){let e="",i=++this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(L.UnterminatedString,this.state.startLoc);const s=this.input.charCodeAt(this.state.pos);if(s===t)break;38===s?(e+=this.input.slice(i,this.state.pos),e+=this.jsxReadEntity(),i=this.state.pos):ft(s)?(e+=this.input.slice(i,this.state.pos),e+=this.jsxReadNewLine(!1),i=this.state.pos):++this.state.pos}e+=this.input.slice(i,this.state.pos++),this.finishToken(133,e)}jsxReadEntity(){const t=++this.state.pos;if(35===this.codePointAtPos(this.state.pos)){++this.state.pos;let t=10;120===this.codePointAtPos(this.state.pos)&&(t=16,++this.state.pos);const e=this.readInt(t,void 0,!1,"bail");if(null!==e&&59===this.codePointAtPos(this.state.pos))return++this.state.pos,String.fromCodePoint(e)}else{let e=0,i=!1;for(;e++<10&&this.state.posclass extends t{constructor(...t){super(...t),this.flowPragma=void 0}getScopeHandler(){return Mt}shouldParseTypes(){return this.getPluginOption("flow","all")||"flow"===this.flowPragma}shouldParseEnums(){return!!this.getPluginOption("flow","enums")}finishToken(t,e){133!==t&&13!==t&&28!==t&&void 0===this.flowPragma&&(this.flowPragma=null),super.finishToken(t,e)}addComment(t){if(void 0===this.flowPragma){const e=ce.exec(t.value);if(e)if("flow"===e[1])this.flowPragma="flow";else{if("noflow"!==e[1])throw new Error("Unexpected flow pragma");this.flowPragma="noflow"}}super.addComment(t)}flowParseTypeInitialiser(t){const e=this.state.inType;this.state.inType=!0,this.expect(t||14);const i=this.flowParseType();return this.state.inType=e,i}flowParsePredicate(){const t=this.startNode(),e=this.state.startLoc;return this.next(),this.expectContextual(110),this.state.lastTokStartLoc.index>e.index+1&&this.raise(re.UnexpectedSpaceBetweenModuloChecks,e),this.eat(10)?(t.value=super.parseExpression(),this.expect(11),this.finishNode(t,"DeclaredPredicate")):this.finishNode(t,"InferredPredicate")}flowParseTypeAndPredicateInitialiser(){const t=this.state.inType;this.state.inType=!0,this.expect(14);let e=null,i=null;return this.match(54)?(this.state.inType=t,i=this.flowParsePredicate()):(e=this.flowParseType(),this.state.inType=t,this.match(54)&&(i=this.flowParsePredicate())),[e,i]}flowParseDeclareClass(t){return this.next(),this.flowParseInterfaceish(t,!0),this.finishNode(t,"DeclareClass")}flowParseDeclareFunction(t){this.next();const e=t.id=this.parseIdentifier(),i=this.startNode(),s=this.startNode();this.match(47)?i.typeParameters=this.flowParseTypeParameterDeclaration():i.typeParameters=null,this.expect(10);const n=this.flowParseFunctionTypeParams();return i.params=n.params,i.rest=n.rest,i.this=n._this,this.expect(11),[i.returnType,t.predicate]=this.flowParseTypeAndPredicateInitialiser(),s.typeAnnotation=this.finishNode(i,"FunctionTypeAnnotation"),e.typeAnnotation=this.finishNode(s,"TypeAnnotation"),this.resetEndLocation(e),this.semicolon(),this.scope.declareName(t.id.name,2048,t.id.loc.start),this.finishNode(t,"DeclareFunction")}flowParseDeclare(t,e){return this.match(80)?this.flowParseDeclareClass(t):this.match(68)?this.flowParseDeclareFunction(t):this.match(74)?this.flowParseDeclareVariable(t):this.eatContextual(127)?this.match(16)?this.flowParseDeclareModuleExports(t):(e&&this.raise(re.NestedDeclareModule,this.state.lastTokStartLoc),this.flowParseDeclareModule(t)):this.isContextual(130)?this.flowParseDeclareTypeAlias(t):this.isContextual(131)?this.flowParseDeclareOpaqueType(t):this.isContextual(129)?this.flowParseDeclareInterface(t):this.match(82)?this.flowParseDeclareExportDeclaration(t,e):void this.unexpected()}flowParseDeclareVariable(t){return this.next(),t.id=this.flowParseTypeAnnotatableIdentifier(!0),this.scope.declareName(t.id.name,5,t.id.loc.start),this.semicolon(),this.finishNode(t,"DeclareVariable")}flowParseDeclareModule(t){this.scope.enter(0),this.match(133)?t.id=super.parseExprAtom():t.id=this.parseIdentifier();const e=t.body=this.startNode(),i=e.body=[];for(this.expect(5);!this.match(8);){let t=this.startNode();this.match(83)?(this.next(),this.isContextual(130)||this.match(87)||this.raise(re.InvalidNonTypeImportInDeclareModule,this.state.lastTokStartLoc),super.parseImport(t)):(this.expectContextual(125,re.UnsupportedStatementInDeclareModule),t=this.flowParseDeclare(t,!0)),i.push(t)}this.scope.exit(),this.expect(8),this.finishNode(e,"BlockStatement");let s=null,n=!1;return i.forEach((t=>{!function(t){return"DeclareExportAllDeclaration"===t.type||"DeclareExportDeclaration"===t.type&&(!t.declaration||"TypeAlias"!==t.declaration.type&&"InterfaceDeclaration"!==t.declaration.type)}(t)?"DeclareModuleExports"===t.type&&(n&&this.raise(re.DuplicateDeclareModuleExports,t),"ES"===s&&this.raise(re.AmbiguousDeclareModuleKind,t),s="CommonJS",n=!0):("CommonJS"===s&&this.raise(re.AmbiguousDeclareModuleKind,t),s="ES")})),t.kind=s||"CommonJS",this.finishNode(t,"DeclareModule")}flowParseDeclareExportDeclaration(t,e){if(this.expect(82),this.eat(65))return this.match(68)||this.match(80)?t.declaration=this.flowParseDeclare(this.startNode()):(t.declaration=this.flowParseType(),this.semicolon()),t.default=!0,this.finishNode(t,"DeclareExportDeclaration");if(this.match(75)||this.isLet()||(this.isContextual(130)||this.isContextual(129))&&!e){const t=this.state.value;throw this.raise(re.UnsupportedDeclareExportKind,this.state.startLoc,{unsupportedExportKind:t,suggestion:he[t]})}return this.match(74)||this.match(68)||this.match(80)||this.isContextual(131)?(t.declaration=this.flowParseDeclare(this.startNode()),t.default=!1,this.finishNode(t,"DeclareExportDeclaration")):this.match(55)||this.match(5)||this.isContextual(129)||this.isContextual(130)||this.isContextual(131)?("ExportNamedDeclaration"===(t=this.parseExport(t,null)).type&&(t.type="ExportDeclaration",t.default=!1,delete t.exportKind),t.type="Declare"+t.type,t):void this.unexpected()}flowParseDeclareModuleExports(t){return this.next(),this.expectContextual(111),t.typeAnnotation=this.flowParseTypeAnnotation(),this.semicolon(),this.finishNode(t,"DeclareModuleExports")}flowParseDeclareTypeAlias(t){this.next();const e=this.flowParseTypeAlias(t);return e.type="DeclareTypeAlias",e}flowParseDeclareOpaqueType(t){this.next();const e=this.flowParseOpaqueType(t,!0);return e.type="DeclareOpaqueType",e}flowParseDeclareInterface(t){return this.next(),this.flowParseInterfaceish(t,!1),this.finishNode(t,"DeclareInterface")}flowParseInterfaceish(t,e){if(t.id=this.flowParseRestrictedIdentifier(!e,!0),this.scope.declareName(t.id.name,e?17:8201,t.id.loc.start),this.match(47)?t.typeParameters=this.flowParseTypeParameterDeclaration():t.typeParameters=null,t.extends=[],this.eat(81))do{t.extends.push(this.flowParseInterfaceExtends())}while(!e&&this.eat(12));if(e){if(t.implements=[],t.mixins=[],this.eatContextual(117))do{t.mixins.push(this.flowParseInterfaceExtends())}while(this.eat(12));if(this.eatContextual(113))do{t.implements.push(this.flowParseInterfaceExtends())}while(this.eat(12))}t.body=this.flowParseObjectType({allowStatic:e,allowExact:!1,allowSpread:!1,allowProto:e,allowInexact:!1})}flowParseInterfaceExtends(){const t=this.startNode();return t.id=this.flowParseQualifiedTypeIdentifier(),this.match(47)?t.typeParameters=this.flowParseTypeParameterInstantiation():t.typeParameters=null,this.finishNode(t,"InterfaceExtends")}flowParseInterface(t){return this.flowParseInterfaceish(t,!1),this.finishNode(t,"InterfaceDeclaration")}checkNotUnderscore(t){"_"===t&&this.raise(re.UnexpectedReservedUnderscore,this.state.startLoc)}checkReservedType(t,e,i){ae.has(t)&&this.raise(i?re.AssignReservedType:re.UnexpectedReservedType,e,{reservedType:t})}flowParseRestrictedIdentifier(t,e){return this.checkReservedType(this.state.value,this.state.startLoc,e),this.parseIdentifier(t)}flowParseTypeAlias(t){return t.id=this.flowParseRestrictedIdentifier(!1,!0),this.scope.declareName(t.id.name,8201,t.id.loc.start),this.match(47)?t.typeParameters=this.flowParseTypeParameterDeclaration():t.typeParameters=null,t.right=this.flowParseTypeInitialiser(29),this.semicolon(),this.finishNode(t,"TypeAlias")}flowParseOpaqueType(t,e){return this.expectContextual(130),t.id=this.flowParseRestrictedIdentifier(!0,!0),this.scope.declareName(t.id.name,8201,t.id.loc.start),this.match(47)?t.typeParameters=this.flowParseTypeParameterDeclaration():t.typeParameters=null,t.supertype=null,this.match(14)&&(t.supertype=this.flowParseTypeInitialiser(14)),t.impltype=null,e||(t.impltype=this.flowParseTypeInitialiser(29)),this.semicolon(),this.finishNode(t,"OpaqueType")}flowParseTypeParameter(t=!1){const e=this.state.startLoc,i=this.startNode(),s=this.flowParseVariance(),n=this.flowParseTypeAnnotatableIdentifier();return i.name=n.name,i.variance=s,i.bound=n.typeAnnotation,this.match(29)?(this.eat(29),i.default=this.flowParseType()):t&&this.raise(re.MissingTypeParamDefault,e),this.finishNode(i,"TypeParameter")}flowParseTypeParameterDeclaration(){const t=this.state.inType,e=this.startNode();e.params=[],this.state.inType=!0,this.match(47)||this.match(142)?this.next():this.unexpected();let i=!1;do{const t=this.flowParseTypeParameter(i);e.params.push(t),t.default&&(i=!0),this.match(48)||this.expect(12)}while(!this.match(48));return this.expect(48),this.state.inType=t,this.finishNode(e,"TypeParameterDeclaration")}flowParseTypeParameterInstantiation(){const t=this.startNode(),e=this.state.inType;t.params=[],this.state.inType=!0,this.expect(47);const i=this.state.noAnonFunctionType;for(this.state.noAnonFunctionType=!1;!this.match(48);)t.params.push(this.flowParseType()),this.match(48)||this.expect(12);return this.state.noAnonFunctionType=i,this.expect(48),this.state.inType=e,this.finishNode(t,"TypeParameterInstantiation")}flowParseTypeParameterInstantiationCallOrNew(){const t=this.startNode(),e=this.state.inType;for(t.params=[],this.state.inType=!0,this.expect(47);!this.match(48);)t.params.push(this.flowParseTypeOrImplicitInstantiation()),this.match(48)||this.expect(12);return this.expect(48),this.state.inType=e,this.finishNode(t,"TypeParameterInstantiation")}flowParseInterfaceType(){const t=this.startNode();if(this.expectContextual(129),t.extends=[],this.eat(81))do{t.extends.push(this.flowParseInterfaceExtends())}while(this.eat(12));return t.body=this.flowParseObjectType({allowStatic:!1,allowExact:!1,allowSpread:!1,allowProto:!1,allowInexact:!1}),this.finishNode(t,"InterfaceTypeAnnotation")}flowParseObjectPropertyKey(){return this.match(134)||this.match(133)?super.parseExprAtom():this.parseIdentifier(!0)}flowParseObjectTypeIndexer(t,e,i){return t.static=e,14===this.lookahead().type?(t.id=this.flowParseObjectPropertyKey(),t.key=this.flowParseTypeInitialiser()):(t.id=null,t.key=this.flowParseType()),this.expect(3),t.value=this.flowParseTypeInitialiser(),t.variance=i,this.finishNode(t,"ObjectTypeIndexer")}flowParseObjectTypeInternalSlot(t,e){return t.static=e,t.id=this.flowParseObjectPropertyKey(),this.expect(3),this.expect(3),this.match(47)||this.match(10)?(t.method=!0,t.optional=!1,t.value=this.flowParseObjectTypeMethodish(this.startNodeAt(t.loc.start))):(t.method=!1,this.eat(17)&&(t.optional=!0),t.value=this.flowParseTypeInitialiser()),this.finishNode(t,"ObjectTypeInternalSlot")}flowParseObjectTypeMethodish(t){for(t.params=[],t.rest=null,t.typeParameters=null,t.this=null,this.match(47)&&(t.typeParameters=this.flowParseTypeParameterDeclaration()),this.expect(10),this.match(78)&&(t.this=this.flowParseFunctionTypeParam(!0),t.this.name=null,this.match(11)||this.expect(12));!this.match(11)&&!this.match(21);)t.params.push(this.flowParseFunctionTypeParam(!1)),this.match(11)||this.expect(12);return this.eat(21)&&(t.rest=this.flowParseFunctionTypeParam(!1)),this.expect(11),t.returnType=this.flowParseTypeInitialiser(),this.finishNode(t,"FunctionTypeAnnotation")}flowParseObjectTypeCallProperty(t,e){const i=this.startNode();return t.static=e,t.value=this.flowParseObjectTypeMethodish(i),this.finishNode(t,"ObjectTypeCallProperty")}flowParseObjectType({allowStatic:t,allowExact:e,allowSpread:i,allowProto:s,allowInexact:n}){const o=this.state.inType;this.state.inType=!0;const a=this.startNode();let r,l;a.callProperties=[],a.properties=[],a.indexers=[],a.internalSlots=[];let h=!1;for(e&&this.match(6)?(this.expect(6),r=9,l=!0):(this.expect(5),r=8,l=!1),a.exact=l;!this.match(r);){let e=!1,o=null,r=null;const c=this.startNode();if(s&&this.isContextual(118)){const e=this.lookahead();14!==e.type&&17!==e.type&&(this.next(),o=this.state.startLoc,t=!1)}if(t&&this.isContextual(106)){const t=this.lookahead();14!==t.type&&17!==t.type&&(this.next(),e=!0)}const d=this.flowParseVariance();if(this.eat(0))null!=o&&this.unexpected(o),this.eat(0)?(d&&this.unexpected(d.loc.start),a.internalSlots.push(this.flowParseObjectTypeInternalSlot(c,e))):a.indexers.push(this.flowParseObjectTypeIndexer(c,e,d));else if(this.match(10)||this.match(47))null!=o&&this.unexpected(o),d&&this.unexpected(d.loc.start),a.callProperties.push(this.flowParseObjectTypeCallProperty(c,e));else{let t="init";(this.isContextual(99)||this.isContextual(104))&&D(this.lookahead().type)&&(t=this.state.value,this.next());const s=this.flowParseObjectTypeProperty(c,e,o,d,t,i,null!=n?n:!l);null===s?(h=!0,r=this.state.lastTokStartLoc):a.properties.push(s)}this.flowObjectTypeSemicolon(),!r||this.match(8)||this.match(9)||this.raise(re.UnexpectedExplicitInexactInObject,r)}this.expect(r),i&&(a.inexact=h);const c=this.finishNode(a,"ObjectTypeAnnotation");return this.state.inType=o,c}flowParseObjectTypeProperty(t,e,i,s,n,o,a){if(this.eat(21))return this.match(12)||this.match(13)||this.match(8)||this.match(9)?(o?a||this.raise(re.InexactInsideExact,this.state.lastTokStartLoc):this.raise(re.InexactInsideNonObject,this.state.lastTokStartLoc),s&&this.raise(re.InexactVariance,s),null):(o||this.raise(re.UnexpectedSpreadType,this.state.lastTokStartLoc),null!=i&&this.unexpected(i),s&&this.raise(re.SpreadVariance,s),t.argument=this.flowParseType(),this.finishNode(t,"ObjectTypeSpreadProperty"));{t.key=this.flowParseObjectPropertyKey(),t.static=e,t.proto=null!=i,t.kind=n;let a=!1;return this.match(47)||this.match(10)?(t.method=!0,null!=i&&this.unexpected(i),s&&this.unexpected(s.loc.start),t.value=this.flowParseObjectTypeMethodish(this.startNodeAt(t.loc.start)),"get"!==n&&"set"!==n||this.flowCheckGetterSetterParams(t),!o&&"constructor"===t.key.name&&t.value.this&&this.raise(re.ThisParamBannedInConstructor,t.value.this)):("init"!==n&&this.unexpected(),t.method=!1,this.eat(17)&&(a=!0),t.value=this.flowParseTypeInitialiser(),t.variance=s),t.optional=a,this.finishNode(t,"ObjectTypeProperty")}}flowCheckGetterSetterParams(t){const e="get"===t.kind?0:1,i=t.value.params.length+(t.value.rest?1:0);t.value.this&&this.raise("get"===t.kind?re.GetterMayNotHaveThisParam:re.SetterMayNotHaveThisParam,t.value.this),i!==e&&this.raise("get"===t.kind?L.BadGetterArity:L.BadSetterArity,t),"set"===t.kind&&t.value.rest&&this.raise(L.BadSetterRestParameter,t)}flowObjectTypeSemicolon(){this.eat(13)||this.eat(12)||this.match(8)||this.match(9)||this.unexpected()}flowParseQualifiedTypeIdentifier(t,e){null!=t||(t=this.state.startLoc);let i=e||this.flowParseRestrictedIdentifier(!0);for(;this.eat(16);){const e=this.startNodeAt(t);e.qualification=i,e.id=this.flowParseRestrictedIdentifier(!0),i=this.finishNode(e,"QualifiedTypeIdentifier")}return i}flowParseGenericType(t,e){const i=this.startNodeAt(t);return i.typeParameters=null,i.id=this.flowParseQualifiedTypeIdentifier(t,e),this.match(47)&&(i.typeParameters=this.flowParseTypeParameterInstantiation()),this.finishNode(i,"GenericTypeAnnotation")}flowParseTypeofType(){const t=this.startNode();return this.expect(87),t.argument=this.flowParsePrimaryType(),this.finishNode(t,"TypeofTypeAnnotation")}flowParseTupleType(){const t=this.startNode();for(t.types=[],this.expect(0);this.state.possuper.parseFunctionBody(t,!0,i))):super.parseFunctionBody(t,!1,i)}parseFunctionBodyAndFinish(t,e,i=!1){if(this.match(14)){const e=this.startNode();[e.typeAnnotation,t.predicate]=this.flowParseTypeAndPredicateInitialiser(),t.returnType=e.typeAnnotation?this.finishNode(e,"TypeAnnotation"):null}return super.parseFunctionBodyAndFinish(t,e,i)}parseStatementLike(t){if(this.state.strict&&this.isContextual(129)){if(E(this.lookahead().type)){const t=this.startNode();return this.next(),this.flowParseInterface(t)}}else if(this.shouldParseEnums()&&this.isContextual(126)){const t=this.startNode();return this.next(),this.flowParseEnumDeclaration(t)}const e=super.parseStatementLike(t);return void 0!==this.flowPragma||this.isValidDirective(e)||(this.flowPragma=null),e}parseExpressionStatement(t,e,i){if("Identifier"===e.type)if("declare"===e.name){if(this.match(80)||X(this.state.type)||this.match(68)||this.match(74)||this.match(82))return this.flowParseDeclare(t)}else if(X(this.state.type)){if("interface"===e.name)return this.flowParseInterface(t);if("type"===e.name)return this.flowParseTypeAlias(t);if("opaque"===e.name)return this.flowParseOpaqueType(t,!1)}return super.parseExpressionStatement(t,e,i)}shouldParseExportDeclaration(){const{type:t}=this.state;return B(t)||this.shouldParseEnums()&&126===t?!this.state.containsEsc:super.shouldParseExportDeclaration()}isExportDefaultSpecifier(){const{type:t}=this.state;return B(t)||this.shouldParseEnums()&&126===t?this.state.containsEsc:super.isExportDefaultSpecifier()}parseExportDefaultExpression(){if(this.shouldParseEnums()&&this.isContextual(126)){const t=this.startNode();return this.next(),this.flowParseEnumDeclaration(t)}return super.parseExportDefaultExpression()}parseConditional(t,e,i){if(!this.match(17))return t;if(this.state.maybeInArrowParameters){const e=this.lookaheadCharCode();if(44===e||61===e||58===e||41===e)return this.setOptionalParametersError(i),t}this.expect(17);const s=this.state.clone(),n=this.state.noArrowAt,o=this.startNodeAt(e);let{consequent:a,failed:r}=this.tryParseConditionalConsequent(),[l,h]=this.getArrowLikeExpressions(a);if(r||h.length>0){const t=[...n];if(h.length>0){this.state=s,this.state.noArrowAt=t;for(let e=0;e1&&this.raise(re.AmbiguousConditionalArrow,s.startLoc),r&&1===l.length&&(this.state=s,t.push(l[0].start),this.state.noArrowAt=t,({consequent:a,failed:r}=this.tryParseConditionalConsequent()))}return this.getArrowLikeExpressions(a,!0),this.state.noArrowAt=n,this.expect(14),o.test=t,o.consequent=a,o.alternate=this.forwardNoArrowParamsConversionAt(o,(()=>this.parseMaybeAssign(void 0,void 0))),this.finishNode(o,"ConditionalExpression")}tryParseConditionalConsequent(){this.state.noArrowParamsConversionAt.push(this.state.start);const t=this.parseMaybeAssignAllowIn(),e=!this.match(14);return this.state.noArrowParamsConversionAt.pop(),{consequent:t,failed:e}}getArrowLikeExpressions(t,e){const i=[t],s=[];for(;0!==i.length;){const t=i.pop();"ArrowFunctionExpression"===t.type?(t.typeParameters||!t.returnType?this.finishArrowValidation(t):s.push(t),i.push(t.body)):"ConditionalExpression"===t.type&&(i.push(t.consequent),i.push(t.alternate))}return e?(s.forEach((t=>this.finishArrowValidation(t))),[s,[]]):function(t,e){const i=[],s=[];for(let n=0;nt.params.every((t=>this.isAssignable(t,!0)))))}finishArrowValidation(t){var e;this.toAssignableList(t.params,null==(e=t.extra)?void 0:e.trailingCommaLoc,!1),this.scope.enter(6),super.checkParams(t,!1,!0),this.scope.exit()}forwardNoArrowParamsConversionAt(t,e){let i;return-1!==this.state.noArrowParamsConversionAt.indexOf(t.start)?(this.state.noArrowParamsConversionAt.push(this.state.start),i=e(),this.state.noArrowParamsConversionAt.pop()):i=e(),i}parseParenItem(t,e){if(t=super.parseParenItem(t,e),this.eat(17)&&(t.optional=!0,this.resetEndLocation(t)),this.match(14)){const i=this.startNodeAt(e);return i.expression=t,i.typeAnnotation=this.flowParseTypeAnnotation(),this.finishNode(i,"TypeCastExpression")}return t}assertModuleNodeAllowed(t){"ImportDeclaration"===t.type&&("type"===t.importKind||"typeof"===t.importKind)||"ExportNamedDeclaration"===t.type&&"type"===t.exportKind||"ExportAllDeclaration"===t.type&&"type"===t.exportKind||super.assertModuleNodeAllowed(t)}parseExportDeclaration(t){if(this.isContextual(130)){t.exportKind="type";const e=this.startNode();return this.next(),this.match(5)?(t.specifiers=this.parseExportSpecifiers(!0),super.parseExportFrom(t),null):this.flowParseTypeAlias(e)}if(this.isContextual(131)){t.exportKind="type";const e=this.startNode();return this.next(),this.flowParseOpaqueType(e,!1)}if(this.isContextual(129)){t.exportKind="type";const e=this.startNode();return this.next(),this.flowParseInterface(e)}if(this.shouldParseEnums()&&this.isContextual(126)){t.exportKind="value";const e=this.startNode();return this.next(),this.flowParseEnumDeclaration(e)}return super.parseExportDeclaration(t)}eatExportStar(t){return!!super.eatExportStar(t)||!(!this.isContextual(130)||55!==this.lookahead().type)&&(t.exportKind="type",this.next(),this.next(),!0)}maybeParseExportNamespaceSpecifier(t){const{startLoc:e}=this.state,i=super.maybeParseExportNamespaceSpecifier(t);return i&&"type"===t.exportKind&&this.unexpected(e),i}parseClassId(t,e,i){super.parseClassId(t,e,i),this.match(47)&&(t.typeParameters=this.flowParseTypeParameterDeclaration())}parseClassMember(t,e,i){const{startLoc:s}=this.state;if(this.isContextual(125)){if(super.parseClassMemberFromModifier(t,e))return;e.declare=!0}super.parseClassMember(t,e,i),e.declare&&("ClassProperty"!==e.type&&"ClassPrivateProperty"!==e.type&&"PropertyDefinition"!==e.type?this.raise(re.DeclareClassElement,s):e.value&&this.raise(re.DeclareClassFieldInitializer,e.value))}isIterator(t){return"iterator"===t||"asyncIterator"===t}readIterator(){const t=super.readWord1(),e="@@"+t;this.isIterator(t)&&this.state.inType||this.raise(L.InvalidIdentifier,this.state.curPosition(),{identifierName:e}),this.finishToken(132,e)}getTokenFromCode(t){const e=this.input.charCodeAt(this.state.pos+1);123===t&&124===e?this.finishOp(6,2):!this.state.inType||62!==t&&60!==t?this.state.inType&&63===t?46===e?this.finishOp(18,2):this.finishOp(17,1):function(t,e,i){return 64===t&&64===e&&at(i)}(t,e,this.input.charCodeAt(this.state.pos+2))?(this.state.pos+=2,this.readIterator()):super.getTokenFromCode(t):this.finishOp(62===t?48:47,1)}isAssignable(t,e){return"TypeCastExpression"===t.type?this.isAssignable(t.expression,e):super.isAssignable(t,e)}toAssignable(t,e=!1){e||"AssignmentExpression"!==t.type||"TypeCastExpression"!==t.left.type||(t.left=this.typeCastToParameter(t.left)),super.toAssignable(t,e)}toAssignableList(t,e,i){for(let e=0;e1)&&e||this.raise(re.TypeCastInPattern,n.typeAnnotation)}return t}parseArrayLike(t,e,i,s){const n=super.parseArrayLike(t,e,i,s);return e&&!this.state.maybeInArrowParameters&&this.toReferencedList(n.elements),n}isValidLVal(t,e,i){return"TypeCastExpression"===t||super.isValidLVal(t,e,i)}parseClassProperty(t){return this.match(14)&&(t.typeAnnotation=this.flowParseTypeAnnotation()),super.parseClassProperty(t)}parseClassPrivateProperty(t){return this.match(14)&&(t.typeAnnotation=this.flowParseTypeAnnotation()),super.parseClassPrivateProperty(t)}isClassMethod(){return this.match(47)||super.isClassMethod()}isClassProperty(){return this.match(14)||super.isClassProperty()}isNonstaticConstructor(t){return!this.match(14)&&super.isNonstaticConstructor(t)}pushClassMethod(t,e,i,s,n,o){if(e.variance&&this.unexpected(e.variance.loc.start),delete e.variance,this.match(47)&&(e.typeParameters=this.flowParseTypeParameterDeclaration()),super.pushClassMethod(t,e,i,s,n,o),e.params&&n){const t=e.params;t.length>0&&this.isThisParam(t[0])&&this.raise(re.ThisParamBannedInConstructor,e)}else if("MethodDefinition"===e.type&&n&&e.value.params){const t=e.value.params;t.length>0&&this.isThisParam(t[0])&&this.raise(re.ThisParamBannedInConstructor,e)}}pushClassPrivateMethod(t,e,i,s){e.variance&&this.unexpected(e.variance.loc.start),delete e.variance,this.match(47)&&(e.typeParameters=this.flowParseTypeParameterDeclaration()),super.pushClassPrivateMethod(t,e,i,s)}parseClassSuper(t){if(super.parseClassSuper(t),t.superClass&&this.match(47)&&(t.superTypeParameters=this.flowParseTypeParameterInstantiation()),this.isContextual(113)){this.next();const e=t.implements=[];do{const t=this.startNode();t.id=this.flowParseRestrictedIdentifier(!0),this.match(47)?t.typeParameters=this.flowParseTypeParameterInstantiation():t.typeParameters=null,e.push(this.finishNode(t,"ClassImplements"))}while(this.eat(12))}}checkGetterSetterParams(t){super.checkGetterSetterParams(t);const e=this.getObjectOrClassMethodParams(t);if(e.length>0){const i=e[0];this.isThisParam(i)&&"get"===t.kind?this.raise(re.GetterMayNotHaveThisParam,i):this.isThisParam(i)&&this.raise(re.SetterMayNotHaveThisParam,i)}}parsePropertyNamePrefixOperator(t){t.variance=this.flowParseVariance()}parseObjPropValue(t,e,i,s,n,o,a){let r;t.variance&&this.unexpected(t.variance.loc.start),delete t.variance,this.match(47)&&!o&&(r=this.flowParseTypeParameterDeclaration(),this.match(10)||this.unexpected());const l=super.parseObjPropValue(t,e,i,s,n,o,a);return r&&((l.value||l).typeParameters=r),l}parseAssignableListItemTypes(t){return this.eat(17)&&("Identifier"!==t.type&&this.raise(re.PatternIsOptional,t),this.isThisParam(t)&&this.raise(re.ThisParamMayNotBeOptional,t),t.optional=!0),this.match(14)?t.typeAnnotation=this.flowParseTypeAnnotation():this.isThisParam(t)&&this.raise(re.ThisParamAnnotationRequired,t),this.match(29)&&this.isThisParam(t)&&this.raise(re.ThisParamNoDefault,t),this.resetEndLocation(t),t}parseMaybeDefault(t,e){const i=super.parseMaybeDefault(t,e);return"AssignmentPattern"===i.type&&i.typeAnnotation&&i.right.startsuper.parseMaybeAssign(t,e)),n),!s.error)return s.node;const{context:i}=this.state,o=i[i.length-1];o!==j.j_oTag&&o!==j.j_expr||i.pop()}if(null!=(i=s)&&i.error||this.match(47)){var o,a;let i;n=n||this.state.clone();const r=this.tryParse((s=>{var n;i=this.flowParseTypeParameterDeclaration();const o=this.forwardNoArrowParamsConversionAt(i,(()=>{const s=super.parseMaybeAssign(t,e);return this.resetStartLocationFromNode(s,i),s}));null!=(n=o.extra)&&n.parenthesized&&s();const a=this.maybeUnwrapTypeCastExpression(o);return"ArrowFunctionExpression"!==a.type&&s(),a.typeParameters=i,this.resetStartLocationFromNode(a,i),o}),n);let l=null;if(r.node&&"ArrowFunctionExpression"===this.maybeUnwrapTypeCastExpression(r.node).type){if(!r.error&&!r.aborted)return r.node.async&&this.raise(re.UnexpectedTypeParameterBeforeAsyncArrowFunction,i),r.node;l=r.node}if(null!=(o=s)&&o.node)return this.state=s.failState,s.node;if(l)return this.state=r.failState,l;if(null!=(a=s)&&a.thrown)throw s.error;if(r.thrown)throw r.error;throw this.raise(re.UnexpectedTokenAfterTypeParameter,i)}return super.parseMaybeAssign(t,e)}parseArrow(t){if(this.match(14)){const e=this.tryParse((()=>{const e=this.state.noAnonFunctionType;this.state.noAnonFunctionType=!0;const i=this.startNode();return[i.typeAnnotation,t.predicate]=this.flowParseTypeAndPredicateInitialiser(),this.state.noAnonFunctionType=e,this.canInsertSemicolon()&&this.unexpected(),this.match(19)||this.unexpected(),i}));if(e.thrown)return null;e.error&&(this.state=e.failState),t.returnType=e.node.typeAnnotation?this.finishNode(e.node,"TypeAnnotation"):null}return super.parseArrow(t)}shouldParseArrow(t){return this.match(14)||super.shouldParseArrow(t)}setArrowFunctionParameters(t,e){-1!==this.state.noArrowParamsConversionAt.indexOf(t.start)?t.params=e:super.setArrowFunctionParameters(t,e)}checkParams(t,e,i,s=!0){if(!i||-1===this.state.noArrowParamsConversionAt.indexOf(t.start)){for(let e=0;e0&&this.raise(re.ThisParamMustBeFirst,t.params[e]);super.checkParams(t,e,i,s)}}parseParenAndDistinguishExpression(t){return super.parseParenAndDistinguishExpression(t&&-1===this.state.noArrowAt.indexOf(this.state.start))}parseSubscripts(t,e,i){if("Identifier"===t.type&&"async"===t.name&&-1!==this.state.noArrowAt.indexOf(e.index)){this.next();const i=this.startNodeAt(e);i.callee=t,i.arguments=super.parseCallExpressionArguments(11,!1),t=this.finishNode(i,"CallExpression")}else if("Identifier"===t.type&&"async"===t.name&&this.match(47)){const s=this.state.clone(),n=this.tryParse((t=>this.parseAsyncArrowWithTypeParameters(e)||t()),s);if(!n.error&&!n.aborted)return n.node;const o=this.tryParse((()=>super.parseSubscripts(t,e,i)),s);if(o.node&&!o.error)return o.node;if(n.node)return this.state=n.failState,n.node;if(o.node)return this.state=o.failState,o.node;throw n.error||o.error}return super.parseSubscripts(t,e,i)}parseSubscript(t,e,i,s){if(this.match(18)&&this.isLookaheadToken_lt()){if(s.optionalChainMember=!0,i)return s.stop=!0,t;this.next();const n=this.startNodeAt(e);return n.callee=t,n.typeArguments=this.flowParseTypeParameterInstantiation(),this.expect(10),n.arguments=this.parseCallExpressionArguments(11,!1),n.optional=!0,this.finishCallExpression(n,!0)}if(!i&&this.shouldParseTypes()&&this.match(47)){const i=this.startNodeAt(e);i.callee=t;const n=this.tryParse((()=>(i.typeArguments=this.flowParseTypeParameterInstantiationCallOrNew(),this.expect(10),i.arguments=super.parseCallExpressionArguments(11,!1),s.optionalChainMember&&(i.optional=!1),this.finishCallExpression(i,s.optionalChainMember))));if(n.node)return n.error&&(this.state=n.failState),n.node}return super.parseSubscript(t,e,i,s)}parseNewCallee(t){super.parseNewCallee(t);let e=null;this.shouldParseTypes()&&this.match(47)&&(e=this.tryParse((()=>this.flowParseTypeParameterInstantiationCallOrNew())).node),t.typeArguments=e}parseAsyncArrowWithTypeParameters(t){const e=this.startNodeAt(t);if(this.parseFunctionParams(e,!1),this.parseArrow(e))return super.parseArrowExpression(e,void 0,!0)}readToken_mult_modulo(t){const e=this.input.charCodeAt(this.state.pos+1);if(42===t&&47===e&&this.state.hasFlowComment)return this.state.hasFlowComment=!1,this.state.pos+=2,void this.nextToken();super.readToken_mult_modulo(t)}readToken_pipe_amp(t){const e=this.input.charCodeAt(this.state.pos+1);124!==t||125!==e?super.readToken_pipe_amp(t):this.finishOp(9,2)}parseTopLevel(t,e){const i=super.parseTopLevel(t,e);return this.state.hasFlowComment&&this.raise(re.UnterminatedFlowComment,this.state.curPosition()),i}skipBlockComment(){if(!this.hasPlugin("flowComments")||!this.skipFlowComment())return super.skipBlockComment(this.state.hasFlowComment?"*-/":"*/");{if(this.state.hasFlowComment)throw this.raise(re.NestedFlowComment,this.state.startLoc);this.hasFlowCommentCompletion();const t=this.skipFlowComment();t&&(this.state.pos+=t,this.state.hasFlowComment=!0)}}skipFlowComment(){const{pos:t}=this.state;let e=2;for(;[32,9].includes(this.input.charCodeAt(t+e));)e++;const i=this.input.charCodeAt(e+t),s=this.input.charCodeAt(e+t+1);return 58===i&&58===s?e+2:"flow-include"===this.input.slice(e+t,e+t+12)?e+12:58===i&&58!==s&&e}hasFlowCommentCompletion(){if(-1===this.input.indexOf("*/",this.state.pos))throw this.raise(L.UnterminatedComment,this.state.curPosition())}flowEnumErrorBooleanMemberNotInitialized(t,{enumName:e,memberName:i}){this.raise(re.EnumBooleanMemberNotInitialized,t,{memberName:i,enumName:e})}flowEnumErrorInvalidMemberInitializer(t,e){return this.raise(e.explicitType?"symbol"===e.explicitType?re.EnumInvalidMemberInitializerSymbolType:re.EnumInvalidMemberInitializerPrimaryType:re.EnumInvalidMemberInitializerUnknownType,t,e)}flowEnumErrorNumberMemberNotInitialized(t,e){this.raise(re.EnumNumberMemberNotInitialized,t,e)}flowEnumErrorStringMemberInconsistentlyInitialized(t,e){this.raise(re.EnumStringMemberInconsistentlyInitialized,t,e)}flowEnumMemberInit(){const t=this.state.startLoc,e=()=>this.match(12)||this.match(8);switch(this.state.type){case 134:{const i=this.parseNumericLiteral(this.state.value);return e()?{type:"number",loc:i.loc.start,value:i}:{type:"invalid",loc:t}}case 133:{const i=this.parseStringLiteral(this.state.value);return e()?{type:"string",loc:i.loc.start,value:i}:{type:"invalid",loc:t}}case 85:case 86:{const i=this.parseBooleanLiteral(this.match(85));return e()?{type:"boolean",loc:i.loc.start,value:i}:{type:"invalid",loc:t}}default:return{type:"invalid",loc:t}}}flowEnumMemberRaw(){const t=this.state.startLoc;return{id:this.parseIdentifier(!0),init:this.eat(29)?this.flowEnumMemberInit():{type:"none",loc:t}}}flowEnumCheckExplicitTypeMismatch(t,e,i){const{explicitType:s}=e;null!==s&&s!==i&&this.flowEnumErrorInvalidMemberInitializer(t,e)}flowEnumMembers({enumName:t,explicitType:e}){const i=new Set,s={booleanMembers:[],numberMembers:[],stringMembers:[],defaultedMembers:[]};let n=!1;for(;!this.match(8);){if(this.eat(21)){n=!0;break}const o=this.startNode(),{id:a,init:r}=this.flowEnumMemberRaw(),l=a.name;if(""===l)continue;/^[a-z]/.test(l)&&this.raise(re.EnumInvalidMemberName,a,{memberName:l,suggestion:l[0].toUpperCase()+l.slice(1),enumName:t}),i.has(l)&&this.raise(re.EnumDuplicateMemberName,a,{memberName:l,enumName:t}),i.add(l);const h={enumName:t,explicitType:e,memberName:l};switch(o.id=a,r.type){case"boolean":this.flowEnumCheckExplicitTypeMismatch(r.loc,h,"boolean"),o.init=r.value,s.booleanMembers.push(this.finishNode(o,"EnumBooleanMember"));break;case"number":this.flowEnumCheckExplicitTypeMismatch(r.loc,h,"number"),o.init=r.value,s.numberMembers.push(this.finishNode(o,"EnumNumberMember"));break;case"string":this.flowEnumCheckExplicitTypeMismatch(r.loc,h,"string"),o.init=r.value,s.stringMembers.push(this.finishNode(o,"EnumStringMember"));break;case"invalid":throw this.flowEnumErrorInvalidMemberInitializer(r.loc,h);case"none":switch(e){case"boolean":this.flowEnumErrorBooleanMemberNotInitialized(r.loc,h);break;case"number":this.flowEnumErrorNumberMemberNotInitialized(r.loc,h);break;default:s.defaultedMembers.push(this.finishNode(o,"EnumDefaultedMember"))}}this.match(8)||this.expect(12)}return{members:s,hasUnknownMembers:n}}flowEnumStringMembers(t,e,{enumName:i}){if(0===t.length)return e;if(0===e.length)return t;if(e.length>t.length){for(const e of t)this.flowEnumErrorStringMemberInconsistentlyInitialized(e,{enumName:i});return e}for(const t of e)this.flowEnumErrorStringMemberInconsistentlyInitialized(t,{enumName:i});return t}flowEnumParseExplicitType({enumName:t}){if(!this.eatContextual(102))return null;if(!X(this.state.type))throw this.raise(re.EnumInvalidExplicitTypeUnknownSupplied,this.state.startLoc,{enumName:t});const{value:e}=this.state;return this.next(),"boolean"!==e&&"number"!==e&&"string"!==e&&"symbol"!==e&&this.raise(re.EnumInvalidExplicitType,this.state.startLoc,{enumName:t,invalidEnumType:e}),e}flowEnumBody(t,e){const i=e.name,s=e.loc.start,n=this.flowEnumParseExplicitType({enumName:i});this.expect(5);const{members:o,hasUnknownMembers:a}=this.flowEnumMembers({enumName:i,explicitType:n});switch(t.hasUnknownMembers=a,n){case"boolean":return t.explicitType=!0,t.members=o.booleanMembers,this.expect(8),this.finishNode(t,"EnumBooleanBody");case"number":return t.explicitType=!0,t.members=o.numberMembers,this.expect(8),this.finishNode(t,"EnumNumberBody");case"string":return t.explicitType=!0,t.members=this.flowEnumStringMembers(o.stringMembers,o.defaultedMembers,{enumName:i}),this.expect(8),this.finishNode(t,"EnumStringBody");case"symbol":return t.members=o.defaultedMembers,this.expect(8),this.finishNode(t,"EnumSymbolBody");default:{const e=()=>(t.members=[],this.expect(8),this.finishNode(t,"EnumStringBody"));t.explicitType=!1;const n=o.booleanMembers.length,a=o.numberMembers.length,r=o.stringMembers.length,l=o.defaultedMembers.length;if(n||a||r||l){if(n||a){if(!a&&!r&&n>=l){for(const t of o.defaultedMembers)this.flowEnumErrorBooleanMemberNotInitialized(t.loc.start,{enumName:i,memberName:t.id.name});return t.members=o.booleanMembers,this.expect(8),this.finishNode(t,"EnumBooleanBody")}if(!n&&!r&&a>=l){for(const t of o.defaultedMembers)this.flowEnumErrorNumberMemberNotInitialized(t.loc.start,{enumName:i,memberName:t.id.name});return t.members=o.numberMembers,this.expect(8),this.finishNode(t,"EnumNumberBody")}return this.raise(re.EnumInconsistentMemberValues,s,{enumName:i}),e()}return t.members=this.flowEnumStringMembers(o.stringMembers,o.defaultedMembers,{enumName:i}),this.expect(8),this.finishNode(t,"EnumStringBody")}return e()}}}flowParseEnumDeclaration(t){const e=this.parseIdentifier();return t.id=e,t.body=this.flowEnumBody(this.startNode(),e),this.finishNode(t,"EnumDeclaration")}isLookaheadToken_lt(){const t=this.nextTokenStart();if(60===this.input.charCodeAt(t)){const e=this.input.charCodeAt(t+1);return 60!==e&&61!==e}return!1}maybeUnwrapTypeCastExpression(t){return"TypeCastExpression"===t.type?t.expression:t}},typescript:t=>class extends t{constructor(...t){super(...t),this.tsParseInOutModifiers=this.tsParseModifiers.bind(this,{allowedModifiers:["in","out"],disallowedModifiers:["const","public","private","protected","readonly","declare","abstract","override"],errorTemplate:We.InvalidModifierOnTypeParameter}),this.tsParseConstModifier=this.tsParseModifiers.bind(this,{allowedModifiers:["const"],disallowedModifiers:["in","out"],errorTemplate:We.InvalidModifierOnTypeParameterPositions}),this.tsParseInOutConstModifiers=this.tsParseModifiers.bind(this,{allowedModifiers:["in","out","const"],disallowedModifiers:["public","private","protected","readonly","declare","abstract","override"],errorTemplate:We.InvalidModifierOnTypeParameter})}getScopeHandler(){return me}tsIsIdentifier(){return X(this.state.type)}tsTokenCanFollowModifier(){return(this.match(0)||this.match(5)||this.match(55)||this.match(21)||this.match(138)||this.isLiteralPropertyName())&&!this.hasPrecedingLineBreak()}tsNextTokenCanFollowModifier(){return this.next(),this.tsTokenCanFollowModifier()}tsParseModifier(t,e){if(!X(this.state.type)&&58!==this.state.type&&75!==this.state.type)return;const i=this.state.value;if(-1!==t.indexOf(i)){if(e&&this.tsIsStartOfStaticBlocks())return;if(this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this)))return i}}tsParseModifiers({allowedModifiers:t,disallowedModifiers:e,stopOnStartOfClassStaticBlock:i,errorTemplate:s=We.InvalidModifierOnTypeMember},n){const o=(t,e,i,s)=>{e===i&&n[s]&&this.raise(We.InvalidModifiersOrder,t,{orderedModifiers:[i,s]})},a=(t,e,i,s)=>{(n[i]&&e===s||n[s]&&e===i)&&this.raise(We.IncompatibleModifiers,t,{modifiers:[i,s]})};for(;;){const{startLoc:r}=this.state,l=this.tsParseModifier(t.concat(null!=e?e:[]),i);if(!l)break;we(l)?n.accessibility?this.raise(We.DuplicateAccessibilityModifier,r,{modifier:l}):(o(r,l,l,"override"),o(r,l,l,"static"),o(r,l,l,"readonly"),n.accessibility=l):ve(l)?(n[l]&&this.raise(We.DuplicateModifier,r,{modifier:l}),n[l]=!0,o(r,l,"in","out")):(Object.hasOwnProperty.call(n,l)?this.raise(We.DuplicateModifier,r,{modifier:l}):(o(r,l,"static","readonly"),o(r,l,"static","override"),o(r,l,"override","readonly"),o(r,l,"abstract","override"),a(r,l,"declare","override"),a(r,l,"static","abstract")),n[l]=!0),null!=e&&e.includes(l)&&this.raise(s,r,{modifier:l})}}tsIsListTerminator(t){switch(t){case"EnumMembers":case"TypeMembers":return this.match(8);case"HeritageClauseElement":return this.match(5);case"TupleElementTypes":return this.match(3);case"TypeParametersOrArguments":return this.match(48)}}tsParseList(t,e){const i=[];for(;!this.tsIsListTerminator(t);)i.push(e());return i}tsParseDelimitedList(t,e,i){return function(t){if(null==t)throw new Error(`Unexpected ${t} value.`);return t}(this.tsParseDelimitedListWorker(t,e,!0,i))}tsParseDelimitedListWorker(t,e,i,s){const n=[];let o=-1;for(;!this.tsIsListTerminator(t);){o=-1;const s=e();if(null==s)return;if(n.push(s),!this.eat(12)){if(this.tsIsListTerminator(t))break;return void(i&&this.expect(12))}o=this.state.lastTokStartLoc.index}return s&&(s.value=o),n}tsParseBracketedList(t,e,i,s,n){s||(i?this.expect(0):this.expect(47));const o=this.tsParseDelimitedList(t,e,n);return i?this.expect(3):this.expect(48),o}tsParseImportType(){const t=this.startNode();return this.expect(83),this.expect(10),this.match(133)||this.raise(We.UnsupportedImportTypeArgument,this.state.startLoc),t.argument=super.parseExprAtom(),this.expect(11),this.eat(16)&&(t.qualifier=this.tsParseEntityName()),this.match(47)&&(t.typeParameters=this.tsParseTypeArguments()),this.finishNode(t,"TSImportType")}tsParseEntityName(t=!0){let e=this.parseIdentifier(t);for(;this.eat(16);){const i=this.startNodeAtNode(e);i.left=e,i.right=this.parseIdentifier(t),e=this.finishNode(i,"TSQualifiedName")}return e}tsParseTypeReference(){const t=this.startNode();return t.typeName=this.tsParseEntityName(),!this.hasPrecedingLineBreak()&&this.match(47)&&(t.typeParameters=this.tsParseTypeArguments()),this.finishNode(t,"TSTypeReference")}tsParseThisTypePredicate(t){this.next();const e=this.startNodeAtNode(t);return e.parameterName=t,e.typeAnnotation=this.tsParseTypeAnnotation(!1),e.asserts=!1,this.finishNode(e,"TSTypePredicate")}tsParseThisTypeNode(){const t=this.startNode();return this.next(),this.finishNode(t,"TSThisType")}tsParseTypeQuery(){const t=this.startNode();return this.expect(87),this.match(83)?t.exprName=this.tsParseImportType():t.exprName=this.tsParseEntityName(),!this.hasPrecedingLineBreak()&&this.match(47)&&(t.typeParameters=this.tsParseTypeArguments()),this.finishNode(t,"TSTypeQuery")}tsParseTypeParameter(t){const e=this.startNode();return t(e),e.name=this.tsParseTypeParameterName(),e.constraint=this.tsEatThenParseType(81),e.default=this.tsEatThenParseType(29),this.finishNode(e,"TSTypeParameter")}tsTryParseTypeParameters(t){if(this.match(47))return this.tsParseTypeParameters(t)}tsParseTypeParameters(t){const e=this.startNode();this.match(47)||this.match(142)?this.next():this.unexpected();const i={value:-1};return e.params=this.tsParseBracketedList("TypeParametersOrArguments",this.tsParseTypeParameter.bind(this,t),!1,!0,i),0===e.params.length&&this.raise(We.EmptyTypeParameters,e),-1!==i.value&&this.addExtra(e,"trailingComma",i.value),this.finishNode(e,"TSTypeParameterDeclaration")}tsFillSignature(t,e){const i=19===t;e.typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier),this.expect(10),e.parameters=this.tsParseBindingListForSignature(),(i||this.match(t))&&(e.typeAnnotation=this.tsParseTypeOrTypePredicateAnnotation(t))}tsParseBindingListForSignature(){const t=super.parseBindingList(11,41,2);for(const e of t){const{type:t}=e;"AssignmentPattern"!==t&&"TSParameterProperty"!==t||this.raise(We.UnsupportedSignatureParameterKind,e,{type:t})}return t}tsParseTypeMemberSemicolon(){this.eat(12)||this.isLineTerminator()||this.expect(13)}tsParseSignatureMember(t,e){return this.tsFillSignature(14,e),this.tsParseTypeMemberSemicolon(),this.finishNode(e,t)}tsIsUnambiguouslyIndexSignature(){return this.next(),!!X(this.state.type)&&(this.next(),this.match(14))}tsTryParseIndexSignature(t){if(!this.match(0)||!this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))return;this.expect(0);const e=this.parseIdentifier();e.typeAnnotation=this.tsParseTypeAnnotation(),this.resetEndLocation(e),this.expect(3),t.parameters=[e];const i=this.tsTryParseTypeAnnotation();return i&&(t.typeAnnotation=i),this.tsParseTypeMemberSemicolon(),this.finishNode(t,"TSIndexSignature")}tsParsePropertyOrMethodSignature(t,e){this.eat(17)&&(t.optional=!0);const i=t;if(this.match(10)||this.match(47)){e&&this.raise(We.ReadonlyForMethodSignature,t);const s=i;s.kind&&this.match(47)&&this.raise(We.AccesorCannotHaveTypeParameters,this.state.curPosition()),this.tsFillSignature(14,s),this.tsParseTypeMemberSemicolon();const n="parameters",o="typeAnnotation";if("get"===s.kind)s[n].length>0&&(this.raise(L.BadGetterArity,this.state.curPosition()),this.isThisParam(s[n][0])&&this.raise(We.AccesorCannotDeclareThisParameter,this.state.curPosition()));else if("set"===s.kind){if(1!==s[n].length)this.raise(L.BadSetterArity,this.state.curPosition());else{const t=s[n][0];this.isThisParam(t)&&this.raise(We.AccesorCannotDeclareThisParameter,this.state.curPosition()),"Identifier"===t.type&&t.optional&&this.raise(We.SetAccesorCannotHaveOptionalParameter,this.state.curPosition()),"RestElement"===t.type&&this.raise(We.SetAccesorCannotHaveRestParameter,this.state.curPosition())}s[o]&&this.raise(We.SetAccesorCannotHaveReturnType,s[o])}else s.kind="method";return this.finishNode(s,"TSMethodSignature")}{const t=i;e&&(t.readonly=!0);const s=this.tsTryParseTypeAnnotation();return s&&(t.typeAnnotation=s),this.tsParseTypeMemberSemicolon(),this.finishNode(t,"TSPropertySignature")}}tsParseTypeMember(){const t=this.startNode();if(this.match(10)||this.match(47))return this.tsParseSignatureMember("TSCallSignatureDeclaration",t);if(this.match(77)){const e=this.startNode();return this.next(),this.match(10)||this.match(47)?this.tsParseSignatureMember("TSConstructSignatureDeclaration",t):(t.key=this.createIdentifier(e,"new"),this.tsParsePropertyOrMethodSignature(t,!1))}this.tsParseModifiers({allowedModifiers:["readonly"],disallowedModifiers:["declare","abstract","private","protected","public","static","override"]},t);return this.tsTryParseIndexSignature(t)||(super.parsePropertyName(t),t.computed||"Identifier"!==t.key.type||"get"!==t.key.name&&"set"!==t.key.name||!this.tsTokenCanFollowModifier()||(t.kind=t.key.name,super.parsePropertyName(t)),this.tsParsePropertyOrMethodSignature(t,!!t.readonly))}tsParseTypeLiteral(){const t=this.startNode();return t.members=this.tsParseObjectTypeMembers(),this.finishNode(t,"TSTypeLiteral")}tsParseObjectTypeMembers(){this.expect(5);const t=this.tsParseList("TypeMembers",this.tsParseTypeMember.bind(this));return this.expect(8),t}tsIsStartOfMappedType(){return this.next(),this.eat(53)?this.isContextual(122):(this.isContextual(122)&&this.next(),!!this.match(0)&&(this.next(),!!this.tsIsIdentifier()&&(this.next(),this.match(58))))}tsParseMappedTypeParameter(){const t=this.startNode();return t.name=this.tsParseTypeParameterName(),t.constraint=this.tsExpectThenParseType(58),this.finishNode(t,"TSTypeParameter")}tsParseMappedType(){const t=this.startNode();return this.expect(5),this.match(53)?(t.readonly=this.state.value,this.next(),this.expectContextual(122)):this.eatContextual(122)&&(t.readonly=!0),this.expect(0),t.typeParameter=this.tsParseMappedTypeParameter(),t.nameType=this.eatContextual(93)?this.tsParseType():null,this.expect(3),this.match(53)?(t.optional=this.state.value,this.next(),this.expect(17)):this.eat(17)&&(t.optional=!0),t.typeAnnotation=this.tsTryParseType(),this.semicolon(),this.expect(8),this.finishNode(t,"TSMappedType")}tsParseTupleType(){const t=this.startNode();t.elementTypes=this.tsParseBracketedList("TupleElementTypes",this.tsParseTupleElementType.bind(this),!0,!1);let e=!1;return t.elementTypes.forEach((t=>{const{type:i}=t;!e||"TSRestType"===i||"TSOptionalType"===i||"TSNamedTupleMember"===i&&t.optional||this.raise(We.OptionalTypeBeforeRequired,t),e||(e="TSNamedTupleMember"===i&&t.optional||"TSOptionalType"===i)})),this.finishNode(t,"TSTupleType")}tsParseTupleElementType(){const{startLoc:t}=this.state,e=this.eat(21);let i,s,n,o;const a=E(this.state.type)?this.lookaheadCharCode():null;if(58===a)i=!0,n=!1,s=this.parseIdentifier(!0),this.expect(14),o=this.tsParseType();else if(63===a){n=!0;const t=this.state.startLoc,e=this.state.value,a=this.tsParseNonArrayType();58===this.lookaheadCharCode()?(i=!0,s=this.createIdentifier(this.startNodeAt(t),e),this.expect(17),this.expect(14),o=this.tsParseType()):(i=!1,o=a,this.expect(17))}else o=this.tsParseType(),n=this.eat(17),i=this.eat(14);if(i){let t;s?(t=this.startNodeAtNode(s),t.optional=n,t.label=s,t.elementType=o,this.eat(17)&&(t.optional=!0,this.raise(We.TupleOptionalAfterType,this.state.lastTokStartLoc))):(t=this.startNodeAtNode(o),t.optional=n,this.raise(We.InvalidTupleMemberLabel,o),t.label=o,t.elementType=this.tsParseType()),o=this.finishNode(t,"TSNamedTupleMember")}else if(n){const t=this.startNodeAtNode(o);t.typeAnnotation=o,o=this.finishNode(t,"TSOptionalType")}if(e){const e=this.startNodeAt(t);e.typeAnnotation=o,o=this.finishNode(e,"TSRestType")}return o}tsParseParenthesizedType(){const t=this.startNode();return this.expect(10),t.typeAnnotation=this.tsParseType(),this.expect(11),this.finishNode(t,"TSParenthesizedType")}tsParseFunctionOrConstructorType(t,e){const i=this.startNode();return"TSConstructorType"===t&&(i.abstract=!!e,e&&this.next(),this.next()),this.tsInAllowConditionalTypesContext((()=>this.tsFillSignature(19,i))),this.finishNode(i,t)}tsParseLiteralTypeNode(){const t=this.startNode();switch(this.state.type){case 134:case 135:case 133:case 85:case 86:t.literal=super.parseExprAtom();break;default:this.unexpected()}return this.finishNode(t,"TSLiteralType")}tsParseTemplateLiteralType(){const t=this.startNode();return t.literal=super.parseTemplate(!1),this.finishNode(t,"TSLiteralType")}parseTemplateSubstitution(){return this.state.inType?this.tsParseType():super.parseTemplateSubstitution()}tsParseThisTypeOrThisTypePredicate(){const t=this.tsParseThisTypeNode();return this.isContextual(116)&&!this.hasPrecedingLineBreak()?this.tsParseThisTypePredicate(t):t}tsParseNonArrayType(){switch(this.state.type){case 133:case 134:case 135:case 85:case 86:return this.tsParseLiteralTypeNode();case 53:if("-"===this.state.value){const t=this.startNode(),e=this.lookahead();return 134!==e.type&&135!==e.type&&this.unexpected(),t.literal=this.parseMaybeUnary(),this.finishNode(t,"TSLiteralType")}break;case 78:return this.tsParseThisTypeOrThisTypePredicate();case 87:return this.tsParseTypeQuery();case 83:return this.tsParseImportType();case 5:return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))?this.tsParseMappedType():this.tsParseTypeLiteral();case 0:return this.tsParseTupleType();case 10:return this.tsParseParenthesizedType();case 25:case 24:return this.tsParseTemplateLiteralType();default:{const{type:t}=this.state;if(X(t)||88===t||84===t){const e=88===t?"TSVoidKeyword":84===t?"TSNullKeyword":function(t){switch(t){case"any":return"TSAnyKeyword";case"boolean":return"TSBooleanKeyword";case"bigint":return"TSBigIntKeyword";case"never":return"TSNeverKeyword";case"number":return"TSNumberKeyword";case"object":return"TSObjectKeyword";case"string":return"TSStringKeyword";case"symbol":return"TSSymbolKeyword";case"undefined":return"TSUndefinedKeyword";case"unknown":return"TSUnknownKeyword";default:return}}(this.state.value);if(void 0!==e&&46!==this.lookaheadCharCode()){const t=this.startNode();return this.next(),this.finishNode(t,e)}return this.tsParseTypeReference()}}}this.unexpected()}tsParseArrayTypeOrHigher(){let t=this.tsParseNonArrayType();for(;!this.hasPrecedingLineBreak()&&this.eat(0);)if(this.match(3)){const e=this.startNodeAtNode(t);e.elementType=t,this.expect(3),t=this.finishNode(e,"TSArrayType")}else{const e=this.startNodeAtNode(t);e.objectType=t,e.indexType=this.tsParseType(),this.expect(3),t=this.finishNode(e,"TSIndexedAccessType")}return t}tsParseTypeOperator(){const t=this.startNode(),e=this.state.value;return this.next(),t.operator=e,t.typeAnnotation=this.tsParseTypeOperatorOrHigher(),"readonly"===e&&this.tsCheckTypeAnnotationForReadOnly(t),this.finishNode(t,"TSTypeOperator")}tsCheckTypeAnnotationForReadOnly(t){switch(t.typeAnnotation.type){case"TSTupleType":case"TSArrayType":return;default:this.raise(We.UnexpectedReadonly,t)}}tsParseInferType(){const t=this.startNode();this.expectContextual(115);const e=this.startNode();return e.name=this.tsParseTypeParameterName(),e.constraint=this.tsTryParse((()=>this.tsParseConstraintForInferType())),t.typeParameter=this.finishNode(e,"TSTypeParameter"),this.finishNode(t,"TSInferType")}tsParseConstraintForInferType(){if(this.eat(81)){const t=this.tsInDisallowConditionalTypesContext((()=>this.tsParseType()));if(this.state.inDisallowConditionalTypesContext||!this.match(17))return t}}tsParseTypeOperatorOrHigher(){var t;return(t=this.state.type)>=121&&t<=123&&!this.state.containsEsc?this.tsParseTypeOperator():this.isContextual(115)?this.tsParseInferType():this.tsInAllowConditionalTypesContext((()=>this.tsParseArrayTypeOrHigher()))}tsParseUnionOrIntersectionType(t,e,i){const s=this.startNode(),n=this.eat(i),o=[];do{o.push(e())}while(this.eat(i));return 1!==o.length||n?(s.types=o,this.finishNode(s,t)):o[0]}tsParseIntersectionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSIntersectionType",this.tsParseTypeOperatorOrHigher.bind(this),45)}tsParseUnionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSUnionType",this.tsParseIntersectionTypeOrHigher.bind(this),43)}tsIsStartOfFunctionType(){return!!this.match(47)||this.match(10)&&this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))}tsSkipParameterStart(){if(X(this.state.type)||this.match(78))return this.next(),!0;if(this.match(5)){const{errors:t}=this.state,e=t.length;try{return this.parseObjectLike(8,!0),t.length===e}catch(t){return!1}}if(this.match(0)){this.next();const{errors:t}=this.state,e=t.length;try{return super.parseBindingList(3,93,1),t.length===e}catch(t){return!1}}return!1}tsIsUnambiguouslyStartOfFunctionType(){if(this.next(),this.match(11)||this.match(21))return!0;if(this.tsSkipParameterStart()){if(this.match(14)||this.match(12)||this.match(17)||this.match(29))return!0;if(this.match(11)&&(this.next(),this.match(19)))return!0}return!1}tsParseTypeOrTypePredicateAnnotation(t){return this.tsInType((()=>{const e=this.startNode();this.expect(t);const i=this.startNode(),s=!!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));if(s&&this.match(78)){let t=this.tsParseThisTypeOrThisTypePredicate();return"TSThisType"===t.type?(i.parameterName=t,i.asserts=!0,i.typeAnnotation=null,t=this.finishNode(i,"TSTypePredicate")):(this.resetStartLocationFromNode(t,i),t.asserts=!0),e.typeAnnotation=t,this.finishNode(e,"TSTypeAnnotation")}const n=this.tsIsIdentifier()&&this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));if(!n)return s?(i.parameterName=this.parseIdentifier(),i.asserts=s,i.typeAnnotation=null,e.typeAnnotation=this.finishNode(i,"TSTypePredicate"),this.finishNode(e,"TSTypeAnnotation")):this.tsParseTypeAnnotation(!1,e);const o=this.tsParseTypeAnnotation(!1);return i.parameterName=n,i.typeAnnotation=o,i.asserts=s,e.typeAnnotation=this.finishNode(i,"TSTypePredicate"),this.finishNode(e,"TSTypeAnnotation")}))}tsTryParseTypeOrTypePredicateAnnotation(){if(this.match(14))return this.tsParseTypeOrTypePredicateAnnotation(14)}tsTryParseTypeAnnotation(){if(this.match(14))return this.tsParseTypeAnnotation()}tsTryParseType(){return this.tsEatThenParseType(14)}tsParseTypePredicatePrefix(){const t=this.parseIdentifier();if(this.isContextual(116)&&!this.hasPrecedingLineBreak())return this.next(),t}tsParseTypePredicateAsserts(){if(109!==this.state.type)return!1;const t=this.state.containsEsc;return this.next(),!(!X(this.state.type)&&!this.match(78)||(t&&this.raise(L.InvalidEscapedReservedWord,this.state.lastTokStartLoc,{reservedWord:"asserts"}),0))}tsParseTypeAnnotation(t=!0,e=this.startNode()){return this.tsInType((()=>{t&&this.expect(14),e.typeAnnotation=this.tsParseType()})),this.finishNode(e,"TSTypeAnnotation")}tsParseType(){Me(this.state.inType);const t=this.tsParseNonConditionalType();if(this.state.inDisallowConditionalTypesContext||this.hasPrecedingLineBreak()||!this.eat(81))return t;const e=this.startNodeAtNode(t);return e.checkType=t,e.extendsType=this.tsInDisallowConditionalTypesContext((()=>this.tsParseNonConditionalType())),this.expect(17),e.trueType=this.tsInAllowConditionalTypesContext((()=>this.tsParseType())),this.expect(14),e.falseType=this.tsInAllowConditionalTypesContext((()=>this.tsParseType())),this.finishNode(e,"TSConditionalType")}isAbstractConstructorSignature(){return this.isContextual(124)&&77===this.lookahead().type}tsParseNonConditionalType(){return this.tsIsStartOfFunctionType()?this.tsParseFunctionOrConstructorType("TSFunctionType"):this.match(77)?this.tsParseFunctionOrConstructorType("TSConstructorType"):this.isAbstractConstructorSignature()?this.tsParseFunctionOrConstructorType("TSConstructorType",!0):this.tsParseUnionTypeOrHigher()}tsParseTypeAssertion(){this.getPluginOption("typescript","disallowAmbiguousJSXLike")&&this.raise(We.ReservedTypeAssertion,this.state.startLoc);const t=this.startNode();return t.typeAnnotation=this.tsInType((()=>(this.next(),this.match(75)?this.tsParseTypeReference():this.tsParseType()))),this.expect(48),t.expression=this.parseMaybeUnary(),this.finishNode(t,"TSTypeAssertion")}tsParseHeritageClause(t){const e=this.state.startLoc,i=this.tsParseDelimitedList("HeritageClauseElement",(()=>{const t=this.startNode();return t.expression=this.tsParseEntityName(),this.match(47)&&(t.typeParameters=this.tsParseTypeArguments()),this.finishNode(t,"TSExpressionWithTypeArguments")}));return i.length||this.raise(We.EmptyHeritageClauseType,e,{token:t}),i}tsParseInterfaceDeclaration(t,e={}){if(this.hasFollowingLineBreak())return null;this.expectContextual(129),e.declare&&(t.declare=!0),X(this.state.type)?(t.id=this.parseIdentifier(),this.checkIdentifier(t.id,130)):(t.id=null,this.raise(We.MissingInterfaceName,this.state.startLoc)),t.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers),this.eat(81)&&(t.extends=this.tsParseHeritageClause("extends"));const i=this.startNode();return i.body=this.tsInType(this.tsParseObjectTypeMembers.bind(this)),t.body=this.finishNode(i,"TSInterfaceBody"),this.finishNode(t,"TSInterfaceDeclaration")}tsParseTypeAliasDeclaration(t){return t.id=this.parseIdentifier(),this.checkIdentifier(t.id,2),t.typeAnnotation=this.tsInType((()=>{if(t.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutModifiers),this.expect(29),this.isContextual(114)&&16!==this.lookahead().type){const t=this.startNode();return this.next(),this.finishNode(t,"TSIntrinsicKeyword")}return this.tsParseType()})),this.semicolon(),this.finishNode(t,"TSTypeAliasDeclaration")}tsInNoContext(t){const e=this.state.context;this.state.context=[e[0]];try{return t()}finally{this.state.context=e}}tsInType(t){const e=this.state.inType;this.state.inType=!0;try{return t()}finally{this.state.inType=e}}tsInDisallowConditionalTypesContext(t){const e=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!0;try{return t()}finally{this.state.inDisallowConditionalTypesContext=e}}tsInAllowConditionalTypesContext(t){const e=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!1;try{return t()}finally{this.state.inDisallowConditionalTypesContext=e}}tsEatThenParseType(t){if(this.match(t))return this.tsNextThenParseType()}tsExpectThenParseType(t){return this.tsInType((()=>(this.expect(t),this.tsParseType())))}tsNextThenParseType(){return this.tsInType((()=>(this.next(),this.tsParseType())))}tsParseEnumMember(){const t=this.startNode();return t.id=this.match(133)?super.parseStringLiteral(this.state.value):this.parseIdentifier(!0),this.eat(29)&&(t.initializer=super.parseMaybeAssignAllowIn()),this.finishNode(t,"TSEnumMember")}tsParseEnumDeclaration(t,e={}){return e.const&&(t.const=!0),e.declare&&(t.declare=!0),this.expectContextual(126),t.id=this.parseIdentifier(),this.checkIdentifier(t.id,t.const?8971:8459),this.expect(5),t.members=this.tsParseDelimitedList("EnumMembers",this.tsParseEnumMember.bind(this)),this.expect(8),this.finishNode(t,"TSEnumDeclaration")}tsParseModuleBlock(){const t=this.startNode();return this.scope.enter(0),this.expect(5),super.parseBlockOrModuleBlockBody(t.body=[],void 0,!0,8),this.scope.exit(),this.finishNode(t,"TSModuleBlock")}tsParseModuleOrNamespaceDeclaration(t,e=!1){if(t.id=this.parseIdentifier(),e||this.checkIdentifier(t.id,1024),this.eat(16)){const e=this.startNode();this.tsParseModuleOrNamespaceDeclaration(e,!0),t.body=e}else this.scope.enter(256),this.prodParam.enter(0),t.body=this.tsParseModuleBlock(),this.prodParam.exit(),this.scope.exit();return this.finishNode(t,"TSModuleDeclaration")}tsParseAmbientExternalModuleDeclaration(t){return this.isContextual(112)?(t.global=!0,t.id=this.parseIdentifier()):this.match(133)?t.id=super.parseStringLiteral(this.state.value):this.unexpected(),this.match(5)?(this.scope.enter(256),this.prodParam.enter(0),t.body=this.tsParseModuleBlock(),this.prodParam.exit(),this.scope.exit()):this.semicolon(),this.finishNode(t,"TSModuleDeclaration")}tsParseImportEqualsDeclaration(t,e,i){t.isExport=i||!1,t.id=e||this.parseIdentifier(),this.checkIdentifier(t.id,4096),this.expect(29);const s=this.tsParseModuleReference();return"type"===t.importKind&&"TSExternalModuleReference"!==s.type&&this.raise(We.ImportAliasHasImportType,s),t.moduleReference=s,this.semicolon(),this.finishNode(t,"TSImportEqualsDeclaration")}tsIsExternalModuleReference(){return this.isContextual(119)&&40===this.lookaheadCharCode()}tsParseModuleReference(){return this.tsIsExternalModuleReference()?this.tsParseExternalModuleReference():this.tsParseEntityName(!1)}tsParseExternalModuleReference(){const t=this.startNode();return this.expectContextual(119),this.expect(10),this.match(133)||this.unexpected(),t.expression=super.parseExprAtom(),this.expect(11),this.sawUnambiguousESM=!0,this.finishNode(t,"TSExternalModuleReference")}tsLookAhead(t){const e=this.state.clone(),i=t();return this.state=e,i}tsTryParseAndCatch(t){const e=this.tryParse((e=>t()||e()));if(!e.aborted&&e.node)return e.error&&(this.state=e.failState),e.node}tsTryParse(t){const e=this.state.clone(),i=t();if(void 0!==i&&!1!==i)return i;this.state=e}tsTryParseDeclare(t){if(this.isLineTerminator())return;let e,i=this.state.type;return this.isContextual(100)&&(i=74,e="let"),this.tsInAmbientContext((()=>{switch(i){case 68:return t.declare=!0,super.parseFunctionStatement(t,!1,!1);case 80:return t.declare=!0,this.parseClass(t,!0,!1);case 126:return this.tsParseEnumDeclaration(t,{declare:!0});case 112:return this.tsParseAmbientExternalModuleDeclaration(t);case 75:case 74:return this.match(75)&&this.isLookaheadContextual("enum")?(this.expect(75),this.tsParseEnumDeclaration(t,{const:!0,declare:!0})):(t.declare=!0,this.parseVarStatement(t,e||this.state.value,!0));case 129:{const e=this.tsParseInterfaceDeclaration(t,{declare:!0});if(e)return e}default:if(X(i))return this.tsParseDeclaration(t,this.state.value,!0,null)}}))}tsTryParseExportDeclaration(){return this.tsParseDeclaration(this.startNode(),this.state.value,!0,null)}tsParseExpressionStatement(t,e,i){switch(e.name){case"declare":{const e=this.tsTryParseDeclare(t);return e&&(e.declare=!0),e}case"global":if(this.match(5)){this.scope.enter(256),this.prodParam.enter(0);const i=t;return i.global=!0,i.id=e,i.body=this.tsParseModuleBlock(),this.scope.exit(),this.prodParam.exit(),this.finishNode(i,"TSModuleDeclaration")}break;default:return this.tsParseDeclaration(t,e.name,!1,i)}}tsParseDeclaration(t,e,i,s){switch(e){case"abstract":if(this.tsCheckLineTerminator(i)&&(this.match(80)||X(this.state.type)))return this.tsParseAbstractDeclaration(t,s);break;case"module":if(this.tsCheckLineTerminator(i)){if(this.match(133))return this.tsParseAmbientExternalModuleDeclaration(t);if(X(this.state.type))return this.tsParseModuleOrNamespaceDeclaration(t)}break;case"namespace":if(this.tsCheckLineTerminator(i)&&X(this.state.type))return this.tsParseModuleOrNamespaceDeclaration(t);break;case"type":if(this.tsCheckLineTerminator(i)&&X(this.state.type))return this.tsParseTypeAliasDeclaration(t)}}tsCheckLineTerminator(t){return t?!this.hasFollowingLineBreak()&&(this.next(),!0):!this.isLineTerminator()}tsTryParseGenericAsyncArrowFunction(t){if(!this.match(47))return;const e=this.state.maybeInArrowParameters;this.state.maybeInArrowParameters=!0;const i=this.tsTryParseAndCatch((()=>{const e=this.startNodeAt(t);return e.typeParameters=this.tsParseTypeParameters(this.tsParseConstModifier),super.parseFunctionParams(e),e.returnType=this.tsTryParseTypeOrTypePredicateAnnotation(),this.expect(19),e}));return this.state.maybeInArrowParameters=e,i?super.parseArrowExpression(i,null,!0):void 0}tsParseTypeArgumentsInExpression(){if(47===this.reScan_lt())return this.tsParseTypeArguments()}tsParseTypeArguments(){const t=this.startNode();return t.params=this.tsInType((()=>this.tsInNoContext((()=>(this.expect(47),this.tsParseDelimitedList("TypeParametersOrArguments",this.tsParseType.bind(this))))))),0===t.params.length?this.raise(We.EmptyTypeArguments,t):this.state.inType||this.curContext()!==j.brace||this.reScan_lt_gt(),this.expect(48),this.finishNode(t,"TSTypeParameterInstantiation")}tsIsDeclarationStart(){return(t=this.state.type)>=124&&t<=130;var t}isExportDefaultSpecifier(){return!this.tsIsDeclarationStart()&&super.isExportDefaultSpecifier()}parseAssignableListItem(t,e){const i=this.state.startLoc,s={};this.tsParseModifiers({allowedModifiers:["public","private","protected","override","readonly"]},s);const n=s.accessibility,o=s.override,a=s.readonly;4&t||!(n||a||o)||this.raise(We.UnexpectedParameterModifier,i);const r=this.parseMaybeDefault();this.parseAssignableListItemTypes(r,t);const l=this.parseMaybeDefault(r.loc.start,r);if(n||a||o){const t=this.startNodeAt(i);return e.length&&(t.decorators=e),n&&(t.accessibility=n),a&&(t.readonly=a),o&&(t.override=o),"Identifier"!==l.type&&"AssignmentPattern"!==l.type&&this.raise(We.UnsupportedParameterPropertyKind,t),t.parameter=l,this.finishNode(t,"TSParameterProperty")}return e.length&&(r.decorators=e),l}isSimpleParameter(t){return"TSParameterProperty"===t.type&&super.isSimpleParameter(t.parameter)||super.isSimpleParameter(t)}tsDisallowOptionalPattern(t){for(const e of t.params)"Identifier"!==e.type&&e.optional&&!this.state.isAmbientContext&&this.raise(We.PatternIsOptional,e)}setArrowFunctionParameters(t,e,i){super.setArrowFunctionParameters(t,e,i),this.tsDisallowOptionalPattern(t)}parseFunctionBodyAndFinish(t,e,i=!1){this.match(14)&&(t.returnType=this.tsParseTypeOrTypePredicateAnnotation(14));const s="FunctionDeclaration"===e?"TSDeclareFunction":"ClassMethod"===e||"ClassPrivateMethod"===e?"TSDeclareMethod":void 0;return s&&!this.match(5)&&this.isLineTerminator()?this.finishNode(t,s):"TSDeclareFunction"===s&&this.state.isAmbientContext&&(this.raise(We.DeclareFunctionHasImplementation,t),t.declare)?super.parseFunctionBodyAndFinish(t,s,i):(this.tsDisallowOptionalPattern(t),super.parseFunctionBodyAndFinish(t,e,i))}registerFunctionStatementId(t){!t.body&&t.id?this.checkIdentifier(t.id,1024):super.registerFunctionStatementId(t)}tsCheckForInvalidTypeCasts(t){t.forEach((t=>{"TSTypeCastExpression"===(null==t?void 0:t.type)&&this.raise(We.UnexpectedTypeAnnotation,t.typeAnnotation)}))}toReferencedList(t,e){return this.tsCheckForInvalidTypeCasts(t),t}parseArrayLike(t,e,i,s){const n=super.parseArrayLike(t,e,i,s);return"ArrayExpression"===n.type&&this.tsCheckForInvalidTypeCasts(n.elements),n}parseSubscript(t,e,i,s){if(!this.hasPrecedingLineBreak()&&this.match(35)){this.state.canStartJSXElement=!1,this.next();const i=this.startNodeAt(e);return i.expression=t,this.finishNode(i,"TSNonNullExpression")}let n=!1;if(this.match(18)&&60===this.lookaheadCharCode()){if(i)return s.stop=!0,t;s.optionalChainMember=n=!0,this.next()}if(this.match(47)||this.match(51)){let o;const a=this.tsTryParseAndCatch((()=>{if(!i&&this.atPossibleAsyncArrow(t)){const t=this.tsTryParseGenericAsyncArrowFunction(e);if(t)return t}const a=this.tsParseTypeArgumentsInExpression();if(!a)return;if(n&&!this.match(10))return void(o=this.state.curPosition());if(q(this.state.type)){const i=super.parseTaggedTemplateExpression(t,e,s);return i.typeParameters=a,i}if(!i&&this.eat(10)){const i=this.startNodeAt(e);return i.callee=t,i.arguments=this.parseCallExpressionArguments(11,!1),this.tsCheckForInvalidTypeCasts(i.arguments),i.typeParameters=a,s.optionalChainMember&&(i.optional=n),this.finishCallExpression(i,s.optionalChainMember)}const r=this.state.type;if(48===r||52===r||10!==r&&U(r)&&!this.hasPrecedingLineBreak())return;const l=this.startNodeAt(e);return l.expression=t,l.typeParameters=a,this.finishNode(l,"TSInstantiationExpression")}));if(o&&this.unexpected(o,10),a)return"TSInstantiationExpression"===a.type&&(this.match(16)||this.match(18)&&40!==this.lookaheadCharCode())&&this.raise(We.InvalidPropertyAccessAfterInstantiationExpression,this.state.startLoc),a}return super.parseSubscript(t,e,i,s)}parseNewCallee(t){var e;super.parseNewCallee(t);const{callee:i}=t;"TSInstantiationExpression"!==i.type||null!=(e=i.extra)&&e.parenthesized||(t.typeParameters=i.typeParameters,t.callee=i.expression)}parseExprOp(t,e,i){let s;if(Q(58)>i&&!this.hasPrecedingLineBreak()&&(this.isContextual(93)||(s=this.isContextual(120)))){const n=this.startNodeAt(e);return n.expression=t,n.typeAnnotation=this.tsInType((()=>(this.next(),this.match(75)?(s&&this.raise(L.UnexpectedKeyword,this.state.startLoc,{keyword:"const"}),this.tsParseTypeReference()):this.tsParseType()))),this.finishNode(n,s?"TSSatisfiesExpression":"TSAsExpression"),this.reScan_lt_gt(),this.parseExprOp(n,e,i)}return super.parseExprOp(t,e,i)}checkReservedWord(t,e,i,s){this.state.isAmbientContext||super.checkReservedWord(t,e,i,s)}checkImportReflection(t){super.checkImportReflection(t),t.module&&"value"!==t.importKind&&this.raise(We.ImportReflectionHasImportType,t.specifiers[0].loc.start)}checkDuplicateExports(){}isPotentialImportPhase(t){if(super.isPotentialImportPhase(t))return!0;if(this.isContextual(130)){const e=this.lookaheadCharCode();return t?123===e||42===e:61!==e}return!t&&this.isContextual(87)}applyImportPhase(t,e,i,s){super.applyImportPhase(t,e,i,s),e?t.exportKind="type"===i?"type":"value":t.importKind="type"===i||"typeof"===i?i:"value"}parseImport(t){if(this.match(133))return t.importKind="value",super.parseImport(t);let e;if(X(this.state.type)&&61===this.lookaheadCharCode())return t.importKind="value",this.tsParseImportEqualsDeclaration(t);if(this.isContextual(130)){const i=this.parseMaybeImportPhase(t,!1);if(61===this.lookaheadCharCode())return this.tsParseImportEqualsDeclaration(t,i);e=super.parseImportSpecifiersAndAfter(t,i)}else e=super.parseImport(t);return"type"===e.importKind&&e.specifiers.length>1&&"ImportDefaultSpecifier"===e.specifiers[0].type&&this.raise(We.TypeImportCannotSpecifyDefaultAndNamed,e),e}parseExport(t,e){if(this.match(83)){this.next();let e=null;return this.isContextual(130)&&this.isPotentialImportPhase(!1)?e=this.parseMaybeImportPhase(t,!1):t.importKind="value",this.tsParseImportEqualsDeclaration(t,e,!0)}if(this.eat(29)){const e=t;return e.expression=super.parseExpression(),this.semicolon(),this.sawUnambiguousESM=!0,this.finishNode(e,"TSExportAssignment")}if(this.eatContextual(93)){const e=t;return this.expectContextual(128),e.id=this.parseIdentifier(),this.semicolon(),this.finishNode(e,"TSNamespaceExportDeclaration")}return super.parseExport(t,e)}isAbstractClass(){return this.isContextual(124)&&80===this.lookahead().type}parseExportDefaultExpression(){if(this.isAbstractClass()){const t=this.startNode();return this.next(),t.abstract=!0,this.parseClass(t,!0,!0)}if(this.match(129)){const t=this.tsParseInterfaceDeclaration(this.startNode());if(t)return t}return super.parseExportDefaultExpression()}parseVarStatement(t,e,i=!1){const{isAmbientContext:s}=this.state,n=super.parseVarStatement(t,e,i||s);if(!s)return n;for(const{id:t,init:i}of n.declarations)i&&("const"!==e||t.typeAnnotation?this.raise(We.InitializerNotAllowedInAmbientContext,i):Ze(i,this.hasPlugin("estree"))||this.raise(We.ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference,i));return n}parseStatementContent(t,e){if(this.match(75)&&this.isLookaheadContextual("enum")){const t=this.startNode();return this.expect(75),this.tsParseEnumDeclaration(t,{const:!0})}if(this.isContextual(126))return this.tsParseEnumDeclaration(this.startNode());if(this.isContextual(129)){const t=this.tsParseInterfaceDeclaration(this.startNode());if(t)return t}return super.parseStatementContent(t,e)}parseAccessModifier(){return this.tsParseModifier(["public","protected","private"])}tsHasSomeModifiers(t,e){return e.some((e=>we(e)?t.accessibility===e:!!t[e]))}tsIsStartOfStaticBlocks(){return this.isContextual(106)&&123===this.lookaheadCharCode()}parseClassMember(t,e,i){const s=["declare","private","public","protected","override","abstract","readonly","static"];this.tsParseModifiers({allowedModifiers:s,disallowedModifiers:["in","out"],stopOnStartOfClassStaticBlock:!0,errorTemplate:We.InvalidModifierOnTypeParameterPositions},e);const n=()=>{this.tsIsStartOfStaticBlocks()?(this.next(),this.next(),this.tsHasSomeModifiers(e,s)&&this.raise(We.StaticBlockCannotHaveModifier,this.state.curPosition()),super.parseClassStaticBlock(t,e)):this.parseClassMemberWithIsStatic(t,e,i,!!e.static)};e.declare?this.tsInAmbientContext(n):n()}parseClassMemberWithIsStatic(t,e,i,s){const n=this.tsTryParseIndexSignature(e);if(n)return t.body.push(n),e.abstract&&this.raise(We.IndexSignatureHasAbstract,e),e.accessibility&&this.raise(We.IndexSignatureHasAccessibility,e,{modifier:e.accessibility}),e.declare&&this.raise(We.IndexSignatureHasDeclare,e),void(e.override&&this.raise(We.IndexSignatureHasOverride,e));!this.state.inAbstractClass&&e.abstract&&this.raise(We.NonAbstractClassHasAbstractMethod,e),e.override&&(i.hadSuperClass||this.raise(We.OverrideNotInSubClass,e)),super.parseClassMemberWithIsStatic(t,e,i,s)}parsePostMemberNameModifiers(t){this.eat(17)&&(t.optional=!0),t.readonly&&this.match(10)&&this.raise(We.ClassMethodHasReadonly,t),t.declare&&this.match(10)&&this.raise(We.ClassMethodHasDeclare,t)}parseExpressionStatement(t,e,i){return("Identifier"===e.type?this.tsParseExpressionStatement(t,e,i):void 0)||super.parseExpressionStatement(t,e,i)}shouldParseExportDeclaration(){return!!this.tsIsDeclarationStart()||super.shouldParseExportDeclaration()}parseConditional(t,e,i){if(!this.state.maybeInArrowParameters||!this.match(17))return super.parseConditional(t,e,i);const s=this.tryParse((()=>super.parseConditional(t,e)));return s.node?(s.error&&(this.state=s.failState),s.node):(s.error&&super.setOptionalParametersError(i,s.error),t)}parseParenItem(t,e){if(t=super.parseParenItem(t,e),this.eat(17)&&(t.optional=!0,this.resetEndLocation(t)),this.match(14)){const i=this.startNodeAt(e);return i.expression=t,i.typeAnnotation=this.tsParseTypeAnnotation(),this.finishNode(i,"TSTypeCastExpression")}return t}parseExportDeclaration(t){if(!this.state.isAmbientContext&&this.isContextual(125))return this.tsInAmbientContext((()=>this.parseExportDeclaration(t)));const e=this.state.startLoc,i=this.eatContextual(125);if(i&&(this.isContextual(125)||!this.shouldParseExportDeclaration()))throw this.raise(We.ExpectedAmbientAfterExportDeclare,this.state.startLoc);const s=X(this.state.type)&&this.tsTryParseExportDeclaration()||super.parseExportDeclaration(t);return s?(("TSInterfaceDeclaration"===s.type||"TSTypeAliasDeclaration"===s.type||i)&&(t.exportKind="type"),i&&(this.resetStartLocation(s,e),s.declare=!0),s):null}parseClassId(t,e,i,s){if((!e||i)&&this.isContextual(113))return;super.parseClassId(t,e,i,t.declare?1024:8331);const n=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);n&&(t.typeParameters=n)}parseClassPropertyAnnotation(t){t.optional||(this.eat(35)?t.definite=!0:this.eat(17)&&(t.optional=!0));const e=this.tsTryParseTypeAnnotation();e&&(t.typeAnnotation=e)}parseClassProperty(t){if(this.parseClassPropertyAnnotation(t),this.state.isAmbientContext&&(!t.readonly||t.typeAnnotation)&&this.match(29)&&this.raise(We.DeclareClassFieldHasInitializer,this.state.startLoc),t.abstract&&this.match(29)){const{key:e}=t;this.raise(We.AbstractPropertyHasInitializer,this.state.startLoc,{propertyName:"Identifier"!==e.type||t.computed?`[${this.input.slice(e.start,e.end)}]`:e.name})}return super.parseClassProperty(t)}parseClassPrivateProperty(t){return t.abstract&&this.raise(We.PrivateElementHasAbstract,t),t.accessibility&&this.raise(We.PrivateElementHasAccessibility,t,{modifier:t.accessibility}),this.parseClassPropertyAnnotation(t),super.parseClassPrivateProperty(t)}parseClassAccessorProperty(t){return this.parseClassPropertyAnnotation(t),t.optional&&this.raise(We.AccessorCannotBeOptional,t),super.parseClassAccessorProperty(t)}pushClassMethod(t,e,i,s,n,o){const a=this.tsTryParseTypeParameters(this.tsParseConstModifier);a&&n&&this.raise(We.ConstructorHasTypeParameters,a);const{declare:r=!1,kind:l}=e;!r||"get"!==l&&"set"!==l||this.raise(We.DeclareAccessor,e,{kind:l}),a&&(e.typeParameters=a),super.pushClassMethod(t,e,i,s,n,o)}pushClassPrivateMethod(t,e,i,s){const n=this.tsTryParseTypeParameters(this.tsParseConstModifier);n&&(e.typeParameters=n),super.pushClassPrivateMethod(t,e,i,s)}declareClassPrivateMethodInScope(t,e){"TSDeclareMethod"!==t.type&&("MethodDefinition"!==t.type||t.value.body)&&super.declareClassPrivateMethodInScope(t,e)}parseClassSuper(t){super.parseClassSuper(t),t.superClass&&(this.match(47)||this.match(51))&&(t.superTypeParameters=this.tsParseTypeArgumentsInExpression()),this.eatContextual(113)&&(t.implements=this.tsParseHeritageClause("implements"))}parseObjPropValue(t,e,i,s,n,o,a){const r=this.tsTryParseTypeParameters(this.tsParseConstModifier);return r&&(t.typeParameters=r),super.parseObjPropValue(t,e,i,s,n,o,a)}parseFunctionParams(t,e){const i=this.tsTryParseTypeParameters(this.tsParseConstModifier);i&&(t.typeParameters=i),super.parseFunctionParams(t,e)}parseVarId(t,e){super.parseVarId(t,e),"Identifier"===t.id.type&&!this.hasPrecedingLineBreak()&&this.eat(35)&&(t.definite=!0);const i=this.tsTryParseTypeAnnotation();i&&(t.id.typeAnnotation=i,this.resetEndLocation(t.id))}parseAsyncArrowFromCallExpression(t,e){return this.match(14)&&(t.returnType=this.tsParseTypeAnnotation()),super.parseAsyncArrowFromCallExpression(t,e)}parseMaybeAssign(t,e){var i,s,n,o,a;let r,l,h,c;if(this.hasPlugin("jsx")&&(this.match(142)||this.match(47))){if(r=this.state.clone(),l=this.tryParse((()=>super.parseMaybeAssign(t,e)),r),!l.error)return l.node;const{context:i}=this.state,s=i[i.length-1];s!==j.j_oTag&&s!==j.j_expr||i.pop()}if(!(null!=(i=l)&&i.error||this.match(47)))return super.parseMaybeAssign(t,e);r&&r!==this.state||(r=this.state.clone());const d=this.tryParse((i=>{var s,n;c=this.tsParseTypeParameters(this.tsParseConstModifier);const o=super.parseMaybeAssign(t,e);return("ArrowFunctionExpression"!==o.type||null!=(s=o.extra)&&s.parenthesized)&&i(),0!==(null==(n=c)?void 0:n.params.length)&&this.resetStartLocationFromNode(o,c),o.typeParameters=c,o}),r);if(!d.error&&!d.aborted)return c&&this.reportReservedArrowTypeParam(c),d.node;if(!l&&(Me(!this.hasPlugin("jsx")),h=this.tryParse((()=>super.parseMaybeAssign(t,e)),r),!h.error))return h.node;if(null!=(s=l)&&s.node)return this.state=l.failState,l.node;if(d.node)return this.state=d.failState,c&&this.reportReservedArrowTypeParam(c),d.node;if(null!=(n=h)&&n.node)return this.state=h.failState,h.node;throw(null==(o=l)?void 0:o.error)||d.error||(null==(a=h)?void 0:a.error)}reportReservedArrowTypeParam(t){var e;1!==t.params.length||t.params[0].constraint||null!=(e=t.extra)&&e.trailingComma||!this.getPluginOption("typescript","disallowAmbiguousJSXLike")||this.raise(We.ReservedArrowTypeParam,t)}parseMaybeUnary(t,e){return!this.hasPlugin("jsx")&&this.match(47)?this.tsParseTypeAssertion():super.parseMaybeUnary(t,e)}parseArrow(t){if(this.match(14)){const e=this.tryParse((t=>{const e=this.tsParseTypeOrTypePredicateAnnotation(14);return!this.canInsertSemicolon()&&this.match(19)||t(),e}));if(e.aborted)return;e.thrown||(e.error&&(this.state=e.failState),t.returnType=e.node)}return super.parseArrow(t)}parseAssignableListItemTypes(t,e){if(!(2&e))return t;this.eat(17)&&(t.optional=!0);const i=this.tsTryParseTypeAnnotation();return i&&(t.typeAnnotation=i),this.resetEndLocation(t),t}isAssignable(t,e){switch(t.type){case"TSTypeCastExpression":return this.isAssignable(t.expression,e);case"TSParameterProperty":return!0;default:return super.isAssignable(t,e)}}toAssignable(t,e=!1){switch(t.type){case"ParenthesizedExpression":this.toAssignableParenthesizedExpression(t,e);break;case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":e?this.expressionScope.recordArrowParameterBindingError(We.UnexpectedTypeCastInParameter,t):this.raise(We.UnexpectedTypeCastInParameter,t),this.toAssignable(t.expression,e);break;case"AssignmentExpression":e||"TSTypeCastExpression"!==t.left.type||(t.left=this.typeCastToParameter(t.left));default:super.toAssignable(t,e)}}toAssignableParenthesizedExpression(t,e){switch(t.expression.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"ParenthesizedExpression":this.toAssignable(t.expression,e);break;default:super.toAssignable(t,e)}}checkToRestConversion(t,e){switch(t.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":case"TSNonNullExpression":this.checkToRestConversion(t.expression,!1);break;default:super.checkToRestConversion(t,e)}}isValidLVal(t,e,i){return s={TSTypeCastExpression:!0,TSParameterProperty:"parameter",TSNonNullExpression:"expression",TSAsExpression:(64!==i||!e)&&["expression",!0],TSSatisfiesExpression:(64!==i||!e)&&["expression",!0],TSTypeAssertion:(64!==i||!e)&&["expression",!0]},n=t,Object.hasOwnProperty.call(s,n)&&s[n]||super.isValidLVal(t,e,i);var s,n}parseBindingAtom(){return 78===this.state.type?this.parseIdentifier(!0):super.parseBindingAtom()}parseMaybeDecoratorArguments(t){if(this.match(47)||this.match(51)){const e=this.tsParseTypeArgumentsInExpression();if(this.match(10)){const i=super.parseMaybeDecoratorArguments(t);return i.typeParameters=e,i}this.unexpected(null,10)}return super.parseMaybeDecoratorArguments(t)}checkCommaAfterRest(t){return this.state.isAmbientContext&&this.match(12)&&this.lookaheadCharCode()===t?(this.next(),!1):super.checkCommaAfterRest(t)}isClassMethod(){return this.match(47)||super.isClassMethod()}isClassProperty(){return this.match(35)||this.match(14)||super.isClassProperty()}parseMaybeDefault(t,e){const i=super.parseMaybeDefault(t,e);return"AssignmentPattern"===i.type&&i.typeAnnotation&&i.right.startthis.isAssignable(t,!0))):super.shouldParseArrow(t)}shouldParseAsyncArrow(){return this.match(14)||super.shouldParseAsyncArrow()}canHaveLeadingDecorator(){return super.canHaveLeadingDecorator()||this.isAbstractClass()}jsxParseOpeningElementAfterName(t){if(this.match(47)||this.match(51)){const e=this.tsTryParseAndCatch((()=>this.tsParseTypeArgumentsInExpression()));e&&(t.typeParameters=e)}return super.jsxParseOpeningElementAfterName(t)}getGetterSetterExpectedParamCount(t){const e=super.getGetterSetterExpectedParamCount(t),i=this.getObjectOrClassMethodParams(t)[0];return i&&this.isThisParam(i)?e+1:e}parseCatchClauseParam(){const t=super.parseCatchClauseParam(),e=this.tsTryParseTypeAnnotation();return e&&(t.typeAnnotation=e,this.resetEndLocation(t)),t}tsInAmbientContext(t){const e=this.state.isAmbientContext;this.state.isAmbientContext=!0;try{return t()}finally{this.state.isAmbientContext=e}}parseClass(t,e,i){const s=this.state.inAbstractClass;this.state.inAbstractClass=!!t.abstract;try{return super.parseClass(t,e,i)}finally{this.state.inAbstractClass=s}}tsParseAbstractDeclaration(t,e){if(this.match(80))return t.abstract=!0,this.maybeTakeDecorators(e,this.parseClass(t,!0,!1));if(this.isContextual(129)){if(!this.hasFollowingLineBreak())return t.abstract=!0,this.raise(We.NonClassMethodPropertyHasAbstractModifer,t),this.tsParseInterfaceDeclaration(t)}else this.unexpected(null,80)}parseMethod(t,e,i,s,n,o,a){const r=super.parseMethod(t,e,i,s,n,o,a);if(r.abstract&&(this.hasPlugin("estree")?r.value.body:r.body)){const{key:t}=r;this.raise(We.AbstractMethodHasImplementation,r,{methodName:"Identifier"!==t.type||r.computed?`[${this.input.slice(t.start,t.end)}]`:t.name})}return r}tsParseTypeParameterName(){return this.parseIdentifier().name}shouldParseAsAmbientContext(){return!!this.getPluginOption("typescript","dts")}parse(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.parse()}getExpression(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.getExpression()}parseExportSpecifier(t,e,i,s){return!e&&s?(this.parseTypeOnlyImportExportSpecifier(t,!1,i),this.finishNode(t,"ExportSpecifier")):(t.exportKind="value",super.parseExportSpecifier(t,e,i,s))}parseImportSpecifier(t,e,i,s,n){return!e&&s?(this.parseTypeOnlyImportExportSpecifier(t,!0,i),this.finishNode(t,"ImportSpecifier")):(t.importKind="value",super.parseImportSpecifier(t,e,i,s,i?4098:4096))}parseTypeOnlyImportExportSpecifier(t,e,i){const s=e?"imported":"local",n=e?"local":"exported";let o,a=t[s],r=!1,l=!0;const h=a.loc.start;if(this.isContextual(93)){const t=this.parseIdentifier();if(this.isContextual(93)){const i=this.parseIdentifier();E(this.state.type)?(r=!0,a=t,o=e?this.parseIdentifier():this.parseModuleExportName(),l=!1):(o=i,l=!1)}else E(this.state.type)?(l=!1,o=e?this.parseIdentifier():this.parseModuleExportName()):(r=!0,a=t)}else E(this.state.type)&&(r=!0,e?(a=this.parseIdentifier(!0),this.isContextual(93)||this.checkReservedWord(a.name,a.loc.start,!0,!0)):a=this.parseModuleExportName());r&&i&&this.raise(e?We.TypeModifierIsUsedInTypeImports:We.TypeModifierIsUsedInTypeExports,h),t[s]=a,t[n]=o,t[e?"importKind":"exportKind"]=r?"type":"value",l&&this.eatContextual(93)&&(t[n]=e?this.parseIdentifier():this.parseModuleExportName()),t[n]||(t[n]=ne(t[s])),e&&this.checkIdentifier(t[n],r?4098:4096)}},v8intrinsic:t=>class extends t{parseV8Intrinsic(){if(this.match(54)){const t=this.state.startLoc,e=this.startNode();if(this.next(),X(this.state.type)){const t=this.parseIdentifierName(),i=this.createIdentifier(e,t);if(i.type="V8IntrinsicIdentifier",this.match(10))return i}this.unexpected(t)}}parseExprAtom(t){return this.parseV8Intrinsic()||super.parseExprAtom(t)}},placeholders:t=>class extends t{parsePlaceholder(t){if(this.match(144)){const e=this.startNode();return this.next(),this.assertNoSpace(),e.name=super.parseIdentifier(!0),this.assertNoSpace(),this.expect(144),this.finishPlaceholder(e,t)}}finishPlaceholder(t,e){const i=!(!t.expectedNode||"Placeholder"!==t.type);return t.expectedNode=e,i?t:this.finishNode(t,"Placeholder")}getTokenFromCode(t){37===t&&37===this.input.charCodeAt(this.state.pos+1)?this.finishOp(144,2):super.getTokenFromCode(t)}parseExprAtom(t){return this.parsePlaceholder("Expression")||super.parseExprAtom(t)}parseIdentifier(t){return this.parsePlaceholder("Identifier")||super.parseIdentifier(t)}checkReservedWord(t,e,i,s){void 0!==t&&super.checkReservedWord(t,e,i,s)}parseBindingAtom(){return this.parsePlaceholder("Pattern")||super.parseBindingAtom()}isValidLVal(t,e,i){return"Placeholder"===t||super.isValidLVal(t,e,i)}toAssignable(t,e){t&&"Placeholder"===t.type&&"Expression"===t.expectedNode?t.expectedNode="Pattern":super.toAssignable(t,e)}chStartsBindingIdentifier(t,e){return!!super.chStartsBindingIdentifier(t,e)||144===this.lookahead().type}verifyBreakContinue(t,e){t.label&&"Placeholder"===t.label.type||super.verifyBreakContinue(t,e)}parseExpressionStatement(t,e){var i;if("Placeholder"!==e.type||null!=(i=e.extra)&&i.parenthesized)return super.parseExpressionStatement(t,e);if(this.match(14)){const i=t;return i.label=this.finishPlaceholder(e,"Identifier"),this.next(),i.body=super.parseStatementOrSloppyAnnexBFunctionDeclaration(),this.finishNode(i,"LabeledStatement")}return this.semicolon(),t.name=e.name,this.finishPlaceholder(t,"Statement")}parseBlock(t,e,i){return this.parsePlaceholder("BlockStatement")||super.parseBlock(t,e,i)}parseFunctionId(t){return this.parsePlaceholder("Identifier")||super.parseFunctionId(t)}parseClass(t,e,i){const s=e?"ClassDeclaration":"ClassExpression";this.next();const n=this.state.strict,o=this.parsePlaceholder("Identifier");if(o){if(!(this.match(81)||this.match(144)||this.match(5))){if(i||!e)return t.id=null,t.body=this.finishPlaceholder(o,"ClassBody"),this.finishNode(t,s);throw this.raise(fe.ClassNameIsRequired,this.state.startLoc)}t.id=o}else this.parseClassId(t,e,i);return super.parseClassSuper(t),t.body=this.parsePlaceholder("ClassBody")||super.parseClassBody(!!t.superClass,n),this.finishNode(t,s)}parseExport(t,e){const i=this.parsePlaceholder("Identifier");if(!i)return super.parseExport(t,e);if(!this.isContextual(98)&&!this.match(12))return t.specifiers=[],t.source=null,t.declaration=this.finishPlaceholder(i,"Declaration"),this.finishNode(t,"ExportNamedDeclaration");this.expectPlugin("exportDefaultFrom");const s=this.startNode();return s.exported=i,t.specifiers=[this.finishNode(s,"ExportDefaultSpecifier")],super.parseExport(t,e)}isExportDefaultSpecifier(){if(this.match(65)){const t=this.nextTokenStart();if(this.isUnparsedContextual(t,"from")&&this.input.startsWith(_(144),this.nextTokenStartSince(t+4)))return!0}return super.isExportDefaultSpecifier()}maybeParseExportDefaultSpecifier(t,e){var i;return!(null==(i=t.specifiers)||!i.length)||super.maybeParseExportDefaultSpecifier(t,e)}checkExport(t){const{specifiers:e}=t;null!=e&&e.length&&(t.specifiers=e.filter((t=>"Placeholder"===t.exported.type))),super.checkExport(t),t.specifiers=e}parseImport(t){const e=this.parsePlaceholder("Identifier");if(!e)return super.parseImport(t);if(t.specifiers=[],!this.isContextual(98)&&!this.match(12))return t.source=this.finishPlaceholder(e,"StringLiteral"),this.semicolon(),this.finishNode(t,"ImportDeclaration");const i=this.startNodeAtNode(e);return i.local=e,t.specifiers.push(this.finishNode(i,"ImportDefaultSpecifier")),this.eat(12)&&(this.maybeParseStarImportSpecifier(t)||this.parseNamedImportSpecifiers(t)),this.expectContextual(98),t.source=this.parseImportSource(),this.semicolon(),this.finishNode(t,"ImportDeclaration")}parseImportSource(){return this.parsePlaceholder("StringLiteral")||super.parseImportSource()}assertNoSpace(){this.state.start>this.state.lastTokEndLoc.index&&this.raise(fe.UnexpectedSpace,this.state.lastTokEndLoc)}}},Ae=Object.keys(ge),Se={sourceType:"script",sourceFilename:void 0,startColumn:0,startLine:1,allowAwaitOutsideFunction:!1,allowReturnOutsideFunction:!1,allowNewTargetOutsideFunction:!1,allowImportExportEverywhere:!1,allowSuperOutsideMethod:!1,allowUndeclaredExports:!1,plugins:[],strictMode:null,ranges:!1,tokens:!1,createImportExpressions:!1,createParenthesizedExpressions:!1,errorRecovery:!1,attachComment:!0,annexB:!0};class ze extends Le{checkProto(t,e,i,s){if("SpreadElement"===t.type||this.isObjectMethod(t)||t.computed||t.shorthand)return;const n=t.key;if("__proto__"===("Identifier"===n.type?n.name:n.value)){if(e)return void this.raise(L.RecordNoProto,n);i.used&&(s?null===s.doubleProtoLoc&&(s.doubleProtoLoc=n.loc.start):this.raise(L.DuplicateProto,n)),i.used=!0}}shouldExitDescending(t,e){return"ArrowFunctionExpression"===t.type&&t.start===e}getExpression(){this.enterInitialScopes(),this.nextToken();const t=this.parseExpression();return this.match(139)||this.unexpected(),this.finalizeRemainingComments(),t.comments=this.comments,t.errors=this.state.errors,this.options.tokens&&(t.tokens=this.tokens),t}parseExpression(t,e){return t?this.disallowInAnd((()=>this.parseExpressionBase(e))):this.allowInAnd((()=>this.parseExpressionBase(e)))}parseExpressionBase(t){const e=this.state.startLoc,i=this.parseMaybeAssign(t);if(this.match(12)){const s=this.startNodeAt(e);for(s.expressions=[i];this.eat(12);)s.expressions.push(this.parseMaybeAssign(t));return this.toReferencedList(s.expressions),this.finishNode(s,"SequenceExpression")}return i}parseMaybeAssignDisallowIn(t,e){return this.disallowInAnd((()=>this.parseMaybeAssign(t,e)))}parseMaybeAssignAllowIn(t,e){return this.allowInAnd((()=>this.parseMaybeAssign(t,e)))}setOptionalParametersError(t,e){var i;t.optionalParametersLoc=null!=(i=null==e?void 0:e.loc)?i:this.state.startLoc}parseMaybeAssign(t,e){const i=this.state.startLoc;if(this.isContextual(108)&&this.prodParam.hasYield){let t=this.parseYield();return e&&(t=e.call(this,t,i)),t}let s;t?s=!1:(t=new ee,s=!0);const{type:n}=this.state;(10===n||X(n))&&(this.state.potentialArrowAt=this.state.start);let o=this.parseMaybeConditional(t);if(e&&(o=e.call(this,o,i)),(a=this.state.type)>=29&&a<=33){const e=this.startNodeAt(i),s=this.state.value;if(e.operator=s,this.match(29)){this.toAssignable(o,!0),e.left=o;const s=i.index;null!=t.doubleProtoLoc&&t.doubleProtoLoc.index>=s&&(t.doubleProtoLoc=null),null!=t.shorthandAssignLoc&&t.shorthandAssignLoc.index>=s&&(t.shorthandAssignLoc=null),null!=t.privateKeyLoc&&t.privateKeyLoc.index>=s&&(this.checkDestructuringPrivate(t),t.privateKeyLoc=null)}else e.left=o;return this.next(),e.right=this.parseMaybeAssign(),this.checkLVal(o,{in:this.finishNode(e,"AssignmentExpression")}),e}var a;return s&&this.checkExpressionErrors(t,!0),o}parseMaybeConditional(t){const e=this.state.startLoc,i=this.state.potentialArrowAt,s=this.parseExprOps(t);return this.shouldExitDescending(s,i)?s:this.parseConditional(s,e,t)}parseConditional(t,e,i){if(this.eat(17)){const i=this.startNodeAt(e);return i.test=t,i.consequent=this.parseMaybeAssignAllowIn(),this.expect(14),i.alternate=this.parseMaybeAssign(),this.finishNode(i,"ConditionalExpression")}return t}parseMaybeUnaryOrPrivate(t){return this.match(138)?this.parsePrivateName():this.parseMaybeUnary(t)}parseExprOps(t){const e=this.state.startLoc,i=this.state.potentialArrowAt,s=this.parseMaybeUnaryOrPrivate(t);return this.shouldExitDescending(s,i)?s:this.parseExprOp(s,e,-1)}parseExprOp(t,e,i){if(this.isPrivateName(t)){const e=this.getPrivateNameSV(t);(i>=Q(58)||!this.prodParam.hasIn||!this.match(58))&&this.raise(L.PrivateInExpectedIn,t,{identifierName:e}),this.classScope.usePrivateName(e,t.loc.start)}const s=this.state.type;if((n=s)>=39&&n<=59&&(this.prodParam.hasIn||!this.match(58))){let n=Q(s);if(n>i){if(39===s){if(this.expectPlugin("pipelineOperator"),this.state.inFSharpPipelineDirectBody)return t;this.checkPipelineAtInfixOperator(t,e)}const o=this.startNodeAt(e);o.left=t,o.operator=this.state.value;const a=41===s||42===s,r=40===s;if(r&&(n=Q(42)),this.next(),39===s&&this.hasPlugin(["pipelineOperator",{proposal:"minimal"}])&&96===this.state.type&&this.prodParam.hasAwait)throw this.raise(L.UnexpectedAwaitAfterPipelineBody,this.state.startLoc);o.right=this.parseExprOpRightExpr(s,n);const l=this.finishNode(o,a||r?"LogicalExpression":"BinaryExpression"),h=this.state.type;if(r&&(41===h||42===h)||a&&40===h)throw this.raise(L.MixingCoalesceWithLogical,this.state.startLoc);return this.parseExprOp(l,e,i)}}var n;return t}parseExprOpRightExpr(t,e){const i=this.state.startLoc;if(39===t)switch(this.getPluginOption("pipelineOperator","proposal")){case"hack":return this.withTopicBindingContext((()=>this.parseHackPipeBody()));case"smart":return this.withTopicBindingContext((()=>{if(this.prodParam.hasYield&&this.isContextual(108))throw this.raise(L.PipeBodyIsTighter,this.state.startLoc);return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(t,e),i)}));case"fsharp":return this.withSoloAwaitPermittingContext((()=>this.parseFSharpPipelineBody(e)))}return this.parseExprOpBaseRightExpr(t,e)}parseExprOpBaseRightExpr(t,e){const i=this.state.startLoc;return this.parseExprOp(this.parseMaybeUnaryOrPrivate(),i,57===t?e-1:e)}parseHackPipeBody(){var t;const{startLoc:e}=this.state,i=this.parseMaybeAssign();return!d.has(i.type)||null!=(t=i.extra)&&t.parenthesized||this.raise(L.PipeUnparenthesizedBody,e,{type:i.type}),this.topicReferenceWasUsedInCurrentContext()||this.raise(L.PipeTopicUnused,e),i}checkExponentialAfterUnary(t){this.match(57)&&this.raise(L.UnexpectedTokenUnaryExponentiation,t.argument)}parseMaybeUnary(t,e){const i=this.state.startLoc,s=this.isContextual(96);if(s&&this.isAwaitAllowed()){this.next();const t=this.parseAwait(i);return e||this.checkExponentialAfterUnary(t),t}const n=this.match(34),o=this.startNode();if(a=this.state.type,k[a]){o.operator=this.state.value,o.prefix=!0,this.match(72)&&this.expectPlugin("throwExpressions");const i=this.match(89);if(this.next(),o.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(t,!0),this.state.strict&&i){const t=o.argument;"Identifier"===t.type?this.raise(L.StrictDelete,o):this.hasPropertyAsPrivateName(t)&&this.raise(L.DeletePrivateField,o)}if(!n)return e||this.checkExponentialAfterUnary(o),this.finishNode(o,"UnaryExpression")}var a;const r=this.parseUpdate(o,n,t);if(s){const{type:t}=this.state;if((this.hasPlugin("v8intrinsic")?U(t):U(t)&&!this.match(54))&&!this.isAmbiguousAwait())return this.raiseOverwrite(L.AwaitNotInAsyncContext,i),this.parseAwait(i)}return r}parseUpdate(t,e,i){if(e){const e=t;return this.checkLVal(e.argument,{in:this.finishNode(e,"UpdateExpression")}),t}const s=this.state.startLoc;let n=this.parseExprSubscripts(i);if(this.checkExpressionErrors(i,!1))return n;for(;34===this.state.type&&!this.canInsertSemicolon();){const t=this.startNodeAt(s);t.operator=this.state.value,t.prefix=!1,t.argument=n,this.next(),this.checkLVal(n,{in:n=this.finishNode(t,"UpdateExpression")})}return n}parseExprSubscripts(t){const e=this.state.startLoc,i=this.state.potentialArrowAt,s=this.parseExprAtom(t);return this.shouldExitDescending(s,i)?s:this.parseSubscripts(s,e)}parseSubscripts(t,e,i){const s={optionalChainMember:!1,maybeAsyncArrow:this.atPossibleAsyncArrow(t),stop:!1};do{t=this.parseSubscript(t,e,i,s),s.maybeAsyncArrow=!1}while(!s.stop);return t}parseSubscript(t,e,i,s){const{type:n}=this.state;if(!i&&15===n)return this.parseBind(t,e,i,s);if(q(n))return this.parseTaggedTemplateExpression(t,e,s);let o=!1;if(18===n){if(i&&(this.raise(L.OptionalChainingNoNew,this.state.startLoc),40===this.lookaheadCharCode()))return s.stop=!0,t;s.optionalChainMember=o=!0,this.next()}if(!i&&this.match(10))return this.parseCoverCallAndAsyncArrowHead(t,e,s,o);{const i=this.eat(0);return i||o||this.eat(16)?this.parseMember(t,e,s,i,o):(s.stop=!0,t)}}parseMember(t,e,i,s,n){const o=this.startNodeAt(e);return o.object=t,o.computed=s,s?(o.property=this.parseExpression(),this.expect(3)):this.match(138)?("Super"===t.type&&this.raise(L.SuperPrivateField,e),this.classScope.usePrivateName(this.state.value,this.state.startLoc),o.property=this.parsePrivateName()):o.property=this.parseIdentifier(!0),i.optionalChainMember?(o.optional=n,this.finishNode(o,"OptionalMemberExpression")):this.finishNode(o,"MemberExpression")}parseBind(t,e,i,s){const n=this.startNodeAt(e);return n.object=t,this.next(),n.callee=this.parseNoCallExpr(),s.stop=!0,this.parseSubscripts(this.finishNode(n,"BindExpression"),e,i)}parseCoverCallAndAsyncArrowHead(t,e,i,s){const n=this.state.maybeInArrowParameters;let o=null;this.state.maybeInArrowParameters=!0,this.next();const a=this.startNodeAt(e);a.callee=t;const{maybeAsyncArrow:r,optionalChainMember:l}=i;r&&(this.expressionScope.enter(new _t(2)),o=new ee),l&&(a.optional=s),a.arguments=s?this.parseCallExpressionArguments(11):this.parseCallExpressionArguments(11,"Import"===t.type,"Super"!==t.type,a,o);let h=this.finishCallExpression(a,l);return r&&this.shouldParseAsyncArrow()&&!s?(i.stop=!0,this.checkDestructuringPrivate(o),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),h=this.parseAsyncArrowFromCallExpression(this.startNodeAt(e),h)):(r&&(this.checkExpressionErrors(o,!0),this.expressionScope.exit()),this.toReferencedArguments(h)),this.state.maybeInArrowParameters=n,h}toReferencedArguments(t,e){this.toReferencedListDeep(t.arguments,e)}parseTaggedTemplateExpression(t,e,i){const s=this.startNodeAt(e);return s.tag=t,s.quasi=this.parseTemplate(!0),i.optionalChainMember&&this.raise(L.OptionalChainingNoTemplate,e),this.finishNode(s,"TaggedTemplateExpression")}atPossibleAsyncArrow(t){return"Identifier"===t.type&&"async"===t.name&&this.state.lastTokEndLoc.index===t.end&&!this.canInsertSemicolon()&&t.end-t.start==5&&t.start===this.state.potentialArrowAt}expectImportAttributesPlugin(){this.hasPlugin("importAssertions")||this.expectPlugin("importAttributes")}finishCallExpression(t,e){if("Import"===t.callee.type)if(2===t.arguments.length&&(this.hasPlugin("moduleAttributes")||this.expectImportAttributesPlugin()),0===t.arguments.length||t.arguments.length>2)this.raise(L.ImportCallArity,t,{maxArgumentCount:this.hasPlugin("importAttributes")||this.hasPlugin("importAssertions")||this.hasPlugin("moduleAttributes")?2:1});else for(const e of t.arguments)"SpreadElement"===e.type&&this.raise(L.ImportCallSpreadArgument,e);return this.finishNode(t,e?"OptionalCallExpression":"CallExpression")}parseCallExpressionArguments(t,e,i,s,n){const o=[];let a=!0;const r=this.state.inFSharpPipelineDirectBody;for(this.state.inFSharpPipelineDirectBody=!1;!this.eat(t);){if(a)a=!1;else if(this.expect(12),this.match(t)){!e||this.hasPlugin("importAttributes")||this.hasPlugin("importAssertions")||this.hasPlugin("moduleAttributes")||this.raise(L.ImportCallArgumentTrailingComma,this.state.lastTokStartLoc),s&&this.addTrailingCommaExtraToNode(s),this.next();break}o.push(this.parseExprListItem(!1,n,i))}return this.state.inFSharpPipelineDirectBody=r,o}shouldParseAsyncArrow(){return this.match(19)&&!this.canInsertSemicolon()}parseAsyncArrowFromCallExpression(t,e){var i;return this.resetPreviousNodeTrailingComments(e),this.expect(19),this.parseArrowExpression(t,e.arguments,!0,null==(i=e.extra)?void 0:i.trailingCommaLoc),e.innerComments&&vt(t,e.innerComments),e.callee.trailingComments&&vt(t,e.callee.trailingComments),t}parseNoCallExpr(){const t=this.state.startLoc;return this.parseSubscripts(this.parseExprAtom(),t,!0)}parseExprAtom(t){let e,i=null;const{type:s}=this.state;switch(s){case 79:return this.parseSuper();case 83:return e=this.startNode(),this.next(),this.match(16)?this.parseImportMetaProperty(e):this.match(10)?this.options.createImportExpressions?this.parseImportCall(e):this.finishNode(e,"Import"):(this.raise(L.UnsupportedImport,this.state.lastTokStartLoc),this.finishNode(e,"Import"));case 78:return e=this.startNode(),this.next(),this.finishNode(e,"ThisExpression");case 90:return this.parseDo(this.startNode(),!1);case 56:case 31:return this.readRegexp(),this.parseRegExpLiteral(this.state.value);case 134:return this.parseNumericLiteral(this.state.value);case 135:return this.parseBigIntLiteral(this.state.value);case 136:return this.parseDecimalLiteral(this.state.value);case 133:return this.parseStringLiteral(this.state.value);case 84:return this.parseNullLiteral();case 85:return this.parseBooleanLiteral(!0);case 86:return this.parseBooleanLiteral(!1);case 10:{const t=this.state.potentialArrowAt===this.state.start;return this.parseParenAndDistinguishExpression(t)}case 2:case 1:return this.parseArrayLike(2===this.state.type?4:3,!1,!0);case 0:return this.parseArrayLike(3,!0,!1,t);case 6:case 7:return this.parseObjectLike(6===this.state.type?9:8,!1,!0);case 5:return this.parseObjectLike(8,!1,!1,t);case 68:return this.parseFunctionOrFunctionSent();case 26:i=this.parseDecorators();case 80:return this.parseClass(this.maybeTakeDecorators(i,this.startNode()),!1);case 77:return this.parseNewOrNewTarget();case 25:case 24:return this.parseTemplate(!1);case 15:{e=this.startNode(),this.next(),e.object=null;const t=e.callee=this.parseNoCallExpr();if("MemberExpression"===t.type)return this.finishNode(e,"BindExpression");throw this.raise(L.UnsupportedBind,t)}case 138:return this.raise(L.PrivateInExpectedIn,this.state.startLoc,{identifierName:this.state.value}),this.parsePrivateName();case 33:return this.parseTopicReferenceThenEqualsSign(54,"%");case 32:return this.parseTopicReferenceThenEqualsSign(44,"^");case 37:case 38:return this.parseTopicReference("hack");case 44:case 54:case 27:{const t=this.getPluginOption("pipelineOperator","proposal");if(t)return this.parseTopicReference(t);this.unexpected();break}case 47:{const t=this.input.codePointAt(this.nextTokenStart());at(t)||62===t?this.expectOnePlugin(["jsx","flow","typescript"]):this.unexpected();break}default:if(X(s)){if(this.isContextual(127)&&123===this.lookaheadInLineCharCode())return this.parseModuleExpression();const t=this.state.potentialArrowAt===this.state.start,e=this.state.containsEsc,i=this.parseIdentifier();if(!e&&"async"===i.name&&!this.canInsertSemicolon()){const{type:t}=this.state;if(68===t)return this.resetPreviousNodeTrailingComments(i),this.next(),this.parseAsyncFunctionExpression(this.startNodeAtNode(i));if(X(t))return 61===this.lookaheadCharCode()?this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(i)):i;if(90===t)return this.resetPreviousNodeTrailingComments(i),this.parseDo(this.startNodeAtNode(i),!0)}return t&&this.match(19)&&!this.canInsertSemicolon()?(this.next(),this.parseArrowExpression(this.startNodeAtNode(i),[i],!1)):i}this.unexpected()}}parseTopicReferenceThenEqualsSign(t,e){const i=this.getPluginOption("pipelineOperator","proposal");if(i)return this.state.type=t,this.state.value=e,this.state.pos--,this.state.end--,this.state.endLoc=o(this.state.endLoc,-1),this.parseTopicReference(i);this.unexpected()}parseTopicReference(t){const e=this.startNode(),i=this.state.startLoc,s=this.state.type;return this.next(),this.finishTopicReference(e,i,t,s)}finishTopicReference(t,e,i,s){if(this.testTopicReferenceConfiguration(i,e,s)){const s="smart"===i?"PipelinePrimaryTopicReference":"TopicReference";return this.topicReferenceIsAllowedInCurrentContext()||this.raise("smart"===i?L.PrimaryTopicNotAllowed:L.PipeTopicUnbound,e),this.registerTopicReference(),this.finishNode(t,s)}throw this.raise(L.PipeTopicUnconfiguredToken,e,{token:_(s)})}testTopicReferenceConfiguration(t,e,i){switch(t){case"hack":return this.hasPlugin(["pipelineOperator",{topicToken:_(i)}]);case"smart":return 27===i;default:throw this.raise(L.PipeTopicRequiresHackPipes,e)}}parseAsyncArrowUnaryFunction(t){this.prodParam.enter(Kt(!0,this.prodParam.hasYield));const e=[this.parseIdentifier()];return this.prodParam.exit(),this.hasPrecedingLineBreak()&&this.raise(L.LineTerminatorBeforeArrow,this.state.curPosition()),this.expect(19),this.parseArrowExpression(t,e,!0)}parseDo(t,e){this.expectPlugin("doExpressions"),e&&this.expectPlugin("asyncDoExpressions"),t.async=e,this.next();const i=this.state.labels;return this.state.labels=[],e?(this.prodParam.enter(2),t.body=this.parseBlock(),this.prodParam.exit()):t.body=this.parseBlock(),this.state.labels=i,this.finishNode(t,"DoExpression")}parseSuper(){const t=this.startNode();return this.next(),!this.match(10)||this.scope.allowDirectSuper||this.options.allowSuperOutsideMethod?this.scope.allowSuper||this.options.allowSuperOutsideMethod||this.raise(L.UnexpectedSuper,t):this.raise(L.SuperNotAllowed,t),this.match(10)||this.match(0)||this.match(16)||this.raise(L.UnsupportedSuper,t),this.finishNode(t,"Super")}parsePrivateName(){const t=this.startNode(),e=this.startNodeAt(o(this.state.startLoc,1)),i=this.state.value;return this.next(),t.id=this.createIdentifier(e,i),this.finishNode(t,"PrivateName")}parseFunctionOrFunctionSent(){const t=this.startNode();if(this.next(),this.prodParam.hasYield&&this.match(16)){const e=this.createIdentifier(this.startNodeAtNode(t),"function");return this.next(),this.match(103)?this.expectPlugin("functionSent"):this.hasPlugin("functionSent")||this.unexpected(),this.parseMetaProperty(t,e,"sent")}return this.parseFunction(t)}parseMetaProperty(t,e,i){t.meta=e;const s=this.state.containsEsc;return t.property=this.parseIdentifier(!0),(t.property.name!==i||s)&&this.raise(L.UnsupportedMetaProperty,t.property,{target:e.name,onlyValidPropertyName:i}),this.finishNode(t,"MetaProperty")}parseImportMetaProperty(t){const e=this.createIdentifier(this.startNodeAtNode(t),"import");if(this.next(),this.isContextual(101))this.inModule||this.raise(L.ImportMetaOutsideModule,e),this.sawUnambiguousESM=!0;else if(this.isContextual(105)||this.isContextual(97)){const e=this.isContextual(105);if(e||this.unexpected(),this.expectPlugin(e?"sourcePhaseImports":"deferredImportEvaluation"),!this.options.createImportExpressions)throw this.raise(L.DynamicImportPhaseRequiresImportExpressions,this.state.startLoc,{phase:this.state.value});return this.next(),t.phase=e?"source":"defer",this.parseImportCall(t)}return this.parseMetaProperty(t,e,"meta")}parseLiteralAtNode(t,e,i){return this.addExtra(i,"rawValue",t),this.addExtra(i,"raw",this.input.slice(i.start,this.state.end)),i.value=t,this.next(),this.finishNode(i,e)}parseLiteral(t,e){const i=this.startNode();return this.parseLiteralAtNode(t,e,i)}parseStringLiteral(t){return this.parseLiteral(t,"StringLiteral")}parseNumericLiteral(t){return this.parseLiteral(t,"NumericLiteral")}parseBigIntLiteral(t){return this.parseLiteral(t,"BigIntLiteral")}parseDecimalLiteral(t){return this.parseLiteral(t,"DecimalLiteral")}parseRegExpLiteral(t){const e=this.parseLiteral(t.value,"RegExpLiteral");return e.pattern=t.pattern,e.flags=t.flags,e}parseBooleanLiteral(t){const e=this.startNode();return e.value=t,this.next(),this.finishNode(e,"BooleanLiteral")}parseNullLiteral(){const t=this.startNode();return this.next(),this.finishNode(t,"NullLiteral")}parseParenAndDistinguishExpression(t){const e=this.state.startLoc;let i;this.next(),this.expressionScope.enter(new _t(1));const s=this.state.maybeInArrowParameters,n=this.state.inFSharpPipelineDirectBody;this.state.maybeInArrowParameters=!0,this.state.inFSharpPipelineDirectBody=!1;const o=this.state.startLoc,a=[],r=new ee;let l,h,c=!0;for(;!this.match(11);){if(c)c=!1;else if(this.expect(12,null===r.optionalParametersLoc?null:r.optionalParametersLoc),this.match(11)){h=this.state.startLoc;break}if(this.match(21)){const t=this.state.startLoc;if(l=this.state.startLoc,a.push(this.parseParenItem(this.parseRestBinding(),t)),!this.checkCommaAfterRest(41))break}else a.push(this.parseMaybeAssignAllowIn(r,this.parseParenItem))}const d=this.state.lastTokEndLoc;this.expect(11),this.state.maybeInArrowParameters=s,this.state.inFSharpPipelineDirectBody=n;let I=this.startNodeAt(e);return t&&this.shouldParseArrow(a)&&(I=this.parseArrow(I))?(this.checkDestructuringPrivate(r),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),this.parseArrowExpression(I,a,!1),I):(this.expressionScope.exit(),a.length||this.unexpected(this.state.lastTokStartLoc),h&&this.unexpected(h),l&&this.unexpected(l),this.checkExpressionErrors(r,!0),this.toReferencedListDeep(a,!0),a.length>1?(i=this.startNodeAt(o),i.expressions=a,this.finishNode(i,"SequenceExpression"),this.resetEndLocation(i,d)):i=a[0],this.wrapParenthesis(e,i))}wrapParenthesis(t,e){if(!this.options.createParenthesizedExpressions)return this.addExtra(e,"parenthesized",!0),this.addExtra(e,"parenStart",t.index),this.takeSurroundingComments(e,t.index,this.state.lastTokEndLoc.index),e;const i=this.startNodeAt(t);return i.expression=e,this.finishNode(i,"ParenthesizedExpression")}shouldParseArrow(t){return!this.canInsertSemicolon()}parseArrow(t){if(this.eat(19))return t}parseParenItem(t,e){return t}parseNewOrNewTarget(){const t=this.startNode();if(this.next(),this.match(16)){const e=this.createIdentifier(this.startNodeAtNode(t),"new");this.next();const i=this.parseMetaProperty(t,e,"target");return this.scope.inNonArrowFunction||this.scope.inClass||this.options.allowNewTargetOutsideFunction||this.raise(L.UnexpectedNewTarget,i),i}return this.parseNew(t)}parseNew(t){if(this.parseNewCallee(t),this.eat(10)){const e=this.parseExprList(11);this.toReferencedList(e),t.arguments=e}else t.arguments=[];return this.finishNode(t,"NewExpression")}parseNewCallee(t){const e=this.match(83),i=this.parseNoCallExpr();t.callee=i,!e||"Import"!==i.type&&"ImportExpression"!==i.type||this.raise(L.ImportCallNotNewExpression,i)}parseTemplateElement(t){const{start:e,startLoc:i,end:s,value:n}=this.state,a=e+1,r=this.startNodeAt(o(i,1));null===n&&(t||this.raise(L.InvalidEscapeSequenceTemplate,o(this.state.firstInvalidTemplateEscapePos,1)));const l=this.match(24),h=l?-1:-2,c=s+h;r.value={raw:this.input.slice(a,c).replace(/\r\n?/g,"\n"),cooked:null===n?null:n.slice(1,h)},r.tail=l,this.next();const d=this.finishNode(r,"TemplateElement");return this.resetEndLocation(d,o(this.state.lastTokEndLoc,h)),d}parseTemplate(t){const e=this.startNode();e.expressions=[];let i=this.parseTemplateElement(t);for(e.quasis=[i];!i.tail;)e.expressions.push(this.parseTemplateSubstitution()),this.readTemplateContinuation(),e.quasis.push(i=this.parseTemplateElement(t));return this.finishNode(e,"TemplateLiteral")}parseTemplateSubstitution(){return this.parseExpression()}parseObjectLike(t,e,i,s){i&&this.expectPlugin("recordAndTuple");const n=this.state.inFSharpPipelineDirectBody;this.state.inFSharpPipelineDirectBody=!1;const o=Object.create(null);let a=!0;const r=this.startNode();for(r.properties=[],this.next();!this.match(t);){if(a)a=!1;else if(this.expect(12),this.match(t)){this.addTrailingCommaExtraToNode(r);break}let n;e?n=this.parseBindingProperty():(n=this.parsePropertyDefinition(s),this.checkProto(n,i,o,s)),i&&!this.isObjectProperty(n)&&"SpreadElement"!==n.type&&this.raise(L.InvalidRecordProperty,n),n.shorthand&&this.addExtra(n,"shorthand",!0),r.properties.push(n)}this.next(),this.state.inFSharpPipelineDirectBody=n;let l="ObjectExpression";return e?l="ObjectPattern":i&&(l="RecordExpression"),this.finishNode(r,l)}addTrailingCommaExtraToNode(t){this.addExtra(t,"trailingComma",this.state.lastTokStartLoc.index),this.addExtra(t,"trailingCommaLoc",this.state.lastTokStartLoc,!1)}maybeAsyncOrAccessorProp(t){return!t.computed&&"Identifier"===t.key.type&&(this.isLiteralPropertyName()||this.match(0)||this.match(55))}parsePropertyDefinition(t){let e=[];if(this.match(26))for(this.hasPlugin("decorators")&&this.raise(L.UnsupportedPropertyDecorator,this.state.startLoc);this.match(26);)e.push(this.parseDecorator());const i=this.startNode();let s,n=!1,o=!1;if(this.match(21))return e.length&&this.unexpected(),this.parseSpread();e.length&&(i.decorators=e,e=[]),i.method=!1,t&&(s=this.state.startLoc);let a=this.eat(55);this.parsePropertyNamePrefixOperator(i);const r=this.state.containsEsc,l=this.parsePropertyName(i,t);if(!a&&!r&&this.maybeAsyncOrAccessorProp(i)){const t=l.name;"async"!==t||this.hasPrecedingLineBreak()||(n=!0,this.resetPreviousNodeTrailingComments(l),a=this.eat(55),this.parsePropertyName(i)),"get"!==t&&"set"!==t||(o=!0,this.resetPreviousNodeTrailingComments(l),i.kind=t,this.match(55)&&(a=!0,this.raise(L.AccessorIsGenerator,this.state.curPosition(),{kind:t}),this.next()),this.parsePropertyName(i))}return this.parseObjPropValue(i,s,a,n,!1,o,t)}getGetterSetterExpectedParamCount(t){return"get"===t.kind?0:1}getObjectOrClassMethodParams(t){return t.params}checkGetterSetterParams(t){var e;const i=this.getGetterSetterExpectedParamCount(t),s=this.getObjectOrClassMethodParams(t);s.length!==i&&this.raise("get"===t.kind?L.BadGetterArity:L.BadSetterArity,t),"set"===t.kind&&"RestElement"===(null==(e=s[s.length-1])?void 0:e.type)&&this.raise(L.BadSetterRestParameter,t)}parseObjectMethod(t,e,i,s,n){if(n){const i=this.parseMethod(t,e,!1,!1,!1,"ObjectMethod");return this.checkGetterSetterParams(i),i}if(i||e||this.match(10))return s&&this.unexpected(),t.kind="method",t.method=!0,this.parseMethod(t,e,i,!1,!1,"ObjectMethod")}parseObjectProperty(t,e,i,s){if(t.shorthand=!1,this.eat(14))return t.value=i?this.parseMaybeDefault(this.state.startLoc):this.parseMaybeAssignAllowIn(s),this.finishNode(t,"ObjectProperty");if(!t.computed&&"Identifier"===t.key.type){if(this.checkReservedWord(t.key.name,t.key.loc.start,!0,!1),i)t.value=this.parseMaybeDefault(e,ne(t.key));else if(this.match(29)){const i=this.state.startLoc;null!=s?null===s.shorthandAssignLoc&&(s.shorthandAssignLoc=i):this.raise(L.InvalidCoverInitializedName,i),t.value=this.parseMaybeDefault(e,ne(t.key))}else t.value=ne(t.key);return t.shorthand=!0,this.finishNode(t,"ObjectProperty")}}parseObjPropValue(t,e,i,s,n,o,a){const r=this.parseObjectMethod(t,i,s,n,o)||this.parseObjectProperty(t,e,n,a);return r||this.unexpected(),r}parsePropertyName(t,e){if(this.eat(0))t.computed=!0,t.key=this.parseMaybeAssignAllowIn(),this.expect(3);else{const{type:i,value:s}=this.state;let n;if(E(i))n=this.parseIdentifier(!0);else switch(i){case 134:n=this.parseNumericLiteral(s);break;case 133:n=this.parseStringLiteral(s);break;case 135:n=this.parseBigIntLiteral(s);break;case 136:n=this.parseDecimalLiteral(s);break;case 138:{const t=this.state.startLoc;null!=e?null===e.privateKeyLoc&&(e.privateKeyLoc=t):this.raise(L.UnexpectedPrivateField,t),n=this.parsePrivateName();break}default:this.unexpected()}t.key=n,138!==i&&(t.computed=!1)}return t.key}initFunction(t,e){t.id=null,t.generator=!1,t.async=e}parseMethod(t,e,i,s,n,o,a=!1){this.initFunction(t,i),t.generator=e,this.scope.enter(18|(a?64:0)|(n?32:0)),this.prodParam.enter(Kt(i,t.generator)),this.parseFunctionParams(t,s);const r=this.parseFunctionBodyAndFinish(t,o,!0);return this.prodParam.exit(),this.scope.exit(),r}parseArrayLike(t,e,i,s){i&&this.expectPlugin("recordAndTuple");const n=this.state.inFSharpPipelineDirectBody;this.state.inFSharpPipelineDirectBody=!1;const o=this.startNode();return this.next(),o.elements=this.parseExprList(t,!i,s,o),this.state.inFSharpPipelineDirectBody=n,this.finishNode(o,i?"TupleExpression":"ArrayExpression")}parseArrowExpression(t,e,i,s){this.scope.enter(6);let n=Kt(i,!1);!this.match(5)&&this.prodParam.hasIn&&(n|=8),this.prodParam.enter(n),this.initFunction(t,i);const o=this.state.maybeInArrowParameters;return e&&(this.state.maybeInArrowParameters=!0,this.setArrowFunctionParameters(t,e,s)),this.state.maybeInArrowParameters=!1,this.parseFunctionBody(t,!0),this.prodParam.exit(),this.scope.exit(),this.state.maybeInArrowParameters=o,this.finishNode(t,"ArrowFunctionExpression")}setArrowFunctionParameters(t,e,i){this.toAssignableList(e,i,!1),t.params=e}parseFunctionBodyAndFinish(t,e,i=!1){return this.parseFunctionBody(t,!1,i),this.finishNode(t,e)}parseFunctionBody(t,e,i=!1){const s=e&&!this.match(5);if(this.expressionScope.enter(qt()),s)t.body=this.parseMaybeAssign(),this.checkParams(t,!1,e,!1);else{const s=this.state.strict,n=this.state.labels;this.state.labels=[],this.prodParam.enter(4|this.prodParam.currentFlags()),t.body=this.parseBlock(!0,!1,(n=>{const o=!this.isSimpleParamList(t.params);n&&o&&this.raise(L.IllegalLanguageModeDirective,"method"!==t.kind&&"constructor"!==t.kind||!t.key?t:t.key.loc.end);const a=!s&&this.state.strict;this.checkParams(t,!(this.state.strict||e||i||o),e,a),this.state.strict&&t.id&&this.checkIdentifier(t.id,65,a)})),this.prodParam.exit(),this.state.labels=n}this.expressionScope.exit()}isSimpleParameter(t){return"Identifier"===t.type}isSimpleParamList(t){for(let e=0,i=t.length;e10)&&function(t){return bt.has(t)}(t))if(i&&function(t){return lt.has(t)}(t))this.raise(L.UnexpectedKeyword,e,{keyword:t});else if((this.state.strict?s?pt:It:dt)(t,this.inModule))this.raise(L.UnexpectedReservedWord,e,{reservedWord:t});else if("yield"===t){if(this.prodParam.hasYield)return void this.raise(L.YieldBindingIdentifier,e)}else if("await"===t){if(this.prodParam.hasAwait)return void this.raise(L.AwaitBindingIdentifier,e);if(this.scope.inStaticBlock)return void this.raise(L.AwaitBindingIdentifierInStaticBlock,e);this.expressionScope.recordAsyncArrowParametersError(e)}else if("arguments"===t&&this.scope.inClassAndNotInNonArrowFunction)return void this.raise(L.ArgumentsInClass,e)}isAwaitAllowed(){return!!this.prodParam.hasAwait||!(!this.options.allowAwaitOutsideFunction||this.scope.inFunction)}parseAwait(t){const e=this.startNodeAt(t);return this.expressionScope.recordParameterInitializerError(L.AwaitExpressionFormalParameter,e),this.eat(55)&&this.raise(L.ObsoleteAwaitStar,e),this.scope.inFunction||this.options.allowAwaitOutsideFunction||(this.isAmbiguousAwait()?this.ambiguousScriptDifferentAst=!0:this.sawUnambiguousESM=!0),this.state.soloAwait||(e.argument=this.parseMaybeUnary(null,!0)),this.finishNode(e,"AwaitExpression")}isAmbiguousAwait(){if(this.hasPrecedingLineBreak())return!0;const{type:t}=this.state;return 53===t||10===t||0===t||q(t)||102===t&&!this.state.containsEsc||137===t||56===t||this.hasPlugin("v8intrinsic")&&54===t}parseYield(){const t=this.startNode();this.expressionScope.recordParameterInitializerError(L.YieldInParameter,t),this.next();let e=!1,i=null;if(!this.hasPrecedingLineBreak())switch(e=this.eat(55),this.state.type){case 13:case 139:case 8:case 11:case 3:case 9:case 14:case 12:if(!e)break;default:i=this.parseMaybeAssign()}return t.delegate=e,t.argument=i,this.finishNode(t,"YieldExpression")}parseImportCall(t){return this.next(),t.source=this.parseMaybeAssignAllowIn(),(this.hasPlugin("importAttributes")||this.hasPlugin("importAssertions"))&&(t.options=null),this.eat(12)&&(this.expectImportAttributesPlugin(),this.match(11)||(t.options=this.parseMaybeAssignAllowIn(),this.eat(12))),this.expect(11),this.finishNode(t,"ImportExpression")}checkPipelineAtInfixOperator(t,e){this.hasPlugin(["pipelineOperator",{proposal:"smart"}])&&"SequenceExpression"===t.type&&this.raise(L.PipelineHeadSequenceExpression,e)}parseSmartPipelineBodyInStyle(t,e){if(this.isSimpleReference(t)){const i=this.startNodeAt(e);return i.callee=t,this.finishNode(i,"PipelineBareFunction")}{const i=this.startNodeAt(e);return this.checkSmartPipeTopicBodyEarlyErrors(e),i.expression=t,this.finishNode(i,"PipelineTopicExpression")}}isSimpleReference(t){switch(t.type){case"MemberExpression":return!t.computed&&this.isSimpleReference(t.object);case"Identifier":return!0;default:return!1}}checkSmartPipeTopicBodyEarlyErrors(t){if(this.match(19))throw this.raise(L.PipelineBodyNoArrow,this.state.startLoc);this.topicReferenceWasUsedInCurrentContext()||this.raise(L.PipelineTopicUnused,t)}withTopicBindingContext(t){const e=this.state.topicContext;this.state.topicContext={maxNumOfResolvableTopics:1,maxTopicIndex:null};try{return t()}finally{this.state.topicContext=e}}withSmartMixTopicForbiddingContext(t){if(!this.hasPlugin(["pipelineOperator",{proposal:"smart"}]))return t();{const e=this.state.topicContext;this.state.topicContext={maxNumOfResolvableTopics:0,maxTopicIndex:null};try{return t()}finally{this.state.topicContext=e}}}withSoloAwaitPermittingContext(t){const e=this.state.soloAwait;this.state.soloAwait=!0;try{return t()}finally{this.state.soloAwait=e}}allowInAnd(t){const e=this.prodParam.currentFlags();if(8&~e){this.prodParam.enter(8|e);try{return t()}finally{this.prodParam.exit()}}return t()}disallowInAnd(t){const e=this.prodParam.currentFlags();if(8&e){this.prodParam.enter(-9&e);try{return t()}finally{this.prodParam.exit()}}return t()}registerTopicReference(){this.state.topicContext.maxTopicIndex=0}topicReferenceIsAllowedInCurrentContext(){return this.state.topicContext.maxNumOfResolvableTopics>=1}topicReferenceWasUsedInCurrentContext(){return null!=this.state.topicContext.maxTopicIndex&&this.state.topicContext.maxTopicIndex>=0}parseFSharpPipelineBody(t){const e=this.state.startLoc;this.state.potentialArrowAt=this.state.start;const i=this.state.inFSharpPipelineDirectBody;this.state.inFSharpPipelineDirectBody=!0;const s=this.parseExprOp(this.parseMaybeUnaryOrPrivate(),e,t);return this.state.inFSharpPipelineDirectBody=i,s}parseModuleExpression(){this.expectPlugin("moduleBlocks");const t=this.startNode();this.next(),this.match(5)||this.unexpected(null,5);const e=this.startNodeAt(this.state.endLoc);this.next();const i=this.initializeScopes(!0);this.enterInitialScopes();try{t.body=this.parseProgram(e,8,"module")}finally{i()}return this.finishNode(t,"ModuleExpression")}parsePropertyNamePrefixOperator(t){}}const Ve={kind:1},Te={kind:2},ke=/[\uD800-\uDFFF]/u,Oe=/in(?:stanceof)?/y;class Fe extends ze{parseTopLevel(t,e){return t.program=this.parseProgram(e),t.comments=this.comments,this.options.tokens&&(t.tokens=function(t,e){for(let i=0;i0)for(const[t,e]of Array.from(this.scope.undefinedExports))this.raise(L.ModuleExportUndefined,e,{localName:t});let s;return s=139===e?this.finishNode(t,"Program"):this.finishNodeAt(t,"Program",o(this.state.startLoc,-1)),s}stmtToDirective(t){const e=t;e.type="Directive",e.value=e.expression,delete e.expression;const i=e.value,s=i.value,n=this.input.slice(i.start,i.end),o=i.value=n.slice(1,-1);return this.addExtra(i,"raw",n),this.addExtra(i,"rawValue",o),this.addExtra(i,"expressionValue",s),i.type="DirectiveLiteral",e}parseInterpreterDirective(){if(!this.match(28))return null;const t=this.startNode();return t.value=this.state.value,this.next(),this.finishNode(t,"InterpreterDirective")}isLet(){return!!this.isContextual(100)&&this.hasFollowingBindingAtom()}chStartsBindingIdentifier(t,e){if(at(t)){if(Oe.lastIndex=e,Oe.test(this.input)){const t=this.codePointAtPos(Oe.lastIndex);if(!rt(t)&&92!==t)return!1}return!0}return 92===t}chStartsBindingPattern(t){return 91===t||123===t}hasFollowingBindingAtom(){const t=this.nextTokenStart(),e=this.codePointAtPos(t);return this.chStartsBindingPattern(e)||this.chStartsBindingIdentifier(e,t)}hasInLineFollowingBindingIdentifier(){const t=this.nextTokenInLineStart(),e=this.codePointAtPos(t);return this.chStartsBindingIdentifier(e,t)}startsUsingForOf(){const{type:t,containsEsc:e}=this.lookahead();return!(102===t&&!e)&&(X(t)&&!this.hasFollowingLineBreak()?(this.expectPlugin("explicitResourceManagement"),!0):void 0)}startsAwaitUsing(){let t=this.nextTokenInLineStart();if(this.isUnparsedContextual(t,"using")){t=this.nextTokenInLineStartSince(t+5);const e=this.codePointAtPos(t);if(this.chStartsBindingIdentifier(e,t))return this.expectPlugin("explicitResourceManagement"),!0}return!1}parseModuleItem(){return this.parseStatementLike(15)}parseStatementListItem(){return this.parseStatementLike(6|(!this.options.annexB||this.state.strict?0:8))}parseStatementOrSloppyAnnexBFunctionDeclaration(t=!1){let e=0;return this.options.annexB&&!this.state.strict&&(e|=4,t&&(e|=8)),this.parseStatementLike(e)}parseStatement(){return this.parseStatementLike(0)}parseStatementLike(t){let e=null;return this.match(26)&&(e=this.parseDecorators(!0)),this.parseStatementContent(t,e)}parseStatementContent(t,e){const i=this.state.type,s=this.startNode(),n=!!(2&t),o=!!(4&t),a=1&t;switch(i){case 60:return this.parseBreakContinueStatement(s,!0);case 63:return this.parseBreakContinueStatement(s,!1);case 64:return this.parseDebuggerStatement(s);case 90:return this.parseDoWhileStatement(s);case 91:return this.parseForStatement(s);case 68:if(46===this.lookaheadCharCode())break;return o||this.raise(this.state.strict?L.StrictFunction:this.options.annexB?L.SloppyFunctionAnnexB:L.SloppyFunction,this.state.startLoc),this.parseFunctionStatement(s,!1,!n&&o);case 80:return n||this.unexpected(),this.parseClass(this.maybeTakeDecorators(e,s),!0);case 69:return this.parseIfStatement(s);case 70:return this.parseReturnStatement(s);case 71:return this.parseSwitchStatement(s);case 72:return this.parseThrowStatement(s);case 73:return this.parseTryStatement(s);case 96:if(!this.state.containsEsc&&this.startsAwaitUsing())return this.isAwaitAllowed()?n||this.raise(L.UnexpectedLexicalDeclaration,s):this.raise(L.AwaitUsingNotInAsyncContext,s),this.next(),this.parseVarStatement(s,"await using");break;case 107:if(this.state.containsEsc||!this.hasInLineFollowingBindingIdentifier())break;return this.expectPlugin("explicitResourceManagement"),!this.scope.inModule&&this.scope.inTopLevel?this.raise(L.UnexpectedUsingDeclaration,this.state.startLoc):n||this.raise(L.UnexpectedLexicalDeclaration,this.state.startLoc),this.parseVarStatement(s,"using");case 100:{if(this.state.containsEsc)break;const t=this.nextTokenStart(),e=this.codePointAtPos(t);if(91!==e){if(!n&&this.hasFollowingLineBreak())break;if(!this.chStartsBindingIdentifier(e,t)&&123!==e)break}}case 75:n||this.raise(L.UnexpectedLexicalDeclaration,this.state.startLoc);case 74:{const t=this.state.value;return this.parseVarStatement(s,t)}case 92:return this.parseWhileStatement(s);case 76:return this.parseWithStatement(s);case 5:return this.parseBlock();case 13:return this.parseEmptyStatement(s);case 83:{const t=this.lookaheadCharCode();if(40===t||46===t)break}case 82:{let t;return this.options.allowImportExportEverywhere||a||this.raise(L.UnexpectedImportExport,this.state.startLoc),this.next(),83===i?(t=this.parseImport(s),"ImportDeclaration"!==t.type||t.importKind&&"value"!==t.importKind||(this.sawUnambiguousESM=!0)):(t=this.parseExport(s,e),("ExportNamedDeclaration"!==t.type||t.exportKind&&"value"!==t.exportKind)&&("ExportAllDeclaration"!==t.type||t.exportKind&&"value"!==t.exportKind)&&"ExportDefaultDeclaration"!==t.type||(this.sawUnambiguousESM=!0)),this.assertModuleNodeAllowed(t),t}default:if(this.isAsyncFunction())return n||this.raise(L.AsyncFunctionInSingleStatementContext,this.state.startLoc),this.next(),this.parseFunctionStatement(s,!0,!n&&o)}const r=this.state.value,l=this.parseExpression();return X(i)&&"Identifier"===l.type&&this.eat(14)?this.parseLabeledStatement(s,r,l,t):this.parseExpressionStatement(s,l,e)}assertModuleNodeAllowed(t){this.options.allowImportExportEverywhere||this.inModule||this.raise(L.ImportOutsideModule,t)}decoratorsEnabledBeforeExport(){return!!this.hasPlugin("decorators-legacy")||this.hasPlugin("decorators")&&!1!==this.getPluginOption("decorators","decoratorsBeforeExport")}maybeTakeDecorators(t,e,i){return t&&(e.decorators&&e.decorators.length>0?("boolean"!=typeof this.getPluginOption("decorators","decoratorsBeforeExport")&&this.raise(L.DecoratorsBeforeAfterExport,e.decorators[0]),e.decorators.unshift(...t)):e.decorators=t,this.resetStartLocationFromNode(e,t[0]),i&&this.resetStartLocationFromNode(i,e)),e}canHaveLeadingDecorator(){return this.match(80)}parseDecorators(t){const e=[];do{e.push(this.parseDecorator())}while(this.match(26));if(this.match(82))t||this.unexpected(),this.decoratorsEnabledBeforeExport()||this.raise(L.DecoratorExportClass,this.state.startLoc);else if(!this.canHaveLeadingDecorator())throw this.raise(L.UnexpectedLeadingDecorator,this.state.startLoc);return e}parseDecorator(){this.expectOnePlugin(["decorators","decorators-legacy"]);const t=this.startNode();if(this.next(),this.hasPlugin("decorators")){const e=this.state.startLoc;let i;if(this.match(10)){const e=this.state.startLoc;this.next(),i=this.parseExpression(),this.expect(11),i=this.wrapParenthesis(e,i);const s=this.state.startLoc;t.expression=this.parseMaybeDecoratorArguments(i),!1===this.getPluginOption("decorators","allowCallParenthesized")&&t.expression!==i&&this.raise(L.DecoratorArgumentsOutsideParentheses,s)}else{for(i=this.parseIdentifier(!1);this.eat(16);){const t=this.startNodeAt(e);t.object=i,this.match(138)?(this.classScope.usePrivateName(this.state.value,this.state.startLoc),t.property=this.parsePrivateName()):t.property=this.parseIdentifier(!0),t.computed=!1,i=this.finishNode(t,"MemberExpression")}t.expression=this.parseMaybeDecoratorArguments(i)}}else t.expression=this.parseExprSubscripts();return this.finishNode(t,"Decorator")}parseMaybeDecoratorArguments(t){if(this.eat(10)){const e=this.startNodeAtNode(t);return e.callee=t,e.arguments=this.parseCallExpressionArguments(11,!1),this.toReferencedList(e.arguments),this.finishNode(e,"CallExpression")}return t}parseBreakContinueStatement(t,e){return this.next(),this.isLineTerminator()?t.label=null:(t.label=this.parseIdentifier(),this.semicolon()),this.verifyBreakContinue(t,e),this.finishNode(t,e?"BreakStatement":"ContinueStatement")}verifyBreakContinue(t,e){let i;for(i=0;ithis.parseStatement())),this.state.labels.pop(),this.expect(92),t.test=this.parseHeaderExpression(),this.eat(13),this.finishNode(t,"DoWhileStatement")}parseForStatement(t){this.next(),this.state.labels.push(Ve);let e=null;if(this.isAwaitAllowed()&&this.eatContextual(96)&&(e=this.state.lastTokStartLoc),this.scope.enter(0),this.expect(10),this.match(13))return null!==e&&this.unexpected(e),this.parseFor(t,null);const i=this.isContextual(100);{const s=this.isContextual(96)&&this.startsAwaitUsing(),n=s||this.isContextual(107)&&this.startsUsingForOf(),o=i&&this.hasFollowingBindingAtom()||n;if(this.match(74)||this.match(75)||o){const i=this.startNode();let o;s?(o="await using",this.isAwaitAllowed()||this.raise(L.AwaitUsingNotInAsyncContext,this.state.startLoc),this.next()):o=this.state.value,this.next(),this.parseVar(i,!0,o);const a=this.finishNode(i,"VariableDeclaration"),r=this.match(58);return r&&n&&this.raise(L.ForInUsing,a),(r||this.isContextual(102))&&1===a.declarations.length?this.parseForIn(t,a,e):(null!==e&&this.unexpected(e),this.parseFor(t,a))}}const s=this.isContextual(95),n=new ee,o=this.parseExpression(!0,n),a=this.isContextual(102);if(a&&(i&&this.raise(L.ForOfLet,o),null===e&&s&&"Identifier"===o.type&&this.raise(L.ForOfAsync,o)),a||this.match(58)){this.checkDestructuringPrivate(n),this.toAssignable(o,!0);const i=a?"ForOfStatement":"ForInStatement";return this.checkLVal(o,{in:{type:i}}),this.parseForIn(t,o,e)}return this.checkExpressionErrors(n,!0),null!==e&&this.unexpected(e),this.parseFor(t,o)}parseFunctionStatement(t,e,i){return this.next(),this.parseFunction(t,1|(i?2:0)|(e?8:0))}parseIfStatement(t){return this.next(),t.test=this.parseHeaderExpression(),t.consequent=this.parseStatementOrSloppyAnnexBFunctionDeclaration(),t.alternate=this.eat(66)?this.parseStatementOrSloppyAnnexBFunctionDeclaration():null,this.finishNode(t,"IfStatement")}parseReturnStatement(t){return this.prodParam.hasReturn||this.options.allowReturnOutsideFunction||this.raise(L.IllegalReturn,this.state.startLoc),this.next(),this.isLineTerminator()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")}parseSwitchStatement(t){this.next(),t.discriminant=this.parseHeaderExpression();const e=t.cases=[];let i;this.expect(5),this.state.labels.push(Te),this.scope.enter(0);for(let t;!this.match(8);)if(this.match(61)||this.match(65)){const s=this.match(61);i&&this.finishNode(i,"SwitchCase"),e.push(i=this.startNode()),i.consequent=[],this.next(),s?i.test=this.parseExpression():(t&&this.raise(L.MultipleDefaultsInSwitch,this.state.lastTokStartLoc),t=!0,i.test=null),this.expect(14)}else i?i.consequent.push(this.parseStatementListItem()):this.unexpected();return this.scope.exit(),i&&this.finishNode(i,"SwitchCase"),this.next(),this.state.labels.pop(),this.finishNode(t,"SwitchStatement")}parseThrowStatement(t){return this.next(),this.hasPrecedingLineBreak()&&this.raise(L.NewlineAfterThrow,this.state.lastTokEndLoc),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")}parseCatchClauseParam(){const t=this.parseBindingAtom();return this.scope.enter(this.options.annexB&&"Identifier"===t.type?8:0),this.checkLVal(t,{in:{type:"CatchClause"},binding:9}),t}parseTryStatement(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.match(62)){const e=this.startNode();this.next(),this.match(10)?(this.expect(10),e.param=this.parseCatchClauseParam(),this.expect(11)):(e.param=null,this.scope.enter(0)),e.body=this.withSmartMixTopicForbiddingContext((()=>this.parseBlock(!1,!1))),this.scope.exit(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(67)?this.parseBlock():null,t.handler||t.finalizer||this.raise(L.NoCatchOrFinally,t),this.finishNode(t,"TryStatement")}parseVarStatement(t,e,i=!1){return this.next(),this.parseVar(t,!1,e,i),this.semicolon(),this.finishNode(t,"VariableDeclaration")}parseWhileStatement(t){return this.next(),t.test=this.parseHeaderExpression(),this.state.labels.push(Ve),t.body=this.withSmartMixTopicForbiddingContext((()=>this.parseStatement())),this.state.labels.pop(),this.finishNode(t,"WhileStatement")}parseWithStatement(t){return this.state.strict&&this.raise(L.StrictWith,this.state.startLoc),this.next(),t.object=this.parseHeaderExpression(),t.body=this.withSmartMixTopicForbiddingContext((()=>this.parseStatement())),this.finishNode(t,"WithStatement")}parseEmptyStatement(t){return this.next(),this.finishNode(t,"EmptyStatement")}parseLabeledStatement(t,e,i,s){for(const t of this.state.labels)t.name===e&&this.raise(L.LabelRedeclaration,i,{labelName:e});const n=(o=this.state.type)>=90&&o<=92?1:this.match(71)?2:null;var o;for(let e=this.state.labels.length-1;e>=0;e--){const i=this.state.labels[e];if(i.statementStart!==t.start)break;i.statementStart=this.state.start,i.kind=n}return this.state.labels.push({name:e,kind:n,statementStart:this.state.start}),t.body=8&s?this.parseStatementOrSloppyAnnexBFunctionDeclaration(!0):this.parseStatement(),this.state.labels.pop(),t.label=i,this.finishNode(t,"LabeledStatement")}parseExpressionStatement(t,e,i){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")}parseBlock(t=!1,e=!0,i){const s=this.startNode();return t&&this.state.strictErrors.clear(),this.expect(5),e&&this.scope.enter(0),this.parseBlockBody(s,t,!1,8,i),e&&this.scope.exit(),this.finishNode(s,"BlockStatement")}isValidDirective(t){return"ExpressionStatement"===t.type&&"StringLiteral"===t.expression.type&&!t.expression.extra.parenthesized}parseBlockBody(t,e,i,s,n){const o=t.body=[],a=t.directives=[];this.parseBlockOrModuleBlockBody(o,e?a:void 0,i,s,n)}parseBlockOrModuleBlockBody(t,e,i,s,n){const o=this.state.strict;let a=!1,r=!1;for(;!this.match(s);){const s=i?this.parseModuleItem():this.parseStatementListItem();if(e&&!r){if(this.isValidDirective(s)){const t=this.stmtToDirective(s);e.push(t),a||"use strict"!==t.value.value||(a=!0,this.setStrict(!0));continue}r=!0,this.state.strictErrors.clear()}t.push(s)}null==n||n.call(this,a),o||this.setStrict(!1),this.next()}parseFor(t,e){return t.init=e,this.semicolon(!1),t.test=this.match(13)?null:this.parseExpression(),this.semicolon(!1),t.update=this.match(11)?null:this.parseExpression(),this.expect(11),t.body=this.withSmartMixTopicForbiddingContext((()=>this.parseStatement())),this.scope.exit(),this.state.labels.pop(),this.finishNode(t,"ForStatement")}parseForIn(t,e,i){const s=this.match(58);return this.next(),s?null!==i&&this.unexpected(i):t.await=null!==i,"VariableDeclaration"!==e.type||null==e.declarations[0].init||s&&this.options.annexB&&!this.state.strict&&"var"===e.kind&&"Identifier"===e.declarations[0].id.type||this.raise(L.ForInOfLoopInitializer,e,{type:s?"ForInStatement":"ForOfStatement"}),"AssignmentPattern"===e.type&&this.raise(L.InvalidLhs,e,{ancestor:{type:"ForStatement"}}),t.left=e,t.right=s?this.parseExpression():this.parseMaybeAssignAllowIn(),this.expect(11),t.body=this.withSmartMixTopicForbiddingContext((()=>this.parseStatement())),this.scope.exit(),this.state.labels.pop(),this.finishNode(t,s?"ForInStatement":"ForOfStatement")}parseVar(t,e,i,s=!1){const n=t.declarations=[];for(t.kind=i;;){const t=this.startNode();if(this.parseVarId(t,i),t.init=this.eat(29)?e?this.parseMaybeAssignDisallowIn():this.parseMaybeAssignAllowIn():null,null!==t.init||s||("Identifier"===t.id.type||e&&(this.match(58)||this.isContextual(102))?"const"!==i||this.match(58)||this.isContextual(102)||this.raise(L.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:"const"}):this.raise(L.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:"destructuring"})),n.push(this.finishNode(t,"VariableDeclarator")),!this.eat(12))break}return t}parseVarId(t,e){const i=this.parseBindingAtom();this.checkLVal(i,{in:{type:"VariableDeclarator"},binding:"var"===e?5:8201}),t.id=i}parseAsyncFunctionExpression(t){return this.parseFunction(t,8)}parseFunction(t,e=0){const i=2&e,s=!!(1&e),n=s&&!(4&e),o=!!(8&e);this.initFunction(t,o),this.match(55)&&(i&&this.raise(L.GeneratorInSingleStatementContext,this.state.startLoc),this.next(),t.generator=!0),s&&(t.id=this.parseFunctionId(n));const a=this.state.maybeInArrowParameters;return this.state.maybeInArrowParameters=!1,this.scope.enter(2),this.prodParam.enter(Kt(o,t.generator)),s||(t.id=this.parseFunctionId()),this.parseFunctionParams(t,!1),this.withSmartMixTopicForbiddingContext((()=>{this.parseFunctionBodyAndFinish(t,s?"FunctionDeclaration":"FunctionExpression")})),this.prodParam.exit(),this.scope.exit(),s&&!i&&this.registerFunctionStatementId(t),this.state.maybeInArrowParameters=a,t}parseFunctionId(t){return t||X(this.state.type)?this.parseIdentifier():null}parseFunctionParams(t,e){this.expect(10),this.expressionScope.enter(new Pt(3)),t.params=this.parseBindingList(11,41,2|(e?4:0)),this.expressionScope.exit()}registerFunctionStatementId(t){t.id&&this.scope.declareName(t.id.name,!this.options.annexB||this.state.strict||t.generator||t.async?this.scope.treatFunctionsAsVar?5:8201:17,t.id.loc.start)}parseClass(t,e,i){this.next();const s=this.state.strict;return this.state.strict=!0,this.parseClassId(t,e,i),this.parseClassSuper(t),t.body=this.parseClassBody(!!t.superClass,s),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")}isClassProperty(){return this.match(29)||this.match(13)||this.match(8)}isClassMethod(){return this.match(10)}isNonstaticConstructor(t){return!(t.computed||t.static||"constructor"!==t.key.name&&"constructor"!==t.key.value)}parseClassBody(t,e){this.classScope.enter();const i={hadConstructor:!1,hadSuperClass:t};let s=[];const n=this.startNode();if(n.body=[],this.expect(5),this.withSmartMixTopicForbiddingContext((()=>{for(;!this.match(8);){if(this.eat(13)){if(s.length>0)throw this.raise(L.DecoratorSemicolon,this.state.lastTokEndLoc);continue}if(this.match(26)){s.push(this.parseDecorator());continue}const t=this.startNode();s.length&&(t.decorators=s,this.resetStartLocationFromNode(t,s[0]),s=[]),this.parseClassMember(n,t,i),"constructor"===t.kind&&t.decorators&&t.decorators.length>0&&this.raise(L.DecoratorConstructor,t)}})),this.state.strict=e,this.next(),s.length)throw this.raise(L.TrailingDecorator,this.state.startLoc);return this.classScope.exit(),this.finishNode(n,"ClassBody")}parseClassMemberFromModifier(t,e){const i=this.parseIdentifier(!0);if(this.isClassMethod()){const s=e;return s.kind="method",s.computed=!1,s.key=i,s.static=!1,this.pushClassMethod(t,s,!1,!1,!1,!1),!0}if(this.isClassProperty()){const s=e;return s.computed=!1,s.key=i,s.static=!1,t.body.push(this.parseClassProperty(s)),!0}return this.resetPreviousNodeTrailingComments(i),!1}parseClassMember(t,e,i){const s=this.isContextual(106);if(s){if(this.parseClassMemberFromModifier(t,e))return;if(this.eat(5))return void this.parseClassStaticBlock(t,e)}this.parseClassMemberWithIsStatic(t,e,i,s)}parseClassMemberWithIsStatic(t,e,i,s){const n=e,o=e,a=e,r=e,l=e,h=n,c=n;if(e.static=s,this.parsePropertyNamePrefixOperator(e),this.eat(55)){h.kind="method";const e=this.match(138);return this.parseClassElementName(h),e?void this.pushClassPrivateMethod(t,o,!0,!1):(this.isNonstaticConstructor(n)&&this.raise(L.ConstructorIsGenerator,n.key),void this.pushClassMethod(t,n,!0,!1,!1,!1))}const d=X(this.state.type)&&!this.state.containsEsc,I=this.match(138),u=this.parseClassElementName(e),p=this.state.startLoc;if(this.parsePostMemberNameModifiers(c),this.isClassMethod()){if(h.kind="method",I)return void this.pushClassPrivateMethod(t,o,!1,!1);const s=this.isNonstaticConstructor(n);let a=!1;s&&(n.kind="constructor",i.hadConstructor&&!this.hasPlugin("typescript")&&this.raise(L.DuplicateConstructor,u),s&&this.hasPlugin("typescript")&&e.override&&this.raise(L.OverrideOnConstructor,u),i.hadConstructor=!0,a=i.hadSuperClass),this.pushClassMethod(t,n,!1,!1,s,a)}else if(this.isClassProperty())I?this.pushClassPrivateProperty(t,r):this.pushClassProperty(t,a);else if(d&&"async"===u.name&&!this.isLineTerminator()){this.resetPreviousNodeTrailingComments(u);const e=this.eat(55);c.optional&&this.unexpected(p),h.kind="method";const i=this.match(138);this.parseClassElementName(h),this.parsePostMemberNameModifiers(c),i?this.pushClassPrivateMethod(t,o,e,!0):(this.isNonstaticConstructor(n)&&this.raise(L.ConstructorIsAsync,n.key),this.pushClassMethod(t,n,e,!0,!1,!1))}else if(!d||"get"!==u.name&&"set"!==u.name||this.match(55)&&this.isLineTerminator())if(d&&"accessor"===u.name&&!this.isLineTerminator()){this.expectPlugin("decoratorAutoAccessors"),this.resetPreviousNodeTrailingComments(u);const e=this.match(138);this.parseClassElementName(a),this.pushClassAccessorProperty(t,l,e)}else this.isLineTerminator()?I?this.pushClassPrivateProperty(t,r):this.pushClassProperty(t,a):this.unexpected();else{this.resetPreviousNodeTrailingComments(u),h.kind=u.name;const e=this.match(138);this.parseClassElementName(n),e?this.pushClassPrivateMethod(t,o,!1,!1):(this.isNonstaticConstructor(n)&&this.raise(L.ConstructorIsAccessor,n.key),this.pushClassMethod(t,n,!1,!1,!1,!1)),this.checkGetterSetterParams(n)}}parseClassElementName(t){const{type:e,value:i}=this.state;if(132!==e&&133!==e||!t.static||"prototype"!==i||this.raise(L.StaticPrototype,this.state.startLoc),138===e){"constructor"===i&&this.raise(L.ConstructorClassPrivateField,this.state.startLoc);const e=this.parsePrivateName();return t.key=e,e}return this.parsePropertyName(t)}parseClassStaticBlock(t,e){var i;this.scope.enter(208);const s=this.state.labels;this.state.labels=[],this.prodParam.enter(0);const n=e.body=[];this.parseBlockOrModuleBlockBody(n,void 0,!1,8),this.prodParam.exit(),this.scope.exit(),this.state.labels=s,t.body.push(this.finishNode(e,"StaticBlock")),null!=(i=e.decorators)&&i.length&&this.raise(L.DecoratorStaticBlock,e)}pushClassProperty(t,e){e.computed||"constructor"!==e.key.name&&"constructor"!==e.key.value||this.raise(L.ConstructorClassField,e.key),t.body.push(this.parseClassProperty(e))}pushClassPrivateProperty(t,e){const i=this.parseClassPrivateProperty(e);t.body.push(i),this.classScope.declarePrivateName(this.getPrivateNameSV(i.key),0,i.key.loc.start)}pushClassAccessorProperty(t,e,i){if(!i&&!e.computed){const t=e.key;"constructor"!==t.name&&"constructor"!==t.value||this.raise(L.ConstructorClassField,t)}const s=this.parseClassAccessorProperty(e);t.body.push(s),i&&this.classScope.declarePrivateName(this.getPrivateNameSV(s.key),0,s.key.loc.start)}pushClassMethod(t,e,i,s,n,o){t.body.push(this.parseMethod(e,i,s,n,o,"ClassMethod",!0))}pushClassPrivateMethod(t,e,i,s){const n=this.parseMethod(e,i,s,!1,!1,"ClassPrivateMethod",!0);t.body.push(n);const o="get"===n.kind?n.static?6:2:"set"===n.kind?n.static?5:1:0;this.declareClassPrivateMethodInScope(n,o)}declareClassPrivateMethodInScope(t,e){this.classScope.declarePrivateName(this.getPrivateNameSV(t.key),e,t.key.loc.start)}parsePostMemberNameModifiers(t){}parseClassPrivateProperty(t){return this.parseInitializer(t),this.semicolon(),this.finishNode(t,"ClassPrivateProperty")}parseClassProperty(t){return this.parseInitializer(t),this.semicolon(),this.finishNode(t,"ClassProperty")}parseClassAccessorProperty(t){return this.parseInitializer(t),this.semicolon(),this.finishNode(t,"ClassAccessorProperty")}parseInitializer(t){this.scope.enter(80),this.expressionScope.enter(qt()),this.prodParam.enter(0),t.value=this.eat(29)?this.parseMaybeAssignAllowIn():null,this.expressionScope.exit(),this.prodParam.exit(),this.scope.exit()}parseClassId(t,e,i,s=8331){if(X(this.state.type))t.id=this.parseIdentifier(),e&&this.declareNameFromIdentifier(t.id,s);else{if(!i&&e)throw this.raise(L.MissingClassName,this.state.startLoc);t.id=null}}parseClassSuper(t){t.superClass=this.eat(81)?this.parseExprSubscripts():null}parseExport(t,e){const i=this.parseMaybeImportPhase(t,!0),s=this.maybeParseExportDefaultSpecifier(t,i),n=!s||this.eat(12),o=n&&this.eatExportStar(t),a=o&&this.maybeParseExportNamespaceSpecifier(t),r=n&&(!a||this.eat(12)),l=s||o;if(o&&!a){if(s&&this.unexpected(),e)throw this.raise(L.UnsupportedDecoratorExport,t);return this.parseExportFrom(t,!0),this.finishNode(t,"ExportAllDeclaration")}const h=this.maybeParseExportNamedSpecifiers(t);let c;if(s&&n&&!o&&!h&&this.unexpected(null,5),a&&r&&this.unexpected(null,98),l||h){if(c=!1,e)throw this.raise(L.UnsupportedDecoratorExport,t);this.parseExportFrom(t,l)}else c=this.maybeParseExportDeclaration(t);if(l||h||c){var d;const i=t;if(this.checkExport(i,!0,!1,!!i.source),"ClassDeclaration"===(null==(d=i.declaration)?void 0:d.type))this.maybeTakeDecorators(e,i.declaration,i);else if(e)throw this.raise(L.UnsupportedDecoratorExport,t);return this.finishNode(i,"ExportNamedDeclaration")}if(this.eat(65)){const i=t,s=this.parseExportDefaultExpression();if(i.declaration=s,"ClassDeclaration"===s.type)this.maybeTakeDecorators(e,s,i);else if(e)throw this.raise(L.UnsupportedDecoratorExport,t);return this.checkExport(i,!0,!0),this.finishNode(i,"ExportDefaultDeclaration")}this.unexpected(null,5)}eatExportStar(t){return this.eat(55)}maybeParseExportDefaultSpecifier(t,e){if(e||this.isExportDefaultSpecifier()){this.expectPlugin("exportDefaultFrom",null==e?void 0:e.loc.start);const i=e||this.parseIdentifier(!0),s=this.startNodeAtNode(i);return s.exported=i,t.specifiers=[this.finishNode(s,"ExportDefaultSpecifier")],!0}return!1}maybeParseExportNamespaceSpecifier(t){if(this.isContextual(93)){t.specifiers||(t.specifiers=[]);const e=this.startNodeAt(this.state.lastTokStartLoc);return this.next(),e.exported=this.parseModuleExportName(),t.specifiers.push(this.finishNode(e,"ExportNamespaceSpecifier")),!0}return!1}maybeParseExportNamedSpecifiers(t){if(this.match(5)){t.specifiers||(t.specifiers=[]);const e="type"===t.exportKind;return t.specifiers.push(...this.parseExportSpecifiers(e)),t.source=null,t.declaration=null,this.hasPlugin("importAssertions")&&(t.assertions=[]),!0}return!1}maybeParseExportDeclaration(t){return!!this.shouldParseExportDeclaration()&&(t.specifiers=[],t.source=null,this.hasPlugin("importAssertions")&&(t.assertions=[]),t.declaration=this.parseExportDeclaration(t),!0)}isAsyncFunction(){if(!this.isContextual(95))return!1;const t=this.nextTokenInLineStart();return this.isUnparsedContextual(t,"function")}parseExportDefaultExpression(){const t=this.startNode();if(this.match(68))return this.next(),this.parseFunction(t,5);if(this.isAsyncFunction())return this.next(),this.next(),this.parseFunction(t,13);if(this.match(80))return this.parseClass(t,!0,!0);if(this.match(26))return this.hasPlugin("decorators")&&!0===this.getPluginOption("decorators","decoratorsBeforeExport")&&this.raise(L.DecoratorBeforeExport,this.state.startLoc),this.parseClass(this.maybeTakeDecorators(this.parseDecorators(!1),this.startNode()),!0,!0);if(this.match(75)||this.match(74)||this.isLet())throw this.raise(L.UnsupportedDefaultExport,this.state.startLoc);const e=this.parseMaybeAssignAllowIn();return this.semicolon(),e}parseExportDeclaration(t){return this.match(80)?this.parseClass(this.startNode(),!0,!1):this.parseStatementListItem()}isExportDefaultSpecifier(){const{type:t}=this.state;if(X(t)){if(95===t&&!this.state.containsEsc||100===t)return!1;if((130===t||129===t)&&!this.state.containsEsc){const{type:t}=this.lookahead();if(X(t)&&98!==t||5===t)return this.expectOnePlugin(["flow","typescript"]),!1}}else if(!this.match(65))return!1;const e=this.nextTokenStart(),i=this.isUnparsedContextual(e,"from");if(44===this.input.charCodeAt(e)||X(this.state.type)&&i)return!0;if(this.match(65)&&i){const t=this.input.charCodeAt(this.nextTokenStartSince(e+4));return 34===t||39===t}return!1}parseExportFrom(t,e){this.eatContextual(98)?(t.source=this.parseImportSource(),this.checkExport(t),this.maybeParseImportAttributes(t),this.checkJSONModuleImport(t)):e&&this.unexpected(),this.semicolon()}shouldParseExportDeclaration(){const{type:t}=this.state;return 26===t&&(this.expectOnePlugin(["decorators","decorators-legacy"]),this.hasPlugin("decorators"))?(!0===this.getPluginOption("decorators","decoratorsBeforeExport")&&this.raise(L.DecoratorBeforeExport,this.state.startLoc),!0):74===t||75===t||68===t||80===t||this.isLet()||this.isAsyncFunction()}checkExport(t,e,i,s){var n;if(e)if(i){if(this.checkDuplicateExports(t,"default"),this.hasPlugin("exportDefaultFrom")){var o;const e=t.declaration;"Identifier"!==e.type||"from"!==e.name||e.end-e.start!=4||null!=(o=e.extra)&&o.parenthesized||this.raise(L.ExportDefaultFromAsIdentifier,e)}}else if(null!=(n=t.specifiers)&&n.length)for(const e of t.specifiers){const{exported:t}=e,i="Identifier"===t.type?t.name:t.value;if(this.checkDuplicateExports(e,i),!s&&e.local){const{local:t}=e;"Identifier"!==t.type?this.raise(L.ExportBindingIsString,e,{localName:t.value,exportName:i}):(this.checkReservedWord(t.name,t.loc.start,!0,!1),this.scope.checkLocalExport(t))}}else if(t.declaration)if("FunctionDeclaration"===t.declaration.type||"ClassDeclaration"===t.declaration.type){const e=t.declaration.id;if(!e)throw new Error("Assertion failure");this.checkDuplicateExports(t,e.name)}else if("VariableDeclaration"===t.declaration.type)for(const e of t.declaration.declarations)this.checkDeclaration(e.id)}checkDeclaration(t){if("Identifier"===t.type)this.checkDuplicateExports(t,t.name);else if("ObjectPattern"===t.type)for(const e of t.properties)this.checkDeclaration(e);else if("ArrayPattern"===t.type)for(const e of t.elements)e&&this.checkDeclaration(e);else"ObjectProperty"===t.type?this.checkDeclaration(t.value):"RestElement"===t.type?this.checkDeclaration(t.argument):"AssignmentPattern"===t.type&&this.checkDeclaration(t.left)}checkDuplicateExports(t,e){this.exportedIdentifiers.has(e)&&("default"===e?this.raise(L.DuplicateDefaultExport,t):this.raise(L.DuplicateExport,t,{exportName:e})),this.exportedIdentifiers.add(e)}parseExportSpecifiers(t){const e=[];let i=!0;for(this.expect(5);!this.eat(8);){if(i)i=!1;else if(this.expect(12),this.eat(8))break;const s=this.isContextual(130),n=this.match(133),o=this.startNode();o.local=this.parseModuleExportName(),e.push(this.parseExportSpecifier(o,n,t,s))}return e}parseExportSpecifier(t,e,i,s){return this.eatContextual(93)?t.exported=this.parseModuleExportName():e?t.exported=function(t){const{type:e,start:i,end:s,loc:n,range:o,extra:a}=t;if("Placeholder"===e)return function(t){return ne(t)}(t);const r=Object.create(se);return r.type=e,r.start=i,r.end=s,r.loc=n,r.range=o,void 0!==t.raw?r.raw=t.raw:r.extra=a,r.value=t.value,r}(t.local):t.exported||(t.exported=ne(t.local)),this.finishNode(t,"ExportSpecifier")}parseModuleExportName(){if(this.match(133)){const t=this.parseStringLiteral(this.state.value),e=t.value.match(ke);return e&&this.raise(L.ModuleExportNameHasLoneSurrogate,t,{surrogateCharCode:e[0].charCodeAt(0)}),t}return this.parseIdentifier(!0)}isJSONModuleImport(t){return null!=t.assertions&&t.assertions.some((({key:t,value:e})=>"json"===e.value&&("Identifier"===t.type?"type"===t.name:"type"===t.value)))}checkImportReflection(t){const{specifiers:e}=t,i=1===e.length?e[0].type:null;if("source"===t.phase)"ImportDefaultSpecifier"!==i&&this.raise(L.SourcePhaseImportRequiresDefault,e[0].loc.start);else if("defer"===t.phase)"ImportNamespaceSpecifier"!==i&&this.raise(L.DeferImportRequiresNamespace,e[0].loc.start);else if(t.module){var s;"ImportDefaultSpecifier"!==i&&this.raise(L.ImportReflectionNotBinding,e[0].loc.start),(null==(s=t.assertions)?void 0:s.length)>0&&this.raise(L.ImportReflectionHasAssertion,e[0].loc.start)}}checkJSONModuleImport(t){if(this.isJSONModuleImport(t)&&"ExportAllDeclaration"!==t.type){const{specifiers:e}=t;if(null!=e){const t=e.find((t=>{let e;if("ExportSpecifier"===t.type?e=t.local:"ImportSpecifier"===t.type&&(e=t.imported),void 0!==e)return"Identifier"===e.type?"default"!==e.name:"default"!==e.value}));void 0!==t&&this.raise(L.ImportJSONBindingNotDefault,t.loc.start)}}}isPotentialImportPhase(t){return!t&&(this.isContextual(105)||this.isContextual(97)||this.isContextual(127))}applyImportPhase(t,e,i,s){e||("module"===i?(this.expectPlugin("importReflection",s),t.module=!0):this.hasPlugin("importReflection")&&(t.module=!1),"source"===i?(this.expectPlugin("sourcePhaseImports",s),t.phase="source"):"defer"===i?(this.expectPlugin("deferredImportEvaluation",s),t.phase="defer"):this.hasPlugin("sourcePhaseImports")&&(t.phase=null))}parseMaybeImportPhase(t,e){if(!this.isPotentialImportPhase(e))return this.applyImportPhase(t,e,null),null;const i=this.parseIdentifier(!0),{type:s}=this.state;return(E(s)?98!==s||102===this.lookaheadCharCode():12!==s)?(this.resetPreviousIdentifierLeadingComments(i),this.applyImportPhase(t,e,i.name,i.loc.start),null):(this.applyImportPhase(t,e,null),i)}isPrecedingIdImportPhase(t){const{type:e}=this.state;return X(e)?98!==e||102===this.lookaheadCharCode():12!==e}parseImport(t){return this.match(133)?this.parseImportSourceAndAttributes(t):this.parseImportSpecifiersAndAfter(t,this.parseMaybeImportPhase(t,!1))}parseImportSpecifiersAndAfter(t,e){t.specifiers=[];const i=!this.maybeParseDefaultImportSpecifier(t,e)||this.eat(12),s=i&&this.maybeParseStarImportSpecifier(t);return i&&!s&&this.parseNamedImportSpecifiers(t),this.expectContextual(98),this.parseImportSourceAndAttributes(t)}parseImportSourceAndAttributes(t){return null!=t.specifiers||(t.specifiers=[]),t.source=this.parseImportSource(),this.maybeParseImportAttributes(t),this.checkImportReflection(t),this.checkJSONModuleImport(t),this.semicolon(),this.finishNode(t,"ImportDeclaration")}parseImportSource(){return this.match(133)||this.unexpected(),this.parseExprAtom()}parseImportSpecifierLocal(t,e,i){e.local=this.parseIdentifier(),t.specifiers.push(this.finishImportSpecifier(e,i))}finishImportSpecifier(t,e,i=8201){return this.checkLVal(t.local,{in:{type:e},binding:i}),this.finishNode(t,e)}parseImportAttributes(){this.expect(5);const t=[],e=new Set;do{if(this.match(8))break;const i=this.startNode(),s=this.state.value;if(e.has(s)&&this.raise(L.ModuleAttributesWithDuplicateKeys,this.state.startLoc,{key:s}),e.add(s),this.match(133)?i.key=this.parseStringLiteral(s):i.key=this.parseIdentifier(!0),this.expect(14),!this.match(133))throw this.raise(L.ModuleAttributeInvalidValue,this.state.startLoc);i.value=this.parseStringLiteral(this.state.value),t.push(this.finishNode(i,"ImportAttribute"))}while(this.eat(12));return this.expect(8),t}parseModuleAttributes(){const t=[],e=new Set;do{const i=this.startNode();if(i.key=this.parseIdentifier(!0),"type"!==i.key.name&&this.raise(L.ModuleAttributeDifferentFromType,i.key),e.has(i.key.name)&&this.raise(L.ModuleAttributesWithDuplicateKeys,i.key,{key:i.key.name}),e.add(i.key.name),this.expect(14),!this.match(133))throw this.raise(L.ModuleAttributeInvalidValue,this.state.startLoc);i.value=this.parseStringLiteral(this.state.value),t.push(this.finishNode(i,"ImportAttribute"))}while(this.eat(12));return t}maybeParseImportAttributes(t){let e,i=!1;if(this.match(76)){if(this.hasPrecedingLineBreak()&&40===this.lookaheadCharCode())return;this.next(),this.hasPlugin("moduleAttributes")?e=this.parseModuleAttributes():(this.expectImportAttributesPlugin(),e=this.parseImportAttributes()),i=!0}else if(this.isContextual(94)&&!this.hasPrecedingLineBreak())this.hasPlugin("importAttributes")?(!0!==this.getPluginOption("importAttributes","deprecatedAssertSyntax")&&this.raise(L.ImportAttributesUseAssert,this.state.startLoc),this.addExtra(t,"deprecatedAssertSyntax",!0)):this.expectOnePlugin(["importAttributes","importAssertions"]),this.next(),e=this.parseImportAttributes();else if(this.hasPlugin("importAttributes")||this.hasPlugin("importAssertions"))e=[];else{if(!this.hasPlugin("moduleAttributes"))return;e=[]}!i&&this.hasPlugin("importAssertions")?t.assertions=e:t.attributes=e}maybeParseDefaultImportSpecifier(t,e){if(e){const i=this.startNodeAtNode(e);return i.local=e,t.specifiers.push(this.finishImportSpecifier(i,"ImportDefaultSpecifier")),!0}return!!E(this.state.type)&&(this.parseImportSpecifierLocal(t,this.startNode(),"ImportDefaultSpecifier"),!0)}maybeParseStarImportSpecifier(t){if(this.match(55)){const e=this.startNode();return this.next(),this.expectContextual(93),this.parseImportSpecifierLocal(t,e,"ImportNamespaceSpecifier"),!0}return!1}parseNamedImportSpecifiers(t){let e=!0;for(this.expect(5);!this.eat(8);){if(e)e=!1;else{if(this.eat(14))throw this.raise(L.DestructureNamedImport,this.state.startLoc);if(this.expect(12),this.eat(8))break}const i=this.startNode(),s=this.match(133),n=this.isContextual(130);i.imported=this.parseModuleExportName();const o=this.parseImportSpecifier(i,s,"type"===t.importKind||"typeof"===t.importKind,n,void 0);t.specifiers.push(o)}}parseImportSpecifier(t,e,i,s,n){if(this.eatContextual(93))t.local=this.parseIdentifier();else{const{imported:i}=t;if(e)throw this.raise(L.ImportBindingIsString,t,{importName:i.value});this.checkReservedWord(i.name,t.loc.start,!0,!0),t.local||(t.local=ne(i))}return this.finishImportSpecifier(t,"ImportSpecifier",n)}isThisParam(t){return"Identifier"===t.type&&"this"===t.name}}class Je extends Fe{constructor(t,e){super(t=function(t){if(null==t)return Object.assign({},Se);if(null!=t.annexB&&!1!==t.annexB)throw new Error("The `annexB` option can only be set to `false`.");const e={};for(const s of Object.keys(Se)){var i;e[s]=null!=(i=t[s])?i:Se[s]}return e}(t),e),this.options=t,this.initializeScopes(),this.plugins=function(t){const e=new Map;for(const i of t){const[t,s]=Array.isArray(i)?i:[i,{}];e.has(t)||e.set(t,s||{})}return e}(this.options.plugins),this.filename=t.sourceFilename}getScopeHandler(){return yt}parse(){this.enterInitialScopes();const t=this.startNode(),e=this.startNode();return this.nextToken(),t.errors=null,this.parseTopLevel(t,e),t.errors=this.state.errors,t.comments.length=this.state.commentsLen,t}}!function(t){const e={};for(const i of Object.keys(t))e[i]=$(t[i])}(J);function Xe(t,e){let i=Je;return null!=t&&t.plugins&&(function(t){if(Ne(t,"decorators")){if(Ne(t,"decorators-legacy"))throw new Error("Cannot use the decorators and decorators-legacy plugin together");const e=xe(t,"decorators","decoratorsBeforeExport");if(null!=e&&"boolean"!=typeof e)throw new Error("'decoratorsBeforeExport' must be a boolean, if specified.");const i=xe(t,"decorators","allowCallParenthesized");if(null!=i&&"boolean"!=typeof i)throw new Error("'allowCallParenthesized' must be a boolean.")}if(Ne(t,"flow")&&Ne(t,"typescript"))throw new Error("Cannot combine flow and typescript plugins.");if(Ne(t,"placeholders")&&Ne(t,"v8intrinsic"))throw new Error("Cannot combine placeholders and v8intrinsic plugins.");if(Ne(t,"pipelineOperator")){const e=xe(t,"pipelineOperator","proposal");if(!Ye.includes(e)){const t=Ye.map((t=>`"${t}"`)).join(", ");throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${t}.`)}const i=Ne(t,["recordAndTuple",{syntaxType:"hash"}]);if("hack"===e){if(Ne(t,"placeholders"))throw new Error("Cannot combine placeholders plugin and Hack-style pipes.");if(Ne(t,"v8intrinsic"))throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");const e=xe(t,"pipelineOperator","topicToken");if(!Re.includes(e)){const t=Re.map((t=>`"${t}"`)).join(", ");throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${t}.`)}if("#"===e&&i)throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "hack", topicToken: "#" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.')}else if("smart"===e&&i)throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "smart" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.')}if(Ne(t,"moduleAttributes")){if(Ne(t,"importAssertions")||Ne(t,"importAttributes"))throw new Error("Cannot combine importAssertions, importAttributes and moduleAttributes plugins.");if("may-2020"!==xe(t,"moduleAttributes","version"))throw new Error("The 'moduleAttributes' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is 'may-2020'.")}if(Ne(t,"importAssertions")&&Ne(t,"importAttributes"))throw new Error("Cannot combine importAssertions and importAttributes plugins.");if(Ne(t,"recordAndTuple")&&null!=xe(t,"recordAndTuple","syntaxType")&&!He.includes(xe(t,"recordAndTuple","syntaxType")))throw new Error("The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: "+He.map((t=>`'${t}'`)).join(", "));if(Ne(t,"asyncDoExpressions")&&!Ne(t,"doExpressions")){const t=new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");throw t.missingPlugins="doExpressions",t}if(Ne(t,"optionalChainingAssign")&&"2023-07"!==xe(t,"optionalChainingAssign","version"))throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is '2023-07'.")}(t.plugins),i=function(t){const e=Ae.filter((e=>Ne(t,e))),i=e.join("/");let s=Ee[i];if(!s){s=Je;for(const t of e)s=ge[t](s);Ee[i]=s}return s}(t.plugins)),new i(t,e)}const Ee={};e.K0=function(t,e){var i;if("unambiguous"!==(null==(i=e)?void 0:i.sourceType))return Xe(e,t).parse();e=Object.assign({},e);try{e.sourceType="module";const i=Xe(e,t),s=i.parse();if(i.sawUnambiguousESM)return s;if(i.ambiguousScriptDifferentAst)try{return e.sourceType="script",Xe(e,t).parse()}catch(t){}else s.program.sourceType="script";return s}catch(i){try{return e.sourceType="script",Xe(e,t).parse()}catch(t){}throw i}}}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var o=e[s]={exports:{}};return t[s](o,o.exports,i),o.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t={};i.r(t),i.d(t,{Decoder:()=>wt,Encoder:()=>Mt,PacketType:()=>Lt,protocol:()=>yt});const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=new Uint8Array(new ArrayBuffer(256));for(let t=0;t<64;t++)s[e.charCodeAt(t)]=t;const n={encode:function(t){let i="",s="";const n=new Uint8Array(t);for(let t=0;t>18&63]+e[s>>12&63]+e[s>>6&63]+e[63&s]}const o=n.length%3;return 1===o?(s="==",i=i.slice(0,-2)):2===o&&(s="=",i=i.slice(0,-1)),i+s},decode:function(t){let e=0;t.endsWith("==")?e=2:t.endsWith("=")&&(e=1);const i=.75*t.length-e,n=new ArrayBuffer(i),o=new Uint8Array(n);let a=0;for(let e=0;e>16&255,o[a++]=i>>8&255,o[a++]=255&i}return n}};Object.setPrototypeOf(n,null),Object.freeze(n);const o=n,a={encode:function(t){const e=Array.from(t).map((t=>t.codePointAt(0)||0)),i=[];for(const t of e)t<=127?i.push(t):t<=2047?(i.push(t>>6|192),i.push(63&t|128)):t<=65535?(i.push(t>>12|224),i.push(t>>6&63|128),i.push(63&t|128)):t<=1114111&&(i.push(t>>18|240),i.push(t>>12&63|128),i.push(t>>6&63|128),i.push(63&t|128));return new Uint8Array(i).buffer},decode:function(t){const e=new Uint8Array(t);let i="",s=0;for(;s{c[h[t]]=t}));const d={type:"error",data:"parser error"},I="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),u="function"==typeof ArrayBuffer,p=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,b=({type:t,data:e},i,s)=>I&&e instanceof Blob?i?s(e):m(e,s):u&&(e instanceof ArrayBuffer||p(e))?i?s(e):m(new Blob([e]),s):s(h[t]+(e||"")),m=(t,e)=>{const i=new FileReader;return i.onload=function(){const t=i.result.split(",")[1];e("b"+(t||""))},i.readAsDataURL(t)};function y(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let L;const M="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)M["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t)]=t;const W="function"==typeof ArrayBuffer,w=(t,e)=>{if("string"!=typeof t)return{type:"message",data:j(t,e)};const i=t.charAt(0);return"b"===i?{type:"message",data:v(t.substring(1),e)}:c[i]?t.length>1?{type:c[i],data:t.substring(1)}:{type:c[i]}:d},v=(t,e)=>{if(W){const i=(t=>{let e,i,s,n,o,a=.75*t.length,r=t.length,l=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);const h=new ArrayBuffer(a),c=new Uint8Array(h);for(e=0;e>4,c[l++]=(15&s)<<4|n>>2,c[l++]=(3&n)<<6|63&o;return h})(t);return j(i,e)}return{base64:!0,data:t}},j=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,Z=String.fromCharCode(30);let C;function G(t){return t.reduce(((t,e)=>t+e.length),0)}function f(t,e){if(t[0].length===e)return t.shift();const i=new Uint8Array(e);let s=0;for(let n=0;n(t.hasOwnProperty(i)&&(e[i]=t[i]),e)),{})}const R=x.setTimeout,H=x.clearTimeout;function g(t,e){e.useNativeTimers?(t.setTimeoutFn=R.bind(x),t.clearTimeoutFn=H.bind(x)):(t.setTimeoutFn=x.setTimeout.bind(x),t.clearTimeoutFn=x.clearTimeout.bind(x))}class A extends Error{constructor(t,e,i){super(t),this.description=e,this.context=i,this.type="TransportError"}}class S extends N{constructor(t){super(),this.writable=!1,g(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,i){return super.emitReserved("error",new A(t,e,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=w(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(t){const e=function(t){let e="";for(let i in t)t.hasOwnProperty(i)&&(e.length&&(e+="&"),e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i]));return e}(t);return e.length?"?"+e:""}}const z="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),V=64,T={};let k,O=0,F=0;function J(t){let e="";do{e=z[t%V]+e,t=Math.floor(t/V)}while(t>0);return e}function X(){const t=J(+new Date);return t!==k?(O=0,k=t):t+"."+J(O++)}for(;F{var t;3===i.readyState&&(null===(t=this.opts.cookieJar)||void 0===t||t.parseCookies(i)),4===i.readyState&&(200===i.status||1223===i.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof i.status?i.status:0)}),0))},i.send(this.data)}catch(t){return void this.setTimeoutFn((()=>{this.onError(t)}),0)}"undefined"!=typeof document&&(this.index=_.requestsCount++,_.requests[this.index]=this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=B,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete _.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}function Q(){for(let t in _.requests)_.requests.hasOwnProperty(t)&&_.requests[t].abort()}_.requestsCount=0,_.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",Q):"function"==typeof addEventListener&&addEventListener("onpagehide"in x?"pagehide":"unload",Q,!1));const q="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),$=x.WebSocket||x.MozWebSocket,K="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),tt={websocket:class extends S{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),e=this.opts.protocols,i=K?{}:Y(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=K?new $(t,e,i):e?new $(t,e):new $(t)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e{try{this.ws.send(t)}catch(t){}s&&q((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=X()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}check(){return!!$}},webtransport:class extends S{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((t=>{this.onError("webtransport error",t)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((t=>{const e=function(t,e){C||(C=new TextDecoder);const i=[];let s=0,n=-1,o=!1;return new TransformStream({transform(a,r){for(i.push(a);;){if(0===s){if(G(i)<1)break;const t=f(i,1);o=128==(128&t[0]),n=127&t[0],s=n<126?3:126===n?1:2}else if(1===s){if(G(i)<2)break;const t=f(i,2);n=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),s=3}else if(2===s){if(G(i)<8)break;const t=f(i,8),e=new DataView(t.buffer,t.byteOffset,t.length),o=e.getUint32(0);if(o>Math.pow(2,21)-1){r.enqueue(d);break}n=o*Math.pow(2,32)+e.getUint32(4),s=3}else{if(G(i)t){r.enqueue(d);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=t.readable.pipeThrough(e).getReader(),s=new TransformStream({transform(t,e){!function(t,e){I&&t.data instanceof Blob?t.data.arrayBuffer().then(y).then(e):u&&(t.data instanceof ArrayBuffer||p(t.data))?e(y(t.data)):b(t,!1,(t=>{L||(L=new TextEncoder),e(L.encode(t))}))}(t,(i=>{const s=i.length;let n;if(s<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,s);else if(s<65536){n=new Uint8Array(3);const t=new DataView(n.buffer);t.setUint8(0,126),t.setUint16(1,s)}else{n=new Uint8Array(9);const t=new DataView(n.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(s))}t.data&&"string"!=typeof t.data&&(n[0]|=128),e.enqueue(n),e.enqueue(i)}))}});s.readable.pipeTo(t.writable),this.writer=s.writable.getWriter();const n=()=>{i.read().then((({done:t,value:e})=>{t||(this.onPacket(e),n())})).catch((t=>{}))};n();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then((()=>this.onOpen()))}))})))}write(t){this.writable=!1;for(let e=0;e{s&&q((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this.transport)||void 0===t||t.close()}},polling:class extends S{constructor(t){if(super(t),this.polling=!1,"undefined"!=typeof location){const e="https:"===location.protocol;let i=location.port;i||(i=e?"443":"80"),this.xd="undefined"!=typeof location&&t.hostname!==location.hostname||i!==t.port}const e=t&&t.forceBase64;this.supportsBinary=P&&!e,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this.polling||!this.writable){let t=0;this.polling&&(t++,this.once("pollComplete",(function(){--t||e()}))),this.writable||(t++,this.once("drain",(function(){--t||e()})))}else e()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){((t,e)=>{const i=t.split(Z),s=[];for(let t=0;t{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const t=()=>{this.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}write(t){this.writable=!1,((t,e)=>{const i=t.length,s=new Array(i);let n=0;t.forEach(((t,o)=>{b(t,!1,(t=>{s[o]=t,++n===i&&e(s.join(Z))}))}))})(t,(t=>{this.doWrite(t,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=X()),this.supportsBinary||e.sid||(e.b64=1),this.createUri(t,e)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new _(this.uri(),t)}doWrite(t,e){const i=this.request({method:"POST",data:t});i.on("success",e),i.on("error",((t,e)=>{this.onError("xhr post error",t,e)}))}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",((t,e)=>{this.onError("xhr poll error",t,e)})),this.pollXhr=t}}},et=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,it=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function st(t){if(t.length>2e3)throw"URI too long";const e=t,i=t.indexOf("["),s=t.indexOf("]");-1!=i&&-1!=s&&(t=t.substring(0,i)+t.substring(i,s).replace(/:/g,";")+t.substring(s,t.length));let n=et.exec(t||""),o={},a=14;for(;a--;)o[it[a]]=n[a]||"";return-1!=i&&-1!=s&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=function(t,e){const i=e.replace(/\/{2,9}/g,"/").split("/");return"/"!=e.slice(0,1)&&0!==e.length||i.splice(0,1),"/"==e.slice(-1)&&i.splice(i.length-1,1),i}(0,o.path),o.queryKey=function(t,e){const i={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,s){e&&(i[e]=s)})),i}(0,o.query),o}class nt extends N{constructor(t,e={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],t&&"object"==typeof t&&(e=t,t=null),t?(t=st(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=st(e.host).host),g(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=e.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(t){let e={},i=t.split("&");for(let t=0,s=i.length;t{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);const i=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new tt[t](i)}open(){let t;if(this.opts.rememberUpgrade&&nt.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(t=>this.onClose("transport close",t)))}probe(t){let e=this.createTransport(t),i=!1;nt.priorWebsocketSuccess=!1;const s=()=>{i||(e.send([{type:"ping",data:"probe"}]),e.once("packet",(t=>{if(!i)if("pong"===t.type&&"probe"===t.data){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;nt.priorWebsocketSuccess="websocket"===e.name,this.transport.pause((()=>{i||"closed"!==this.readyState&&(h(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())}))}else{const t=new Error("probe error");t.transport=e.name,this.emitReserved("upgradeError",t)}})))};function n(){i||(i=!0,h(),e.close(),e=null)}const o=t=>{const i=new Error("probe error: "+t);i.transport=e.name,n(),this.emitReserved("upgradeError",i)};function a(){o("transport closed")}function r(){o("socket closed")}function l(t){e&&t.name!==e.name&&n()}const h=()=>{e.removeListener("open",s),e.removeListener("error",o),e.removeListener("close",a),this.off("close",r),this.off("upgrading",l)};e.once("open",s),e.once("error",o),e.once("close",a),this.once("close",r),this.once("upgrading",l),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==t?this.setTimeoutFn((()=>{i||e.open()}),200):e.open()}onOpen(){if(this.readyState="open",nt.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let t=0;const e=this.upgrades.length;for(;t{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let i=0;i=57344?i+=3:(s++,i+=4);return i}(e):Math.ceil(1.33*(e.byteLength||e.size))),i>0&&t>this.maxPayload)return this.writeBuffer.slice(0,i);t+=2}var e;return this.writeBuffer}write(t,e,i){return this.sendPacket("message",t,e,i),this}send(t,e,i){return this.sendPacket("message",t,e,i),this}sendPacket(t,e,i,s){if("function"==typeof e&&(s=e,e=void 0),"function"==typeof i&&(s=i,i=null),"closing"===this.readyState||"closed"===this.readyState)return;(i=i||{}).compress=!1!==i.compress;const n={type:t,data:e,options:i};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),s&&this.once("flush",s),this.flush()}close(){const t=()=>{this.onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},i=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?i():t()})):this.upgrading?i():t()),this}onError(t){nt.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let i=0;const s=t.length;for(;i"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,rt=Object.prototype.toString,lt="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===rt.call(Blob),ht="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===rt.call(File);function ct(t){return ot&&(t instanceof ArrayBuffer||at(t))||lt&&t instanceof Blob||ht&&t instanceof File}function dt(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,i=t.length;e=0&&t.num{delete this.acks[t];for(let e=0;e{this.io.clearTimeoutFn(n),e.apply(this,[null,...t])}}emitWithAck(t,...e){const i=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((s,n)=>{e.push(((t,e)=>i?t?n(t):s(e):s(t))),this.emit(t,...e)}))}_addToQueue(t){let e;"function"==typeof t[t.length-1]&&(e=t.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push(((t,...s)=>{if(i===this._queue[0])return null!==t?i.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(t)):(this._queue.shift(),e&&e(null,...s)),i.pending=!1,this._drainQueue()})),this._queue.push(i),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||0===this._queue.length)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){"function"==typeof this.auth?this.auth((t=>{this._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:Lt.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e)}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case Lt.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Lt.EVENT:case Lt.BINARY_EVENT:this.onevent(t);break;case Lt.ACK:case Lt.BINARY_ACK:this.onack(t);break;case Lt.DISCONNECT:this.ondisconnect();break;case Lt.CONNECT_ERROR:this.destroy();const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){const e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const i of e)i.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&"string"==typeof t[t.length-1]&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let i=!1;return function(...s){i||(i=!0,e.packet({type:Lt.ACK,id:t,data:s}))}}onack(t){const e=this.acks[t.id];"function"==typeof e&&(e.apply(this,t.data),delete this.acks[t.id])}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((t=>this.emitEvent(t))),this.receiveBuffer=[],this.sendBuffer.forEach((t=>{this.notifyOutgoingListeners(t),this.packet(t)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((t=>t())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Lt.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let i=0;i0&&t.jitter<=1?t.jitter:0,this.attempts=0}Gt.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),i=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-i:t+i}return 0|Math.min(t,this.max)},Gt.prototype.reset=function(){this.attempts=0},Gt.prototype.setMin=function(t){this.ms=t},Gt.prototype.setMax=function(t){this.max=t},Gt.prototype.setJitter=function(t){this.jitter=t};class ft extends N{constructor(e,i){var s;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(i=e,e=void 0),(i=i||{}).path=i.path||"/socket.io",this.opts=i,g(this,i),this.reconnection(!1!==i.reconnection),this.reconnectionAttempts(i.reconnectionAttempts||1/0),this.reconnectionDelay(i.reconnectionDelay||1e3),this.reconnectionDelayMax(i.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(s=i.randomizationFactor)&&void 0!==s?s:.5),this.backoff=new Gt({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==i.timeout?2e4:i.timeout),this._readyState="closed",this.uri=e;const n=i.parser||t;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==i.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new nt(this.uri,this.opts);const e=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const s=jt(e,"open",(function(){i.onopen(),t&&t()})),n=e=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",e),t?t(e):this.maybeReconnectOnOpen()},o=jt(e,"error",n);if(!1!==this._timeout){const t=this._timeout,i=this.setTimeoutFn((()=>{s(),n(new Error("timeout")),e.close()}),t);this.opts.autoUnref&&i.unref(),this.subs.push((()=>{this.clearTimeoutFn(i)}))}return this.subs.push(s),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(jt(t,"ping",this.onping.bind(this)),jt(t,"data",this.ondata.bind(this)),jt(t,"error",this.onerror.bind(this)),jt(t,"close",this.onclose.bind(this)),jt(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}ondecoded(t){q((()=>{this.emitReserved("packet",t)}),this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let i=this.nsps[t];return i?this._autoConnect&&!i.active&&i.connect():(i=new Ct(this,t,e),this.nsps[t]=i),i}_destroy(t){const e=Object.keys(this.nsps);for(const t of e)if(this.nsps[t].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let i=0;it())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const i=this.setTimeoutFn((()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((e=>{e?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):t.onreconnect()})))}),e);this.opts.autoUnref&&i.unref(),this.subs.push((()=>{this.clearTimeoutFn(i)}))}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Nt={};function xt(t,e){"object"==typeof t&&(e=t,t=void 0);const i=function(t,e="",i){let s=t;i=i||"undefined"!=typeof location&&location,null==t&&(t=i.protocol+"//"+i.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?i.protocol+t:i.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==i?i.protocol+"//"+t:"https://"+t),s=st(t)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const n=-1!==s.host.indexOf(":")?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+n+":"+s.port+e,s.href=s.protocol+"://"+n+(i&&i.port===s.port?"":":"+s.port),s}(t,(e=e||{}).path||"/socket.io"),s=i.source,n=i.id,o=i.path,a=Nt[n]&&o in Nt[n].nsps;let r;return e.forceNew||e["force new connection"]||!1===e.multiplex||a?r=new ft(s,e):(Nt[n]||(Nt[n]=new ft(s,e)),r=Nt[n]),i.query&&!e.query&&(e.query=i.queryKey),r.socket(i.path,e)}Object.assign(xt,{Manager:ft,Socket:Ct,io:xt,connect:xt});const Yt=function(t,e){if(!t)throw Rt(e)},Rt=function(t){return new Error("Firebase Database (${JSCORE_VERSION}) INTERNAL ASSERT FAILED: "+t)},Ht=function(t){const e=[];let i=0;for(let s=0;s>6|192,e[i++]=63&n|128):55296==(64512&n)&&s+1>18|240,e[i++]=n>>12&63|128,e[i++]=n>>6&63|128,e[i++]=63&n|128):(e[i++]=n>>12|224,e[i++]=n>>6&63|128,e[i++]=63&n|128)}return e},gt={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const i=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,s=[];for(let e=0;e>2,c=(3&n)<<4|a>>4;let d=(15&a)<<2|l>>6,I=63&l;r||(I=64,o||(d=64)),s.push(i[h],i[c],i[d],i[I])}return s.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(Ht(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){const e=[];let i=0,s=0;for(;i191&&n<224){const o=t[i++];e[s++]=String.fromCharCode((31&n)<<6|63&o)}else if(n>239&&n<365){const o=((7&n)<<18|(63&t[i++])<<12|(63&t[i++])<<6|63&t[i++])-65536;e[s++]=String.fromCharCode(55296+(o>>10)),e[s++]=String.fromCharCode(56320+(1023&o))}else{const o=t[i++],a=t[i++];e[s++]=String.fromCharCode((15&n)<<12|(63&o)<<6|63&a)}}return e.join("")}(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const i=e?this.charToByteMapWebSafe_:this.charToByteMap_,s=[];for(let e=0;e>4;if(s.push(l),64!==a){const t=o<<4&240|a>>2;if(s.push(t),64!==r){const t=a<<6&192|r;s.push(t)}}}return s},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};class At extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const St=function(t){const e=Ht(t);return gt.encodeByteArray(e,!0)},zt=function(t){return St(t).replace(/\./g,"")},Vt=function(t){try{return gt.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null};function Tt(t){return kt(void 0,t)}function kt(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(const i in e)e.hasOwnProperty(i)&&"__proto__"!==i&&(t[i]=kt(t[i],e[i]));return t}const Ot=()=>{try{return function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==i.g)return i.g;throw new Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__||(()=>{if("undefined"==typeof process||void 0===process.env)return;const t=process.env.__FIREBASE_DEFAULTS__;return t?JSON.parse(t):void 0})()||(()=>{if("undefined"==typeof document)return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(t){return}const e=t&&Vt(t[1]);return e&&JSON.parse(e)})()}catch(t){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`)}},Ft=()=>{var t;return null===(t=Ot())||void 0===t?void 0:t.config};class Jt{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}wrapCallback(t){return(e,i)=>{e?this.reject(e):this.resolve(i),"function"==typeof t&&(this.promise.catch((()=>{})),1===t.length?t(e):t(e,i))}}}function Xt(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test("undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:"")}function Et(){try{return"object"==typeof indexedDB}catch(t){return!1}}function Dt(){return new Promise(((t,e)=>{try{let i=!0;const s="validate-browser-context-for-indexeddb-analytics-module",n=self.indexedDB.open(s);n.onsuccess=()=>{n.result.close(),i||self.indexedDB.deleteDatabase(s),t(!0)},n.onupgradeneeded=()=>{i=!1},n.onerror=()=>{var t;e((null===(t=n.error)||void 0===t?void 0:t.message)||"")}}catch(t){e(t)}}))}class Ut extends Error{constructor(t,e,i){super(e),this.code=t,this.customData=i,this.name="FirebaseError",Object.setPrototypeOf(this,Ut.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Bt.prototype.create)}}class Bt{constructor(t,e,i){this.service=t,this.serviceName=e,this.errors=i}create(t,...e){const i=e[0]||{},s=`${this.service}/${t}`,n=this.errors[t],o=n?function(t,e){return t.replace(Pt,((t,i)=>{const s=e[i];return null!=s?String(s):`<${i}?>`}))}(n,i):"Error",a=`${this.serviceName}: ${o} (${s}).`;return new Ut(s,a,i)}}const Pt=/\{\$([^}]+)}/g;function _t(t){return JSON.parse(t)}function Qt(t){return JSON.stringify(t)}const qt=function(t){let e={},i={},s={},n="";try{const o=t.split(".");e=_t(Vt(o[0])||""),i=_t(Vt(o[1])||""),n=o[2],s=i.d||{},delete i.d}catch(t){}return{header:e,claims:i,data:s,signature:n}};function $t(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Kt(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function te(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function ee(t,e,i){const s={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=e.call(i,t[n],n,t));return s}function ie(t,e){if(t===e)return!0;const i=Object.keys(t),s=Object.keys(e);for(const n of i){if(!s.includes(n))return!1;const i=t[n],o=e[n];if(se(i)&&se(o)){if(!ie(i,o))return!1}else if(i!==o)return!1}for(const t of s)if(!i.includes(t))return!1;return!0}function se(t){return null!==t&&"object"==typeof t}class ne{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(let t=1;t>>31)}let s,n,o=this.chain_[0],a=this.chain_[1],r=this.chain_[2],l=this.chain_[3],h=this.chain_[4];for(let t=0;t<80;t++){t<40?t<20?(s=l^a&(r^l),n=1518500249):(s=a^r^l,n=1859775393):t<60?(s=a&r|l&(a|r),n=2400959708):(s=a^r^l,n=3395469782);const e=(o<<5|o>>>27)+s+h+n+i[t]&4294967295;h=l,l=r,r=4294967295&(a<<30|a>>>2),a=o,o=e}this.chain_[0]=this.chain_[0]+o&4294967295,this.chain_[1]=this.chain_[1]+a&4294967295,this.chain_[2]=this.chain_[2]+r&4294967295,this.chain_[3]=this.chain_[3]+l&4294967295,this.chain_[4]=this.chain_[4]+h&4294967295}update(t,e){if(null==t)return;void 0===e&&(e=t.length);const i=e-this.blockSize;let s=0;const n=this.buf_;let o=this.inbuf_;for(;s=56;t--)this.buf_[t]=255&e,e/=256;this.compress_(this.buf_);let i=0;for(let e=0;e<5;e++)for(let s=24;s>=0;s-=8)t[i]=this.chain_[e]>>s&255,++i;return t}}function oe(t,e){return`${t} failed: ${e} argument `}const ae=function(t){let e=0;for(let i=0;i=55296&&s<=56319?(e+=4,i++):e+=3}return e},re=1e3,le=2,he=144e5,ce=.5;function de(t,e=re,i=le){const s=e*Math.pow(i,t),n=Math.round(ce*s*(Math.random()-.5)*2);return Math.min(he,s+n)}function Ie(t){return t&&t._delegate?t._delegate:t}class ue{constructor(t,e,i){this.name=t,this.instanceFactory=e,this.type=i,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}const pe="[DEFAULT]";class be{constructor(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){const t=new Jt;if(this.instancesDeferred.set(e,t),this.isInitialized(e)||this.shouldAutoInitialize())try{const i=this.getOrInitializeService({instanceIdentifier:e});i&&t.resolve(i)}catch(t){}}return this.instancesDeferred.get(e).promise}getImmediate(t){var e;const i=this.normalizeInstanceIdentifier(null==t?void 0:t.identifier),s=null!==(e=null==t?void 0:t.optional)&&void 0!==e&&e;if(!this.isInitialized(i)&&!this.shouldAutoInitialize()){if(s)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:i})}catch(t){if(s)return null;throw t}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,this.shouldAutoInitialize()){if(function(t){return"EAGER"===t.instantiationMode}(t))try{this.getOrInitializeService({instanceIdentifier:pe})}catch(t){}for(const[t,e]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(t);try{const t=this.getOrInitializeService({instanceIdentifier:i});e.resolve(t)}catch(t){}}}}clearInstance(t=pe){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter((t=>"INTERNAL"in t)).map((t=>t.INTERNAL.delete())),...t.filter((t=>"_delete"in t)).map((t=>t._delete()))])}isComponentSet(){return null!=this.component}isInitialized(t=pe){return this.instances.has(t)}getOptions(t=pe){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t,i=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(i))throw Error(`${this.name}(${i}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:i,options:e});for(const[t,e]of this.instancesDeferred.entries())i===this.normalizeInstanceIdentifier(t)&&e.resolve(s);return s}onInit(t,e){var i;const s=this.normalizeInstanceIdentifier(e),n=null!==(i=this.onInitCallbacks.get(s))&&void 0!==i?i:new Set;n.add(t),this.onInitCallbacks.set(s,n);const o=this.instances.get(s);return o&&t(o,s),()=>{n.delete(t)}}invokeOnInitCallbacks(t,e){const i=this.onInitCallbacks.get(e);if(i)for(const s of i)try{s(t,e)}catch(t){}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let i=this.instances.get(t);if(!i&&this.component&&(i=this.component.instanceFactory(this.container,{instanceIdentifier:(s=t,s===pe?void 0:s),options:e}),this.instances.set(t,i),this.instancesOptions.set(t,e),this.invokeOnInitCallbacks(i,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,i)}catch(t){}var s;return i||null}normalizeInstanceIdentifier(t=pe){return this.component?this.component.multipleInstances?t:pe:t}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class me{constructor(t){this.name=t,this.providers=new Map}addComponent(t){const e=this.getProvider(t.name);if(e.isComponentSet())throw new Error(`Component ${t.name} has already been registered with ${this.name}`);e.setComponent(t)}addOrOverwriteComponent(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)}getProvider(t){if(this.providers.has(t))return this.providers.get(t);const e=new be(t,this);return this.providers.set(t,e),e}getProviders(){return Array.from(this.providers.values())}}const ye=[];var Le;!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(Le||(Le={}));const Me={debug:Le.DEBUG,verbose:Le.VERBOSE,info:Le.INFO,warn:Le.WARN,error:Le.ERROR,silent:Le.SILENT},We=Le.INFO,we={[Le.DEBUG]:"log",[Le.VERBOSE]:"log",[Le.INFO]:"info",[Le.WARN]:"warn",[Le.ERROR]:"error"},ve=(t,e,...i)=>{if(ee.some((e=>t instanceof e));let Ce,Ge;const fe=new WeakMap,Ne=new WeakMap,xe=new WeakMap,Ye=new WeakMap,Re=new WeakMap;let He={get(t,e,i){if(t instanceof IDBTransaction){if("done"===e)return Ne.get(t);if("objectStoreNames"===e)return t.objectStoreNames||xe.get(t);if("store"===e)return i.objectStoreNames[1]?void 0:i.objectStore(i.objectStoreNames[0])}return Ae(t[e])},set:(t,e,i)=>(t[e]=i,!0),has:(t,e)=>t instanceof IDBTransaction&&("done"===e||"store"===e)||e in t};function ge(t){return"function"==typeof t?(e=t)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(Ge||(Ge=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Se(this),t),Ae(fe.get(this))}:function(...t){return Ae(e.apply(Se(this),t))}:function(t,...i){const s=e.call(Se(this),t,...i);return xe.set(s,t.sort?t.sort():[t]),Ae(s)}:(t instanceof IDBTransaction&&function(t){if(Ne.has(t))return;const e=new Promise(((e,i)=>{const s=()=>{t.removeEventListener("complete",n),t.removeEventListener("error",o),t.removeEventListener("abort",o)},n=()=>{e(),s()},o=()=>{i(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",n),t.addEventListener("error",o),t.addEventListener("abort",o)}));Ne.set(t,e)}(t),Ze(t,Ce||(Ce=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(t,He):t);var e}function Ae(t){if(t instanceof IDBRequest)return function(t){const e=new Promise(((e,i)=>{const s=()=>{t.removeEventListener("success",n),t.removeEventListener("error",o)},n=()=>{e(Ae(t.result)),s()},o=()=>{i(t.error),s()};t.addEventListener("success",n),t.addEventListener("error",o)}));return e.then((e=>{e instanceof IDBCursor&&fe.set(e,t)})).catch((()=>{})),Re.set(e,t),e}(t);if(Ye.has(t))return Ye.get(t);const e=ge(t);return e!==t&&(Ye.set(t,e),Re.set(e,t)),e}const Se=t=>Re.get(t);function ze(t,e,{blocked:i,upgrade:s,blocking:n,terminated:o}={}){const a=indexedDB.open(t,e),r=Ae(a);return s&&a.addEventListener("upgradeneeded",(t=>{s(Ae(a.result),t.oldVersion,t.newVersion,Ae(a.transaction),t)})),i&&a.addEventListener("blocked",(t=>i(t.oldVersion,t.newVersion,t))),r.then((t=>{o&&t.addEventListener("close",(()=>o())),n&&t.addEventListener("versionchange",(t=>n(t.oldVersion,t.newVersion,t)))})).catch((()=>{})),r}const Ve=["get","getKey","getAll","getAllKeys","count"],Te=["put","add","delete","clear"],ke=new Map;function Oe(t,e){if(!(t instanceof IDBDatabase)||e in t||"string"!=typeof e)return;if(ke.get(e))return ke.get(e);const i=e.replace(/FromIndex$/,""),s=e!==i,n=Te.includes(i);if(!(i in(s?IDBIndex:IDBObjectStore).prototype)||!n&&!Ve.includes(i))return;const o=async function(t,...e){const o=this.transaction(t,n?"readwrite":"readonly");let a=o.store;return s&&(a=a.index(e.shift())),(await Promise.all([a[i](...e),n&&o.done]))[0]};return ke.set(e,o),o}var Fe;Fe=He,He={...Fe,get:(t,e,i)=>Oe(t,e)||Fe.get(t,e,i),has:(t,e)=>!!Oe(t,e)||Fe.has(t,e)};class Je{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map((t=>{if(function(t){const e=t.getComponent();return"VERSION"===(null==e?void 0:e.type)}(t)){const e=t.getImmediate();return`${e.library}/${e.version}`}return null})).filter((t=>t)).join(" ")}}const Xe="@firebase/app",Ee="0.9.27",De=new je("@firebase/app"),Ue="[DEFAULT]",Be={[Xe]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","fire-js":"fire-js",firebase:"fire-js-all"},Pe=new Map,_e=new Map;function Qe(t,e){try{t.container.addComponent(e)}catch(i){De.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,i)}}function qe(t){const e=t.name;if(_e.has(e))return De.debug(`There were multiple attempts to register component ${e}.`),!1;_e.set(e,t);for(const e of Pe.values())Qe(e,t);return!0}function $e(t,e){const i=t.container.getProvider("heartbeat").getImmediate({optional:!0});return i&&i.triggerHeartbeat(),t.container.getProvider(e)}const Ke=new Bt("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}."});class ti{constructor(t,e,i){this._isDeleted=!1,this._options=Object.assign({},t),this._config=Object.assign({},e),this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=i,this.container.addComponent(new ue("app",(()=>this),"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw Ke.create("app-deleted",{appName:this._name})}}function ei(t,e={}){let i=t;"object"!=typeof e&&(e={name:e});const s=Object.assign({name:Ue,automaticDataCollectionEnabled:!1},e),n=s.name;if("string"!=typeof n||!n)throw Ke.create("bad-app-name",{appName:String(n)});if(i||(i=Ft()),!i)throw Ke.create("no-options");const o=Pe.get(n);if(o){if(ie(i,o.options)&&ie(s,o.config))return o;throw Ke.create("duplicate-app",{appName:n})}const a=new me(n);for(const t of _e.values())a.addComponent(t);const r=new ti(i,s,a);return Pe.set(n,r),r}function ii(t=Ue){const e=Pe.get(t);if(!e&&t===Ue&&Ft())return ei();if(!e)throw Ke.create("no-app",{appName:t});return e}function si(t,e,i){var s;let n=null!==(s=Be[t])&&void 0!==s?s:t;i&&(n+=`-${i}`);const o=n.match(/\s|\//),a=e.match(/\s|\//);if(o||a){const t=[`Unable to register library "${n}" with version "${e}":`];return o&&t.push(`library name "${n}" contains illegal characters (whitespace or "/")`),o&&a&&t.push("and"),a&&t.push(`version name "${e}" contains illegal characters (whitespace or "/")`),void De.warn(t.join(" "))}qe(new ue(`${n}-version`,(()=>({library:n,version:e})),"VERSION"))}const ni="firebase-heartbeat-database",oi=1,ai="firebase-heartbeat-store";let ri=null;function li(){return ri||(ri=ze(ni,oi,{upgrade:(t,e)=>{if(0===e)try{t.createObjectStore(ai)}catch(t){console.warn(t)}}}).catch((t=>{throw Ke.create("idb-open",{originalErrorMessage:t.message})}))),ri}async function hi(t,e){try{const i=(await li()).transaction(ai,"readwrite"),s=i.objectStore(ai);await s.put(e,ci(t)),await i.done}catch(t){if(t instanceof Ut)De.warn(t.message);else{const e=Ke.create("idb-set",{originalErrorMessage:null==t?void 0:t.message});De.warn(e.message)}}}function ci(t){return`${t.name}!${t.options.appId}`}class di{constructor(t){this.container=t,this._heartbeatsCache=null;const e=this.container.getProvider("app").getImmediate();this._storage=new ui(e),this._heartbeatsCachePromise=this._storage.read().then((t=>(this._heartbeatsCache=t,t)))}async triggerHeartbeat(){var t,e;const i=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),s=Ii();if((null!=(null===(t=this._heartbeatsCache)||void 0===t?void 0:t.heartbeats)||(this._heartbeatsCache=await this._heartbeatsCachePromise,null!=(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)))&&this._heartbeatsCache.lastSentHeartbeatDate!==s&&!this._heartbeatsCache.heartbeats.some((t=>t.date===s)))return this._heartbeatsCache.heartbeats.push({date:s,agent:i}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter((t=>{const e=new Date(t.date).valueOf();return Date.now()-e<=2592e6})),this._storage.overwrite(this._heartbeatsCache)}async getHeartbeatsHeader(){var t;if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null==(null===(t=this._heartbeatsCache)||void 0===t?void 0:t.heartbeats)||0===this._heartbeatsCache.heartbeats.length)return"";const e=Ii(),{heartbeatsToSend:i,unsentEntries:s}=function(t,e=1024){const i=[];let s=t.slice();for(const n of t){const t=i.find((t=>t.agent===n.agent));if(t){if(t.dates.push(n.date),pi(i)>e){t.dates.pop();break}}else if(i.push({agent:n.agent,dates:[n.date]}),pi(i)>e){i.pop();break}s=s.slice(1)}return{heartbeatsToSend:i,unsentEntries:s}}(this._heartbeatsCache.heartbeats),n=zt(JSON.stringify({version:2,heartbeats:i}));return this._heartbeatsCache.lastSentHeartbeatDate=e,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),n}}function Ii(){return(new Date).toISOString().substring(0,10)}class ui{constructor(t){this.app=t,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!Et()&&Dt().then((()=>!0)).catch((()=>!1))}async read(){if(await this._canUseIndexedDBPromise){const t=await async function(t){try{const e=(await li()).transaction(ai),i=await e.objectStore(ai).get(ci(t));return await e.done,i}catch(t){if(t instanceof Ut)De.warn(t.message);else{const e=Ke.create("idb-get",{originalErrorMessage:null==t?void 0:t.message});De.warn(e.message)}}}(this.app);return(null==t?void 0:t.heartbeats)?t:{heartbeats:[]}}return{heartbeats:[]}}async overwrite(t){var e;if(await this._canUseIndexedDBPromise){const i=await this.read();return hi(this.app,{lastSentHeartbeatDate:null!==(e=t.lastSentHeartbeatDate)&&void 0!==e?e:i.lastSentHeartbeatDate,heartbeats:t.heartbeats})}}async add(t){var e;if(await this._canUseIndexedDBPromise){const i=await this.read();return hi(this.app,{lastSentHeartbeatDate:null!==(e=t.lastSentHeartbeatDate)&&void 0!==e?e:i.lastSentHeartbeatDate,heartbeats:[...i.heartbeats,...t.heartbeats]})}}}function pi(t){return zt(JSON.stringify({version:2,heartbeats:t})).length}qe(new ue("platform-logger",(t=>new Je(t)),"PRIVATE")),qe(new ue("heartbeat",(t=>new di(t)),"PRIVATE")),si(Xe,Ee,""),si(Xe,Ee,"esm2017"),si("fire-js",""),si("firebase","10.8.0","app");const bi="@firebase/installations",mi="0.6.5",yi=1e4,Li=`w:${mi}`,Mi="FIS_v2",Wi="https://firebaseinstallations.googleapis.com/v1",wi=36e5,vi=new Bt("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function ji(t){return t instanceof Ut&&t.code.includes("request-failed")}function Zi({projectId:t}){return`${Wi}/projects/${t}/installations`}function Ci(t){return{token:t.token,requestStatus:2,expiresIn:(e=t.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()};var e}async function Gi(t,e){const i=(await e.json()).error;return vi.create("request-failed",{requestName:t,serverCode:i.code,serverMessage:i.message,serverStatus:i.status})}function fi({apiKey:t}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":t})}async function Ni(t){const e=await t();return e.status>=500&&e.status<600?t():e}function xi(t){return new Promise((e=>{setTimeout(e,t)}))}const Yi=/^[cdef][\w-]{21}$/,Ri="";function Hi(){try{const t=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(t),t[0]=112+t[0]%16;const e=function(t){var e;return(e=t,btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_")).substr(0,22)}(t);return Yi.test(e)?e:Ri}catch(t){return Ri}}function gi(t){return`${t.appName}!${t.appId}`}const Ai=new Map;function Si(t,e){const i=gi(t);zi(i,e),function(t,e){const i=(!Vi&&"BroadcastChannel"in self&&(Vi=new BroadcastChannel("[Firebase] FID Change"),Vi.onmessage=t=>{zi(t.data.key,t.data.fid)}),Vi);i&&i.postMessage({key:t,fid:e}),0===Ai.size&&Vi&&(Vi.close(),Vi=null)}(i,e)}function zi(t,e){const i=Ai.get(t);if(i)for(const t of i)t(e)}let Vi=null;const Ti="firebase-installations-database",ki=1,Oi="firebase-installations-store";let Fi=null;function Ji(){return Fi||(Fi=ze(Ti,ki,{upgrade:(t,e)=>{0===e&&t.createObjectStore(Oi)}})),Fi}async function Xi(t,e){const i=gi(t),s=(await Ji()).transaction(Oi,"readwrite"),n=s.objectStore(Oi),o=await n.get(i);return await n.put(e,i),await s.done,o&&o.fid===e.fid||Si(t,e.fid),e}async function Ei(t){const e=gi(t),i=(await Ji()).transaction(Oi,"readwrite");await i.objectStore(Oi).delete(e),await i.done}async function Di(t,e){const i=gi(t),s=(await Ji()).transaction(Oi,"readwrite"),n=s.objectStore(Oi),o=await n.get(i),a=e(o);return void 0===a?await n.delete(i):await n.put(a,i),await s.done,!a||o&&o.fid===a.fid||Si(t,a.fid),a}async function Ui(t){let e;const i=await Di(t.appConfig,(i=>{const s=function(t){return _i(t||{fid:Hi(),registrationStatus:0})}(i),n=function(t,e){if(0===e.registrationStatus){if(!navigator.onLine)return{installationEntry:e,registrationPromise:Promise.reject(vi.create("app-offline"))};const i={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},s=async function(t,e){try{const i=await async function({appConfig:t,heartbeatServiceProvider:e},{fid:i}){const s=Zi(t),n=fi(t),o=e.getImmediate({optional:!0});if(o){const t=await o.getHeartbeatsHeader();t&&n.append("x-firebase-client",t)}const a={fid:i,authVersion:Mi,appId:t.appId,sdkVersion:Li},r={method:"POST",headers:n,body:JSON.stringify(a)},l=await Ni((()=>fetch(s,r)));if(l.ok){const t=await l.json();return{fid:t.fid||i,registrationStatus:2,refreshToken:t.refreshToken,authToken:Ci(t.authToken)}}throw await Gi("Create Installation",l)}(t,e);return Xi(t.appConfig,i)}catch(i){throw ji(i)&&409===i.customData.serverCode?await Ei(t.appConfig):await Xi(t.appConfig,{fid:e.fid,registrationStatus:0}),i}}(t,i);return{installationEntry:i,registrationPromise:s}}return 1===e.registrationStatus?{installationEntry:e,registrationPromise:Bi(t)}:{installationEntry:e}}(t,s);return e=n.registrationPromise,n.installationEntry}));return i.fid===Ri?{installationEntry:await e}:{installationEntry:i,registrationPromise:e}}async function Bi(t){let e=await Pi(t.appConfig);for(;1===e.registrationStatus;)await xi(100),e=await Pi(t.appConfig);if(0===e.registrationStatus){const{installationEntry:e,registrationPromise:i}=await Ui(t);return i||e}return e}function Pi(t){return Di(t,(t=>{if(!t)throw vi.create("installation-not-found");return _i(t)}))}function _i(t){return 1===(e=t).registrationStatus&&e.registrationTime+yifetch(s,r)));if(l.ok)return Ci(await l.json());throw await Gi("Generate Auth Token",l)}async function qi(t,e=!1){let i;const s=await Di(t.appConfig,(s=>{if(!Ki(s))throw vi.create("not-registered");const n=s.authToken;if(!e&&(2===(o=n).requestStatus&&!function(t){const e=Date.now();return e{if(!Ki(t))throw vi.create("not-registered");return 1===(e=t.authToken).requestStatus&&e.requestTime+yi{const e=t.getProvider("app").getImmediate(),i=function(t){if(!t||!t.options)throw ts("App Configuration");if(!t.name)throw ts("App Name");const e=["projectId","apiKey","appId"];for(const i of e)if(!t.options[i])throw ts(i);return{appName:t.name,projectId:t.options.projectId,apiKey:t.options.apiKey,appId:t.options.appId}}(e);return{app:e,appConfig:i,heartbeatServiceProvider:$e(e,"heartbeat"),_delete:()=>Promise.resolve()}}),"PUBLIC")),qe(new ue("installations-internal",(t=>{const e=$e(t.getProvider("app").getImmediate(),es).getImmediate();return{getId:()=>async function(t){const e=t,{installationEntry:i,registrationPromise:s}=await Ui(e);return s?s.catch(console.error):qi(e).catch(console.error),i.fid}(e),getToken:t=>async function(t,e=!1){const i=t;return await async function(t){const{registrationPromise:e}=await Ui(t);e&&await e}(i),(await qi(i,e)).token}(e,t)}}),"PRIVATE")),si(bi,mi),si(bi,mi,"esm2017");const is="analytics",ss="firebase_id",ns="origin",os=6e4,as="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",rs="https://www.googletagmanager.com/gtag/js",ls=new je("@firebase/analytics"),hs=new Bt("analytics","Analytics",{"already-exists":"A Firebase Analytics instance with the appId {$id} already exists. Only one Firebase Analytics instance can be created for each appId.","already-initialized":"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-intialized instance.","already-initialized-settings":"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.","interop-component-reg-failed":"Firebase Analytics Interop Component failed to instantiate: {$reason}","invalid-analytics-context":"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","indexeddb-unavailable":"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","fetch-throttle":"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.","config-fetch-failed":"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}","no-api-key":'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',"no-app-id":'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.',"no-client-id":'The "client_id" field is empty.',"invalid-gtag-resource":"Trusted Types detected an invalid gtag resource: {$gtagURL}."});function cs(t){if(!t.startsWith(rs)){const e=hs.create("invalid-gtag-resource",{gtagURL:t});return ls.warn(e.message),""}return t}function ds(t){return Promise.all(t.map((t=>t.catch((t=>t)))))}const Is=30,us=new class{constructor(t={},e=1e3){this.throttleMetadata=t,this.intervalMillis=e}getThrottleMetadata(t){return this.throttleMetadata[t]}setThrottleMetadata(t,e){this.throttleMetadata[t]=e}deleteThrottleMetadata(t){delete this.throttleMetadata[t]}};function ps(t){return new Headers({Accept:"application/json","x-goog-api-key":t})}async function bs(t,e=us,i){const{appId:s,apiKey:n,measurementId:o}=t.options;if(!s)throw hs.create("no-app-id");if(!n){if(o)return{measurementId:o,appId:s};throw hs.create("no-api-key")}const a=e.getThrottleMetadata(s)||{backoffCount:0,throttleEndTimeMillis:Date.now()},r=new ys;return setTimeout((async()=>{r.abort()}),void 0!==i?i:os),ms({appId:s,apiKey:n,measurementId:o},a,r,e)}async function ms(t,{throttleEndTimeMillis:e,backoffCount:i},s,n=us){var o;const{appId:a,measurementId:r}=t;try{await function(t,e){return new Promise(((i,s)=>{const n=Math.max(e-Date.now(),0),o=setTimeout(i,n);t.addEventListener((()=>{clearTimeout(o),s(hs.create("fetch-throttle",{throttleEndTimeMillis:e}))}))}))}(s,e)}catch(t){if(r)return ls.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${r} provided in the "measurementId" field in the local Firebase config. [${null==t?void 0:t.message}]`),{appId:a,measurementId:r};throw t}try{const e=await async function(t){var e;const{appId:i,apiKey:s}=t,n={method:"GET",headers:ps(s)},o=as.replace("{app-id}",i),a=await fetch(o,n);if(200!==a.status&&304!==a.status){let t="";try{const i=await a.json();(null===(e=i.error)||void 0===e?void 0:e.message)&&(t=i.error.message)}catch(t){}throw hs.create("config-fetch-failed",{httpStatus:a.status,responseMessage:t})}return a.json()}(t);return n.deleteThrottleMetadata(a),e}catch(e){const l=e;if(!function(t){if(!(t instanceof Ut&&t.customData))return!1;const e=Number(t.customData.httpStatus);return 429===e||500===e||503===e||504===e}(l)){if(n.deleteThrottleMetadata(a),r)return ls.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${r} provided in the "measurementId" field in the local Firebase config. [${null==l?void 0:l.message}]`),{appId:a,measurementId:r};throw e}const h=503===Number(null===(o=null==l?void 0:l.customData)||void 0===o?void 0:o.httpStatus)?de(i,n.intervalMillis,Is):de(i,n.intervalMillis),c={throttleEndTimeMillis:Date.now()+h,backoffCount:i+1};return n.setThrottleMetadata(a,c),ls.debug(`Calling attemptFetch again in ${h} millis`),ms(t,c,s,n)}}class ys{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}abort(){this.listeners.forEach((t=>t()))}}let Ls,Ms;async function Ws(t,e,i,s,n,o,a){var r;const l=bs(t);l.then((e=>{i[e.measurementId]=e.appId,t.options.measurementId&&e.measurementId!==t.options.measurementId&&ls.warn(`The measurement ID in the local Firebase config (${t.options.measurementId}) does not match the measurement ID fetched from the server (${e.measurementId}). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.`)})).catch((t=>ls.error(t))),e.push(l);const h=async function(){if(!Et())return ls.warn(hs.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;try{await Dt()}catch(t){return ls.warn(hs.create("indexeddb-unavailable",{errorInfo:null==t?void 0:t.toString()}).message),!1}return!0}().then((t=>t?s.getId():void 0)),[c,d]=await Promise.all([l,h]);(function(t){const e=window.document.getElementsByTagName("script");for(const i of Object.values(e))if(i.src&&i.src.includes(rs)&&i.src.includes(t))return i;return null})(o)||function(t,e){const i=function(t,e){let i;return window.trustedTypes&&(i=window.trustedTypes.createPolicy("firebase-js-sdk-policy",e)),i}(0,{createScriptURL:cs}),s=document.createElement("script"),n=`${rs}?l=${t}&id=${e}`;s.src=i?null==i?void 0:i.createScriptURL(n):n,s.async=!0,document.head.appendChild(s)}(o,c.measurementId),Ms&&(n("consent","default",Ms),Ms=void 0),n("js",new Date);const I=null!==(r=null==a?void 0:a.config)&&void 0!==r?r:{};return I[ns]="firebase",I.update=!0,null!=d&&(I[ss]=d),n("config",c.measurementId,I),Ls&&(n("set",Ls),Ls=void 0),c.measurementId}class ws{constructor(t){this.app=t}_delete(){return delete vs[this.app.options.appId],Promise.resolve()}}let vs={},js=[];const Zs={};let Cs,Gs,fs="dataLayer",Ns=!1;function xs(t,e,i){!function(){const t=[];if(function(){const t="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof t&&void 0!==t.id}()&&t.push("This is a browser extension environment."),"undefined"!=typeof navigator&&navigator.cookieEnabled||t.push("Cookies are not available."),t.length>0){const e=t.map(((t,e)=>`(${e+1}) ${t}`)).join(" "),i=hs.create("invalid-analytics-context",{errorInfo:e});ls.warn(i.message)}}();const s=t.options.appId;if(!s)throw hs.create("no-app-id");if(!t.options.apiKey){if(!t.options.measurementId)throw hs.create("no-api-key");ls.warn(`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID ${t.options.measurementId} provided in the "measurementId" field in the local Firebase config.`)}if(null!=vs[s])throw hs.create("already-exists",{id:s});if(!Ns){!function(t){let e=[];Array.isArray(window[t])?e=window[t]:window[t]=e}(fs);const{wrappedGtag:t,gtagCore:e}=function(t,e,i,s,n){let o=function(...t){window[s].push(arguments)};return window[n]&&"function"==typeof window[n]&&(o=window[n]),window[n]=function(t,e,i,s){return async function(n,...o){try{if("event"===n){const[s,n]=o;await async function(t,e,i,s,n){try{let o=[];if(n&&n.send_to){let t=n.send_to;Array.isArray(t)||(t=[t]);const s=await ds(i);for(const i of t){const t=s.find((t=>t.measurementId===i)),n=t&&e[t.appId];if(!n){o=[];break}o.push(n)}}0===o.length&&(o=Object.values(e)),await Promise.all(o),t("event",s,n||{})}catch(t){ls.error(t)}}(t,e,i,s,n)}else if("config"===n){const[n,a]=o;await async function(t,e,i,s,n,o){const a=s[n];try{if(a)await e[a];else{const t=(await ds(i)).find((t=>t.measurementId===n));t&&await e[t.appId]}}catch(t){ls.error(t)}t("config",n,o)}(t,e,i,s,n,a)}else if("consent"===n){const[e]=o;t("consent","update",e)}else if("get"===n){const[e,i,s]=o;t("get",e,i,s)}else if("set"===n){const[e]=o;t("set",e)}else t(n,...o)}catch(t){ls.error(t)}}}(o,t,e,i),{gtagCore:o,wrappedGtag:window[n]}}(vs,js,Zs,fs,"gtag");Gs=t,Cs=e,Ns=!0}return vs[s]=Ws(t,js,Zs,e,Cs,fs,i),new ws(t)}const Ys="@firebase/analytics",Rs="0.10.1";qe(new ue(is,((t,{options:e})=>xs(t.getProvider("app").getImmediate(),t.getProvider("installations-internal").getImmediate(),e)),"PUBLIC")),qe(new ue("analytics-internal",(function(t){try{const e=t.getProvider(is).getImmediate();return{logEvent:(t,i,s)=>function(t,e,i,s){t=Ie(t),async function(t,e,i,s,n){if(n&&n.global)t("event",i,s);else{const n=await e;t("event",i,Object.assign(Object.assign({},s),{send_to:n}))}}(Gs,vs[t.app.options.appId],e,i,s).catch((t=>ls.error(t)))}(e,t,i,s)}}catch(t){throw hs.create("interop-component-reg-failed",{reason:t})}}),"PRIVATE")),si(Ys,Rs),si(Ys,Rs,"esm2017");const Hs="@firebase/database",gs="1.0.3";let As="";class Ss{constructor(t){this.domStorage_=t,this.prefix_="firebase:"}set(t,e){null==e?this.domStorage_.removeItem(this.prefixedName_(t)):this.domStorage_.setItem(this.prefixedName_(t),Qt(e))}get(t){const e=this.domStorage_.getItem(this.prefixedName_(t));return null==e?null:_t(e)}remove(t){this.domStorage_.removeItem(this.prefixedName_(t))}prefixedName_(t){return this.prefix_+t}toString(){return this.domStorage_.toString()}}class zs{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(t,e){null==e?delete this.cache_[t]:this.cache_[t]=e}get(t){return $t(this.cache_,t)?this.cache_[t]:null}remove(t){delete this.cache_[t]}}const Vs=function(t){try{if("undefined"!=typeof window&&void 0!==window[t]){const e=window[t];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new Ss(e)}}catch(t){}return new zs},Ts=Vs("localStorage"),ks=Vs("sessionStorage"),Os=new je("@firebase/database"),Fs=function(){let t=1;return function(){return t++}}(),Js=function(t){const e=function(t){const e=[];let i=0;for(let s=0;s=55296&&n<=56319){const e=n-55296;s++,Yt(s>6|192,e[i++]=63&n|128):n<65536?(e[i++]=n>>12|224,e[i++]=n>>6&63|128,e[i++]=63&n|128):(e[i++]=n>>18|240,e[i++]=n>>12&63|128,e[i++]=n>>6&63|128,e[i++]=63&n|128)}return e}(t),i=new ne;i.update(e);const s=i.digest();return gt.encodeByteArray(s)},Xs=function(...t){let e="";for(let i=0;ii?s.push(t.substring(n,i)):s.push(t.substring(n,n+e));return s};function an(t,e){for(const i in t)t.hasOwnProperty(i)&&e(i,t[i])}const rn=function(t){Yt(!qs(t),"Invalid JSON number");let e,i,s,n,o;0===t?(i=0,s=0,e=1/t==-1/0?1:0):(e=t<0,(t=Math.abs(t))>=Math.pow(2,-1022)?(n=Math.min(Math.floor(Math.log(t)/Math.LN2),1023),i=n+1023,s=Math.round(t*Math.pow(2,52-n)-Math.pow(2,52))):(i=0,s=Math.round(t/Math.pow(2,-1074))));const a=[];for(o=52;o;o-=1)a.push(s%2?1:0),s=Math.floor(s/2);for(o=11;o;o-=1)a.push(i%2?1:0),i=Math.floor(i/2);a.push(e?1:0),a.reverse();const r=a.join("");let l="";for(o=0;o<64;o+=8){let t=parseInt(r.substr(o,8),2).toString(16);1===t.length&&(t="0"+t),l+=t}return l.toLowerCase()},ln=new RegExp("^-?(0*)\\d{1,10}$"),hn=function(t){if(ln.test(t)){const e=Number(t);if(e>=-2147483648&&e<=2147483647)return e}return null},cn=function(t){try{t()}catch(t){setTimeout((()=>{const e=t.stack||"";throw Qs("Exception was thrown by user callback.",e),t}),Math.floor(0))}},dn=function(t,e){const i=setTimeout(t,e);return"number"==typeof i&&"undefined"!=typeof Deno&&Deno.unrefTimer?Deno.unrefTimer(i):"object"==typeof i&&i.unref&&i.unref(),i};class In{constructor(t,e){this.appName_=t,this.appCheckProvider=e,this.appCheck=null==e?void 0:e.getImmediate({optional:!0}),this.appCheck||null==e||e.get().then((t=>this.appCheck=t))}getToken(t){return this.appCheck?this.appCheck.getToken(t):new Promise(((e,i)=>{setTimeout((()=>{this.appCheck?this.getToken(t).then(e,i):e(null)}),0)}))}addTokenChangeListener(t){var e;null===(e=this.appCheckProvider)||void 0===e||e.get().then((e=>e.addTokenListener(t)))}notifyForInvalidToken(){Qs(`Provided AppCheck credentials for the app named "${this.appName_}" are invalid. This usually indicates your app was not initialized correctly.`)}}class un{constructor(t,e,i){this.appName_=t,this.firebaseOptions_=e,this.authProvider_=i,this.auth_=null,this.auth_=i.getImmediate({optional:!0}),this.auth_||i.onInit((t=>this.auth_=t))}getToken(t){return this.auth_?this.auth_.getToken(t).catch((t=>t&&"auth/token-not-initialized"===t.code?(Us("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(t))):new Promise(((e,i)=>{setTimeout((()=>{this.auth_?this.getToken(t).then(e,i):e(null)}),0)}))}addTokenChangeListener(t){this.auth_?this.auth_.addAuthTokenListener(t):this.authProvider_.get().then((e=>e.addAuthTokenListener(t)))}removeTokenChangeListener(t){this.authProvider_.get().then((e=>e.removeAuthTokenListener(t)))}notifyForInvalidToken(){let t='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?t+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?t+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':t+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',Qs(t)}}class pn{constructor(t){this.accessToken=t}getToken(t){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(t){t(this.accessToken)}removeTokenChangeListener(t){}notifyForInvalidToken(){}}pn.OWNER="owner";const bn="5",mn=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,yn="ac",Ln="websocket",Mn="long_polling";class Wn{constructor(t,e,i,s,n=!1,o="",a=!1,r=!1){this.secure=e,this.namespace=i,this.webSocketOnly=s,this.nodeAdmin=n,this.persistenceKey=o,this.includeNamespaceInQueryParams=a,this.isUsingEmulator=r,this._host=t.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=Ts.get("host:"+t)||this._host}isCacheableHost(){return"s-"===this.internalHost.substr(0,2)}isCustomHost(){return"firebaseio.com"!==this._domain&&"firebaseio-demo.com"!==this._domain}get host(){return this._host}set host(t){t!==this.internalHost&&(this.internalHost=t,this.isCacheableHost()&&Ts.set("host:"+this._host,this.internalHost))}toString(){let t=this.toURLString();return this.persistenceKey&&(t+="<"+this.persistenceKey+">"),t}toURLString(){const t=this.secure?"https://":"http://",e=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${t}${this.host}/${e}`}}function wn(t,e,i){let s;if(Yt("string"==typeof e,"typeof type must == string"),Yt("object"==typeof i,"typeof params must == object"),e===Ln)s=(t.secure?"wss://":"ws://")+t.internalHost+"/.ws?";else{if(e!==Mn)throw new Error("Unknown connection type: "+e);s=(t.secure?"https://":"http://")+t.internalHost+"/.lp?"}(function(t){return t.host!==t.internalHost||t.isCustomHost()||t.includeNamespaceInQueryParams})(t)&&(i.ns=t.namespace);const n=[];return an(i,((t,e)=>{n.push(t+"="+e)})),s+n.join("&")}class vn{constructor(){this.counters_={}}incrementCounter(t,e=1){$t(this.counters_,t)||(this.counters_[t]=0),this.counters_[t]+=e}get(){return Tt(this.counters_)}}const jn={},Zn={};function Cn(t){const e=t.toString();return jn[e]||(jn[e]=new vn),jn[e]}class Gn{constructor(t){this.onMessage_=t,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(t,e){this.closeAfterResponse=t,this.onClose=e,this.closeAfterResponse{this.onMessage_(t[e])}));if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}const fn="start";class Nn{constructor(t,e,i,s,n,o,a){this.connId=t,this.repoInfo=e,this.applicationId=i,this.appCheckToken=s,this.authToken=n,this.transportSessionId=o,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Bs(t),this.stats_=Cn(e),this.urlFn=t=>(this.appCheckToken&&(t[yn]=this.appCheckToken),wn(e,Mn,t))}open(t,e){this.curSegmentNum=0,this.onDisconnect_=e,this.myPacketOrderer=new Gn(t),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout((()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null}),Math.floor(3e4)),function(t){if("complete"===document.readyState)t();else{let e=!1;const i=function(){document.body?e||(e=!0,t()):setTimeout(i,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",i,!1),window.addEventListener("load",i,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",(()=>{"complete"===document.readyState&&i()})),window.attachEvent("onload",i))}}((()=>{if(this.isClosed_)return;this.scriptTagHolder=new xn(((...t)=>{const[e,i,s,n,o]=t;if(this.incrementIncomingBytes_(t),this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,e===fn)this.id=i,this.password=s;else{if("close"!==e)throw new Error("Unrecognized command received: "+e);i?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(i,(()=>{this.onClosed_()}))):this.onClosed_()}}),((...t)=>{const[e,i]=t;this.incrementIncomingBytes_(t),this.myPacketOrderer.handleResponse(e,i)}),(()=>{this.onClosed_()}),this.urlFn);const t={};t[fn]="t",t.ser=Math.floor(1e8*Math.random()),this.scriptTagHolder.uniqueCallbackIdentifier&&(t.cb=this.scriptTagHolder.uniqueCallbackIdentifier),t.v=bn,this.transportSessionId&&(t.s=this.transportSessionId),this.lastSessionId&&(t.ls=this.lastSessionId),this.applicationId&&(t.p=this.applicationId),this.appCheckToken&&(t[yn]=this.appCheckToken),"undefined"!=typeof location&&location.hostname&&mn.test(location.hostname)&&(t.r="f");const e=this.urlFn(t);this.log_("Connecting via long-poll to "+e),this.scriptTagHolder.addTag(e,(()=>{}))}))}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){Nn.forceAllow_=!0}static forceDisallow(){Nn.forceDisallow_=!0}static isAvailable(){return!(!Nn.forceAllow_&&(Nn.forceDisallow_||"undefined"==typeof document||null==document.createElement||"object"==typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href)||"object"==typeof Windows&&"object"==typeof Windows.UI))}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(t){const e=Qt(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);const i=St(e),s=on(i,1840);for(let t=0;tdocument.domain="'+document.domain+'";<\/script>');const s=""+i+"";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(s),this.myIFrame.doc.close()}catch(t){Us("frame writing exception"),t.stack&&Us(t.stack),Us(t)}}}static createIFrame_(){const t=document.createElement("iframe");if(t.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(t);try{t.contentWindow.document||Us("No IE domain setting required")}catch(e){const i=document.domain;t.src="javascript:void((function(){document.open();document.domain='"+i+"';document.close();})())"}return t.contentDocument?t.doc=t.contentDocument:t.contentWindow?t.doc=t.contentWindow.document:t.document&&(t.doc=t.document),t}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout((()=>{null!==this.myIFrame&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)}),Math.floor(0)));const t=this.onDisconnect;t&&(this.onDisconnect=null,t())}startLongPoll(t,e){for(this.myID=t,this.myPW=e,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const t={};t.id=this.myID,t.pw=this.myPW,t.ser=this.currentSerial;let e=this.urlFn(t),i="",s=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+30+i.length<=1870;){const t=this.pendingSegs.shift();i=i+"&seg"+s+"="+t.seg+"&ts"+s+"="+t.ts+"&d"+s+"="+t.d,s++}return e+=i,this.addLongPollTag_(e,this.currentSerial),!0}return!1}enqueueSegment(t,e,i){this.pendingSegs.push({seg:t,ts:e,d:i}),this.alive&&this.newRequest_()}addLongPollTag_(t,e){this.outstandingRequests.add(e);const i=()=>{this.outstandingRequests.delete(e),this.newRequest_()},s=setTimeout(i,Math.floor(25e3));this.addTag(t,(()=>{clearTimeout(s),i()}))}addTag(t,e){setTimeout((()=>{try{if(!this.sendNewPolls)return;const i=this.myIFrame.doc.createElement("script");i.type="text/javascript",i.async=!0,i.src=t,i.onload=i.onreadystatechange=function(){const t=i.readyState;t&&"loaded"!==t&&"complete"!==t||(i.onload=i.onreadystatechange=null,i.parentNode&&i.parentNode.removeChild(i),e())},i.onerror=()=>{Us("Long-poll script failed to load: "+t),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(i)}catch(t){}}),Math.floor(1))}}let Yn=null;"undefined"!=typeof MozWebSocket?Yn=MozWebSocket:"undefined"!=typeof WebSocket&&(Yn=WebSocket);class Rn{constructor(t,e,i,s,n,o,a){this.connId=t,this.applicationId=i,this.appCheckToken=s,this.authToken=n,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=Bs(this.connId),this.stats_=Cn(e),this.connURL=Rn.connectionURL_(e,o,a,s,i),this.nodeAdmin=e.nodeAdmin}static connectionURL_(t,e,i,s,n){const o={};return o.v=bn,"undefined"!=typeof location&&location.hostname&&mn.test(location.hostname)&&(o.r="f"),e&&(o.s=e),i&&(o.ls=i),s&&(o[yn]=s),n&&(o.p=n),wn(t,Ln,o)}open(t,e){this.onDisconnect=e,this.onMessage=t,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,Ts.set("previous_websocket_failure",!0);try{let t;0,this.mySock=new Yn(this.connURL,[],t)}catch(t){this.log_("Error instantiating WebSocket.");const e=t.message||t.data;return e&&this.log_(e),void this.onClosed_()}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=t=>{this.handleIncomingFrame(t)},this.mySock.onerror=t=>{this.log_("WebSocket error. Closing connection.");const e=t.message||t.data;e&&this.log_(e),this.onClosed_()}}start(){}static forceDisallow(){Rn.forceDisallow_=!0}static isAvailable(){let t=!1;if("undefined"!=typeof navigator&&navigator.userAgent){const e=/Android ([0-9]{0,}\.[0-9]{0,})/,i=navigator.userAgent.match(e);i&&i.length>1&&parseFloat(i[1])<4.4&&(t=!0)}return!t&&null!==Yn&&!Rn.forceDisallow_}static previouslyFailed(){return Ts.isInMemoryStorage||!0===Ts.get("previous_websocket_failure")}markConnectionHealthy(){Ts.remove("previous_websocket_failure")}appendFrame_(t){if(this.frames.push(t),this.frames.length===this.totalFrames){const t=this.frames.join("");this.frames=null;const e=_t(t);this.onMessage(e)}}handleNewFrameCount_(t){this.totalFrames=t,this.frames=[]}extractFrameCount_(t){if(Yt(null===this.frames,"We already have a frame buffer"),t.length<=6){const e=Number(t);if(!isNaN(e))return this.handleNewFrameCount_(e),null}return this.handleNewFrameCount_(1),t}handleIncomingFrame(t){if(null===this.mySock)return;const e=t.data;if(this.bytesReceived+=e.length,this.stats_.incrementCounter("bytes_received",e.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(e);else{const t=this.extractFrameCount_(e);null!==t&&this.appendFrame_(t)}}send(t){this.resetKeepAlive();const e=Qt(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);const i=on(e,16384);i.length>1&&this.sendString_(String(i.length));for(let t=0;t{this.mySock&&this.sendString_("0"),this.resetKeepAlive()}),Math.floor(45e3))}sendString_(t){try{this.mySock.send(t)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}Rn.responsesRequiredToBeHealthy=2,Rn.healthyTimeout=3e4;class Hn{constructor(t){this.initTransports_(t)}static get ALL_TRANSPORTS(){return[Nn,Rn]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}initTransports_(t){const e=Rn&&Rn.isAvailable();let i=e&&!Rn.previouslyFailed();if(t.webSocketOnly&&(e||Qs("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),i=!0),i)this.transports_=[Rn];else{const t=this.transports_=[];for(const e of Hn.ALL_TRANSPORTS)e&&e.isAvailable()&&t.push(e);Hn.globalTransportInitialized_=!0}}initialTransport(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return this.transports_.length>1?this.transports_[1]:null}}Hn.globalTransportInitialized_=!1;class gn{constructor(t,e,i,s,n,o,a,r,l,h){this.id=t,this.repoInfo_=e,this.applicationId_=i,this.appCheckToken_=s,this.authToken_=n,this.onMessage_=o,this.onReady_=a,this.onDisconnect_=r,this.onKill_=l,this.lastSessionId=h,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=Bs("c:"+this.id+":"),this.transportManager_=new Hn(e),this.log_("Connection created"),this.start_()}start_(){const t=this.transportManager_.initialTransport();this.conn_=new t(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=t.responsesRequiredToBeHealthy||0;const e=this.connReceiver_(this.conn_),i=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout((()=>{this.conn_&&this.conn_.open(e,i)}),Math.floor(0));const s=t.healthyTimeout||0;s>0&&(this.healthyTimeout_=dn((()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>102400?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes. Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>10240?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes. Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))}),Math.floor(s)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(t){return e=>{t===this.conn_?this.onConnectionLost_(e):t===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(t){return e=>{2!==this.state_&&(t===this.rx_?this.onPrimaryMessageReceived_(e):t===this.secondaryConn_?this.onSecondaryMessageReceived_(e):this.log_("message on old connection"))}}sendRequest(t){const e={t:"d",d:t};this.sendData_(e)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(t){if("t"in t){const e=t.t;"a"===e?this.upgradeIfSecondaryHealthy_():"r"===e?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===e&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(t){const e=sn("t",t),i=sn("d",t);if("c"===e)this.onSecondaryControl_(i);else{if("d"!==e)throw new Error("Unknown protocol layer: "+e);this.pendingDataMessages.push(i)}}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(t){const e=sn("t",t),i=sn("d",t);"c"===e?this.onControl_(i):"d"===e&&this.onDataMessage_(i)}onDataMessage_(t){this.onPrimaryResponse_(),this.onMessage_(t)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(t){const e=sn("t",t);if("d"in t){const i=t.d;if("h"===e){const t=Object.assign({},i);this.repoInfo_.isUsingEmulator&&(t.h=this.repoInfo_.host),this.onHandshake_(t)}else if("n"===e){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let t=0;t{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())}),Math.floor(6e4))}onReset_(t){this.log_("Reset packet received. New host: "+t),this.repoInfo_.host=t,1===this.state_?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(t,e){this.log_("Realtime connection established."),this.conn_=t,this.state_=1,this.onReady_&&(this.onReady_(e,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):dn((()=>{this.sendPingOnPrimaryIfNecessary_()}),Math.floor(5e3))}sendPingOnPrimaryIfNecessary_(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))}onSecondaryConnectionLost_(){const t=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==t&&this.rx_!==t||this.close()}onConnectionLost_(t){this.conn_=null,t||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(Ts.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()}onConnectionShutdown_(t){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(t),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(t){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(t)}close(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}class An{put(t,e,i,s){}merge(t,e,i,s){}refreshAuthToken(t){}refreshAppCheckToken(t){}onDisconnectPut(t,e,i){}onDisconnectMerge(t,e,i){}onDisconnectCancel(t,e){}reportStats(t){}}class Sn{constructor(t){this.allowedEvents_=t,this.listeners_={},Yt(Array.isArray(t)&&t.length>0,"Requires a non-empty array")}trigger(t,...e){if(Array.isArray(this.listeners_[t])){const i=[...this.listeners_[t]];for(let t=0;te===t)),"Unknown event: "+t)}}class zn extends Sn{constructor(){super(["online"]),this.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||Xt()||(window.addEventListener("online",(()=>{this.online_||(this.online_=!0,this.trigger("online",!0))}),!1),window.addEventListener("offline",(()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))}),!1))}static getInstance(){return new zn}getInitialEvent(t){return Yt("online"===t,"Unknown event type: "+t),[this.online_]}currentlyOnline(){return this.online_}}class Vn{constructor(t,e){if(void 0===e){this.pieces_=t.split("/");let e=0;for(let t=0;t0&&(this.pieces_[e]=this.pieces_[t],e++);this.pieces_.length=e,this.pieceNum_=0}else this.pieces_=t,this.pieceNum_=e}toString(){let t="";for(let e=this.pieceNum_;e=t.pieces_.length?null:t.pieces_[t.pieceNum_]}function On(t){return t.pieces_.length-t.pieceNum_}function Fn(t){let e=t.pieceNum_;return e=t.pieces_.length)return null;const e=[];for(let i=t.pieceNum_;i0&&i.push(t[e])}return new Vn(i,0)}function Un(t){return t.pieceNum_>=t.pieces_.length}function Bn(t,e){const i=kn(t),s=kn(e);if(null===i)return e;if(i===s)return Bn(Fn(t),Fn(e));throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")}function Pn(t,e){if(On(t)!==On(e))return!1;for(let i=t.pieceNum_,s=e.pieceNum_;i<=t.pieces_.length;i++,s++)if(t.pieces_[i]!==e.pieces_[s])return!1;return!0}function _n(t,e){let i=t.pieceNum_,s=e.pieceNum_;if(On(t)>On(e))return!1;for(;i768)throw new Error(t.errorPrefix_+"has a key path longer than 768 bytes ("+t.byteLength_+").");if(t.parts_.length>32)throw new Error(t.errorPrefix_+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+$n(t))}function $n(t){return 0===t.parts_.length?"":"in property '"+t.parts_.join(".")+"'"}class Kn extends Sn{constructor(){let t,e;super(["visible"]),"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(e="visibilitychange",t="hidden"):void 0!==document.mozHidden?(e="mozvisibilitychange",t="mozHidden"):void 0!==document.msHidden?(e="msvisibilitychange",t="msHidden"):void 0!==document.webkitHidden&&(e="webkitvisibilitychange",t="webkitHidden")),this.visible_=!0,e&&document.addEventListener(e,(()=>{const e=!document[t];e!==this.visible_&&(this.visible_=e,this.trigger("visible",e))}),!1)}static getInstance(){return new Kn}getInitialEvent(t){return Yt("visible"===t,"Unknown event type: "+t),[this.visible_]}}const to=1e3;class eo extends An{constructor(t,e,i,s,n,o,a,r){if(super(),this.repoInfo_=t,this.applicationId_=e,this.onDataUpdate_=i,this.onConnectStatus_=s,this.onServerInfoUpdate_=n,this.authTokenProvider_=o,this.appCheckTokenProvider_=a,this.authOverride_=r,this.id=eo.nextPersistentConnectionId_++,this.log_=Bs("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=to,this.maxReconnectDelay_=3e5,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,r)throw new Error("Auth override specified in options, but not supported on non Node.js platforms");Kn.getInstance().on("visible",this.onVisible_,this),-1===t.host.indexOf("fblocal")&&zn.getInstance().on("online",this.onOnline_,this)}sendRequest(t,e,i){const s=++this.requestNumber_,n={r:s,a:t,b:e};this.log_(Qt(n)),Yt(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(n),i&&(this.requestCBHash_[s]=i)}get(t){this.initConnection_();const e=new Jt,i={action:"g",request:{p:t._path.toString(),q:t._queryObject},onComplete:t=>{const i=t.d;"ok"===t.s?e.resolve(i):e.reject(i)}};this.outstandingGets_.push(i),this.outstandingGetCount_++;const s=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(s),e.promise}listen(t,e,i,s){this.initConnection_();const n=t._queryIdentifier,o=t._path.toString();this.log_("Listen called for "+o+" "+n),this.listens.has(o)||this.listens.set(o,new Map),Yt(t._queryParams.isDefault()||!t._queryParams.loadsAllData(),"listen() called for non-default but complete query"),Yt(!this.listens.get(o).has(n),"listen() called twice for same path/queryId.");const a={onComplete:s,hashFn:e,query:t,tag:i};this.listens.get(o).set(n,a),this.connected_&&this.sendListen_(a)}sendGet_(t){const e=this.outstandingGets_[t];this.sendRequest("g",e.request,(i=>{delete this.outstandingGets_[t],this.outstandingGetCount_--,0===this.outstandingGetCount_&&(this.outstandingGets_=[]),e.onComplete&&e.onComplete(i)}))}sendListen_(t){const e=t.query,i=e._path.toString(),s=e._queryIdentifier;this.log_("Listen on "+i+" for "+s);const n={p:i};t.tag&&(n.q=e._queryObject,n.t=t.tag),n.h=t.hashFn(),this.sendRequest("q",n,(n=>{const o=n.d,a=n.s;eo.warnOnListenWarnings_(o,e),(this.listens.get(i)&&this.listens.get(i).get(s))===t&&(this.log_("listen response",n),"ok"!==a&&this.removeListen_(i,s),t.onComplete&&t.onComplete(a,o))}))}static warnOnListenWarnings_(t,e){if(t&&"object"==typeof t&&$t(t,"w")){const i=Kt(t,"w");if(Array.isArray(i)&&~i.indexOf("no_index")){const t='".indexOn": "'+e._queryParams.getIndex().toString()+'"',i=e._path.toString();Qs(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${t} at ${i} to your security rules for better performance.`)}}}refreshAuthToken(t){this.authToken_=t,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},(()=>{})),this.reduceReconnectDelayIfAdminCredential_(t)}reduceReconnectDelayIfAdminCredential_(t){(t&&40===t.length||function(t){const e=qt(t).claims;return"object"==typeof e&&!0===e.admin}(t))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=3e4)}refreshAppCheckToken(t){this.appCheckToken_=t,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},(()=>{}))}tryAuth(){if(this.connected_&&this.authToken_){const t=this.authToken_,e=function(t){const e=qt(t).claims;return!!e&&"object"==typeof e&&e.hasOwnProperty("iat")}(t)?"auth":"gauth",i={cred:t};null===this.authOverride_?i.noauth=!0:"object"==typeof this.authOverride_&&(i.authvar=this.authOverride_),this.sendRequest(e,i,(e=>{const i=e.s,s=e.d||"error";this.authToken_===t&&("ok"===i?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(i,s))}))}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},(t=>{const e=t.s,i=t.d||"error";"ok"===e?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(e,i)}))}unlisten(t,e){const i=t._path.toString(),s=t._queryIdentifier;this.log_("Unlisten called for "+i+" "+s),Yt(t._queryParams.isDefault()||!t._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(i,s)&&this.connected_&&this.sendUnlisten_(i,s,t._queryObject,e)}sendUnlisten_(t,e,i,s){this.log_("Unlisten on "+t+" for "+e);const n={p:t};s&&(n.q=i,n.t=s),this.sendRequest("n",n)}onDisconnectPut(t,e,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",t,e,i):this.onDisconnectRequestQueue_.push({pathString:t,action:"o",data:e,onComplete:i})}onDisconnectMerge(t,e,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",t,e,i):this.onDisconnectRequestQueue_.push({pathString:t,action:"om",data:e,onComplete:i})}onDisconnectCancel(t,e){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",t,null,e):this.onDisconnectRequestQueue_.push({pathString:t,action:"oc",data:null,onComplete:e})}sendOnDisconnect_(t,e,i,s){const n={p:e,d:i};this.log_("onDisconnect "+t,n),this.sendRequest(t,n,(t=>{s&&setTimeout((()=>{s(t.s,t.d)}),Math.floor(0))}))}put(t,e,i,s){this.putInternal("p",t,e,i,s)}merge(t,e,i,s){this.putInternal("m",t,e,i,s)}putInternal(t,e,i,s,n){this.initConnection_();const o={p:e,d:i};void 0!==n&&(o.h=n),this.outstandingPuts_.push({action:t,request:o,onComplete:s}),this.outstandingPutCount_++;const a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):this.log_("Buffering put: "+e)}sendPut_(t){const e=this.outstandingPuts_[t].action,i=this.outstandingPuts_[t].request,s=this.outstandingPuts_[t].onComplete;this.outstandingPuts_[t].queued=this.connected_,this.sendRequest(e,i,(i=>{this.log_(e+" response",i),delete this.outstandingPuts_[t],this.outstandingPutCount_--,0===this.outstandingPutCount_&&(this.outstandingPuts_=[]),s&&s(i.s,i.d)}))}reportStats(t){if(this.connected_){const e={c:t};this.log_("reportStats",e),this.sendRequest("s",e,(t=>{if("ok"!==t.s){const e=t.d;this.log_("reportStats","Error sending stats: "+e)}}))}}onDataMessage_(t){if("r"in t){this.log_("from server: "+Qt(t));const e=t.r,i=this.requestCBHash_[e];i&&(delete this.requestCBHash_[e],i(t.b))}else{if("error"in t)throw"A server-side error has occurred: "+t.error;"a"in t&&this.onDataPush_(t.a,t.b)}}onDataPush_(t,e){this.log_("handleServerMessage",t,e),"d"===t?this.onDataUpdate_(e.p,e.d,!1,e.t):"m"===t?this.onDataUpdate_(e.p,e.d,!0,e.t):"c"===t?this.onListenRevoked_(e.p,e.q):"ac"===t?this.onAuthRevoked_(e.s,e.d):"apc"===t?this.onAppCheckRevoked_(e.s,e.d):"sd"===t?this.onSecurityDebugPacket_(e):Ps("Unrecognized action received from server: "+Qt(t)+"\nAre you using the latest client?")}onReady_(t,e){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(t),this.lastSessionId=e,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(t){Yt(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout((()=>{this.establishConnectionTimer_=null,this.establishConnection_()}),Math.floor(t))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(t){t&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=to,this.realtime_||this.scheduleConnect_(0)),this.visible_=t}onOnline_(t){t?(this.log_("Browser went online."),this.reconnectDelay_=to,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&((new Date).getTime()-this.lastConnectionEstablishedTime_>3e4&&(this.reconnectDelay_=to),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime());const t=(new Date).getTime()-this.lastConnectionAttemptTime_;let e=Math.max(0,this.reconnectDelay_-t);e=Math.random()*e,this.log_("Trying to reconnect in "+e+"ms"),this.scheduleConnect_(e),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;const t=this.onDataMessage_.bind(this),e=this.onReady_.bind(this),i=this.onRealtimeDisconnect_.bind(this),s=this.id+":"+eo.nextConnectionId_++,n=this.lastSessionId;let o=!1,a=null;const r=function(){a?a.close():(o=!0,i())},l=function(t){Yt(a,"sendRequest call when we're not connected not allowed."),a.sendRequest(t)};this.realtime_={close:r,sendRequest:l};const h=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[r,l]=await Promise.all([this.authTokenProvider_.getToken(h),this.appCheckTokenProvider_.getToken(h)]);o?Us("getToken() completed but was canceled"):(Us("getToken() completed. Creating connection."),this.authToken_=r&&r.accessToken,this.appCheckToken_=l&&l.token,a=new gn(s,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,t,e,i,(t=>{Qs(t+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")}),n))}catch(t){this.log_("Failed to get token: "+t),o||(this.repoInfo_.nodeAdmin&&Qs(t),r())}}}interrupt(t){Us("Interrupting connection for reason: "+t),this.interruptReasons_[t]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(t){Us("Resuming connection for reason: "+t),delete this.interruptReasons_[t],te(this.interruptReasons_)&&(this.reconnectDelay_=to,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(t){const e=t-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:e})}cancelSentTransactions_(){for(let t=0;tnn(t))).join("$"):"default";const s=this.removeListen_(t,i);s&&s.onComplete&&s.onComplete("permission_denied")}removeListen_(t,e){const i=new Vn(t).toString();let s;if(this.listens.has(i)){const t=this.listens.get(i);s=t.get(e),t.delete(e),0===t.size&&this.listens.delete(i)}else s=void 0;return s}onAuthRevoked_(t,e){Us("Auth token revoked: "+t+"/"+e),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==t&&"permission_denied"!==t||(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=3&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(t,e){Us("App check token revoked: "+t+"/"+e),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==t&&"permission_denied"!==t||(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=3&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(t){this.securityDebugCallback_?this.securityDebugCallback_(t):"msg"in t&&console.log("FIREBASE: "+t.msg.replace("\n","\nFIREBASE: "))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const t of this.listens.values())for(const e of t.values())this.sendListen_(e);for(let t=0;t0}peek(){if(0===this.nodeStack_.length)return null;const t=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(t.key,t.value):{key:t.key,value:t.value}}}class lo{constructor(t,e,i,s,n){this.key=t,this.value=e,this.color=null!=i?i:lo.RED,this.left=null!=s?s:ho.EMPTY_NODE,this.right=null!=n?n:ho.EMPTY_NODE}copy(t,e,i,s,n){return new lo(null!=t?t:this.key,null!=e?e:this.value,null!=i?i:this.color,null!=s?s:this.left,null!=n?n:this.right)}count(){return this.left.count()+1+this.right.count()}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||!!t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min_(){return this.left.isEmpty()?this:this.left.min_()}minKey(){return this.min_().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,e,i){let s=this;const n=i(t,s.key);return s=n<0?s.copy(null,null,null,s.left.insert(t,e,i),null):0===n?s.copy(null,e,null,null,null):s.copy(null,null,null,null,s.right.insert(t,e,i)),s.fixUp_()}removeMin_(){if(this.left.isEmpty())return ho.EMPTY_NODE;let t=this;return t.left.isRed_()||t.left.left.isRed_()||(t=t.moveRedLeft_()),t=t.copy(null,null,null,t.left.removeMin_(),null),t.fixUp_()}remove(t,e){let i,s;if(i=this,e(t,i.key)<0)i.left.isEmpty()||i.left.isRed_()||i.left.left.isRed_()||(i=i.moveRedLeft_()),i=i.copy(null,null,null,i.left.remove(t,e),null);else{if(i.left.isRed_()&&(i=i.rotateRight_()),i.right.isEmpty()||i.right.isRed_()||i.right.left.isRed_()||(i=i.moveRedRight_()),0===e(t,i.key)){if(i.right.isEmpty())return ho.EMPTY_NODE;s=i.right.min_(),i=i.copy(s.key,s.value,null,null,i.right.removeMin_())}i=i.copy(null,null,null,null,i.right.remove(t,e))}return i.fixUp_()}isRed_(){return this.color}fixUp_(){let t=this;return t.right.isRed_()&&!t.left.isRed_()&&(t=t.rotateLeft_()),t.left.isRed_()&&t.left.left.isRed_()&&(t=t.rotateRight_()),t.left.isRed_()&&t.right.isRed_()&&(t=t.colorFlip_()),t}moveRedLeft_(){let t=this.colorFlip_();return t.right.left.isRed_()&&(t=t.copy(null,null,null,null,t.right.rotateRight_()),t=t.rotateLeft_(),t=t.colorFlip_()),t}moveRedRight_(){let t=this.colorFlip_();return t.left.left.isRed_()&&(t=t.rotateRight_(),t=t.colorFlip_()),t}rotateLeft_(){const t=this.copy(null,null,lo.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight_(){const t=this.copy(null,null,lo.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip_(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth_(){const t=this.check_();return Math.pow(2,t)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");const t=this.left.check_();if(t!==this.right.check_())throw new Error("Black depths differ");return t+(this.isRed_()?0:1)}}lo.RED=!0,lo.BLACK=!1;class ho{constructor(t,e=ho.EMPTY_NODE){this.comparator_=t,this.root_=e}insert(t,e){return new ho(this.comparator_,this.root_.insert(t,e,this.comparator_).copy(null,null,lo.BLACK,null,null))}remove(t){return new ho(this.comparator_,this.root_.remove(t,this.comparator_).copy(null,null,lo.BLACK,null,null))}get(t){let e,i=this.root_;for(;!i.isEmpty();){if(e=this.comparator_(t,i.key),0===e)return i.value;e<0?i=i.left:e>0&&(i=i.right)}return null}getPredecessorKey(t){let e,i=this.root_,s=null;for(;!i.isEmpty();){if(e=this.comparator_(t,i.key),0===e){if(i.left.isEmpty())return s?s.key:null;for(i=i.left;!i.right.isEmpty();)i=i.right;return i.key}e<0?i=i.left:e>0&&(s=i,i=i.right)}throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(t){return this.root_.inorderTraversal(t)}reverseTraversal(t){return this.root_.reverseTraversal(t)}getIterator(t){return new ro(this.root_,null,this.comparator_,!1,t)}getIteratorFrom(t,e){return new ro(this.root_,t,this.comparator_,!1,e)}getReverseIteratorFrom(t,e){return new ro(this.root_,t,this.comparator_,!0,e)}getReverseIterator(t){return new ro(this.root_,null,this.comparator_,!0,t)}}function co(t,e){return tn(t.name,e.name)}function Io(t,e){return tn(t,e)}let uo;ho.EMPTY_NODE=new class{copy(t,e,i,s,n){return this}insert(t,e,i){return new lo(t,e,null)}remove(t,e){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}};const po=function(t){return"number"==typeof t?"number:"+rn(t):"string:"+t},bo=function(t){if(t.isLeafNode()){const e=t.val();Yt("string"==typeof e||"number"==typeof e||"object"==typeof e&&$t(e,".sv"),"Priority must be a string or number.")}else Yt(t===uo||t.isEmpty(),"priority of unexpected type.");Yt(t===uo||t.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};let mo,yo,Lo;class Mo{constructor(t,e=Mo.__childrenNodeConstructor.EMPTY_NODE){this.value_=t,this.priorityNode_=e,this.lazyHash_=null,Yt(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),bo(this.priorityNode_)}static set __childrenNodeConstructor(t){mo=t}static get __childrenNodeConstructor(){return mo}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(t){return new Mo(this.value_,t)}getImmediateChild(t){return".priority"===t?this.priorityNode_:Mo.__childrenNodeConstructor.EMPTY_NODE}getChild(t){return Un(t)?this:".priority"===kn(t)?this.priorityNode_:Mo.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(t,e){return null}updateImmediateChild(t,e){return".priority"===t?this.updatePriority(e):e.isEmpty()&&".priority"!==t?this:Mo.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(t,e).updatePriority(this.priorityNode_)}updateChild(t,e){const i=kn(t);return null===i?e:e.isEmpty()&&".priority"!==i?this:(Yt(".priority"!==i||1===On(t),".priority must be the last token in a path"),this.updateImmediateChild(i,Mo.__childrenNodeConstructor.EMPTY_NODE.updateChild(Fn(t),e)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(t,e){return!1}val(t){return t&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(null===this.lazyHash_){let t="";this.priorityNode_.isEmpty()||(t+="priority:"+po(this.priorityNode_.val())+":");const e=typeof this.value_;t+=e+":",t+="number"===e?rn(this.value_):this.value_,this.lazyHash_=Js(t)}return this.lazyHash_}getValue(){return this.value_}compareTo(t){return t===Mo.__childrenNodeConstructor.EMPTY_NODE?1:t instanceof Mo.__childrenNodeConstructor?-1:(Yt(t.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(t))}compareToLeafNode_(t){const e=typeof t.value_,i=typeof this.value_,s=Mo.VALUE_TYPE_ORDER.indexOf(e),n=Mo.VALUE_TYPE_ORDER.indexOf(i);return Yt(s>=0,"Unknown leaf type: "+e),Yt(n>=0,"Unknown leaf type: "+i),s===n?"object"===i?0:this.value_{const n=Kt(this.indexSet_,s);if(Yt(n,"Missing index implementation for "+s),i===Co){if(n.isDefinedOn(t.node)){const i=[],s=e.getIterator(io.Wrap);let o=s.getNext();for(;o;)o.name!==t.name&&i.push(o),o=s.getNext();return i.push(t),jo(i,n.getCompare())}return Co}{const s=e.get(t.name);let n=i;return s&&(n=n.remove(new io(t.name,s))),n.insert(t,t.node)}}));return new Go(i,this.indexSet_)}removeFromIndexes(t,e){const i=ee(this.indexes_,(i=>{if(i===Co)return i;{const s=e.get(t.name);return s?i.remove(new io(t.name,s)):i}}));return new Go(i,this.indexSet_)}}let fo;class No{constructor(t,e,i){this.children_=t,this.priorityNode_=e,this.indexMap_=i,this.lazyHash_=null,this.priorityNode_&&bo(this.priorityNode_),this.children_.isEmpty()&&Yt(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}static get EMPTY_NODE(){return fo||(fo=new No(new ho(Io),null,Go.Default))}isLeafNode(){return!1}getPriority(){return this.priorityNode_||fo}updatePriority(t){return this.children_.isEmpty()?this:new No(this.children_,t,this.indexMap_)}getImmediateChild(t){if(".priority"===t)return this.getPriority();{const e=this.children_.get(t);return null===e?fo:e}}getChild(t){const e=kn(t);return null===e?this:this.getImmediateChild(e).getChild(Fn(t))}hasChild(t){return null!==this.children_.get(t)}updateImmediateChild(t,e){if(Yt(e,"We should always be passing snapshot nodes"),".priority"===t)return this.updatePriority(e);{const i=new io(t,e);let s,n;e.isEmpty()?(s=this.children_.remove(t),n=this.indexMap_.removeFromIndexes(i,this.children_)):(s=this.children_.insert(t,e),n=this.indexMap_.addToIndexes(i,this.children_));const o=s.isEmpty()?fo:this.priorityNode_;return new No(s,o,n)}}updateChild(t,e){const i=kn(t);if(null===i)return e;{Yt(".priority"!==kn(t)||1===On(t),".priority must be the last token in a path");const s=this.getImmediateChild(i).updateChild(Fn(t),e);return this.updateImmediateChild(i,s)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(t){if(this.isEmpty())return null;const e={};let i=0,s=0,n=!0;if(this.forEachChild(Wo,((o,a)=>{e[o]=a.val(t),i++,n&&No.INTEGER_REGEXP_.test(o)?s=Math.max(s,Number(o)):n=!1})),!t&&n&&s<2*i){const t=[];for(const i in e)t[i]=e[i];return t}return t&&!this.getPriority().isEmpty()&&(e[".priority"]=this.getPriority().val()),e}hash(){if(null===this.lazyHash_){let t="";this.getPriority().isEmpty()||(t+="priority:"+po(this.getPriority().val())+":"),this.forEachChild(Wo,((e,i)=>{const s=i.hash();""!==s&&(t+=":"+e+":"+s)})),this.lazyHash_=""===t?"":Js(t)}return this.lazyHash_}getPredecessorChildName(t,e,i){const s=this.resolveIndex_(i);if(s){const i=s.getPredecessorKey(new io(t,e));return i?i.name:null}return this.children_.getPredecessorKey(t)}getFirstChildName(t){const e=this.resolveIndex_(t);if(e){const t=e.minKey();return t&&t.name}return this.children_.minKey()}getFirstChild(t){const e=this.getFirstChildName(t);return e?new io(e,this.children_.get(e)):null}getLastChildName(t){const e=this.resolveIndex_(t);if(e){const t=e.maxKey();return t&&t.name}return this.children_.maxKey()}getLastChild(t){const e=this.getLastChildName(t);return e?new io(e,this.children_.get(e)):null}forEachChild(t,e){const i=this.resolveIndex_(t);return i?i.inorderTraversal((t=>e(t.name,t.node))):this.children_.inorderTraversal(e)}getIterator(t){return this.getIteratorFrom(t.minPost(),t)}getIteratorFrom(t,e){const i=this.resolveIndex_(e);if(i)return i.getIteratorFrom(t,(t=>t));{const i=this.children_.getIteratorFrom(t.name,io.Wrap);let s=i.peek();for(;null!=s&&e.compare(s,t)<0;)i.getNext(),s=i.peek();return i}}getReverseIterator(t){return this.getReverseIteratorFrom(t.maxPost(),t)}getReverseIteratorFrom(t,e){const i=this.resolveIndex_(e);if(i)return i.getReverseIteratorFrom(t,(t=>t));{const i=this.children_.getReverseIteratorFrom(t.name,io.Wrap);let s=i.peek();for(;null!=s&&e.compare(s,t)>0;)i.getNext(),s=i.peek();return i}}compareTo(t){return this.isEmpty()?t.isEmpty()?0:-1:t.isLeafNode()||t.isEmpty()?1:t===xo?-1:0}withIndex(t){if(t===ao||this.indexMap_.hasIndex(t))return this;{const e=this.indexMap_.addIndex(t,this.children_);return new No(this.children_,this.priorityNode_,e)}}isIndexed(t){return t===ao||this.indexMap_.hasIndex(t)}equals(t){if(t===this)return!0;if(t.isLeafNode())return!1;{const e=t;if(this.getPriority().equals(e.getPriority())){if(this.children_.count()===e.children_.count()){const t=this.getIterator(Wo),i=e.getIterator(Wo);let s=t.getNext(),n=i.getNext();for(;s&&n;){if(s.name!==n.name||!s.node.equals(n.node))return!1;s=t.getNext(),n=i.getNext()}return null===s&&null===n}return!1}return!1}}resolveIndex_(t){return t===ao?null:this.indexMap_.get(t.toString())}}No.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;const xo=new class extends No{constructor(){super(new ho(Io),No.EMPTY_NODE,Go.Default)}compareTo(t){return t===this?0:1}equals(t){return t===this}getPriority(){return this}getImmediateChild(t){return No.EMPTY_NODE}isEmpty(){return!1}};Object.defineProperties(io,{MIN:{value:new io($s,No.EMPTY_NODE)},MAX:{value:new io(Ks,xo)}}),oo.__EMPTY_NODE=No.EMPTY_NODE,Mo.__childrenNodeConstructor=No,uo=xo,Lo=xo;const Yo=!0;function Ro(t,e=null){if(null===t)return No.EMPTY_NODE;if("object"==typeof t&&".priority"in t&&(e=t[".priority"]),Yt(null===e||"string"==typeof e||"number"==typeof e||"object"==typeof e&&".sv"in e,"Invalid priority type found: "+typeof e),"object"==typeof t&&".value"in t&&null!==t[".value"]&&(t=t[".value"]),"object"!=typeof t||".sv"in t)return new Mo(t,Ro(e));if(t instanceof Array||!Yo){let i=No.EMPTY_NODE;return an(t,((e,s)=>{if($t(t,e)&&"."!==e.substring(0,1)){const t=Ro(s);!t.isLeafNode()&&t.isEmpty()||(i=i.updateImmediateChild(e,t))}})),i.updatePriority(Ro(e))}{const i=[];let s=!1;if(an(t,((t,e)=>{if("."!==t.substring(0,1)){const n=Ro(e);n.isEmpty()||(s=s||!n.getPriority().isEmpty(),i.push(new io(t,n)))}})),0===i.length)return No.EMPTY_NODE;const n=jo(i,co,(t=>t.name),Io);if(s){const t=jo(i,Wo.getCompare());return new No(n,Ro(e),new Go({".priority":t},{".priority":Wo}))}return new No(n,Ro(e),Go.Default)}}!function(t){yo=t}(Ro);class Ho extends so{constructor(t){super(),this.indexPath_=t,Yt(!Un(t)&&".priority"!==kn(t),"Can't create PathIndex with empty path or .priority key")}extractChild(t){return t.getChild(this.indexPath_)}isDefinedOn(t){return!t.getChild(this.indexPath_).isEmpty()}compare(t,e){const i=this.extractChild(t.node),s=this.extractChild(e.node),n=i.compareTo(s);return 0===n?tn(t.name,e.name):n}makePost(t,e){const i=Ro(t),s=No.EMPTY_NODE.updateChild(this.indexPath_,i);return new io(e,s)}maxPost(){const t=No.EMPTY_NODE.updateChild(this.indexPath_,xo);return new io(Ks,t)}toString(){return Xn(this.indexPath_,0).join("/")}}const go=new class extends so{compare(t,e){const i=t.node.compareTo(e.node);return 0===i?tn(t.name,e.name):i}isDefinedOn(t){return!0}indexedValueChanged(t,e){return!t.equals(e)}minPost(){return io.MIN}maxPost(){return io.MAX}makePost(t,e){const i=Ro(t);return new io(e,i)}toString(){return".value"}};function Ao(t){return{type:"value",snapshotNode:t}}function So(t,e){return{type:"child_added",snapshotNode:e,childName:t}}function zo(t,e){return{type:"child_removed",snapshotNode:e,childName:t}}function Vo(t,e,i){return{type:"child_changed",snapshotNode:e,childName:t,oldSnap:i}}class To{constructor(t){this.index_=t}updateChild(t,e,i,s,n,o){Yt(t.isIndexed(this.index_),"A node must be indexed if only a child is updated");const a=t.getImmediateChild(e);return a.getChild(s).equals(i.getChild(s))&&a.isEmpty()===i.isEmpty()?t:(null!=o&&(i.isEmpty()?t.hasChild(e)?o.trackChildChange(zo(e,a)):Yt(t.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(So(e,i)):o.trackChildChange(Vo(e,i,a))),t.isLeafNode()&&i.isEmpty()?t:t.updateImmediateChild(e,i).withIndex(this.index_))}updateFullNode(t,e,i){return null!=i&&(t.isLeafNode()||t.forEachChild(Wo,((t,s)=>{e.hasChild(t)||i.trackChildChange(zo(t,s))})),e.isLeafNode()||e.forEachChild(Wo,((e,s)=>{if(t.hasChild(e)){const n=t.getImmediateChild(e);n.equals(s)||i.trackChildChange(Vo(e,s,n))}else i.trackChildChange(So(e,s))}))),e.withIndex(this.index_)}updatePriority(t,e){return t.isEmpty()?No.EMPTY_NODE:t.updatePriority(e)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}class ko{constructor(t){this.indexedFilter_=new To(t.getIndex()),this.index_=t.getIndex(),this.startPost_=ko.getStartPost_(t),this.endPost_=ko.getEndPost_(t),this.startIsInclusive_=!t.startAfterSet_,this.endIsInclusive_=!t.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(t){const e=this.startIsInclusive_?this.index_.compare(this.getStartPost(),t)<=0:this.index_.compare(this.getStartPost(),t)<0,i=this.endIsInclusive_?this.index_.compare(t,this.getEndPost())<=0:this.index_.compare(t,this.getEndPost())<0;return e&&i}updateChild(t,e,i,s,n,o){return this.matches(new io(e,i))||(i=No.EMPTY_NODE),this.indexedFilter_.updateChild(t,e,i,s,n,o)}updateFullNode(t,e,i){e.isLeafNode()&&(e=No.EMPTY_NODE);let s=e.withIndex(this.index_);s=s.updatePriority(No.EMPTY_NODE);const n=this;return e.forEachChild(Wo,((t,e)=>{n.matches(new io(t,e))||(s=s.updateImmediateChild(t,No.EMPTY_NODE))})),this.indexedFilter_.updateFullNode(t,s,i)}updatePriority(t,e){return t}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(t){if(t.hasStart()){const e=t.getIndexStartName();return t.getIndex().makePost(t.getIndexStartValue(),e)}return t.getIndex().minPost()}static getEndPost_(t){if(t.hasEnd()){const e=t.getIndexEndName();return t.getIndex().makePost(t.getIndexEndValue(),e)}return t.getIndex().maxPost()}}class Oo{constructor(t){this.withinDirectionalStart=t=>this.reverse_?this.withinEndPost(t):this.withinStartPost(t),this.withinDirectionalEnd=t=>this.reverse_?this.withinStartPost(t):this.withinEndPost(t),this.withinStartPost=t=>{const e=this.index_.compare(this.rangedFilter_.getStartPost(),t);return this.startIsInclusive_?e<=0:e<0},this.withinEndPost=t=>{const e=this.index_.compare(t,this.rangedFilter_.getEndPost());return this.endIsInclusive_?e<=0:e<0},this.rangedFilter_=new ko(t),this.index_=t.getIndex(),this.limit_=t.getLimit(),this.reverse_=!t.isViewFromLeft(),this.startIsInclusive_=!t.startAfterSet_,this.endIsInclusive_=!t.endBeforeSet_}updateChild(t,e,i,s,n,o){return this.rangedFilter_.matches(new io(e,i))||(i=No.EMPTY_NODE),t.getImmediateChild(e).equals(i)?t:t.numChildren()t(i,e)}else o=this.index_.getCompare();const a=t;Yt(a.numChildren()===this.limit_,"");const r=new io(e,i),l=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),h=this.rangedFilter_.matches(r);if(a.hasChild(e)){const t=a.getImmediateChild(e);let c=s.getChildAfterChild(this.index_,l,this.reverse_);for(;null!=c&&(c.name===e||a.hasChild(c.name));)c=s.getChildAfterChild(this.index_,c,this.reverse_);const d=null==c?1:o(c,r);if(h&&!i.isEmpty()&&d>=0)return null!=n&&n.trackChildChange(Vo(e,i,t)),a.updateImmediateChild(e,i);{null!=n&&n.trackChildChange(zo(e,t));const i=a.updateImmediateChild(e,No.EMPTY_NODE);return null!=c&&this.rangedFilter_.matches(c)?(null!=n&&n.trackChildChange(So(c.name,c.node)),i.updateImmediateChild(c.name,c.node)):i}}return i.isEmpty()?t:h&&o(l,r)>=0?(null!=n&&(n.trackChildChange(zo(l.name,l.node)),n.trackChildChange(So(e,i))),a.updateImmediateChild(e,i).updateImmediateChild(l.name,No.EMPTY_NODE)):t}}class Fo{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=Wo}hasStart(){return this.startSet_}isViewFromLeft(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_}getIndexStartValue(){return Yt(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return Yt(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:$s}hasEnd(){return this.endSet_}getIndexEndValue(){return Yt(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return Yt(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:Ks}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&""!==this.viewFrom_}getLimit(){return Yt(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===Wo}copy(){const t=new Fo;return t.limitSet_=this.limitSet_,t.limit_=this.limit_,t.startSet_=this.startSet_,t.startAfterSet_=this.startAfterSet_,t.indexStartValue_=this.indexStartValue_,t.startNameSet_=this.startNameSet_,t.indexStartName_=this.indexStartName_,t.endSet_=this.endSet_,t.endBeforeSet_=this.endBeforeSet_,t.indexEndValue_=this.indexEndValue_,t.endNameSet_=this.endNameSet_,t.indexEndName_=this.indexEndName_,t.index_=this.index_,t.viewFrom_=this.viewFrom_,t}}function Jo(t){const e={};if(t.isDefault())return e;let i;if(t.index_===Wo?i="$priority":t.index_===go?i="$value":t.index_===ao?i="$key":(Yt(t.index_ instanceof Ho,"Unrecognized index type!"),i=t.index_.toString()),e.orderBy=Qt(i),t.startSet_){const i=t.startAfterSet_?"startAfter":"startAt";e[i]=Qt(t.indexStartValue_),t.startNameSet_&&(e[i]+=","+Qt(t.indexStartName_))}if(t.endSet_){const i=t.endBeforeSet_?"endBefore":"endAt";e[i]=Qt(t.indexEndValue_),t.endNameSet_&&(e[i]+=","+Qt(t.indexEndName_))}return t.limitSet_&&(t.isViewFromLeft()?e.limitToFirst=t.limit_:e.limitToLast=t.limit_),e}function Xo(t){const e={};if(t.startSet_&&(e.sp=t.indexStartValue_,t.startNameSet_&&(e.sn=t.indexStartName_),e.sin=!t.startAfterSet_),t.endSet_&&(e.ep=t.indexEndValue_,t.endNameSet_&&(e.en=t.indexEndName_),e.ein=!t.endBeforeSet_),t.limitSet_){e.l=t.limit_;let i=t.viewFrom_;""===i&&(i=t.isViewFromLeft()?"l":"r"),e.vf=i}return t.index_!==Wo&&(e.i=t.index_.toString()),e}class Eo extends An{constructor(t,e,i,s){super(),this.repoInfo_=t,this.onDataUpdate_=e,this.authTokenProvider_=i,this.appCheckTokenProvider_=s,this.log_=Bs("p:rest:"),this.listens_={}}reportStats(t){throw new Error("Method not implemented.")}static getListenId_(t,e){return void 0!==e?"tag$"+e:(Yt(t._queryParams.isDefault(),"should have a tag if it's not a default query."),t._path.toString())}listen(t,e,i,s){const n=t._path.toString();this.log_("Listen called for "+n+" "+t._queryIdentifier);const o=Eo.getListenId_(t,i),a={};this.listens_[o]=a;const r=Jo(t._queryParams);this.restRequest_(n+".json",r,((t,e)=>{let r=e;if(404===t&&(r=null,t=null),null===t&&this.onDataUpdate_(n,r,!1,i),Kt(this.listens_,o)===a){let e;e=t?401===t?"permission_denied":"rest_error:"+t:"ok",s(e,null)}}))}unlisten(t,e){const i=Eo.getListenId_(t,e);delete this.listens_[i]}get(t){const e=Jo(t._queryParams),i=t._path.toString(),s=new Jt;return this.restRequest_(i+".json",e,((t,e)=>{let n=e;404===t&&(n=null,t=null),null===t?(this.onDataUpdate_(i,n,!1,null),s.resolve(n)):s.reject(new Error(n))})),s.promise}refreshAuthToken(t){}restRequest_(t,e={},i){return e.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then((([s,n])=>{s&&s.accessToken&&(e.auth=s.accessToken),n&&n.token&&(e.ac=n.token);const o=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+t+"?ns="+this.repoInfo_.namespace+function(t){const e=[];for(const[i,s]of Object.entries(t))Array.isArray(s)?s.forEach((t=>{e.push(encodeURIComponent(i)+"="+encodeURIComponent(t))})):e.push(encodeURIComponent(i)+"="+encodeURIComponent(s));return e.length?"&"+e.join("&"):""}(e);this.log_("Sending REST request for "+o);const a=new XMLHttpRequest;a.onreadystatechange=()=>{if(i&&4===a.readyState){this.log_("REST Response for "+o+" received. status:",a.status,"response:",a.responseText);let t=null;if(a.status>=200&&a.status<300){try{t=_t(a.responseText)}catch(t){Qs("Failed to parse JSON response for "+o+": "+a.responseText)}i(null,t)}else 401!==a.status&&404!==a.status&&Qs("Got unsuccessful REST response for "+o+" Status: "+a.status),i(a.status);i=null}},a.open("GET",o,!0),a.send()}))}}class Do{constructor(){this.rootNode_=No.EMPTY_NODE}getNode(t){return this.rootNode_.getChild(t)}updateSnapshot(t,e){this.rootNode_=this.rootNode_.updateChild(t,e)}}function Uo(){return{value:null,children:new Map}}function Bo(t,e,i){if(Un(e))t.value=i,t.children.clear();else if(null!==t.value)t.value=t.value.updateChild(e,i);else{const s=kn(e);t.children.has(s)||t.children.set(s,Uo()),Bo(t.children.get(s),e=Fn(e),i)}}function Po(t,e,i){null!==t.value?i(e,t.value):function(t,e){t.children.forEach(((t,i)=>{e(i,t)}))}(t,((t,s)=>{Po(s,new Vn(e.toString()+"/"+t),i)}))}class _o{constructor(t){this.collection_=t,this.last_=null}get(){const t=this.collection_.get(),e=Object.assign({},t);return this.last_&&an(this.last_,((t,i)=>{e[t]=e[t]-i})),this.last_=t,e}}class Qo{constructor(t,e){this.server_=e,this.statsToReport_={},this.statsListener_=new _o(t);const i=1e4+2e4*Math.random();dn(this.reportStats_.bind(this),Math.floor(i))}reportStats_(){const t=this.statsListener_.get(),e={};let i=!1;an(t,((t,s)=>{s>0&&$t(this.statsToReport_,t)&&(e[t]=s,i=!0)})),i&&this.server_.reportStats(e),dn(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))}}var qo;function $o(t){return{fromUser:!1,fromServer:!0,queryId:t,tagged:!0}}!function(t){t[t.OVERWRITE=0]="OVERWRITE",t[t.MERGE=1]="MERGE",t[t.ACK_USER_WRITE=2]="ACK_USER_WRITE",t[t.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(qo||(qo={}));class Ko{constructor(t,e,i){this.path=t,this.affectedTree=e,this.revert=i,this.type=qo.ACK_USER_WRITE,this.source={fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}operationForChild(t){if(Un(this.path)){if(null!=this.affectedTree.value)return Yt(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const e=this.affectedTree.subtree(new Vn(t));return new Ko(Tn(),e,this.revert)}}return Yt(kn(this.path)===t,"operationForChild called for unrelated child."),new Ko(Fn(this.path),this.affectedTree,this.revert)}}class ta{constructor(t,e){this.source=t,this.path=e,this.type=qo.LISTEN_COMPLETE}operationForChild(t){return Un(this.path)?new ta(this.source,Tn()):new ta(this.source,Fn(this.path))}}class ea{constructor(t,e,i){this.source=t,this.path=e,this.snap=i,this.type=qo.OVERWRITE}operationForChild(t){return Un(this.path)?new ea(this.source,Tn(),this.snap.getImmediateChild(t)):new ea(this.source,Fn(this.path),this.snap)}}class ia{constructor(t,e,i){this.source=t,this.path=e,this.children=i,this.type=qo.MERGE}operationForChild(t){if(Un(this.path)){const e=this.children.subtree(new Vn(t));return e.isEmpty()?null:e.value?new ea(this.source,Tn(),e.value):new ia(this.source,Tn(),e)}return Yt(kn(this.path)===t,"Can't get a merge for a child not on the path of the operation"),new ia(this.source,Fn(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}class sa{constructor(t,e,i){this.node_=t,this.fullyInitialized_=e,this.filtered_=i}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(t){if(Un(t))return this.isFullyInitialized()&&!this.filtered_;const e=kn(t);return this.isCompleteForChild(e)}isCompleteForChild(t){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(t)}getNode(){return this.node_}}class na{constructor(t){this.query_=t,this.index_=this.query_._queryParams.getIndex()}}function oa(t,e,i,s,n,o){const a=s.filter((t=>t.type===i));a.sort(((e,i)=>function(t,e,i){if(null==e.childName||null==i.childName)throw Rt("Should only compare child_ events.");const s=new io(e.childName,e.snapshotNode),n=new io(i.childName,i.snapshotNode);return t.index_.compare(s,n)}(t,e,i))),a.forEach((i=>{const s=function(t,e,i){return"value"===e.type||"child_removed"===e.type||(e.prevName=i.getPredecessorChildName(e.childName,e.snapshotNode,t.index_)),e}(t,i,o);n.forEach((n=>{n.respondsTo(i.type)&&e.push(n.createEvent(s,t.query_))}))}))}function aa(t,e){return{eventCache:t,serverCache:e}}function ra(t,e,i,s){return aa(new sa(e,i,s),t.serverCache)}function la(t,e,i,s){return aa(t.eventCache,new sa(e,i,s))}function ha(t){return t.eventCache.isFullyInitialized()?t.eventCache.getNode():null}function ca(t){return t.serverCache.isFullyInitialized()?t.serverCache.getNode():null}let da;class Ia{constructor(t,e=(()=>(da||(da=new ho(en)),da))()){this.value=t,this.children=e}static fromObject(t){let e=new Ia(null);return an(t,((t,i)=>{e=e.set(new Vn(t),i)})),e}isEmpty(){return null===this.value&&this.children.isEmpty()}findRootMostMatchingPathAndValue(t,e){if(null!=this.value&&e(this.value))return{path:Tn(),value:this.value};if(Un(t))return null;{const i=kn(t),s=this.children.get(i);if(null!==s){const n=s.findRootMostMatchingPathAndValue(Fn(t),e);return null!=n?{path:Dn(new Vn(i),n.path),value:n.value}:null}return null}}findRootMostValueAndPath(t){return this.findRootMostMatchingPathAndValue(t,(()=>!0))}subtree(t){if(Un(t))return this;{const e=kn(t),i=this.children.get(e);return null!==i?i.subtree(Fn(t)):new Ia(null)}}set(t,e){if(Un(t))return new Ia(e,this.children);{const i=kn(t),s=(this.children.get(i)||new Ia(null)).set(Fn(t),e),n=this.children.insert(i,s);return new Ia(this.value,n)}}remove(t){if(Un(t))return this.children.isEmpty()?new Ia(null):new Ia(null,this.children);{const e=kn(t),i=this.children.get(e);if(i){const s=i.remove(Fn(t));let n;return n=s.isEmpty()?this.children.remove(e):this.children.insert(e,s),null===this.value&&n.isEmpty()?new Ia(null):new Ia(this.value,n)}return this}}get(t){if(Un(t))return this.value;{const e=kn(t),i=this.children.get(e);return i?i.get(Fn(t)):null}}setTree(t,e){if(Un(t))return e;{const i=kn(t),s=(this.children.get(i)||new Ia(null)).setTree(Fn(t),e);let n;return n=s.isEmpty()?this.children.remove(i):this.children.insert(i,s),new Ia(this.value,n)}}fold(t){return this.fold_(Tn(),t)}fold_(t,e){const i={};return this.children.inorderTraversal(((s,n)=>{i[s]=n.fold_(Dn(t,s),e)})),e(t,this.value,i)}findOnPath(t,e){return this.findOnPath_(t,Tn(),e)}findOnPath_(t,e,i){const s=!!this.value&&i(e,this.value);if(s)return s;if(Un(t))return null;{const s=kn(t),n=this.children.get(s);return n?n.findOnPath_(Fn(t),Dn(e,s),i):null}}foreachOnPath(t,e){return this.foreachOnPath_(t,Tn(),e)}foreachOnPath_(t,e,i){if(Un(t))return this;{this.value&&i(e,this.value);const s=kn(t),n=this.children.get(s);return n?n.foreachOnPath_(Fn(t),Dn(e,s),i):new Ia(null)}}foreach(t){this.foreach_(Tn(),t)}foreach_(t,e){this.children.inorderTraversal(((i,s)=>{s.foreach_(Dn(t,i),e)})),this.value&&e(t,this.value)}foreachChild(t){this.children.inorderTraversal(((e,i)=>{i.value&&t(e,i.value)}))}}class ua{constructor(t){this.writeTree_=t}static empty(){return new ua(new Ia(null))}}function pa(t,e,i){if(Un(e))return new ua(new Ia(i));{const s=t.writeTree_.findRootMostValueAndPath(e);if(null!=s){const n=s.path;let o=s.value;const a=Bn(n,e);return o=o.updateChild(a,i),new ua(t.writeTree_.set(n,o))}{const s=new Ia(i),n=t.writeTree_.setTree(e,s);return new ua(n)}}}function ba(t,e,i){let s=t;return an(i,((t,i)=>{s=pa(s,Dn(e,t),i)})),s}function ma(t,e){if(Un(e))return ua.empty();{const i=t.writeTree_.setTree(e,new Ia(null));return new ua(i)}}function ya(t,e){return null!=La(t,e)}function La(t,e){const i=t.writeTree_.findRootMostValueAndPath(e);return null!=i?t.writeTree_.get(i.path).getChild(Bn(i.path,e)):null}function Ma(t){const e=[],i=t.writeTree_.value;return null!=i?i.isLeafNode()||i.forEachChild(Wo,((t,i)=>{e.push(new io(t,i))})):t.writeTree_.children.inorderTraversal(((t,i)=>{null!=i.value&&e.push(new io(t,i.value))})),e}function Wa(t,e){if(Un(e))return t;{const i=La(t,e);return new ua(null!=i?new Ia(i):t.writeTree_.subtree(e))}}function wa(t){return t.writeTree_.isEmpty()}function va(t,e){return ja(Tn(),t.writeTree_,e)}function ja(t,e,i){if(null!=e.value)return i.updateChild(t,e.value);{let s=null;return e.children.inorderTraversal(((e,n)=>{".priority"===e?(Yt(null!==n.value,"Priority writes must always be leaf nodes"),s=n.value):i=ja(Dn(t,e),n,i)})),i.getChild(t).isEmpty()||null===s||(i=i.updateChild(Dn(t,".priority"),s)),i}}function Za(t,e){return Sa(e,t)}function Ca(t,e){if(t.snap)return _n(t.path,e);for(const i in t.children)if(t.children.hasOwnProperty(i)&&_n(Dn(t.path,i),e))return!0;return!1}function Ga(t){return t.visible}function fa(t,e,i){let s=ua.empty();for(let n=0;n{s=s.updateImmediateChild(t,e)})),s;if(i){const n=Wa(t.visibleWrites,e);return i.forEachChild(Wo,((t,e)=>{const i=va(Wa(n,new Vn(t)),e);s=s.updateImmediateChild(t,i)})),Ma(n).forEach((t=>{s=s.updateImmediateChild(t.name,t.node)})),s}return Ma(Wa(t.visibleWrites,e)).forEach((t=>{s=s.updateImmediateChild(t.name,t.node)})),s}(t.writeTree,t.treePath,e)}function Ra(t,e,i,s){return function(t,e,i,s,n){Yt(s||n,"Either existingEventSnap or existingServerSnap must exist");const o=Dn(e,i);if(ya(t.visibleWrites,o))return null;{const e=Wa(t.visibleWrites,o);return wa(e)?n.getChild(i):va(e,n.getChild(i))}}(t.writeTree,t.treePath,e,i,s)}function Ha(t,e){return function(t,e){return La(t.visibleWrites,e)}(t.writeTree,Dn(t.treePath,e))}function ga(t,e,i){return function(t,e,i,s){const n=Dn(e,i),o=La(t.visibleWrites,n);return null!=o?o:s.isCompleteForChild(i)?va(Wa(t.visibleWrites,n),s.getNode().getImmediateChild(i)):null}(t.writeTree,t.treePath,e,i)}function Aa(t,e){return Sa(Dn(t.treePath,e),t.writeTree)}function Sa(t,e){return{treePath:t,writeTree:e}}class za{constructor(){this.changeMap=new Map}trackChildChange(t){const e=t.type,i=t.childName;Yt("child_added"===e||"child_changed"===e||"child_removed"===e,"Only child changes supported for tracking"),Yt(".priority"!==i,"Only non-priority child changes can be tracked.");const s=this.changeMap.get(i);if(s){const n=s.type;if("child_added"===e&&"child_removed"===n)this.changeMap.set(i,Vo(i,t.snapshotNode,s.snapshotNode));else if("child_removed"===e&&"child_added"===n)this.changeMap.delete(i);else if("child_removed"===e&&"child_changed"===n)this.changeMap.set(i,zo(i,s.oldSnap));else if("child_changed"===e&&"child_added"===n)this.changeMap.set(i,So(i,t.snapshotNode));else{if("child_changed"!==e||"child_changed"!==n)throw Rt("Illegal combination of changes: "+t+" occurred after "+s);this.changeMap.set(i,Vo(i,t.snapshotNode,s.oldSnap))}}else this.changeMap.set(i,t)}getChanges(){return Array.from(this.changeMap.values())}}const Va=new class{getCompleteChild(t){return null}getChildAfterChild(t,e,i){return null}};class Ta{constructor(t,e,i=null){this.writes_=t,this.viewCache_=e,this.optCompleteServerCache_=i}getCompleteChild(t){const e=this.viewCache_.eventCache;if(e.isCompleteForChild(t))return e.getNode().getImmediateChild(t);{const e=null!=this.optCompleteServerCache_?new sa(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return ga(this.writes_,t,e)}}getChildAfterChild(t,e,i){const s=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:ca(this.viewCache_),n=function(t,e,i,s,n,o){return function(t,e,i,s,n,o,a){let r;const l=Wa(t.visibleWrites,e),h=La(l,Tn());if(null!=h)r=h;else{if(null==i)return[];r=va(l,i)}if(r=r.withIndex(a),r.isEmpty()||r.isLeafNode())return[];{const t=[],e=a.getCompare(),i=o?r.getReverseIteratorFrom(s,a):r.getIteratorFrom(s,a);let l=i.getNext();for(;l&&t.length1)return e;const n=Fn(i),o=l.getNode().getImmediateChild(t).updateChild(n,s);h=".priority"===t?c.updatePriority(l.getNode(),o):c.updateChild(l.getNode(),t,o,n,Va,null)}const d=la(e,h,l.isFullyInitialized()||Un(i),c.filtersNodes());return ka(t,d,i,n,new Ta(n,d,o),r)}function Fa(t,e,i,s,n,o,a){const r=e.eventCache;let l,h;const c=new Ta(n,e,o);if(Un(i))h=t.filter.updateFullNode(e.eventCache.getNode(),s,a),l=ra(e,h,!0,t.filter.filtersNodes());else{const n=kn(i);if(".priority"===n)h=t.filter.updatePriority(e.eventCache.getNode(),s),l=ra(e,h,r.isFullyInitialized(),r.isFiltered());else{const o=Fn(i),h=r.getNode().getImmediateChild(n);let d;if(Un(o))d=s;else{const t=c.getCompleteChild(n);d=null!=t?".priority"===Jn(o)&&t.getChild(En(o)).isEmpty()?t:t.updateChild(o,s):No.EMPTY_NODE}l=h.equals(d)?e:ra(e,t.filter.updateChild(r.getNode(),n,d,o,c,a),r.isFullyInitialized(),t.filter.filtersNodes())}}return l}function Ja(t,e){return t.eventCache.isCompleteForChild(e)}function Xa(t,e,i){return i.foreach(((t,i)=>{e=e.updateChild(t,i)})),e}function Ea(t,e,i,s,n,o,a,r){if(e.serverCache.getNode().isEmpty()&&!e.serverCache.isFullyInitialized())return e;let l,h=e;l=Un(i)?s:new Ia(null).setTree(i,s);const c=e.serverCache.getNode();return l.children.inorderTraversal(((i,s)=>{if(c.hasChild(i)){const l=Xa(0,e.serverCache.getNode().getImmediateChild(i),s);h=Oa(t,h,new Vn(i),l,n,o,a,r)}})),l.children.inorderTraversal(((i,s)=>{const l=!e.serverCache.isCompleteForChild(i)&&null===s.value;if(!c.hasChild(i)&&!l){const l=Xa(0,e.serverCache.getNode().getImmediateChild(i),s);h=Oa(t,h,new Vn(i),l,n,o,a,r)}})),h}class Da{constructor(t,e){this.query_=t,this.eventRegistrations_=[];const i=this.query_._queryParams,s=new To(i.getIndex()),n=(o=i).loadsAllData()?new To(o.getIndex()):o.hasLimit()?new Oo(o):new ko(o);var o;this.processor_=function(t){return{filter:t}}(n);const a=e.serverCache,r=e.eventCache,l=s.updateFullNode(No.EMPTY_NODE,a.getNode(),null),h=n.updateFullNode(No.EMPTY_NODE,r.getNode(),null),c=new sa(l,a.isFullyInitialized(),s.filtersNodes()),d=new sa(h,r.isFullyInitialized(),n.filtersNodes());this.viewCache_=aa(d,c),this.eventGenerator_=new na(this.query_)}get query(){return this.query_}}function Ua(t,e){const i=ca(t.viewCache_);return i&&(t.query._queryParams.loadsAllData()||!Un(e)&&!i.getImmediateChild(kn(e)).isEmpty())?i.getChild(e):null}function Ba(t){return 0===t.eventRegistrations_.length}function Pa(t,e,i){const s=[];if(i){Yt(null==e,"A cancel should cancel all event registrations.");const n=t.query._path;t.eventRegistrations_.forEach((t=>{const e=t.createCancelEvent(i,n);e&&s.push(e)}))}if(e){let i=[];for(let s=0;s{const h=Dn(i,s);Ja(e,kn(h))&&(r=Fa(t,r,h,l,n,o,a))})),s.foreach(((s,l)=>{const h=Dn(i,s);Ja(e,kn(h))||(r=Fa(t,r,h,l,n,o,a))})),r}(t,e,l.path,l.children,s,n,o):(Yt(l.source.fromServer,"Unknown source."),r=l.source.tagged||e.serverCache.isFiltered(),a=Ea(t,e,l.path,l.children,s,n,r,o))}else if(i.type===qo.ACK_USER_WRITE){const r=i;a=r.revert?function(t,e,i,s,n,o){let a;if(null!=Ha(s,i))return e;{const r=new Ta(s,e,n),l=e.eventCache.getNode();let h;if(Un(i)||".priority"===kn(i)){let i;if(e.serverCache.isFullyInitialized())i=xa(s,ca(e));else{const t=e.serverCache.getNode();Yt(t instanceof No,"serverChildren would be complete if leaf node"),i=Ya(s,t)}h=t.filter.updateFullNode(l,i,o)}else{const n=kn(i);let c=ga(s,n,e.serverCache);null==c&&e.serverCache.isCompleteForChild(n)&&(c=l.getImmediateChild(n)),h=null!=c?t.filter.updateChild(l,n,c,Fn(i),r,o):e.eventCache.getNode().hasChild(n)?t.filter.updateChild(l,n,No.EMPTY_NODE,Fn(i),r,o):l,h.isEmpty()&&e.serverCache.isFullyInitialized()&&(a=xa(s,ca(e)),a.isLeafNode()&&(h=t.filter.updateFullNode(h,a,o)))}return a=e.serverCache.isFullyInitialized()||null!=Ha(s,Tn()),ra(e,h,a,t.filter.filtersNodes())}}(t,e,r.path,s,n,o):function(t,e,i,s,n,o,a){if(null!=Ha(n,i))return e;const r=e.serverCache.isFiltered(),l=e.serverCache;if(null!=s.value){if(Un(i)&&l.isFullyInitialized()||l.isCompleteForPath(i))return Oa(t,e,i,l.getNode().getChild(i),n,o,r,a);if(Un(i)){let s=new Ia(null);return l.getNode().forEachChild(ao,((t,e)=>{s=s.set(new Vn(t),e)})),Ea(t,e,i,s,n,o,r,a)}return e}{let h=new Ia(null);return s.foreach(((t,e)=>{const s=Dn(i,t);l.isCompleteForPath(s)&&(h=h.set(t,l.getNode().getChild(s)))})),Ea(t,e,i,h,n,o,r,a)}}(t,e,r.path,r.affectedTree,s,n,o)}else{if(i.type!==qo.LISTEN_COMPLETE)throw Rt("Unknown operation type: "+i.type);a=function(t,e,i,s,n){const o=e.serverCache;return ka(t,la(e,o.getNode(),o.isFullyInitialized()||Un(i),o.isFiltered()),i,s,Va,n)}(t,e,i.path,s,o)}const l=o.getChanges();return function(t,e,i){const s=e.eventCache;if(s.isFullyInitialized()){const n=s.getNode().isLeafNode()||s.getNode().isEmpty(),o=ha(t);(i.length>0||!t.eventCache.isFullyInitialized()||n&&!s.getNode().equals(o)||!s.getNode().getPriority().equals(o.getPriority()))&&i.push(Ao(ha(e)))}}(e,a,l),{viewCache:a,changes:l}}(t.processor_,n,e,i,s);var a,r;return a=t.processor_,r=o.viewCache,Yt(r.eventCache.getNode().isIndexed(a.filter.getIndex()),"Event snap not indexed"),Yt(r.serverCache.getNode().isIndexed(a.filter.getIndex()),"Server snap not indexed"),Yt(o.viewCache.serverCache.isFullyInitialized()||!n.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),t.viewCache_=o.viewCache,Qa(t,o.changes,o.viewCache.eventCache.getNode(),null)}function Qa(t,e,i,s){const n=s?[s]:t.eventRegistrations_;return function(t,e,i,s){const n=[],o=[];return e.forEach((e=>{var i;"child_changed"===e.type&&t.index_.indexedValueChanged(e.oldSnap,e.snapshotNode)&&o.push((i=e.childName,{type:"child_moved",snapshotNode:e.snapshotNode,childName:i}))})),oa(t,n,"child_removed",e,s,i),oa(t,n,"child_added",e,s,i),oa(t,n,"child_moved",o,s,i),oa(t,n,"child_changed",e,s,i),oa(t,n,"value",e,s,i),n}(t.eventGenerator_,e,i,n)}let qa,$a;class Ka{constructor(){this.views=new Map}}function tr(t,e,i,s){const n=e.source.queryId;if(null!==n){const o=t.views.get(n);return Yt(null!=o,"SyncTree gave us an op for an invalid query."),_a(o,e,i,s)}{let n=[];for(const o of t.views.values())n=n.concat(_a(o,e,i,s));return n}}function er(t,e,i,s,n){const o=e._queryIdentifier,a=t.views.get(o);if(!a){let t=xa(i,n?s:null),o=!1;t?o=!0:s instanceof No?(t=Ya(i,s),o=!1):(t=No.EMPTY_NODE,o=!1);const a=aa(new sa(t,o,!1),new sa(s,n,!1));return new Da(e,a)}return a}function ir(t){const e=[];for(const i of t.views.values())i.query._queryParams.loadsAllData()||e.push(i);return e}function sr(t,e){let i=null;for(const s of t.views.values())i=i||Ua(s,e);return i}function nr(t,e){if(e._queryParams.loadsAllData())return rr(t);{const i=e._queryIdentifier;return t.views.get(i)}}function or(t,e){return null!=nr(t,e)}function ar(t){return null!=rr(t)}function rr(t){for(const e of t.views.values())if(e.query._queryParams.loadsAllData())return e;return null}let lr=1;class hr{constructor(t){this.listenProvider_=t,this.syncPointTree_=new Ia(null),this.pendingWriteTree_={visibleWrites:ua.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function cr(t,e,i,s,n){return function(t,e,i,s,n){Yt(s>t.lastWriteId,"Stacking an older write on top of newer ones"),void 0===n&&(n=!0),t.allWrites.push({path:e,snap:i,writeId:s,visible:n}),n&&(t.visibleWrites=pa(t.visibleWrites,e,i)),t.lastWriteId=s}(t.pendingWriteTree_,e,i,s,n),n?yr(t,new ea({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},e,i)):[]}function dr(t,e,i=!1){const s=function(t,e){for(let i=0;it.writeId===e));Yt(i>=0,"removeWrite called with nonexistent writeId.");const s=t.allWrites[i];t.allWrites.splice(i,1);let n=s.visible,o=!1,a=t.allWrites.length-1;for(;n&&a>=0;){const e=t.allWrites[a];e.visible&&(a>=i&&Ca(e,s.path)?n=!1:_n(s.path,e.path)&&(o=!0)),a--}return!!n&&(o?(function(t){t.visibleWrites=fa(t.allWrites,Ga,Tn()),t.allWrites.length>0?t.lastWriteId=t.allWrites[t.allWrites.length-1].writeId:t.lastWriteId=-1}(t),!0):(s.snap?t.visibleWrites=ma(t.visibleWrites,s.path):an(s.children,(e=>{t.visibleWrites=ma(t.visibleWrites,Dn(s.path,e))})),!0))}(t.pendingWriteTree_,e)){let e=new Ia(null);return null!=s.snap?e=e.set(Tn(),!0):an(s.children,(t=>{e=e.set(new Vn(t),!0)})),yr(t,new Ko(s.path,e,i))}return[]}function Ir(t,e,i){return yr(t,new ea({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},e,i))}function ur(t,e,i,s,n=!1){const o=e._path,a=t.syncPointTree_.get(o);let r=[];if(a&&("default"===e._queryIdentifier||or(a,e))){const l=function(t,e,i,s){const n=e._queryIdentifier,o=[];let a=[];const r=ar(t);if("default"===n)for(const[e,n]of t.views.entries())a=a.concat(Pa(n,i,s)),Ba(n)&&(t.views.delete(e),n.query._queryParams.loadsAllData()||o.push(n.query));else{const e=t.views.get(n);e&&(a=a.concat(Pa(e,i,s)),Ba(e)&&(t.views.delete(n),e.query._queryParams.loadsAllData()||o.push(e.query)))}return r&&!ar(t)&&o.push(new(Yt(qa,"Reference.ts has not been loaded"),qa)(e._repo,e._path)),{removed:o,events:a}}(a,e,i,s);0===a.views.size&&(t.syncPointTree_=t.syncPointTree_.remove(o));const h=l.removed;if(r=l.events,!n){const i=-1!==h.findIndex((t=>t._queryParams.loadsAllData())),n=t.syncPointTree_.findOnPath(o,((t,e)=>ar(e)));if(i&&!n){const e=t.syncPointTree_.subtree(o);if(!e.isEmpty()){const i=function(t){return t.fold(((t,e,i)=>{if(e&&ar(e))return[rr(e)];{let t=[];return e&&(t=ir(e)),an(i,((e,i)=>{t=t.concat(i)})),t}}))}(e);for(let e=0;e0&&!s)if(i){const i=null;t.listenProvider_.stopListening(Gr(e),i)}else h.forEach((e=>{const i=t.queryToTagMap.get(vr(e));t.listenProvider_.stopListening(Gr(e),i)}))}!function(t,e){for(let i=0;i{const i=Bn(t,n);o=o||sr(e,i),a=a||ar(e)}));let r,l=t.syncPointTree_.get(n);l?(a=a||ar(l),o=o||sr(l,Tn())):(l=new Ka,t.syncPointTree_=t.syncPointTree_.set(n,l)),null!=o?r=!0:(r=!1,o=No.EMPTY_NODE,t.syncPointTree_.subtree(n).foreachChild(((t,e)=>{const i=sr(e,Tn());i&&(o=o.updateImmediateChild(t,i))})));const h=or(l,e);if(!h&&!e._queryParams.loadsAllData()){const i=vr(e);Yt(!t.queryToTagMap.has(i),"View does not exist, but we have a tag");const s=lr++;t.queryToTagMap.set(i,s),t.tagToQueryMap.set(s,i)}let c=function(t,e,i,s,n,o){const a=er(t,e,s,n,o);return t.views.has(e._queryIdentifier)||t.views.set(e._queryIdentifier,a),function(t,e){t.eventRegistrations_.push(e)}(a,i),function(t,e){const i=t.viewCache_.eventCache,s=[];return i.getNode().isLeafNode()||i.getNode().forEachChild(Wo,((t,e)=>{s.push(So(t,e))})),i.isFullyInitialized()&&s.push(Ao(i.getNode())),Qa(t,s,i.getNode(),e)}(a,i)}(l,e,i,Za(t.pendingWriteTree_,n),o,r);if(!h&&!a&&!s){const i=nr(l,e);c=c.concat(function(t,e,i){const s=e._path,n=wr(t,e),o=Wr(t,i),a=t.listenProvider_.startListening(Gr(e),n,o.hashFn,o.onComplete),r=t.syncPointTree_.subtree(s);if(n)Yt(!ar(r.value),"If we're adding a query, it shouldn't be shadowed");else{const e=r.fold(((t,e,i)=>{if(!Un(t)&&e&&ar(e))return[rr(e).query];{let t=[];return e&&(t=t.concat(ir(e).map((t=>t.query)))),an(i,((e,i)=>{t=t.concat(i)})),t}}));for(let i=0;i{const s=sr(i,Bn(t,e));if(s)return s}));return Na(s,e,n,i,!0)}function yr(t,e){return Lr(e,t.syncPointTree_,null,Za(t.pendingWriteTree_,Tn()))}function Lr(t,e,i,s){if(Un(t.path))return Mr(t,e,i,s);{const n=e.get(Tn());null==i&&null!=n&&(i=sr(n,Tn()));let o=[];const a=kn(t.path),r=t.operationForChild(a),l=e.children.get(a);if(l&&r){const t=i?i.getImmediateChild(a):null,e=Aa(s,a);o=o.concat(Lr(r,l,t,e))}return n&&(o=o.concat(tr(n,t,s,i))),o}}function Mr(t,e,i,s){const n=e.get(Tn());null==i&&null!=n&&(i=sr(n,Tn()));let o=[];return e.children.inorderTraversal(((e,n)=>{const a=i?i.getImmediateChild(e):null,r=Aa(s,e),l=t.operationForChild(e);l&&(o=o.concat(Mr(l,n,a,r)))})),n&&(o=o.concat(tr(n,t,s,i))),o}function Wr(t,e){const i=e.query,s=wr(t,i);return{hashFn:()=>{const t=function(t){return t.viewCache_.serverCache.getNode()}(e)||No.EMPTY_NODE;return t.hash()},onComplete:e=>{if("ok"===e)return s?function(t,e,i){const s=jr(t,i);if(s){const i=Zr(s),n=i.path,o=i.queryId,a=Bn(n,e);return Cr(t,n,new ta($o(o),a))}return[]}(t,i._path,s):function(t,e){return yr(t,new ta({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},e))}(t,i._path);{const s=function(t,e){let i="Unknown Error";"too_big"===t?i="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"===t?i="Client doesn't have permission to access the desired data.":"unavailable"===t&&(i="The service is unavailable");const s=new Error(t+" at "+e._path.toString()+": "+i);return s.code=t.toUpperCase(),s}(e,i);return ur(t,i,null,s)}}}}function wr(t,e){const i=vr(e);return t.queryToTagMap.get(i)}function vr(t){return t._path.toString()+"$"+t._queryIdentifier}function jr(t,e){return t.tagToQueryMap.get(e)}function Zr(t){const e=t.indexOf("$");return Yt(-1!==e&&e{const n=Sr(s,e.getImmediateChild(t),i);n!==s&&(o=o.updateImmediateChild(t,n))})),o}}class zr{constructor(t="",e=null,i={children:{},childCount:0}){this.name=t,this.parent=e,this.node=i}}function Vr(t,e){let i=e instanceof Vn?e:new Vn(e),s=t,n=kn(i);for(;null!==n;){const t=Kt(s.node.children,n)||{children:{},childCount:0};s=new zr(n,s,t),i=Fn(i),n=kn(i)}return s}function Tr(t){return t.node.value}function kr(t,e){t.node.value=e,Er(t)}function Or(t){return t.node.childCount>0}function Fr(t,e){an(t.node.children,((i,s)=>{e(new zr(i,t,s))}))}function Jr(t,e,i,s){i&&!s&&e(t),Fr(t,(t=>{Jr(t,e,!0,s)})),i&&s&&e(t)}function Xr(t){return new Vn(null===t.parent?t.name:Xr(t.parent)+"/"+t.name)}function Er(t){null!==t.parent&&function(t,e,i){const s=function(t){return void 0===Tr(t)&&!Or(t)}(i),n=$t(t.node.children,e);s&&n?(delete t.node.children[e],t.node.childCount--,Er(t)):s||n||(t.node.children[e]=i.node,t.node.childCount++,Er(t))}(t.parent,t.name,t)}const Dr=/[\[\].#$\/\u0000-\u001F\u007F]/,Ur=/[\[\].#$\u0000-\u001F\u007F]/,Br=10485760,Pr=function(t){return"string"==typeof t&&0!==t.length&&!Dr.test(t)},_r=function(t){return"string"==typeof t&&0!==t.length&&!Ur.test(t)},Qr=function(t,e,i){const s=i instanceof Vn?new Qn(i,t):i;if(void 0===e)throw new Error(t+"contains undefined "+$n(s));if("function"==typeof e)throw new Error(t+"contains a function "+$n(s)+" with contents = "+e.toString());if(qs(e))throw new Error(t+"contains "+e.toString()+" "+$n(s));if("string"==typeof e&&e.length>Br/3&&ae(e)>Br)throw new Error(t+"contains a string greater than "+Br+" utf8 bytes "+$n(s)+" ('"+e.substring(0,50)+"...')");if(e&&"object"==typeof e){let i=!1,n=!1;if(an(e,((e,o)=>{if(".value"===e)i=!0;else if(".priority"!==e&&".sv"!==e&&(n=!0,!Pr(e)))throw new Error(t+" contains an invalid key ("+e+") "+$n(s)+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');!function(t,e){t.parts_.length>0&&(t.byteLength_+=1),t.parts_.push(e),t.byteLength_+=ae(e),qn(t)}(s,e),Qr(t,o,s),function(t){const e=t.parts_.pop();t.byteLength_-=ae(e),t.parts_.length>0&&(t.byteLength_-=1)}(s)})),i&&n)throw new Error(t+' contains ".value" child '+$n(s)+" in addition to actual children.")}},qr=function(t,e,i,s){if(!(s&&void 0===i||_r(i)))throw new Error(oe(t,e)+'was an invalid path = "'+i+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},$r=function(t,e,i,s){i&&(i=i.replace(/^\/*\.info(\/|$)/,"/")),qr(t,e,i,s)};class Kr{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function tl(t,e){let i=null;for(let s=0;s_n(t,e)||_n(e,t)))}function il(t){for(let e=0;e=0)t.server_=new Eo(t.repoInfo_,((e,i,s,n)=>{ll(t,e,i,s,n)}),t.authTokenProvider_,t.appCheckProvider_),setTimeout((()=>hl(t,!0)),0);else{if(null!=i){if("object"!=typeof i)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{Qt(i)}catch(t){throw new Error("Invalid authOverride provided: "+t)}}t.persistentConnection_=new eo(t.repoInfo_,e,((e,i,s,n)=>{ll(t,e,i,s,n)}),(e=>{hl(t,e)}),(e=>{!function(t,e){an(e,((e,i)=>{cl(t,e,i)}))}(t,e)}),t.authTokenProvider_,t.appCheckProvider_,i),t.server_=t.persistentConnection_}t.authTokenProvider_.addTokenChangeListener((e=>{t.server_.refreshAuthToken(e)})),t.appCheckProvider_.addTokenChangeListener((e=>{t.server_.refreshAppCheckToken(e.token)})),t.statsReporter_=function(e,i){const s=e.toString();return Zn[s]||(Zn[s]=new Qo(t.stats_,t.server_)),Zn[s]}(t.repoInfo_),t.infoData_=new Do,t.infoSyncTree_=new hr({startListening:(e,i,s,n)=>{let o=[];const a=t.infoData_.getNode(e._path);return a.isEmpty()||(o=Ir(t.infoSyncTree_,e._path,a),setTimeout((()=>{n("ok")}),0)),o},stopListening:()=>{}}),cl(t,"connected",!1),t.serverSyncTree_=new hr({startListening:(e,i,s,n)=>(t.server_.listen(e,s,i,((i,s)=>{const o=n(i,s);el(t.eventQueue_,e._path,o)})),[]),stopListening:(e,i)=>{t.server_.unlisten(e,i)}})}function al(t){const e=t.infoData_.getNode(new Vn(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+e}function rl(t){return xr({timestamp:al(t)})}function ll(t,e,i,s,n){t.dataUpdateCount++;const o=new Vn(e);i=t.interceptServerDataCallback_?t.interceptServerDataCallback_(e,i):i;let a=[];if(n)if(s){const e=ee(i,(t=>Ro(t)));a=function(t,e,i,s){const n=jr(t,s);if(n){const s=Zr(n),o=s.path,a=s.queryId,r=Bn(o,e),l=Ia.fromObject(i);return Cr(t,o,new ia($o(a),r,l))}return[]}(t.serverSyncTree_,o,e,n)}else{const e=Ro(i);a=pr(t.serverSyncTree_,o,e,n)}else if(s){const e=ee(i,(t=>Ro(t)));a=function(t,e,i){const s=Ia.fromObject(i);return yr(t,new ia({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},e,s))}(t.serverSyncTree_,o,e)}else{const e=Ro(i);a=Ir(t.serverSyncTree_,o,e)}let r=o;a.length>0&&(r=ml(t,o)),el(t.eventQueue_,r,a)}function hl(t,e){cl(t,"connected",e),!1===e&&function(t){ul(t,"onDisconnectEvents");const e=rl(t),i=Uo();Po(t.onDisconnect_,Tn(),((s,n)=>{const o=gr(s,n,t.serverSyncTree_,e);Bo(i,s,o)}));let s=[];Po(i,Tn(),((e,i)=>{s=s.concat(Ir(t.serverSyncTree_,e,i));const n=wl(t,e);ml(t,n)})),t.onDisconnect_=Uo(),el(t.eventQueue_,Tn(),s)}(t)}function cl(t,e,i){const s=new Vn("/.info/"+e),n=Ro(i);t.infoData_.updateSnapshot(s,n);const o=Ir(t.infoSyncTree_,s,n);el(t.eventQueue_,s,o)}function dl(t){return t.nextWriteId_++}function Il(t,e,i,s,n){ul(t,"set",{path:e.toString(),value:i,priority:s});const o=rl(t),a=Ro(i,s),r=mr(t.serverSyncTree_,e),l=Ar(a,r,o),h=dl(t),c=cr(t.serverSyncTree_,e,l,h,!0);tl(t.eventQueue_,c),t.server_.put(e.toString(),a.val(!0),((i,s)=>{const o="ok"===i;o||Qs("set at "+e+" failed: "+i);const a=dr(t.serverSyncTree_,h,!o);el(t.eventQueue_,e,a),function(t,e,i,s){e&&cn((()=>{if("ok"===i)e(null);else{const t=(i||"error").toUpperCase();let n=t;s&&(n+=": "+s);const o=new Error(n);o.code=t,e(o)}}))}(0,n,i,s)}));const d=wl(t,e);ml(t,d),el(t.eventQueue_,d,[])}function ul(t,...e){let i="";t.persistentConnection_&&(i=t.persistentConnection_.id+":"),Us(i,...e)}function pl(t,e,i){return mr(t.serverSyncTree_,e,i)||No.EMPTY_NODE}function bl(t,e=t.transactionQueueTree_){if(e||Wl(t,e),Tr(e)){const i=Ll(t,e);Yt(i.length>0,"Sending zero length transaction queue"),i.every((t=>0===t.status))&&function(t,e,i){const s=i.map((t=>t.currentWriteId)),n=pl(t,e,s);let o=n;const a=n.hash();for(let t=0;t{ul(t,"transaction put response",{path:l.toString(),status:s});let n=[];if("ok"===s){const s=[];for(let e=0;ei[e].onComplete(null,!0,i[e].currentOutputSnapshotResolved))),i[e].unwatcher();Wl(t,Vr(t.transactionQueueTree_,e)),bl(t,t.transactionQueueTree_),el(t.eventQueue_,e,n);for(let t=0;t{bl(t,e)}))}function ml(t,e){const i=yl(t,e),s=Xr(i);return function(t,e,i){if(0===e.length)return;const s=[];let n=[];const o=e.filter((t=>0===t.status)).map((t=>t.currentWriteId));for(let r=0;r=sl)d=!0,c="maxretry",n=n.concat(dr(t.serverSyncTree_,l.currentWriteId,!0));else{const i=pl(t,l.path,o);l.currentInputSnapshot=i;const s=e[r].update(i.val());if(void 0!==s){Qr("transaction failed: Data returned ",s,l.path);let e=Ro(s);"object"==typeof s&&null!=s&&$t(s,".priority")||(e=e.updatePriority(i.getPriority()));const a=l.currentWriteId,r=rl(t),h=Ar(e,i,r);l.currentOutputSnapshotRaw=e,l.currentOutputSnapshotResolved=h,l.currentWriteId=dl(t),o.splice(o.indexOf(a),1),n=n.concat(cr(t.serverSyncTree_,l.path,h,l.currentWriteId,l.applyLocally)),n=n.concat(dr(t.serverSyncTree_,a,!0))}else d=!0,c="nodata",n=n.concat(dr(t.serverSyncTree_,l.currentWriteId,!0))}el(t.eventQueue_,i,n),n=[],d&&(e[r].status=2,a=e[r].unwatcher,setTimeout(a,Math.floor(0)),e[r].onComplete&&("nodata"===c?s.push((()=>e[r].onComplete(null,!1,e[r].currentInputSnapshot))):s.push((()=>e[r].onComplete(new Error(c),!1,null)))))}var a;Wl(t,t.transactionQueueTree_);for(let t=0;tt.order-e.order)),i}function Ml(t,e,i){const s=Tr(e);if(s)for(let t=0;t{Ml(t,e,i)}))}function Wl(t,e){const i=Tr(e);if(i){let t=0;for(let e=0;e0?i:void 0)}Fr(e,(e=>{Wl(t,e)}))}function wl(t,e){const i=Xr(yl(t,e)),s=Vr(t.transactionQueueTree_,e);return function(t,e,i){let s=t.parent;for(;null!==s;){if(e(s))return!0;s=s.parent}}(s,(e=>{vl(t,e)})),vl(t,s),Jr(s,(e=>{vl(t,e)})),i}function vl(t,e){const i=Tr(e);if(i){const s=[];let n=[],o=-1;for(let e=0;e.firebaseio.com instead"),s&&"undefined"!==s||"localhost"===i.domain||_s("Cannot parse Firebase url. Please use https://.firebaseio.com"),i.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&Qs("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");const n="ws"===i.scheme||"wss"===i.scheme;return{repoInfo:new Wn(i.host,i.secure,s,n,e,"",s!==i.subdomain),path:new Vn(i.pathString)}},Zl=function(t){let e="",i="",s="",n="",o="",a=!0,r="https",l=443;if("string"==typeof t){let h=t.indexOf("//");h>=0&&(r=t.substring(0,h-1),t=t.substring(h+2));let c=t.indexOf("/");-1===c&&(c=t.length);let d=t.indexOf("?");-1===d&&(d=t.length),e=t.substring(0,Math.min(c,d)),c0){let s=i[t];try{s=decodeURIComponent(s.replace(/\+/g," "))}catch(t){}e+="/"+s}return e}(t.substring(c,d)));const I=function(t){const e={};"?"===t.charAt(0)&&(t=t.substring(1));for(const i of t.split("&")){if(0===i.length)continue;const s=i.split("=");2===s.length?e[decodeURIComponent(s[0])]=decodeURIComponent(s[1]):Qs(`Invalid query segment '${i}' in query '${t}'`)}return e}(t.substring(Math.min(t.length,d)));h=e.indexOf(":"),h>=0?(a="https"===r||"wss"===r,l=parseInt(e.substring(h+1),10)):h=e.length;const u=e.slice(0,h);if("localhost"===u.toLowerCase())i="localhost";else if(u.split(".").length<=2)i=u;else{const t=e.indexOf(".");s=e.substring(0,t).toLowerCase(),i=e.substring(t+1),o=s}"ns"in I&&(o=I.ns)}return{host:e,port:l,domain:i,subdomain:s,secure:a,scheme:r,pathString:n,namespace:o}};class Cl{constructor(t,e,i,s){this.eventType=t,this.eventRegistration=e,this.snapshot=i,this.prevName=s}getPath(){const t=this.snapshot.ref;return"value"===this.eventType?t._path:t.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+Qt(this.snapshot.exportVal())}}class Gl{constructor(t,e,i){this.eventRegistration=t,this.error=e,this.path=i}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}class fl{constructor(t,e){this.snapshotCallback=t,this.cancelCallback=e}onValue(t,e){this.snapshotCallback.call(null,t,e)}onCancel(t){return Yt(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,t)}get hasCancelCallback(){return!!this.cancelCallback}matches(t){return this.snapshotCallback===t.snapshotCallback||void 0!==this.snapshotCallback.userCallback&&this.snapshotCallback.userCallback===t.snapshotCallback.userCallback&&this.snapshotCallback.context===t.snapshotCallback.context}}class Nl{constructor(t,e,i,s){this._repo=t,this._path=e,this._queryParams=i,this._orderByCalled=s}get key(){return Un(this._path)?null:Jn(this._path)}get ref(){return new xl(this._repo,this._path)}get _queryIdentifier(){const t=Xo(this._queryParams),e=nn(t);return"{}"===e?"default":e}get _queryObject(){return Xo(this._queryParams)}isEqual(t){if(!((t=Ie(t))instanceof Nl))return!1;const e=this._repo===t._repo,i=Pn(this._path,t._path),s=this._queryIdentifier===t._queryIdentifier;return e&&i&&s}toJSON(){return this.toString()}toString(){return this._repo.toString()+function(t){let e="";for(let i=t.pieceNum_;it(new Yl(i,Rl(this.ref,e),Wo))))}hasChild(t){const e=new Vn(t);return!this._node.getChild(e).isEmpty()}hasChildren(){return!this._node.isLeafNode()&&!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function Rl(t,e){return null===kn((t=Ie(t))._path)?$r("child","path",e,!1):qr("child","path",e,!1),new xl(t._repo,Dn(t._path,e))}function Hl(t,e){(function(t,e){if(".info"===kn(e))throw new Error(t+" failed = Can't modify data under /.info/")})("set",(t=Ie(t))._path),function(t,e,i,s){s&&void 0===e||Qr(oe(t,"value"),e,i)}("set",e,t._path,!1);const i=new Jt;return Il(t._repo,t._path,e,null,i.wrapCallback((()=>{}))),i.promise}function gl(t){t=Ie(t);const e=new fl((()=>{})),i=new Al(e);return function(t,e,i){const s=function(t,e){const i=e._path;let s=null;t.syncPointTree_.foreachOnPath(i,((t,e)=>{const n=Bn(t,i);s=s||sr(e,n)}));let n=t.syncPointTree_.get(i);n?s=s||sr(n,Tn()):(n=new Ka,t.syncPointTree_=t.syncPointTree_.set(i,n));const o=null!=s,a=o?new sa(s,!0,!1):null;return ha(er(n,e,Za(t.pendingWriteTree_,e._path),o?a.getNode():No.EMPTY_NODE,o).viewCache_)}(t.serverSyncTree_,e);return null!=s?Promise.resolve(s):t.server_.get(e).then((s=>{const n=Ro(s).withIndex(e._queryParams.getIndex());let o;if(br(t.serverSyncTree_,e,i,!0),e._queryParams.loadsAllData())o=Ir(t.serverSyncTree_,e._path,n);else{const i=wr(t.serverSyncTree_,e);o=pr(t.serverSyncTree_,e._path,n,i)}return el(t.eventQueue_,e._path,o),ur(t.serverSyncTree_,e,i,null,!0),n}),(i=>(ul(t,"get for query "+Qt(e)+" failed: "+i),Promise.reject(new Error(i)))))}(t._repo,t,i).then((e=>new Yl(e,new xl(t._repo,t._path),t._queryParams.getIndex())))}class Al{constructor(t){this.callbackContext=t}respondsTo(t){return"value"===t}createEvent(t,e){const i=e._queryParams.getIndex();return new Cl("value",this,new Yl(t.snapshotNode,new xl(e._repo,e._path),i))}getEventRunner(t){return"cancel"===t.getEventType()?()=>this.callbackContext.onCancel(t.error):()=>this.callbackContext.onValue(t.snapshot,null)}createCancelEvent(t,e){return this.callbackContext.hasCancelCallback?new Gl(this,t,e):null}matches(t){return t instanceof Al&&(!t.callbackContext||!this.callbackContext||t.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}!function(t){Yt(!qa,"__referenceConstructor has already been defined"),qa=t}(xl),function(t){Yt(!$a,"__referenceConstructor has already been defined"),$a=t}(xl);const Sl={};function zl(t,e,i,s,n){let o=s||t.options.databaseURL;void 0===o&&(t.options.projectId||_s("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),Us("Using default host for project ",t.options.projectId),o=`${t.options.projectId}-default-rtdb.firebaseio.com`);let a,r,l=jl(o,n),h=l.repoInfo;"undefined"!=typeof process&&process.env&&(r=process.env.FIREBASE_DATABASE_EMULATOR_HOST),r?(a=!0,o=`http://${r}?ns=${h.namespace}`,l=jl(o,n),h=l.repoInfo):a=!l.repoInfo.secure;const c=n&&a?new pn(pn.OWNER):new un(t.name,t.options,e);(function(t,e){const i=e.path.toString();if("string"!=typeof e.repoInfo.host||0===e.repoInfo.host.length||!Pr(e.repoInfo.namespace)&&"localhost"!==e.repoInfo.host.split(":")[0]||0!==i.length&&!function(t){return t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),_r(t)}(i))throw new Error(oe(t,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')})("Invalid Firebase Database URL",l),Un(l.path)||_s("Database URL must point to the root of a Firebase Database (not including a child path).");const d=function(t,e,i,s){let n=Sl[e.name];n||(n={},Sl[e.name]=n);let o=n[t.toURLString()];return o&&_s("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),o=new nl(t,false,i,s),n[t.toURLString()]=o,o}(h,t,c,new In(t.name,i));return new Vl(d,t)}class Vl{constructor(t,e){this._repoInternal=t,this.app=e,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(ol(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new xl(this._repo,Tn())),this._rootInternal}_delete(){return null!==this._rootInternal&&(function(t,e){const i=Sl[e];i&&i[t.key]===t||_s(`Database ${e}(${t.repoInfo_}) has already been deleted.`),function(t){t.persistentConnection_&&t.persistentConnection_.interrupt("repo_interrupt")}(t),delete i[t.key]}(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(t){null===this._rootInternal&&_s("Cannot call "+t+" on a deleted database.")}}function Tl(t){const e=Object.create(Storage.prototype);return e.getItem=e=>t.get(e),e.setItem=(e,i)=>t.set(e,i),e.removeItem=e=>{t.delete(e)},e.clear=()=>t.clear(),e.key=e=>t.keys()[e]||null,Object.defineProperty(e,"length",{get:()=>t.size,enumerable:!1,configurable:!1}),Object.freeze(e)}function kl(t){const e=Object.create(null);return e.has=e=>e in t,e.get=e=>t[e]||null,e.set=(e,i)=>{t[e]=i},e.delete=e=>delete t[e],e.clear=()=>{for(const e of Object.keys(t))delete t[e]},e.keys=()=>Object.keys(t),e.values=()=>{const e=[];for(const i of Object.keys(t))e.push(t[i]);return e},e.entries=()=>{const e=[];for(const i of Object.keys(t))e.push([i,t[i]]);return e},Object.defineProperties(e,{size:{get:()=>Object.keys(t).length,enumerable:!1,configurable:!1}}),Object.freeze(e)}function Ol(t){const e=Object.create(null);return e.has=e=>null!==t.getItem(e),e.get=e=>t.getItem(e),e.set=(e,i)=>t.setItem(e,i),e.clear=()=>t.clear(),e.delete=e=>(t.removeItem(e),!0),e.keys=()=>{const e=t.length,i=new Array(e);for(let s=0;s{const e=t.length,i=new Array(e);for(let s=0;s{const e=t.length,i=new Array(e);for(let s=0;st.length,enumerable:!1,configurable:!1}}),Object.freeze(e)}eo.prototype.simpleListen=function(t,e){this.sendRequest("q",{p:t},e)},eo.prototype.echo=function(t,e){this.sendRequest("echo",{d:t},e)},As="10.8.0",qe(new ue("database",((t,{instanceIdentifier:e})=>zl(t.getProvider("app").getImmediate(),t.getProvider("auth-internal"),t.getProvider("app-check-internal"),e)),"PUBLIC").setMultipleInstances(!0)),si(Hs,gs,void 0),si(Hs,gs,"esm2017");const Fl=function(...t){if(1!==t.length)throw new Error("Invalid arguments");const e=t[0];if("object"!=typeof e)throw new Error("Invalid arguments");const i=Object.create(Jl);try{const t=e.localStorage,s=e.sessionStorage;if("object"!=typeof t||"object"!=typeof s)throw new Error;i.storageEnabled=!0,i.localStorage=Ol(t),i.sessionStorage=Ol(s)}catch(t){i.storageEnabled=!1,i.localStorage=kl(Object.create(null)),i.sessionStorage=kl(Object.create(null))}return Object.defineProperties(e,{localStorage:{value:Tl(i.localStorage),writable:!1,enumerable:!1,configurable:!1},sessionStorage:{value:Tl(i.sessionStorage),writable:!1,enumerable:!1,configurable:!1}}),Object.freeze(i)},Jl=Object.freeze(Object.create(null));Object.defineProperty(Fl,"prototype",{value:Jl,writable:!1,enumerable:!1,configurable:!1}),Object.setPrototypeOf(Fl,null),Object.freeze(Fl);const Xl=Fl;var El=i(984);function Dl(t,e){let i="";switch(e.type){case"VariableDeclaration":switch(e.kind){case"var":case"let":for(const s of e.declarations){i+='window["'+s.id.name+'"] = ';const e=s.init;if(null!=e){const s=t.slice(e.start,e.end).trim();";"!==s[s.length-1]?i+=s+";\n":i+=s+"\n"}else i+="void 0;\n"}break;case"const":for(const s of e.declarations){i+='Object.defineProperty(window, "'+s.id.name+'", { value: ';const e=s.init;if(null!=e){const s=t.slice(e.start,e.end).trim(),n=s.length-1;";"===s[n]?i+=s.slice(0,n):i+=s}else i+="void 0";i+=", writable: false, enumerable: false, configurable: false });\n"}break;default:i+="// invalid expression\n"}break;case"InterfaceDeclaration":case"FunctionDeclaration":case"ClassDeclaration":case"EnumDeclaration":{const s=e.id;null!=s&&(i+='window["'+s.name+'"] = ');const n=t.slice(e.start,e.end).trim();";"!==n[n.length-1]?i+=n+";\n":i+=n+"\n"}break;case"EmptyStatement":case"DebuggerStatement":break;case"ExpressionStatement":{const s=e.expression;switch(s.type){case"AwaitExpression":case"YieldExpression":{const e=s.argument;if(null!=e){const s=t.slice(e.start,e.end).trim();";"!==s[s.length-1]?i+="await "+s+";\n":i+="await "+s+"\n"}}}}break;default:{const s=t.slice(e.start,e.end).trim();";"!==s[s.length-1]?i+=s+";\n":i+=s+"\n"}}return i}const Ul=ei({apiKey:"AIzaSyCPXTy7dt3fpcLd8kVTBtXy0xuBdeuhbFc",authDomain:"whitespider.firebaseapp.com",projectId:"whitespider",storageBucket:"whitespider.appspot.com",messagingSenderId:"176227430389",appId:"1:176227430389:web:94270de43b7eb971c03abc",measurementId:"G-F72WBJT57S"}),Bl=(function(t=ii()){const e=$e(t=Ie(t),is);e.isInitialized()?e.getImmediate():function(t,e={}){const i=$e(t,is);if(i.isInitialized()){const t=i.getImmediate();if(ie(e,i.getOptions()))return t;throw hs.create("already-initialized")}i.initialize({options:e})}(t)}(Ul),function(t=ii(),e){const i=$e(t,"database").getImmediate({identifier:e});if(!i._instanceStarted){const t=(t=>{const e=(t=>{var e,i;return null===(i=null===(e=Ot())||void 0===e?void 0:e.emulatorHosts)||void 0===i?void 0:i[t]})(t);if(!e)return;const i=e.lastIndexOf(":");if(i<=0||i+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const s=parseInt(e.substring(i+1),10);return"["===e[0]?[e.substring(1,i-1),s]:[e.substring(0,i),s]})("database");t&&function(t,e,i,s={}){(t=Ie(t))._checkNotDeleted("useEmulator"),t._instanceStarted&&_s("Cannot call useEmulator() after instance has already been initialized.");const n=t._repoInternal;let o;if(n.repoInfo_.nodeAdmin)s.mockUserToken&&_s('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new pn(pn.OWNER);else if(s.mockUserToken){const e="string"==typeof s.mockUserToken?s.mockUserToken:function(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const i=e||"demo-project",s=t.iat||0,n=t.sub||t.user_id;if(!n)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${i}`,aud:i,iat:s,exp:s+3600,auth_time:s,sub:n,user_id:n,firebase:{sign_in_provider:"custom",identities:{}}},t);return[zt(JSON.stringify({alg:"none",type:"JWT"})),zt(JSON.stringify(o)),""].join(".")}(s.mockUserToken,t.app.options.projectId);o=new pn(e)}!function(t,e,i,s){t.repoInfo_=new Wn(`${e}:${i}`,!1,t.repoInfo_.namespace,t.repoInfo_.webSocketOnly,t.repoInfo_.nodeAdmin,t.repoInfo_.persistenceKey,t.repoInfo_.includeNamespaceInQueryParams,!0),s&&(t.authTokenProvider_=s)}(n,e,i,o)}(i,...t)}return i}(Ul));(async({window:t,document:e})=>{var i;function s(t){const i=e.getElementById(t);if(null==i)throw new Error("Element does not exist: "+t);return i}function n(t){const i=e.querySelector(t);if(i instanceof HTMLElement)return i;throw new Error("Failed to query selector: "+t)}const a=t.location,h=s("error"),c=new DOMParser;t.onerror=(t,e,i,s,n)=>{let o="Unhandled error at "+(e||"unknown source ");null!=i&&(o+=i),null!=s&&(o+=":"+s),null!=n&&(o+="\n\n"+n),h.textContent=o,h.style.display="block"},t.onkeydown=t=>{if(t.ctrlKey&&!t.altKey&&!t.metaKey&&!t.shiftKey)switch(t.key){case"q":t.preventDefault(),t.stopPropagation(),a.replace("https://www.google.com/webhp?igu=1");break;case"b":t.preventDefault(),t.stopPropagation();const{body:i}=e;i.hasAttribute("style")?i.removeAttribute("style"):i.setAttribute("style","filter: blur(15px);");break;case"h":t.preventDefault(),t.stopPropagation(),"WhiteSpider"===e.title?(e.title="Google",n("link[rel*='icon']").href="/res/google.ico"):(e.title="WhiteSpider",n("link[rel*='icon']").href="/favicon.ico")}},await new Promise((t=>{const i=setInterval((()=>{"complete"===e.readyState&&(clearInterval(i),t())}),50)}));const d=t["xz z\ud800\ud812"];if("function"!=typeof d)return void y("Internal Error");const I=s("frame"),u=s("frame-view"),p=s("video"),b=s("video-frame"),m=s("status");function y(t){null!=t?(h.textContent=t,h.style.display="block"):h.style.display="none"}function L(t){I.appendChild(W(t)),u.style.display="flex"}function M(t){p.appendChild(function(t){const i=e.createElement("iframe");return i.setAttribute("width","1024"),i.setAttribute("height","768"),i.setAttribute("allow",""),i.setAttribute("allowfullscreen","true"),i.setAttribute("allowpaymentrequest","true"),i.setAttribute("sandbox","allow-scripts allow-same-origin"),i.setAttribute("loading","lazy"),i.setAttribute("credentialless","true"),i.setAttribute("referrerpolicy","no-referrer"),null!=t&&i.setAttribute("src","data:application/xhtml+xml;base64,"+o.encode(r.encode(`\n\n\n\t\n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\tGoogle \n\t\n\t\n\t\t \n\t\n`))),i}(t)),b.style.display="flex"}function W(t){const i=e.createElement("embed");return i.type="text/plain",i.width="1024",i.height="768",i.src=t.startsWith("http://")?"https://"+t.substring(7):t,i}function w(t){try{return new URL(t)}catch(t){return null}}function v(e){const i=t.open(void 0,"_blank","");if(null==i)return void y("Please allow popups in your browser settings and try again.");i.focus();const s=c.parseFromString(`\n\n\n\t\n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\tGoogle \n\t\n\t\n\t\t\x3c!-- dummy --\x3e\n\t\n`,"application/xml");e.remove(),s.body.appendChild(e),i.document.documentElement.replaceWith(s.documentElement)}if(m.innerHTML="Connecting...",m.style.color="#808000",t!==t.top){const S=a.ancestorOrigins;if("null"===S[S.length-1]){const z=e.createElement("div");return z.textContent="Click here to continue",z.onclick=()=>v(W("https://whitespider.dev/")),z.setAttribute("style","padding: 15px;"),e.body.innerHTML="",void e.body.appendChild(z)}if("https://whitespider.dev"!==a.origin)return void a.replace("https://whitespider.dev/")}await new Promise((t=>setTimeout(t,500))),h.onclick=()=>{h.innerHTML="",h.style.display="none"};const j=Xl(t),Z=(N="gamelist_v2",(f=Ie(f=Bl))._checkNotDeleted("ref"),void 0!==N?Rl(f._root,N):f._root),C=t.navigator.serviceWorker,{localStorage:G}=j;var f,N;let x,Y=null,R=null,H=null;if(null!=C&&j.storageEnabled)try{await C.register("/sw.js",{type:"classic",scope:"/",updateViaCache:"none"}),await C.ready;const V=await t.fetch("/manifest.json",{cache:"no-cache",method:"GET",headers:{Accept:"application/json"}});if(V.ok){const{version:k}=await V.json();if(k!==G.get("__mf_version")){document.body.innerHTML="Updating contents...";const O=t.caches;for(const F of await O.keys())await O.delete(F);return G.delete("__new_read"),G.set("__mf_version",k),void a.reload()}s("version").textContent="v"+k}const T=G.get("__oauth_token")||"";if(T.length>0){const J=parseInt(G.get("__oauth_expr")||"",10);!Number.isNaN(J)&&J>Date.now()&&(Y=T)}}catch(X){}else y("Warning: Cookies are blocked by your browser. Some features might not work properly, and your game data will NOT be saved.");{const E=await Promise.race([gl(Z),new Promise((t=>setTimeout(t,2500)))]);if(null!=E&&E.exists())for(const D of(null===(i=E.val())||void 0===i?void 0:i.data)||[])null!=D&&"object"==typeof D&&l.push({0:D[0],1:3,2:D[2],3:[]})}{const U=n("link[rel*='icon']"),B=s("backend-url"),P=s("theme"),_=s("tab-cloaking");let Q;function q(t){if(0===t.length){const e=(new Date).getUTCHours();t=e>20||e<9?"https://gq.whitespider.dev/":"https://tk.whitespider.dev/"}null!=x&&(x.disconnect(),x.close()),x=xt(t,{path:"/untrihexium_v2/",secure:!0,upgrade:!0,timeout:1e4,forceNew:!0,multiplex:!1,protocols:[],transports:["polling","websocket"],autoConnect:!0,reconnection:!0,rememberUpgrade:!0,reconnectionDelay:5e3,reconnectionDelayMax:1e4}),x.io.on("error",(t=>{m.title="Server connection error. Message: "+t.message,m.innerHTML="✕Disconnected",m.style.color="#ff0000"})),x.io.on("reconnect_attempt",(()=>{m.title="",m.innerHTML="Connecting...",m.style.color="#808000"})),x.io.on("reconnect_failed",(()=>{m.title="",m.innerHTML="✕Disconnected",m.style.color="#ff0000"})),x.io.on("reconnect",(()=>{m.title="",m.innerHTML="✓Connected",m.style.color="#008000",null!=R&&R()})),x.once("connect",(()=>{m.innerHTML="✓Connected",m.style.color="#008000"}))}function $(t){switch(null==Q&&(Q=e.createElement("link"),Q.rel="stylesheet",Q.type="text/css",Q.href="data:text/css;base64,",e.head.appendChild(Q)),t){case"light":Q.href="data:text/css;base64,";break;case"dark":Q.href="index.dark.css";break;default:Q.href="data:text/css;base64,QG1lZGlhIGFsbCBhbmQocHJlZmVycy1jb2xvci1zY2hlbWU6IGRhcmspe0BpbXBvcnQgdXJsKCJpbmRleC5kYXJrLmNzcyIpO30="}}function K(t){switch(t){case"empty":e.title="",U.type="image/x-icon",U.href="/res/empty.ico";break;case"google":e.title="Google",U.type="image/x-icon",U.href="/res/google.ico";break;case"classroom":e.title="Home",U.type="image/png",U.href="/res/classroom.png";break;default:e.title="WhiteSpider",U.type="image/x-icon",U.href="/favicon.ico"}}B.onblur=()=>{const t=w(B.value.trim());if(null!=t&&"https:"===t.protocol){const e=t.href;q(e),G.set("__backendURL_",e)}else q(""),G.delete("__backendURL_")},P.onchange=()=>{const t=P.value;$(t),G.set("__set_theme",t)},_.onchange=()=>{const t=_.value;K(t),G.set("__set_tabc",t)};{const tt=G.get("__backendURL_")||"";q(tt),B.value=tt}{const et=G.get("__set_theme")||"default";$(et),P.value=et}{const it=G.get("__set_tabc")||"disabled";K(it),_.value=it}}{const st=s("game-container"),nt=s("gnav-page-number"),ot=s("gnav-back"),at=s("gnav-forward"),rt=s("submit-game-frame"),lt=s("game-name"),ht=s("game-url"),ct=s("error-msg"),dt=s("cancel"),It=s("submit"),ut=[];let pt=0,bt="all",mt="";{const Wt=s("game-search"),wt=n("#game-search>input");let vt=0;function jt(){mt=wt.value.toLowerCase().trim(),yt()}Wt.onsubmit=t=>{t.preventDefault(),t.stopPropagation(),clearTimeout(vt),jt()},wt.onblur=()=>{clearTimeout(vt),jt()},wt.oninput=()=>{clearTimeout(vt),vt=setTimeout((()=>{jt()}),1e3)}}{const Zt=e.querySelectorAll("#game-category>button");for(const Ct of Zt)Ct.onclick=()=>{for(const t of Zt)t.removeAttribute("current");Ct.setAttribute("current","true"),bt=Ct.getAttribute("match")||"all",yt()}}{const Gt=n('#game-category>button[match="new"]');G.has("__new_read")||(Gt.setAttribute("unread","true"),Gt.addEventListener("click",(()=>{Gt.removeAttribute("unread"),G.set("__new_read","1")}),{once:!0,passive:!0}))}function yt(){pt=0,ut.length=0;const t=[];switch(bt){case"all":for(const e of l)(!mt||e[0].toLowerCase().indexOf(mt)>=0)&&t.push(e);break;case"html5":for(const e of l)0===e[1]&&(!mt||e[0].toLowerCase().indexOf(mt)>=0)&&t.push(e);break;case"flash":for(const e of l)1===e[1]&&(!mt||e[0].toLowerCase().indexOf(mt)>=0)&&t.push(e);break;case"dos":for(const e of l)2===e[1]&&(!mt||e[0].toLowerCase().indexOf(mt)>=0)&&t.push(e);break;default:for(const e of l)e[3].indexOf(bt)>=0&&(!mt||e[0].toLowerCase().indexOf(mt)>=0)&&t.push(e)}if(0===t.length)return ot.disabled=!0,at.disabled=!0,void(st.innerHTML="No results found :(");for(let e=0;e=ut.length-1?at.disabled=!0:at.disabled=!1;for(const t of ut[pt]){const i=t[0],s=t[1],n=t[4],o=e.createElement("div");o.onclick=()=>L("player.html?type="+s+"&url="+encodeURIComponent(t[2])),o.oncontextmenu=t=>{t.preventDefault(),t.stopPropagation()},o.style.backgroundImage=null!=n?'url("'+n+'")':3===s?'url("/res/preview.svg")':'url("/d/'+encodeURIComponent(i)+'.jpg"), url("/res/preview.svg")';const a=e.createElement("div");a.textContent=i,o.appendChild(a);const r=e.createElement("label");switch(s){case 0:r.textContent="HTML5",r.style.background="#ff9933";break;case 1:r.textContent="Flash",r.style.background="#00cc99";break;case 2:r.textContent="Dos",r.style.background="#80bfff";break;case 3:r.textContent="User",r.style.background="#ff0000"}o.appendChild(r),st.appendChild(o)}}function Mt(t){const e=t.length;for(let i=0;i90)&&(s<97||s>122)&&(s<48||s>57)){if(0===i&&40!==s)return!1;if(i===e-1&&41!==s)return!1;switch(s){case 32:case 39:case 40:case 41:case 45:break;default:return!1}}}return!0}ot.onclick=()=>{pt--,Lt(),st.scrollIntoView({behavior:"instant",inline:"start",block:"start"})},at.onclick=()=>{pt++,Lt(),st.scrollIntoView({behavior:"instant",inline:"start",block:"start"})},dt.onclick=()=>{rt.style.display="none",lt.value="",ht.value="",ct.innerHTML="",ct.style.display="none"},It.onclick=async()=>{var t;const e=lt.value.replace(/\s+/g," ").trim(),i=w(ht.value.trim());if(0===e.length)return ct.textContent="Game name must not be empty.",void(ct.style.display="block");if(null==i)return ct.textContent="Invalid URL",void(ct.style.display="block");if("https:"!==i.protocol)return ct.textContent="URL protocol must be 'https:'. (Insecure 'http:' URLs are not supported)",void(ct.style.display="block");if(!Mt(e))return ct.textContent="Game name contains illegal characters.",void(ct.style.display="block");dt.disabled=!0,It.disabled=!0;const s=await gl(Z);if(!s.exists())return ct.textContent="Failed to retrieve remote data. (Internal Error)",void(ct.style.display="block");const n={0:e,2:i.href},o=((null===(t=s.val())||void 0===t?void 0:t.data)||[]).filter((t=>t&&"object"==typeof t));o.push(n),await Hl(Z,{data:o}),n[1]=3,n[3]=[],l.push(n),yt(),pt=ut.length-1,Lt(),dt.disabled=!1,It.disabled=!1,dt.click()},s("frame-close").onclick=()=>{I.innerHTML="",u.style.display="none"},s("frame-newtab").onclick=()=>{const t=I.firstElementChild;null!=t&&(I.innerHTML="",u.style.display="none",v(t))},s("video-close").onclick=()=>{p.innerHTML="",b.style.display="none"},s("video-fullscreen").onclick=()=>{if(e.fullscreenEnabled)return void p.requestFullscreen({navigationUI:"hide"});const t=p.firstElementChild;null!=t&&(p.innerHTML="",b.style.display="none",v(t))},s("submit-game").onclick=()=>{rt.style.display="block"},yt(),d()}{const ft=s("tabs"),Nt=s("mode-select"),Yt=s("u-frame"),Rt=s("address"),Ht=s("message"),gt=s("container"),At=[],St=["left","middle","right","back","forward"],zt=Yt.getContext("bitmaprenderer",{alpha:!1}),Vt={width:e.documentElement.clientWidth,height:e.documentElement.clientHeight-120,touch:t.navigator.maxTouchPoints>0};let Tt=-1;{const Pt=s("prox-btn"),_t=s("unbl-content");Nt.value=G.get("__unbl_mode_")||"puppeteer",Pt.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,Pt.setAttribute("current","true"),_t.setAttribute("current","true"),"puppeteer"===Nt.value&&(R=()=>{kt("Restoring session..."),Bt()},H=()=>{kt(null),R=null,H=null,Tt=-1,At.length=0,ft.innerHTML="",x.emit("end_session"),x.removeAllListeners()},kt("Requesting new session..."),Bt())},Nt.onchange=()=>{"puppeteer"===Nt.value?(G.set("__unbl_mode_","puppeteer"),Pt.click()):(null!=H&&H(),G.set("__unbl_mode_","raw-embed"))}}function kt(t){null!=t?(Ht.textContent=t,Ht.style.display="block"):Ht.style.display="none"}function Ot(t){return t.preventDefault(),t.stopPropagation(),t.returnValue=!1,x.emit("event",{type:t.type,x:t.offsetX,y:t.offsetY,button:St[t.button]}),!1}function Ft(t){t.preventDefault(),t.stopPropagation(),t.returnValue=!1;const e=t.touches;if(0==e.length)return x.emit("event",{type:t.type}),!1;const i=Yt.getBoundingClientRect();for(const s of e)x.emit("event",{type:t.type,x:s.clientX-i.x,y:s.clientY-i.y});return!1}function Jt(t){return t.preventDefault(),t.stopPropagation(),t.returnValue=!1,x.emit("event",{type:t.type,deltaX:t.deltaX,deltaY:t.deltaY}),!1}function Xt(t){return t.preventDefault(),t.stopPropagation(),t.returnValue=!1,x.emit("event",{type:t.type,key:t.key}),!1}function Et(t){return t.preventDefault(),t.stopPropagation(),t.returnValue=!1,Yt.focus({preventScroll:!0}),!1}function Dt(t){t=t.toLowerCase();for(let e=0;e57)&&(i<97||i>122)&&45!==i&&46!==i)return!1}return!0}function Ut(t,e){const i=w(t=t.replace(/\s+/g," ").trim());if(null!=i)return i.href;if(t.includes(" "))return e+encodeURIComponent(t);const s=t.indexOf("/");if(0===s)return e+encodeURIComponent(t);if(s>0){if(Dt(t.substring(0,s)))return"http://"+t}else if(Dt(t)&&t.includes("."))return"http://"+t;return e+encodeURIComponent(t)}async function Bt(){if(null==zt)throw new Error("Failed initialize canvas context");x.removeAllListeners(),x.emit("request_new_session",Vt);const{width:t,height:i}=await new Promise((t=>{x.once("session_ready",(e=>t(e)))}));gt.style.width=t+"px",gt.style.height=i+"px",Yt.width=t,Yt.height=i;for(const t of At)x.emit("newtab"),await new Promise((t=>{x.once("tabopen",t)})),x.emit("navigate",t.url),await new Promise((e=>{x.once("tabinfo",(i=>{const s=ft.children[i.id];t.title=s.querySelector("div").textContent=i.title||"Untitled",t.favicon=s.querySelector("img").src=i.favicon||"/res/empty.ico",e()}))}));x.on("url",(t=>{At[Tt].url=t,e.activeElement!==Rt&&(Rt.value=t)})),x.on("frame",(async e=>{const s=await createImageBitmap(new Blob([e],{type:"image/jpeg",endings:"native"}),0,0,t,i,{resizeQuality:"pixelated",imageOrientation:"none",premultiplyAlpha:"none",colorSpaceConversion:"none"});zt.transferFromImageBitmap(s),s.close()})),x.on("tabinfo",(t=>{const{id:e}=t,i=ft.children[e],s=At[e];s.title=i.querySelector("div").textContent=t.title||"Untitled",s.favicon=i.querySelector("img").src=t.favicon||"/res/empty.ico"})),x.on("tabopen",(()=>{const t=e.createElement("div");t.innerHTML='Untitled
',t.onclick=()=>{for(const t of ft.children)t.removeAttribute("current");t.setAttribute("current","true"),x.emit("focustab",Tt=At.indexOf(s))};const i=e.createElement("button");i.type="button",i.title="Close",i.onclick=t=>{t.preventDefault(),t.stopPropagation(),x.emit("closetab",At.indexOf(s))},t.appendChild(i);for(const t of ft.children)t.removeAttribute("current");t.setAttribute("current","true");const s={url:"",title:"",favicon:""};Tt=At.length,At.push(s),ft.appendChild(t)})),x.on("tabclose",(t=>{const e=ft.children;t===Tt&&(t>1?e[Tt=t-1].setAttribute("current","true"):At.length>0&&e[Tt=0].setAttribute("current","true")),e[t].remove(),At.splice(t,1)})),-1===Tt?x.emit("newtab"):x.emit("focustab",Tt),kt(null),Yt.autofocus=!0,Yt.focus({preventScroll:!0})}s("back").onclick=()=>x.emit("goback"),s("forward").onclick=()=>x.emit("goforward"),s("refresh").onclick=()=>x.emit("refresh"),s("new-tab").onclick=()=>x.emit("newtab"),Rt.onfocus=t=>{t.preventDefault(),t.stopPropagation(),Rt.select()},Rt.onkeydown=t=>{if("Enter"===t.key){t.preventDefault(),t.stopPropagation();const e=Rt.value.trim();e.length>0&&("puppeteer"===Nt.value?(Yt.focus({preventScroll:!0}),x.emit("navigate",Ut(e,"https://www.google.com/search?q="))):L(Ut(e,"https://www.bing.com/search?q=")))}},Rt.ondragstart=t=>{t.preventDefault(),t.stopPropagation(),Rt.selectionEnd=Rt.selectionStart||(Rt.selectionStart=0)},Yt.addEventListener("mousedown",Ot,{passive:!1}),Yt.addEventListener("mouseup",Ot,{passive:!1}),Yt.addEventListener("mousemove",Ot,{passive:!1}),Yt.addEventListener("touchstart",Ft,{passive:!1}),Yt.addEventListener("touchend",Ft,{passive:!1}),Yt.addEventListener("touchmove",Ft,{passive:!1}),Yt.addEventListener("wheel",Jt,{passive:!1}),Yt.addEventListener("keydown",Xt,{passive:!1}),Yt.addEventListener("keyup",Xt,{passive:!1}),Yt.addEventListener("click",Et,{passive:!1}),Yt.addEventListener("contextmenu",Et,{passive:!1})}{const Qt=s("dialog"),qt=n("#chatgpt>input"),$t=n("#chatgpt>button"),Kt=[];function te(t,i){const s=e.createElement("div");{const i=e.createElement("img");i.src=t?"/res/user.svg":"/res/bot.svg",i.width=36,i.height=36,i.draggable=!1,s.appendChild(i)}{const t=e.createElement("div");t.textContent=i,s.appendChild(t)}return Qt.appendChild(s),s.scrollIntoView({behavior:"instant",block:"start",inline:"start"}),s}function ee(t){const i=e.createElement("span");return i.textContent=t,Qt.appendChild(i),i.scrollIntoView({behavior:"instant",block:"start",inline:"start"}),i}function ie(){qt.disabled=!1,$t.disabled=!1,x.removeAllListeners()}s("chatgpt").onsubmit=t=>{t.preventDefault(),t.stopPropagation();const e=qt.value.trim();if(e.length<2)return void ee("Error: Input message must not be empty.");if(!x.connected)return void ee("Error: Disconnected from the backend server.");qt.blur(),qt.value="",qt.disabled=!0,$t.disabled=!0,te(!0,e),Kt.push({role:"user",content:e});const i=te(!1,"Processing...\n"),s=i.lastElementChild;let n="";x.on("gpt_response",(t=>{n+=t,s.textContent+=t})),x.once("gpt_end",(()=>{Kt.push({role:"assistant",content:s.textContent=n}),ie()})),x.once("gpt_error",(()=>{i.remove(),Kt.pop(),ie(),ee("Error: Failed to retrieve data from the server.")})),x.emit("gpt_request",Kt)},s("new-topic").onclick=t=>{t.preventDefault(),t.stopPropagation(),Qt.innerHTML="",Kt.length=0,qt.value=""}}{const se=s("yt-search"),ne=n("#yt-search>input"),oe=n("#yt-search>button"),ae=s("yt-api-key"),re=s("yt-order"),le=s("yt-results"),he=s("yt-load-more"),ce=s("yt-max-results");let de;function ue(t){switch(t.host){case"youtube.com":case"youtube-nocookie.com":case"www.youtube.com":case"www.youtube-nocookie.com":const e=t.pathname;return"/watch"===e?t.searchParams.get("v")||null:e.startsWith("/embed/")&&e.substring(7)||null;case"youtu.be":return t.pathname.substring(1)||null;default:return null}}async function pe(){const e=new URL("https://youtube.googleapis.com/youtube/v3/search"),i=e.searchParams;i.set("q",ne.value),i.set("key",ae.value||"AIzaSyARuwknsJhvP-ysM8-DwbqqJ5e-EaTL-UY"),i.set("type","video"),i.set("part","snippet"),i.set("order",re.value),i.set("maxResults",ce.value),i.set("safeSearch","none"),i.set("videoEmbeddable","true"),null!=de&&i.set("pageToken",de);const s=await t.fetch(e,{cache:"no-cache",method:"GET",headers:{Accept:"application/json"}});return"application/json"===(s.headers.get("content-type")||"").split(";",2)[0].trim()?await s.json():null}async function be(){y(null),oe.disabled=!0,ne.disabled=!0,he.style.display="none";const t=await pe();if(null==t)return void y("API server returned invalid data.");if("error"in t){const{message:e,code:i}=t.error;return void y(e+" (Code: "+i+")")}const i=t.items;if(0==i.length)return void y("No results match your search.");for(const t of i){const i=t.id.videoId,s=t.snippet,n=e.createElement("div");n.onclick=()=>M("https://www.youtube-nocookie.com/embed/"+i+"?autoplay=1&controls=1&rel=0&color=white");const o=e.createElement("img");o.width=160,o.height=90,o.title="Video Preview",o.draggable=!1,o.src=s.thumbnails.medium.url,n.appendChild(o);const a=e.createElement("div");n.appendChild(a);const r=e.createElement("div");r.className="title",r.textContent=s.title,a.appendChild(r);const l=e.createElement("div");l.className="desc",l.textContent=s.description,a.appendChild(l);const h=e.createElement("div");h.className="time",h.textContent=s.publishTime,a.appendChild(h),le.appendChild(n)}const s=t.nextPageToken;null!=s&&(he.style.display="block",he.onclick=()=>{de=s,be().then((()=>{oe.disabled=!1,ne.disabled=!1}))})}ae.value=G.get("__yt_apikey")||"",se.onsubmit=t=>{t.preventDefault(),t.stopPropagation(),de=null,le.innerHTML="";const e=w(ne.value);if(null==e)return void be().then((()=>{oe.disabled=!1,ne.disabled=!1}));y(null),he.style.display="none";const i=ue(e);null!=i?M("https://www.youtube-nocookie.com/embed/"+i+"?autoplay=1&controls=1&rel=0&color=white"):y("Error: Failed to parse YouTube video ID from the provided URL.")},ae.onblur=()=>{const t=ae.value.trim();return 0===t.length?(G.delete("__yt_apikey"),void(ae.value="")):t.length<30?(y("Invalid API key."),void(ae.value="")):void G.set("__yt_apikey",ae.value=t)},ce.onblur=()=>{const t=parseInt(ce.value);isNaN(t)?ce.value="10":t<1?ce.value="1":t>30&&(ce.value="30")}}const g=e.querySelectorAll("#nav-bar>button, #content>div:not(#footer), #unbl-content"),A=s("side-menu");{const me=s("home-btn"),ye=s("chai-btn"),Le=s("apps-btn"),Me=s("chat-btn"),We=s("unbl-btn"),we=s("settings"),ve=s("home-page"),je=s("chatgpt-page"),Ze=s("services-page"),Ce=s("community-page"),Ge=s("site-blocked-page"),fe=s("settings-page");me.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,me.setAttribute("current","true"),ve.setAttribute("current","true")},ye.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,ye.setAttribute("current","true"),je.setAttribute("current","true")},Le.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,Le.setAttribute("current","true"),Ze.setAttribute("current","true")},Me.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,Me.setAttribute("current","true"),Ce.setAttribute("current","true")},We.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,We.setAttribute("current","true"),Ge.setAttribute("current","true")},we.onclick=t=>{if(t.preventDefault(),t.stopPropagation(),null!=H&&H(),fe.hasAttribute("current")){for(const t of g)t.removeAttribute("current");me.setAttribute("current","true"),ve.setAttribute("current","true")}else{for(const t of g)t.removeAttribute("current");fe.setAttribute("current","true")}A.checked=!1}}{const Ne=s("accn-btn"),xe=s("accountinfo-page");function Ye(){Ne.innerHTML="My Account",Ne.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,Ne.setAttribute("current","true"),xe.setAttribute("current","true")},s("signout").onclick=()=>{{const t=e.createElement("form");t.method="post",t.target="_blank",t.action="https://oauth2.googleapis.com/revoke",t.enctype="application/x-www-form-urlencoded";const i=e.createElement("input");i.type="hidden",i.name="token",i.value=Y,t.appendChild(i),e.body.appendChild(t),t.submit(),t.remove()}G.delete("__oauth_token"),G.delete("__oauth_expr"),setTimeout((()=>a.reload()),500)}}if(null!=Y)return void Ye();Ne.onclick=()=>{const e=t.open(void 0,"_blank","width="+screen.availWidth+",height="+screen.availHeight+",left=0,top=0,popup");if(null==e)return void y("Please allow popups in your browser settings and try again.");e.stop(),e.focus();const i=new URL("https://accounts.google.com/o/oauth2/v2/auth"),s=i.searchParams;s.set("client_id","176227430389-qkdboctmfhe9jnvnk2vmarafc5p8amuf.apps.googleusercontent.com"),s.set("redirect_uri",t.origin+"/auth.xht"),s.set("response_type","token"),s.set("state","12"),s.set("scope","email profile"),s.set("include_granted_scopes","true"),s.set("enable_granular_consent","true"),e.location.replace(i)},t.addEventListener("message",(e=>{e.preventDefault(),e.stopPropagation();const i=e.data;if(e.origin===t.origin&&"string"==typeof i){const t=new URLSearchParams(i),e=t.get("access_token")||"",s=t.get("expires_in")||"";if(0===e.length||0===s.length)return void y("External Server Error: Failed to receive login data.");G.set("__oauth_expr",String(1e3*parseInt(s,10)+Date.now())),G.set("__oauth_token",Y=e),Ye()}}),{passive:!1})}{const Re=n("#console-input>input"),He=s("console-output"),ge=[];let Ae=0;function Se(t,i,s){const n=e.createElement("span");return n.style.color=i||"",n.style.whiteSpace="pre-wrap",n.style.overflowWrap="break-word",n.textContent=t,(s||He).appendChild(n),n}function ze(){He.appendChild(e.createElement("hr"))}function Ve(t,i,s){const n=i?100:1e3,o=t.length;if(o>n){const i=Se('"'+Ee(t.slice(0,n))+"\n..."+(o-n)+" more characters","#008000",s),a=e.createElement("button");a.type="button",a.textContent="Expand",a.onclick=()=>{i.textContent='"'+Ee(t)+'"',a.remove()},He.appendChild(a)}else Se('"'+Ee(t)+'"',"#008000",s)}function Te(t,e,i){Se("[\n",void 0,e);for(const i of t)Se("\t",void 0,e),Je(i,!0,e),Se(",\n",void 0,e);Se(i||"]",void 0,e)}function ke(t,i,s){const n=t.length;if(0!==n)if(i)Se("[...]",void 0,s);else if(n>20){const i=e.createElement("span");Te(t.slice(0,20),i,"\t..."+(n-20)+" more items");const o=e.createElement("button");o.type="button",o.textContent="Expand",o.onclick=()=>{i.innerHTML="",Te(t,i)},i.appendChild(o),(s||He).appendChild(i)}else Te(t,s);else Se("[]",void 0,s)}function Oe(t,e,i,s){var n,o,a,r,l,h;const c=Xe(t);c.length>0?Se(c+" {\n",void 0,i):Se("{\n",void 0,i);const d=Object.getPrototypeOf(t);null!=d&&(Se("\t[[prototype]]: ",void 0,i),Fe(d,!0,i),Se(",\n",void 0,i));for(const s of e){Se("\t",void 0,i);const e=Object.getOwnPropertyDescriptor(t,s)||{value:void 0};"value"in e?(null===(n=e.writable)||void 0===n||n||Se("readonly ","#000080",i),null===(o=e.configurable)||void 0===o||o||Se("final ","#000080",i),Se("string"==typeof s?s:"["+s.toString()+"]",null===(a=e.enumerable)||void 0===a||a?"#008000":"#808080",i),Se(": ",void 0,i),Je(e.value,!0,i),Se(",\n",void 0,i)):(null===(r=e.configurable)||void 0===r||r||Se("final ","#000080",i),"get"in e&&(Se("get ","#000080",i),Se("string"==typeof s?s:"["+s.toString()+"]",null===(l=e.enumerable)||void 0===l||l?"#008000":"#808080",i),Se("() { ... }, ",void 0,i)),"set"in e&&(Se("set ","#000080",i),Se("string"==typeof s?s:"["+s.toString()+"]",null===(h=e.enumerable)||void 0===h||h?"#008000":"#808080",i),Se("(v) { ... }, ",void 0,i)),Se("\n",void 0,i))}Se(s||"}",void 0,i)}function Fe(t,i,s){if(null==t)return void Se("null","#000080",s);if(Array.isArray(t))return void ke(t,i);if(i){const e=Xe(t);return void Se((e.length>0?e+" {":"{")+(Object.keys(t).length>0?"...":"")+"}",void 0,s)}const n=Object.getOwnPropertyNames(t).sort();if(n.push.apply(n,Object.getOwnPropertySymbols(t)),n.length>20){const i=e.createElement("span");Oe(t,n.slice(0,20),i,"\t...\n}");const o=e.createElement("button");o.type="button",o.textContent="Expand",o.onclick=()=>{i.innerHTML="",Oe(t,n,i)},i.appendChild(o),(s||He).appendChild(i)}else Oe(t,n,s)}function Je(t,e,i){switch(typeof t){case"boolean":Se(t?"true":"false","#000080",i);break;case"number":Se(t.toString(10),"#0000ff",i);break;case"bigint":Se(String(t)+"n","#0000ff",i);break;case"symbol":Se(t.toString(),"#800080",i);break;case"function":Se(String(t),void 0,i);break;case"undefined":Se("undefined","#000080",i);break;case"string":Ve(t,e,i);break;default:Fe(t,e,i)}}function Xe(t){try{const e=t[Symbol.toStringTag];if("string"==typeof e)return e;const i=t.constructor;if("function"==typeof i){const{name:t}=i;if("string"==typeof t)return t}}catch(t){}return""}function Ee(t){return t.replace(/[\"\'\n\r\\]/g,(t=>{switch(t){case"\n":return"\\n";case"\r":return"\\r";case'"':return'\\"';case"'":return"\\'";case"\\":return"\\\\";default:return""}}))}function De(t){const e=t.replace(/\s+/g," ").split(" ");switch(t=e[0]){case"clear":if(e.length>1)return Se("Invalid arguments. Try '/help' for more information.\n","#ff0000"),void ze();He.innerHTML="";break;case"help":Se("JSConsole version 0.1.0 by WhiteSpider Dev\n\n","#0000ff"),Se("All inputs that starts with '/' will be treated as a built-in command.\n","#808000"),Se("All other inputs will be executed as JavaScript code with 'eval(code)'.\n\n","#808000"),Se("Built-in commands:\n","#008000"),Se("\t/clear\t\t\t\t- Clear the console.\n","#008000"),Se("\t/help\t\t\t\t- Show version info and built-in command list.\n\n","#008000"),ze();break;default:Se(t+": command not found. \nTry '/help' for a list of built-in commands.\n","#ff0000")}}async function Ue(i){if(Se("-> ","#808080"),Se(i=i.trim(),"#323232"),ze(),"/"===i[0])return void De(i.slice(1));try{i=function(t){const{body:e}=(0,El.K0)(t,{ranges:!0,tokens:!1,strictMode:!0,sourceType:"script",attachComment:!1,allowAwaitOutsideFunction:!0,allowReturnOutsideFunction:!0}).program,i=e.pop();let s="";for(const i of e)s+=Dl(t,i);return null!=i&&("ExpressionStatement"===i.type?s+="return "+t.slice(i.start,i.end):s+=Dl(t,i)),s}(i)}catch(t){return Se(String(t)+"\n","#ff0000"),void ze()}let s;try{s=await new Be("window","document",'"use strict;"\n'+i).apply(t,[t,e])}catch(t){return Se("Uncaught "+String(t)+"\n","#ff0000"),void ze()}Je(s,!1),ze()}Re.onkeydown=t=>{switch(t.key){case"Enter":t.preventDefault(),t.stopPropagation();const{value:e}=Re;e.length>0&&(ge.push(e),Ae=ge.length,Re.value="",Re.disabled=!0,Ue(e).then((()=>{Re.disabled=!1,Re.scrollIntoView({behavior:"instant",block:"start",inline:"start"}),Re.focus({preventScroll:!0})})));break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),Ae>0&&(Re.value=ge[--Ae]);break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),Ae{"use strict";var t={984:(t,e)=>{function i(t,e){if(null==t)return{};var i,s,n={},o=Object.keys(t);for(s=0;s=0||(n[i]=t[i]);return n}class s{constructor(t,e,i){this.line=void 0,this.column=void 0,this.index=void 0,this.line=t,this.column=e,this.index=i}}class n{constructor(t,e){this.start=void 0,this.end=void 0,this.filename=void 0,this.identifierName=void 0,this.start=t,this.end=e}}function o(t,e){const{line:i,column:n,index:o}=t;return new s(i,n+e,o+e)}const a="BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";var r={ImportMetaOutsideModule:{message:"import.meta may appear only with 'sourceType: \"module\"'",code:a},ImportOutsideModule:{message:"'import' and 'export' may appear only with 'sourceType: \"module\"'",code:a}};const l={ArrayPattern:"array destructuring pattern",AssignmentExpression:"assignment expression",AssignmentPattern:"assignment expression",ArrowFunctionExpression:"arrow function expression",ConditionalExpression:"conditional expression",CatchClause:"catch clause",ForOfStatement:"for-of statement",ForInStatement:"for-in statement",ForStatement:"for-loop",FormalParameters:"function parameter list",Identifier:"identifier",ImportSpecifier:"import specifier",ImportDefaultSpecifier:"import default specifier",ImportNamespaceSpecifier:"import namespace specifier",ObjectPattern:"object destructuring pattern",ParenthesizedExpression:"parenthesized expression",RestElement:"rest element",UpdateExpression:{true:"prefix operation",false:"postfix operation"},VariableDeclarator:"variable declaration",YieldExpression:"yield expression"},h=({type:t,prefix:e})=>"UpdateExpression"===t?l.UpdateExpression[String(e)]:l[t];var c={AccessorIsGenerator:({kind:t})=>`A ${t}ter cannot be a generator.`,ArgumentsInClass:"'arguments' is only allowed in functions and class methods.",AsyncFunctionInSingleStatementContext:"Async functions can only be declared at the top level or inside a block.",AwaitBindingIdentifier:"Can not use 'await' as identifier inside an async function.",AwaitBindingIdentifierInStaticBlock:"Can not use 'await' as identifier inside a static block.",AwaitExpressionFormalParameter:"'await' is not allowed in async function parameters.",AwaitUsingNotInAsyncContext:"'await using' is only allowed within async functions and at the top levels of modules.",AwaitNotInAsyncContext:"'await' is only allowed within async functions and at the top levels of modules.",AwaitNotInAsyncFunction:"'await' is only allowed within async functions.",BadGetterArity:"A 'get' accessor must not have any formal parameters.",BadSetterArity:"A 'set' accessor must have exactly one formal parameter.",BadSetterRestParameter:"A 'set' accessor function argument must not be a rest parameter.",ConstructorClassField:"Classes may not have a field named 'constructor'.",ConstructorClassPrivateField:"Classes may not have a private field named '#constructor'.",ConstructorIsAccessor:"Class constructor may not be an accessor.",ConstructorIsAsync:"Constructor can't be an async function.",ConstructorIsGenerator:"Constructor can't be a generator.",DeclarationMissingInitializer:({kind:t})=>`Missing initializer in ${t} declaration.`,DecoratorArgumentsOutsideParentheses:"Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",DecoratorBeforeExport:"Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",DecoratorsBeforeAfterExport:"Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",DecoratorConstructor:"Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",DecoratorExportClass:"Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",DecoratorSemicolon:"Decorators must not be followed by a semicolon.",DecoratorStaticBlock:"Decorators can't be used with a static block.",DeferImportRequiresNamespace:'Only `import defer * as x from "./module"` is valid.',DeletePrivateField:"Deleting a private field is not allowed.",DestructureNamedImport:"ES2015 named imports do not destructure. Use another statement for destructuring after the import.",DuplicateConstructor:"Duplicate constructor in the same class.",DuplicateDefaultExport:"Only one default export allowed per module.",DuplicateExport:({exportName:t})=>`\`${t}\` has already been exported. Exported identifiers must be unique.`,DuplicateProto:"Redefinition of __proto__ property.",DuplicateRegExpFlags:"Duplicate regular expression flag.",DynamicImportPhaseRequiresImportExpressions:({phase:t})=>`'import.${t}(...)' can only be parsed when using the 'createImportExpressions' option.`,ElementAfterRest:"Rest element must be last element.",EscapedCharNotAnIdentifier:"Invalid Unicode escape.",ExportBindingIsString:({localName:t,exportName:e})=>`A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${t}' as '${e}' } from 'some-module'\`?`,ExportDefaultFromAsIdentifier:"'from' is not allowed as an identifier after 'export default'.",ForInOfLoopInitializer:({type:t})=>`'${"ForInStatement"===t?"for-in":"for-of"}' loop variable declaration may not have an initializer.`,ForInUsing:"For-in loop may not start with 'using' declaration.",ForOfAsync:"The left-hand side of a for-of loop may not be 'async'.",ForOfLet:"The left-hand side of a for-of loop may not start with 'let'.",GeneratorInSingleStatementContext:"Generators can only be declared at the top level or inside a block.",IllegalBreakContinue:({type:t})=>`Unsyntactic ${"BreakStatement"===t?"break":"continue"}.`,IllegalLanguageModeDirective:"Illegal 'use strict' directive in function with non-simple parameter list.",IllegalReturn:"'return' outside of function.",ImportAttributesUseAssert:"The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedAssertSyntax: true` option in the import attributes plugin to suppress this error.",ImportBindingIsString:({importName:t})=>`A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${t}" as foo }\`?`,ImportCallArgumentTrailingComma:"Trailing comma is disallowed inside import(...) arguments.",ImportCallArity:({maxArgumentCount:t})=>`\`import()\` requires exactly ${1===t?"one argument":"one or two arguments"}.`,ImportCallNotNewExpression:"Cannot use new with import(...).",ImportCallSpreadArgument:"`...` is not allowed in `import()`.",ImportJSONBindingNotDefault:"A JSON module can only be imported with `default`.",ImportReflectionHasAssertion:"`import module x` cannot have assertions.",ImportReflectionNotBinding:'Only `import module x from "./module"` is valid.',IncompatibleRegExpUVFlags:"The 'u' and 'v' regular expression flags cannot be enabled at the same time.",InvalidBigIntLiteral:"Invalid BigIntLiteral.",InvalidCodePoint:"Code point out of bounds.",InvalidCoverInitializedName:"Invalid shorthand property initializer.",InvalidDecimal:"Invalid decimal.",InvalidDigit:({radix:t})=>`Expected number in radix ${t}.`,InvalidEscapeSequence:"Bad character escape sequence.",InvalidEscapeSequenceTemplate:"Invalid escape sequence in template.",InvalidEscapedReservedWord:({reservedWord:t})=>`Escape sequence in keyword ${t}.`,InvalidIdentifier:({identifierName:t})=>`Invalid identifier ${t}.`,InvalidLhs:({ancestor:t})=>`Invalid left-hand side in ${h(t)}.`,InvalidLhsBinding:({ancestor:t})=>`Binding invalid left-hand side in ${h(t)}.`,InvalidLhsOptionalChaining:({ancestor:t})=>`Invalid optional chaining in the left-hand side of ${h(t)}.`,InvalidNumber:"Invalid number.",InvalidOrMissingExponent:"Floating-point numbers require a valid exponent after the 'e'.",InvalidOrUnexpectedToken:({unexpected:t})=>`Unexpected character '${t}'.`,InvalidParenthesizedAssignment:"Invalid parenthesized assignment pattern.",InvalidPrivateFieldResolution:({identifierName:t})=>`Private name #${t} is not defined.`,InvalidPropertyBindingPattern:"Binding member expression.",InvalidRecordProperty:"Only properties and spread elements are allowed in record definitions.",InvalidRestAssignmentPattern:"Invalid rest operator's argument.",LabelRedeclaration:({labelName:t})=>`Label '${t}' is already declared.`,LetInLexicalBinding:"'let' is disallowed as a lexically bound name.",LineTerminatorBeforeArrow:"No line break is allowed before '=>'.",MalformedRegExpFlags:"Invalid regular expression flag.",MissingClassName:"A class name is required.",MissingEqInAssignment:"Only '=' operator can be used for specifying default value.",MissingSemicolon:"Missing semicolon.",MissingPlugin:({missingPlugin:t})=>`This experimental syntax requires enabling the parser plugin: ${t.map((t=>JSON.stringify(t))).join(", ")}.`,MissingOneOfPlugins:({missingPlugin:t})=>`This experimental syntax requires enabling one of the following parser plugin(s): ${t.map((t=>JSON.stringify(t))).join(", ")}.`,MissingUnicodeEscape:"Expecting Unicode escape sequence \\uXXXX.",MixingCoalesceWithLogical:"Nullish coalescing operator(??) requires parens when mixing with logical operators.",ModuleAttributeDifferentFromType:"The only accepted module attribute is `type`.",ModuleAttributeInvalidValue:"Only string literals are allowed as module attribute values.",ModuleAttributesWithDuplicateKeys:({key:t})=>`Duplicate key "${t}" is not allowed in module attributes.`,ModuleExportNameHasLoneSurrogate:({surrogateCharCode:t})=>`An export name cannot include a lone surrogate, found '\\u${t.toString(16)}'.`,ModuleExportUndefined:({localName:t})=>`Export '${t}' is not defined.`,MultipleDefaultsInSwitch:"Multiple default clauses.",NewlineAfterThrow:"Illegal newline after throw.",NoCatchOrFinally:"Missing catch or finally clause.",NumberIdentifier:"Identifier directly after number.",NumericSeparatorInEscapeSequence:"Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",ObsoleteAwaitStar:"'await*' has been removed from the async functions proposal. Use Promise.all() instead.",OptionalChainingNoNew:"Constructors in/after an Optional Chain are not allowed.",OptionalChainingNoTemplate:"Tagged Template Literals are not allowed in optionalChain.",OverrideOnConstructor:"'override' modifier cannot appear on a constructor declaration.",ParamDupe:"Argument name clash.",PatternHasAccessor:"Object pattern can't contain getter or setter.",PatternHasMethod:"Object pattern can't contain methods.",PrivateInExpectedIn:({identifierName:t})=>`Private names are only allowed in property accesses (\`obj.#${t}\`) or in \`in\` expressions (\`#${t} in obj\`).`,PrivateNameRedeclaration:({identifierName:t})=>`Duplicate private name #${t}.`,RecordExpressionBarIncorrectEndSyntaxType:"Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",RecordExpressionBarIncorrectStartSyntaxType:"Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",RecordExpressionHashIncorrectStartSyntaxType:"Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",RecordNoProto:"'__proto__' is not allowed in Record expressions.",RestTrailingComma:"Unexpected trailing comma after rest element.",SloppyFunction:"In non-strict mode code, functions can only be declared at top level or inside a block.",SloppyFunctionAnnexB:"In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",SourcePhaseImportRequiresDefault:'Only `import source x from "./module"` is valid.',StaticPrototype:"Classes may not have static property named prototype.",SuperNotAllowed:"`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",SuperPrivateField:"Private fields can't be accessed on super.",TrailingDecorator:"Decorators must be attached to a class element.",TupleExpressionBarIncorrectEndSyntaxType:"Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",TupleExpressionBarIncorrectStartSyntaxType:"Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",TupleExpressionHashIncorrectStartSyntaxType:"Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",UnexpectedArgumentPlaceholder:"Unexpected argument placeholder.",UnexpectedAwaitAfterPipelineBody:'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',UnexpectedDigitAfterHash:"Unexpected digit after hash token.",UnexpectedImportExport:"'import' and 'export' may only appear at the top level.",UnexpectedKeyword:({keyword:t})=>`Unexpected keyword '${t}'.`,UnexpectedLeadingDecorator:"Leading decorators must be attached to a class declaration.",UnexpectedLexicalDeclaration:"Lexical declaration cannot appear in a single-statement context.",UnexpectedNewTarget:"`new.target` can only be used in functions or class properties.",UnexpectedNumericSeparator:"A numeric separator is only allowed between two digits.",UnexpectedPrivateField:"Unexpected private name.",UnexpectedReservedWord:({reservedWord:t})=>`Unexpected reserved word '${t}'.`,UnexpectedSuper:"'super' is only allowed in object methods and classes.",UnexpectedToken:({expected:t,unexpected:e})=>`Unexpected token${e?` '${e}'.`:""}${t?`, expected "${t}"`:""}`,UnexpectedTokenUnaryExponentiation:"Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",UnexpectedUsingDeclaration:"Using declaration cannot appear in the top level when source type is `script`.",UnsupportedBind:"Binding should be performed on object property.",UnsupportedDecoratorExport:"A decorated export must export a class declaration.",UnsupportedDefaultExport:"Only expressions, functions or classes are allowed as the `default` export.",UnsupportedImport:"`import` can only be used in `import()` or `import.meta`.",UnsupportedMetaProperty:({target:t,onlyValidPropertyName:e})=>`The only valid meta property for ${t} is ${t}.${e}.`,UnsupportedParameterDecorator:"Decorators cannot be used to decorate parameters.",UnsupportedPropertyDecorator:"Decorators cannot be used to decorate object literal properties.",UnsupportedSuper:"'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",UnterminatedComment:"Unterminated comment.",UnterminatedRegExp:"Unterminated regular expression.",UnterminatedString:"Unterminated string constant.",UnterminatedTemplate:"Unterminated template.",UsingDeclarationHasBindingPattern:"Using declaration cannot have destructuring patterns.",VarRedeclaration:({identifierName:t})=>`Identifier '${t}' has already been declared.`,YieldBindingIdentifier:"Can not use 'yield' as identifier inside a generator.",YieldInParameter:"Yield expression is not allowed in formal parameters.",ZeroDigitNumericSeparator:"Numeric separator can not be used after leading 0."};const d=new Set(["ArrowFunctionExpression","AssignmentExpression","ConditionalExpression","YieldExpression"]);var I={PipeBodyIsTighter:"Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",PipeTopicRequiresHackPipes:'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.',PipeTopicUnbound:"Topic reference is unbound; it must be inside a pipe body.",PipeTopicUnconfiguredToken:({token:t})=>`Invalid topic token ${t}. In order to use ${t} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${t}" }.`,PipeTopicUnused:"Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",PipeUnparenthesizedBody:({type:t})=>`Hack-style pipe body cannot be an unparenthesized ${h({type:t})}; please wrap it in parentheses.`,PipelineBodyNoArrow:'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.',PipelineBodySequenceExpression:"Pipeline body may not be a comma-separated sequence expression.",PipelineHeadSequenceExpression:"Pipeline head should not be a comma-separated sequence expression.",PipelineTopicUnused:"Pipeline is in topic style but does not use topic reference.",PrimaryTopicNotAllowed:"Topic reference was used in a lexical context without topic binding.",PrimaryTopicRequiresSmartPipeline:'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'};const u=["toMessage"],p=["message"];function b(t,e,i){Object.defineProperty(t,e,{enumerable:!1,configurable:!0,value:i})}function m(t){let{toMessage:e}=t,n=i(t,u);return function t(i,o){const a=new SyntaxError;return Object.assign(a,n,{loc:i,pos:i.index}),"missingPlugin"in o&&Object.assign(a,{missingPlugin:o.missingPlugin}),b(a,"clone",(function(e={}){var n;const{line:a,column:r,index:l}=null!=(n=e.loc)?n:i;return t(new s(a,r,l),Object.assign({},o,e.details))})),b(a,"details",o),Object.defineProperty(a,"message",{configurable:!0,get(){const t=`${e(o)} (${i.line}:${i.column})`;return this.message=t,t},set(t){Object.defineProperty(this,"message",{value:t,writable:!0})}}),a}}function y(t,e){if(Array.isArray(t))return e=>y(e,t[0]);const s={};for(const n of Object.keys(t)){const o=t[n],a="string"==typeof o?{message:()=>o}:"function"==typeof o?{message:o}:o,{message:r}=a,l=i(a,p),h="string"==typeof r?()=>r:r;s[n]=m(Object.assign({code:"BABEL_PARSER_SYNTAX_ERROR",reasonCode:n,toMessage:h},e?{syntaxPlugin:e}:{},l))}return s}const L=Object.assign({},y(r),y(c),y({StrictDelete:"Deleting local variable in strict mode.",StrictEvalArguments:({referenceName:t})=>`Assigning to '${t}' in strict mode.`,StrictEvalArgumentsBinding:({bindingName:t})=>`Binding '${t}' in strict mode.`,StrictFunction:"In strict mode code, functions can only be declared at top level or inside a block.",StrictNumericEscape:"The only valid numeric escape in strict mode is '\\0'.",StrictOctalLiteral:"Legacy octal literals are not allowed in strict mode.",StrictWith:"'with' in strict mode."}),y`pipelineOperator`(I)),{defineProperty:M}=Object,W=(t,e)=>M(t,e,{enumerable:!1,value:t[e]});function w(t){return t.loc.start&&W(t.loc.start,"index"),t.loc.end&&W(t.loc.end,"index"),t}class v{constructor(t,e){this.token=void 0,this.preserveSpace=void 0,this.token=t,this.preserveSpace=!!e}}const j={brace:new v("{"),j_oTag:new v("... ",!0)};j.template=new v("`",!0);const Z=!0,C=!0,G=!0,f=!0,N=!0;class x{constructor(t,e={}){this.label=void 0,this.keyword=void 0,this.beforeExpr=void 0,this.startsExpr=void 0,this.rightAssociative=void 0,this.isLoop=void 0,this.isAssign=void 0,this.prefix=void 0,this.postfix=void 0,this.binop=void 0,this.label=t,this.keyword=e.keyword,this.beforeExpr=!!e.beforeExpr,this.startsExpr=!!e.startsExpr,this.rightAssociative=!!e.rightAssociative,this.isLoop=!!e.isLoop,this.isAssign=!!e.isAssign,this.prefix=!!e.prefix,this.postfix=!!e.postfix,this.binop=null!=e.binop?e.binop:null,this.updateContext=null}}const Y=new Map;function R(t,e={}){e.keyword=t;const i=O(t,e);return Y.set(t,i),i}function H(t,e){return O(t,{beforeExpr:Z,binop:e})}let g=-1;const A=[],S=[],z=[],V=[],T=[],k=[];function O(t,e={}){var i,s,n,o;return++g,S.push(t),z.push(null!=(i=e.binop)?i:-1),V.push(null!=(s=e.beforeExpr)&&s),T.push(null!=(n=e.startsExpr)&&n),k.push(null!=(o=e.prefix)&&o),A.push(new x(t,e)),g}function F(t,e={}){var i,s,n,o;return++g,Y.set(t,g),S.push(t),z.push(null!=(i=e.binop)?i:-1),V.push(null!=(s=e.beforeExpr)&&s),T.push(null!=(n=e.startsExpr)&&n),k.push(null!=(o=e.prefix)&&o),A.push(new x("name",e)),g}const J={bracketL:O("[",{beforeExpr:Z,startsExpr:C}),bracketHashL:O("#[",{beforeExpr:Z,startsExpr:C}),bracketBarL:O("[|",{beforeExpr:Z,startsExpr:C}),bracketR:O("]"),bracketBarR:O("|]"),braceL:O("{",{beforeExpr:Z,startsExpr:C}),braceBarL:O("{|",{beforeExpr:Z,startsExpr:C}),braceHashL:O("#{",{beforeExpr:Z,startsExpr:C}),braceR:O("}"),braceBarR:O("|}"),parenL:O("(",{beforeExpr:Z,startsExpr:C}),parenR:O(")"),comma:O(",",{beforeExpr:Z}),semi:O(";",{beforeExpr:Z}),colon:O(":",{beforeExpr:Z}),doubleColon:O("::",{beforeExpr:Z}),dot:O("."),question:O("?",{beforeExpr:Z}),questionDot:O("?."),arrow:O("=>",{beforeExpr:Z}),template:O("template"),ellipsis:O("...",{beforeExpr:Z}),backQuote:O("`",{startsExpr:C}),dollarBraceL:O("${",{beforeExpr:Z,startsExpr:C}),templateTail:O("...`",{startsExpr:C}),templateNonTail:O("...${",{beforeExpr:Z,startsExpr:C}),at:O("@"),hash:O("#",{startsExpr:C}),interpreterDirective:O("#!..."),eq:O("=",{beforeExpr:Z,isAssign:f}),assign:O("_=",{beforeExpr:Z,isAssign:f}),slashAssign:O("_=",{beforeExpr:Z,isAssign:f}),xorAssign:O("_=",{beforeExpr:Z,isAssign:f}),moduloAssign:O("_=",{beforeExpr:Z,isAssign:f}),incDec:O("++/--",{prefix:N,postfix:!0,startsExpr:C}),bang:O("!",{beforeExpr:Z,prefix:N,startsExpr:C}),tilde:O("~",{beforeExpr:Z,prefix:N,startsExpr:C}),doubleCaret:O("^^",{startsExpr:C}),doubleAt:O("@@",{startsExpr:C}),pipeline:H("|>",0),nullishCoalescing:H("??",1),logicalOR:H("||",1),logicalAND:H("&&",2),bitwiseOR:H("|",3),bitwiseXOR:H("^",4),bitwiseAND:H("&",5),equality:H("==/!=/===/!==",6),lt:H(">/<=/>=",7),gt:H(">/<=/>=",7),relational:H(">/<=/>=",7),bitShift:H("<>>/>>>",8),bitShiftL:H("<>>/>>>",8),bitShiftR:H("<>>/>>>",8),plusMin:O("+/-",{beforeExpr:Z,binop:9,prefix:N,startsExpr:C}),modulo:O("%",{binop:10,startsExpr:C}),star:O("*",{binop:10}),slash:H("/",10),exponent:O("**",{beforeExpr:Z,binop:11,rightAssociative:!0}),_in:R("in",{beforeExpr:Z,binop:7}),_instanceof:R("instanceof",{beforeExpr:Z,binop:7}),_break:R("break"),_case:R("case",{beforeExpr:Z}),_catch:R("catch"),_continue:R("continue"),_debugger:R("debugger"),_default:R("default",{beforeExpr:Z}),_else:R("else",{beforeExpr:Z}),_finally:R("finally"),_function:R("function",{startsExpr:C}),_if:R("if"),_return:R("return",{beforeExpr:Z}),_switch:R("switch"),_throw:R("throw",{beforeExpr:Z,prefix:N,startsExpr:C}),_try:R("try"),_var:R("var"),_const:R("const"),_with:R("with"),_new:R("new",{beforeExpr:Z,startsExpr:C}),_this:R("this",{startsExpr:C}),_super:R("super",{startsExpr:C}),_class:R("class",{startsExpr:C}),_extends:R("extends",{beforeExpr:Z}),_export:R("export"),_import:R("import",{startsExpr:C}),_null:R("null",{startsExpr:C}),_true:R("true",{startsExpr:C}),_false:R("false",{startsExpr:C}),_typeof:R("typeof",{beforeExpr:Z,prefix:N,startsExpr:C}),_void:R("void",{beforeExpr:Z,prefix:N,startsExpr:C}),_delete:R("delete",{beforeExpr:Z,prefix:N,startsExpr:C}),_do:R("do",{isLoop:G,beforeExpr:Z}),_for:R("for",{isLoop:G}),_while:R("while",{isLoop:G}),_as:F("as",{startsExpr:C}),_assert:F("assert",{startsExpr:C}),_async:F("async",{startsExpr:C}),_await:F("await",{startsExpr:C}),_defer:F("defer",{startsExpr:C}),_from:F("from",{startsExpr:C}),_get:F("get",{startsExpr:C}),_let:F("let",{startsExpr:C}),_meta:F("meta",{startsExpr:C}),_of:F("of",{startsExpr:C}),_sent:F("sent",{startsExpr:C}),_set:F("set",{startsExpr:C}),_source:F("source",{startsExpr:C}),_static:F("static",{startsExpr:C}),_using:F("using",{startsExpr:C}),_yield:F("yield",{startsExpr:C}),_asserts:F("asserts",{startsExpr:C}),_checks:F("checks",{startsExpr:C}),_exports:F("exports",{startsExpr:C}),_global:F("global",{startsExpr:C}),_implements:F("implements",{startsExpr:C}),_intrinsic:F("intrinsic",{startsExpr:C}),_infer:F("infer",{startsExpr:C}),_is:F("is",{startsExpr:C}),_mixins:F("mixins",{startsExpr:C}),_proto:F("proto",{startsExpr:C}),_require:F("require",{startsExpr:C}),_satisfies:F("satisfies",{startsExpr:C}),_keyof:F("keyof",{startsExpr:C}),_readonly:F("readonly",{startsExpr:C}),_unique:F("unique",{startsExpr:C}),_abstract:F("abstract",{startsExpr:C}),_declare:F("declare",{startsExpr:C}),_enum:F("enum",{startsExpr:C}),_module:F("module",{startsExpr:C}),_namespace:F("namespace",{startsExpr:C}),_interface:F("interface",{startsExpr:C}),_type:F("type",{startsExpr:C}),_opaque:F("opaque",{startsExpr:C}),name:O("name",{startsExpr:C}),string:O("string",{startsExpr:C}),num:O("num",{startsExpr:C}),bigint:O("bigint",{startsExpr:C}),decimal:O("decimal",{startsExpr:C}),regexp:O("regexp",{startsExpr:C}),privateName:O("#name",{startsExpr:C}),eof:O("eof"),jsxName:O("jsxName"),jsxText:O("jsxText",{beforeExpr:!0}),jsxTagStart:O("jsxTagStart",{startsExpr:!0}),jsxTagEnd:O("jsxTagEnd"),placeholder:O("%%",{startsExpr:!0})};function X(t){return t>=93&&t<=132}function E(t){return t>=58&&t<=132}function D(t){return t>=58&&t<=136}function U(t){return T[t]}function B(t){return t>=129&&t<=131}function P(t){return t>=58&&t<=92}function _(t){return S[t]}function Q(t){return z[t]}function q(t){return t>=24&&t<=25}function $(t){return A[t]}A[8].updateContext=t=>{t.pop()},A[5].updateContext=A[7].updateContext=A[23].updateContext=t=>{t.push(j.brace)},A[22].updateContext=t=>{t[t.length-1]===j.template?t.pop():t.push(j.template)},A[142].updateContext=t=>{t.push(j.j_expr,j.j_oTag)};let K="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲈᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟊꟐꟑꟓꟕ-ꟙꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",tt="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛࢘-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・";const et=new RegExp("["+K+"]"),it=new RegExp("["+K+tt+"]");K=tt=null;const st=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,68,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,4026,582,8634,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,757,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],nt=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,81,2,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,9,5351,0,7,14,13835,9,87,9,39,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,4706,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,983,6,110,6,6,9,4759,9,787719,239];function ot(t,e){let i=65536;for(let s=0,n=e.length;st)return!1;if(i+=e[s+1],i>=t)return!0}return!1}function at(t){return t<65?36===t:t<=90||(t<97?95===t:t<=122||(t<=65535?t>=170&&et.test(String.fromCharCode(t)):ot(t,st)))}function rt(t){return t<48?36===t:t<58||!(t<65)&&(t<=90||(t<97?95===t:t<=122||(t<=65535?t>=170&&it.test(String.fromCharCode(t)):ot(t,st)||ot(t,nt))))}const lt=new Set(["break","case","catch","continue","debugger","default","do","else","finally","for","function","if","return","switch","throw","try","var","const","while","with","new","this","super","class","extends","export","import","null","true","false","in","instanceof","typeof","void","delete"]),ht=new Set(["implements","interface","let","package","private","protected","public","static","yield"]),ct=new Set(["eval","arguments"]);function dt(t,e){return e&&"await"===t||"enum"===t}function It(t,e){return dt(t,e)||ht.has(t)}function ut(t){return ct.has(t)}function pt(t,e){return It(t,e)||ut(t)}const bt=new Set(["break","case","catch","continue","debugger","default","do","else","finally","for","function","if","return","switch","throw","try","var","const","while","with","new","this","super","class","extends","export","import","null","true","false","in","instanceof","typeof","void","delete","implements","interface","let","package","private","protected","public","static","yield","eval","arguments","enum","await"]);class mt{constructor(t){this.flags=0,this.names=new Map,this.firstLexicalName="",this.flags=t}}class yt{constructor(t,e){this.parser=void 0,this.scopeStack=[],this.inModule=void 0,this.undefinedExports=new Map,this.parser=t,this.inModule=e}get inTopLevel(){return(1&this.currentScope().flags)>0}get inFunction(){return(2&this.currentVarScopeFlags())>0}get allowSuper(){return(16&this.currentThisScopeFlags())>0}get allowDirectSuper(){return(32&this.currentThisScopeFlags())>0}get inClass(){return(64&this.currentThisScopeFlags())>0}get inClassAndNotInNonArrowFunction(){const t=this.currentThisScopeFlags();return(64&t)>0&&0==(2&t)}get inStaticBlock(){for(let t=this.scopeStack.length-1;;t--){const{flags:e}=this.scopeStack[t];if(128&e)return!0;if(451&e)return!1}}get inNonArrowFunction(){return(2&this.currentThisScopeFlags())>0}get treatFunctionsAsVar(){return this.treatFunctionsAsVarInScope(this.currentScope())}createScope(t){return new mt(t)}enter(t){this.scopeStack.push(this.createScope(t))}exit(){return this.scopeStack.pop().flags}treatFunctionsAsVarInScope(t){return!!(130&t.flags||!this.parser.inModule&&1&t.flags)}declareName(t,e,i){let s=this.currentScope();if(8&e||16&e){this.checkRedeclarationInScope(s,t,e,i);let n=s.names.get(t)||0;16&e?n|=4:(s.firstLexicalName||(s.firstLexicalName=t),n|=2),s.names.set(t,n),8&e&&this.maybeExportDefined(s,t)}else if(4&e)for(let n=this.scopeStack.length-1;n>=0&&(s=this.scopeStack[n],this.checkRedeclarationInScope(s,t,e,i),s.names.set(t,1|(s.names.get(t)||0)),this.maybeExportDefined(s,t),!(387&s.flags));--n);this.parser.inModule&&1&s.flags&&this.undefinedExports.delete(t)}maybeExportDefined(t,e){this.parser.inModule&&1&t.flags&&this.undefinedExports.delete(e)}checkRedeclarationInScope(t,e,i,s){this.isRedeclaredInScope(t,e,i)&&this.parser.raise(L.VarRedeclaration,s,{identifierName:e})}isRedeclaredInScope(t,e,i){if(!(1&i))return!1;if(8&i)return t.names.has(e);const s=t.names.get(e);return 16&i?(2&s)>0||!this.treatFunctionsAsVarInScope(t)&&(1&s)>0:(2&s)>0&&!(8&t.flags&&t.firstLexicalName===e)||!this.treatFunctionsAsVarInScope(t)&&(4&s)>0}checkLocalExport(t){const{name:e}=t;this.scopeStack[0].names.has(e)||this.undefinedExports.set(e,t.loc.start)}currentScope(){return this.scopeStack[this.scopeStack.length-1]}currentVarScopeFlags(){for(let t=this.scopeStack.length-1;;t--){const{flags:e}=this.scopeStack[t];if(387&e)return e}}currentThisScopeFlags(){for(let t=this.scopeStack.length-1;;t--){const{flags:e}=this.scopeStack[t];if(451&e&&!(4&e))return e}}}class Lt extends mt{constructor(...t){super(...t),this.declareFunctions=new Set}}class Mt extends yt{createScope(t){return new Lt(t)}declareName(t,e,i){const s=this.currentScope();if(2048&e)return this.checkRedeclarationInScope(s,t,e,i),this.maybeExportDefined(s,t),void s.declareFunctions.add(t);super.declareName(t,e,i)}isRedeclaredInScope(t,e,i){if(super.isRedeclaredInScope(t,e,i))return!0;if(2048&i&&!t.declareFunctions.has(e)){const i=t.names.get(e);return(4&i)>0||(2&i)>0}return!1}checkLocalExport(t){this.scopeStack[0].declareFunctions.has(t.name)||super.checkLocalExport(t)}}class Wt{constructor(){this.sawUnambiguousESM=!1,this.ambiguousScriptDifferentAst=!1}hasPlugin(t){if("string"==typeof t)return this.plugins.has(t);{const[e,i]=t;if(!this.hasPlugin(e))return!1;const s=this.plugins.get(e);for(const t of Object.keys(i))if((null==s?void 0:s[t])!==i[t])return!1;return!0}}getPluginOption(t,e){var i;return null==(i=this.plugins.get(t))?void 0:i[e]}}function wt(t,e){void 0===t.trailingComments?t.trailingComments=e:t.trailingComments.unshift(...e)}function vt(t,e){void 0===t.innerComments?t.innerComments=e:t.innerComments.unshift(...e)}function jt(t,e,i){let s=null,n=e.length;for(;null===s&&n>0;)s=e[--n];null===s||s.start>i.start?vt(t,i.comments):wt(s,i.comments)}class Zt extends Wt{addComment(t){this.filename&&(t.loc.filename=this.filename);const{commentsLen:e}=this.state;this.comments.length!=e&&(this.comments.length=e),this.comments.push(t),this.state.commentsLen++}processComment(t){const{commentStack:e}=this.state,i=e.length;if(0===i)return;let s=i-1;const n=e[s];n.start===t.end&&(n.leadingNode=t,s--);const{start:o}=t;for(;s>=0;s--){const i=e[s],n=i.end;if(!(n>o)){n===o&&(i.trailingNode=t);break}i.containingNode=t,this.finalizeComment(i),e.splice(s,1)}}finalizeComment(t){const{comments:e}=t;if(null!==t.leadingNode||null!==t.trailingNode)null!==t.leadingNode&&wt(t.leadingNode,e),null!==t.trailingNode&&function(t,e){void 0===t.leadingComments?t.leadingComments=e:t.leadingComments.unshift(...e)}(t.trailingNode,e);else{const{containingNode:i,start:s}=t;if(44===this.input.charCodeAt(s-1))switch(i.type){case"ObjectExpression":case"ObjectPattern":case"RecordExpression":jt(i,i.properties,t);break;case"CallExpression":case"OptionalCallExpression":jt(i,i.arguments,t);break;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"ObjectMethod":case"ClassMethod":case"ClassPrivateMethod":jt(i,i.params,t);break;case"ArrayExpression":case"ArrayPattern":case"TupleExpression":jt(i,i.elements,t);break;case"ExportNamedDeclaration":case"ImportDeclaration":jt(i,i.specifiers,t);break;default:vt(i,e)}else vt(i,e)}}finalizeRemainingComments(){const{commentStack:t}=this.state;for(let e=t.length-1;e>=0;e--)this.finalizeComment(t[e]);this.state.commentStack=[]}resetPreviousNodeTrailingComments(t){const{commentStack:e}=this.state,{length:i}=e;if(0===i)return;const s=e[i-1];s.leadingNode===t&&(s.leadingNode=null)}resetPreviousIdentifierLeadingComments(t){const{commentStack:e}=this.state,{length:i}=e;0!==i&&(e[i-1].trailingNode===t?e[i-1].trailingNode=null:i>=2&&e[i-2].trailingNode===t&&(e[i-2].trailingNode=null))}takeSurroundingComments(t,e,i){const{commentStack:s}=this.state,n=s.length;if(0===n)return;let o=n-1;for(;o>=0;o--){const n=s[o],a=n.end;if(n.start===i)n.leadingNode=t;else if(a===e)n.trailingNode=t;else if(a0}set strict(t){t?this.flags|=1:this.flags&=-2}init({strictMode:t,sourceType:e,startLine:i,startColumn:n}){this.strict=!1!==t&&(!0===t||"module"===e),this.curLine=i,this.lineStart=-n,this.startLoc=this.endLoc=new s(i,n,0)}get maybeInArrowParameters(){return(2&this.flags)>0}set maybeInArrowParameters(t){t?this.flags|=2:this.flags&=-3}get inType(){return(4&this.flags)>0}set inType(t){t?this.flags|=4:this.flags&=-5}get noAnonFunctionType(){return(8&this.flags)>0}set noAnonFunctionType(t){t?this.flags|=8:this.flags&=-9}get hasFlowComment(){return(16&this.flags)>0}set hasFlowComment(t){t?this.flags|=16:this.flags&=-17}get isAmbientContext(){return(32&this.flags)>0}set isAmbientContext(t){t?this.flags|=32:this.flags&=-33}get inAbstractClass(){return(64&this.flags)>0}set inAbstractClass(t){t?this.flags|=64:this.flags&=-65}get inDisallowConditionalTypesContext(){return(128&this.flags)>0}set inDisallowConditionalTypesContext(t){t?this.flags|=128:this.flags&=-129}get soloAwait(){return(256&this.flags)>0}set soloAwait(t){t?this.flags|=256:this.flags&=-257}get inFSharpPipelineDirectBody(){return(512&this.flags)>0}set inFSharpPipelineDirectBody(t){t?this.flags|=512:this.flags&=-513}get canStartJSXElement(){return(1024&this.flags)>0}set canStartJSXElement(t){t?this.flags|=1024:this.flags&=-1025}get containsEsc(){return(2048&this.flags)>0}set containsEsc(t){t?this.flags|=2048:this.flags&=-2049}curPosition(){return new s(this.curLine,this.pos-this.lineStart,this.pos)}clone(){const t=new Ht;return t.flags=this.flags,t.curLine=this.curLine,t.lineStart=this.lineStart,t.startLoc=this.startLoc,t.endLoc=this.endLoc,t.errors=this.errors.slice(),t.potentialArrowAt=this.potentialArrowAt,t.noArrowAt=this.noArrowAt.slice(),t.noArrowParamsConversionAt=this.noArrowParamsConversionAt.slice(),t.topicContext=this.topicContext,t.labels=this.labels.slice(),t.commentsLen=this.commentsLen,t.commentStack=this.commentStack.slice(),t.pos=this.pos,t.type=this.type,t.value=this.value,t.start=this.start,t.end=this.end,t.lastTokEndLoc=this.lastTokEndLoc,t.lastTokStartLoc=this.lastTokStartLoc,t.context=this.context.slice(),t.firstInvalidTemplateEscapePos=this.firstInvalidTemplateEscapePos,t.strictErrors=this.strictErrors,t.tokensLength=this.tokensLength,t}}var gt=function(t){return t>=48&&t<=57};const At={decBinOct:new Set([46,66,69,79,95,98,101,111]),hex:new Set([46,88,95,120])},St={bin:t=>48===t||49===t,oct:t=>t>=48&&t<=55,dec:t=>t>=48&&t<=57,hex:t=>t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102};function zt(t,e,i,s,n,o){const a=i,r=s,l=n;let h="",c=null,d=i;const{length:I}=e;for(;;){if(i>=I){o.unterminated(a,r,l),h+=e.slice(d,i);break}const u=e.charCodeAt(i);if(Vt(t,u,e,i)){h+=e.slice(d,i);break}if(92===u){h+=e.slice(d,i);const a=Tt(e,i,s,n,"template"===t,o);null!==a.ch||c?h+=a.ch:c={pos:i,lineStart:s,curLine:n},({pos:i,lineStart:s,curLine:n}=a),d=i}else 8232===u||8233===u?(++n,s=++i):10===u||13===u?"template"===t?(h+=e.slice(d,i)+"\n",++i,13===u&&10===e.charCodeAt(i)&&++i,++n,d=s=i):o.unterminated(a,r,l):++i}return{pos:i,str:h,firstInvalidLoc:c,lineStart:s,curLine:n,containsInvalid:!!c}}function Vt(t,e,i,s){return"template"===t?96===e||36===e&&123===i.charCodeAt(s+1):e===("double"===t?34:39)}function Tt(t,e,i,s,n,o){const a=!n;e++;const r=t=>({pos:e,ch:t,lineStart:i,curLine:s}),l=t.charCodeAt(e++);switch(l){case 110:return r("\n");case 114:return r("\r");case 120:{let n;return({code:n,pos:e}=kt(t,e,i,s,2,!1,a,o)),r(null===n?null:String.fromCharCode(n))}case 117:{let n;return({code:n,pos:e}=Ft(t,e,i,s,a,o)),r(null===n?null:String.fromCodePoint(n))}case 116:return r("\t");case 98:return r("\b");case 118:return r("\v");case 102:return r("\f");case 13:10===t.charCodeAt(e)&&++e;case 10:i=e,++s;case 8232:case 8233:return r("");case 56:case 57:if(n)return r(null);o.strictNumericEscape(e-1,i,s);default:if(l>=48&&l<=55){const a=e-1;let l=t.slice(a,e+2).match(/^[0-7]+/)[0],h=parseInt(l,8);h>255&&(l=l.slice(0,-1),h=parseInt(l,8)),e+=l.length-1;const c=t.charCodeAt(e);if("0"!==l||56===c||57===c){if(n)return r(null);o.strictNumericEscape(a,i,s)}return r(String.fromCharCode(h))}return r(String.fromCharCode(l))}}function kt(t,e,i,s,n,o,a,r){const l=e;let h;return({n:h,pos:e}=Ot(t,e,i,s,16,n,o,!1,r,!a)),null===h&&(a?r.invalidEscapeSequence(l,i,s):e=l-1),{code:h,pos:e}}function Ot(t,e,i,s,n,o,a,r,l,h){const c=e,d=16===n?At.hex:At.decBinOct,I=16===n?St.hex:10===n?St.dec:8===n?St.oct:St.bin;let u=!1,p=0;for(let c=0,b=null==o?1/0:o;c=97?o-97+10:o>=65?o-65+10:gt(o)?o-48:1/0,c>=n){if(c<=9&&h)return{n:null,pos:e};if(c<=9&&l.invalidDigit(e,i,s,n))c=0;else{if(!a)break;c=0,u=!0}}++e,p=p*n+c}else{const n=t.charCodeAt(e-1),o=t.charCodeAt(e+1);if(r){if(Number.isNaN(o)||!I(o)||d.has(n)||d.has(o)){if(h)return{n:null,pos:e};l.unexpectedNumericSeparator(e,i,s)}}else{if(h)return{n:null,pos:e};l.numericSeparatorInEscapeSequence(e,i,s)}++e}}return e===c||null!=o&&e-c!==o||u?{n:null,pos:e}:{n:p,pos:e}}function Ft(t,e,i,s,n,o){let a;if(123===t.charCodeAt(e)){if(++e,({code:a,pos:e}=kt(t,e,i,s,t.indexOf("}",e)-e,!0,n,o)),++e,null!==a&&a>1114111){if(!n)return{code:null,pos:e};o.invalidCodePoint(e,i,s)}}else({code:a,pos:e}=kt(t,e,i,s,4,!1,n,o));return{code:a,pos:e}}function Jt(t,e,i){return new s(i,t-e,t)}const Xt=new Set([103,109,115,105,121,117,100,118]);class Et{constructor(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,this.loc=new n(t.startLoc,t.endLoc)}}class Dt extends Zt{constructor(t,e){super(),this.isLookahead=void 0,this.tokens=[],this.errorHandlers_readInt={invalidDigit:(t,e,i,s)=>!!this.options.errorRecovery&&(this.raise(L.InvalidDigit,Jt(t,e,i),{radix:s}),!0),numericSeparatorInEscapeSequence:this.errorBuilder(L.NumericSeparatorInEscapeSequence),unexpectedNumericSeparator:this.errorBuilder(L.UnexpectedNumericSeparator)},this.errorHandlers_readCodePoint=Object.assign({},this.errorHandlers_readInt,{invalidEscapeSequence:this.errorBuilder(L.InvalidEscapeSequence),invalidCodePoint:this.errorBuilder(L.InvalidCodePoint)}),this.errorHandlers_readStringContents_string=Object.assign({},this.errorHandlers_readCodePoint,{strictNumericEscape:(t,e,i)=>{this.recordStrictModeErrors(L.StrictNumericEscape,Jt(t,e,i))},unterminated:(t,e,i)=>{throw this.raise(L.UnterminatedString,Jt(t-1,e,i))}}),this.errorHandlers_readStringContents_template=Object.assign({},this.errorHandlers_readCodePoint,{strictNumericEscape:this.errorBuilder(L.StrictNumericEscape),unterminated:(t,e,i)=>{throw this.raise(L.UnterminatedTemplate,Jt(t,e,i))}}),this.state=new Ht,this.state.init(t),this.input=e,this.length=e.length,this.comments=[],this.isLookahead=!1}pushToken(t){this.tokens.length=this.state.tokensLength,this.tokens.push(t),++this.state.tokensLength}next(){this.checkKeywordEscapes(),this.options.tokens&&this.pushToken(new Et(this.state)),this.state.lastTokEndLoc=this.state.endLoc,this.state.lastTokStartLoc=this.state.startLoc,this.nextToken()}eat(t){return!!this.match(t)&&(this.next(),!0)}match(t){return this.state.type===t}createLookaheadState(t){return{pos:t.pos,value:null,type:t.type,start:t.start,end:t.end,context:[this.curContext()],inType:t.inType,startLoc:t.startLoc,lastTokEndLoc:t.lastTokEndLoc,curLine:t.curLine,lineStart:t.lineStart,curPosition:t.curPosition}}lookahead(){const t=this.state;this.state=this.createLookaheadState(t),this.isLookahead=!0,this.nextToken(),this.isLookahead=!1;const e=this.state;return this.state=t,e}nextTokenStart(){return this.nextTokenStartSince(this.state.pos)}nextTokenStartSince(t){return Nt.lastIndex=t,Nt.test(this.input)?Nt.lastIndex:t}lookaheadCharCode(){return this.input.charCodeAt(this.nextTokenStart())}nextTokenInLineStart(){return this.nextTokenInLineStartSince(this.state.pos)}nextTokenInLineStartSince(t){return xt.lastIndex=t,xt.test(this.input)?xt.lastIndex:t}lookaheadInLineCharCode(){return this.input.charCodeAt(this.nextTokenInLineStart())}codePointAtPos(t){let e=this.input.charCodeAt(t);if(55296==(64512&e)&&++tthis.raise(t,e))),this.state.strictErrors.clear())}curContext(){return this.state.context[this.state.context.length-1]}nextToken(){this.skipSpace(),this.state.start=this.state.pos,this.isLookahead||(this.state.startLoc=this.state.curPosition()),this.state.pos>=this.length?this.finishToken(139):this.getTokenFromCode(this.codePointAtPos(this.state.pos))}skipBlockComment(t){let e;this.isLookahead||(e=this.state.curPosition());const i=this.state.pos,s=this.input.indexOf(t,i+2);if(-1===s)throw this.raise(L.UnterminatedComment,this.state.curPosition());for(this.state.pos=s+t.length,Gt.lastIndex=i+2;Gt.test(this.input)&&Gt.lastIndex<=s;)++this.state.curLine,this.state.lineStart=Gt.lastIndex;if(this.isLookahead)return;const o={type:"CommentBlock",value:this.input.slice(i+2,s),start:i,end:s+t.length,loc:new n(e,this.state.curPosition())};return this.options.tokens&&this.pushToken(o),o}skipLineComment(t){const e=this.state.pos;let i;this.isLookahead||(i=this.state.curPosition());let s=this.input.charCodeAt(this.state.pos+=t);if(this.state.post))break t;{const t=this.skipLineComment(3);void 0!==t&&(this.addComment(t),this.options.attachComment&&e.push(t))}}else{if(60!==i||this.inModule||!this.options.annexB)break t;{const t=this.state.pos;if(33!==this.input.charCodeAt(t+1)||45!==this.input.charCodeAt(t+2)||45!==this.input.charCodeAt(t+3))break t;{const t=this.skipLineComment(4);void 0!==t&&(this.addComment(t),this.options.attachComment&&e.push(t))}}}}}if(e.length>0){const i={start:t,end:this.state.pos,comments:e,leadingNode:null,trailingNode:null,containingNode:null};this.state.commentStack.push(i)}}finishToken(t,e){this.state.end=this.state.pos,this.state.endLoc=this.state.curPosition();const i=this.state.type;this.state.type=t,this.state.value=e,this.isLookahead||this.updateContext(i)}replaceToken(t){this.state.type=t,this.updateContext()}readToken_numberSign(){if(0===this.state.pos&&this.readToken_interpreter())return;const t=this.state.pos+1,e=this.codePointAtPos(t);if(e>=48&&e<=57)throw this.raise(L.UnexpectedDigitAfterHash,this.state.curPosition());if(123===e||91===e&&this.hasPlugin("recordAndTuple")){if(this.expectPlugin("recordAndTuple"),"bar"===this.getPluginOption("recordAndTuple","syntaxType"))throw this.raise(123===e?L.RecordExpressionHashIncorrectStartSyntaxType:L.TupleExpressionHashIncorrectStartSyntaxType,this.state.curPosition());this.state.pos+=2,123===e?this.finishToken(7):this.finishToken(1)}else at(e)?(++this.state.pos,this.finishToken(138,this.readWord1(e))):92===e?(++this.state.pos,this.finishToken(138,this.readWord1())):this.finishOp(27,1)}readToken_dot(){const t=this.input.charCodeAt(this.state.pos+1);t>=48&&t<=57?this.readNumber(!0):46===t&&46===this.input.charCodeAt(this.state.pos+2)?(this.state.pos+=3,this.finishToken(21)):(++this.state.pos,this.finishToken(16))}readToken_slash(){61===this.input.charCodeAt(this.state.pos+1)?this.finishOp(31,2):this.finishOp(56,1)}readToken_interpreter(){if(0!==this.state.pos||this.length<2)return!1;let t=this.input.charCodeAt(this.state.pos+1);if(33!==t)return!1;const e=this.state.pos;for(this.state.pos+=1;!ft(t)&&++this.state.pos=48&&e<=57?(++this.state.pos,this.finishToken(17)):(this.state.pos+=2,this.finishToken(18))}getTokenFromCode(t){switch(t){case 46:return void this.readToken_dot();case 40:return++this.state.pos,void this.finishToken(10);case 41:return++this.state.pos,void this.finishToken(11);case 59:return++this.state.pos,void this.finishToken(13);case 44:return++this.state.pos,void this.finishToken(12);case 91:if(this.hasPlugin("recordAndTuple")&&124===this.input.charCodeAt(this.state.pos+1)){if("bar"!==this.getPluginOption("recordAndTuple","syntaxType"))throw this.raise(L.TupleExpressionBarIncorrectStartSyntaxType,this.state.curPosition());this.state.pos+=2,this.finishToken(2)}else++this.state.pos,this.finishToken(0);return;case 93:return++this.state.pos,void this.finishToken(3);case 123:if(this.hasPlugin("recordAndTuple")&&124===this.input.charCodeAt(this.state.pos+1)){if("bar"!==this.getPluginOption("recordAndTuple","syntaxType"))throw this.raise(L.RecordExpressionBarIncorrectStartSyntaxType,this.state.curPosition());this.state.pos+=2,this.finishToken(6)}else++this.state.pos,this.finishToken(5);return;case 125:return++this.state.pos,void this.finishToken(8);case 58:return void(this.hasPlugin("functionBind")&&58===this.input.charCodeAt(this.state.pos+1)?this.finishOp(15,2):(++this.state.pos,this.finishToken(14)));case 63:return void this.readToken_question();case 96:return void this.readTemplateToken();case 48:{const t=this.input.charCodeAt(this.state.pos+1);if(120===t||88===t)return void this.readRadixNumber(16);if(111===t||79===t)return void this.readRadixNumber(8);if(98===t||66===t)return void this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return void this.readNumber(!1);case 34:case 39:return void this.readString(t);case 47:return void this.readToken_slash();case 37:case 42:return void this.readToken_mult_modulo(t);case 124:case 38:return void this.readToken_pipe_amp(t);case 94:return void this.readToken_caret();case 43:case 45:return void this.readToken_plus_min(t);case 60:return void this.readToken_lt();case 62:return void this.readToken_gt();case 61:case 33:return void this.readToken_eq_excl(t);case 126:return void this.finishOp(36,1);case 64:return void this.readToken_atSign();case 35:return void this.readToken_numberSign();case 92:return void this.readWord();default:if(at(t))return void this.readWord(t)}throw this.raise(L.InvalidOrUnexpectedToken,this.state.curPosition(),{unexpected:String.fromCodePoint(t)})}finishOp(t,e){const i=this.input.slice(this.state.pos,this.state.pos+e);this.state.pos+=e,this.finishToken(t,i)}readRegexp(){const t=this.state.startLoc,e=this.state.start+1;let i,s,{pos:n}=this.state;for(;;++n){if(n>=this.length)throw this.raise(L.UnterminatedRegExp,o(t,1));const e=this.input.charCodeAt(n);if(ft(e))throw this.raise(L.UnterminatedRegExp,o(t,1));if(i)i=!1;else{if(91===e)s=!0;else if(93===e&&s)s=!1;else if(47===e&&!s)break;i=92===e}}const a=this.input.slice(e,n);++n;let r="";const l=()=>o(t,n+2-e);for(;n=2&&48===this.input.charCodeAt(e);if(h){const t=this.input.slice(e,this.state.pos);if(this.recordStrictModeErrors(L.StrictOctalLiteral,i),!this.state.strict){const e=t.indexOf("_");e>0&&this.raise(L.ZeroDigitNumericSeparator,o(i,e))}l=h&&!/[89]/.test(t)}let c=this.input.charCodeAt(this.state.pos);if(46!==c||l||(++this.state.pos,this.readInt(10),s=!0,c=this.input.charCodeAt(this.state.pos)),69!==c&&101!==c||l||(c=this.input.charCodeAt(++this.state.pos),43!==c&&45!==c||++this.state.pos,null===this.readInt(10)&&this.raise(L.InvalidOrMissingExponent,i),s=!0,r=!0,c=this.input.charCodeAt(this.state.pos)),110===c&&((s||h)&&this.raise(L.InvalidBigIntLiteral,i),++this.state.pos,n=!0),109===c&&(this.expectPlugin("decimal",this.state.curPosition()),(r||h)&&this.raise(L.InvalidDecimal,i),++this.state.pos,a=!0),at(this.codePointAtPos(this.state.pos)))throw this.raise(L.NumberIdentifier,this.state.curPosition());const d=this.input.slice(e,this.state.pos).replace(/[_mn]/g,"");if(n)return void this.finishToken(135,d);if(a)return void this.finishToken(136,d);const I=l?parseInt(d,8):parseFloat(d);this.finishToken(134,I)}readCodePoint(t){const{code:e,pos:i}=Ft(this.input,this.state.pos,this.state.lineStart,this.state.curLine,t,this.errorHandlers_readCodePoint);return this.state.pos=i,e}readString(t){const{str:e,pos:i,curLine:s,lineStart:n}=zt(34===t?"double":"single",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_string);this.state.pos=i+1,this.state.lineStart=n,this.state.curLine=s,this.finishToken(133,e)}readTemplateContinuation(){this.match(8)||this.unexpected(null,8),this.state.pos--,this.readTemplateToken()}readTemplateToken(){const t=this.input[this.state.pos],{str:e,firstInvalidLoc:i,pos:n,curLine:o,lineStart:a}=zt("template",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_template);this.state.pos=n+1,this.state.lineStart=a,this.state.curLine=o,i&&(this.state.firstInvalidTemplateEscapePos=new s(i.curLine,i.pos-i.lineStart,i.pos)),96===this.input.codePointAt(n)?this.finishToken(24,i?null:t+e+"`"):(this.state.pos++,this.finishToken(25,i?null:t+e+"${"))}recordStrictModeErrors(t,e){const i=e.index;this.state.strict&&!this.state.strictErrors.has(i)?this.raise(t,e):this.state.strictErrors.set(i,[t,e])}readWord1(t){this.state.containsEsc=!1;let e="";const i=this.state.pos;let s=this.state.pos;for(void 0!==t&&(this.state.pos+=t<=65535?1:2);this.state.pos=0;e--){const s=a[e];if(s.loc.index===o)return a[e]=t(n,i);if(s.loc.indexthis.hasPlugin(t))))throw this.raise(L.MissingOneOfPlugins,this.state.startLoc,{missingPlugin:t})}errorBuilder(t){return(e,i,s)=>{this.raise(t,Jt(e,i,s))}}}class Ut{constructor(){this.privateNames=new Set,this.loneAccessors=new Map,this.undefinedPrivateNames=new Map}}class Bt{constructor(t){this.parser=void 0,this.stack=[],this.undefinedPrivateNames=new Map,this.parser=t}current(){return this.stack[this.stack.length-1]}enter(){this.stack.push(new Ut)}exit(){const t=this.stack.pop(),e=this.current();for(const[i,s]of Array.from(t.undefinedPrivateNames))e?e.undefinedPrivateNames.has(i)||e.undefinedPrivateNames.set(i,s):this.parser.raise(L.InvalidPrivateFieldResolution,s,{identifierName:i})}declarePrivateName(t,e,i){const{privateNames:s,loneAccessors:n,undefinedPrivateNames:o}=this.current();let a=s.has(t);if(3&e){const i=a&&n.get(t);i?(a=(3&i)==(3&e)||(4&i)!=(4&e),a||n.delete(t)):a||n.set(t,e)}a&&this.parser.raise(L.PrivateNameRedeclaration,i,{identifierName:t}),s.add(t),o.delete(t)}usePrivateName(t,e){let i;for(i of this.stack)if(i.privateNames.has(t))return;i?i.undefinedPrivateNames.set(t,e):this.parser.raise(L.InvalidPrivateFieldResolution,e,{identifierName:t})}}class Pt{constructor(t=0){this.type=t}canBeArrowParameterDeclaration(){return 2===this.type||1===this.type}isCertainlyParameterDeclaration(){return 3===this.type}}class _t extends Pt{constructor(t){super(t),this.declarationErrors=new Map}recordDeclarationError(t,e){const i=e.index;this.declarationErrors.set(i,[t,e])}clearDeclarationError(t){this.declarationErrors.delete(t)}iterateErrors(t){this.declarationErrors.forEach(t)}}class Qt{constructor(t){this.parser=void 0,this.stack=[new Pt],this.parser=t}enter(t){this.stack.push(t)}exit(){this.stack.pop()}recordParameterInitializerError(t,e){const i=e.loc.start,{stack:s}=this;let n=s.length-1,o=s[n];for(;!o.isCertainlyParameterDeclaration();){if(!o.canBeArrowParameterDeclaration())return;o.recordDeclarationError(t,i),o=s[--n]}this.parser.raise(t,i)}recordArrowParameterBindingError(t,e){const{stack:i}=this,s=i[i.length-1],n=e.loc.start;if(s.isCertainlyParameterDeclaration())this.parser.raise(t,n);else{if(!s.canBeArrowParameterDeclaration())return;s.recordDeclarationError(t,n)}}recordAsyncArrowParametersError(t){const{stack:e}=this;let i=e.length-1,s=e[i];for(;s.canBeArrowParameterDeclaration();)2===s.type&&s.recordDeclarationError(L.AwaitBindingIdentifier,t),s=e[--i]}validateAsPattern(){const{stack:t}=this,e=t[t.length-1];e.canBeArrowParameterDeclaration()&&e.iterateErrors((([e,i])=>{this.parser.raise(e,i);let s=t.length-2,n=t[s];for(;n.canBeArrowParameterDeclaration();)n.clearDeclarationError(i.index),n=t[--s]}))}}function qt(){return new Pt}class $t{constructor(){this.stacks=[]}enter(t){this.stacks.push(t)}exit(){this.stacks.pop()}currentFlags(){return this.stacks[this.stacks.length-1]}get hasAwait(){return(2&this.currentFlags())>0}get hasYield(){return(1&this.currentFlags())>0}get hasReturn(){return(4&this.currentFlags())>0}get hasIn(){return(8&this.currentFlags())>0}}function Kt(t,e){return(t?2:0)|(e?1:0)}class te extends Dt{addExtra(t,e,i,s=!0){if(!t)return;const n=t.extra=t.extra||{};s?n[e]=i:Object.defineProperty(n,e,{enumerable:s,value:i})}isContextual(t){return this.state.type===t&&!this.state.containsEsc}isUnparsedContextual(t,e){const i=t+e.length;if(this.input.slice(t,i)===e){const t=this.input.charCodeAt(i);return!(rt(t)||55296==(64512&t))}return!1}isLookaheadContextual(t){const e=this.nextTokenStart();return this.isUnparsedContextual(e,t)}eatContextual(t){return!!this.isContextual(t)&&(this.next(),!0)}expectContextual(t,e){if(!this.eatContextual(t)){if(null!=e)throw this.raise(e,this.state.startLoc);this.unexpected(null,t)}}canInsertSemicolon(){return this.match(139)||this.match(8)||this.hasPrecedingLineBreak()}hasPrecedingLineBreak(){return Ct.test(this.input.slice(this.state.lastTokEndLoc.index,this.state.start))}hasFollowingLineBreak(){return Yt.lastIndex=this.state.end,Yt.test(this.input)}isLineTerminator(){return this.eat(13)||this.canInsertSemicolon()}semicolon(t=!0){(t?this.isLineTerminator():this.eat(13))||this.raise(L.MissingSemicolon,this.state.lastTokEndLoc)}expect(t,e){this.eat(t)||this.unexpected(e,t)}tryParse(t,e=this.state.clone()){const i={node:null};try{const s=t(((t=null)=>{throw i.node=t,i}));if(this.state.errors.length>e.errors.length){const t=this.state;return this.state=e,this.state.tokensLength=t.tokensLength,{node:s,error:t.errors[e.errors.length],thrown:!1,aborted:!1,failState:t}}return{node:s,error:null,thrown:!1,aborted:!1,failState:null}}catch(t){const s=this.state;if(this.state=e,t instanceof SyntaxError)return{node:null,error:t,thrown:!0,aborted:!1,failState:s};if(t===i)return{node:i.node,error:null,thrown:!1,aborted:!0,failState:s};throw t}}checkExpressionErrors(t,e){if(!t)return!1;const{shorthandAssignLoc:i,doubleProtoLoc:s,privateKeyLoc:n,optionalParametersLoc:o}=t;if(!e)return!!(i||s||o||n);null!=i&&this.raise(L.InvalidCoverInitializedName,i),null!=s&&this.raise(L.DuplicateProto,s),null!=n&&this.raise(L.UnexpectedPrivateField,n),null!=o&&this.unexpected(o)}isLiteralPropertyName(){return D(this.state.type)}isPrivateName(t){return"PrivateName"===t.type}getPrivateNameSV(t){return t.id.name}hasPropertyAsPrivateName(t){return("MemberExpression"===t.type||"OptionalMemberExpression"===t.type)&&this.isPrivateName(t.property)}isObjectProperty(t){return"ObjectProperty"===t.type}isObjectMethod(t){return"ObjectMethod"===t.type}initializeScopes(t="module"===this.options.sourceType){const e=this.state.labels;this.state.labels=[];const i=this.exportedIdentifiers;this.exportedIdentifiers=new Set;const s=this.inModule;this.inModule=t;const n=this.scope,o=this.getScopeHandler();this.scope=new o(this,t);const a=this.prodParam;this.prodParam=new $t;const r=this.classScope;this.classScope=new Bt(this);const l=this.expressionScope;return this.expressionScope=new Qt(this),()=>{this.state.labels=e,this.exportedIdentifiers=i,this.inModule=s,this.scope=n,this.prodParam=a,this.classScope=r,this.expressionScope=l}}enterInitialScopes(){let t=0;this.inModule&&(t|=2),this.scope.enter(1),this.prodParam.enter(t)}checkDestructuringPrivate(t){const{privateKeyLoc:e}=t;null!==e&&this.expectPlugin("destructuringPrivate",e)}}class ee{constructor(){this.shorthandAssignLoc=null,this.doubleProtoLoc=null,this.privateKeyLoc=null,this.optionalParametersLoc=null}}class ie{constructor(t,e,i){this.type="",this.start=e,this.end=0,this.loc=new n(i),null!=t&&t.options.ranges&&(this.range=[e,0]),null!=t&&t.filename&&(this.loc.filename=t.filename)}}const se=ie.prototype;function ne(t){const{type:e,start:i,end:s,loc:n,range:o,extra:a,name:r}=t,l=Object.create(se);return l.type=e,l.start=i,l.end=s,l.loc=n,l.range=o,l.extra=a,l.name=r,"Placeholder"===e&&(l.expectedNode=t.expectedNode),l}se.__clone=function(){const t=new ie(void 0,this.start,this.loc.start),e=Object.keys(this);for(let i=0,s=e.length;i`Cannot overwrite reserved type ${t}.`,DeclareClassElement:"The `declare` modifier can only appear on class fields.",DeclareClassFieldInitializer:"Initializers are not allowed in fields with the `declare` modifier.",DuplicateDeclareModuleExports:"Duplicate `declare module.exports` statement.",EnumBooleanMemberNotInitialized:({memberName:t,enumName:e})=>`Boolean enum members need to be initialized. Use either \`${t} = true,\` or \`${t} = false,\` in enum \`${e}\`.`,EnumDuplicateMemberName:({memberName:t,enumName:e})=>`Enum member names need to be unique, but the name \`${t}\` has already been used before in enum \`${e}\`.`,EnumInconsistentMemberValues:({enumName:t})=>`Enum \`${t}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,EnumInvalidExplicitType:({invalidEnumType:t,enumName:e})=>`Enum type \`${t}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${e}\`.`,EnumInvalidExplicitTypeUnknownSupplied:({enumName:t})=>`Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${t}\`.`,EnumInvalidMemberInitializerPrimaryType:({enumName:t,memberName:e,explicitType:i})=>`Enum \`${t}\` has type \`${i}\`, so the initializer of \`${e}\` needs to be a ${i} literal.`,EnumInvalidMemberInitializerSymbolType:({enumName:t,memberName:e})=>`Symbol enum members cannot be initialized. Use \`${e},\` in enum \`${t}\`.`,EnumInvalidMemberInitializerUnknownType:({enumName:t,memberName:e})=>`The enum member initializer for \`${e}\` needs to be a literal (either a boolean, number, or string) in enum \`${t}\`.`,EnumInvalidMemberName:({enumName:t,memberName:e,suggestion:i})=>`Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${e}\`, consider using \`${i}\`, in enum \`${t}\`.`,EnumNumberMemberNotInitialized:({enumName:t,memberName:e})=>`Number enum members need to be initialized, e.g. \`${e} = 1\` in enum \`${t}\`.`,EnumStringMemberInconsistentlyInitialized:({enumName:t})=>`String enum members need to consistently either all use initializers, or use no initializers, in enum \`${t}\`.`,GetterMayNotHaveThisParam:"A getter cannot have a `this` parameter.",ImportReflectionHasImportType:"An `import module` declaration can not use `type` or `typeof` keyword.",ImportTypeShorthandOnlyInPureImport:"The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements.",InexactInsideExact:"Explicit inexact syntax cannot appear inside an explicit exact object type.",InexactInsideNonObject:"Explicit inexact syntax cannot appear in class or interface definitions.",InexactVariance:"Explicit inexact syntax cannot have variance.",InvalidNonTypeImportInDeclareModule:"Imports within a `declare module` body must always be `import type` or `import typeof`.",MissingTypeParamDefault:"Type parameter declaration needs a default, since a preceding type parameter declaration has a default.",NestedDeclareModule:"`declare module` cannot be used inside another `declare module`.",NestedFlowComment:"Cannot have a flow comment inside another flow comment.",PatternIsOptional:Object.assign({message:"A binding pattern parameter cannot be optional in an implementation signature."},{reasonCode:"OptionalBindingPattern"}),SetterMayNotHaveThisParam:"A setter cannot have a `this` parameter.",SpreadVariance:"Spread properties cannot have variance.",ThisParamAnnotationRequired:"A type annotation is required for the `this` parameter.",ThisParamBannedInConstructor:"Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",ThisParamMayNotBeOptional:"The `this` parameter cannot be optional.",ThisParamMustBeFirst:"The `this` parameter must be the first function parameter.",ThisParamNoDefault:"The `this` parameter may not have a default value.",TypeBeforeInitializer:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeCastInPattern:"The type cast expression is expected to be wrapped with parenthesis.",UnexpectedExplicitInexactInObject:"Explicit inexact syntax must appear at the end of an inexact object.",UnexpectedReservedType:({reservedType:t})=>`Unexpected reserved type ${t}.`,UnexpectedReservedUnderscore:"`_` is only allowed as a type argument to call or new.",UnexpectedSpaceBetweenModuloChecks:"Spaces between `%` and `checks` are not allowed here.",UnexpectedSpreadType:"Spread operator cannot appear in class or interface definitions.",UnexpectedSubtractionOperand:'Unexpected token, expected "number" or "bigint".',UnexpectedTokenAfterTypeParameter:"Expected an arrow function after this type parameter declaration.",UnexpectedTypeParameterBeforeAsyncArrowFunction:"Type parameters must come after the async keyword, e.g. instead of ` async () => {}`, use `async () => {}`.",UnsupportedDeclareExportKind:({unsupportedExportKind:t,suggestion:e})=>`\`declare export ${t}\` is not supported. Use \`${e}\` instead.`,UnsupportedStatementInDeclareModule:"Only declares and type imports are allowed inside declare module.",UnterminatedFlowComment:"Unterminated flow-comment."});function le(t){return"type"===t.importKind||"typeof"===t.importKind}const he={const:"declare export var",let:"declare export var",type:"export type",interface:"export interface"},ce=/\*?\s*@((?:no)?flow)\b/,de={__proto__:null,quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"},Ie=y`jsx`({AttributeIsEmpty:"JSX attributes must only be assigned a non-empty expression.",MissingClosingTagElement:({openingTagName:t})=>`Expected corresponding JSX closing tag for <${t}>.`,MissingClosingTagFragment:"Expected corresponding JSX closing tag for <>.",UnexpectedSequenceExpression:"Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",UnexpectedToken:({unexpected:t,HTMLEntity:e})=>`Unexpected token \`${t}\`. Did you mean \`${e}\` or \`{'${t}'}\`?`,UnsupportedJsxValue:"JSX value should be either an expression or a quoted JSX text.",UnterminatedJsxContent:"Unterminated JSX contents.",UnwrappedAdjacentJSXElements:"Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...>?"});function ue(t){return!!t&&("JSXOpeningFragment"===t.type||"JSXClosingFragment"===t.type)}function pe(t){if("JSXIdentifier"===t.type)return t.name;if("JSXNamespacedName"===t.type)return t.namespace.name+":"+t.name.name;if("JSXMemberExpression"===t.type)return pe(t.object)+"."+pe(t.property);throw new Error("Node had unexpected type: "+t.type)}class be extends mt{constructor(...t){super(...t),this.tsNames=new Map}}class me extends yt{constructor(...t){super(...t),this.importsStack=[]}createScope(t){return this.importsStack.push(new Set),new be(t)}enter(t){256==t&&this.importsStack.push(new Set),super.enter(t)}exit(){const t=super.exit();return 256==t&&this.importsStack.pop(),t}hasImport(t,e){const i=this.importsStack.length;if(this.importsStack[i-1].has(t))return!0;if(!e&&i>1)for(let e=0;e0?!(256&i)||!!(512&i)!=(4&s)>0:128&i&&(8&s)>0?!!(2&t.names.get(e))&&!!(1&i):!!(2&i&&(1&s)>0)||super.isRedeclaredInScope(t,e,i)}checkLocalExport(t){const{name:e}=t;if(!this.hasImport(e)){for(let t=this.scopeStack.length-1;t>=0;t--){const i=this.scopeStack[t].tsNames.get(e);if((1&i)>0||(16&i)>0)return}super.checkLocalExport(t)}}}const ye=t=>"ParenthesizedExpression"===t.type?ye(t.expression):t;class Le extends oe{toAssignable(t,e=!1){var i,s;let n;switch(("ParenthesizedExpression"===t.type||null!=(i=t.extra)&&i.parenthesized)&&(n=ye(t),e?"Identifier"===n.type?this.expressionScope.recordArrowParameterBindingError(L.InvalidParenthesizedAssignment,t):"MemberExpression"===n.type||this.isOptionalMemberExpression(n)||this.raise(L.InvalidParenthesizedAssignment,t):this.raise(L.InvalidParenthesizedAssignment,t)),t.type){case"Identifier":case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern";for(let i=0,s=t.properties.length,n=s-1;i"ObjectMethod"!==t.type&&(i===e||"SpreadElement"!==t.type)&&this.isAssignable(t)))}case"ObjectProperty":return this.isAssignable(t.value);case"SpreadElement":return this.isAssignable(t.argument);case"ArrayExpression":return t.elements.every((t=>null===t||this.isAssignable(t)));case"AssignmentExpression":return"="===t.operator;case"ParenthesizedExpression":return this.isAssignable(t.expression);case"MemberExpression":case"OptionalMemberExpression":return!e;default:return!1}}toReferencedList(t,e){return t}toReferencedListDeep(t,e){this.toReferencedList(t,e);for(const e of t)"ArrayExpression"===(null==e?void 0:e.type)&&this.toReferencedListDeep(e.elements)}parseSpread(t){const e=this.startNode();return this.next(),e.argument=this.parseMaybeAssignAllowIn(t,void 0),this.finishNode(e,"SpreadElement")}parseRestBinding(){const t=this.startNode();return this.next(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")}parseBindingAtom(){switch(this.state.type){case 0:{const t=this.startNode();return this.next(),t.elements=this.parseBindingList(3,93,1),this.finishNode(t,"ArrayPattern")}case 5:return this.parseObjectLike(8,!0)}return this.parseIdentifier()}parseBindingList(t,e,i){const s=1&i,n=[];let o=!0;for(;!this.eat(t);)if(o?o=!1:this.expect(12),s&&this.match(12))n.push(null);else{if(this.eat(t))break;if(this.match(21)){if(n.push(this.parseAssignableListItemTypes(this.parseRestBinding(),i)),!this.checkCommaAfterRest(e)){this.expect(t);break}}else{const t=[];for(this.match(26)&&this.hasPlugin("decorators")&&this.raise(L.UnsupportedParameterDecorator,this.state.startLoc);this.match(26);)t.push(this.parseDecorator());n.push(this.parseAssignableListItem(i,t))}}return n}parseBindingRestProperty(t){return this.next(),t.argument=this.parseIdentifier(),this.checkCommaAfterRest(125),this.finishNode(t,"RestElement")}parseBindingProperty(){const t=this.startNode(),{type:e,startLoc:i}=this.state;return 21===e?this.parseBindingRestProperty(t):(138===e?(this.expectPlugin("destructuringPrivate",i),this.classScope.usePrivateName(this.state.value,i),t.key=this.parsePrivateName()):this.parsePropertyName(t),t.method=!1,this.parseObjPropValue(t,i,!1,!1,!0,!1))}parseAssignableListItem(t,e){const i=this.parseMaybeDefault();this.parseAssignableListItemTypes(i,t);const s=this.parseMaybeDefault(i.loc.start,i);return e.length&&(i.decorators=e),s}parseAssignableListItemTypes(t,e){return t}parseMaybeDefault(t,e){var i;if(null!=t||(t=this.state.startLoc),e=null!=(i=e)?i:this.parseBindingAtom(),!this.eat(29))return e;const s=this.startNodeAt(t);return s.left=e,s.right=this.parseMaybeAssignAllowIn(),this.finishNode(s,"AssignmentPattern")}isValidLVal(t,e,i){return s={AssignmentPattern:"left",RestElement:"argument",ObjectProperty:"value",ParenthesizedExpression:"expression",ArrayPattern:"elements",ObjectPattern:"properties"},n=t,Object.hasOwnProperty.call(s,n)&&s[n];var s,n}isOptionalMemberExpression(t){return"OptionalMemberExpression"===t.type}checkLVal(t,{in:e,binding:i=64,checkClashes:s=!1,strictModeChanged:n=!1,hasParenthesizedAncestor:o=!1}){var a;const r=t.type;if(this.isObjectMethod(t))return;const l=this.isOptionalMemberExpression(t);if(l||"MemberExpression"===r)return l&&(this.expectPlugin("optionalChainingAssign",t.loc.start),"AssignmentExpression"!==e.type&&this.raise(L.InvalidLhsOptionalChaining,t,{ancestor:e})),void(64!==i&&this.raise(L.InvalidPropertyBindingPattern,t));if("Identifier"===r){this.checkIdentifier(t,i,n);const{name:e}=t;return void(s&&(s.has(e)?this.raise(L.ParamDupe,t):s.add(e)))}const h=this.isValidLVal(r,!(o||null!=(a=t.extra)&&a.parenthesized)&&"AssignmentExpression"===e.type,i);if(!0===h)return;if(!1===h){const s=64===i?L.InvalidLhs:L.InvalidLhsBinding;return void this.raise(s,t,{ancestor:e})}const[c,d]=Array.isArray(h)?h:[h,"ParenthesizedExpression"===r],I="ArrayPattern"===r||"ObjectPattern"===r?{type:r}:e;for(const e of[].concat(t[c]))e&&this.checkLVal(e,{in:I,binding:i,checkClashes:s,strictModeChanged:n,hasParenthesizedAncestor:d})}checkIdentifier(t,e,i=!1){this.state.strict&&(i?pt(t.name,this.inModule):ut(t.name))&&(64===e?this.raise(L.StrictEvalArguments,t,{referenceName:t.name}):this.raise(L.StrictEvalArgumentsBinding,t,{bindingName:t.name})),8192&e&&"let"===t.name&&this.raise(L.LetInLexicalBinding,t),64&e||this.declareNameFromIdentifier(t,e)}declareNameFromIdentifier(t,e){this.scope.declareName(t.name,e,t.loc.start)}checkToRestConversion(t,e){switch(t.type){case"ParenthesizedExpression":this.checkToRestConversion(t.expression,e);break;case"Identifier":case"MemberExpression":break;case"ArrayExpression":case"ObjectExpression":if(e)break;default:this.raise(L.InvalidRestAssignmentPattern,t)}}checkCommaAfterRest(t){return!!this.match(12)&&(this.raise(this.lookaheadCharCode()===t?L.RestTrailingComma:L.ElementAfterRest,this.state.startLoc),!0)}}function Me(t){if(!t)throw new Error("Assert fail")}const We=y`typescript`({AbstractMethodHasImplementation:({methodName:t})=>`Method '${t}' cannot have an implementation because it is marked abstract.`,AbstractPropertyHasInitializer:({propertyName:t})=>`Property '${t}' cannot have an initializer because it is marked abstract.`,AccesorCannotDeclareThisParameter:"'get' and 'set' accessors cannot declare 'this' parameters.",AccesorCannotHaveTypeParameters:"An accessor cannot have type parameters.",AccessorCannotBeOptional:"An 'accessor' property cannot be declared optional.",ClassMethodHasDeclare:"Class methods cannot have the 'declare' modifier.",ClassMethodHasReadonly:"Class methods cannot have the 'readonly' modifier.",ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference:"A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",ConstructorHasTypeParameters:"Type parameters cannot appear on a constructor declaration.",DeclareAccessor:({kind:t})=>`'declare' is not allowed in ${t}ters.`,DeclareClassFieldHasInitializer:"Initializers are not allowed in ambient contexts.",DeclareFunctionHasImplementation:"An implementation cannot be declared in ambient contexts.",DuplicateAccessibilityModifier:({modifier:t})=>"Accessibility modifier already seen.",DuplicateModifier:({modifier:t})=>`Duplicate modifier: '${t}'.`,EmptyHeritageClauseType:({token:t})=>`'${t}' list cannot be empty.`,EmptyTypeArguments:"Type argument list cannot be empty.",EmptyTypeParameters:"Type parameter list cannot be empty.",ExpectedAmbientAfterExportDeclare:"'export declare' must be followed by an ambient declaration.",ImportAliasHasImportType:"An import alias can not use 'import type'.",ImportReflectionHasImportType:"An `import module` declaration can not use `type` modifier",IncompatibleModifiers:({modifiers:t})=>`'${t[0]}' modifier cannot be used with '${t[1]}' modifier.`,IndexSignatureHasAbstract:"Index signatures cannot have the 'abstract' modifier.",IndexSignatureHasAccessibility:({modifier:t})=>`Index signatures cannot have an accessibility modifier ('${t}').`,IndexSignatureHasDeclare:"Index signatures cannot have the 'declare' modifier.",IndexSignatureHasOverride:"'override' modifier cannot appear on an index signature.",IndexSignatureHasStatic:"Index signatures cannot have the 'static' modifier.",InitializerNotAllowedInAmbientContext:"Initializers are not allowed in ambient contexts.",InvalidModifierOnTypeMember:({modifier:t})=>`'${t}' modifier cannot appear on a type member.`,InvalidModifierOnTypeParameter:({modifier:t})=>`'${t}' modifier cannot appear on a type parameter.`,InvalidModifierOnTypeParameterPositions:({modifier:t})=>`'${t}' modifier can only appear on a type parameter of a class, interface or type alias.`,InvalidModifiersOrder:({orderedModifiers:t})=>`'${t[0]}' modifier must precede '${t[1]}' modifier.`,InvalidPropertyAccessAfterInstantiationExpression:"Invalid property access after an instantiation expression. You can either wrap the instantiation expression in parentheses, or delete the type arguments.",InvalidTupleMemberLabel:"Tuple members must be labeled with a simple identifier.",MissingInterfaceName:"'interface' declarations must be followed by an identifier.",NonAbstractClassHasAbstractMethod:"Abstract methods can only appear within an abstract class.",NonClassMethodPropertyHasAbstractModifer:"'abstract' modifier can only appear on a class, method, or property declaration.",OptionalTypeBeforeRequired:"A required element cannot follow an optional element.",OverrideNotInSubClass:"This member cannot have an 'override' modifier because its containing class does not extend another class.",PatternIsOptional:"A binding pattern parameter cannot be optional in an implementation signature.",PrivateElementHasAbstract:"Private elements cannot have the 'abstract' modifier.",PrivateElementHasAccessibility:({modifier:t})=>`Private elements cannot have an accessibility modifier ('${t}').`,ReadonlyForMethodSignature:"'readonly' modifier can only appear on a property declaration or index signature.",ReservedArrowTypeParam:"This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `() => ...`.",ReservedTypeAssertion:"This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",SetAccesorCannotHaveOptionalParameter:"A 'set' accessor cannot have an optional parameter.",SetAccesorCannotHaveRestParameter:"A 'set' accessor cannot have rest parameter.",SetAccesorCannotHaveReturnType:"A 'set' accessor cannot have a return type annotation.",SingleTypeParameterWithoutTrailingComma:({typeParameterName:t})=>`Single type parameter ${t} should have a trailing comma. Example usage: <${t},>.`,StaticBlockCannotHaveModifier:"Static class blocks cannot have any modifier.",TupleOptionalAfterType:"A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",TypeAnnotationAfterAssign:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeImportCannotSpecifyDefaultAndNamed:"A type-only import can specify a default import or named bindings, but not both.",TypeModifierIsUsedInTypeExports:"The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",TypeModifierIsUsedInTypeImports:"The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",UnexpectedParameterModifier:"A parameter property is only allowed in a constructor implementation.",UnexpectedReadonly:"'readonly' type modifier is only permitted on array and tuple literal types.",UnexpectedTypeAnnotation:"Did not expect a type annotation here.",UnexpectedTypeCastInParameter:"Unexpected type cast in parameter position.",UnsupportedImportTypeArgument:"Argument in a type import must be a string literal.",UnsupportedParameterPropertyKind:"A parameter property may not be declared using a binding pattern.",UnsupportedSignatureParameterKind:({type:t})=>`Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${t}.`});function we(t){return"private"===t||"public"===t||"protected"===t}function ve(t){return"in"===t||"out"===t}function je(t){if("MemberExpression"!==t.type)return!1;const{computed:e,property:i}=t;return(!e||"StringLiteral"===i.type||!("TemplateLiteral"!==i.type||i.expressions.length>0))&&Ge(t.object)}function Ze(t,e){var i;const{type:s}=t;if(null!=(i=t.extra)&&i.parenthesized)return!1;if(e){if("Literal"===s){const{value:e}=t;if("string"==typeof e||"boolean"==typeof e)return!0}}else if("StringLiteral"===s||"BooleanLiteral"===s)return!0;return!(!Ce(t,e)&&!function(t,e){if("UnaryExpression"===t.type){const{operator:i,argument:s}=t;if("-"===i&&Ce(s,e))return!0}return!1}(t,e))||"TemplateLiteral"===s&&0===t.expressions.length||!!je(t)}function Ce(t,e){return e?"Literal"===t.type&&("number"==typeof t.value||"bigint"in t):"NumericLiteral"===t.type||"BigIntLiteral"===t.type}function Ge(t){return"Identifier"===t.type||"MemberExpression"===t.type&&!t.computed&&Ge(t.object)}const fe=y`placeholders`({ClassNameIsRequired:"A class name is required.",UnexpectedSpace:"Unexpected space in placeholder."});function Ne(t,e){const[i,s]="string"==typeof e?[e,{}]:e,n=Object.keys(s),o=0===n.length;return t.some((t=>{if("string"==typeof t)return o&&t===i;{const[e,o]=t;if(e!==i)return!1;for(const t of n)if(o[t]!==s[t])return!1;return!0}}))}function xe(t,e,i){const s=t.find((t=>Array.isArray(t)?t[0]===e:t===e));return s&&Array.isArray(s)&&s.length>1?s[1][i]:null}const Ye=["minimal","fsharp","hack","smart"],Re=["^^","@@","^","%","#"],He=["hash","bar"],ge={estree:t=>class extends t{parse(){const t=w(super.parse());return this.options.tokens&&(t.tokens=t.tokens.map(w)),t}parseRegExpLiteral({pattern:t,flags:e}){let i=null;try{i=new RegExp(t,e)}catch(t){}const s=this.estreeParseLiteral(i);return s.regex={pattern:t,flags:e},s}parseBigIntLiteral(t){let e;try{e=BigInt(t)}catch(t){e=null}const i=this.estreeParseLiteral(e);return i.bigint=String(i.value||t),i}parseDecimalLiteral(t){const e=this.estreeParseLiteral(null);return e.decimal=String(e.value||t),e}estreeParseLiteral(t){return this.parseLiteral(t,"Literal")}parseStringLiteral(t){return this.estreeParseLiteral(t)}parseNumericLiteral(t){return this.estreeParseLiteral(t)}parseNullLiteral(){return this.estreeParseLiteral(null)}parseBooleanLiteral(t){return this.estreeParseLiteral(t)}directiveToStmt(t){const e=t.value;delete t.value,e.type="Literal",e.raw=e.extra.raw,e.value=e.extra.expressionValue;const i=t;return i.type="ExpressionStatement",i.expression=e,i.directive=e.extra.rawValue,delete e.extra,i}initFunction(t,e){super.initFunction(t,e),t.expression=!1}checkDeclaration(t){null!=t&&this.isObjectProperty(t)?this.checkDeclaration(t.value):super.checkDeclaration(t)}getObjectOrClassMethodParams(t){return t.value.params}isValidDirective(t){var e;return"ExpressionStatement"===t.type&&"Literal"===t.expression.type&&"string"==typeof t.expression.value&&!(null!=(e=t.expression.extra)&&e.parenthesized)}parseBlockBody(t,e,i,s,n){super.parseBlockBody(t,e,i,s,n);const o=t.directives.map((t=>this.directiveToStmt(t)));t.body=o.concat(t.body),delete t.directives}pushClassMethod(t,e,i,s,n,o){this.parseMethod(e,i,s,n,o,"ClassMethod",!0),e.typeParameters&&(e.value.typeParameters=e.typeParameters,delete e.typeParameters),t.body.push(e)}parsePrivateName(){const t=super.parsePrivateName();return this.getPluginOption("estree","classFeatures")?this.convertPrivateNameToPrivateIdentifier(t):t}convertPrivateNameToPrivateIdentifier(t){const e=super.getPrivateNameSV(t);return delete t.id,t.name=e,t.type="PrivateIdentifier",t}isPrivateName(t){return this.getPluginOption("estree","classFeatures")?"PrivateIdentifier"===t.type:super.isPrivateName(t)}getPrivateNameSV(t){return this.getPluginOption("estree","classFeatures")?t.name:super.getPrivateNameSV(t)}parseLiteral(t,e){const i=super.parseLiteral(t,e);return i.raw=i.extra.raw,delete i.extra,i}parseFunctionBody(t,e,i=!1){super.parseFunctionBody(t,e,i),t.expression="BlockStatement"!==t.body.type}parseMethod(t,e,i,s,n,o,a=!1){let r=this.startNode();return r.kind=t.kind,r=super.parseMethod(r,e,i,s,n,o,a),r.type="FunctionExpression",delete r.kind,t.value=r,"ClassPrivateMethod"===o&&(t.computed=!1),this.finishNode(t,"MethodDefinition")}parseClassProperty(...t){const e=super.parseClassProperty(...t);return this.getPluginOption("estree","classFeatures")?(e.type="PropertyDefinition",e):e}parseClassPrivateProperty(...t){const e=super.parseClassPrivateProperty(...t);return this.getPluginOption("estree","classFeatures")?(e.type="PropertyDefinition",e.computed=!1,e):e}parseObjectMethod(t,e,i,s,n){const o=super.parseObjectMethod(t,e,i,s,n);return o&&(o.type="Property","method"===o.kind&&(o.kind="init"),o.shorthand=!1),o}parseObjectProperty(t,e,i,s){const n=super.parseObjectProperty(t,e,i,s);return n&&(n.kind="init",n.type="Property"),n}isValidLVal(t,e,i){return"Property"===t?"value":super.isValidLVal(t,e,i)}isAssignable(t,e){return null!=t&&this.isObjectProperty(t)?this.isAssignable(t.value,e):super.isAssignable(t,e)}toAssignable(t,e=!1){if(null!=t&&this.isObjectProperty(t)){const{key:i,value:s}=t;this.isPrivateName(i)&&this.classScope.usePrivateName(this.getPrivateNameSV(i),i.loc.start),this.toAssignable(s,e)}else super.toAssignable(t,e)}toAssignableObjectExpressionProp(t,e,i){"get"===t.kind||"set"===t.kind?this.raise(L.PatternHasAccessor,t.key):t.method?this.raise(L.PatternHasMethod,t.key):super.toAssignableObjectExpressionProp(t,e,i)}finishCallExpression(t,e){const i=super.finishCallExpression(t,e);var s,n;"Import"===i.callee.type&&(i.type="ImportExpression",i.source=i.arguments[0],(this.hasPlugin("importAttributes")||this.hasPlugin("importAssertions"))&&(i.options=null!=(s=i.arguments[1])?s:null,i.attributes=null!=(n=i.arguments[1])?n:null),delete i.arguments,delete i.callee);return i}toReferencedArguments(t){"ImportExpression"!==t.type&&super.toReferencedArguments(t)}parseExport(t,e){const i=this.state.lastTokStartLoc,s=super.parseExport(t,e);switch(s.type){case"ExportAllDeclaration":s.exported=null;break;case"ExportNamedDeclaration":1===s.specifiers.length&&"ExportNamespaceSpecifier"===s.specifiers[0].type&&(s.type="ExportAllDeclaration",s.exported=s.specifiers[0].exported,delete s.specifiers);case"ExportDefaultDeclaration":{var n;const{declaration:t}=s;"ClassDeclaration"===(null==t?void 0:t.type)&&(null==(n=t.decorators)?void 0:n.length)>0&&t.start===s.start&&this.resetStartLocation(s,i)}}return s}parseSubscript(t,e,i,s){const n=super.parseSubscript(t,e,i,s);if(s.optionalChainMember){if("OptionalMemberExpression"!==n.type&&"OptionalCallExpression"!==n.type||(n.type=n.type.substring(8)),s.stop){const t=this.startNodeAtNode(n);return t.expression=n,this.finishNode(t,"ChainExpression")}}else"MemberExpression"!==n.type&&"CallExpression"!==n.type||(n.optional=!1);return n}isOptionalMemberExpression(t){return"ChainExpression"===t.type?"MemberExpression"===t.expression.type:super.isOptionalMemberExpression(t)}hasPropertyAsPrivateName(t){return"ChainExpression"===t.type&&(t=t.expression),super.hasPropertyAsPrivateName(t)}isObjectProperty(t){return"Property"===t.type&&"init"===t.kind&&!t.method}isObjectMethod(t){return t.method||"get"===t.kind||"set"===t.kind}finishNodeAt(t,e,i){return w(super.finishNodeAt(t,e,i))}resetStartLocation(t,e){super.resetStartLocation(t,e),w(t)}resetEndLocation(t,e=this.state.lastTokEndLoc){super.resetEndLocation(t,e),w(t)}},jsx:t=>class extends t{jsxReadToken(){let t="",e=this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(Ie.UnterminatedJsxContent,this.state.startLoc);const i=this.input.charCodeAt(this.state.pos);switch(i){case 60:case 123:return this.state.pos===this.state.start?void(60===i&&this.state.canStartJSXElement?(++this.state.pos,this.finishToken(142)):super.getTokenFromCode(i)):(t+=this.input.slice(e,this.state.pos),void this.finishToken(141,t));case 38:t+=this.input.slice(e,this.state.pos),t+=this.jsxReadEntity(),e=this.state.pos;break;default:ft(i)?(t+=this.input.slice(e,this.state.pos),t+=this.jsxReadNewLine(!0),e=this.state.pos):++this.state.pos}}}jsxReadNewLine(t){const e=this.input.charCodeAt(this.state.pos);let i;return++this.state.pos,13===e&&10===this.input.charCodeAt(this.state.pos)?(++this.state.pos,i=t?"\n":"\r\n"):i=String.fromCharCode(e),++this.state.curLine,this.state.lineStart=this.state.pos,i}jsxReadString(t){let e="",i=++this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(L.UnterminatedString,this.state.startLoc);const s=this.input.charCodeAt(this.state.pos);if(s===t)break;38===s?(e+=this.input.slice(i,this.state.pos),e+=this.jsxReadEntity(),i=this.state.pos):ft(s)?(e+=this.input.slice(i,this.state.pos),e+=this.jsxReadNewLine(!1),i=this.state.pos):++this.state.pos}e+=this.input.slice(i,this.state.pos++),this.finishToken(133,e)}jsxReadEntity(){const t=++this.state.pos;if(35===this.codePointAtPos(this.state.pos)){++this.state.pos;let t=10;120===this.codePointAtPos(this.state.pos)&&(t=16,++this.state.pos);const e=this.readInt(t,void 0,!1,"bail");if(null!==e&&59===this.codePointAtPos(this.state.pos))return++this.state.pos,String.fromCodePoint(e)}else{let e=0,i=!1;for(;e++<10&&this.state.posclass extends t{constructor(...t){super(...t),this.flowPragma=void 0}getScopeHandler(){return Mt}shouldParseTypes(){return this.getPluginOption("flow","all")||"flow"===this.flowPragma}shouldParseEnums(){return!!this.getPluginOption("flow","enums")}finishToken(t,e){133!==t&&13!==t&&28!==t&&void 0===this.flowPragma&&(this.flowPragma=null),super.finishToken(t,e)}addComment(t){if(void 0===this.flowPragma){const e=ce.exec(t.value);if(e)if("flow"===e[1])this.flowPragma="flow";else{if("noflow"!==e[1])throw new Error("Unexpected flow pragma");this.flowPragma="noflow"}}super.addComment(t)}flowParseTypeInitialiser(t){const e=this.state.inType;this.state.inType=!0,this.expect(t||14);const i=this.flowParseType();return this.state.inType=e,i}flowParsePredicate(){const t=this.startNode(),e=this.state.startLoc;return this.next(),this.expectContextual(110),this.state.lastTokStartLoc.index>e.index+1&&this.raise(re.UnexpectedSpaceBetweenModuloChecks,e),this.eat(10)?(t.value=super.parseExpression(),this.expect(11),this.finishNode(t,"DeclaredPredicate")):this.finishNode(t,"InferredPredicate")}flowParseTypeAndPredicateInitialiser(){const t=this.state.inType;this.state.inType=!0,this.expect(14);let e=null,i=null;return this.match(54)?(this.state.inType=t,i=this.flowParsePredicate()):(e=this.flowParseType(),this.state.inType=t,this.match(54)&&(i=this.flowParsePredicate())),[e,i]}flowParseDeclareClass(t){return this.next(),this.flowParseInterfaceish(t,!0),this.finishNode(t,"DeclareClass")}flowParseDeclareFunction(t){this.next();const e=t.id=this.parseIdentifier(),i=this.startNode(),s=this.startNode();this.match(47)?i.typeParameters=this.flowParseTypeParameterDeclaration():i.typeParameters=null,this.expect(10);const n=this.flowParseFunctionTypeParams();return i.params=n.params,i.rest=n.rest,i.this=n._this,this.expect(11),[i.returnType,t.predicate]=this.flowParseTypeAndPredicateInitialiser(),s.typeAnnotation=this.finishNode(i,"FunctionTypeAnnotation"),e.typeAnnotation=this.finishNode(s,"TypeAnnotation"),this.resetEndLocation(e),this.semicolon(),this.scope.declareName(t.id.name,2048,t.id.loc.start),this.finishNode(t,"DeclareFunction")}flowParseDeclare(t,e){return this.match(80)?this.flowParseDeclareClass(t):this.match(68)?this.flowParseDeclareFunction(t):this.match(74)?this.flowParseDeclareVariable(t):this.eatContextual(127)?this.match(16)?this.flowParseDeclareModuleExports(t):(e&&this.raise(re.NestedDeclareModule,this.state.lastTokStartLoc),this.flowParseDeclareModule(t)):this.isContextual(130)?this.flowParseDeclareTypeAlias(t):this.isContextual(131)?this.flowParseDeclareOpaqueType(t):this.isContextual(129)?this.flowParseDeclareInterface(t):this.match(82)?this.flowParseDeclareExportDeclaration(t,e):void this.unexpected()}flowParseDeclareVariable(t){return this.next(),t.id=this.flowParseTypeAnnotatableIdentifier(!0),this.scope.declareName(t.id.name,5,t.id.loc.start),this.semicolon(),this.finishNode(t,"DeclareVariable")}flowParseDeclareModule(t){this.scope.enter(0),this.match(133)?t.id=super.parseExprAtom():t.id=this.parseIdentifier();const e=t.body=this.startNode(),i=e.body=[];for(this.expect(5);!this.match(8);){let t=this.startNode();this.match(83)?(this.next(),this.isContextual(130)||this.match(87)||this.raise(re.InvalidNonTypeImportInDeclareModule,this.state.lastTokStartLoc),super.parseImport(t)):(this.expectContextual(125,re.UnsupportedStatementInDeclareModule),t=this.flowParseDeclare(t,!0)),i.push(t)}this.scope.exit(),this.expect(8),this.finishNode(e,"BlockStatement");let s=null,n=!1;return i.forEach((t=>{!function(t){return"DeclareExportAllDeclaration"===t.type||"DeclareExportDeclaration"===t.type&&(!t.declaration||"TypeAlias"!==t.declaration.type&&"InterfaceDeclaration"!==t.declaration.type)}(t)?"DeclareModuleExports"===t.type&&(n&&this.raise(re.DuplicateDeclareModuleExports,t),"ES"===s&&this.raise(re.AmbiguousDeclareModuleKind,t),s="CommonJS",n=!0):("CommonJS"===s&&this.raise(re.AmbiguousDeclareModuleKind,t),s="ES")})),t.kind=s||"CommonJS",this.finishNode(t,"DeclareModule")}flowParseDeclareExportDeclaration(t,e){if(this.expect(82),this.eat(65))return this.match(68)||this.match(80)?t.declaration=this.flowParseDeclare(this.startNode()):(t.declaration=this.flowParseType(),this.semicolon()),t.default=!0,this.finishNode(t,"DeclareExportDeclaration");if(this.match(75)||this.isLet()||(this.isContextual(130)||this.isContextual(129))&&!e){const t=this.state.value;throw this.raise(re.UnsupportedDeclareExportKind,this.state.startLoc,{unsupportedExportKind:t,suggestion:he[t]})}return this.match(74)||this.match(68)||this.match(80)||this.isContextual(131)?(t.declaration=this.flowParseDeclare(this.startNode()),t.default=!1,this.finishNode(t,"DeclareExportDeclaration")):this.match(55)||this.match(5)||this.isContextual(129)||this.isContextual(130)||this.isContextual(131)?("ExportNamedDeclaration"===(t=this.parseExport(t,null)).type&&(t.type="ExportDeclaration",t.default=!1,delete t.exportKind),t.type="Declare"+t.type,t):void this.unexpected()}flowParseDeclareModuleExports(t){return this.next(),this.expectContextual(111),t.typeAnnotation=this.flowParseTypeAnnotation(),this.semicolon(),this.finishNode(t,"DeclareModuleExports")}flowParseDeclareTypeAlias(t){this.next();const e=this.flowParseTypeAlias(t);return e.type="DeclareTypeAlias",e}flowParseDeclareOpaqueType(t){this.next();const e=this.flowParseOpaqueType(t,!0);return e.type="DeclareOpaqueType",e}flowParseDeclareInterface(t){return this.next(),this.flowParseInterfaceish(t,!1),this.finishNode(t,"DeclareInterface")}flowParseInterfaceish(t,e){if(t.id=this.flowParseRestrictedIdentifier(!e,!0),this.scope.declareName(t.id.name,e?17:8201,t.id.loc.start),this.match(47)?t.typeParameters=this.flowParseTypeParameterDeclaration():t.typeParameters=null,t.extends=[],this.eat(81))do{t.extends.push(this.flowParseInterfaceExtends())}while(!e&&this.eat(12));if(e){if(t.implements=[],t.mixins=[],this.eatContextual(117))do{t.mixins.push(this.flowParseInterfaceExtends())}while(this.eat(12));if(this.eatContextual(113))do{t.implements.push(this.flowParseInterfaceExtends())}while(this.eat(12))}t.body=this.flowParseObjectType({allowStatic:e,allowExact:!1,allowSpread:!1,allowProto:e,allowInexact:!1})}flowParseInterfaceExtends(){const t=this.startNode();return t.id=this.flowParseQualifiedTypeIdentifier(),this.match(47)?t.typeParameters=this.flowParseTypeParameterInstantiation():t.typeParameters=null,this.finishNode(t,"InterfaceExtends")}flowParseInterface(t){return this.flowParseInterfaceish(t,!1),this.finishNode(t,"InterfaceDeclaration")}checkNotUnderscore(t){"_"===t&&this.raise(re.UnexpectedReservedUnderscore,this.state.startLoc)}checkReservedType(t,e,i){ae.has(t)&&this.raise(i?re.AssignReservedType:re.UnexpectedReservedType,e,{reservedType:t})}flowParseRestrictedIdentifier(t,e){return this.checkReservedType(this.state.value,this.state.startLoc,e),this.parseIdentifier(t)}flowParseTypeAlias(t){return t.id=this.flowParseRestrictedIdentifier(!1,!0),this.scope.declareName(t.id.name,8201,t.id.loc.start),this.match(47)?t.typeParameters=this.flowParseTypeParameterDeclaration():t.typeParameters=null,t.right=this.flowParseTypeInitialiser(29),this.semicolon(),this.finishNode(t,"TypeAlias")}flowParseOpaqueType(t,e){return this.expectContextual(130),t.id=this.flowParseRestrictedIdentifier(!0,!0),this.scope.declareName(t.id.name,8201,t.id.loc.start),this.match(47)?t.typeParameters=this.flowParseTypeParameterDeclaration():t.typeParameters=null,t.supertype=null,this.match(14)&&(t.supertype=this.flowParseTypeInitialiser(14)),t.impltype=null,e||(t.impltype=this.flowParseTypeInitialiser(29)),this.semicolon(),this.finishNode(t,"OpaqueType")}flowParseTypeParameter(t=!1){const e=this.state.startLoc,i=this.startNode(),s=this.flowParseVariance(),n=this.flowParseTypeAnnotatableIdentifier();return i.name=n.name,i.variance=s,i.bound=n.typeAnnotation,this.match(29)?(this.eat(29),i.default=this.flowParseType()):t&&this.raise(re.MissingTypeParamDefault,e),this.finishNode(i,"TypeParameter")}flowParseTypeParameterDeclaration(){const t=this.state.inType,e=this.startNode();e.params=[],this.state.inType=!0,this.match(47)||this.match(142)?this.next():this.unexpected();let i=!1;do{const t=this.flowParseTypeParameter(i);e.params.push(t),t.default&&(i=!0),this.match(48)||this.expect(12)}while(!this.match(48));return this.expect(48),this.state.inType=t,this.finishNode(e,"TypeParameterDeclaration")}flowParseTypeParameterInstantiation(){const t=this.startNode(),e=this.state.inType;t.params=[],this.state.inType=!0,this.expect(47);const i=this.state.noAnonFunctionType;for(this.state.noAnonFunctionType=!1;!this.match(48);)t.params.push(this.flowParseType()),this.match(48)||this.expect(12);return this.state.noAnonFunctionType=i,this.expect(48),this.state.inType=e,this.finishNode(t,"TypeParameterInstantiation")}flowParseTypeParameterInstantiationCallOrNew(){const t=this.startNode(),e=this.state.inType;for(t.params=[],this.state.inType=!0,this.expect(47);!this.match(48);)t.params.push(this.flowParseTypeOrImplicitInstantiation()),this.match(48)||this.expect(12);return this.expect(48),this.state.inType=e,this.finishNode(t,"TypeParameterInstantiation")}flowParseInterfaceType(){const t=this.startNode();if(this.expectContextual(129),t.extends=[],this.eat(81))do{t.extends.push(this.flowParseInterfaceExtends())}while(this.eat(12));return t.body=this.flowParseObjectType({allowStatic:!1,allowExact:!1,allowSpread:!1,allowProto:!1,allowInexact:!1}),this.finishNode(t,"InterfaceTypeAnnotation")}flowParseObjectPropertyKey(){return this.match(134)||this.match(133)?super.parseExprAtom():this.parseIdentifier(!0)}flowParseObjectTypeIndexer(t,e,i){return t.static=e,14===this.lookahead().type?(t.id=this.flowParseObjectPropertyKey(),t.key=this.flowParseTypeInitialiser()):(t.id=null,t.key=this.flowParseType()),this.expect(3),t.value=this.flowParseTypeInitialiser(),t.variance=i,this.finishNode(t,"ObjectTypeIndexer")}flowParseObjectTypeInternalSlot(t,e){return t.static=e,t.id=this.flowParseObjectPropertyKey(),this.expect(3),this.expect(3),this.match(47)||this.match(10)?(t.method=!0,t.optional=!1,t.value=this.flowParseObjectTypeMethodish(this.startNodeAt(t.loc.start))):(t.method=!1,this.eat(17)&&(t.optional=!0),t.value=this.flowParseTypeInitialiser()),this.finishNode(t,"ObjectTypeInternalSlot")}flowParseObjectTypeMethodish(t){for(t.params=[],t.rest=null,t.typeParameters=null,t.this=null,this.match(47)&&(t.typeParameters=this.flowParseTypeParameterDeclaration()),this.expect(10),this.match(78)&&(t.this=this.flowParseFunctionTypeParam(!0),t.this.name=null,this.match(11)||this.expect(12));!this.match(11)&&!this.match(21);)t.params.push(this.flowParseFunctionTypeParam(!1)),this.match(11)||this.expect(12);return this.eat(21)&&(t.rest=this.flowParseFunctionTypeParam(!1)),this.expect(11),t.returnType=this.flowParseTypeInitialiser(),this.finishNode(t,"FunctionTypeAnnotation")}flowParseObjectTypeCallProperty(t,e){const i=this.startNode();return t.static=e,t.value=this.flowParseObjectTypeMethodish(i),this.finishNode(t,"ObjectTypeCallProperty")}flowParseObjectType({allowStatic:t,allowExact:e,allowSpread:i,allowProto:s,allowInexact:n}){const o=this.state.inType;this.state.inType=!0;const a=this.startNode();let r,l;a.callProperties=[],a.properties=[],a.indexers=[],a.internalSlots=[];let h=!1;for(e&&this.match(6)?(this.expect(6),r=9,l=!0):(this.expect(5),r=8,l=!1),a.exact=l;!this.match(r);){let e=!1,o=null,r=null;const c=this.startNode();if(s&&this.isContextual(118)){const e=this.lookahead();14!==e.type&&17!==e.type&&(this.next(),o=this.state.startLoc,t=!1)}if(t&&this.isContextual(106)){const t=this.lookahead();14!==t.type&&17!==t.type&&(this.next(),e=!0)}const d=this.flowParseVariance();if(this.eat(0))null!=o&&this.unexpected(o),this.eat(0)?(d&&this.unexpected(d.loc.start),a.internalSlots.push(this.flowParseObjectTypeInternalSlot(c,e))):a.indexers.push(this.flowParseObjectTypeIndexer(c,e,d));else if(this.match(10)||this.match(47))null!=o&&this.unexpected(o),d&&this.unexpected(d.loc.start),a.callProperties.push(this.flowParseObjectTypeCallProperty(c,e));else{let t="init";(this.isContextual(99)||this.isContextual(104))&&D(this.lookahead().type)&&(t=this.state.value,this.next());const s=this.flowParseObjectTypeProperty(c,e,o,d,t,i,null!=n?n:!l);null===s?(h=!0,r=this.state.lastTokStartLoc):a.properties.push(s)}this.flowObjectTypeSemicolon(),!r||this.match(8)||this.match(9)||this.raise(re.UnexpectedExplicitInexactInObject,r)}this.expect(r),i&&(a.inexact=h);const c=this.finishNode(a,"ObjectTypeAnnotation");return this.state.inType=o,c}flowParseObjectTypeProperty(t,e,i,s,n,o,a){if(this.eat(21))return this.match(12)||this.match(13)||this.match(8)||this.match(9)?(o?a||this.raise(re.InexactInsideExact,this.state.lastTokStartLoc):this.raise(re.InexactInsideNonObject,this.state.lastTokStartLoc),s&&this.raise(re.InexactVariance,s),null):(o||this.raise(re.UnexpectedSpreadType,this.state.lastTokStartLoc),null!=i&&this.unexpected(i),s&&this.raise(re.SpreadVariance,s),t.argument=this.flowParseType(),this.finishNode(t,"ObjectTypeSpreadProperty"));{t.key=this.flowParseObjectPropertyKey(),t.static=e,t.proto=null!=i,t.kind=n;let a=!1;return this.match(47)||this.match(10)?(t.method=!0,null!=i&&this.unexpected(i),s&&this.unexpected(s.loc.start),t.value=this.flowParseObjectTypeMethodish(this.startNodeAt(t.loc.start)),"get"!==n&&"set"!==n||this.flowCheckGetterSetterParams(t),!o&&"constructor"===t.key.name&&t.value.this&&this.raise(re.ThisParamBannedInConstructor,t.value.this)):("init"!==n&&this.unexpected(),t.method=!1,this.eat(17)&&(a=!0),t.value=this.flowParseTypeInitialiser(),t.variance=s),t.optional=a,this.finishNode(t,"ObjectTypeProperty")}}flowCheckGetterSetterParams(t){const e="get"===t.kind?0:1,i=t.value.params.length+(t.value.rest?1:0);t.value.this&&this.raise("get"===t.kind?re.GetterMayNotHaveThisParam:re.SetterMayNotHaveThisParam,t.value.this),i!==e&&this.raise("get"===t.kind?L.BadGetterArity:L.BadSetterArity,t),"set"===t.kind&&t.value.rest&&this.raise(L.BadSetterRestParameter,t)}flowObjectTypeSemicolon(){this.eat(13)||this.eat(12)||this.match(8)||this.match(9)||this.unexpected()}flowParseQualifiedTypeIdentifier(t,e){null!=t||(t=this.state.startLoc);let i=e||this.flowParseRestrictedIdentifier(!0);for(;this.eat(16);){const e=this.startNodeAt(t);e.qualification=i,e.id=this.flowParseRestrictedIdentifier(!0),i=this.finishNode(e,"QualifiedTypeIdentifier")}return i}flowParseGenericType(t,e){const i=this.startNodeAt(t);return i.typeParameters=null,i.id=this.flowParseQualifiedTypeIdentifier(t,e),this.match(47)&&(i.typeParameters=this.flowParseTypeParameterInstantiation()),this.finishNode(i,"GenericTypeAnnotation")}flowParseTypeofType(){const t=this.startNode();return this.expect(87),t.argument=this.flowParsePrimaryType(),this.finishNode(t,"TypeofTypeAnnotation")}flowParseTupleType(){const t=this.startNode();for(t.types=[],this.expect(0);this.state.possuper.parseFunctionBody(t,!0,i))):super.parseFunctionBody(t,!1,i)}parseFunctionBodyAndFinish(t,e,i=!1){if(this.match(14)){const e=this.startNode();[e.typeAnnotation,t.predicate]=this.flowParseTypeAndPredicateInitialiser(),t.returnType=e.typeAnnotation?this.finishNode(e,"TypeAnnotation"):null}return super.parseFunctionBodyAndFinish(t,e,i)}parseStatementLike(t){if(this.state.strict&&this.isContextual(129)){if(E(this.lookahead().type)){const t=this.startNode();return this.next(),this.flowParseInterface(t)}}else if(this.shouldParseEnums()&&this.isContextual(126)){const t=this.startNode();return this.next(),this.flowParseEnumDeclaration(t)}const e=super.parseStatementLike(t);return void 0!==this.flowPragma||this.isValidDirective(e)||(this.flowPragma=null),e}parseExpressionStatement(t,e,i){if("Identifier"===e.type)if("declare"===e.name){if(this.match(80)||X(this.state.type)||this.match(68)||this.match(74)||this.match(82))return this.flowParseDeclare(t)}else if(X(this.state.type)){if("interface"===e.name)return this.flowParseInterface(t);if("type"===e.name)return this.flowParseTypeAlias(t);if("opaque"===e.name)return this.flowParseOpaqueType(t,!1)}return super.parseExpressionStatement(t,e,i)}shouldParseExportDeclaration(){const{type:t}=this.state;return B(t)||this.shouldParseEnums()&&126===t?!this.state.containsEsc:super.shouldParseExportDeclaration()}isExportDefaultSpecifier(){const{type:t}=this.state;return B(t)||this.shouldParseEnums()&&126===t?this.state.containsEsc:super.isExportDefaultSpecifier()}parseExportDefaultExpression(){if(this.shouldParseEnums()&&this.isContextual(126)){const t=this.startNode();return this.next(),this.flowParseEnumDeclaration(t)}return super.parseExportDefaultExpression()}parseConditional(t,e,i){if(!this.match(17))return t;if(this.state.maybeInArrowParameters){const e=this.lookaheadCharCode();if(44===e||61===e||58===e||41===e)return this.setOptionalParametersError(i),t}this.expect(17);const s=this.state.clone(),n=this.state.noArrowAt,o=this.startNodeAt(e);let{consequent:a,failed:r}=this.tryParseConditionalConsequent(),[l,h]=this.getArrowLikeExpressions(a);if(r||h.length>0){const t=[...n];if(h.length>0){this.state=s,this.state.noArrowAt=t;for(let e=0;e1&&this.raise(re.AmbiguousConditionalArrow,s.startLoc),r&&1===l.length&&(this.state=s,t.push(l[0].start),this.state.noArrowAt=t,({consequent:a,failed:r}=this.tryParseConditionalConsequent()))}return this.getArrowLikeExpressions(a,!0),this.state.noArrowAt=n,this.expect(14),o.test=t,o.consequent=a,o.alternate=this.forwardNoArrowParamsConversionAt(o,(()=>this.parseMaybeAssign(void 0,void 0))),this.finishNode(o,"ConditionalExpression")}tryParseConditionalConsequent(){this.state.noArrowParamsConversionAt.push(this.state.start);const t=this.parseMaybeAssignAllowIn(),e=!this.match(14);return this.state.noArrowParamsConversionAt.pop(),{consequent:t,failed:e}}getArrowLikeExpressions(t,e){const i=[t],s=[];for(;0!==i.length;){const t=i.pop();"ArrowFunctionExpression"===t.type?(t.typeParameters||!t.returnType?this.finishArrowValidation(t):s.push(t),i.push(t.body)):"ConditionalExpression"===t.type&&(i.push(t.consequent),i.push(t.alternate))}return e?(s.forEach((t=>this.finishArrowValidation(t))),[s,[]]):function(t,e){const i=[],s=[];for(let n=0;nt.params.every((t=>this.isAssignable(t,!0)))))}finishArrowValidation(t){var e;this.toAssignableList(t.params,null==(e=t.extra)?void 0:e.trailingCommaLoc,!1),this.scope.enter(6),super.checkParams(t,!1,!0),this.scope.exit()}forwardNoArrowParamsConversionAt(t,e){let i;return-1!==this.state.noArrowParamsConversionAt.indexOf(t.start)?(this.state.noArrowParamsConversionAt.push(this.state.start),i=e(),this.state.noArrowParamsConversionAt.pop()):i=e(),i}parseParenItem(t,e){if(t=super.parseParenItem(t,e),this.eat(17)&&(t.optional=!0,this.resetEndLocation(t)),this.match(14)){const i=this.startNodeAt(e);return i.expression=t,i.typeAnnotation=this.flowParseTypeAnnotation(),this.finishNode(i,"TypeCastExpression")}return t}assertModuleNodeAllowed(t){"ImportDeclaration"===t.type&&("type"===t.importKind||"typeof"===t.importKind)||"ExportNamedDeclaration"===t.type&&"type"===t.exportKind||"ExportAllDeclaration"===t.type&&"type"===t.exportKind||super.assertModuleNodeAllowed(t)}parseExportDeclaration(t){if(this.isContextual(130)){t.exportKind="type";const e=this.startNode();return this.next(),this.match(5)?(t.specifiers=this.parseExportSpecifiers(!0),super.parseExportFrom(t),null):this.flowParseTypeAlias(e)}if(this.isContextual(131)){t.exportKind="type";const e=this.startNode();return this.next(),this.flowParseOpaqueType(e,!1)}if(this.isContextual(129)){t.exportKind="type";const e=this.startNode();return this.next(),this.flowParseInterface(e)}if(this.shouldParseEnums()&&this.isContextual(126)){t.exportKind="value";const e=this.startNode();return this.next(),this.flowParseEnumDeclaration(e)}return super.parseExportDeclaration(t)}eatExportStar(t){return!!super.eatExportStar(t)||!(!this.isContextual(130)||55!==this.lookahead().type)&&(t.exportKind="type",this.next(),this.next(),!0)}maybeParseExportNamespaceSpecifier(t){const{startLoc:e}=this.state,i=super.maybeParseExportNamespaceSpecifier(t);return i&&"type"===t.exportKind&&this.unexpected(e),i}parseClassId(t,e,i){super.parseClassId(t,e,i),this.match(47)&&(t.typeParameters=this.flowParseTypeParameterDeclaration())}parseClassMember(t,e,i){const{startLoc:s}=this.state;if(this.isContextual(125)){if(super.parseClassMemberFromModifier(t,e))return;e.declare=!0}super.parseClassMember(t,e,i),e.declare&&("ClassProperty"!==e.type&&"ClassPrivateProperty"!==e.type&&"PropertyDefinition"!==e.type?this.raise(re.DeclareClassElement,s):e.value&&this.raise(re.DeclareClassFieldInitializer,e.value))}isIterator(t){return"iterator"===t||"asyncIterator"===t}readIterator(){const t=super.readWord1(),e="@@"+t;this.isIterator(t)&&this.state.inType||this.raise(L.InvalidIdentifier,this.state.curPosition(),{identifierName:e}),this.finishToken(132,e)}getTokenFromCode(t){const e=this.input.charCodeAt(this.state.pos+1);123===t&&124===e?this.finishOp(6,2):!this.state.inType||62!==t&&60!==t?this.state.inType&&63===t?46===e?this.finishOp(18,2):this.finishOp(17,1):function(t,e,i){return 64===t&&64===e&&at(i)}(t,e,this.input.charCodeAt(this.state.pos+2))?(this.state.pos+=2,this.readIterator()):super.getTokenFromCode(t):this.finishOp(62===t?48:47,1)}isAssignable(t,e){return"TypeCastExpression"===t.type?this.isAssignable(t.expression,e):super.isAssignable(t,e)}toAssignable(t,e=!1){e||"AssignmentExpression"!==t.type||"TypeCastExpression"!==t.left.type||(t.left=this.typeCastToParameter(t.left)),super.toAssignable(t,e)}toAssignableList(t,e,i){for(let e=0;e1)&&e||this.raise(re.TypeCastInPattern,n.typeAnnotation)}return t}parseArrayLike(t,e,i,s){const n=super.parseArrayLike(t,e,i,s);return e&&!this.state.maybeInArrowParameters&&this.toReferencedList(n.elements),n}isValidLVal(t,e,i){return"TypeCastExpression"===t||super.isValidLVal(t,e,i)}parseClassProperty(t){return this.match(14)&&(t.typeAnnotation=this.flowParseTypeAnnotation()),super.parseClassProperty(t)}parseClassPrivateProperty(t){return this.match(14)&&(t.typeAnnotation=this.flowParseTypeAnnotation()),super.parseClassPrivateProperty(t)}isClassMethod(){return this.match(47)||super.isClassMethod()}isClassProperty(){return this.match(14)||super.isClassProperty()}isNonstaticConstructor(t){return!this.match(14)&&super.isNonstaticConstructor(t)}pushClassMethod(t,e,i,s,n,o){if(e.variance&&this.unexpected(e.variance.loc.start),delete e.variance,this.match(47)&&(e.typeParameters=this.flowParseTypeParameterDeclaration()),super.pushClassMethod(t,e,i,s,n,o),e.params&&n){const t=e.params;t.length>0&&this.isThisParam(t[0])&&this.raise(re.ThisParamBannedInConstructor,e)}else if("MethodDefinition"===e.type&&n&&e.value.params){const t=e.value.params;t.length>0&&this.isThisParam(t[0])&&this.raise(re.ThisParamBannedInConstructor,e)}}pushClassPrivateMethod(t,e,i,s){e.variance&&this.unexpected(e.variance.loc.start),delete e.variance,this.match(47)&&(e.typeParameters=this.flowParseTypeParameterDeclaration()),super.pushClassPrivateMethod(t,e,i,s)}parseClassSuper(t){if(super.parseClassSuper(t),t.superClass&&this.match(47)&&(t.superTypeParameters=this.flowParseTypeParameterInstantiation()),this.isContextual(113)){this.next();const e=t.implements=[];do{const t=this.startNode();t.id=this.flowParseRestrictedIdentifier(!0),this.match(47)?t.typeParameters=this.flowParseTypeParameterInstantiation():t.typeParameters=null,e.push(this.finishNode(t,"ClassImplements"))}while(this.eat(12))}}checkGetterSetterParams(t){super.checkGetterSetterParams(t);const e=this.getObjectOrClassMethodParams(t);if(e.length>0){const i=e[0];this.isThisParam(i)&&"get"===t.kind?this.raise(re.GetterMayNotHaveThisParam,i):this.isThisParam(i)&&this.raise(re.SetterMayNotHaveThisParam,i)}}parsePropertyNamePrefixOperator(t){t.variance=this.flowParseVariance()}parseObjPropValue(t,e,i,s,n,o,a){let r;t.variance&&this.unexpected(t.variance.loc.start),delete t.variance,this.match(47)&&!o&&(r=this.flowParseTypeParameterDeclaration(),this.match(10)||this.unexpected());const l=super.parseObjPropValue(t,e,i,s,n,o,a);return r&&((l.value||l).typeParameters=r),l}parseAssignableListItemTypes(t){return this.eat(17)&&("Identifier"!==t.type&&this.raise(re.PatternIsOptional,t),this.isThisParam(t)&&this.raise(re.ThisParamMayNotBeOptional,t),t.optional=!0),this.match(14)?t.typeAnnotation=this.flowParseTypeAnnotation():this.isThisParam(t)&&this.raise(re.ThisParamAnnotationRequired,t),this.match(29)&&this.isThisParam(t)&&this.raise(re.ThisParamNoDefault,t),this.resetEndLocation(t),t}parseMaybeDefault(t,e){const i=super.parseMaybeDefault(t,e);return"AssignmentPattern"===i.type&&i.typeAnnotation&&i.right.startsuper.parseMaybeAssign(t,e)),n),!s.error)return s.node;const{context:i}=this.state,o=i[i.length-1];o!==j.j_oTag&&o!==j.j_expr||i.pop()}if(null!=(i=s)&&i.error||this.match(47)){var o,a;let i;n=n||this.state.clone();const r=this.tryParse((s=>{var n;i=this.flowParseTypeParameterDeclaration();const o=this.forwardNoArrowParamsConversionAt(i,(()=>{const s=super.parseMaybeAssign(t,e);return this.resetStartLocationFromNode(s,i),s}));null!=(n=o.extra)&&n.parenthesized&&s();const a=this.maybeUnwrapTypeCastExpression(o);return"ArrowFunctionExpression"!==a.type&&s(),a.typeParameters=i,this.resetStartLocationFromNode(a,i),o}),n);let l=null;if(r.node&&"ArrowFunctionExpression"===this.maybeUnwrapTypeCastExpression(r.node).type){if(!r.error&&!r.aborted)return r.node.async&&this.raise(re.UnexpectedTypeParameterBeforeAsyncArrowFunction,i),r.node;l=r.node}if(null!=(o=s)&&o.node)return this.state=s.failState,s.node;if(l)return this.state=r.failState,l;if(null!=(a=s)&&a.thrown)throw s.error;if(r.thrown)throw r.error;throw this.raise(re.UnexpectedTokenAfterTypeParameter,i)}return super.parseMaybeAssign(t,e)}parseArrow(t){if(this.match(14)){const e=this.tryParse((()=>{const e=this.state.noAnonFunctionType;this.state.noAnonFunctionType=!0;const i=this.startNode();return[i.typeAnnotation,t.predicate]=this.flowParseTypeAndPredicateInitialiser(),this.state.noAnonFunctionType=e,this.canInsertSemicolon()&&this.unexpected(),this.match(19)||this.unexpected(),i}));if(e.thrown)return null;e.error&&(this.state=e.failState),t.returnType=e.node.typeAnnotation?this.finishNode(e.node,"TypeAnnotation"):null}return super.parseArrow(t)}shouldParseArrow(t){return this.match(14)||super.shouldParseArrow(t)}setArrowFunctionParameters(t,e){-1!==this.state.noArrowParamsConversionAt.indexOf(t.start)?t.params=e:super.setArrowFunctionParameters(t,e)}checkParams(t,e,i,s=!0){if(!i||-1===this.state.noArrowParamsConversionAt.indexOf(t.start)){for(let e=0;e0&&this.raise(re.ThisParamMustBeFirst,t.params[e]);super.checkParams(t,e,i,s)}}parseParenAndDistinguishExpression(t){return super.parseParenAndDistinguishExpression(t&&-1===this.state.noArrowAt.indexOf(this.state.start))}parseSubscripts(t,e,i){if("Identifier"===t.type&&"async"===t.name&&-1!==this.state.noArrowAt.indexOf(e.index)){this.next();const i=this.startNodeAt(e);i.callee=t,i.arguments=super.parseCallExpressionArguments(11,!1),t=this.finishNode(i,"CallExpression")}else if("Identifier"===t.type&&"async"===t.name&&this.match(47)){const s=this.state.clone(),n=this.tryParse((t=>this.parseAsyncArrowWithTypeParameters(e)||t()),s);if(!n.error&&!n.aborted)return n.node;const o=this.tryParse((()=>super.parseSubscripts(t,e,i)),s);if(o.node&&!o.error)return o.node;if(n.node)return this.state=n.failState,n.node;if(o.node)return this.state=o.failState,o.node;throw n.error||o.error}return super.parseSubscripts(t,e,i)}parseSubscript(t,e,i,s){if(this.match(18)&&this.isLookaheadToken_lt()){if(s.optionalChainMember=!0,i)return s.stop=!0,t;this.next();const n=this.startNodeAt(e);return n.callee=t,n.typeArguments=this.flowParseTypeParameterInstantiation(),this.expect(10),n.arguments=this.parseCallExpressionArguments(11,!1),n.optional=!0,this.finishCallExpression(n,!0)}if(!i&&this.shouldParseTypes()&&this.match(47)){const i=this.startNodeAt(e);i.callee=t;const n=this.tryParse((()=>(i.typeArguments=this.flowParseTypeParameterInstantiationCallOrNew(),this.expect(10),i.arguments=super.parseCallExpressionArguments(11,!1),s.optionalChainMember&&(i.optional=!1),this.finishCallExpression(i,s.optionalChainMember))));if(n.node)return n.error&&(this.state=n.failState),n.node}return super.parseSubscript(t,e,i,s)}parseNewCallee(t){super.parseNewCallee(t);let e=null;this.shouldParseTypes()&&this.match(47)&&(e=this.tryParse((()=>this.flowParseTypeParameterInstantiationCallOrNew())).node),t.typeArguments=e}parseAsyncArrowWithTypeParameters(t){const e=this.startNodeAt(t);if(this.parseFunctionParams(e,!1),this.parseArrow(e))return super.parseArrowExpression(e,void 0,!0)}readToken_mult_modulo(t){const e=this.input.charCodeAt(this.state.pos+1);if(42===t&&47===e&&this.state.hasFlowComment)return this.state.hasFlowComment=!1,this.state.pos+=2,void this.nextToken();super.readToken_mult_modulo(t)}readToken_pipe_amp(t){const e=this.input.charCodeAt(this.state.pos+1);124!==t||125!==e?super.readToken_pipe_amp(t):this.finishOp(9,2)}parseTopLevel(t,e){const i=super.parseTopLevel(t,e);return this.state.hasFlowComment&&this.raise(re.UnterminatedFlowComment,this.state.curPosition()),i}skipBlockComment(){if(!this.hasPlugin("flowComments")||!this.skipFlowComment())return super.skipBlockComment(this.state.hasFlowComment?"*-/":"*/");{if(this.state.hasFlowComment)throw this.raise(re.NestedFlowComment,this.state.startLoc);this.hasFlowCommentCompletion();const t=this.skipFlowComment();t&&(this.state.pos+=t,this.state.hasFlowComment=!0)}}skipFlowComment(){const{pos:t}=this.state;let e=2;for(;[32,9].includes(this.input.charCodeAt(t+e));)e++;const i=this.input.charCodeAt(e+t),s=this.input.charCodeAt(e+t+1);return 58===i&&58===s?e+2:"flow-include"===this.input.slice(e+t,e+t+12)?e+12:58===i&&58!==s&&e}hasFlowCommentCompletion(){if(-1===this.input.indexOf("*/",this.state.pos))throw this.raise(L.UnterminatedComment,this.state.curPosition())}flowEnumErrorBooleanMemberNotInitialized(t,{enumName:e,memberName:i}){this.raise(re.EnumBooleanMemberNotInitialized,t,{memberName:i,enumName:e})}flowEnumErrorInvalidMemberInitializer(t,e){return this.raise(e.explicitType?"symbol"===e.explicitType?re.EnumInvalidMemberInitializerSymbolType:re.EnumInvalidMemberInitializerPrimaryType:re.EnumInvalidMemberInitializerUnknownType,t,e)}flowEnumErrorNumberMemberNotInitialized(t,e){this.raise(re.EnumNumberMemberNotInitialized,t,e)}flowEnumErrorStringMemberInconsistentlyInitialized(t,e){this.raise(re.EnumStringMemberInconsistentlyInitialized,t,e)}flowEnumMemberInit(){const t=this.state.startLoc,e=()=>this.match(12)||this.match(8);switch(this.state.type){case 134:{const i=this.parseNumericLiteral(this.state.value);return e()?{type:"number",loc:i.loc.start,value:i}:{type:"invalid",loc:t}}case 133:{const i=this.parseStringLiteral(this.state.value);return e()?{type:"string",loc:i.loc.start,value:i}:{type:"invalid",loc:t}}case 85:case 86:{const i=this.parseBooleanLiteral(this.match(85));return e()?{type:"boolean",loc:i.loc.start,value:i}:{type:"invalid",loc:t}}default:return{type:"invalid",loc:t}}}flowEnumMemberRaw(){const t=this.state.startLoc;return{id:this.parseIdentifier(!0),init:this.eat(29)?this.flowEnumMemberInit():{type:"none",loc:t}}}flowEnumCheckExplicitTypeMismatch(t,e,i){const{explicitType:s}=e;null!==s&&s!==i&&this.flowEnumErrorInvalidMemberInitializer(t,e)}flowEnumMembers({enumName:t,explicitType:e}){const i=new Set,s={booleanMembers:[],numberMembers:[],stringMembers:[],defaultedMembers:[]};let n=!1;for(;!this.match(8);){if(this.eat(21)){n=!0;break}const o=this.startNode(),{id:a,init:r}=this.flowEnumMemberRaw(),l=a.name;if(""===l)continue;/^[a-z]/.test(l)&&this.raise(re.EnumInvalidMemberName,a,{memberName:l,suggestion:l[0].toUpperCase()+l.slice(1),enumName:t}),i.has(l)&&this.raise(re.EnumDuplicateMemberName,a,{memberName:l,enumName:t}),i.add(l);const h={enumName:t,explicitType:e,memberName:l};switch(o.id=a,r.type){case"boolean":this.flowEnumCheckExplicitTypeMismatch(r.loc,h,"boolean"),o.init=r.value,s.booleanMembers.push(this.finishNode(o,"EnumBooleanMember"));break;case"number":this.flowEnumCheckExplicitTypeMismatch(r.loc,h,"number"),o.init=r.value,s.numberMembers.push(this.finishNode(o,"EnumNumberMember"));break;case"string":this.flowEnumCheckExplicitTypeMismatch(r.loc,h,"string"),o.init=r.value,s.stringMembers.push(this.finishNode(o,"EnumStringMember"));break;case"invalid":throw this.flowEnumErrorInvalidMemberInitializer(r.loc,h);case"none":switch(e){case"boolean":this.flowEnumErrorBooleanMemberNotInitialized(r.loc,h);break;case"number":this.flowEnumErrorNumberMemberNotInitialized(r.loc,h);break;default:s.defaultedMembers.push(this.finishNode(o,"EnumDefaultedMember"))}}this.match(8)||this.expect(12)}return{members:s,hasUnknownMembers:n}}flowEnumStringMembers(t,e,{enumName:i}){if(0===t.length)return e;if(0===e.length)return t;if(e.length>t.length){for(const e of t)this.flowEnumErrorStringMemberInconsistentlyInitialized(e,{enumName:i});return e}for(const t of e)this.flowEnumErrorStringMemberInconsistentlyInitialized(t,{enumName:i});return t}flowEnumParseExplicitType({enumName:t}){if(!this.eatContextual(102))return null;if(!X(this.state.type))throw this.raise(re.EnumInvalidExplicitTypeUnknownSupplied,this.state.startLoc,{enumName:t});const{value:e}=this.state;return this.next(),"boolean"!==e&&"number"!==e&&"string"!==e&&"symbol"!==e&&this.raise(re.EnumInvalidExplicitType,this.state.startLoc,{enumName:t,invalidEnumType:e}),e}flowEnumBody(t,e){const i=e.name,s=e.loc.start,n=this.flowEnumParseExplicitType({enumName:i});this.expect(5);const{members:o,hasUnknownMembers:a}=this.flowEnumMembers({enumName:i,explicitType:n});switch(t.hasUnknownMembers=a,n){case"boolean":return t.explicitType=!0,t.members=o.booleanMembers,this.expect(8),this.finishNode(t,"EnumBooleanBody");case"number":return t.explicitType=!0,t.members=o.numberMembers,this.expect(8),this.finishNode(t,"EnumNumberBody");case"string":return t.explicitType=!0,t.members=this.flowEnumStringMembers(o.stringMembers,o.defaultedMembers,{enumName:i}),this.expect(8),this.finishNode(t,"EnumStringBody");case"symbol":return t.members=o.defaultedMembers,this.expect(8),this.finishNode(t,"EnumSymbolBody");default:{const e=()=>(t.members=[],this.expect(8),this.finishNode(t,"EnumStringBody"));t.explicitType=!1;const n=o.booleanMembers.length,a=o.numberMembers.length,r=o.stringMembers.length,l=o.defaultedMembers.length;if(n||a||r||l){if(n||a){if(!a&&!r&&n>=l){for(const t of o.defaultedMembers)this.flowEnumErrorBooleanMemberNotInitialized(t.loc.start,{enumName:i,memberName:t.id.name});return t.members=o.booleanMembers,this.expect(8),this.finishNode(t,"EnumBooleanBody")}if(!n&&!r&&a>=l){for(const t of o.defaultedMembers)this.flowEnumErrorNumberMemberNotInitialized(t.loc.start,{enumName:i,memberName:t.id.name});return t.members=o.numberMembers,this.expect(8),this.finishNode(t,"EnumNumberBody")}return this.raise(re.EnumInconsistentMemberValues,s,{enumName:i}),e()}return t.members=this.flowEnumStringMembers(o.stringMembers,o.defaultedMembers,{enumName:i}),this.expect(8),this.finishNode(t,"EnumStringBody")}return e()}}}flowParseEnumDeclaration(t){const e=this.parseIdentifier();return t.id=e,t.body=this.flowEnumBody(this.startNode(),e),this.finishNode(t,"EnumDeclaration")}isLookaheadToken_lt(){const t=this.nextTokenStart();if(60===this.input.charCodeAt(t)){const e=this.input.charCodeAt(t+1);return 60!==e&&61!==e}return!1}maybeUnwrapTypeCastExpression(t){return"TypeCastExpression"===t.type?t.expression:t}},typescript:t=>class extends t{constructor(...t){super(...t),this.tsParseInOutModifiers=this.tsParseModifiers.bind(this,{allowedModifiers:["in","out"],disallowedModifiers:["const","public","private","protected","readonly","declare","abstract","override"],errorTemplate:We.InvalidModifierOnTypeParameter}),this.tsParseConstModifier=this.tsParseModifiers.bind(this,{allowedModifiers:["const"],disallowedModifiers:["in","out"],errorTemplate:We.InvalidModifierOnTypeParameterPositions}),this.tsParseInOutConstModifiers=this.tsParseModifiers.bind(this,{allowedModifiers:["in","out","const"],disallowedModifiers:["public","private","protected","readonly","declare","abstract","override"],errorTemplate:We.InvalidModifierOnTypeParameter})}getScopeHandler(){return me}tsIsIdentifier(){return X(this.state.type)}tsTokenCanFollowModifier(){return(this.match(0)||this.match(5)||this.match(55)||this.match(21)||this.match(138)||this.isLiteralPropertyName())&&!this.hasPrecedingLineBreak()}tsNextTokenCanFollowModifier(){return this.next(),this.tsTokenCanFollowModifier()}tsParseModifier(t,e){if(!X(this.state.type)&&58!==this.state.type&&75!==this.state.type)return;const i=this.state.value;if(-1!==t.indexOf(i)){if(e&&this.tsIsStartOfStaticBlocks())return;if(this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this)))return i}}tsParseModifiers({allowedModifiers:t,disallowedModifiers:e,stopOnStartOfClassStaticBlock:i,errorTemplate:s=We.InvalidModifierOnTypeMember},n){const o=(t,e,i,s)=>{e===i&&n[s]&&this.raise(We.InvalidModifiersOrder,t,{orderedModifiers:[i,s]})},a=(t,e,i,s)=>{(n[i]&&e===s||n[s]&&e===i)&&this.raise(We.IncompatibleModifiers,t,{modifiers:[i,s]})};for(;;){const{startLoc:r}=this.state,l=this.tsParseModifier(t.concat(null!=e?e:[]),i);if(!l)break;we(l)?n.accessibility?this.raise(We.DuplicateAccessibilityModifier,r,{modifier:l}):(o(r,l,l,"override"),o(r,l,l,"static"),o(r,l,l,"readonly"),n.accessibility=l):ve(l)?(n[l]&&this.raise(We.DuplicateModifier,r,{modifier:l}),n[l]=!0,o(r,l,"in","out")):(Object.hasOwnProperty.call(n,l)?this.raise(We.DuplicateModifier,r,{modifier:l}):(o(r,l,"static","readonly"),o(r,l,"static","override"),o(r,l,"override","readonly"),o(r,l,"abstract","override"),a(r,l,"declare","override"),a(r,l,"static","abstract")),n[l]=!0),null!=e&&e.includes(l)&&this.raise(s,r,{modifier:l})}}tsIsListTerminator(t){switch(t){case"EnumMembers":case"TypeMembers":return this.match(8);case"HeritageClauseElement":return this.match(5);case"TupleElementTypes":return this.match(3);case"TypeParametersOrArguments":return this.match(48)}}tsParseList(t,e){const i=[];for(;!this.tsIsListTerminator(t);)i.push(e());return i}tsParseDelimitedList(t,e,i){return function(t){if(null==t)throw new Error(`Unexpected ${t} value.`);return t}(this.tsParseDelimitedListWorker(t,e,!0,i))}tsParseDelimitedListWorker(t,e,i,s){const n=[];let o=-1;for(;!this.tsIsListTerminator(t);){o=-1;const s=e();if(null==s)return;if(n.push(s),!this.eat(12)){if(this.tsIsListTerminator(t))break;return void(i&&this.expect(12))}o=this.state.lastTokStartLoc.index}return s&&(s.value=o),n}tsParseBracketedList(t,e,i,s,n){s||(i?this.expect(0):this.expect(47));const o=this.tsParseDelimitedList(t,e,n);return i?this.expect(3):this.expect(48),o}tsParseImportType(){const t=this.startNode();return this.expect(83),this.expect(10),this.match(133)||this.raise(We.UnsupportedImportTypeArgument,this.state.startLoc),t.argument=super.parseExprAtom(),this.expect(11),this.eat(16)&&(t.qualifier=this.tsParseEntityName()),this.match(47)&&(t.typeParameters=this.tsParseTypeArguments()),this.finishNode(t,"TSImportType")}tsParseEntityName(t=!0){let e=this.parseIdentifier(t);for(;this.eat(16);){const i=this.startNodeAtNode(e);i.left=e,i.right=this.parseIdentifier(t),e=this.finishNode(i,"TSQualifiedName")}return e}tsParseTypeReference(){const t=this.startNode();return t.typeName=this.tsParseEntityName(),!this.hasPrecedingLineBreak()&&this.match(47)&&(t.typeParameters=this.tsParseTypeArguments()),this.finishNode(t,"TSTypeReference")}tsParseThisTypePredicate(t){this.next();const e=this.startNodeAtNode(t);return e.parameterName=t,e.typeAnnotation=this.tsParseTypeAnnotation(!1),e.asserts=!1,this.finishNode(e,"TSTypePredicate")}tsParseThisTypeNode(){const t=this.startNode();return this.next(),this.finishNode(t,"TSThisType")}tsParseTypeQuery(){const t=this.startNode();return this.expect(87),this.match(83)?t.exprName=this.tsParseImportType():t.exprName=this.tsParseEntityName(),!this.hasPrecedingLineBreak()&&this.match(47)&&(t.typeParameters=this.tsParseTypeArguments()),this.finishNode(t,"TSTypeQuery")}tsParseTypeParameter(t){const e=this.startNode();return t(e),e.name=this.tsParseTypeParameterName(),e.constraint=this.tsEatThenParseType(81),e.default=this.tsEatThenParseType(29),this.finishNode(e,"TSTypeParameter")}tsTryParseTypeParameters(t){if(this.match(47))return this.tsParseTypeParameters(t)}tsParseTypeParameters(t){const e=this.startNode();this.match(47)||this.match(142)?this.next():this.unexpected();const i={value:-1};return e.params=this.tsParseBracketedList("TypeParametersOrArguments",this.tsParseTypeParameter.bind(this,t),!1,!0,i),0===e.params.length&&this.raise(We.EmptyTypeParameters,e),-1!==i.value&&this.addExtra(e,"trailingComma",i.value),this.finishNode(e,"TSTypeParameterDeclaration")}tsFillSignature(t,e){const i=19===t;e.typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier),this.expect(10),e.parameters=this.tsParseBindingListForSignature(),(i||this.match(t))&&(e.typeAnnotation=this.tsParseTypeOrTypePredicateAnnotation(t))}tsParseBindingListForSignature(){const t=super.parseBindingList(11,41,2);for(const e of t){const{type:t}=e;"AssignmentPattern"!==t&&"TSParameterProperty"!==t||this.raise(We.UnsupportedSignatureParameterKind,e,{type:t})}return t}tsParseTypeMemberSemicolon(){this.eat(12)||this.isLineTerminator()||this.expect(13)}tsParseSignatureMember(t,e){return this.tsFillSignature(14,e),this.tsParseTypeMemberSemicolon(),this.finishNode(e,t)}tsIsUnambiguouslyIndexSignature(){return this.next(),!!X(this.state.type)&&(this.next(),this.match(14))}tsTryParseIndexSignature(t){if(!this.match(0)||!this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))return;this.expect(0);const e=this.parseIdentifier();e.typeAnnotation=this.tsParseTypeAnnotation(),this.resetEndLocation(e),this.expect(3),t.parameters=[e];const i=this.tsTryParseTypeAnnotation();return i&&(t.typeAnnotation=i),this.tsParseTypeMemberSemicolon(),this.finishNode(t,"TSIndexSignature")}tsParsePropertyOrMethodSignature(t,e){this.eat(17)&&(t.optional=!0);const i=t;if(this.match(10)||this.match(47)){e&&this.raise(We.ReadonlyForMethodSignature,t);const s=i;s.kind&&this.match(47)&&this.raise(We.AccesorCannotHaveTypeParameters,this.state.curPosition()),this.tsFillSignature(14,s),this.tsParseTypeMemberSemicolon();const n="parameters",o="typeAnnotation";if("get"===s.kind)s[n].length>0&&(this.raise(L.BadGetterArity,this.state.curPosition()),this.isThisParam(s[n][0])&&this.raise(We.AccesorCannotDeclareThisParameter,this.state.curPosition()));else if("set"===s.kind){if(1!==s[n].length)this.raise(L.BadSetterArity,this.state.curPosition());else{const t=s[n][0];this.isThisParam(t)&&this.raise(We.AccesorCannotDeclareThisParameter,this.state.curPosition()),"Identifier"===t.type&&t.optional&&this.raise(We.SetAccesorCannotHaveOptionalParameter,this.state.curPosition()),"RestElement"===t.type&&this.raise(We.SetAccesorCannotHaveRestParameter,this.state.curPosition())}s[o]&&this.raise(We.SetAccesorCannotHaveReturnType,s[o])}else s.kind="method";return this.finishNode(s,"TSMethodSignature")}{const t=i;e&&(t.readonly=!0);const s=this.tsTryParseTypeAnnotation();return s&&(t.typeAnnotation=s),this.tsParseTypeMemberSemicolon(),this.finishNode(t,"TSPropertySignature")}}tsParseTypeMember(){const t=this.startNode();if(this.match(10)||this.match(47))return this.tsParseSignatureMember("TSCallSignatureDeclaration",t);if(this.match(77)){const e=this.startNode();return this.next(),this.match(10)||this.match(47)?this.tsParseSignatureMember("TSConstructSignatureDeclaration",t):(t.key=this.createIdentifier(e,"new"),this.tsParsePropertyOrMethodSignature(t,!1))}this.tsParseModifiers({allowedModifiers:["readonly"],disallowedModifiers:["declare","abstract","private","protected","public","static","override"]},t);return this.tsTryParseIndexSignature(t)||(super.parsePropertyName(t),t.computed||"Identifier"!==t.key.type||"get"!==t.key.name&&"set"!==t.key.name||!this.tsTokenCanFollowModifier()||(t.kind=t.key.name,super.parsePropertyName(t)),this.tsParsePropertyOrMethodSignature(t,!!t.readonly))}tsParseTypeLiteral(){const t=this.startNode();return t.members=this.tsParseObjectTypeMembers(),this.finishNode(t,"TSTypeLiteral")}tsParseObjectTypeMembers(){this.expect(5);const t=this.tsParseList("TypeMembers",this.tsParseTypeMember.bind(this));return this.expect(8),t}tsIsStartOfMappedType(){return this.next(),this.eat(53)?this.isContextual(122):(this.isContextual(122)&&this.next(),!!this.match(0)&&(this.next(),!!this.tsIsIdentifier()&&(this.next(),this.match(58))))}tsParseMappedTypeParameter(){const t=this.startNode();return t.name=this.tsParseTypeParameterName(),t.constraint=this.tsExpectThenParseType(58),this.finishNode(t,"TSTypeParameter")}tsParseMappedType(){const t=this.startNode();return this.expect(5),this.match(53)?(t.readonly=this.state.value,this.next(),this.expectContextual(122)):this.eatContextual(122)&&(t.readonly=!0),this.expect(0),t.typeParameter=this.tsParseMappedTypeParameter(),t.nameType=this.eatContextual(93)?this.tsParseType():null,this.expect(3),this.match(53)?(t.optional=this.state.value,this.next(),this.expect(17)):this.eat(17)&&(t.optional=!0),t.typeAnnotation=this.tsTryParseType(),this.semicolon(),this.expect(8),this.finishNode(t,"TSMappedType")}tsParseTupleType(){const t=this.startNode();t.elementTypes=this.tsParseBracketedList("TupleElementTypes",this.tsParseTupleElementType.bind(this),!0,!1);let e=!1;return t.elementTypes.forEach((t=>{const{type:i}=t;!e||"TSRestType"===i||"TSOptionalType"===i||"TSNamedTupleMember"===i&&t.optional||this.raise(We.OptionalTypeBeforeRequired,t),e||(e="TSNamedTupleMember"===i&&t.optional||"TSOptionalType"===i)})),this.finishNode(t,"TSTupleType")}tsParseTupleElementType(){const{startLoc:t}=this.state,e=this.eat(21);let i,s,n,o;const a=E(this.state.type)?this.lookaheadCharCode():null;if(58===a)i=!0,n=!1,s=this.parseIdentifier(!0),this.expect(14),o=this.tsParseType();else if(63===a){n=!0;const t=this.state.startLoc,e=this.state.value,a=this.tsParseNonArrayType();58===this.lookaheadCharCode()?(i=!0,s=this.createIdentifier(this.startNodeAt(t),e),this.expect(17),this.expect(14),o=this.tsParseType()):(i=!1,o=a,this.expect(17))}else o=this.tsParseType(),n=this.eat(17),i=this.eat(14);if(i){let t;s?(t=this.startNodeAtNode(s),t.optional=n,t.label=s,t.elementType=o,this.eat(17)&&(t.optional=!0,this.raise(We.TupleOptionalAfterType,this.state.lastTokStartLoc))):(t=this.startNodeAtNode(o),t.optional=n,this.raise(We.InvalidTupleMemberLabel,o),t.label=o,t.elementType=this.tsParseType()),o=this.finishNode(t,"TSNamedTupleMember")}else if(n){const t=this.startNodeAtNode(o);t.typeAnnotation=o,o=this.finishNode(t,"TSOptionalType")}if(e){const e=this.startNodeAt(t);e.typeAnnotation=o,o=this.finishNode(e,"TSRestType")}return o}tsParseParenthesizedType(){const t=this.startNode();return this.expect(10),t.typeAnnotation=this.tsParseType(),this.expect(11),this.finishNode(t,"TSParenthesizedType")}tsParseFunctionOrConstructorType(t,e){const i=this.startNode();return"TSConstructorType"===t&&(i.abstract=!!e,e&&this.next(),this.next()),this.tsInAllowConditionalTypesContext((()=>this.tsFillSignature(19,i))),this.finishNode(i,t)}tsParseLiteralTypeNode(){const t=this.startNode();switch(this.state.type){case 134:case 135:case 133:case 85:case 86:t.literal=super.parseExprAtom();break;default:this.unexpected()}return this.finishNode(t,"TSLiteralType")}tsParseTemplateLiteralType(){const t=this.startNode();return t.literal=super.parseTemplate(!1),this.finishNode(t,"TSLiteralType")}parseTemplateSubstitution(){return this.state.inType?this.tsParseType():super.parseTemplateSubstitution()}tsParseThisTypeOrThisTypePredicate(){const t=this.tsParseThisTypeNode();return this.isContextual(116)&&!this.hasPrecedingLineBreak()?this.tsParseThisTypePredicate(t):t}tsParseNonArrayType(){switch(this.state.type){case 133:case 134:case 135:case 85:case 86:return this.tsParseLiteralTypeNode();case 53:if("-"===this.state.value){const t=this.startNode(),e=this.lookahead();return 134!==e.type&&135!==e.type&&this.unexpected(),t.literal=this.parseMaybeUnary(),this.finishNode(t,"TSLiteralType")}break;case 78:return this.tsParseThisTypeOrThisTypePredicate();case 87:return this.tsParseTypeQuery();case 83:return this.tsParseImportType();case 5:return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))?this.tsParseMappedType():this.tsParseTypeLiteral();case 0:return this.tsParseTupleType();case 10:return this.tsParseParenthesizedType();case 25:case 24:return this.tsParseTemplateLiteralType();default:{const{type:t}=this.state;if(X(t)||88===t||84===t){const e=88===t?"TSVoidKeyword":84===t?"TSNullKeyword":function(t){switch(t){case"any":return"TSAnyKeyword";case"boolean":return"TSBooleanKeyword";case"bigint":return"TSBigIntKeyword";case"never":return"TSNeverKeyword";case"number":return"TSNumberKeyword";case"object":return"TSObjectKeyword";case"string":return"TSStringKeyword";case"symbol":return"TSSymbolKeyword";case"undefined":return"TSUndefinedKeyword";case"unknown":return"TSUnknownKeyword";default:return}}(this.state.value);if(void 0!==e&&46!==this.lookaheadCharCode()){const t=this.startNode();return this.next(),this.finishNode(t,e)}return this.tsParseTypeReference()}}}this.unexpected()}tsParseArrayTypeOrHigher(){let t=this.tsParseNonArrayType();for(;!this.hasPrecedingLineBreak()&&this.eat(0);)if(this.match(3)){const e=this.startNodeAtNode(t);e.elementType=t,this.expect(3),t=this.finishNode(e,"TSArrayType")}else{const e=this.startNodeAtNode(t);e.objectType=t,e.indexType=this.tsParseType(),this.expect(3),t=this.finishNode(e,"TSIndexedAccessType")}return t}tsParseTypeOperator(){const t=this.startNode(),e=this.state.value;return this.next(),t.operator=e,t.typeAnnotation=this.tsParseTypeOperatorOrHigher(),"readonly"===e&&this.tsCheckTypeAnnotationForReadOnly(t),this.finishNode(t,"TSTypeOperator")}tsCheckTypeAnnotationForReadOnly(t){switch(t.typeAnnotation.type){case"TSTupleType":case"TSArrayType":return;default:this.raise(We.UnexpectedReadonly,t)}}tsParseInferType(){const t=this.startNode();this.expectContextual(115);const e=this.startNode();return e.name=this.tsParseTypeParameterName(),e.constraint=this.tsTryParse((()=>this.tsParseConstraintForInferType())),t.typeParameter=this.finishNode(e,"TSTypeParameter"),this.finishNode(t,"TSInferType")}tsParseConstraintForInferType(){if(this.eat(81)){const t=this.tsInDisallowConditionalTypesContext((()=>this.tsParseType()));if(this.state.inDisallowConditionalTypesContext||!this.match(17))return t}}tsParseTypeOperatorOrHigher(){var t;return(t=this.state.type)>=121&&t<=123&&!this.state.containsEsc?this.tsParseTypeOperator():this.isContextual(115)?this.tsParseInferType():this.tsInAllowConditionalTypesContext((()=>this.tsParseArrayTypeOrHigher()))}tsParseUnionOrIntersectionType(t,e,i){const s=this.startNode(),n=this.eat(i),o=[];do{o.push(e())}while(this.eat(i));return 1!==o.length||n?(s.types=o,this.finishNode(s,t)):o[0]}tsParseIntersectionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSIntersectionType",this.tsParseTypeOperatorOrHigher.bind(this),45)}tsParseUnionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSUnionType",this.tsParseIntersectionTypeOrHigher.bind(this),43)}tsIsStartOfFunctionType(){return!!this.match(47)||this.match(10)&&this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))}tsSkipParameterStart(){if(X(this.state.type)||this.match(78))return this.next(),!0;if(this.match(5)){const{errors:t}=this.state,e=t.length;try{return this.parseObjectLike(8,!0),t.length===e}catch(t){return!1}}if(this.match(0)){this.next();const{errors:t}=this.state,e=t.length;try{return super.parseBindingList(3,93,1),t.length===e}catch(t){return!1}}return!1}tsIsUnambiguouslyStartOfFunctionType(){if(this.next(),this.match(11)||this.match(21))return!0;if(this.tsSkipParameterStart()){if(this.match(14)||this.match(12)||this.match(17)||this.match(29))return!0;if(this.match(11)&&(this.next(),this.match(19)))return!0}return!1}tsParseTypeOrTypePredicateAnnotation(t){return this.tsInType((()=>{const e=this.startNode();this.expect(t);const i=this.startNode(),s=!!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));if(s&&this.match(78)){let t=this.tsParseThisTypeOrThisTypePredicate();return"TSThisType"===t.type?(i.parameterName=t,i.asserts=!0,i.typeAnnotation=null,t=this.finishNode(i,"TSTypePredicate")):(this.resetStartLocationFromNode(t,i),t.asserts=!0),e.typeAnnotation=t,this.finishNode(e,"TSTypeAnnotation")}const n=this.tsIsIdentifier()&&this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));if(!n)return s?(i.parameterName=this.parseIdentifier(),i.asserts=s,i.typeAnnotation=null,e.typeAnnotation=this.finishNode(i,"TSTypePredicate"),this.finishNode(e,"TSTypeAnnotation")):this.tsParseTypeAnnotation(!1,e);const o=this.tsParseTypeAnnotation(!1);return i.parameterName=n,i.typeAnnotation=o,i.asserts=s,e.typeAnnotation=this.finishNode(i,"TSTypePredicate"),this.finishNode(e,"TSTypeAnnotation")}))}tsTryParseTypeOrTypePredicateAnnotation(){if(this.match(14))return this.tsParseTypeOrTypePredicateAnnotation(14)}tsTryParseTypeAnnotation(){if(this.match(14))return this.tsParseTypeAnnotation()}tsTryParseType(){return this.tsEatThenParseType(14)}tsParseTypePredicatePrefix(){const t=this.parseIdentifier();if(this.isContextual(116)&&!this.hasPrecedingLineBreak())return this.next(),t}tsParseTypePredicateAsserts(){if(109!==this.state.type)return!1;const t=this.state.containsEsc;return this.next(),!(!X(this.state.type)&&!this.match(78)||(t&&this.raise(L.InvalidEscapedReservedWord,this.state.lastTokStartLoc,{reservedWord:"asserts"}),0))}tsParseTypeAnnotation(t=!0,e=this.startNode()){return this.tsInType((()=>{t&&this.expect(14),e.typeAnnotation=this.tsParseType()})),this.finishNode(e,"TSTypeAnnotation")}tsParseType(){Me(this.state.inType);const t=this.tsParseNonConditionalType();if(this.state.inDisallowConditionalTypesContext||this.hasPrecedingLineBreak()||!this.eat(81))return t;const e=this.startNodeAtNode(t);return e.checkType=t,e.extendsType=this.tsInDisallowConditionalTypesContext((()=>this.tsParseNonConditionalType())),this.expect(17),e.trueType=this.tsInAllowConditionalTypesContext((()=>this.tsParseType())),this.expect(14),e.falseType=this.tsInAllowConditionalTypesContext((()=>this.tsParseType())),this.finishNode(e,"TSConditionalType")}isAbstractConstructorSignature(){return this.isContextual(124)&&77===this.lookahead().type}tsParseNonConditionalType(){return this.tsIsStartOfFunctionType()?this.tsParseFunctionOrConstructorType("TSFunctionType"):this.match(77)?this.tsParseFunctionOrConstructorType("TSConstructorType"):this.isAbstractConstructorSignature()?this.tsParseFunctionOrConstructorType("TSConstructorType",!0):this.tsParseUnionTypeOrHigher()}tsParseTypeAssertion(){this.getPluginOption("typescript","disallowAmbiguousJSXLike")&&this.raise(We.ReservedTypeAssertion,this.state.startLoc);const t=this.startNode();return t.typeAnnotation=this.tsInType((()=>(this.next(),this.match(75)?this.tsParseTypeReference():this.tsParseType()))),this.expect(48),t.expression=this.parseMaybeUnary(),this.finishNode(t,"TSTypeAssertion")}tsParseHeritageClause(t){const e=this.state.startLoc,i=this.tsParseDelimitedList("HeritageClauseElement",(()=>{const t=this.startNode();return t.expression=this.tsParseEntityName(),this.match(47)&&(t.typeParameters=this.tsParseTypeArguments()),this.finishNode(t,"TSExpressionWithTypeArguments")}));return i.length||this.raise(We.EmptyHeritageClauseType,e,{token:t}),i}tsParseInterfaceDeclaration(t,e={}){if(this.hasFollowingLineBreak())return null;this.expectContextual(129),e.declare&&(t.declare=!0),X(this.state.type)?(t.id=this.parseIdentifier(),this.checkIdentifier(t.id,130)):(t.id=null,this.raise(We.MissingInterfaceName,this.state.startLoc)),t.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers),this.eat(81)&&(t.extends=this.tsParseHeritageClause("extends"));const i=this.startNode();return i.body=this.tsInType(this.tsParseObjectTypeMembers.bind(this)),t.body=this.finishNode(i,"TSInterfaceBody"),this.finishNode(t,"TSInterfaceDeclaration")}tsParseTypeAliasDeclaration(t){return t.id=this.parseIdentifier(),this.checkIdentifier(t.id,2),t.typeAnnotation=this.tsInType((()=>{if(t.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutModifiers),this.expect(29),this.isContextual(114)&&16!==this.lookahead().type){const t=this.startNode();return this.next(),this.finishNode(t,"TSIntrinsicKeyword")}return this.tsParseType()})),this.semicolon(),this.finishNode(t,"TSTypeAliasDeclaration")}tsInNoContext(t){const e=this.state.context;this.state.context=[e[0]];try{return t()}finally{this.state.context=e}}tsInType(t){const e=this.state.inType;this.state.inType=!0;try{return t()}finally{this.state.inType=e}}tsInDisallowConditionalTypesContext(t){const e=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!0;try{return t()}finally{this.state.inDisallowConditionalTypesContext=e}}tsInAllowConditionalTypesContext(t){const e=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!1;try{return t()}finally{this.state.inDisallowConditionalTypesContext=e}}tsEatThenParseType(t){if(this.match(t))return this.tsNextThenParseType()}tsExpectThenParseType(t){return this.tsInType((()=>(this.expect(t),this.tsParseType())))}tsNextThenParseType(){return this.tsInType((()=>(this.next(),this.tsParseType())))}tsParseEnumMember(){const t=this.startNode();return t.id=this.match(133)?super.parseStringLiteral(this.state.value):this.parseIdentifier(!0),this.eat(29)&&(t.initializer=super.parseMaybeAssignAllowIn()),this.finishNode(t,"TSEnumMember")}tsParseEnumDeclaration(t,e={}){return e.const&&(t.const=!0),e.declare&&(t.declare=!0),this.expectContextual(126),t.id=this.parseIdentifier(),this.checkIdentifier(t.id,t.const?8971:8459),this.expect(5),t.members=this.tsParseDelimitedList("EnumMembers",this.tsParseEnumMember.bind(this)),this.expect(8),this.finishNode(t,"TSEnumDeclaration")}tsParseModuleBlock(){const t=this.startNode();return this.scope.enter(0),this.expect(5),super.parseBlockOrModuleBlockBody(t.body=[],void 0,!0,8),this.scope.exit(),this.finishNode(t,"TSModuleBlock")}tsParseModuleOrNamespaceDeclaration(t,e=!1){if(t.id=this.parseIdentifier(),e||this.checkIdentifier(t.id,1024),this.eat(16)){const e=this.startNode();this.tsParseModuleOrNamespaceDeclaration(e,!0),t.body=e}else this.scope.enter(256),this.prodParam.enter(0),t.body=this.tsParseModuleBlock(),this.prodParam.exit(),this.scope.exit();return this.finishNode(t,"TSModuleDeclaration")}tsParseAmbientExternalModuleDeclaration(t){return this.isContextual(112)?(t.global=!0,t.id=this.parseIdentifier()):this.match(133)?t.id=super.parseStringLiteral(this.state.value):this.unexpected(),this.match(5)?(this.scope.enter(256),this.prodParam.enter(0),t.body=this.tsParseModuleBlock(),this.prodParam.exit(),this.scope.exit()):this.semicolon(),this.finishNode(t,"TSModuleDeclaration")}tsParseImportEqualsDeclaration(t,e,i){t.isExport=i||!1,t.id=e||this.parseIdentifier(),this.checkIdentifier(t.id,4096),this.expect(29);const s=this.tsParseModuleReference();return"type"===t.importKind&&"TSExternalModuleReference"!==s.type&&this.raise(We.ImportAliasHasImportType,s),t.moduleReference=s,this.semicolon(),this.finishNode(t,"TSImportEqualsDeclaration")}tsIsExternalModuleReference(){return this.isContextual(119)&&40===this.lookaheadCharCode()}tsParseModuleReference(){return this.tsIsExternalModuleReference()?this.tsParseExternalModuleReference():this.tsParseEntityName(!1)}tsParseExternalModuleReference(){const t=this.startNode();return this.expectContextual(119),this.expect(10),this.match(133)||this.unexpected(),t.expression=super.parseExprAtom(),this.expect(11),this.sawUnambiguousESM=!0,this.finishNode(t,"TSExternalModuleReference")}tsLookAhead(t){const e=this.state.clone(),i=t();return this.state=e,i}tsTryParseAndCatch(t){const e=this.tryParse((e=>t()||e()));if(!e.aborted&&e.node)return e.error&&(this.state=e.failState),e.node}tsTryParse(t){const e=this.state.clone(),i=t();if(void 0!==i&&!1!==i)return i;this.state=e}tsTryParseDeclare(t){if(this.isLineTerminator())return;let e,i=this.state.type;return this.isContextual(100)&&(i=74,e="let"),this.tsInAmbientContext((()=>{switch(i){case 68:return t.declare=!0,super.parseFunctionStatement(t,!1,!1);case 80:return t.declare=!0,this.parseClass(t,!0,!1);case 126:return this.tsParseEnumDeclaration(t,{declare:!0});case 112:return this.tsParseAmbientExternalModuleDeclaration(t);case 75:case 74:return this.match(75)&&this.isLookaheadContextual("enum")?(this.expect(75),this.tsParseEnumDeclaration(t,{const:!0,declare:!0})):(t.declare=!0,this.parseVarStatement(t,e||this.state.value,!0));case 129:{const e=this.tsParseInterfaceDeclaration(t,{declare:!0});if(e)return e}default:if(X(i))return this.tsParseDeclaration(t,this.state.value,!0,null)}}))}tsTryParseExportDeclaration(){return this.tsParseDeclaration(this.startNode(),this.state.value,!0,null)}tsParseExpressionStatement(t,e,i){switch(e.name){case"declare":{const e=this.tsTryParseDeclare(t);return e&&(e.declare=!0),e}case"global":if(this.match(5)){this.scope.enter(256),this.prodParam.enter(0);const i=t;return i.global=!0,i.id=e,i.body=this.tsParseModuleBlock(),this.scope.exit(),this.prodParam.exit(),this.finishNode(i,"TSModuleDeclaration")}break;default:return this.tsParseDeclaration(t,e.name,!1,i)}}tsParseDeclaration(t,e,i,s){switch(e){case"abstract":if(this.tsCheckLineTerminator(i)&&(this.match(80)||X(this.state.type)))return this.tsParseAbstractDeclaration(t,s);break;case"module":if(this.tsCheckLineTerminator(i)){if(this.match(133))return this.tsParseAmbientExternalModuleDeclaration(t);if(X(this.state.type))return this.tsParseModuleOrNamespaceDeclaration(t)}break;case"namespace":if(this.tsCheckLineTerminator(i)&&X(this.state.type))return this.tsParseModuleOrNamespaceDeclaration(t);break;case"type":if(this.tsCheckLineTerminator(i)&&X(this.state.type))return this.tsParseTypeAliasDeclaration(t)}}tsCheckLineTerminator(t){return t?!this.hasFollowingLineBreak()&&(this.next(),!0):!this.isLineTerminator()}tsTryParseGenericAsyncArrowFunction(t){if(!this.match(47))return;const e=this.state.maybeInArrowParameters;this.state.maybeInArrowParameters=!0;const i=this.tsTryParseAndCatch((()=>{const e=this.startNodeAt(t);return e.typeParameters=this.tsParseTypeParameters(this.tsParseConstModifier),super.parseFunctionParams(e),e.returnType=this.tsTryParseTypeOrTypePredicateAnnotation(),this.expect(19),e}));return this.state.maybeInArrowParameters=e,i?super.parseArrowExpression(i,null,!0):void 0}tsParseTypeArgumentsInExpression(){if(47===this.reScan_lt())return this.tsParseTypeArguments()}tsParseTypeArguments(){const t=this.startNode();return t.params=this.tsInType((()=>this.tsInNoContext((()=>(this.expect(47),this.tsParseDelimitedList("TypeParametersOrArguments",this.tsParseType.bind(this))))))),0===t.params.length?this.raise(We.EmptyTypeArguments,t):this.state.inType||this.curContext()!==j.brace||this.reScan_lt_gt(),this.expect(48),this.finishNode(t,"TSTypeParameterInstantiation")}tsIsDeclarationStart(){return(t=this.state.type)>=124&&t<=130;var t}isExportDefaultSpecifier(){return!this.tsIsDeclarationStart()&&super.isExportDefaultSpecifier()}parseAssignableListItem(t,e){const i=this.state.startLoc,s={};this.tsParseModifiers({allowedModifiers:["public","private","protected","override","readonly"]},s);const n=s.accessibility,o=s.override,a=s.readonly;4&t||!(n||a||o)||this.raise(We.UnexpectedParameterModifier,i);const r=this.parseMaybeDefault();this.parseAssignableListItemTypes(r,t);const l=this.parseMaybeDefault(r.loc.start,r);if(n||a||o){const t=this.startNodeAt(i);return e.length&&(t.decorators=e),n&&(t.accessibility=n),a&&(t.readonly=a),o&&(t.override=o),"Identifier"!==l.type&&"AssignmentPattern"!==l.type&&this.raise(We.UnsupportedParameterPropertyKind,t),t.parameter=l,this.finishNode(t,"TSParameterProperty")}return e.length&&(r.decorators=e),l}isSimpleParameter(t){return"TSParameterProperty"===t.type&&super.isSimpleParameter(t.parameter)||super.isSimpleParameter(t)}tsDisallowOptionalPattern(t){for(const e of t.params)"Identifier"!==e.type&&e.optional&&!this.state.isAmbientContext&&this.raise(We.PatternIsOptional,e)}setArrowFunctionParameters(t,e,i){super.setArrowFunctionParameters(t,e,i),this.tsDisallowOptionalPattern(t)}parseFunctionBodyAndFinish(t,e,i=!1){this.match(14)&&(t.returnType=this.tsParseTypeOrTypePredicateAnnotation(14));const s="FunctionDeclaration"===e?"TSDeclareFunction":"ClassMethod"===e||"ClassPrivateMethod"===e?"TSDeclareMethod":void 0;return s&&!this.match(5)&&this.isLineTerminator()?this.finishNode(t,s):"TSDeclareFunction"===s&&this.state.isAmbientContext&&(this.raise(We.DeclareFunctionHasImplementation,t),t.declare)?super.parseFunctionBodyAndFinish(t,s,i):(this.tsDisallowOptionalPattern(t),super.parseFunctionBodyAndFinish(t,e,i))}registerFunctionStatementId(t){!t.body&&t.id?this.checkIdentifier(t.id,1024):super.registerFunctionStatementId(t)}tsCheckForInvalidTypeCasts(t){t.forEach((t=>{"TSTypeCastExpression"===(null==t?void 0:t.type)&&this.raise(We.UnexpectedTypeAnnotation,t.typeAnnotation)}))}toReferencedList(t,e){return this.tsCheckForInvalidTypeCasts(t),t}parseArrayLike(t,e,i,s){const n=super.parseArrayLike(t,e,i,s);return"ArrayExpression"===n.type&&this.tsCheckForInvalidTypeCasts(n.elements),n}parseSubscript(t,e,i,s){if(!this.hasPrecedingLineBreak()&&this.match(35)){this.state.canStartJSXElement=!1,this.next();const i=this.startNodeAt(e);return i.expression=t,this.finishNode(i,"TSNonNullExpression")}let n=!1;if(this.match(18)&&60===this.lookaheadCharCode()){if(i)return s.stop=!0,t;s.optionalChainMember=n=!0,this.next()}if(this.match(47)||this.match(51)){let o;const a=this.tsTryParseAndCatch((()=>{if(!i&&this.atPossibleAsyncArrow(t)){const t=this.tsTryParseGenericAsyncArrowFunction(e);if(t)return t}const a=this.tsParseTypeArgumentsInExpression();if(!a)return;if(n&&!this.match(10))return void(o=this.state.curPosition());if(q(this.state.type)){const i=super.parseTaggedTemplateExpression(t,e,s);return i.typeParameters=a,i}if(!i&&this.eat(10)){const i=this.startNodeAt(e);return i.callee=t,i.arguments=this.parseCallExpressionArguments(11,!1),this.tsCheckForInvalidTypeCasts(i.arguments),i.typeParameters=a,s.optionalChainMember&&(i.optional=n),this.finishCallExpression(i,s.optionalChainMember)}const r=this.state.type;if(48===r||52===r||10!==r&&U(r)&&!this.hasPrecedingLineBreak())return;const l=this.startNodeAt(e);return l.expression=t,l.typeParameters=a,this.finishNode(l,"TSInstantiationExpression")}));if(o&&this.unexpected(o,10),a)return"TSInstantiationExpression"===a.type&&(this.match(16)||this.match(18)&&40!==this.lookaheadCharCode())&&this.raise(We.InvalidPropertyAccessAfterInstantiationExpression,this.state.startLoc),a}return super.parseSubscript(t,e,i,s)}parseNewCallee(t){var e;super.parseNewCallee(t);const{callee:i}=t;"TSInstantiationExpression"!==i.type||null!=(e=i.extra)&&e.parenthesized||(t.typeParameters=i.typeParameters,t.callee=i.expression)}parseExprOp(t,e,i){let s;if(Q(58)>i&&!this.hasPrecedingLineBreak()&&(this.isContextual(93)||(s=this.isContextual(120)))){const n=this.startNodeAt(e);return n.expression=t,n.typeAnnotation=this.tsInType((()=>(this.next(),this.match(75)?(s&&this.raise(L.UnexpectedKeyword,this.state.startLoc,{keyword:"const"}),this.tsParseTypeReference()):this.tsParseType()))),this.finishNode(n,s?"TSSatisfiesExpression":"TSAsExpression"),this.reScan_lt_gt(),this.parseExprOp(n,e,i)}return super.parseExprOp(t,e,i)}checkReservedWord(t,e,i,s){this.state.isAmbientContext||super.checkReservedWord(t,e,i,s)}checkImportReflection(t){super.checkImportReflection(t),t.module&&"value"!==t.importKind&&this.raise(We.ImportReflectionHasImportType,t.specifiers[0].loc.start)}checkDuplicateExports(){}isPotentialImportPhase(t){if(super.isPotentialImportPhase(t))return!0;if(this.isContextual(130)){const e=this.lookaheadCharCode();return t?123===e||42===e:61!==e}return!t&&this.isContextual(87)}applyImportPhase(t,e,i,s){super.applyImportPhase(t,e,i,s),e?t.exportKind="type"===i?"type":"value":t.importKind="type"===i||"typeof"===i?i:"value"}parseImport(t){if(this.match(133))return t.importKind="value",super.parseImport(t);let e;if(X(this.state.type)&&61===this.lookaheadCharCode())return t.importKind="value",this.tsParseImportEqualsDeclaration(t);if(this.isContextual(130)){const i=this.parseMaybeImportPhase(t,!1);if(61===this.lookaheadCharCode())return this.tsParseImportEqualsDeclaration(t,i);e=super.parseImportSpecifiersAndAfter(t,i)}else e=super.parseImport(t);return"type"===e.importKind&&e.specifiers.length>1&&"ImportDefaultSpecifier"===e.specifiers[0].type&&this.raise(We.TypeImportCannotSpecifyDefaultAndNamed,e),e}parseExport(t,e){if(this.match(83)){this.next();let e=null;return this.isContextual(130)&&this.isPotentialImportPhase(!1)?e=this.parseMaybeImportPhase(t,!1):t.importKind="value",this.tsParseImportEqualsDeclaration(t,e,!0)}if(this.eat(29)){const e=t;return e.expression=super.parseExpression(),this.semicolon(),this.sawUnambiguousESM=!0,this.finishNode(e,"TSExportAssignment")}if(this.eatContextual(93)){const e=t;return this.expectContextual(128),e.id=this.parseIdentifier(),this.semicolon(),this.finishNode(e,"TSNamespaceExportDeclaration")}return super.parseExport(t,e)}isAbstractClass(){return this.isContextual(124)&&80===this.lookahead().type}parseExportDefaultExpression(){if(this.isAbstractClass()){const t=this.startNode();return this.next(),t.abstract=!0,this.parseClass(t,!0,!0)}if(this.match(129)){const t=this.tsParseInterfaceDeclaration(this.startNode());if(t)return t}return super.parseExportDefaultExpression()}parseVarStatement(t,e,i=!1){const{isAmbientContext:s}=this.state,n=super.parseVarStatement(t,e,i||s);if(!s)return n;for(const{id:t,init:i}of n.declarations)i&&("const"!==e||t.typeAnnotation?this.raise(We.InitializerNotAllowedInAmbientContext,i):Ze(i,this.hasPlugin("estree"))||this.raise(We.ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference,i));return n}parseStatementContent(t,e){if(this.match(75)&&this.isLookaheadContextual("enum")){const t=this.startNode();return this.expect(75),this.tsParseEnumDeclaration(t,{const:!0})}if(this.isContextual(126))return this.tsParseEnumDeclaration(this.startNode());if(this.isContextual(129)){const t=this.tsParseInterfaceDeclaration(this.startNode());if(t)return t}return super.parseStatementContent(t,e)}parseAccessModifier(){return this.tsParseModifier(["public","protected","private"])}tsHasSomeModifiers(t,e){return e.some((e=>we(e)?t.accessibility===e:!!t[e]))}tsIsStartOfStaticBlocks(){return this.isContextual(106)&&123===this.lookaheadCharCode()}parseClassMember(t,e,i){const s=["declare","private","public","protected","override","abstract","readonly","static"];this.tsParseModifiers({allowedModifiers:s,disallowedModifiers:["in","out"],stopOnStartOfClassStaticBlock:!0,errorTemplate:We.InvalidModifierOnTypeParameterPositions},e);const n=()=>{this.tsIsStartOfStaticBlocks()?(this.next(),this.next(),this.tsHasSomeModifiers(e,s)&&this.raise(We.StaticBlockCannotHaveModifier,this.state.curPosition()),super.parseClassStaticBlock(t,e)):this.parseClassMemberWithIsStatic(t,e,i,!!e.static)};e.declare?this.tsInAmbientContext(n):n()}parseClassMemberWithIsStatic(t,e,i,s){const n=this.tsTryParseIndexSignature(e);if(n)return t.body.push(n),e.abstract&&this.raise(We.IndexSignatureHasAbstract,e),e.accessibility&&this.raise(We.IndexSignatureHasAccessibility,e,{modifier:e.accessibility}),e.declare&&this.raise(We.IndexSignatureHasDeclare,e),void(e.override&&this.raise(We.IndexSignatureHasOverride,e));!this.state.inAbstractClass&&e.abstract&&this.raise(We.NonAbstractClassHasAbstractMethod,e),e.override&&(i.hadSuperClass||this.raise(We.OverrideNotInSubClass,e)),super.parseClassMemberWithIsStatic(t,e,i,s)}parsePostMemberNameModifiers(t){this.eat(17)&&(t.optional=!0),t.readonly&&this.match(10)&&this.raise(We.ClassMethodHasReadonly,t),t.declare&&this.match(10)&&this.raise(We.ClassMethodHasDeclare,t)}parseExpressionStatement(t,e,i){return("Identifier"===e.type?this.tsParseExpressionStatement(t,e,i):void 0)||super.parseExpressionStatement(t,e,i)}shouldParseExportDeclaration(){return!!this.tsIsDeclarationStart()||super.shouldParseExportDeclaration()}parseConditional(t,e,i){if(!this.state.maybeInArrowParameters||!this.match(17))return super.parseConditional(t,e,i);const s=this.tryParse((()=>super.parseConditional(t,e)));return s.node?(s.error&&(this.state=s.failState),s.node):(s.error&&super.setOptionalParametersError(i,s.error),t)}parseParenItem(t,e){if(t=super.parseParenItem(t,e),this.eat(17)&&(t.optional=!0,this.resetEndLocation(t)),this.match(14)){const i=this.startNodeAt(e);return i.expression=t,i.typeAnnotation=this.tsParseTypeAnnotation(),this.finishNode(i,"TSTypeCastExpression")}return t}parseExportDeclaration(t){if(!this.state.isAmbientContext&&this.isContextual(125))return this.tsInAmbientContext((()=>this.parseExportDeclaration(t)));const e=this.state.startLoc,i=this.eatContextual(125);if(i&&(this.isContextual(125)||!this.shouldParseExportDeclaration()))throw this.raise(We.ExpectedAmbientAfterExportDeclare,this.state.startLoc);const s=X(this.state.type)&&this.tsTryParseExportDeclaration()||super.parseExportDeclaration(t);return s?(("TSInterfaceDeclaration"===s.type||"TSTypeAliasDeclaration"===s.type||i)&&(t.exportKind="type"),i&&(this.resetStartLocation(s,e),s.declare=!0),s):null}parseClassId(t,e,i,s){if((!e||i)&&this.isContextual(113))return;super.parseClassId(t,e,i,t.declare?1024:8331);const n=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);n&&(t.typeParameters=n)}parseClassPropertyAnnotation(t){t.optional||(this.eat(35)?t.definite=!0:this.eat(17)&&(t.optional=!0));const e=this.tsTryParseTypeAnnotation();e&&(t.typeAnnotation=e)}parseClassProperty(t){if(this.parseClassPropertyAnnotation(t),this.state.isAmbientContext&&(!t.readonly||t.typeAnnotation)&&this.match(29)&&this.raise(We.DeclareClassFieldHasInitializer,this.state.startLoc),t.abstract&&this.match(29)){const{key:e}=t;this.raise(We.AbstractPropertyHasInitializer,this.state.startLoc,{propertyName:"Identifier"!==e.type||t.computed?`[${this.input.slice(e.start,e.end)}]`:e.name})}return super.parseClassProperty(t)}parseClassPrivateProperty(t){return t.abstract&&this.raise(We.PrivateElementHasAbstract,t),t.accessibility&&this.raise(We.PrivateElementHasAccessibility,t,{modifier:t.accessibility}),this.parseClassPropertyAnnotation(t),super.parseClassPrivateProperty(t)}parseClassAccessorProperty(t){return this.parseClassPropertyAnnotation(t),t.optional&&this.raise(We.AccessorCannotBeOptional,t),super.parseClassAccessorProperty(t)}pushClassMethod(t,e,i,s,n,o){const a=this.tsTryParseTypeParameters(this.tsParseConstModifier);a&&n&&this.raise(We.ConstructorHasTypeParameters,a);const{declare:r=!1,kind:l}=e;!r||"get"!==l&&"set"!==l||this.raise(We.DeclareAccessor,e,{kind:l}),a&&(e.typeParameters=a),super.pushClassMethod(t,e,i,s,n,o)}pushClassPrivateMethod(t,e,i,s){const n=this.tsTryParseTypeParameters(this.tsParseConstModifier);n&&(e.typeParameters=n),super.pushClassPrivateMethod(t,e,i,s)}declareClassPrivateMethodInScope(t,e){"TSDeclareMethod"!==t.type&&("MethodDefinition"!==t.type||t.value.body)&&super.declareClassPrivateMethodInScope(t,e)}parseClassSuper(t){super.parseClassSuper(t),t.superClass&&(this.match(47)||this.match(51))&&(t.superTypeParameters=this.tsParseTypeArgumentsInExpression()),this.eatContextual(113)&&(t.implements=this.tsParseHeritageClause("implements"))}parseObjPropValue(t,e,i,s,n,o,a){const r=this.tsTryParseTypeParameters(this.tsParseConstModifier);return r&&(t.typeParameters=r),super.parseObjPropValue(t,e,i,s,n,o,a)}parseFunctionParams(t,e){const i=this.tsTryParseTypeParameters(this.tsParseConstModifier);i&&(t.typeParameters=i),super.parseFunctionParams(t,e)}parseVarId(t,e){super.parseVarId(t,e),"Identifier"===t.id.type&&!this.hasPrecedingLineBreak()&&this.eat(35)&&(t.definite=!0);const i=this.tsTryParseTypeAnnotation();i&&(t.id.typeAnnotation=i,this.resetEndLocation(t.id))}parseAsyncArrowFromCallExpression(t,e){return this.match(14)&&(t.returnType=this.tsParseTypeAnnotation()),super.parseAsyncArrowFromCallExpression(t,e)}parseMaybeAssign(t,e){var i,s,n,o,a;let r,l,h,c;if(this.hasPlugin("jsx")&&(this.match(142)||this.match(47))){if(r=this.state.clone(),l=this.tryParse((()=>super.parseMaybeAssign(t,e)),r),!l.error)return l.node;const{context:i}=this.state,s=i[i.length-1];s!==j.j_oTag&&s!==j.j_expr||i.pop()}if(!(null!=(i=l)&&i.error||this.match(47)))return super.parseMaybeAssign(t,e);r&&r!==this.state||(r=this.state.clone());const d=this.tryParse((i=>{var s,n;c=this.tsParseTypeParameters(this.tsParseConstModifier);const o=super.parseMaybeAssign(t,e);return("ArrowFunctionExpression"!==o.type||null!=(s=o.extra)&&s.parenthesized)&&i(),0!==(null==(n=c)?void 0:n.params.length)&&this.resetStartLocationFromNode(o,c),o.typeParameters=c,o}),r);if(!d.error&&!d.aborted)return c&&this.reportReservedArrowTypeParam(c),d.node;if(!l&&(Me(!this.hasPlugin("jsx")),h=this.tryParse((()=>super.parseMaybeAssign(t,e)),r),!h.error))return h.node;if(null!=(s=l)&&s.node)return this.state=l.failState,l.node;if(d.node)return this.state=d.failState,c&&this.reportReservedArrowTypeParam(c),d.node;if(null!=(n=h)&&n.node)return this.state=h.failState,h.node;throw(null==(o=l)?void 0:o.error)||d.error||(null==(a=h)?void 0:a.error)}reportReservedArrowTypeParam(t){var e;1!==t.params.length||t.params[0].constraint||null!=(e=t.extra)&&e.trailingComma||!this.getPluginOption("typescript","disallowAmbiguousJSXLike")||this.raise(We.ReservedArrowTypeParam,t)}parseMaybeUnary(t,e){return!this.hasPlugin("jsx")&&this.match(47)?this.tsParseTypeAssertion():super.parseMaybeUnary(t,e)}parseArrow(t){if(this.match(14)){const e=this.tryParse((t=>{const e=this.tsParseTypeOrTypePredicateAnnotation(14);return!this.canInsertSemicolon()&&this.match(19)||t(),e}));if(e.aborted)return;e.thrown||(e.error&&(this.state=e.failState),t.returnType=e.node)}return super.parseArrow(t)}parseAssignableListItemTypes(t,e){if(!(2&e))return t;this.eat(17)&&(t.optional=!0);const i=this.tsTryParseTypeAnnotation();return i&&(t.typeAnnotation=i),this.resetEndLocation(t),t}isAssignable(t,e){switch(t.type){case"TSTypeCastExpression":return this.isAssignable(t.expression,e);case"TSParameterProperty":return!0;default:return super.isAssignable(t,e)}}toAssignable(t,e=!1){switch(t.type){case"ParenthesizedExpression":this.toAssignableParenthesizedExpression(t,e);break;case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":e?this.expressionScope.recordArrowParameterBindingError(We.UnexpectedTypeCastInParameter,t):this.raise(We.UnexpectedTypeCastInParameter,t),this.toAssignable(t.expression,e);break;case"AssignmentExpression":e||"TSTypeCastExpression"!==t.left.type||(t.left=this.typeCastToParameter(t.left));default:super.toAssignable(t,e)}}toAssignableParenthesizedExpression(t,e){switch(t.expression.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"ParenthesizedExpression":this.toAssignable(t.expression,e);break;default:super.toAssignable(t,e)}}checkToRestConversion(t,e){switch(t.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":case"TSNonNullExpression":this.checkToRestConversion(t.expression,!1);break;default:super.checkToRestConversion(t,e)}}isValidLVal(t,e,i){return s={TSTypeCastExpression:!0,TSParameterProperty:"parameter",TSNonNullExpression:"expression",TSAsExpression:(64!==i||!e)&&["expression",!0],TSSatisfiesExpression:(64!==i||!e)&&["expression",!0],TSTypeAssertion:(64!==i||!e)&&["expression",!0]},n=t,Object.hasOwnProperty.call(s,n)&&s[n]||super.isValidLVal(t,e,i);var s,n}parseBindingAtom(){return 78===this.state.type?this.parseIdentifier(!0):super.parseBindingAtom()}parseMaybeDecoratorArguments(t){if(this.match(47)||this.match(51)){const e=this.tsParseTypeArgumentsInExpression();if(this.match(10)){const i=super.parseMaybeDecoratorArguments(t);return i.typeParameters=e,i}this.unexpected(null,10)}return super.parseMaybeDecoratorArguments(t)}checkCommaAfterRest(t){return this.state.isAmbientContext&&this.match(12)&&this.lookaheadCharCode()===t?(this.next(),!1):super.checkCommaAfterRest(t)}isClassMethod(){return this.match(47)||super.isClassMethod()}isClassProperty(){return this.match(35)||this.match(14)||super.isClassProperty()}parseMaybeDefault(t,e){const i=super.parseMaybeDefault(t,e);return"AssignmentPattern"===i.type&&i.typeAnnotation&&i.right.startthis.isAssignable(t,!0))):super.shouldParseArrow(t)}shouldParseAsyncArrow(){return this.match(14)||super.shouldParseAsyncArrow()}canHaveLeadingDecorator(){return super.canHaveLeadingDecorator()||this.isAbstractClass()}jsxParseOpeningElementAfterName(t){if(this.match(47)||this.match(51)){const e=this.tsTryParseAndCatch((()=>this.tsParseTypeArgumentsInExpression()));e&&(t.typeParameters=e)}return super.jsxParseOpeningElementAfterName(t)}getGetterSetterExpectedParamCount(t){const e=super.getGetterSetterExpectedParamCount(t),i=this.getObjectOrClassMethodParams(t)[0];return i&&this.isThisParam(i)?e+1:e}parseCatchClauseParam(){const t=super.parseCatchClauseParam(),e=this.tsTryParseTypeAnnotation();return e&&(t.typeAnnotation=e,this.resetEndLocation(t)),t}tsInAmbientContext(t){const e=this.state.isAmbientContext;this.state.isAmbientContext=!0;try{return t()}finally{this.state.isAmbientContext=e}}parseClass(t,e,i){const s=this.state.inAbstractClass;this.state.inAbstractClass=!!t.abstract;try{return super.parseClass(t,e,i)}finally{this.state.inAbstractClass=s}}tsParseAbstractDeclaration(t,e){if(this.match(80))return t.abstract=!0,this.maybeTakeDecorators(e,this.parseClass(t,!0,!1));if(this.isContextual(129)){if(!this.hasFollowingLineBreak())return t.abstract=!0,this.raise(We.NonClassMethodPropertyHasAbstractModifer,t),this.tsParseInterfaceDeclaration(t)}else this.unexpected(null,80)}parseMethod(t,e,i,s,n,o,a){const r=super.parseMethod(t,e,i,s,n,o,a);if(r.abstract&&(this.hasPlugin("estree")?r.value.body:r.body)){const{key:t}=r;this.raise(We.AbstractMethodHasImplementation,r,{methodName:"Identifier"!==t.type||r.computed?`[${this.input.slice(t.start,t.end)}]`:t.name})}return r}tsParseTypeParameterName(){return this.parseIdentifier().name}shouldParseAsAmbientContext(){return!!this.getPluginOption("typescript","dts")}parse(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.parse()}getExpression(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.getExpression()}parseExportSpecifier(t,e,i,s){return!e&&s?(this.parseTypeOnlyImportExportSpecifier(t,!1,i),this.finishNode(t,"ExportSpecifier")):(t.exportKind="value",super.parseExportSpecifier(t,e,i,s))}parseImportSpecifier(t,e,i,s,n){return!e&&s?(this.parseTypeOnlyImportExportSpecifier(t,!0,i),this.finishNode(t,"ImportSpecifier")):(t.importKind="value",super.parseImportSpecifier(t,e,i,s,i?4098:4096))}parseTypeOnlyImportExportSpecifier(t,e,i){const s=e?"imported":"local",n=e?"local":"exported";let o,a=t[s],r=!1,l=!0;const h=a.loc.start;if(this.isContextual(93)){const t=this.parseIdentifier();if(this.isContextual(93)){const i=this.parseIdentifier();E(this.state.type)?(r=!0,a=t,o=e?this.parseIdentifier():this.parseModuleExportName(),l=!1):(o=i,l=!1)}else E(this.state.type)?(l=!1,o=e?this.parseIdentifier():this.parseModuleExportName()):(r=!0,a=t)}else E(this.state.type)&&(r=!0,e?(a=this.parseIdentifier(!0),this.isContextual(93)||this.checkReservedWord(a.name,a.loc.start,!0,!0)):a=this.parseModuleExportName());r&&i&&this.raise(e?We.TypeModifierIsUsedInTypeImports:We.TypeModifierIsUsedInTypeExports,h),t[s]=a,t[n]=o,t[e?"importKind":"exportKind"]=r?"type":"value",l&&this.eatContextual(93)&&(t[n]=e?this.parseIdentifier():this.parseModuleExportName()),t[n]||(t[n]=ne(t[s])),e&&this.checkIdentifier(t[n],r?4098:4096)}},v8intrinsic:t=>class extends t{parseV8Intrinsic(){if(this.match(54)){const t=this.state.startLoc,e=this.startNode();if(this.next(),X(this.state.type)){const t=this.parseIdentifierName(),i=this.createIdentifier(e,t);if(i.type="V8IntrinsicIdentifier",this.match(10))return i}this.unexpected(t)}}parseExprAtom(t){return this.parseV8Intrinsic()||super.parseExprAtom(t)}},placeholders:t=>class extends t{parsePlaceholder(t){if(this.match(144)){const e=this.startNode();return this.next(),this.assertNoSpace(),e.name=super.parseIdentifier(!0),this.assertNoSpace(),this.expect(144),this.finishPlaceholder(e,t)}}finishPlaceholder(t,e){const i=!(!t.expectedNode||"Placeholder"!==t.type);return t.expectedNode=e,i?t:this.finishNode(t,"Placeholder")}getTokenFromCode(t){37===t&&37===this.input.charCodeAt(this.state.pos+1)?this.finishOp(144,2):super.getTokenFromCode(t)}parseExprAtom(t){return this.parsePlaceholder("Expression")||super.parseExprAtom(t)}parseIdentifier(t){return this.parsePlaceholder("Identifier")||super.parseIdentifier(t)}checkReservedWord(t,e,i,s){void 0!==t&&super.checkReservedWord(t,e,i,s)}parseBindingAtom(){return this.parsePlaceholder("Pattern")||super.parseBindingAtom()}isValidLVal(t,e,i){return"Placeholder"===t||super.isValidLVal(t,e,i)}toAssignable(t,e){t&&"Placeholder"===t.type&&"Expression"===t.expectedNode?t.expectedNode="Pattern":super.toAssignable(t,e)}chStartsBindingIdentifier(t,e){return!!super.chStartsBindingIdentifier(t,e)||144===this.lookahead().type}verifyBreakContinue(t,e){t.label&&"Placeholder"===t.label.type||super.verifyBreakContinue(t,e)}parseExpressionStatement(t,e){var i;if("Placeholder"!==e.type||null!=(i=e.extra)&&i.parenthesized)return super.parseExpressionStatement(t,e);if(this.match(14)){const i=t;return i.label=this.finishPlaceholder(e,"Identifier"),this.next(),i.body=super.parseStatementOrSloppyAnnexBFunctionDeclaration(),this.finishNode(i,"LabeledStatement")}return this.semicolon(),t.name=e.name,this.finishPlaceholder(t,"Statement")}parseBlock(t,e,i){return this.parsePlaceholder("BlockStatement")||super.parseBlock(t,e,i)}parseFunctionId(t){return this.parsePlaceholder("Identifier")||super.parseFunctionId(t)}parseClass(t,e,i){const s=e?"ClassDeclaration":"ClassExpression";this.next();const n=this.state.strict,o=this.parsePlaceholder("Identifier");if(o){if(!(this.match(81)||this.match(144)||this.match(5))){if(i||!e)return t.id=null,t.body=this.finishPlaceholder(o,"ClassBody"),this.finishNode(t,s);throw this.raise(fe.ClassNameIsRequired,this.state.startLoc)}t.id=o}else this.parseClassId(t,e,i);return super.parseClassSuper(t),t.body=this.parsePlaceholder("ClassBody")||super.parseClassBody(!!t.superClass,n),this.finishNode(t,s)}parseExport(t,e){const i=this.parsePlaceholder("Identifier");if(!i)return super.parseExport(t,e);if(!this.isContextual(98)&&!this.match(12))return t.specifiers=[],t.source=null,t.declaration=this.finishPlaceholder(i,"Declaration"),this.finishNode(t,"ExportNamedDeclaration");this.expectPlugin("exportDefaultFrom");const s=this.startNode();return s.exported=i,t.specifiers=[this.finishNode(s,"ExportDefaultSpecifier")],super.parseExport(t,e)}isExportDefaultSpecifier(){if(this.match(65)){const t=this.nextTokenStart();if(this.isUnparsedContextual(t,"from")&&this.input.startsWith(_(144),this.nextTokenStartSince(t+4)))return!0}return super.isExportDefaultSpecifier()}maybeParseExportDefaultSpecifier(t,e){var i;return!(null==(i=t.specifiers)||!i.length)||super.maybeParseExportDefaultSpecifier(t,e)}checkExport(t){const{specifiers:e}=t;null!=e&&e.length&&(t.specifiers=e.filter((t=>"Placeholder"===t.exported.type))),super.checkExport(t),t.specifiers=e}parseImport(t){const e=this.parsePlaceholder("Identifier");if(!e)return super.parseImport(t);if(t.specifiers=[],!this.isContextual(98)&&!this.match(12))return t.source=this.finishPlaceholder(e,"StringLiteral"),this.semicolon(),this.finishNode(t,"ImportDeclaration");const i=this.startNodeAtNode(e);return i.local=e,t.specifiers.push(this.finishNode(i,"ImportDefaultSpecifier")),this.eat(12)&&(this.maybeParseStarImportSpecifier(t)||this.parseNamedImportSpecifiers(t)),this.expectContextual(98),t.source=this.parseImportSource(),this.semicolon(),this.finishNode(t,"ImportDeclaration")}parseImportSource(){return this.parsePlaceholder("StringLiteral")||super.parseImportSource()}assertNoSpace(){this.state.start>this.state.lastTokEndLoc.index&&this.raise(fe.UnexpectedSpace,this.state.lastTokEndLoc)}}},Ae=Object.keys(ge),Se={sourceType:"script",sourceFilename:void 0,startColumn:0,startLine:1,allowAwaitOutsideFunction:!1,allowReturnOutsideFunction:!1,allowNewTargetOutsideFunction:!1,allowImportExportEverywhere:!1,allowSuperOutsideMethod:!1,allowUndeclaredExports:!1,plugins:[],strictMode:null,ranges:!1,tokens:!1,createImportExpressions:!1,createParenthesizedExpressions:!1,errorRecovery:!1,attachComment:!0,annexB:!0};class ze extends Le{checkProto(t,e,i,s){if("SpreadElement"===t.type||this.isObjectMethod(t)||t.computed||t.shorthand)return;const n=t.key;if("__proto__"===("Identifier"===n.type?n.name:n.value)){if(e)return void this.raise(L.RecordNoProto,n);i.used&&(s?null===s.doubleProtoLoc&&(s.doubleProtoLoc=n.loc.start):this.raise(L.DuplicateProto,n)),i.used=!0}}shouldExitDescending(t,e){return"ArrowFunctionExpression"===t.type&&t.start===e}getExpression(){this.enterInitialScopes(),this.nextToken();const t=this.parseExpression();return this.match(139)||this.unexpected(),this.finalizeRemainingComments(),t.comments=this.comments,t.errors=this.state.errors,this.options.tokens&&(t.tokens=this.tokens),t}parseExpression(t,e){return t?this.disallowInAnd((()=>this.parseExpressionBase(e))):this.allowInAnd((()=>this.parseExpressionBase(e)))}parseExpressionBase(t){const e=this.state.startLoc,i=this.parseMaybeAssign(t);if(this.match(12)){const s=this.startNodeAt(e);for(s.expressions=[i];this.eat(12);)s.expressions.push(this.parseMaybeAssign(t));return this.toReferencedList(s.expressions),this.finishNode(s,"SequenceExpression")}return i}parseMaybeAssignDisallowIn(t,e){return this.disallowInAnd((()=>this.parseMaybeAssign(t,e)))}parseMaybeAssignAllowIn(t,e){return this.allowInAnd((()=>this.parseMaybeAssign(t,e)))}setOptionalParametersError(t,e){var i;t.optionalParametersLoc=null!=(i=null==e?void 0:e.loc)?i:this.state.startLoc}parseMaybeAssign(t,e){const i=this.state.startLoc;if(this.isContextual(108)&&this.prodParam.hasYield){let t=this.parseYield();return e&&(t=e.call(this,t,i)),t}let s;t?s=!1:(t=new ee,s=!0);const{type:n}=this.state;(10===n||X(n))&&(this.state.potentialArrowAt=this.state.start);let o=this.parseMaybeConditional(t);if(e&&(o=e.call(this,o,i)),(a=this.state.type)>=29&&a<=33){const e=this.startNodeAt(i),s=this.state.value;if(e.operator=s,this.match(29)){this.toAssignable(o,!0),e.left=o;const s=i.index;null!=t.doubleProtoLoc&&t.doubleProtoLoc.index>=s&&(t.doubleProtoLoc=null),null!=t.shorthandAssignLoc&&t.shorthandAssignLoc.index>=s&&(t.shorthandAssignLoc=null),null!=t.privateKeyLoc&&t.privateKeyLoc.index>=s&&(this.checkDestructuringPrivate(t),t.privateKeyLoc=null)}else e.left=o;return this.next(),e.right=this.parseMaybeAssign(),this.checkLVal(o,{in:this.finishNode(e,"AssignmentExpression")}),e}var a;return s&&this.checkExpressionErrors(t,!0),o}parseMaybeConditional(t){const e=this.state.startLoc,i=this.state.potentialArrowAt,s=this.parseExprOps(t);return this.shouldExitDescending(s,i)?s:this.parseConditional(s,e,t)}parseConditional(t,e,i){if(this.eat(17)){const i=this.startNodeAt(e);return i.test=t,i.consequent=this.parseMaybeAssignAllowIn(),this.expect(14),i.alternate=this.parseMaybeAssign(),this.finishNode(i,"ConditionalExpression")}return t}parseMaybeUnaryOrPrivate(t){return this.match(138)?this.parsePrivateName():this.parseMaybeUnary(t)}parseExprOps(t){const e=this.state.startLoc,i=this.state.potentialArrowAt,s=this.parseMaybeUnaryOrPrivate(t);return this.shouldExitDescending(s,i)?s:this.parseExprOp(s,e,-1)}parseExprOp(t,e,i){if(this.isPrivateName(t)){const e=this.getPrivateNameSV(t);(i>=Q(58)||!this.prodParam.hasIn||!this.match(58))&&this.raise(L.PrivateInExpectedIn,t,{identifierName:e}),this.classScope.usePrivateName(e,t.loc.start)}const s=this.state.type;if((n=s)>=39&&n<=59&&(this.prodParam.hasIn||!this.match(58))){let n=Q(s);if(n>i){if(39===s){if(this.expectPlugin("pipelineOperator"),this.state.inFSharpPipelineDirectBody)return t;this.checkPipelineAtInfixOperator(t,e)}const o=this.startNodeAt(e);o.left=t,o.operator=this.state.value;const a=41===s||42===s,r=40===s;if(r&&(n=Q(42)),this.next(),39===s&&this.hasPlugin(["pipelineOperator",{proposal:"minimal"}])&&96===this.state.type&&this.prodParam.hasAwait)throw this.raise(L.UnexpectedAwaitAfterPipelineBody,this.state.startLoc);o.right=this.parseExprOpRightExpr(s,n);const l=this.finishNode(o,a||r?"LogicalExpression":"BinaryExpression"),h=this.state.type;if(r&&(41===h||42===h)||a&&40===h)throw this.raise(L.MixingCoalesceWithLogical,this.state.startLoc);return this.parseExprOp(l,e,i)}}var n;return t}parseExprOpRightExpr(t,e){const i=this.state.startLoc;if(39===t)switch(this.getPluginOption("pipelineOperator","proposal")){case"hack":return this.withTopicBindingContext((()=>this.parseHackPipeBody()));case"smart":return this.withTopicBindingContext((()=>{if(this.prodParam.hasYield&&this.isContextual(108))throw this.raise(L.PipeBodyIsTighter,this.state.startLoc);return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(t,e),i)}));case"fsharp":return this.withSoloAwaitPermittingContext((()=>this.parseFSharpPipelineBody(e)))}return this.parseExprOpBaseRightExpr(t,e)}parseExprOpBaseRightExpr(t,e){const i=this.state.startLoc;return this.parseExprOp(this.parseMaybeUnaryOrPrivate(),i,57===t?e-1:e)}parseHackPipeBody(){var t;const{startLoc:e}=this.state,i=this.parseMaybeAssign();return!d.has(i.type)||null!=(t=i.extra)&&t.parenthesized||this.raise(L.PipeUnparenthesizedBody,e,{type:i.type}),this.topicReferenceWasUsedInCurrentContext()||this.raise(L.PipeTopicUnused,e),i}checkExponentialAfterUnary(t){this.match(57)&&this.raise(L.UnexpectedTokenUnaryExponentiation,t.argument)}parseMaybeUnary(t,e){const i=this.state.startLoc,s=this.isContextual(96);if(s&&this.isAwaitAllowed()){this.next();const t=this.parseAwait(i);return e||this.checkExponentialAfterUnary(t),t}const n=this.match(34),o=this.startNode();if(a=this.state.type,k[a]){o.operator=this.state.value,o.prefix=!0,this.match(72)&&this.expectPlugin("throwExpressions");const i=this.match(89);if(this.next(),o.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(t,!0),this.state.strict&&i){const t=o.argument;"Identifier"===t.type?this.raise(L.StrictDelete,o):this.hasPropertyAsPrivateName(t)&&this.raise(L.DeletePrivateField,o)}if(!n)return e||this.checkExponentialAfterUnary(o),this.finishNode(o,"UnaryExpression")}var a;const r=this.parseUpdate(o,n,t);if(s){const{type:t}=this.state;if((this.hasPlugin("v8intrinsic")?U(t):U(t)&&!this.match(54))&&!this.isAmbiguousAwait())return this.raiseOverwrite(L.AwaitNotInAsyncContext,i),this.parseAwait(i)}return r}parseUpdate(t,e,i){if(e){const e=t;return this.checkLVal(e.argument,{in:this.finishNode(e,"UpdateExpression")}),t}const s=this.state.startLoc;let n=this.parseExprSubscripts(i);if(this.checkExpressionErrors(i,!1))return n;for(;34===this.state.type&&!this.canInsertSemicolon();){const t=this.startNodeAt(s);t.operator=this.state.value,t.prefix=!1,t.argument=n,this.next(),this.checkLVal(n,{in:n=this.finishNode(t,"UpdateExpression")})}return n}parseExprSubscripts(t){const e=this.state.startLoc,i=this.state.potentialArrowAt,s=this.parseExprAtom(t);return this.shouldExitDescending(s,i)?s:this.parseSubscripts(s,e)}parseSubscripts(t,e,i){const s={optionalChainMember:!1,maybeAsyncArrow:this.atPossibleAsyncArrow(t),stop:!1};do{t=this.parseSubscript(t,e,i,s),s.maybeAsyncArrow=!1}while(!s.stop);return t}parseSubscript(t,e,i,s){const{type:n}=this.state;if(!i&&15===n)return this.parseBind(t,e,i,s);if(q(n))return this.parseTaggedTemplateExpression(t,e,s);let o=!1;if(18===n){if(i&&(this.raise(L.OptionalChainingNoNew,this.state.startLoc),40===this.lookaheadCharCode()))return s.stop=!0,t;s.optionalChainMember=o=!0,this.next()}if(!i&&this.match(10))return this.parseCoverCallAndAsyncArrowHead(t,e,s,o);{const i=this.eat(0);return i||o||this.eat(16)?this.parseMember(t,e,s,i,o):(s.stop=!0,t)}}parseMember(t,e,i,s,n){const o=this.startNodeAt(e);return o.object=t,o.computed=s,s?(o.property=this.parseExpression(),this.expect(3)):this.match(138)?("Super"===t.type&&this.raise(L.SuperPrivateField,e),this.classScope.usePrivateName(this.state.value,this.state.startLoc),o.property=this.parsePrivateName()):o.property=this.parseIdentifier(!0),i.optionalChainMember?(o.optional=n,this.finishNode(o,"OptionalMemberExpression")):this.finishNode(o,"MemberExpression")}parseBind(t,e,i,s){const n=this.startNodeAt(e);return n.object=t,this.next(),n.callee=this.parseNoCallExpr(),s.stop=!0,this.parseSubscripts(this.finishNode(n,"BindExpression"),e,i)}parseCoverCallAndAsyncArrowHead(t,e,i,s){const n=this.state.maybeInArrowParameters;let o=null;this.state.maybeInArrowParameters=!0,this.next();const a=this.startNodeAt(e);a.callee=t;const{maybeAsyncArrow:r,optionalChainMember:l}=i;r&&(this.expressionScope.enter(new _t(2)),o=new ee),l&&(a.optional=s),a.arguments=s?this.parseCallExpressionArguments(11):this.parseCallExpressionArguments(11,"Import"===t.type,"Super"!==t.type,a,o);let h=this.finishCallExpression(a,l);return r&&this.shouldParseAsyncArrow()&&!s?(i.stop=!0,this.checkDestructuringPrivate(o),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),h=this.parseAsyncArrowFromCallExpression(this.startNodeAt(e),h)):(r&&(this.checkExpressionErrors(o,!0),this.expressionScope.exit()),this.toReferencedArguments(h)),this.state.maybeInArrowParameters=n,h}toReferencedArguments(t,e){this.toReferencedListDeep(t.arguments,e)}parseTaggedTemplateExpression(t,e,i){const s=this.startNodeAt(e);return s.tag=t,s.quasi=this.parseTemplate(!0),i.optionalChainMember&&this.raise(L.OptionalChainingNoTemplate,e),this.finishNode(s,"TaggedTemplateExpression")}atPossibleAsyncArrow(t){return"Identifier"===t.type&&"async"===t.name&&this.state.lastTokEndLoc.index===t.end&&!this.canInsertSemicolon()&&t.end-t.start==5&&t.start===this.state.potentialArrowAt}expectImportAttributesPlugin(){this.hasPlugin("importAssertions")||this.expectPlugin("importAttributes")}finishCallExpression(t,e){if("Import"===t.callee.type)if(2===t.arguments.length&&(this.hasPlugin("moduleAttributes")||this.expectImportAttributesPlugin()),0===t.arguments.length||t.arguments.length>2)this.raise(L.ImportCallArity,t,{maxArgumentCount:this.hasPlugin("importAttributes")||this.hasPlugin("importAssertions")||this.hasPlugin("moduleAttributes")?2:1});else for(const e of t.arguments)"SpreadElement"===e.type&&this.raise(L.ImportCallSpreadArgument,e);return this.finishNode(t,e?"OptionalCallExpression":"CallExpression")}parseCallExpressionArguments(t,e,i,s,n){const o=[];let a=!0;const r=this.state.inFSharpPipelineDirectBody;for(this.state.inFSharpPipelineDirectBody=!1;!this.eat(t);){if(a)a=!1;else if(this.expect(12),this.match(t)){!e||this.hasPlugin("importAttributes")||this.hasPlugin("importAssertions")||this.hasPlugin("moduleAttributes")||this.raise(L.ImportCallArgumentTrailingComma,this.state.lastTokStartLoc),s&&this.addTrailingCommaExtraToNode(s),this.next();break}o.push(this.parseExprListItem(!1,n,i))}return this.state.inFSharpPipelineDirectBody=r,o}shouldParseAsyncArrow(){return this.match(19)&&!this.canInsertSemicolon()}parseAsyncArrowFromCallExpression(t,e){var i;return this.resetPreviousNodeTrailingComments(e),this.expect(19),this.parseArrowExpression(t,e.arguments,!0,null==(i=e.extra)?void 0:i.trailingCommaLoc),e.innerComments&&vt(t,e.innerComments),e.callee.trailingComments&&vt(t,e.callee.trailingComments),t}parseNoCallExpr(){const t=this.state.startLoc;return this.parseSubscripts(this.parseExprAtom(),t,!0)}parseExprAtom(t){let e,i=null;const{type:s}=this.state;switch(s){case 79:return this.parseSuper();case 83:return e=this.startNode(),this.next(),this.match(16)?this.parseImportMetaProperty(e):this.match(10)?this.options.createImportExpressions?this.parseImportCall(e):this.finishNode(e,"Import"):(this.raise(L.UnsupportedImport,this.state.lastTokStartLoc),this.finishNode(e,"Import"));case 78:return e=this.startNode(),this.next(),this.finishNode(e,"ThisExpression");case 90:return this.parseDo(this.startNode(),!1);case 56:case 31:return this.readRegexp(),this.parseRegExpLiteral(this.state.value);case 134:return this.parseNumericLiteral(this.state.value);case 135:return this.parseBigIntLiteral(this.state.value);case 136:return this.parseDecimalLiteral(this.state.value);case 133:return this.parseStringLiteral(this.state.value);case 84:return this.parseNullLiteral();case 85:return this.parseBooleanLiteral(!0);case 86:return this.parseBooleanLiteral(!1);case 10:{const t=this.state.potentialArrowAt===this.state.start;return this.parseParenAndDistinguishExpression(t)}case 2:case 1:return this.parseArrayLike(2===this.state.type?4:3,!1,!0);case 0:return this.parseArrayLike(3,!0,!1,t);case 6:case 7:return this.parseObjectLike(6===this.state.type?9:8,!1,!0);case 5:return this.parseObjectLike(8,!1,!1,t);case 68:return this.parseFunctionOrFunctionSent();case 26:i=this.parseDecorators();case 80:return this.parseClass(this.maybeTakeDecorators(i,this.startNode()),!1);case 77:return this.parseNewOrNewTarget();case 25:case 24:return this.parseTemplate(!1);case 15:{e=this.startNode(),this.next(),e.object=null;const t=e.callee=this.parseNoCallExpr();if("MemberExpression"===t.type)return this.finishNode(e,"BindExpression");throw this.raise(L.UnsupportedBind,t)}case 138:return this.raise(L.PrivateInExpectedIn,this.state.startLoc,{identifierName:this.state.value}),this.parsePrivateName();case 33:return this.parseTopicReferenceThenEqualsSign(54,"%");case 32:return this.parseTopicReferenceThenEqualsSign(44,"^");case 37:case 38:return this.parseTopicReference("hack");case 44:case 54:case 27:{const t=this.getPluginOption("pipelineOperator","proposal");if(t)return this.parseTopicReference(t);this.unexpected();break}case 47:{const t=this.input.codePointAt(this.nextTokenStart());at(t)||62===t?this.expectOnePlugin(["jsx","flow","typescript"]):this.unexpected();break}default:if(X(s)){if(this.isContextual(127)&&123===this.lookaheadInLineCharCode())return this.parseModuleExpression();const t=this.state.potentialArrowAt===this.state.start,e=this.state.containsEsc,i=this.parseIdentifier();if(!e&&"async"===i.name&&!this.canInsertSemicolon()){const{type:t}=this.state;if(68===t)return this.resetPreviousNodeTrailingComments(i),this.next(),this.parseAsyncFunctionExpression(this.startNodeAtNode(i));if(X(t))return 61===this.lookaheadCharCode()?this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(i)):i;if(90===t)return this.resetPreviousNodeTrailingComments(i),this.parseDo(this.startNodeAtNode(i),!0)}return t&&this.match(19)&&!this.canInsertSemicolon()?(this.next(),this.parseArrowExpression(this.startNodeAtNode(i),[i],!1)):i}this.unexpected()}}parseTopicReferenceThenEqualsSign(t,e){const i=this.getPluginOption("pipelineOperator","proposal");if(i)return this.state.type=t,this.state.value=e,this.state.pos--,this.state.end--,this.state.endLoc=o(this.state.endLoc,-1),this.parseTopicReference(i);this.unexpected()}parseTopicReference(t){const e=this.startNode(),i=this.state.startLoc,s=this.state.type;return this.next(),this.finishTopicReference(e,i,t,s)}finishTopicReference(t,e,i,s){if(this.testTopicReferenceConfiguration(i,e,s)){const s="smart"===i?"PipelinePrimaryTopicReference":"TopicReference";return this.topicReferenceIsAllowedInCurrentContext()||this.raise("smart"===i?L.PrimaryTopicNotAllowed:L.PipeTopicUnbound,e),this.registerTopicReference(),this.finishNode(t,s)}throw this.raise(L.PipeTopicUnconfiguredToken,e,{token:_(s)})}testTopicReferenceConfiguration(t,e,i){switch(t){case"hack":return this.hasPlugin(["pipelineOperator",{topicToken:_(i)}]);case"smart":return 27===i;default:throw this.raise(L.PipeTopicRequiresHackPipes,e)}}parseAsyncArrowUnaryFunction(t){this.prodParam.enter(Kt(!0,this.prodParam.hasYield));const e=[this.parseIdentifier()];return this.prodParam.exit(),this.hasPrecedingLineBreak()&&this.raise(L.LineTerminatorBeforeArrow,this.state.curPosition()),this.expect(19),this.parseArrowExpression(t,e,!0)}parseDo(t,e){this.expectPlugin("doExpressions"),e&&this.expectPlugin("asyncDoExpressions"),t.async=e,this.next();const i=this.state.labels;return this.state.labels=[],e?(this.prodParam.enter(2),t.body=this.parseBlock(),this.prodParam.exit()):t.body=this.parseBlock(),this.state.labels=i,this.finishNode(t,"DoExpression")}parseSuper(){const t=this.startNode();return this.next(),!this.match(10)||this.scope.allowDirectSuper||this.options.allowSuperOutsideMethod?this.scope.allowSuper||this.options.allowSuperOutsideMethod||this.raise(L.UnexpectedSuper,t):this.raise(L.SuperNotAllowed,t),this.match(10)||this.match(0)||this.match(16)||this.raise(L.UnsupportedSuper,t),this.finishNode(t,"Super")}parsePrivateName(){const t=this.startNode(),e=this.startNodeAt(o(this.state.startLoc,1)),i=this.state.value;return this.next(),t.id=this.createIdentifier(e,i),this.finishNode(t,"PrivateName")}parseFunctionOrFunctionSent(){const t=this.startNode();if(this.next(),this.prodParam.hasYield&&this.match(16)){const e=this.createIdentifier(this.startNodeAtNode(t),"function");return this.next(),this.match(103)?this.expectPlugin("functionSent"):this.hasPlugin("functionSent")||this.unexpected(),this.parseMetaProperty(t,e,"sent")}return this.parseFunction(t)}parseMetaProperty(t,e,i){t.meta=e;const s=this.state.containsEsc;return t.property=this.parseIdentifier(!0),(t.property.name!==i||s)&&this.raise(L.UnsupportedMetaProperty,t.property,{target:e.name,onlyValidPropertyName:i}),this.finishNode(t,"MetaProperty")}parseImportMetaProperty(t){const e=this.createIdentifier(this.startNodeAtNode(t),"import");if(this.next(),this.isContextual(101))this.inModule||this.raise(L.ImportMetaOutsideModule,e),this.sawUnambiguousESM=!0;else if(this.isContextual(105)||this.isContextual(97)){const e=this.isContextual(105);if(e||this.unexpected(),this.expectPlugin(e?"sourcePhaseImports":"deferredImportEvaluation"),!this.options.createImportExpressions)throw this.raise(L.DynamicImportPhaseRequiresImportExpressions,this.state.startLoc,{phase:this.state.value});return this.next(),t.phase=e?"source":"defer",this.parseImportCall(t)}return this.parseMetaProperty(t,e,"meta")}parseLiteralAtNode(t,e,i){return this.addExtra(i,"rawValue",t),this.addExtra(i,"raw",this.input.slice(i.start,this.state.end)),i.value=t,this.next(),this.finishNode(i,e)}parseLiteral(t,e){const i=this.startNode();return this.parseLiteralAtNode(t,e,i)}parseStringLiteral(t){return this.parseLiteral(t,"StringLiteral")}parseNumericLiteral(t){return this.parseLiteral(t,"NumericLiteral")}parseBigIntLiteral(t){return this.parseLiteral(t,"BigIntLiteral")}parseDecimalLiteral(t){return this.parseLiteral(t,"DecimalLiteral")}parseRegExpLiteral(t){const e=this.parseLiteral(t.value,"RegExpLiteral");return e.pattern=t.pattern,e.flags=t.flags,e}parseBooleanLiteral(t){const e=this.startNode();return e.value=t,this.next(),this.finishNode(e,"BooleanLiteral")}parseNullLiteral(){const t=this.startNode();return this.next(),this.finishNode(t,"NullLiteral")}parseParenAndDistinguishExpression(t){const e=this.state.startLoc;let i;this.next(),this.expressionScope.enter(new _t(1));const s=this.state.maybeInArrowParameters,n=this.state.inFSharpPipelineDirectBody;this.state.maybeInArrowParameters=!0,this.state.inFSharpPipelineDirectBody=!1;const o=this.state.startLoc,a=[],r=new ee;let l,h,c=!0;for(;!this.match(11);){if(c)c=!1;else if(this.expect(12,null===r.optionalParametersLoc?null:r.optionalParametersLoc),this.match(11)){h=this.state.startLoc;break}if(this.match(21)){const t=this.state.startLoc;if(l=this.state.startLoc,a.push(this.parseParenItem(this.parseRestBinding(),t)),!this.checkCommaAfterRest(41))break}else a.push(this.parseMaybeAssignAllowIn(r,this.parseParenItem))}const d=this.state.lastTokEndLoc;this.expect(11),this.state.maybeInArrowParameters=s,this.state.inFSharpPipelineDirectBody=n;let I=this.startNodeAt(e);return t&&this.shouldParseArrow(a)&&(I=this.parseArrow(I))?(this.checkDestructuringPrivate(r),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),this.parseArrowExpression(I,a,!1),I):(this.expressionScope.exit(),a.length||this.unexpected(this.state.lastTokStartLoc),h&&this.unexpected(h),l&&this.unexpected(l),this.checkExpressionErrors(r,!0),this.toReferencedListDeep(a,!0),a.length>1?(i=this.startNodeAt(o),i.expressions=a,this.finishNode(i,"SequenceExpression"),this.resetEndLocation(i,d)):i=a[0],this.wrapParenthesis(e,i))}wrapParenthesis(t,e){if(!this.options.createParenthesizedExpressions)return this.addExtra(e,"parenthesized",!0),this.addExtra(e,"parenStart",t.index),this.takeSurroundingComments(e,t.index,this.state.lastTokEndLoc.index),e;const i=this.startNodeAt(t);return i.expression=e,this.finishNode(i,"ParenthesizedExpression")}shouldParseArrow(t){return!this.canInsertSemicolon()}parseArrow(t){if(this.eat(19))return t}parseParenItem(t,e){return t}parseNewOrNewTarget(){const t=this.startNode();if(this.next(),this.match(16)){const e=this.createIdentifier(this.startNodeAtNode(t),"new");this.next();const i=this.parseMetaProperty(t,e,"target");return this.scope.inNonArrowFunction||this.scope.inClass||this.options.allowNewTargetOutsideFunction||this.raise(L.UnexpectedNewTarget,i),i}return this.parseNew(t)}parseNew(t){if(this.parseNewCallee(t),this.eat(10)){const e=this.parseExprList(11);this.toReferencedList(e),t.arguments=e}else t.arguments=[];return this.finishNode(t,"NewExpression")}parseNewCallee(t){const e=this.match(83),i=this.parseNoCallExpr();t.callee=i,!e||"Import"!==i.type&&"ImportExpression"!==i.type||this.raise(L.ImportCallNotNewExpression,i)}parseTemplateElement(t){const{start:e,startLoc:i,end:s,value:n}=this.state,a=e+1,r=this.startNodeAt(o(i,1));null===n&&(t||this.raise(L.InvalidEscapeSequenceTemplate,o(this.state.firstInvalidTemplateEscapePos,1)));const l=this.match(24),h=l?-1:-2,c=s+h;r.value={raw:this.input.slice(a,c).replace(/\r\n?/g,"\n"),cooked:null===n?null:n.slice(1,h)},r.tail=l,this.next();const d=this.finishNode(r,"TemplateElement");return this.resetEndLocation(d,o(this.state.lastTokEndLoc,h)),d}parseTemplate(t){const e=this.startNode();e.expressions=[];let i=this.parseTemplateElement(t);for(e.quasis=[i];!i.tail;)e.expressions.push(this.parseTemplateSubstitution()),this.readTemplateContinuation(),e.quasis.push(i=this.parseTemplateElement(t));return this.finishNode(e,"TemplateLiteral")}parseTemplateSubstitution(){return this.parseExpression()}parseObjectLike(t,e,i,s){i&&this.expectPlugin("recordAndTuple");const n=this.state.inFSharpPipelineDirectBody;this.state.inFSharpPipelineDirectBody=!1;const o=Object.create(null);let a=!0;const r=this.startNode();for(r.properties=[],this.next();!this.match(t);){if(a)a=!1;else if(this.expect(12),this.match(t)){this.addTrailingCommaExtraToNode(r);break}let n;e?n=this.parseBindingProperty():(n=this.parsePropertyDefinition(s),this.checkProto(n,i,o,s)),i&&!this.isObjectProperty(n)&&"SpreadElement"!==n.type&&this.raise(L.InvalidRecordProperty,n),n.shorthand&&this.addExtra(n,"shorthand",!0),r.properties.push(n)}this.next(),this.state.inFSharpPipelineDirectBody=n;let l="ObjectExpression";return e?l="ObjectPattern":i&&(l="RecordExpression"),this.finishNode(r,l)}addTrailingCommaExtraToNode(t){this.addExtra(t,"trailingComma",this.state.lastTokStartLoc.index),this.addExtra(t,"trailingCommaLoc",this.state.lastTokStartLoc,!1)}maybeAsyncOrAccessorProp(t){return!t.computed&&"Identifier"===t.key.type&&(this.isLiteralPropertyName()||this.match(0)||this.match(55))}parsePropertyDefinition(t){let e=[];if(this.match(26))for(this.hasPlugin("decorators")&&this.raise(L.UnsupportedPropertyDecorator,this.state.startLoc);this.match(26);)e.push(this.parseDecorator());const i=this.startNode();let s,n=!1,o=!1;if(this.match(21))return e.length&&this.unexpected(),this.parseSpread();e.length&&(i.decorators=e,e=[]),i.method=!1,t&&(s=this.state.startLoc);let a=this.eat(55);this.parsePropertyNamePrefixOperator(i);const r=this.state.containsEsc,l=this.parsePropertyName(i,t);if(!a&&!r&&this.maybeAsyncOrAccessorProp(i)){const t=l.name;"async"!==t||this.hasPrecedingLineBreak()||(n=!0,this.resetPreviousNodeTrailingComments(l),a=this.eat(55),this.parsePropertyName(i)),"get"!==t&&"set"!==t||(o=!0,this.resetPreviousNodeTrailingComments(l),i.kind=t,this.match(55)&&(a=!0,this.raise(L.AccessorIsGenerator,this.state.curPosition(),{kind:t}),this.next()),this.parsePropertyName(i))}return this.parseObjPropValue(i,s,a,n,!1,o,t)}getGetterSetterExpectedParamCount(t){return"get"===t.kind?0:1}getObjectOrClassMethodParams(t){return t.params}checkGetterSetterParams(t){var e;const i=this.getGetterSetterExpectedParamCount(t),s=this.getObjectOrClassMethodParams(t);s.length!==i&&this.raise("get"===t.kind?L.BadGetterArity:L.BadSetterArity,t),"set"===t.kind&&"RestElement"===(null==(e=s[s.length-1])?void 0:e.type)&&this.raise(L.BadSetterRestParameter,t)}parseObjectMethod(t,e,i,s,n){if(n){const i=this.parseMethod(t,e,!1,!1,!1,"ObjectMethod");return this.checkGetterSetterParams(i),i}if(i||e||this.match(10))return s&&this.unexpected(),t.kind="method",t.method=!0,this.parseMethod(t,e,i,!1,!1,"ObjectMethod")}parseObjectProperty(t,e,i,s){if(t.shorthand=!1,this.eat(14))return t.value=i?this.parseMaybeDefault(this.state.startLoc):this.parseMaybeAssignAllowIn(s),this.finishNode(t,"ObjectProperty");if(!t.computed&&"Identifier"===t.key.type){if(this.checkReservedWord(t.key.name,t.key.loc.start,!0,!1),i)t.value=this.parseMaybeDefault(e,ne(t.key));else if(this.match(29)){const i=this.state.startLoc;null!=s?null===s.shorthandAssignLoc&&(s.shorthandAssignLoc=i):this.raise(L.InvalidCoverInitializedName,i),t.value=this.parseMaybeDefault(e,ne(t.key))}else t.value=ne(t.key);return t.shorthand=!0,this.finishNode(t,"ObjectProperty")}}parseObjPropValue(t,e,i,s,n,o,a){const r=this.parseObjectMethod(t,i,s,n,o)||this.parseObjectProperty(t,e,n,a);return r||this.unexpected(),r}parsePropertyName(t,e){if(this.eat(0))t.computed=!0,t.key=this.parseMaybeAssignAllowIn(),this.expect(3);else{const{type:i,value:s}=this.state;let n;if(E(i))n=this.parseIdentifier(!0);else switch(i){case 134:n=this.parseNumericLiteral(s);break;case 133:n=this.parseStringLiteral(s);break;case 135:n=this.parseBigIntLiteral(s);break;case 136:n=this.parseDecimalLiteral(s);break;case 138:{const t=this.state.startLoc;null!=e?null===e.privateKeyLoc&&(e.privateKeyLoc=t):this.raise(L.UnexpectedPrivateField,t),n=this.parsePrivateName();break}default:this.unexpected()}t.key=n,138!==i&&(t.computed=!1)}return t.key}initFunction(t,e){t.id=null,t.generator=!1,t.async=e}parseMethod(t,e,i,s,n,o,a=!1){this.initFunction(t,i),t.generator=e,this.scope.enter(18|(a?64:0)|(n?32:0)),this.prodParam.enter(Kt(i,t.generator)),this.parseFunctionParams(t,s);const r=this.parseFunctionBodyAndFinish(t,o,!0);return this.prodParam.exit(),this.scope.exit(),r}parseArrayLike(t,e,i,s){i&&this.expectPlugin("recordAndTuple");const n=this.state.inFSharpPipelineDirectBody;this.state.inFSharpPipelineDirectBody=!1;const o=this.startNode();return this.next(),o.elements=this.parseExprList(t,!i,s,o),this.state.inFSharpPipelineDirectBody=n,this.finishNode(o,i?"TupleExpression":"ArrayExpression")}parseArrowExpression(t,e,i,s){this.scope.enter(6);let n=Kt(i,!1);!this.match(5)&&this.prodParam.hasIn&&(n|=8),this.prodParam.enter(n),this.initFunction(t,i);const o=this.state.maybeInArrowParameters;return e&&(this.state.maybeInArrowParameters=!0,this.setArrowFunctionParameters(t,e,s)),this.state.maybeInArrowParameters=!1,this.parseFunctionBody(t,!0),this.prodParam.exit(),this.scope.exit(),this.state.maybeInArrowParameters=o,this.finishNode(t,"ArrowFunctionExpression")}setArrowFunctionParameters(t,e,i){this.toAssignableList(e,i,!1),t.params=e}parseFunctionBodyAndFinish(t,e,i=!1){return this.parseFunctionBody(t,!1,i),this.finishNode(t,e)}parseFunctionBody(t,e,i=!1){const s=e&&!this.match(5);if(this.expressionScope.enter(qt()),s)t.body=this.parseMaybeAssign(),this.checkParams(t,!1,e,!1);else{const s=this.state.strict,n=this.state.labels;this.state.labels=[],this.prodParam.enter(4|this.prodParam.currentFlags()),t.body=this.parseBlock(!0,!1,(n=>{const o=!this.isSimpleParamList(t.params);n&&o&&this.raise(L.IllegalLanguageModeDirective,"method"!==t.kind&&"constructor"!==t.kind||!t.key?t:t.key.loc.end);const a=!s&&this.state.strict;this.checkParams(t,!(this.state.strict||e||i||o),e,a),this.state.strict&&t.id&&this.checkIdentifier(t.id,65,a)})),this.prodParam.exit(),this.state.labels=n}this.expressionScope.exit()}isSimpleParameter(t){return"Identifier"===t.type}isSimpleParamList(t){for(let e=0,i=t.length;e10)&&function(t){return bt.has(t)}(t))if(i&&function(t){return lt.has(t)}(t))this.raise(L.UnexpectedKeyword,e,{keyword:t});else if((this.state.strict?s?pt:It:dt)(t,this.inModule))this.raise(L.UnexpectedReservedWord,e,{reservedWord:t});else if("yield"===t){if(this.prodParam.hasYield)return void this.raise(L.YieldBindingIdentifier,e)}else if("await"===t){if(this.prodParam.hasAwait)return void this.raise(L.AwaitBindingIdentifier,e);if(this.scope.inStaticBlock)return void this.raise(L.AwaitBindingIdentifierInStaticBlock,e);this.expressionScope.recordAsyncArrowParametersError(e)}else if("arguments"===t&&this.scope.inClassAndNotInNonArrowFunction)return void this.raise(L.ArgumentsInClass,e)}isAwaitAllowed(){return!!this.prodParam.hasAwait||!(!this.options.allowAwaitOutsideFunction||this.scope.inFunction)}parseAwait(t){const e=this.startNodeAt(t);return this.expressionScope.recordParameterInitializerError(L.AwaitExpressionFormalParameter,e),this.eat(55)&&this.raise(L.ObsoleteAwaitStar,e),this.scope.inFunction||this.options.allowAwaitOutsideFunction||(this.isAmbiguousAwait()?this.ambiguousScriptDifferentAst=!0:this.sawUnambiguousESM=!0),this.state.soloAwait||(e.argument=this.parseMaybeUnary(null,!0)),this.finishNode(e,"AwaitExpression")}isAmbiguousAwait(){if(this.hasPrecedingLineBreak())return!0;const{type:t}=this.state;return 53===t||10===t||0===t||q(t)||102===t&&!this.state.containsEsc||137===t||56===t||this.hasPlugin("v8intrinsic")&&54===t}parseYield(){const t=this.startNode();this.expressionScope.recordParameterInitializerError(L.YieldInParameter,t),this.next();let e=!1,i=null;if(!this.hasPrecedingLineBreak())switch(e=this.eat(55),this.state.type){case 13:case 139:case 8:case 11:case 3:case 9:case 14:case 12:if(!e)break;default:i=this.parseMaybeAssign()}return t.delegate=e,t.argument=i,this.finishNode(t,"YieldExpression")}parseImportCall(t){return this.next(),t.source=this.parseMaybeAssignAllowIn(),(this.hasPlugin("importAttributes")||this.hasPlugin("importAssertions"))&&(t.options=null),this.eat(12)&&(this.expectImportAttributesPlugin(),this.match(11)||(t.options=this.parseMaybeAssignAllowIn(),this.eat(12))),this.expect(11),this.finishNode(t,"ImportExpression")}checkPipelineAtInfixOperator(t,e){this.hasPlugin(["pipelineOperator",{proposal:"smart"}])&&"SequenceExpression"===t.type&&this.raise(L.PipelineHeadSequenceExpression,e)}parseSmartPipelineBodyInStyle(t,e){if(this.isSimpleReference(t)){const i=this.startNodeAt(e);return i.callee=t,this.finishNode(i,"PipelineBareFunction")}{const i=this.startNodeAt(e);return this.checkSmartPipeTopicBodyEarlyErrors(e),i.expression=t,this.finishNode(i,"PipelineTopicExpression")}}isSimpleReference(t){switch(t.type){case"MemberExpression":return!t.computed&&this.isSimpleReference(t.object);case"Identifier":return!0;default:return!1}}checkSmartPipeTopicBodyEarlyErrors(t){if(this.match(19))throw this.raise(L.PipelineBodyNoArrow,this.state.startLoc);this.topicReferenceWasUsedInCurrentContext()||this.raise(L.PipelineTopicUnused,t)}withTopicBindingContext(t){const e=this.state.topicContext;this.state.topicContext={maxNumOfResolvableTopics:1,maxTopicIndex:null};try{return t()}finally{this.state.topicContext=e}}withSmartMixTopicForbiddingContext(t){if(!this.hasPlugin(["pipelineOperator",{proposal:"smart"}]))return t();{const e=this.state.topicContext;this.state.topicContext={maxNumOfResolvableTopics:0,maxTopicIndex:null};try{return t()}finally{this.state.topicContext=e}}}withSoloAwaitPermittingContext(t){const e=this.state.soloAwait;this.state.soloAwait=!0;try{return t()}finally{this.state.soloAwait=e}}allowInAnd(t){const e=this.prodParam.currentFlags();if(8&~e){this.prodParam.enter(8|e);try{return t()}finally{this.prodParam.exit()}}return t()}disallowInAnd(t){const e=this.prodParam.currentFlags();if(8&e){this.prodParam.enter(-9&e);try{return t()}finally{this.prodParam.exit()}}return t()}registerTopicReference(){this.state.topicContext.maxTopicIndex=0}topicReferenceIsAllowedInCurrentContext(){return this.state.topicContext.maxNumOfResolvableTopics>=1}topicReferenceWasUsedInCurrentContext(){return null!=this.state.topicContext.maxTopicIndex&&this.state.topicContext.maxTopicIndex>=0}parseFSharpPipelineBody(t){const e=this.state.startLoc;this.state.potentialArrowAt=this.state.start;const i=this.state.inFSharpPipelineDirectBody;this.state.inFSharpPipelineDirectBody=!0;const s=this.parseExprOp(this.parseMaybeUnaryOrPrivate(),e,t);return this.state.inFSharpPipelineDirectBody=i,s}parseModuleExpression(){this.expectPlugin("moduleBlocks");const t=this.startNode();this.next(),this.match(5)||this.unexpected(null,5);const e=this.startNodeAt(this.state.endLoc);this.next();const i=this.initializeScopes(!0);this.enterInitialScopes();try{t.body=this.parseProgram(e,8,"module")}finally{i()}return this.finishNode(t,"ModuleExpression")}parsePropertyNamePrefixOperator(t){}}const Ve={kind:1},Te={kind:2},ke=/[\uD800-\uDFFF]/u,Oe=/in(?:stanceof)?/y;class Fe extends ze{parseTopLevel(t,e){return t.program=this.parseProgram(e),t.comments=this.comments,this.options.tokens&&(t.tokens=function(t,e){for(let i=0;i0)for(const[t,e]of Array.from(this.scope.undefinedExports))this.raise(L.ModuleExportUndefined,e,{localName:t});let s;return s=139===e?this.finishNode(t,"Program"):this.finishNodeAt(t,"Program",o(this.state.startLoc,-1)),s}stmtToDirective(t){const e=t;e.type="Directive",e.value=e.expression,delete e.expression;const i=e.value,s=i.value,n=this.input.slice(i.start,i.end),o=i.value=n.slice(1,-1);return this.addExtra(i,"raw",n),this.addExtra(i,"rawValue",o),this.addExtra(i,"expressionValue",s),i.type="DirectiveLiteral",e}parseInterpreterDirective(){if(!this.match(28))return null;const t=this.startNode();return t.value=this.state.value,this.next(),this.finishNode(t,"InterpreterDirective")}isLet(){return!!this.isContextual(100)&&this.hasFollowingBindingAtom()}chStartsBindingIdentifier(t,e){if(at(t)){if(Oe.lastIndex=e,Oe.test(this.input)){const t=this.codePointAtPos(Oe.lastIndex);if(!rt(t)&&92!==t)return!1}return!0}return 92===t}chStartsBindingPattern(t){return 91===t||123===t}hasFollowingBindingAtom(){const t=this.nextTokenStart(),e=this.codePointAtPos(t);return this.chStartsBindingPattern(e)||this.chStartsBindingIdentifier(e,t)}hasInLineFollowingBindingIdentifier(){const t=this.nextTokenInLineStart(),e=this.codePointAtPos(t);return this.chStartsBindingIdentifier(e,t)}startsUsingForOf(){const{type:t,containsEsc:e}=this.lookahead();return!(102===t&&!e)&&(X(t)&&!this.hasFollowingLineBreak()?(this.expectPlugin("explicitResourceManagement"),!0):void 0)}startsAwaitUsing(){let t=this.nextTokenInLineStart();if(this.isUnparsedContextual(t,"using")){t=this.nextTokenInLineStartSince(t+5);const e=this.codePointAtPos(t);if(this.chStartsBindingIdentifier(e,t))return this.expectPlugin("explicitResourceManagement"),!0}return!1}parseModuleItem(){return this.parseStatementLike(15)}parseStatementListItem(){return this.parseStatementLike(6|(!this.options.annexB||this.state.strict?0:8))}parseStatementOrSloppyAnnexBFunctionDeclaration(t=!1){let e=0;return this.options.annexB&&!this.state.strict&&(e|=4,t&&(e|=8)),this.parseStatementLike(e)}parseStatement(){return this.parseStatementLike(0)}parseStatementLike(t){let e=null;return this.match(26)&&(e=this.parseDecorators(!0)),this.parseStatementContent(t,e)}parseStatementContent(t,e){const i=this.state.type,s=this.startNode(),n=!!(2&t),o=!!(4&t),a=1&t;switch(i){case 60:return this.parseBreakContinueStatement(s,!0);case 63:return this.parseBreakContinueStatement(s,!1);case 64:return this.parseDebuggerStatement(s);case 90:return this.parseDoWhileStatement(s);case 91:return this.parseForStatement(s);case 68:if(46===this.lookaheadCharCode())break;return o||this.raise(this.state.strict?L.StrictFunction:this.options.annexB?L.SloppyFunctionAnnexB:L.SloppyFunction,this.state.startLoc),this.parseFunctionStatement(s,!1,!n&&o);case 80:return n||this.unexpected(),this.parseClass(this.maybeTakeDecorators(e,s),!0);case 69:return this.parseIfStatement(s);case 70:return this.parseReturnStatement(s);case 71:return this.parseSwitchStatement(s);case 72:return this.parseThrowStatement(s);case 73:return this.parseTryStatement(s);case 96:if(!this.state.containsEsc&&this.startsAwaitUsing())return this.isAwaitAllowed()?n||this.raise(L.UnexpectedLexicalDeclaration,s):this.raise(L.AwaitUsingNotInAsyncContext,s),this.next(),this.parseVarStatement(s,"await using");break;case 107:if(this.state.containsEsc||!this.hasInLineFollowingBindingIdentifier())break;return this.expectPlugin("explicitResourceManagement"),!this.scope.inModule&&this.scope.inTopLevel?this.raise(L.UnexpectedUsingDeclaration,this.state.startLoc):n||this.raise(L.UnexpectedLexicalDeclaration,this.state.startLoc),this.parseVarStatement(s,"using");case 100:{if(this.state.containsEsc)break;const t=this.nextTokenStart(),e=this.codePointAtPos(t);if(91!==e){if(!n&&this.hasFollowingLineBreak())break;if(!this.chStartsBindingIdentifier(e,t)&&123!==e)break}}case 75:n||this.raise(L.UnexpectedLexicalDeclaration,this.state.startLoc);case 74:{const t=this.state.value;return this.parseVarStatement(s,t)}case 92:return this.parseWhileStatement(s);case 76:return this.parseWithStatement(s);case 5:return this.parseBlock();case 13:return this.parseEmptyStatement(s);case 83:{const t=this.lookaheadCharCode();if(40===t||46===t)break}case 82:{let t;return this.options.allowImportExportEverywhere||a||this.raise(L.UnexpectedImportExport,this.state.startLoc),this.next(),83===i?(t=this.parseImport(s),"ImportDeclaration"!==t.type||t.importKind&&"value"!==t.importKind||(this.sawUnambiguousESM=!0)):(t=this.parseExport(s,e),("ExportNamedDeclaration"!==t.type||t.exportKind&&"value"!==t.exportKind)&&("ExportAllDeclaration"!==t.type||t.exportKind&&"value"!==t.exportKind)&&"ExportDefaultDeclaration"!==t.type||(this.sawUnambiguousESM=!0)),this.assertModuleNodeAllowed(t),t}default:if(this.isAsyncFunction())return n||this.raise(L.AsyncFunctionInSingleStatementContext,this.state.startLoc),this.next(),this.parseFunctionStatement(s,!0,!n&&o)}const r=this.state.value,l=this.parseExpression();return X(i)&&"Identifier"===l.type&&this.eat(14)?this.parseLabeledStatement(s,r,l,t):this.parseExpressionStatement(s,l,e)}assertModuleNodeAllowed(t){this.options.allowImportExportEverywhere||this.inModule||this.raise(L.ImportOutsideModule,t)}decoratorsEnabledBeforeExport(){return!!this.hasPlugin("decorators-legacy")||this.hasPlugin("decorators")&&!1!==this.getPluginOption("decorators","decoratorsBeforeExport")}maybeTakeDecorators(t,e,i){return t&&(e.decorators&&e.decorators.length>0?("boolean"!=typeof this.getPluginOption("decorators","decoratorsBeforeExport")&&this.raise(L.DecoratorsBeforeAfterExport,e.decorators[0]),e.decorators.unshift(...t)):e.decorators=t,this.resetStartLocationFromNode(e,t[0]),i&&this.resetStartLocationFromNode(i,e)),e}canHaveLeadingDecorator(){return this.match(80)}parseDecorators(t){const e=[];do{e.push(this.parseDecorator())}while(this.match(26));if(this.match(82))t||this.unexpected(),this.decoratorsEnabledBeforeExport()||this.raise(L.DecoratorExportClass,this.state.startLoc);else if(!this.canHaveLeadingDecorator())throw this.raise(L.UnexpectedLeadingDecorator,this.state.startLoc);return e}parseDecorator(){this.expectOnePlugin(["decorators","decorators-legacy"]);const t=this.startNode();if(this.next(),this.hasPlugin("decorators")){const e=this.state.startLoc;let i;if(this.match(10)){const e=this.state.startLoc;this.next(),i=this.parseExpression(),this.expect(11),i=this.wrapParenthesis(e,i);const s=this.state.startLoc;t.expression=this.parseMaybeDecoratorArguments(i),!1===this.getPluginOption("decorators","allowCallParenthesized")&&t.expression!==i&&this.raise(L.DecoratorArgumentsOutsideParentheses,s)}else{for(i=this.parseIdentifier(!1);this.eat(16);){const t=this.startNodeAt(e);t.object=i,this.match(138)?(this.classScope.usePrivateName(this.state.value,this.state.startLoc),t.property=this.parsePrivateName()):t.property=this.parseIdentifier(!0),t.computed=!1,i=this.finishNode(t,"MemberExpression")}t.expression=this.parseMaybeDecoratorArguments(i)}}else t.expression=this.parseExprSubscripts();return this.finishNode(t,"Decorator")}parseMaybeDecoratorArguments(t){if(this.eat(10)){const e=this.startNodeAtNode(t);return e.callee=t,e.arguments=this.parseCallExpressionArguments(11,!1),this.toReferencedList(e.arguments),this.finishNode(e,"CallExpression")}return t}parseBreakContinueStatement(t,e){return this.next(),this.isLineTerminator()?t.label=null:(t.label=this.parseIdentifier(),this.semicolon()),this.verifyBreakContinue(t,e),this.finishNode(t,e?"BreakStatement":"ContinueStatement")}verifyBreakContinue(t,e){let i;for(i=0;ithis.parseStatement())),this.state.labels.pop(),this.expect(92),t.test=this.parseHeaderExpression(),this.eat(13),this.finishNode(t,"DoWhileStatement")}parseForStatement(t){this.next(),this.state.labels.push(Ve);let e=null;if(this.isAwaitAllowed()&&this.eatContextual(96)&&(e=this.state.lastTokStartLoc),this.scope.enter(0),this.expect(10),this.match(13))return null!==e&&this.unexpected(e),this.parseFor(t,null);const i=this.isContextual(100);{const s=this.isContextual(96)&&this.startsAwaitUsing(),n=s||this.isContextual(107)&&this.startsUsingForOf(),o=i&&this.hasFollowingBindingAtom()||n;if(this.match(74)||this.match(75)||o){const i=this.startNode();let o;s?(o="await using",this.isAwaitAllowed()||this.raise(L.AwaitUsingNotInAsyncContext,this.state.startLoc),this.next()):o=this.state.value,this.next(),this.parseVar(i,!0,o);const a=this.finishNode(i,"VariableDeclaration"),r=this.match(58);return r&&n&&this.raise(L.ForInUsing,a),(r||this.isContextual(102))&&1===a.declarations.length?this.parseForIn(t,a,e):(null!==e&&this.unexpected(e),this.parseFor(t,a))}}const s=this.isContextual(95),n=new ee,o=this.parseExpression(!0,n),a=this.isContextual(102);if(a&&(i&&this.raise(L.ForOfLet,o),null===e&&s&&"Identifier"===o.type&&this.raise(L.ForOfAsync,o)),a||this.match(58)){this.checkDestructuringPrivate(n),this.toAssignable(o,!0);const i=a?"ForOfStatement":"ForInStatement";return this.checkLVal(o,{in:{type:i}}),this.parseForIn(t,o,e)}return this.checkExpressionErrors(n,!0),null!==e&&this.unexpected(e),this.parseFor(t,o)}parseFunctionStatement(t,e,i){return this.next(),this.parseFunction(t,1|(i?2:0)|(e?8:0))}parseIfStatement(t){return this.next(),t.test=this.parseHeaderExpression(),t.consequent=this.parseStatementOrSloppyAnnexBFunctionDeclaration(),t.alternate=this.eat(66)?this.parseStatementOrSloppyAnnexBFunctionDeclaration():null,this.finishNode(t,"IfStatement")}parseReturnStatement(t){return this.prodParam.hasReturn||this.options.allowReturnOutsideFunction||this.raise(L.IllegalReturn,this.state.startLoc),this.next(),this.isLineTerminator()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")}parseSwitchStatement(t){this.next(),t.discriminant=this.parseHeaderExpression();const e=t.cases=[];let i;this.expect(5),this.state.labels.push(Te),this.scope.enter(0);for(let t;!this.match(8);)if(this.match(61)||this.match(65)){const s=this.match(61);i&&this.finishNode(i,"SwitchCase"),e.push(i=this.startNode()),i.consequent=[],this.next(),s?i.test=this.parseExpression():(t&&this.raise(L.MultipleDefaultsInSwitch,this.state.lastTokStartLoc),t=!0,i.test=null),this.expect(14)}else i?i.consequent.push(this.parseStatementListItem()):this.unexpected();return this.scope.exit(),i&&this.finishNode(i,"SwitchCase"),this.next(),this.state.labels.pop(),this.finishNode(t,"SwitchStatement")}parseThrowStatement(t){return this.next(),this.hasPrecedingLineBreak()&&this.raise(L.NewlineAfterThrow,this.state.lastTokEndLoc),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")}parseCatchClauseParam(){const t=this.parseBindingAtom();return this.scope.enter(this.options.annexB&&"Identifier"===t.type?8:0),this.checkLVal(t,{in:{type:"CatchClause"},binding:9}),t}parseTryStatement(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.match(62)){const e=this.startNode();this.next(),this.match(10)?(this.expect(10),e.param=this.parseCatchClauseParam(),this.expect(11)):(e.param=null,this.scope.enter(0)),e.body=this.withSmartMixTopicForbiddingContext((()=>this.parseBlock(!1,!1))),this.scope.exit(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(67)?this.parseBlock():null,t.handler||t.finalizer||this.raise(L.NoCatchOrFinally,t),this.finishNode(t,"TryStatement")}parseVarStatement(t,e,i=!1){return this.next(),this.parseVar(t,!1,e,i),this.semicolon(),this.finishNode(t,"VariableDeclaration")}parseWhileStatement(t){return this.next(),t.test=this.parseHeaderExpression(),this.state.labels.push(Ve),t.body=this.withSmartMixTopicForbiddingContext((()=>this.parseStatement())),this.state.labels.pop(),this.finishNode(t,"WhileStatement")}parseWithStatement(t){return this.state.strict&&this.raise(L.StrictWith,this.state.startLoc),this.next(),t.object=this.parseHeaderExpression(),t.body=this.withSmartMixTopicForbiddingContext((()=>this.parseStatement())),this.finishNode(t,"WithStatement")}parseEmptyStatement(t){return this.next(),this.finishNode(t,"EmptyStatement")}parseLabeledStatement(t,e,i,s){for(const t of this.state.labels)t.name===e&&this.raise(L.LabelRedeclaration,i,{labelName:e});const n=(o=this.state.type)>=90&&o<=92?1:this.match(71)?2:null;var o;for(let e=this.state.labels.length-1;e>=0;e--){const i=this.state.labels[e];if(i.statementStart!==t.start)break;i.statementStart=this.state.start,i.kind=n}return this.state.labels.push({name:e,kind:n,statementStart:this.state.start}),t.body=8&s?this.parseStatementOrSloppyAnnexBFunctionDeclaration(!0):this.parseStatement(),this.state.labels.pop(),t.label=i,this.finishNode(t,"LabeledStatement")}parseExpressionStatement(t,e,i){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")}parseBlock(t=!1,e=!0,i){const s=this.startNode();return t&&this.state.strictErrors.clear(),this.expect(5),e&&this.scope.enter(0),this.parseBlockBody(s,t,!1,8,i),e&&this.scope.exit(),this.finishNode(s,"BlockStatement")}isValidDirective(t){return"ExpressionStatement"===t.type&&"StringLiteral"===t.expression.type&&!t.expression.extra.parenthesized}parseBlockBody(t,e,i,s,n){const o=t.body=[],a=t.directives=[];this.parseBlockOrModuleBlockBody(o,e?a:void 0,i,s,n)}parseBlockOrModuleBlockBody(t,e,i,s,n){const o=this.state.strict;let a=!1,r=!1;for(;!this.match(s);){const s=i?this.parseModuleItem():this.parseStatementListItem();if(e&&!r){if(this.isValidDirective(s)){const t=this.stmtToDirective(s);e.push(t),a||"use strict"!==t.value.value||(a=!0,this.setStrict(!0));continue}r=!0,this.state.strictErrors.clear()}t.push(s)}null==n||n.call(this,a),o||this.setStrict(!1),this.next()}parseFor(t,e){return t.init=e,this.semicolon(!1),t.test=this.match(13)?null:this.parseExpression(),this.semicolon(!1),t.update=this.match(11)?null:this.parseExpression(),this.expect(11),t.body=this.withSmartMixTopicForbiddingContext((()=>this.parseStatement())),this.scope.exit(),this.state.labels.pop(),this.finishNode(t,"ForStatement")}parseForIn(t,e,i){const s=this.match(58);return this.next(),s?null!==i&&this.unexpected(i):t.await=null!==i,"VariableDeclaration"!==e.type||null==e.declarations[0].init||s&&this.options.annexB&&!this.state.strict&&"var"===e.kind&&"Identifier"===e.declarations[0].id.type||this.raise(L.ForInOfLoopInitializer,e,{type:s?"ForInStatement":"ForOfStatement"}),"AssignmentPattern"===e.type&&this.raise(L.InvalidLhs,e,{ancestor:{type:"ForStatement"}}),t.left=e,t.right=s?this.parseExpression():this.parseMaybeAssignAllowIn(),this.expect(11),t.body=this.withSmartMixTopicForbiddingContext((()=>this.parseStatement())),this.scope.exit(),this.state.labels.pop(),this.finishNode(t,s?"ForInStatement":"ForOfStatement")}parseVar(t,e,i,s=!1){const n=t.declarations=[];for(t.kind=i;;){const t=this.startNode();if(this.parseVarId(t,i),t.init=this.eat(29)?e?this.parseMaybeAssignDisallowIn():this.parseMaybeAssignAllowIn():null,null!==t.init||s||("Identifier"===t.id.type||e&&(this.match(58)||this.isContextual(102))?"const"!==i||this.match(58)||this.isContextual(102)||this.raise(L.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:"const"}):this.raise(L.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:"destructuring"})),n.push(this.finishNode(t,"VariableDeclarator")),!this.eat(12))break}return t}parseVarId(t,e){const i=this.parseBindingAtom();this.checkLVal(i,{in:{type:"VariableDeclarator"},binding:"var"===e?5:8201}),t.id=i}parseAsyncFunctionExpression(t){return this.parseFunction(t,8)}parseFunction(t,e=0){const i=2&e,s=!!(1&e),n=s&&!(4&e),o=!!(8&e);this.initFunction(t,o),this.match(55)&&(i&&this.raise(L.GeneratorInSingleStatementContext,this.state.startLoc),this.next(),t.generator=!0),s&&(t.id=this.parseFunctionId(n));const a=this.state.maybeInArrowParameters;return this.state.maybeInArrowParameters=!1,this.scope.enter(2),this.prodParam.enter(Kt(o,t.generator)),s||(t.id=this.parseFunctionId()),this.parseFunctionParams(t,!1),this.withSmartMixTopicForbiddingContext((()=>{this.parseFunctionBodyAndFinish(t,s?"FunctionDeclaration":"FunctionExpression")})),this.prodParam.exit(),this.scope.exit(),s&&!i&&this.registerFunctionStatementId(t),this.state.maybeInArrowParameters=a,t}parseFunctionId(t){return t||X(this.state.type)?this.parseIdentifier():null}parseFunctionParams(t,e){this.expect(10),this.expressionScope.enter(new Pt(3)),t.params=this.parseBindingList(11,41,2|(e?4:0)),this.expressionScope.exit()}registerFunctionStatementId(t){t.id&&this.scope.declareName(t.id.name,!this.options.annexB||this.state.strict||t.generator||t.async?this.scope.treatFunctionsAsVar?5:8201:17,t.id.loc.start)}parseClass(t,e,i){this.next();const s=this.state.strict;return this.state.strict=!0,this.parseClassId(t,e,i),this.parseClassSuper(t),t.body=this.parseClassBody(!!t.superClass,s),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")}isClassProperty(){return this.match(29)||this.match(13)||this.match(8)}isClassMethod(){return this.match(10)}isNonstaticConstructor(t){return!(t.computed||t.static||"constructor"!==t.key.name&&"constructor"!==t.key.value)}parseClassBody(t,e){this.classScope.enter();const i={hadConstructor:!1,hadSuperClass:t};let s=[];const n=this.startNode();if(n.body=[],this.expect(5),this.withSmartMixTopicForbiddingContext((()=>{for(;!this.match(8);){if(this.eat(13)){if(s.length>0)throw this.raise(L.DecoratorSemicolon,this.state.lastTokEndLoc);continue}if(this.match(26)){s.push(this.parseDecorator());continue}const t=this.startNode();s.length&&(t.decorators=s,this.resetStartLocationFromNode(t,s[0]),s=[]),this.parseClassMember(n,t,i),"constructor"===t.kind&&t.decorators&&t.decorators.length>0&&this.raise(L.DecoratorConstructor,t)}})),this.state.strict=e,this.next(),s.length)throw this.raise(L.TrailingDecorator,this.state.startLoc);return this.classScope.exit(),this.finishNode(n,"ClassBody")}parseClassMemberFromModifier(t,e){const i=this.parseIdentifier(!0);if(this.isClassMethod()){const s=e;return s.kind="method",s.computed=!1,s.key=i,s.static=!1,this.pushClassMethod(t,s,!1,!1,!1,!1),!0}if(this.isClassProperty()){const s=e;return s.computed=!1,s.key=i,s.static=!1,t.body.push(this.parseClassProperty(s)),!0}return this.resetPreviousNodeTrailingComments(i),!1}parseClassMember(t,e,i){const s=this.isContextual(106);if(s){if(this.parseClassMemberFromModifier(t,e))return;if(this.eat(5))return void this.parseClassStaticBlock(t,e)}this.parseClassMemberWithIsStatic(t,e,i,s)}parseClassMemberWithIsStatic(t,e,i,s){const n=e,o=e,a=e,r=e,l=e,h=n,c=n;if(e.static=s,this.parsePropertyNamePrefixOperator(e),this.eat(55)){h.kind="method";const e=this.match(138);return this.parseClassElementName(h),e?void this.pushClassPrivateMethod(t,o,!0,!1):(this.isNonstaticConstructor(n)&&this.raise(L.ConstructorIsGenerator,n.key),void this.pushClassMethod(t,n,!0,!1,!1,!1))}const d=X(this.state.type)&&!this.state.containsEsc,I=this.match(138),u=this.parseClassElementName(e),p=this.state.startLoc;if(this.parsePostMemberNameModifiers(c),this.isClassMethod()){if(h.kind="method",I)return void this.pushClassPrivateMethod(t,o,!1,!1);const s=this.isNonstaticConstructor(n);let a=!1;s&&(n.kind="constructor",i.hadConstructor&&!this.hasPlugin("typescript")&&this.raise(L.DuplicateConstructor,u),s&&this.hasPlugin("typescript")&&e.override&&this.raise(L.OverrideOnConstructor,u),i.hadConstructor=!0,a=i.hadSuperClass),this.pushClassMethod(t,n,!1,!1,s,a)}else if(this.isClassProperty())I?this.pushClassPrivateProperty(t,r):this.pushClassProperty(t,a);else if(d&&"async"===u.name&&!this.isLineTerminator()){this.resetPreviousNodeTrailingComments(u);const e=this.eat(55);c.optional&&this.unexpected(p),h.kind="method";const i=this.match(138);this.parseClassElementName(h),this.parsePostMemberNameModifiers(c),i?this.pushClassPrivateMethod(t,o,e,!0):(this.isNonstaticConstructor(n)&&this.raise(L.ConstructorIsAsync,n.key),this.pushClassMethod(t,n,e,!0,!1,!1))}else if(!d||"get"!==u.name&&"set"!==u.name||this.match(55)&&this.isLineTerminator())if(d&&"accessor"===u.name&&!this.isLineTerminator()){this.expectPlugin("decoratorAutoAccessors"),this.resetPreviousNodeTrailingComments(u);const e=this.match(138);this.parseClassElementName(a),this.pushClassAccessorProperty(t,l,e)}else this.isLineTerminator()?I?this.pushClassPrivateProperty(t,r):this.pushClassProperty(t,a):this.unexpected();else{this.resetPreviousNodeTrailingComments(u),h.kind=u.name;const e=this.match(138);this.parseClassElementName(n),e?this.pushClassPrivateMethod(t,o,!1,!1):(this.isNonstaticConstructor(n)&&this.raise(L.ConstructorIsAccessor,n.key),this.pushClassMethod(t,n,!1,!1,!1,!1)),this.checkGetterSetterParams(n)}}parseClassElementName(t){const{type:e,value:i}=this.state;if(132!==e&&133!==e||!t.static||"prototype"!==i||this.raise(L.StaticPrototype,this.state.startLoc),138===e){"constructor"===i&&this.raise(L.ConstructorClassPrivateField,this.state.startLoc);const e=this.parsePrivateName();return t.key=e,e}return this.parsePropertyName(t)}parseClassStaticBlock(t,e){var i;this.scope.enter(208);const s=this.state.labels;this.state.labels=[],this.prodParam.enter(0);const n=e.body=[];this.parseBlockOrModuleBlockBody(n,void 0,!1,8),this.prodParam.exit(),this.scope.exit(),this.state.labels=s,t.body.push(this.finishNode(e,"StaticBlock")),null!=(i=e.decorators)&&i.length&&this.raise(L.DecoratorStaticBlock,e)}pushClassProperty(t,e){e.computed||"constructor"!==e.key.name&&"constructor"!==e.key.value||this.raise(L.ConstructorClassField,e.key),t.body.push(this.parseClassProperty(e))}pushClassPrivateProperty(t,e){const i=this.parseClassPrivateProperty(e);t.body.push(i),this.classScope.declarePrivateName(this.getPrivateNameSV(i.key),0,i.key.loc.start)}pushClassAccessorProperty(t,e,i){if(!i&&!e.computed){const t=e.key;"constructor"!==t.name&&"constructor"!==t.value||this.raise(L.ConstructorClassField,t)}const s=this.parseClassAccessorProperty(e);t.body.push(s),i&&this.classScope.declarePrivateName(this.getPrivateNameSV(s.key),0,s.key.loc.start)}pushClassMethod(t,e,i,s,n,o){t.body.push(this.parseMethod(e,i,s,n,o,"ClassMethod",!0))}pushClassPrivateMethod(t,e,i,s){const n=this.parseMethod(e,i,s,!1,!1,"ClassPrivateMethod",!0);t.body.push(n);const o="get"===n.kind?n.static?6:2:"set"===n.kind?n.static?5:1:0;this.declareClassPrivateMethodInScope(n,o)}declareClassPrivateMethodInScope(t,e){this.classScope.declarePrivateName(this.getPrivateNameSV(t.key),e,t.key.loc.start)}parsePostMemberNameModifiers(t){}parseClassPrivateProperty(t){return this.parseInitializer(t),this.semicolon(),this.finishNode(t,"ClassPrivateProperty")}parseClassProperty(t){return this.parseInitializer(t),this.semicolon(),this.finishNode(t,"ClassProperty")}parseClassAccessorProperty(t){return this.parseInitializer(t),this.semicolon(),this.finishNode(t,"ClassAccessorProperty")}parseInitializer(t){this.scope.enter(80),this.expressionScope.enter(qt()),this.prodParam.enter(0),t.value=this.eat(29)?this.parseMaybeAssignAllowIn():null,this.expressionScope.exit(),this.prodParam.exit(),this.scope.exit()}parseClassId(t,e,i,s=8331){if(X(this.state.type))t.id=this.parseIdentifier(),e&&this.declareNameFromIdentifier(t.id,s);else{if(!i&&e)throw this.raise(L.MissingClassName,this.state.startLoc);t.id=null}}parseClassSuper(t){t.superClass=this.eat(81)?this.parseExprSubscripts():null}parseExport(t,e){const i=this.parseMaybeImportPhase(t,!0),s=this.maybeParseExportDefaultSpecifier(t,i),n=!s||this.eat(12),o=n&&this.eatExportStar(t),a=o&&this.maybeParseExportNamespaceSpecifier(t),r=n&&(!a||this.eat(12)),l=s||o;if(o&&!a){if(s&&this.unexpected(),e)throw this.raise(L.UnsupportedDecoratorExport,t);return this.parseExportFrom(t,!0),this.finishNode(t,"ExportAllDeclaration")}const h=this.maybeParseExportNamedSpecifiers(t);let c;if(s&&n&&!o&&!h&&this.unexpected(null,5),a&&r&&this.unexpected(null,98),l||h){if(c=!1,e)throw this.raise(L.UnsupportedDecoratorExport,t);this.parseExportFrom(t,l)}else c=this.maybeParseExportDeclaration(t);if(l||h||c){var d;const i=t;if(this.checkExport(i,!0,!1,!!i.source),"ClassDeclaration"===(null==(d=i.declaration)?void 0:d.type))this.maybeTakeDecorators(e,i.declaration,i);else if(e)throw this.raise(L.UnsupportedDecoratorExport,t);return this.finishNode(i,"ExportNamedDeclaration")}if(this.eat(65)){const i=t,s=this.parseExportDefaultExpression();if(i.declaration=s,"ClassDeclaration"===s.type)this.maybeTakeDecorators(e,s,i);else if(e)throw this.raise(L.UnsupportedDecoratorExport,t);return this.checkExport(i,!0,!0),this.finishNode(i,"ExportDefaultDeclaration")}this.unexpected(null,5)}eatExportStar(t){return this.eat(55)}maybeParseExportDefaultSpecifier(t,e){if(e||this.isExportDefaultSpecifier()){this.expectPlugin("exportDefaultFrom",null==e?void 0:e.loc.start);const i=e||this.parseIdentifier(!0),s=this.startNodeAtNode(i);return s.exported=i,t.specifiers=[this.finishNode(s,"ExportDefaultSpecifier")],!0}return!1}maybeParseExportNamespaceSpecifier(t){if(this.isContextual(93)){t.specifiers||(t.specifiers=[]);const e=this.startNodeAt(this.state.lastTokStartLoc);return this.next(),e.exported=this.parseModuleExportName(),t.specifiers.push(this.finishNode(e,"ExportNamespaceSpecifier")),!0}return!1}maybeParseExportNamedSpecifiers(t){if(this.match(5)){t.specifiers||(t.specifiers=[]);const e="type"===t.exportKind;return t.specifiers.push(...this.parseExportSpecifiers(e)),t.source=null,t.declaration=null,this.hasPlugin("importAssertions")&&(t.assertions=[]),!0}return!1}maybeParseExportDeclaration(t){return!!this.shouldParseExportDeclaration()&&(t.specifiers=[],t.source=null,this.hasPlugin("importAssertions")&&(t.assertions=[]),t.declaration=this.parseExportDeclaration(t),!0)}isAsyncFunction(){if(!this.isContextual(95))return!1;const t=this.nextTokenInLineStart();return this.isUnparsedContextual(t,"function")}parseExportDefaultExpression(){const t=this.startNode();if(this.match(68))return this.next(),this.parseFunction(t,5);if(this.isAsyncFunction())return this.next(),this.next(),this.parseFunction(t,13);if(this.match(80))return this.parseClass(t,!0,!0);if(this.match(26))return this.hasPlugin("decorators")&&!0===this.getPluginOption("decorators","decoratorsBeforeExport")&&this.raise(L.DecoratorBeforeExport,this.state.startLoc),this.parseClass(this.maybeTakeDecorators(this.parseDecorators(!1),this.startNode()),!0,!0);if(this.match(75)||this.match(74)||this.isLet())throw this.raise(L.UnsupportedDefaultExport,this.state.startLoc);const e=this.parseMaybeAssignAllowIn();return this.semicolon(),e}parseExportDeclaration(t){return this.match(80)?this.parseClass(this.startNode(),!0,!1):this.parseStatementListItem()}isExportDefaultSpecifier(){const{type:t}=this.state;if(X(t)){if(95===t&&!this.state.containsEsc||100===t)return!1;if((130===t||129===t)&&!this.state.containsEsc){const{type:t}=this.lookahead();if(X(t)&&98!==t||5===t)return this.expectOnePlugin(["flow","typescript"]),!1}}else if(!this.match(65))return!1;const e=this.nextTokenStart(),i=this.isUnparsedContextual(e,"from");if(44===this.input.charCodeAt(e)||X(this.state.type)&&i)return!0;if(this.match(65)&&i){const t=this.input.charCodeAt(this.nextTokenStartSince(e+4));return 34===t||39===t}return!1}parseExportFrom(t,e){this.eatContextual(98)?(t.source=this.parseImportSource(),this.checkExport(t),this.maybeParseImportAttributes(t),this.checkJSONModuleImport(t)):e&&this.unexpected(),this.semicolon()}shouldParseExportDeclaration(){const{type:t}=this.state;return 26===t&&(this.expectOnePlugin(["decorators","decorators-legacy"]),this.hasPlugin("decorators"))?(!0===this.getPluginOption("decorators","decoratorsBeforeExport")&&this.raise(L.DecoratorBeforeExport,this.state.startLoc),!0):74===t||75===t||68===t||80===t||this.isLet()||this.isAsyncFunction()}checkExport(t,e,i,s){var n;if(e)if(i){if(this.checkDuplicateExports(t,"default"),this.hasPlugin("exportDefaultFrom")){var o;const e=t.declaration;"Identifier"!==e.type||"from"!==e.name||e.end-e.start!=4||null!=(o=e.extra)&&o.parenthesized||this.raise(L.ExportDefaultFromAsIdentifier,e)}}else if(null!=(n=t.specifiers)&&n.length)for(const e of t.specifiers){const{exported:t}=e,i="Identifier"===t.type?t.name:t.value;if(this.checkDuplicateExports(e,i),!s&&e.local){const{local:t}=e;"Identifier"!==t.type?this.raise(L.ExportBindingIsString,e,{localName:t.value,exportName:i}):(this.checkReservedWord(t.name,t.loc.start,!0,!1),this.scope.checkLocalExport(t))}}else if(t.declaration)if("FunctionDeclaration"===t.declaration.type||"ClassDeclaration"===t.declaration.type){const e=t.declaration.id;if(!e)throw new Error("Assertion failure");this.checkDuplicateExports(t,e.name)}else if("VariableDeclaration"===t.declaration.type)for(const e of t.declaration.declarations)this.checkDeclaration(e.id)}checkDeclaration(t){if("Identifier"===t.type)this.checkDuplicateExports(t,t.name);else if("ObjectPattern"===t.type)for(const e of t.properties)this.checkDeclaration(e);else if("ArrayPattern"===t.type)for(const e of t.elements)e&&this.checkDeclaration(e);else"ObjectProperty"===t.type?this.checkDeclaration(t.value):"RestElement"===t.type?this.checkDeclaration(t.argument):"AssignmentPattern"===t.type&&this.checkDeclaration(t.left)}checkDuplicateExports(t,e){this.exportedIdentifiers.has(e)&&("default"===e?this.raise(L.DuplicateDefaultExport,t):this.raise(L.DuplicateExport,t,{exportName:e})),this.exportedIdentifiers.add(e)}parseExportSpecifiers(t){const e=[];let i=!0;for(this.expect(5);!this.eat(8);){if(i)i=!1;else if(this.expect(12),this.eat(8))break;const s=this.isContextual(130),n=this.match(133),o=this.startNode();o.local=this.parseModuleExportName(),e.push(this.parseExportSpecifier(o,n,t,s))}return e}parseExportSpecifier(t,e,i,s){return this.eatContextual(93)?t.exported=this.parseModuleExportName():e?t.exported=function(t){const{type:e,start:i,end:s,loc:n,range:o,extra:a}=t;if("Placeholder"===e)return function(t){return ne(t)}(t);const r=Object.create(se);return r.type=e,r.start=i,r.end=s,r.loc=n,r.range=o,void 0!==t.raw?r.raw=t.raw:r.extra=a,r.value=t.value,r}(t.local):t.exported||(t.exported=ne(t.local)),this.finishNode(t,"ExportSpecifier")}parseModuleExportName(){if(this.match(133)){const t=this.parseStringLiteral(this.state.value),e=t.value.match(ke);return e&&this.raise(L.ModuleExportNameHasLoneSurrogate,t,{surrogateCharCode:e[0].charCodeAt(0)}),t}return this.parseIdentifier(!0)}isJSONModuleImport(t){return null!=t.assertions&&t.assertions.some((({key:t,value:e})=>"json"===e.value&&("Identifier"===t.type?"type"===t.name:"type"===t.value)))}checkImportReflection(t){const{specifiers:e}=t,i=1===e.length?e[0].type:null;if("source"===t.phase)"ImportDefaultSpecifier"!==i&&this.raise(L.SourcePhaseImportRequiresDefault,e[0].loc.start);else if("defer"===t.phase)"ImportNamespaceSpecifier"!==i&&this.raise(L.DeferImportRequiresNamespace,e[0].loc.start);else if(t.module){var s;"ImportDefaultSpecifier"!==i&&this.raise(L.ImportReflectionNotBinding,e[0].loc.start),(null==(s=t.assertions)?void 0:s.length)>0&&this.raise(L.ImportReflectionHasAssertion,e[0].loc.start)}}checkJSONModuleImport(t){if(this.isJSONModuleImport(t)&&"ExportAllDeclaration"!==t.type){const{specifiers:e}=t;if(null!=e){const t=e.find((t=>{let e;if("ExportSpecifier"===t.type?e=t.local:"ImportSpecifier"===t.type&&(e=t.imported),void 0!==e)return"Identifier"===e.type?"default"!==e.name:"default"!==e.value}));void 0!==t&&this.raise(L.ImportJSONBindingNotDefault,t.loc.start)}}}isPotentialImportPhase(t){return!t&&(this.isContextual(105)||this.isContextual(97)||this.isContextual(127))}applyImportPhase(t,e,i,s){e||("module"===i?(this.expectPlugin("importReflection",s),t.module=!0):this.hasPlugin("importReflection")&&(t.module=!1),"source"===i?(this.expectPlugin("sourcePhaseImports",s),t.phase="source"):"defer"===i?(this.expectPlugin("deferredImportEvaluation",s),t.phase="defer"):this.hasPlugin("sourcePhaseImports")&&(t.phase=null))}parseMaybeImportPhase(t,e){if(!this.isPotentialImportPhase(e))return this.applyImportPhase(t,e,null),null;const i=this.parseIdentifier(!0),{type:s}=this.state;return(E(s)?98!==s||102===this.lookaheadCharCode():12!==s)?(this.resetPreviousIdentifierLeadingComments(i),this.applyImportPhase(t,e,i.name,i.loc.start),null):(this.applyImportPhase(t,e,null),i)}isPrecedingIdImportPhase(t){const{type:e}=this.state;return X(e)?98!==e||102===this.lookaheadCharCode():12!==e}parseImport(t){return this.match(133)?this.parseImportSourceAndAttributes(t):this.parseImportSpecifiersAndAfter(t,this.parseMaybeImportPhase(t,!1))}parseImportSpecifiersAndAfter(t,e){t.specifiers=[];const i=!this.maybeParseDefaultImportSpecifier(t,e)||this.eat(12),s=i&&this.maybeParseStarImportSpecifier(t);return i&&!s&&this.parseNamedImportSpecifiers(t),this.expectContextual(98),this.parseImportSourceAndAttributes(t)}parseImportSourceAndAttributes(t){return null!=t.specifiers||(t.specifiers=[]),t.source=this.parseImportSource(),this.maybeParseImportAttributes(t),this.checkImportReflection(t),this.checkJSONModuleImport(t),this.semicolon(),this.finishNode(t,"ImportDeclaration")}parseImportSource(){return this.match(133)||this.unexpected(),this.parseExprAtom()}parseImportSpecifierLocal(t,e,i){e.local=this.parseIdentifier(),t.specifiers.push(this.finishImportSpecifier(e,i))}finishImportSpecifier(t,e,i=8201){return this.checkLVal(t.local,{in:{type:e},binding:i}),this.finishNode(t,e)}parseImportAttributes(){this.expect(5);const t=[],e=new Set;do{if(this.match(8))break;const i=this.startNode(),s=this.state.value;if(e.has(s)&&this.raise(L.ModuleAttributesWithDuplicateKeys,this.state.startLoc,{key:s}),e.add(s),this.match(133)?i.key=this.parseStringLiteral(s):i.key=this.parseIdentifier(!0),this.expect(14),!this.match(133))throw this.raise(L.ModuleAttributeInvalidValue,this.state.startLoc);i.value=this.parseStringLiteral(this.state.value),t.push(this.finishNode(i,"ImportAttribute"))}while(this.eat(12));return this.expect(8),t}parseModuleAttributes(){const t=[],e=new Set;do{const i=this.startNode();if(i.key=this.parseIdentifier(!0),"type"!==i.key.name&&this.raise(L.ModuleAttributeDifferentFromType,i.key),e.has(i.key.name)&&this.raise(L.ModuleAttributesWithDuplicateKeys,i.key,{key:i.key.name}),e.add(i.key.name),this.expect(14),!this.match(133))throw this.raise(L.ModuleAttributeInvalidValue,this.state.startLoc);i.value=this.parseStringLiteral(this.state.value),t.push(this.finishNode(i,"ImportAttribute"))}while(this.eat(12));return t}maybeParseImportAttributes(t){let e,i=!1;if(this.match(76)){if(this.hasPrecedingLineBreak()&&40===this.lookaheadCharCode())return;this.next(),this.hasPlugin("moduleAttributes")?e=this.parseModuleAttributes():(this.expectImportAttributesPlugin(),e=this.parseImportAttributes()),i=!0}else if(this.isContextual(94)&&!this.hasPrecedingLineBreak())this.hasPlugin("importAttributes")?(!0!==this.getPluginOption("importAttributes","deprecatedAssertSyntax")&&this.raise(L.ImportAttributesUseAssert,this.state.startLoc),this.addExtra(t,"deprecatedAssertSyntax",!0)):this.expectOnePlugin(["importAttributes","importAssertions"]),this.next(),e=this.parseImportAttributes();else if(this.hasPlugin("importAttributes")||this.hasPlugin("importAssertions"))e=[];else{if(!this.hasPlugin("moduleAttributes"))return;e=[]}!i&&this.hasPlugin("importAssertions")?t.assertions=e:t.attributes=e}maybeParseDefaultImportSpecifier(t,e){if(e){const i=this.startNodeAtNode(e);return i.local=e,t.specifiers.push(this.finishImportSpecifier(i,"ImportDefaultSpecifier")),!0}return!!E(this.state.type)&&(this.parseImportSpecifierLocal(t,this.startNode(),"ImportDefaultSpecifier"),!0)}maybeParseStarImportSpecifier(t){if(this.match(55)){const e=this.startNode();return this.next(),this.expectContextual(93),this.parseImportSpecifierLocal(t,e,"ImportNamespaceSpecifier"),!0}return!1}parseNamedImportSpecifiers(t){let e=!0;for(this.expect(5);!this.eat(8);){if(e)e=!1;else{if(this.eat(14))throw this.raise(L.DestructureNamedImport,this.state.startLoc);if(this.expect(12),this.eat(8))break}const i=this.startNode(),s=this.match(133),n=this.isContextual(130);i.imported=this.parseModuleExportName();const o=this.parseImportSpecifier(i,s,"type"===t.importKind||"typeof"===t.importKind,n,void 0);t.specifiers.push(o)}}parseImportSpecifier(t,e,i,s,n){if(this.eatContextual(93))t.local=this.parseIdentifier();else{const{imported:i}=t;if(e)throw this.raise(L.ImportBindingIsString,t,{importName:i.value});this.checkReservedWord(i.name,t.loc.start,!0,!0),t.local||(t.local=ne(i))}return this.finishImportSpecifier(t,"ImportSpecifier",n)}isThisParam(t){return"Identifier"===t.type&&"this"===t.name}}class Je extends Fe{constructor(t,e){super(t=function(t){if(null==t)return Object.assign({},Se);if(null!=t.annexB&&!1!==t.annexB)throw new Error("The `annexB` option can only be set to `false`.");const e={};for(const s of Object.keys(Se)){var i;e[s]=null!=(i=t[s])?i:Se[s]}return e}(t),e),this.options=t,this.initializeScopes(),this.plugins=function(t){const e=new Map;for(const i of t){const[t,s]=Array.isArray(i)?i:[i,{}];e.has(t)||e.set(t,s||{})}return e}(this.options.plugins),this.filename=t.sourceFilename}getScopeHandler(){return yt}parse(){this.enterInitialScopes();const t=this.startNode(),e=this.startNode();return this.nextToken(),t.errors=null,this.parseTopLevel(t,e),t.errors=this.state.errors,t.comments.length=this.state.commentsLen,t}}!function(t){const e={};for(const i of Object.keys(t))e[i]=$(t[i])}(J);function Xe(t,e){let i=Je;return null!=t&&t.plugins&&(function(t){if(Ne(t,"decorators")){if(Ne(t,"decorators-legacy"))throw new Error("Cannot use the decorators and decorators-legacy plugin together");const e=xe(t,"decorators","decoratorsBeforeExport");if(null!=e&&"boolean"!=typeof e)throw new Error("'decoratorsBeforeExport' must be a boolean, if specified.");const i=xe(t,"decorators","allowCallParenthesized");if(null!=i&&"boolean"!=typeof i)throw new Error("'allowCallParenthesized' must be a boolean.")}if(Ne(t,"flow")&&Ne(t,"typescript"))throw new Error("Cannot combine flow and typescript plugins.");if(Ne(t,"placeholders")&&Ne(t,"v8intrinsic"))throw new Error("Cannot combine placeholders and v8intrinsic plugins.");if(Ne(t,"pipelineOperator")){const e=xe(t,"pipelineOperator","proposal");if(!Ye.includes(e)){const t=Ye.map((t=>`"${t}"`)).join(", ");throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${t}.`)}const i=Ne(t,["recordAndTuple",{syntaxType:"hash"}]);if("hack"===e){if(Ne(t,"placeholders"))throw new Error("Cannot combine placeholders plugin and Hack-style pipes.");if(Ne(t,"v8intrinsic"))throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");const e=xe(t,"pipelineOperator","topicToken");if(!Re.includes(e)){const t=Re.map((t=>`"${t}"`)).join(", ");throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${t}.`)}if("#"===e&&i)throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "hack", topicToken: "#" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.')}else if("smart"===e&&i)throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "smart" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.')}if(Ne(t,"moduleAttributes")){if(Ne(t,"importAssertions")||Ne(t,"importAttributes"))throw new Error("Cannot combine importAssertions, importAttributes and moduleAttributes plugins.");if("may-2020"!==xe(t,"moduleAttributes","version"))throw new Error("The 'moduleAttributes' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is 'may-2020'.")}if(Ne(t,"importAssertions")&&Ne(t,"importAttributes"))throw new Error("Cannot combine importAssertions and importAttributes plugins.");if(Ne(t,"recordAndTuple")&&null!=xe(t,"recordAndTuple","syntaxType")&&!He.includes(xe(t,"recordAndTuple","syntaxType")))throw new Error("The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: "+He.map((t=>`'${t}'`)).join(", "));if(Ne(t,"asyncDoExpressions")&&!Ne(t,"doExpressions")){const t=new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");throw t.missingPlugins="doExpressions",t}if(Ne(t,"optionalChainingAssign")&&"2023-07"!==xe(t,"optionalChainingAssign","version"))throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is '2023-07'.")}(t.plugins),i=function(t){const e=Ae.filter((e=>Ne(t,e))),i=e.join("/");let s=Ee[i];if(!s){s=Je;for(const t of e)s=ge[t](s);Ee[i]=s}return s}(t.plugins)),new i(t,e)}const Ee={};e.K0=function(t,e){var i;if("unambiguous"!==(null==(i=e)?void 0:i.sourceType))return Xe(e,t).parse();e=Object.assign({},e);try{e.sourceType="module";const i=Xe(e,t),s=i.parse();if(i.sawUnambiguousESM)return s;if(i.ambiguousScriptDifferentAst)try{return e.sourceType="script",Xe(e,t).parse()}catch(t){}else s.program.sourceType="script";return s}catch(i){try{return e.sourceType="script",Xe(e,t).parse()}catch(t){}throw i}}}},e={};function i(s){var n=e[s];if(void 0!==n)return n.exports;var o=e[s]={exports:{}};return t[s](o,o.exports,i),o.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t={};i.r(t),i.d(t,{Decoder:()=>wt,Encoder:()=>Mt,PacketType:()=>Lt,protocol:()=>yt});const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=new Uint8Array(new ArrayBuffer(256));for(let t=0;t<64;t++)s[e.charCodeAt(t)]=t;const n={encode:function(t){let i="",s="";const n=new Uint8Array(t);for(let t=0;t>18&63]+e[s>>12&63]+e[s>>6&63]+e[63&s]}const o=n.length%3;return 1===o?(s="==",i=i.slice(0,-2)):2===o&&(s="=",i=i.slice(0,-1)),i+s},decode:function(t){let e=0;t.endsWith("==")?e=2:t.endsWith("=")&&(e=1);const i=.75*t.length-e,n=new ArrayBuffer(i),o=new Uint8Array(n);let a=0;for(let e=0;e>16&255,o[a++]=i>>8&255,o[a++]=255&i}return n}};Object.setPrototypeOf(n,null),Object.freeze(n);const o=n,a={encode:function(t){const e=Array.from(t).map((t=>t.codePointAt(0)||0)),i=[];for(const t of e)t<=127?i.push(t):t<=2047?(i.push(t>>6|192),i.push(63&t|128)):t<=65535?(i.push(t>>12|224),i.push(t>>6&63|128),i.push(63&t|128)):t<=1114111&&(i.push(t>>18|240),i.push(t>>12&63|128),i.push(t>>6&63|128),i.push(63&t|128));return new Uint8Array(i).buffer},decode:function(t){const e=new Uint8Array(t);let i="",s=0;for(;s{c[h[t]]=t}));const d={type:"error",data:"parser error"},I="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),u="function"==typeof ArrayBuffer,p=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,b=({type:t,data:e},i,s)=>I&&e instanceof Blob?i?s(e):m(e,s):u&&(e instanceof ArrayBuffer||p(e))?i?s(e):m(new Blob([e]),s):s(h[t]+(e||"")),m=(t,e)=>{const i=new FileReader;return i.onload=function(){const t=i.result.split(",")[1];e("b"+(t||""))},i.readAsDataURL(t)};function y(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let L;const M="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<64;t++)M["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(t)]=t;const W="function"==typeof ArrayBuffer,w=(t,e)=>{if("string"!=typeof t)return{type:"message",data:j(t,e)};const i=t.charAt(0);return"b"===i?{type:"message",data:v(t.substring(1),e)}:c[i]?t.length>1?{type:c[i],data:t.substring(1)}:{type:c[i]}:d},v=(t,e)=>{if(W){const i=(t=>{let e,i,s,n,o,a=.75*t.length,r=t.length,l=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);const h=new ArrayBuffer(a),c=new Uint8Array(h);for(e=0;e>4,c[l++]=(15&s)<<4|n>>2,c[l++]=(3&n)<<6|63&o;return h})(t);return j(i,e)}return{base64:!0,data:t}},j=(t,e)=>"blob"===e?t instanceof Blob?t:new Blob([t]):t instanceof ArrayBuffer?t:t.buffer,Z=String.fromCharCode(30);let C;function G(t){return t.reduce(((t,e)=>t+e.length),0)}function f(t,e){if(t[0].length===e)return t.shift();const i=new Uint8Array(e);let s=0;for(let n=0;n(t.hasOwnProperty(i)&&(e[i]=t[i]),e)),{})}const R=x.setTimeout,H=x.clearTimeout;function g(t,e){e.useNativeTimers?(t.setTimeoutFn=R.bind(x),t.clearTimeoutFn=H.bind(x)):(t.setTimeoutFn=x.setTimeout.bind(x),t.clearTimeoutFn=x.clearTimeout.bind(x))}class A extends Error{constructor(t,e,i){super(t),this.description=e,this.context=i,this.type="TransportError"}}class S extends N{constructor(t){super(),this.writable=!1,g(this,t),this.opts=t,this.query=t.query,this.socket=t.socket}onError(t,e,i){return super.emitReserved("error",new A(t,e,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=w(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(t){const e=function(t){let e="";for(let i in t)t.hasOwnProperty(i)&&(e.length&&(e+="&"),e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i]));return e}(t);return e.length?"?"+e:""}}const z="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),V=64,T={};let k,O=0,F=0;function J(t){let e="";do{e=z[t%V]+e,t=Math.floor(t/V)}while(t>0);return e}function X(){const t=J(+new Date);return t!==k?(O=0,k=t):t+"."+J(O++)}for(;F{var t;3===i.readyState&&(null===(t=this.opts.cookieJar)||void 0===t||t.parseCookies(i)),4===i.readyState&&(200===i.status||1223===i.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof i.status?i.status:0)}),0))},i.send(this.data)}catch(t){return void this.setTimeoutFn((()=>{this.onError(t)}),0)}"undefined"!=typeof document&&(this.index=_.requestsCount++,_.requests[this.index]=this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=B,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete _.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}function Q(){for(let t in _.requests)_.requests.hasOwnProperty(t)&&_.requests[t].abort()}_.requestsCount=0,_.requests={},"undefined"!=typeof document&&("function"==typeof attachEvent?attachEvent("onunload",Q):"function"==typeof addEventListener&&addEventListener("onpagehide"in x?"pagehide":"unload",Q,!1));const q="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),$=x.WebSocket||x.MozWebSocket,K="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),tt={websocket:class extends S{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),e=this.opts.protocols,i=K?{}:Y(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=K?new $(t,e,i):e?new $(t,e):new $(t)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e{try{this.ws.send(t)}catch(t){}s&&q((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=X()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}check(){return!!$}},webtransport:class extends S{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((t=>{this.onError("webtransport error",t)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((t=>{const e=function(t,e){C||(C=new TextDecoder);const i=[];let s=0,n=-1,o=!1;return new TransformStream({transform(a,r){for(i.push(a);;){if(0===s){if(G(i)<1)break;const t=f(i,1);o=128==(128&t[0]),n=127&t[0],s=n<126?3:126===n?1:2}else if(1===s){if(G(i)<2)break;const t=f(i,2);n=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),s=3}else if(2===s){if(G(i)<8)break;const t=f(i,8),e=new DataView(t.buffer,t.byteOffset,t.length),o=e.getUint32(0);if(o>Math.pow(2,21)-1){r.enqueue(d);break}n=o*Math.pow(2,32)+e.getUint32(4),s=3}else{if(G(i)t){r.enqueue(d);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=t.readable.pipeThrough(e).getReader(),s=new TransformStream({transform(t,e){!function(t,e){I&&t.data instanceof Blob?t.data.arrayBuffer().then(y).then(e):u&&(t.data instanceof ArrayBuffer||p(t.data))?e(y(t.data)):b(t,!1,(t=>{L||(L=new TextEncoder),e(L.encode(t))}))}(t,(i=>{const s=i.length;let n;if(s<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,s);else if(s<65536){n=new Uint8Array(3);const t=new DataView(n.buffer);t.setUint8(0,126),t.setUint16(1,s)}else{n=new Uint8Array(9);const t=new DataView(n.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(s))}t.data&&"string"!=typeof t.data&&(n[0]|=128),e.enqueue(n),e.enqueue(i)}))}});s.readable.pipeTo(t.writable),this.writer=s.writable.getWriter();const n=()=>{i.read().then((({done:t,value:e})=>{t||(this.onPacket(e),n())})).catch((t=>{}))};n();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then((()=>this.onOpen()))}))})))}write(t){this.writable=!1;for(let e=0;e{s&&q((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var t;null===(t=this.transport)||void 0===t||t.close()}},polling:class extends S{constructor(t){if(super(t),this.polling=!1,"undefined"!=typeof location){const e="https:"===location.protocol;let i=location.port;i||(i=e?"443":"80"),this.xd="undefined"!=typeof location&&t.hostname!==location.hostname||i!==t.port}const e=t&&t.forceBase64;this.supportsBinary=P&&!e,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this.polling||!this.writable){let t=0;this.polling&&(t++,this.once("pollComplete",(function(){--t||e()}))),this.writable||(t++,this.once("drain",(function(){--t||e()})))}else e()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){((t,e)=>{const i=t.split(Z),s=[];for(let t=0;t{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const t=()=>{this.write([{type:"close"}])};"open"===this.readyState?t():this.once("open",t)}write(t){this.writable=!1,((t,e)=>{const i=t.length,s=new Array(i);let n=0;t.forEach(((t,o)=>{b(t,!1,(t=>{s[o]=t,++n===i&&e(s.join(Z))}))}))})(t,(t=>{this.doWrite(t,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=X()),this.supportsBinary||e.sid||(e.b64=1),this.createUri(t,e)}request(t={}){return Object.assign(t,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new _(this.uri(),t)}doWrite(t,e){const i=this.request({method:"POST",data:t});i.on("success",e),i.on("error",((t,e)=>{this.onError("xhr post error",t,e)}))}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",((t,e)=>{this.onError("xhr poll error",t,e)})),this.pollXhr=t}}},et=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,it=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function st(t){if(t.length>2e3)throw"URI too long";const e=t,i=t.indexOf("["),s=t.indexOf("]");-1!=i&&-1!=s&&(t=t.substring(0,i)+t.substring(i,s).replace(/:/g,";")+t.substring(s,t.length));let n=et.exec(t||""),o={},a=14;for(;a--;)o[it[a]]=n[a]||"";return-1!=i&&-1!=s&&(o.source=e,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=function(t,e){const i=e.replace(/\/{2,9}/g,"/").split("/");return"/"!=e.slice(0,1)&&0!==e.length||i.splice(0,1),"/"==e.slice(-1)&&i.splice(i.length-1,1),i}(0,o.path),o.queryKey=function(t,e){const i={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,s){e&&(i[e]=s)})),i}(0,o.query),o}class nt extends N{constructor(t,e={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],t&&"object"==typeof t&&(e=t,t=null),t?(t=st(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=st(e.host).host),g(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=e.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(t){let e={},i=t.split("&");for(let t=0,s=i.length;t{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);const i=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new tt[t](i)}open(){let t;if(this.opts.rememberUpgrade&&nt.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(t=>this.onClose("transport close",t)))}probe(t){let e=this.createTransport(t),i=!1;nt.priorWebsocketSuccess=!1;const s=()=>{i||(e.send([{type:"ping",data:"probe"}]),e.once("packet",(t=>{if(!i)if("pong"===t.type&&"probe"===t.data){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;nt.priorWebsocketSuccess="websocket"===e.name,this.transport.pause((()=>{i||"closed"!==this.readyState&&(h(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())}))}else{const t=new Error("probe error");t.transport=e.name,this.emitReserved("upgradeError",t)}})))};function n(){i||(i=!0,h(),e.close(),e=null)}const o=t=>{const i=new Error("probe error: "+t);i.transport=e.name,n(),this.emitReserved("upgradeError",i)};function a(){o("transport closed")}function r(){o("socket closed")}function l(t){e&&t.name!==e.name&&n()}const h=()=>{e.removeListener("open",s),e.removeListener("error",o),e.removeListener("close",a),this.off("close",r),this.off("upgrading",l)};e.once("open",s),e.once("error",o),e.once("close",a),this.once("close",r),this.once("upgrading",l),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==t?this.setTimeoutFn((()=>{i||e.open()}),200):e.open()}onOpen(){if(this.readyState="open",nt.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let t=0;const e=this.upgrades.length;for(;t{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let i=0;i=57344?i+=3:(s++,i+=4);return i}(e):Math.ceil(1.33*(e.byteLength||e.size))),i>0&&t>this.maxPayload)return this.writeBuffer.slice(0,i);t+=2}var e;return this.writeBuffer}write(t,e,i){return this.sendPacket("message",t,e,i),this}send(t,e,i){return this.sendPacket("message",t,e,i),this}sendPacket(t,e,i,s){if("function"==typeof e&&(s=e,e=void 0),"function"==typeof i&&(s=i,i=null),"closing"===this.readyState||"closed"===this.readyState)return;(i=i||{}).compress=!1!==i.compress;const n={type:t,data:e,options:i};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),s&&this.once("flush",s),this.flush()}close(){const t=()=>{this.onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},i=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?i():t()})):this.upgrading?i():t()),this}onError(t){nt.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let i=0;const s=t.length;for(;i"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,rt=Object.prototype.toString,lt="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===rt.call(Blob),ht="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===rt.call(File);function ct(t){return ot&&(t instanceof ArrayBuffer||at(t))||lt&&t instanceof Blob||ht&&t instanceof File}function dt(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,i=t.length;e=0&&t.num{delete this.acks[t];for(let e=0;e{this.io.clearTimeoutFn(n),e.apply(this,[null,...t])}}emitWithAck(t,...e){const i=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((s,n)=>{e.push(((t,e)=>i?t?n(t):s(e):s(t))),this.emit(t,...e)}))}_addToQueue(t){let e;"function"==typeof t[t.length-1]&&(e=t.pop());const i={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push(((t,...s)=>{if(i===this._queue[0])return null!==t?i.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(t)):(this._queue.shift(),e&&e(null,...s)),i.pending=!1,this._drainQueue()})),this._queue.push(i),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||0===this._queue.length)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){"function"==typeof this.auth?this.auth((t=>{this._sendConnectPacket(t)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:Lt.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e)}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case Lt.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Lt.EVENT:case Lt.BINARY_EVENT:this.onevent(t);break;case Lt.ACK:case Lt.BINARY_ACK:this.onack(t);break;case Lt.DISCONNECT:this.ondisconnect();break;case Lt.CONNECT_ERROR:this.destroy();const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){const e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const i of e)i.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&"string"==typeof t[t.length-1]&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let i=!1;return function(...s){i||(i=!0,e.packet({type:Lt.ACK,id:t,data:s}))}}onack(t){const e=this.acks[t.id];"function"==typeof e&&(e.apply(this,t.data),delete this.acks[t.id])}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((t=>this.emitEvent(t))),this.receiveBuffer=[],this.sendBuffer.forEach((t=>{this.notifyOutgoingListeners(t),this.packet(t)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((t=>t())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Lt.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let i=0;i0&&t.jitter<=1?t.jitter:0,this.attempts=0}Gt.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),i=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-i:t+i}return 0|Math.min(t,this.max)},Gt.prototype.reset=function(){this.attempts=0},Gt.prototype.setMin=function(t){this.ms=t},Gt.prototype.setMax=function(t){this.max=t},Gt.prototype.setJitter=function(t){this.jitter=t};class ft extends N{constructor(e,i){var s;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(i=e,e=void 0),(i=i||{}).path=i.path||"/socket.io",this.opts=i,g(this,i),this.reconnection(!1!==i.reconnection),this.reconnectionAttempts(i.reconnectionAttempts||1/0),this.reconnectionDelay(i.reconnectionDelay||1e3),this.reconnectionDelayMax(i.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(s=i.randomizationFactor)&&void 0!==s?s:.5),this.backoff=new Gt({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==i.timeout?2e4:i.timeout),this._readyState="closed",this.uri=e;const n=i.parser||t;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==i.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new nt(this.uri,this.opts);const e=this.engine,i=this;this._readyState="opening",this.skipReconnect=!1;const s=jt(e,"open",(function(){i.onopen(),t&&t()})),n=e=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",e),t?t(e):this.maybeReconnectOnOpen()},o=jt(e,"error",n);if(!1!==this._timeout){const t=this._timeout,i=this.setTimeoutFn((()=>{s(),n(new Error("timeout")),e.close()}),t);this.opts.autoUnref&&i.unref(),this.subs.push((()=>{this.clearTimeoutFn(i)}))}return this.subs.push(s),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(jt(t,"ping",this.onping.bind(this)),jt(t,"data",this.ondata.bind(this)),jt(t,"error",this.onerror.bind(this)),jt(t,"close",this.onclose.bind(this)),jt(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}ondecoded(t){q((()=>{this.emitReserved("packet",t)}),this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let i=this.nsps[t];return i?this._autoConnect&&!i.active&&i.connect():(i=new Ct(this,t,e),this.nsps[t]=i),i}_destroy(t){const e=Object.keys(this.nsps);for(const t of e)if(this.nsps[t].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let i=0;it())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const i=this.setTimeoutFn((()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((e=>{e?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):t.onreconnect()})))}),e);this.opts.autoUnref&&i.unref(),this.subs.push((()=>{this.clearTimeoutFn(i)}))}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Nt={};function xt(t,e){"object"==typeof t&&(e=t,t=void 0);const i=function(t,e="",i){let s=t;i=i||"undefined"!=typeof location&&location,null==t&&(t=i.protocol+"//"+i.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?i.protocol+t:i.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==i?i.protocol+"//"+t:"https://"+t),s=st(t)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const n=-1!==s.host.indexOf(":")?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+n+":"+s.port+e,s.href=s.protocol+"://"+n+(i&&i.port===s.port?"":":"+s.port),s}(t,(e=e||{}).path||"/socket.io"),s=i.source,n=i.id,o=i.path,a=Nt[n]&&o in Nt[n].nsps;let r;return e.forceNew||e["force new connection"]||!1===e.multiplex||a?r=new ft(s,e):(Nt[n]||(Nt[n]=new ft(s,e)),r=Nt[n]),i.query&&!e.query&&(e.query=i.queryKey),r.socket(i.path,e)}Object.assign(xt,{Manager:ft,Socket:Ct,io:xt,connect:xt});const Yt=function(t,e){if(!t)throw Rt(e)},Rt=function(t){return new Error("Firebase Database (${JSCORE_VERSION}) INTERNAL ASSERT FAILED: "+t)},Ht=function(t){const e=[];let i=0;for(let s=0;s>6|192,e[i++]=63&n|128):55296==(64512&n)&&s+1>18|240,e[i++]=n>>12&63|128,e[i++]=n>>6&63|128,e[i++]=63&n|128):(e[i++]=n>>12|224,e[i++]=n>>6&63|128,e[i++]=63&n|128)}return e},gt={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const i=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,s=[];for(let e=0;e>2,c=(3&n)<<4|a>>4;let d=(15&a)<<2|l>>6,I=63&l;r||(I=64,o||(d=64)),s.push(i[h],i[c],i[d],i[I])}return s.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(Ht(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):function(t){const e=[];let i=0,s=0;for(;i191&&n<224){const o=t[i++];e[s++]=String.fromCharCode((31&n)<<6|63&o)}else if(n>239&&n<365){const o=((7&n)<<18|(63&t[i++])<<12|(63&t[i++])<<6|63&t[i++])-65536;e[s++]=String.fromCharCode(55296+(o>>10)),e[s++]=String.fromCharCode(56320+(1023&o))}else{const o=t[i++],a=t[i++];e[s++]=String.fromCharCode((15&n)<<12|(63&o)<<6|63&a)}}return e.join("")}(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const i=e?this.charToByteMapWebSafe_:this.charToByteMap_,s=[];for(let e=0;e>4;if(s.push(l),64!==a){const t=o<<4&240|a>>2;if(s.push(t),64!==r){const t=a<<6&192|r;s.push(t)}}}return s},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};class At extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const St=function(t){const e=Ht(t);return gt.encodeByteArray(e,!0)},zt=function(t){return St(t).replace(/\./g,"")},Vt=function(t){try{return gt.decodeString(t,!0)}catch(t){console.error("base64Decode failed: ",t)}return null};function Tt(t){return kt(void 0,t)}function kt(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(const i in e)e.hasOwnProperty(i)&&"__proto__"!==i&&(t[i]=kt(t[i],e[i]));return t}const Ot=()=>{try{return function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==i.g)return i.g;throw new Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__||(()=>{if("undefined"==typeof process||void 0===process.env)return;const t=process.env.__FIREBASE_DEFAULTS__;return t?JSON.parse(t):void 0})()||(()=>{if("undefined"==typeof document)return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(t){return}const e=t&&Vt(t[1]);return e&&JSON.parse(e)})()}catch(t){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`)}},Ft=()=>{var t;return null===(t=Ot())||void 0===t?void 0:t.config};class Jt{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}wrapCallback(t){return(e,i)=>{e?this.reject(e):this.resolve(i),"function"==typeof t&&(this.promise.catch((()=>{})),1===t.length?t(e):t(e,i))}}}function Xt(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test("undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:"")}function Et(){try{return"object"==typeof indexedDB}catch(t){return!1}}function Dt(){return new Promise(((t,e)=>{try{let i=!0;const s="validate-browser-context-for-indexeddb-analytics-module",n=self.indexedDB.open(s);n.onsuccess=()=>{n.result.close(),i||self.indexedDB.deleteDatabase(s),t(!0)},n.onupgradeneeded=()=>{i=!1},n.onerror=()=>{var t;e((null===(t=n.error)||void 0===t?void 0:t.message)||"")}}catch(t){e(t)}}))}class Ut extends Error{constructor(t,e,i){super(e),this.code=t,this.customData=i,this.name="FirebaseError",Object.setPrototypeOf(this,Ut.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Bt.prototype.create)}}class Bt{constructor(t,e,i){this.service=t,this.serviceName=e,this.errors=i}create(t,...e){const i=e[0]||{},s=`${this.service}/${t}`,n=this.errors[t],o=n?function(t,e){return t.replace(Pt,((t,i)=>{const s=e[i];return null!=s?String(s):`<${i}?>`}))}(n,i):"Error",a=`${this.serviceName}: ${o} (${s}).`;return new Ut(s,a,i)}}const Pt=/\{\$([^}]+)}/g;function _t(t){return JSON.parse(t)}function Qt(t){return JSON.stringify(t)}const qt=function(t){let e={},i={},s={},n="";try{const o=t.split(".");e=_t(Vt(o[0])||""),i=_t(Vt(o[1])||""),n=o[2],s=i.d||{},delete i.d}catch(t){}return{header:e,claims:i,data:s,signature:n}};function $t(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Kt(t,e){return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0}function te(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function ee(t,e,i){const s={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=e.call(i,t[n],n,t));return s}function ie(t,e){if(t===e)return!0;const i=Object.keys(t),s=Object.keys(e);for(const n of i){if(!s.includes(n))return!1;const i=t[n],o=e[n];if(se(i)&&se(o)){if(!ie(i,o))return!1}else if(i!==o)return!1}for(const t of s)if(!i.includes(t))return!1;return!0}function se(t){return null!==t&&"object"==typeof t}class ne{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(let t=1;t>>31)}let s,n,o=this.chain_[0],a=this.chain_[1],r=this.chain_[2],l=this.chain_[3],h=this.chain_[4];for(let t=0;t<80;t++){t<40?t<20?(s=l^a&(r^l),n=1518500249):(s=a^r^l,n=1859775393):t<60?(s=a&r|l&(a|r),n=2400959708):(s=a^r^l,n=3395469782);const e=(o<<5|o>>>27)+s+h+n+i[t]&4294967295;h=l,l=r,r=4294967295&(a<<30|a>>>2),a=o,o=e}this.chain_[0]=this.chain_[0]+o&4294967295,this.chain_[1]=this.chain_[1]+a&4294967295,this.chain_[2]=this.chain_[2]+r&4294967295,this.chain_[3]=this.chain_[3]+l&4294967295,this.chain_[4]=this.chain_[4]+h&4294967295}update(t,e){if(null==t)return;void 0===e&&(e=t.length);const i=e-this.blockSize;let s=0;const n=this.buf_;let o=this.inbuf_;for(;s=56;t--)this.buf_[t]=255&e,e/=256;this.compress_(this.buf_);let i=0;for(let e=0;e<5;e++)for(let s=24;s>=0;s-=8)t[i]=this.chain_[e]>>s&255,++i;return t}}function oe(t,e){return`${t} failed: ${e} argument `}const ae=function(t){let e=0;for(let i=0;i=55296&&s<=56319?(e+=4,i++):e+=3}return e},re=1e3,le=2,he=144e5,ce=.5;function de(t,e=re,i=le){const s=e*Math.pow(i,t),n=Math.round(ce*s*(Math.random()-.5)*2);return Math.min(he,s+n)}function Ie(t){return t&&t._delegate?t._delegate:t}class ue{constructor(t,e,i){this.name=t,this.instanceFactory=e,this.type=i,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(t){return this.instantiationMode=t,this}setMultipleInstances(t){return this.multipleInstances=t,this}setServiceProps(t){return this.serviceProps=t,this}setInstanceCreatedCallback(t){return this.onInstanceCreated=t,this}}const pe="[DEFAULT]";class be{constructor(t,e){this.name=t,this.container=e,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(t){const e=this.normalizeInstanceIdentifier(t);if(!this.instancesDeferred.has(e)){const t=new Jt;if(this.instancesDeferred.set(e,t),this.isInitialized(e)||this.shouldAutoInitialize())try{const i=this.getOrInitializeService({instanceIdentifier:e});i&&t.resolve(i)}catch(t){}}return this.instancesDeferred.get(e).promise}getImmediate(t){var e;const i=this.normalizeInstanceIdentifier(null==t?void 0:t.identifier),s=null!==(e=null==t?void 0:t.optional)&&void 0!==e&&e;if(!this.isInitialized(i)&&!this.shouldAutoInitialize()){if(s)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:i})}catch(t){if(s)return null;throw t}}getComponent(){return this.component}setComponent(t){if(t.name!==this.name)throw Error(`Mismatching Component ${t.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=t,this.shouldAutoInitialize()){if(function(t){return"EAGER"===t.instantiationMode}(t))try{this.getOrInitializeService({instanceIdentifier:pe})}catch(t){}for(const[t,e]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(t);try{const t=this.getOrInitializeService({instanceIdentifier:i});e.resolve(t)}catch(t){}}}}clearInstance(t=pe){this.instancesDeferred.delete(t),this.instancesOptions.delete(t),this.instances.delete(t)}async delete(){const t=Array.from(this.instances.values());await Promise.all([...t.filter((t=>"INTERNAL"in t)).map((t=>t.INTERNAL.delete())),...t.filter((t=>"_delete"in t)).map((t=>t._delete()))])}isComponentSet(){return null!=this.component}isInitialized(t=pe){return this.instances.has(t)}getOptions(t=pe){return this.instancesOptions.get(t)||{}}initialize(t={}){const{options:e={}}=t,i=this.normalizeInstanceIdentifier(t.instanceIdentifier);if(this.isInitialized(i))throw Error(`${this.name}(${i}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:i,options:e});for(const[t,e]of this.instancesDeferred.entries())i===this.normalizeInstanceIdentifier(t)&&e.resolve(s);return s}onInit(t,e){var i;const s=this.normalizeInstanceIdentifier(e),n=null!==(i=this.onInitCallbacks.get(s))&&void 0!==i?i:new Set;n.add(t),this.onInitCallbacks.set(s,n);const o=this.instances.get(s);return o&&t(o,s),()=>{n.delete(t)}}invokeOnInitCallbacks(t,e){const i=this.onInitCallbacks.get(e);if(i)for(const s of i)try{s(t,e)}catch(t){}}getOrInitializeService({instanceIdentifier:t,options:e={}}){let i=this.instances.get(t);if(!i&&this.component&&(i=this.component.instanceFactory(this.container,{instanceIdentifier:(s=t,s===pe?void 0:s),options:e}),this.instances.set(t,i),this.instancesOptions.set(t,e),this.invokeOnInitCallbacks(i,t),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,t,i)}catch(t){}var s;return i||null}normalizeInstanceIdentifier(t=pe){return this.component?this.component.multipleInstances?t:pe:t}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class me{constructor(t){this.name=t,this.providers=new Map}addComponent(t){const e=this.getProvider(t.name);if(e.isComponentSet())throw new Error(`Component ${t.name} has already been registered with ${this.name}`);e.setComponent(t)}addOrOverwriteComponent(t){this.getProvider(t.name).isComponentSet()&&this.providers.delete(t.name),this.addComponent(t)}getProvider(t){if(this.providers.has(t))return this.providers.get(t);const e=new be(t,this);return this.providers.set(t,e),e}getProviders(){return Array.from(this.providers.values())}}const ye=[];var Le;!function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"}(Le||(Le={}));const Me={debug:Le.DEBUG,verbose:Le.VERBOSE,info:Le.INFO,warn:Le.WARN,error:Le.ERROR,silent:Le.SILENT},We=Le.INFO,we={[Le.DEBUG]:"log",[Le.VERBOSE]:"log",[Le.INFO]:"info",[Le.WARN]:"warn",[Le.ERROR]:"error"},ve=(t,e,...i)=>{if(ee.some((e=>t instanceof e));let Ce,Ge;const fe=new WeakMap,Ne=new WeakMap,xe=new WeakMap,Ye=new WeakMap,Re=new WeakMap;let He={get(t,e,i){if(t instanceof IDBTransaction){if("done"===e)return Ne.get(t);if("objectStoreNames"===e)return t.objectStoreNames||xe.get(t);if("store"===e)return i.objectStoreNames[1]?void 0:i.objectStore(i.objectStoreNames[0])}return Ae(t[e])},set:(t,e,i)=>(t[e]=i,!0),has:(t,e)=>t instanceof IDBTransaction&&("done"===e||"store"===e)||e in t};function ge(t){return"function"==typeof t?(e=t)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(Ge||(Ge=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Se(this),t),Ae(fe.get(this))}:function(...t){return Ae(e.apply(Se(this),t))}:function(t,...i){const s=e.call(Se(this),t,...i);return xe.set(s,t.sort?t.sort():[t]),Ae(s)}:(t instanceof IDBTransaction&&function(t){if(Ne.has(t))return;const e=new Promise(((e,i)=>{const s=()=>{t.removeEventListener("complete",n),t.removeEventListener("error",o),t.removeEventListener("abort",o)},n=()=>{e(),s()},o=()=>{i(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",n),t.addEventListener("error",o),t.addEventListener("abort",o)}));Ne.set(t,e)}(t),Ze(t,Ce||(Ce=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(t,He):t);var e}function Ae(t){if(t instanceof IDBRequest)return function(t){const e=new Promise(((e,i)=>{const s=()=>{t.removeEventListener("success",n),t.removeEventListener("error",o)},n=()=>{e(Ae(t.result)),s()},o=()=>{i(t.error),s()};t.addEventListener("success",n),t.addEventListener("error",o)}));return e.then((e=>{e instanceof IDBCursor&&fe.set(e,t)})).catch((()=>{})),Re.set(e,t),e}(t);if(Ye.has(t))return Ye.get(t);const e=ge(t);return e!==t&&(Ye.set(t,e),Re.set(e,t)),e}const Se=t=>Re.get(t);function ze(t,e,{blocked:i,upgrade:s,blocking:n,terminated:o}={}){const a=indexedDB.open(t,e),r=Ae(a);return s&&a.addEventListener("upgradeneeded",(t=>{s(Ae(a.result),t.oldVersion,t.newVersion,Ae(a.transaction),t)})),i&&a.addEventListener("blocked",(t=>i(t.oldVersion,t.newVersion,t))),r.then((t=>{o&&t.addEventListener("close",(()=>o())),n&&t.addEventListener("versionchange",(t=>n(t.oldVersion,t.newVersion,t)))})).catch((()=>{})),r}const Ve=["get","getKey","getAll","getAllKeys","count"],Te=["put","add","delete","clear"],ke=new Map;function Oe(t,e){if(!(t instanceof IDBDatabase)||e in t||"string"!=typeof e)return;if(ke.get(e))return ke.get(e);const i=e.replace(/FromIndex$/,""),s=e!==i,n=Te.includes(i);if(!(i in(s?IDBIndex:IDBObjectStore).prototype)||!n&&!Ve.includes(i))return;const o=async function(t,...e){const o=this.transaction(t,n?"readwrite":"readonly");let a=o.store;return s&&(a=a.index(e.shift())),(await Promise.all([a[i](...e),n&&o.done]))[0]};return ke.set(e,o),o}var Fe;Fe=He,He={...Fe,get:(t,e,i)=>Oe(t,e)||Fe.get(t,e,i),has:(t,e)=>!!Oe(t,e)||Fe.has(t,e)};class Je{constructor(t){this.container=t}getPlatformInfoString(){return this.container.getProviders().map((t=>{if(function(t){const e=t.getComponent();return"VERSION"===(null==e?void 0:e.type)}(t)){const e=t.getImmediate();return`${e.library}/${e.version}`}return null})).filter((t=>t)).join(" ")}}const Xe="@firebase/app",Ee="0.9.27",De=new je("@firebase/app"),Ue="[DEFAULT]",Be={[Xe]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","fire-js":"fire-js",firebase:"fire-js-all"},Pe=new Map,_e=new Map;function Qe(t,e){try{t.container.addComponent(e)}catch(i){De.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,i)}}function qe(t){const e=t.name;if(_e.has(e))return De.debug(`There were multiple attempts to register component ${e}.`),!1;_e.set(e,t);for(const e of Pe.values())Qe(e,t);return!0}function $e(t,e){const i=t.container.getProvider("heartbeat").getImmediate({optional:!0});return i&&i.triggerHeartbeat(),t.container.getProvider(e)}const Ke=new Bt("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}."});class ti{constructor(t,e,i){this._isDeleted=!1,this._options=Object.assign({},t),this._config=Object.assign({},e),this._name=e.name,this._automaticDataCollectionEnabled=e.automaticDataCollectionEnabled,this._container=i,this.container.addComponent(new ue("app",(()=>this),"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(t){this.checkDestroyed(),this._automaticDataCollectionEnabled=t}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(t){this._isDeleted=t}checkDestroyed(){if(this.isDeleted)throw Ke.create("app-deleted",{appName:this._name})}}function ei(t,e={}){let i=t;"object"!=typeof e&&(e={name:e});const s=Object.assign({name:Ue,automaticDataCollectionEnabled:!1},e),n=s.name;if("string"!=typeof n||!n)throw Ke.create("bad-app-name",{appName:String(n)});if(i||(i=Ft()),!i)throw Ke.create("no-options");const o=Pe.get(n);if(o){if(ie(i,o.options)&&ie(s,o.config))return o;throw Ke.create("duplicate-app",{appName:n})}const a=new me(n);for(const t of _e.values())a.addComponent(t);const r=new ti(i,s,a);return Pe.set(n,r),r}function ii(t=Ue){const e=Pe.get(t);if(!e&&t===Ue&&Ft())return ei();if(!e)throw Ke.create("no-app",{appName:t});return e}function si(t,e,i){var s;let n=null!==(s=Be[t])&&void 0!==s?s:t;i&&(n+=`-${i}`);const o=n.match(/\s|\//),a=e.match(/\s|\//);if(o||a){const t=[`Unable to register library "${n}" with version "${e}":`];return o&&t.push(`library name "${n}" contains illegal characters (whitespace or "/")`),o&&a&&t.push("and"),a&&t.push(`version name "${e}" contains illegal characters (whitespace or "/")`),void De.warn(t.join(" "))}qe(new ue(`${n}-version`,(()=>({library:n,version:e})),"VERSION"))}const ni="firebase-heartbeat-database",oi=1,ai="firebase-heartbeat-store";let ri=null;function li(){return ri||(ri=ze(ni,oi,{upgrade:(t,e)=>{if(0===e)try{t.createObjectStore(ai)}catch(t){console.warn(t)}}}).catch((t=>{throw Ke.create("idb-open",{originalErrorMessage:t.message})}))),ri}async function hi(t,e){try{const i=(await li()).transaction(ai,"readwrite"),s=i.objectStore(ai);await s.put(e,ci(t)),await i.done}catch(t){if(t instanceof Ut)De.warn(t.message);else{const e=Ke.create("idb-set",{originalErrorMessage:null==t?void 0:t.message});De.warn(e.message)}}}function ci(t){return`${t.name}!${t.options.appId}`}class di{constructor(t){this.container=t,this._heartbeatsCache=null;const e=this.container.getProvider("app").getImmediate();this._storage=new ui(e),this._heartbeatsCachePromise=this._storage.read().then((t=>(this._heartbeatsCache=t,t)))}async triggerHeartbeat(){var t,e;const i=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),s=Ii();if((null!=(null===(t=this._heartbeatsCache)||void 0===t?void 0:t.heartbeats)||(this._heartbeatsCache=await this._heartbeatsCachePromise,null!=(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)))&&this._heartbeatsCache.lastSentHeartbeatDate!==s&&!this._heartbeatsCache.heartbeats.some((t=>t.date===s)))return this._heartbeatsCache.heartbeats.push({date:s,agent:i}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter((t=>{const e=new Date(t.date).valueOf();return Date.now()-e<=2592e6})),this._storage.overwrite(this._heartbeatsCache)}async getHeartbeatsHeader(){var t;if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null==(null===(t=this._heartbeatsCache)||void 0===t?void 0:t.heartbeats)||0===this._heartbeatsCache.heartbeats.length)return"";const e=Ii(),{heartbeatsToSend:i,unsentEntries:s}=function(t,e=1024){const i=[];let s=t.slice();for(const n of t){const t=i.find((t=>t.agent===n.agent));if(t){if(t.dates.push(n.date),pi(i)>e){t.dates.pop();break}}else if(i.push({agent:n.agent,dates:[n.date]}),pi(i)>e){i.pop();break}s=s.slice(1)}return{heartbeatsToSend:i,unsentEntries:s}}(this._heartbeatsCache.heartbeats),n=zt(JSON.stringify({version:2,heartbeats:i}));return this._heartbeatsCache.lastSentHeartbeatDate=e,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),n}}function Ii(){return(new Date).toISOString().substring(0,10)}class ui{constructor(t){this.app=t,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!Et()&&Dt().then((()=>!0)).catch((()=>!1))}async read(){if(await this._canUseIndexedDBPromise){const t=await async function(t){try{const e=(await li()).transaction(ai),i=await e.objectStore(ai).get(ci(t));return await e.done,i}catch(t){if(t instanceof Ut)De.warn(t.message);else{const e=Ke.create("idb-get",{originalErrorMessage:null==t?void 0:t.message});De.warn(e.message)}}}(this.app);return(null==t?void 0:t.heartbeats)?t:{heartbeats:[]}}return{heartbeats:[]}}async overwrite(t){var e;if(await this._canUseIndexedDBPromise){const i=await this.read();return hi(this.app,{lastSentHeartbeatDate:null!==(e=t.lastSentHeartbeatDate)&&void 0!==e?e:i.lastSentHeartbeatDate,heartbeats:t.heartbeats})}}async add(t){var e;if(await this._canUseIndexedDBPromise){const i=await this.read();return hi(this.app,{lastSentHeartbeatDate:null!==(e=t.lastSentHeartbeatDate)&&void 0!==e?e:i.lastSentHeartbeatDate,heartbeats:[...i.heartbeats,...t.heartbeats]})}}}function pi(t){return zt(JSON.stringify({version:2,heartbeats:t})).length}qe(new ue("platform-logger",(t=>new Je(t)),"PRIVATE")),qe(new ue("heartbeat",(t=>new di(t)),"PRIVATE")),si(Xe,Ee,""),si(Xe,Ee,"esm2017"),si("fire-js",""),si("firebase","10.8.0","app");const bi="@firebase/installations",mi="0.6.5",yi=1e4,Li=`w:${mi}`,Mi="FIS_v2",Wi="https://firebaseinstallations.googleapis.com/v1",wi=36e5,vi=new Bt("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function ji(t){return t instanceof Ut&&t.code.includes("request-failed")}function Zi({projectId:t}){return`${Wi}/projects/${t}/installations`}function Ci(t){return{token:t.token,requestStatus:2,expiresIn:(e=t.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()};var e}async function Gi(t,e){const i=(await e.json()).error;return vi.create("request-failed",{requestName:t,serverCode:i.code,serverMessage:i.message,serverStatus:i.status})}function fi({apiKey:t}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":t})}async function Ni(t){const e=await t();return e.status>=500&&e.status<600?t():e}function xi(t){return new Promise((e=>{setTimeout(e,t)}))}const Yi=/^[cdef][\w-]{21}$/,Ri="";function Hi(){try{const t=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(t),t[0]=112+t[0]%16;const e=function(t){var e;return(e=t,btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_")).substr(0,22)}(t);return Yi.test(e)?e:Ri}catch(t){return Ri}}function gi(t){return`${t.appName}!${t.appId}`}const Ai=new Map;function Si(t,e){const i=gi(t);zi(i,e),function(t,e){const i=(!Vi&&"BroadcastChannel"in self&&(Vi=new BroadcastChannel("[Firebase] FID Change"),Vi.onmessage=t=>{zi(t.data.key,t.data.fid)}),Vi);i&&i.postMessage({key:t,fid:e}),0===Ai.size&&Vi&&(Vi.close(),Vi=null)}(i,e)}function zi(t,e){const i=Ai.get(t);if(i)for(const t of i)t(e)}let Vi=null;const Ti="firebase-installations-database",ki=1,Oi="firebase-installations-store";let Fi=null;function Ji(){return Fi||(Fi=ze(Ti,ki,{upgrade:(t,e)=>{0===e&&t.createObjectStore(Oi)}})),Fi}async function Xi(t,e){const i=gi(t),s=(await Ji()).transaction(Oi,"readwrite"),n=s.objectStore(Oi),o=await n.get(i);return await n.put(e,i),await s.done,o&&o.fid===e.fid||Si(t,e.fid),e}async function Ei(t){const e=gi(t),i=(await Ji()).transaction(Oi,"readwrite");await i.objectStore(Oi).delete(e),await i.done}async function Di(t,e){const i=gi(t),s=(await Ji()).transaction(Oi,"readwrite"),n=s.objectStore(Oi),o=await n.get(i),a=e(o);return void 0===a?await n.delete(i):await n.put(a,i),await s.done,!a||o&&o.fid===a.fid||Si(t,a.fid),a}async function Ui(t){let e;const i=await Di(t.appConfig,(i=>{const s=function(t){return _i(t||{fid:Hi(),registrationStatus:0})}(i),n=function(t,e){if(0===e.registrationStatus){if(!navigator.onLine)return{installationEntry:e,registrationPromise:Promise.reject(vi.create("app-offline"))};const i={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},s=async function(t,e){try{const i=await async function({appConfig:t,heartbeatServiceProvider:e},{fid:i}){const s=Zi(t),n=fi(t),o=e.getImmediate({optional:!0});if(o){const t=await o.getHeartbeatsHeader();t&&n.append("x-firebase-client",t)}const a={fid:i,authVersion:Mi,appId:t.appId,sdkVersion:Li},r={method:"POST",headers:n,body:JSON.stringify(a)},l=await Ni((()=>fetch(s,r)));if(l.ok){const t=await l.json();return{fid:t.fid||i,registrationStatus:2,refreshToken:t.refreshToken,authToken:Ci(t.authToken)}}throw await Gi("Create Installation",l)}(t,e);return Xi(t.appConfig,i)}catch(i){throw ji(i)&&409===i.customData.serverCode?await Ei(t.appConfig):await Xi(t.appConfig,{fid:e.fid,registrationStatus:0}),i}}(t,i);return{installationEntry:i,registrationPromise:s}}return 1===e.registrationStatus?{installationEntry:e,registrationPromise:Bi(t)}:{installationEntry:e}}(t,s);return e=n.registrationPromise,n.installationEntry}));return i.fid===Ri?{installationEntry:await e}:{installationEntry:i,registrationPromise:e}}async function Bi(t){let e=await Pi(t.appConfig);for(;1===e.registrationStatus;)await xi(100),e=await Pi(t.appConfig);if(0===e.registrationStatus){const{installationEntry:e,registrationPromise:i}=await Ui(t);return i||e}return e}function Pi(t){return Di(t,(t=>{if(!t)throw vi.create("installation-not-found");return _i(t)}))}function _i(t){return 1===(e=t).registrationStatus&&e.registrationTime+yifetch(s,r)));if(l.ok)return Ci(await l.json());throw await Gi("Generate Auth Token",l)}async function qi(t,e=!1){let i;const s=await Di(t.appConfig,(s=>{if(!Ki(s))throw vi.create("not-registered");const n=s.authToken;if(!e&&(2===(o=n).requestStatus&&!function(t){const e=Date.now();return e{if(!Ki(t))throw vi.create("not-registered");return 1===(e=t.authToken).requestStatus&&e.requestTime+yi{const e=t.getProvider("app").getImmediate(),i=function(t){if(!t||!t.options)throw ts("App Configuration");if(!t.name)throw ts("App Name");const e=["projectId","apiKey","appId"];for(const i of e)if(!t.options[i])throw ts(i);return{appName:t.name,projectId:t.options.projectId,apiKey:t.options.apiKey,appId:t.options.appId}}(e);return{app:e,appConfig:i,heartbeatServiceProvider:$e(e,"heartbeat"),_delete:()=>Promise.resolve()}}),"PUBLIC")),qe(new ue("installations-internal",(t=>{const e=$e(t.getProvider("app").getImmediate(),es).getImmediate();return{getId:()=>async function(t){const e=t,{installationEntry:i,registrationPromise:s}=await Ui(e);return s?s.catch(console.error):qi(e).catch(console.error),i.fid}(e),getToken:t=>async function(t,e=!1){const i=t;return await async function(t){const{registrationPromise:e}=await Ui(t);e&&await e}(i),(await qi(i,e)).token}(e,t)}}),"PRIVATE")),si(bi,mi),si(bi,mi,"esm2017");const is="analytics",ss="firebase_id",ns="origin",os=6e4,as="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",rs="https://www.googletagmanager.com/gtag/js",ls=new je("@firebase/analytics"),hs=new Bt("analytics","Analytics",{"already-exists":"A Firebase Analytics instance with the appId {$id} already exists. Only one Firebase Analytics instance can be created for each appId.","already-initialized":"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-intialized instance.","already-initialized-settings":"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.","interop-component-reg-failed":"Firebase Analytics Interop Component failed to instantiate: {$reason}","invalid-analytics-context":"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","indexeddb-unavailable":"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}","fetch-throttle":"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.","config-fetch-failed":"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}","no-api-key":'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',"no-app-id":'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.',"no-client-id":'The "client_id" field is empty.',"invalid-gtag-resource":"Trusted Types detected an invalid gtag resource: {$gtagURL}."});function cs(t){if(!t.startsWith(rs)){const e=hs.create("invalid-gtag-resource",{gtagURL:t});return ls.warn(e.message),""}return t}function ds(t){return Promise.all(t.map((t=>t.catch((t=>t)))))}const Is=30,us=new class{constructor(t={},e=1e3){this.throttleMetadata=t,this.intervalMillis=e}getThrottleMetadata(t){return this.throttleMetadata[t]}setThrottleMetadata(t,e){this.throttleMetadata[t]=e}deleteThrottleMetadata(t){delete this.throttleMetadata[t]}};function ps(t){return new Headers({Accept:"application/json","x-goog-api-key":t})}async function bs(t,e=us,i){const{appId:s,apiKey:n,measurementId:o}=t.options;if(!s)throw hs.create("no-app-id");if(!n){if(o)return{measurementId:o,appId:s};throw hs.create("no-api-key")}const a=e.getThrottleMetadata(s)||{backoffCount:0,throttleEndTimeMillis:Date.now()},r=new ys;return setTimeout((async()=>{r.abort()}),void 0!==i?i:os),ms({appId:s,apiKey:n,measurementId:o},a,r,e)}async function ms(t,{throttleEndTimeMillis:e,backoffCount:i},s,n=us){var o;const{appId:a,measurementId:r}=t;try{await function(t,e){return new Promise(((i,s)=>{const n=Math.max(e-Date.now(),0),o=setTimeout(i,n);t.addEventListener((()=>{clearTimeout(o),s(hs.create("fetch-throttle",{throttleEndTimeMillis:e}))}))}))}(s,e)}catch(t){if(r)return ls.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${r} provided in the "measurementId" field in the local Firebase config. [${null==t?void 0:t.message}]`),{appId:a,measurementId:r};throw t}try{const e=await async function(t){var e;const{appId:i,apiKey:s}=t,n={method:"GET",headers:ps(s)},o=as.replace("{app-id}",i),a=await fetch(o,n);if(200!==a.status&&304!==a.status){let t="";try{const i=await a.json();(null===(e=i.error)||void 0===e?void 0:e.message)&&(t=i.error.message)}catch(t){}throw hs.create("config-fetch-failed",{httpStatus:a.status,responseMessage:t})}return a.json()}(t);return n.deleteThrottleMetadata(a),e}catch(e){const l=e;if(!function(t){if(!(t instanceof Ut&&t.customData))return!1;const e=Number(t.customData.httpStatus);return 429===e||500===e||503===e||504===e}(l)){if(n.deleteThrottleMetadata(a),r)return ls.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${r} provided in the "measurementId" field in the local Firebase config. [${null==l?void 0:l.message}]`),{appId:a,measurementId:r};throw e}const h=503===Number(null===(o=null==l?void 0:l.customData)||void 0===o?void 0:o.httpStatus)?de(i,n.intervalMillis,Is):de(i,n.intervalMillis),c={throttleEndTimeMillis:Date.now()+h,backoffCount:i+1};return n.setThrottleMetadata(a,c),ls.debug(`Calling attemptFetch again in ${h} millis`),ms(t,c,s,n)}}class ys{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}abort(){this.listeners.forEach((t=>t()))}}let Ls,Ms;async function Ws(t,e,i,s,n,o,a){var r;const l=bs(t);l.then((e=>{i[e.measurementId]=e.appId,t.options.measurementId&&e.measurementId!==t.options.measurementId&&ls.warn(`The measurement ID in the local Firebase config (${t.options.measurementId}) does not match the measurement ID fetched from the server (${e.measurementId}). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.`)})).catch((t=>ls.error(t))),e.push(l);const h=async function(){if(!Et())return ls.warn(hs.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;try{await Dt()}catch(t){return ls.warn(hs.create("indexeddb-unavailable",{errorInfo:null==t?void 0:t.toString()}).message),!1}return!0}().then((t=>t?s.getId():void 0)),[c,d]=await Promise.all([l,h]);(function(t){const e=window.document.getElementsByTagName("script");for(const i of Object.values(e))if(i.src&&i.src.includes(rs)&&i.src.includes(t))return i;return null})(o)||function(t,e){const i=function(t,e){let i;return window.trustedTypes&&(i=window.trustedTypes.createPolicy("firebase-js-sdk-policy",e)),i}(0,{createScriptURL:cs}),s=document.createElement("script"),n=`${rs}?l=${t}&id=${e}`;s.src=i?null==i?void 0:i.createScriptURL(n):n,s.async=!0,document.head.appendChild(s)}(o,c.measurementId),Ms&&(n("consent","default",Ms),Ms=void 0),n("js",new Date);const I=null!==(r=null==a?void 0:a.config)&&void 0!==r?r:{};return I[ns]="firebase",I.update=!0,null!=d&&(I[ss]=d),n("config",c.measurementId,I),Ls&&(n("set",Ls),Ls=void 0),c.measurementId}class ws{constructor(t){this.app=t}_delete(){return delete vs[this.app.options.appId],Promise.resolve()}}let vs={},js=[];const Zs={};let Cs,Gs,fs="dataLayer",Ns=!1;function xs(t,e,i){!function(){const t=[];if(function(){const t="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof t&&void 0!==t.id}()&&t.push("This is a browser extension environment."),"undefined"!=typeof navigator&&navigator.cookieEnabled||t.push("Cookies are not available."),t.length>0){const e=t.map(((t,e)=>`(${e+1}) ${t}`)).join(" "),i=hs.create("invalid-analytics-context",{errorInfo:e});ls.warn(i.message)}}();const s=t.options.appId;if(!s)throw hs.create("no-app-id");if(!t.options.apiKey){if(!t.options.measurementId)throw hs.create("no-api-key");ls.warn(`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID ${t.options.measurementId} provided in the "measurementId" field in the local Firebase config.`)}if(null!=vs[s])throw hs.create("already-exists",{id:s});if(!Ns){!function(t){let e=[];Array.isArray(window[t])?e=window[t]:window[t]=e}(fs);const{wrappedGtag:t,gtagCore:e}=function(t,e,i,s,n){let o=function(...t){window[s].push(arguments)};return window[n]&&"function"==typeof window[n]&&(o=window[n]),window[n]=function(t,e,i,s){return async function(n,...o){try{if("event"===n){const[s,n]=o;await async function(t,e,i,s,n){try{let o=[];if(n&&n.send_to){let t=n.send_to;Array.isArray(t)||(t=[t]);const s=await ds(i);for(const i of t){const t=s.find((t=>t.measurementId===i)),n=t&&e[t.appId];if(!n){o=[];break}o.push(n)}}0===o.length&&(o=Object.values(e)),await Promise.all(o),t("event",s,n||{})}catch(t){ls.error(t)}}(t,e,i,s,n)}else if("config"===n){const[n,a]=o;await async function(t,e,i,s,n,o){const a=s[n];try{if(a)await e[a];else{const t=(await ds(i)).find((t=>t.measurementId===n));t&&await e[t.appId]}}catch(t){ls.error(t)}t("config",n,o)}(t,e,i,s,n,a)}else if("consent"===n){const[e]=o;t("consent","update",e)}else if("get"===n){const[e,i,s]=o;t("get",e,i,s)}else if("set"===n){const[e]=o;t("set",e)}else t(n,...o)}catch(t){ls.error(t)}}}(o,t,e,i),{gtagCore:o,wrappedGtag:window[n]}}(vs,js,Zs,fs,"gtag");Gs=t,Cs=e,Ns=!0}return vs[s]=Ws(t,js,Zs,e,Cs,fs,i),new ws(t)}const Ys="@firebase/analytics",Rs="0.10.1";qe(new ue(is,((t,{options:e})=>xs(t.getProvider("app").getImmediate(),t.getProvider("installations-internal").getImmediate(),e)),"PUBLIC")),qe(new ue("analytics-internal",(function(t){try{const e=t.getProvider(is).getImmediate();return{logEvent:(t,i,s)=>function(t,e,i,s){t=Ie(t),async function(t,e,i,s,n){if(n&&n.global)t("event",i,s);else{const n=await e;t("event",i,Object.assign(Object.assign({},s),{send_to:n}))}}(Gs,vs[t.app.options.appId],e,i,s).catch((t=>ls.error(t)))}(e,t,i,s)}}catch(t){throw hs.create("interop-component-reg-failed",{reason:t})}}),"PRIVATE")),si(Ys,Rs),si(Ys,Rs,"esm2017");const Hs="@firebase/database",gs="1.0.3";let As="";class Ss{constructor(t){this.domStorage_=t,this.prefix_="firebase:"}set(t,e){null==e?this.domStorage_.removeItem(this.prefixedName_(t)):this.domStorage_.setItem(this.prefixedName_(t),Qt(e))}get(t){const e=this.domStorage_.getItem(this.prefixedName_(t));return null==e?null:_t(e)}remove(t){this.domStorage_.removeItem(this.prefixedName_(t))}prefixedName_(t){return this.prefix_+t}toString(){return this.domStorage_.toString()}}class zs{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(t,e){null==e?delete this.cache_[t]:this.cache_[t]=e}get(t){return $t(this.cache_,t)?this.cache_[t]:null}remove(t){delete this.cache_[t]}}const Vs=function(t){try{if("undefined"!=typeof window&&void 0!==window[t]){const e=window[t];return e.setItem("firebase:sentinel","cache"),e.removeItem("firebase:sentinel"),new Ss(e)}}catch(t){}return new zs},Ts=Vs("localStorage"),ks=Vs("sessionStorage"),Os=new je("@firebase/database"),Fs=function(){let t=1;return function(){return t++}}(),Js=function(t){const e=function(t){const e=[];let i=0;for(let s=0;s=55296&&n<=56319){const e=n-55296;s++,Yt(s>6|192,e[i++]=63&n|128):n<65536?(e[i++]=n>>12|224,e[i++]=n>>6&63|128,e[i++]=63&n|128):(e[i++]=n>>18|240,e[i++]=n>>12&63|128,e[i++]=n>>6&63|128,e[i++]=63&n|128)}return e}(t),i=new ne;i.update(e);const s=i.digest();return gt.encodeByteArray(s)},Xs=function(...t){let e="";for(let i=0;ii?s.push(t.substring(n,i)):s.push(t.substring(n,n+e));return s};function an(t,e){for(const i in t)t.hasOwnProperty(i)&&e(i,t[i])}const rn=function(t){Yt(!qs(t),"Invalid JSON number");let e,i,s,n,o;0===t?(i=0,s=0,e=1/t==-1/0?1:0):(e=t<0,(t=Math.abs(t))>=Math.pow(2,-1022)?(n=Math.min(Math.floor(Math.log(t)/Math.LN2),1023),i=n+1023,s=Math.round(t*Math.pow(2,52-n)-Math.pow(2,52))):(i=0,s=Math.round(t/Math.pow(2,-1074))));const a=[];for(o=52;o;o-=1)a.push(s%2?1:0),s=Math.floor(s/2);for(o=11;o;o-=1)a.push(i%2?1:0),i=Math.floor(i/2);a.push(e?1:0),a.reverse();const r=a.join("");let l="";for(o=0;o<64;o+=8){let t=parseInt(r.substr(o,8),2).toString(16);1===t.length&&(t="0"+t),l+=t}return l.toLowerCase()},ln=new RegExp("^-?(0*)\\d{1,10}$"),hn=function(t){if(ln.test(t)){const e=Number(t);if(e>=-2147483648&&e<=2147483647)return e}return null},cn=function(t){try{t()}catch(t){setTimeout((()=>{const e=t.stack||"";throw Qs("Exception was thrown by user callback.",e),t}),Math.floor(0))}},dn=function(t,e){const i=setTimeout(t,e);return"number"==typeof i&&"undefined"!=typeof Deno&&Deno.unrefTimer?Deno.unrefTimer(i):"object"==typeof i&&i.unref&&i.unref(),i};class In{constructor(t,e){this.appName_=t,this.appCheckProvider=e,this.appCheck=null==e?void 0:e.getImmediate({optional:!0}),this.appCheck||null==e||e.get().then((t=>this.appCheck=t))}getToken(t){return this.appCheck?this.appCheck.getToken(t):new Promise(((e,i)=>{setTimeout((()=>{this.appCheck?this.getToken(t).then(e,i):e(null)}),0)}))}addTokenChangeListener(t){var e;null===(e=this.appCheckProvider)||void 0===e||e.get().then((e=>e.addTokenListener(t)))}notifyForInvalidToken(){Qs(`Provided AppCheck credentials for the app named "${this.appName_}" are invalid. This usually indicates your app was not initialized correctly.`)}}class un{constructor(t,e,i){this.appName_=t,this.firebaseOptions_=e,this.authProvider_=i,this.auth_=null,this.auth_=i.getImmediate({optional:!0}),this.auth_||i.onInit((t=>this.auth_=t))}getToken(t){return this.auth_?this.auth_.getToken(t).catch((t=>t&&"auth/token-not-initialized"===t.code?(Us("Got auth/token-not-initialized error. Treating as null token."),null):Promise.reject(t))):new Promise(((e,i)=>{setTimeout((()=>{this.auth_?this.getToken(t).then(e,i):e(null)}),0)}))}addTokenChangeListener(t){this.auth_?this.auth_.addAuthTokenListener(t):this.authProvider_.get().then((e=>e.addAuthTokenListener(t)))}removeTokenChangeListener(t){this.authProvider_.get().then((e=>e.removeAuthTokenListener(t)))}notifyForInvalidToken(){let t='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?t+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?t+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':t+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',Qs(t)}}class pn{constructor(t){this.accessToken=t}getToken(t){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(t){t(this.accessToken)}removeTokenChangeListener(t){}notifyForInvalidToken(){}}pn.OWNER="owner";const bn="5",mn=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,yn="ac",Ln="websocket",Mn="long_polling";class Wn{constructor(t,e,i,s,n=!1,o="",a=!1,r=!1){this.secure=e,this.namespace=i,this.webSocketOnly=s,this.nodeAdmin=n,this.persistenceKey=o,this.includeNamespaceInQueryParams=a,this.isUsingEmulator=r,this._host=t.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=Ts.get("host:"+t)||this._host}isCacheableHost(){return"s-"===this.internalHost.substr(0,2)}isCustomHost(){return"firebaseio.com"!==this._domain&&"firebaseio-demo.com"!==this._domain}get host(){return this._host}set host(t){t!==this.internalHost&&(this.internalHost=t,this.isCacheableHost()&&Ts.set("host:"+this._host,this.internalHost))}toString(){let t=this.toURLString();return this.persistenceKey&&(t+="<"+this.persistenceKey+">"),t}toURLString(){const t=this.secure?"https://":"http://",e=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${t}${this.host}/${e}`}}function wn(t,e,i){let s;if(Yt("string"==typeof e,"typeof type must == string"),Yt("object"==typeof i,"typeof params must == object"),e===Ln)s=(t.secure?"wss://":"ws://")+t.internalHost+"/.ws?";else{if(e!==Mn)throw new Error("Unknown connection type: "+e);s=(t.secure?"https://":"http://")+t.internalHost+"/.lp?"}(function(t){return t.host!==t.internalHost||t.isCustomHost()||t.includeNamespaceInQueryParams})(t)&&(i.ns=t.namespace);const n=[];return an(i,((t,e)=>{n.push(t+"="+e)})),s+n.join("&")}class vn{constructor(){this.counters_={}}incrementCounter(t,e=1){$t(this.counters_,t)||(this.counters_[t]=0),this.counters_[t]+=e}get(){return Tt(this.counters_)}}const jn={},Zn={};function Cn(t){const e=t.toString();return jn[e]||(jn[e]=new vn),jn[e]}class Gn{constructor(t){this.onMessage_=t,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(t,e){this.closeAfterResponse=t,this.onClose=e,this.closeAfterResponse{this.onMessage_(t[e])}));if(this.currentResponseNum===this.closeAfterResponse){this.onClose&&(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}const fn="start";class Nn{constructor(t,e,i,s,n,o,a){this.connId=t,this.repoInfo=e,this.applicationId=i,this.appCheckToken=s,this.authToken=n,this.transportSessionId=o,this.lastSessionId=a,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=Bs(t),this.stats_=Cn(e),this.urlFn=t=>(this.appCheckToken&&(t[yn]=this.appCheckToken),wn(e,Mn,t))}open(t,e){this.curSegmentNum=0,this.onDisconnect_=e,this.myPacketOrderer=new Gn(t),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout((()=>{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null}),Math.floor(3e4)),function(t){if("complete"===document.readyState)t();else{let e=!1;const i=function(){document.body?e||(e=!0,t()):setTimeout(i,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",i,!1),window.addEventListener("load",i,!1)):document.attachEvent&&(document.attachEvent("onreadystatechange",(()=>{"complete"===document.readyState&&i()})),window.attachEvent("onload",i))}}((()=>{if(this.isClosed_)return;this.scriptTagHolder=new xn(((...t)=>{const[e,i,s,n,o]=t;if(this.incrementIncomingBytes_(t),this.scriptTagHolder)if(this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,e===fn)this.id=i,this.password=s;else{if("close"!==e)throw new Error("Unrecognized command received: "+e);i?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(i,(()=>{this.onClosed_()}))):this.onClosed_()}}),((...t)=>{const[e,i]=t;this.incrementIncomingBytes_(t),this.myPacketOrderer.handleResponse(e,i)}),(()=>{this.onClosed_()}),this.urlFn);const t={};t[fn]="t",t.ser=Math.floor(1e8*Math.random()),this.scriptTagHolder.uniqueCallbackIdentifier&&(t.cb=this.scriptTagHolder.uniqueCallbackIdentifier),t.v=bn,this.transportSessionId&&(t.s=this.transportSessionId),this.lastSessionId&&(t.ls=this.lastSessionId),this.applicationId&&(t.p=this.applicationId),this.appCheckToken&&(t[yn]=this.appCheckToken),"undefined"!=typeof location&&location.hostname&&mn.test(location.hostname)&&(t.r="f");const e=this.urlFn(t);this.log_("Connecting via long-poll to "+e),this.scriptTagHolder.addTag(e,(()=>{}))}))}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){Nn.forceAllow_=!0}static forceDisallow(){Nn.forceDisallow_=!0}static isAvailable(){return!(!Nn.forceAllow_&&(Nn.forceDisallow_||"undefined"==typeof document||null==document.createElement||"object"==typeof window&&window.chrome&&window.chrome.extension&&!/^chrome/.test(window.location.href)||"object"==typeof Windows&&"object"==typeof Windows.UI))}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&&(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&&(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&&(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&&(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(t){const e=Qt(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);const i=St(e),s=on(i,1840);for(let t=0;tdocument.domain="'+document.domain+'";<\/script>');const s=""+i+"";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(s),this.myIFrame.doc.close()}catch(t){Us("frame writing exception"),t.stack&&Us(t.stack),Us(t)}}}static createIFrame_(){const t=document.createElement("iframe");if(t.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(t);try{t.contentWindow.document||Us("No IE domain setting required")}catch(e){const i=document.domain;t.src="javascript:void((function(){document.open();document.domain='"+i+"';document.close();})())"}return t.contentDocument?t.doc=t.contentDocument:t.contentWindow?t.doc=t.contentWindow.document:t.document&&(t.doc=t.document),t}close(){this.alive=!1,this.myIFrame&&(this.myIFrame.doc.body.textContent="",setTimeout((()=>{null!==this.myIFrame&&(document.body.removeChild(this.myIFrame),this.myIFrame=null)}),Math.floor(0)));const t=this.onDisconnect;t&&(this.onDisconnect=null,t())}startLongPoll(t,e){for(this.myID=t,this.myPW=e,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&&this.sendNewPolls&&this.outstandingRequests.size<(this.pendingSegs.length>0?2:1)){this.currentSerial++;const t={};t.id=this.myID,t.pw=this.myPW,t.ser=this.currentSerial;let e=this.urlFn(t),i="",s=0;for(;this.pendingSegs.length>0&&this.pendingSegs[0].d.length+30+i.length<=1870;){const t=this.pendingSegs.shift();i=i+"&seg"+s+"="+t.seg+"&ts"+s+"="+t.ts+"&d"+s+"="+t.d,s++}return e+=i,this.addLongPollTag_(e,this.currentSerial),!0}return!1}enqueueSegment(t,e,i){this.pendingSegs.push({seg:t,ts:e,d:i}),this.alive&&this.newRequest_()}addLongPollTag_(t,e){this.outstandingRequests.add(e);const i=()=>{this.outstandingRequests.delete(e),this.newRequest_()},s=setTimeout(i,Math.floor(25e3));this.addTag(t,(()=>{clearTimeout(s),i()}))}addTag(t,e){setTimeout((()=>{try{if(!this.sendNewPolls)return;const i=this.myIFrame.doc.createElement("script");i.type="text/javascript",i.async=!0,i.src=t,i.onload=i.onreadystatechange=function(){const t=i.readyState;t&&"loaded"!==t&&"complete"!==t||(i.onload=i.onreadystatechange=null,i.parentNode&&i.parentNode.removeChild(i),e())},i.onerror=()=>{Us("Long-poll script failed to load: "+t),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(i)}catch(t){}}),Math.floor(1))}}let Yn=null;"undefined"!=typeof MozWebSocket?Yn=MozWebSocket:"undefined"!=typeof WebSocket&&(Yn=WebSocket);class Rn{constructor(t,e,i,s,n,o,a){this.connId=t,this.applicationId=i,this.appCheckToken=s,this.authToken=n,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=Bs(this.connId),this.stats_=Cn(e),this.connURL=Rn.connectionURL_(e,o,a,s,i),this.nodeAdmin=e.nodeAdmin}static connectionURL_(t,e,i,s,n){const o={};return o.v=bn,"undefined"!=typeof location&&location.hostname&&mn.test(location.hostname)&&(o.r="f"),e&&(o.s=e),i&&(o.ls=i),s&&(o[yn]=s),n&&(o.p=n),wn(t,Ln,o)}open(t,e){this.onDisconnect=e,this.onMessage=t,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,Ts.set("previous_websocket_failure",!0);try{let t;0,this.mySock=new Yn(this.connURL,[],t)}catch(t){this.log_("Error instantiating WebSocket.");const e=t.message||t.data;return e&&this.log_(e),void this.onClosed_()}this.mySock.onopen=()=>{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=>{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=t=>{this.handleIncomingFrame(t)},this.mySock.onerror=t=>{this.log_("WebSocket error. Closing connection.");const e=t.message||t.data;e&&this.log_(e),this.onClosed_()}}start(){}static forceDisallow(){Rn.forceDisallow_=!0}static isAvailable(){let t=!1;if("undefined"!=typeof navigator&&navigator.userAgent){const e=/Android ([0-9]{0,}\.[0-9]{0,})/,i=navigator.userAgent.match(e);i&&i.length>1&&parseFloat(i[1])<4.4&&(t=!0)}return!t&&null!==Yn&&!Rn.forceDisallow_}static previouslyFailed(){return Ts.isInMemoryStorage||!0===Ts.get("previous_websocket_failure")}markConnectionHealthy(){Ts.remove("previous_websocket_failure")}appendFrame_(t){if(this.frames.push(t),this.frames.length===this.totalFrames){const t=this.frames.join("");this.frames=null;const e=_t(t);this.onMessage(e)}}handleNewFrameCount_(t){this.totalFrames=t,this.frames=[]}extractFrameCount_(t){if(Yt(null===this.frames,"We already have a frame buffer"),t.length<=6){const e=Number(t);if(!isNaN(e))return this.handleNewFrameCount_(e),null}return this.handleNewFrameCount_(1),t}handleIncomingFrame(t){if(null===this.mySock)return;const e=t.data;if(this.bytesReceived+=e.length,this.stats_.incrementCounter("bytes_received",e.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(e);else{const t=this.extractFrameCount_(e);null!==t&&this.appendFrame_(t)}}send(t){this.resetKeepAlive();const e=Qt(t);this.bytesSent+=e.length,this.stats_.incrementCounter("bytes_sent",e.length);const i=on(e,16384);i.length>1&&this.sendString_(String(i.length));for(let t=0;t{this.mySock&&this.sendString_("0"),this.resetKeepAlive()}),Math.floor(45e3))}sendString_(t){try{this.mySock.send(t)}catch(t){this.log_("Exception thrown from WebSocket.send():",t.message||t.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}Rn.responsesRequiredToBeHealthy=2,Rn.healthyTimeout=3e4;class Hn{constructor(t){this.initTransports_(t)}static get ALL_TRANSPORTS(){return[Nn,Rn]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}initTransports_(t){const e=Rn&&Rn.isAvailable();let i=e&&!Rn.previouslyFailed();if(t.webSocketOnly&&(e||Qs("wss:// URL used, but browser isn't known to support websockets. Trying anyway."),i=!0),i)this.transports_=[Rn];else{const t=this.transports_=[];for(const e of Hn.ALL_TRANSPORTS)e&&e.isAvailable()&&t.push(e);Hn.globalTransportInitialized_=!0}}initialTransport(){if(this.transports_.length>0)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return this.transports_.length>1?this.transports_[1]:null}}Hn.globalTransportInitialized_=!1;class gn{constructor(t,e,i,s,n,o,a,r,l,h){this.id=t,this.repoInfo_=e,this.applicationId_=i,this.appCheckToken_=s,this.authToken_=n,this.onMessage_=o,this.onReady_=a,this.onDisconnect_=r,this.onKill_=l,this.lastSessionId=h,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=Bs("c:"+this.id+":"),this.transportManager_=new Hn(e),this.log_("Connection created"),this.start_()}start_(){const t=this.transportManager_.initialTransport();this.conn_=new t(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=t.responsesRequiredToBeHealthy||0;const e=this.connReceiver_(this.conn_),i=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout((()=>{this.conn_&&this.conn_.open(e,i)}),Math.floor(0));const s=t.healthyTimeout||0;s>0&&(this.healthyTimeout_=dn((()=>{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&&this.conn_.bytesReceived>102400?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes. Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&&this.conn_.bytesSent>10240?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes. Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))}),Math.floor(s)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(t){return e=>{t===this.conn_?this.onConnectionLost_(e):t===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(t){return e=>{2!==this.state_&&(t===this.rx_?this.onPrimaryMessageReceived_(e):t===this.secondaryConn_?this.onSecondaryMessageReceived_(e):this.log_("message on old connection"))}}sendRequest(t){const e={t:"d",d:t};this.sendData_(e)}tryCleanupConnection(){this.tx_===this.secondaryConn_&&this.rx_===this.secondaryConn_&&(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(t){if("t"in t){const e=t.t;"a"===e?this.upgradeIfSecondaryHealthy_():"r"===e?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&&this.rx_!==this.secondaryConn_||this.close()):"o"===e&&(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(t){const e=sn("t",t),i=sn("d",t);if("c"===e)this.onSecondaryControl_(i);else{if("d"!==e)throw new Error("Unknown protocol layer: "+e);this.pendingDataMessages.push(i)}}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_<=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(t){const e=sn("t",t),i=sn("d",t);"c"===e?this.onControl_(i):"d"===e&&this.onDataMessage_(i)}onDataMessage_(t){this.onPrimaryResponse_(),this.onMessage_(t)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_<=0&&(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(t){const e=sn("t",t);if("d"in t){const i=t.d;if("h"===e){const t=Object.assign({},i);this.repoInfo_.isUsingEmulator&&(t.h=this.repoInfo_.host),this.onHandshake_(t)}else if("n"===e){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let t=0;t{this.secondaryConn_&&(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())}),Math.floor(6e4))}onReset_(t){this.log_("Reset packet received. New host: "+t),this.repoInfo_.host=t,1===this.state_?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(t,e){this.log_("Realtime connection established."),this.conn_=t,this.state_=1,this.onReady_&&(this.onReady_(e,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):dn((()=>{this.sendPingOnPrimaryIfNecessary_()}),Math.floor(5e3))}sendPingOnPrimaryIfNecessary_(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))}onSecondaryConnectionLost_(){const t=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==t&&this.rx_!==t||this.close()}onConnectionLost_(t){this.conn_=null,t||0!==this.state_?1===this.state_&&this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&&(Ts.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()}onConnectionShutdown_(t){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&&(this.onKill_(t),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(t){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(t)}close(){2!==this.state_&&(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&&(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&&(this.conn_.close(),this.conn_=null),this.secondaryConn_&&(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&&(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}class An{put(t,e,i,s){}merge(t,e,i,s){}refreshAuthToken(t){}refreshAppCheckToken(t){}onDisconnectPut(t,e,i){}onDisconnectMerge(t,e,i){}onDisconnectCancel(t,e){}reportStats(t){}}class Sn{constructor(t){this.allowedEvents_=t,this.listeners_={},Yt(Array.isArray(t)&&t.length>0,"Requires a non-empty array")}trigger(t,...e){if(Array.isArray(this.listeners_[t])){const i=[...this.listeners_[t]];for(let t=0;te===t)),"Unknown event: "+t)}}class zn extends Sn{constructor(){super(["online"]),this.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||Xt()||(window.addEventListener("online",(()=>{this.online_||(this.online_=!0,this.trigger("online",!0))}),!1),window.addEventListener("offline",(()=>{this.online_&&(this.online_=!1,this.trigger("online",!1))}),!1))}static getInstance(){return new zn}getInitialEvent(t){return Yt("online"===t,"Unknown event type: "+t),[this.online_]}currentlyOnline(){return this.online_}}class Vn{constructor(t,e){if(void 0===e){this.pieces_=t.split("/");let e=0;for(let t=0;t0&&(this.pieces_[e]=this.pieces_[t],e++);this.pieces_.length=e,this.pieceNum_=0}else this.pieces_=t,this.pieceNum_=e}toString(){let t="";for(let e=this.pieceNum_;e=t.pieces_.length?null:t.pieces_[t.pieceNum_]}function On(t){return t.pieces_.length-t.pieceNum_}function Fn(t){let e=t.pieceNum_;return e=t.pieces_.length)return null;const e=[];for(let i=t.pieceNum_;i0&&i.push(t[e])}return new Vn(i,0)}function Un(t){return t.pieceNum_>=t.pieces_.length}function Bn(t,e){const i=kn(t),s=kn(e);if(null===i)return e;if(i===s)return Bn(Fn(t),Fn(e));throw new Error("INTERNAL ERROR: innerPath ("+e+") is not within outerPath ("+t+")")}function Pn(t,e){if(On(t)!==On(e))return!1;for(let i=t.pieceNum_,s=e.pieceNum_;i<=t.pieces_.length;i++,s++)if(t.pieces_[i]!==e.pieces_[s])return!1;return!0}function _n(t,e){let i=t.pieceNum_,s=e.pieceNum_;if(On(t)>On(e))return!1;for(;i768)throw new Error(t.errorPrefix_+"has a key path longer than 768 bytes ("+t.byteLength_+").");if(t.parts_.length>32)throw new Error(t.errorPrefix_+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+$n(t))}function $n(t){return 0===t.parts_.length?"":"in property '"+t.parts_.join(".")+"'"}class Kn extends Sn{constructor(){let t,e;super(["visible"]),"undefined"!=typeof document&&void 0!==document.addEventListener&&(void 0!==document.hidden?(e="visibilitychange",t="hidden"):void 0!==document.mozHidden?(e="mozvisibilitychange",t="mozHidden"):void 0!==document.msHidden?(e="msvisibilitychange",t="msHidden"):void 0!==document.webkitHidden&&(e="webkitvisibilitychange",t="webkitHidden")),this.visible_=!0,e&&document.addEventListener(e,(()=>{const e=!document[t];e!==this.visible_&&(this.visible_=e,this.trigger("visible",e))}),!1)}static getInstance(){return new Kn}getInitialEvent(t){return Yt("visible"===t,"Unknown event type: "+t),[this.visible_]}}const to=1e3;class eo extends An{constructor(t,e,i,s,n,o,a,r){if(super(),this.repoInfo_=t,this.applicationId_=e,this.onDataUpdate_=i,this.onConnectStatus_=s,this.onServerInfoUpdate_=n,this.authTokenProvider_=o,this.appCheckTokenProvider_=a,this.authOverride_=r,this.id=eo.nextPersistentConnectionId_++,this.log_=Bs("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=to,this.maxReconnectDelay_=3e5,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,r)throw new Error("Auth override specified in options, but not supported on non Node.js platforms");Kn.getInstance().on("visible",this.onVisible_,this),-1===t.host.indexOf("fblocal")&&zn.getInstance().on("online",this.onOnline_,this)}sendRequest(t,e,i){const s=++this.requestNumber_,n={r:s,a:t,b:e};this.log_(Qt(n)),Yt(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(n),i&&(this.requestCBHash_[s]=i)}get(t){this.initConnection_();const e=new Jt,i={action:"g",request:{p:t._path.toString(),q:t._queryObject},onComplete:t=>{const i=t.d;"ok"===t.s?e.resolve(i):e.reject(i)}};this.outstandingGets_.push(i),this.outstandingGetCount_++;const s=this.outstandingGets_.length-1;return this.connected_&&this.sendGet_(s),e.promise}listen(t,e,i,s){this.initConnection_();const n=t._queryIdentifier,o=t._path.toString();this.log_("Listen called for "+o+" "+n),this.listens.has(o)||this.listens.set(o,new Map),Yt(t._queryParams.isDefault()||!t._queryParams.loadsAllData(),"listen() called for non-default but complete query"),Yt(!this.listens.get(o).has(n),"listen() called twice for same path/queryId.");const a={onComplete:s,hashFn:e,query:t,tag:i};this.listens.get(o).set(n,a),this.connected_&&this.sendListen_(a)}sendGet_(t){const e=this.outstandingGets_[t];this.sendRequest("g",e.request,(i=>{delete this.outstandingGets_[t],this.outstandingGetCount_--,0===this.outstandingGetCount_&&(this.outstandingGets_=[]),e.onComplete&&e.onComplete(i)}))}sendListen_(t){const e=t.query,i=e._path.toString(),s=e._queryIdentifier;this.log_("Listen on "+i+" for "+s);const n={p:i};t.tag&&(n.q=e._queryObject,n.t=t.tag),n.h=t.hashFn(),this.sendRequest("q",n,(n=>{const o=n.d,a=n.s;eo.warnOnListenWarnings_(o,e),(this.listens.get(i)&&this.listens.get(i).get(s))===t&&(this.log_("listen response",n),"ok"!==a&&this.removeListen_(i,s),t.onComplete&&t.onComplete(a,o))}))}static warnOnListenWarnings_(t,e){if(t&&"object"==typeof t&&$t(t,"w")){const i=Kt(t,"w");if(Array.isArray(i)&&~i.indexOf("no_index")){const t='".indexOn": "'+e._queryParams.getIndex().toString()+'"',i=e._path.toString();Qs(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${t} at ${i} to your security rules for better performance.`)}}}refreshAuthToken(t){this.authToken_=t,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&&this.sendRequest("unauth",{},(()=>{})),this.reduceReconnectDelayIfAdminCredential_(t)}reduceReconnectDelayIfAdminCredential_(t){(t&&40===t.length||function(t){const e=qt(t).claims;return"object"==typeof e&&!0===e.admin}(t))&&(this.log_("Admin auth credential detected. Reducing max reconnect time."),this.maxReconnectDelay_=3e4)}refreshAppCheckToken(t){this.appCheckToken_=t,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&&this.sendRequest("unappeck",{},(()=>{}))}tryAuth(){if(this.connected_&&this.authToken_){const t=this.authToken_,e=function(t){const e=qt(t).claims;return!!e&&"object"==typeof e&&e.hasOwnProperty("iat")}(t)?"auth":"gauth",i={cred:t};null===this.authOverride_?i.noauth=!0:"object"==typeof this.authOverride_&&(i.authvar=this.authOverride_),this.sendRequest(e,i,(e=>{const i=e.s,s=e.d||"error";this.authToken_===t&&("ok"===i?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(i,s))}))}}tryAppCheck(){this.connected_&&this.appCheckToken_&&this.sendRequest("appcheck",{token:this.appCheckToken_},(t=>{const e=t.s,i=t.d||"error";"ok"===e?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(e,i)}))}unlisten(t,e){const i=t._path.toString(),s=t._queryIdentifier;this.log_("Unlisten called for "+i+" "+s),Yt(t._queryParams.isDefault()||!t._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(i,s)&&this.connected_&&this.sendUnlisten_(i,s,t._queryObject,e)}sendUnlisten_(t,e,i,s){this.log_("Unlisten on "+t+" for "+e);const n={p:t};s&&(n.q=i,n.t=s),this.sendRequest("n",n)}onDisconnectPut(t,e,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",t,e,i):this.onDisconnectRequestQueue_.push({pathString:t,action:"o",data:e,onComplete:i})}onDisconnectMerge(t,e,i){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",t,e,i):this.onDisconnectRequestQueue_.push({pathString:t,action:"om",data:e,onComplete:i})}onDisconnectCancel(t,e){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",t,null,e):this.onDisconnectRequestQueue_.push({pathString:t,action:"oc",data:null,onComplete:e})}sendOnDisconnect_(t,e,i,s){const n={p:e,d:i};this.log_("onDisconnect "+t,n),this.sendRequest(t,n,(t=>{s&&setTimeout((()=>{s(t.s,t.d)}),Math.floor(0))}))}put(t,e,i,s){this.putInternal("p",t,e,i,s)}merge(t,e,i,s){this.putInternal("m",t,e,i,s)}putInternal(t,e,i,s,n){this.initConnection_();const o={p:e,d:i};void 0!==n&&(o.h=n),this.outstandingPuts_.push({action:t,request:o,onComplete:s}),this.outstandingPutCount_++;const a=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(a):this.log_("Buffering put: "+e)}sendPut_(t){const e=this.outstandingPuts_[t].action,i=this.outstandingPuts_[t].request,s=this.outstandingPuts_[t].onComplete;this.outstandingPuts_[t].queued=this.connected_,this.sendRequest(e,i,(i=>{this.log_(e+" response",i),delete this.outstandingPuts_[t],this.outstandingPutCount_--,0===this.outstandingPutCount_&&(this.outstandingPuts_=[]),s&&s(i.s,i.d)}))}reportStats(t){if(this.connected_){const e={c:t};this.log_("reportStats",e),this.sendRequest("s",e,(t=>{if("ok"!==t.s){const e=t.d;this.log_("reportStats","Error sending stats: "+e)}}))}}onDataMessage_(t){if("r"in t){this.log_("from server: "+Qt(t));const e=t.r,i=this.requestCBHash_[e];i&&(delete this.requestCBHash_[e],i(t.b))}else{if("error"in t)throw"A server-side error has occurred: "+t.error;"a"in t&&this.onDataPush_(t.a,t.b)}}onDataPush_(t,e){this.log_("handleServerMessage",t,e),"d"===t?this.onDataUpdate_(e.p,e.d,!1,e.t):"m"===t?this.onDataUpdate_(e.p,e.d,!0,e.t):"c"===t?this.onListenRevoked_(e.p,e.q):"ac"===t?this.onAuthRevoked_(e.s,e.d):"apc"===t?this.onAppCheckRevoked_(e.s,e.d):"sd"===t?this.onSecurityDebugPacket_(e):Ps("Unrecognized action received from server: "+Qt(t)+"\nAre you using the latest client?")}onReady_(t,e){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(t),this.lastSessionId=e,this.firstConnection_&&this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(t){Yt(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&&clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout((()=>{this.establishConnectionTimer_=null,this.establishConnection_()}),Math.floor(t))}initConnection_(){!this.realtime_&&this.firstConnection_&&this.scheduleConnect_(0)}onVisible_(t){t&&!this.visible_&&this.reconnectDelay_===this.maxReconnectDelay_&&(this.log_("Window became visible. Reducing delay."),this.reconnectDelay_=to,this.realtime_||this.scheduleConnect_(0)),this.visible_=t}onOnline_(t){t?(this.log_("Browser went online."),this.reconnectDelay_=to,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline. Killing connection."),this.realtime_&&this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&&((new Date).getTime()-this.lastConnectionEstablishedTime_>3e4&&(this.reconnectDelay_=to),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible. Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime());const t=(new Date).getTime()-this.lastConnectionAttemptTime_;let e=Math.max(0,this.reconnectDelay_-t);e=Math.random()*e,this.log_("Trying to reconnect in "+e+"ms"),this.scheduleConnect_(e),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;const t=this.onDataMessage_.bind(this),e=this.onReady_.bind(this),i=this.onRealtimeDisconnect_.bind(this),s=this.id+":"+eo.nextConnectionId_++,n=this.lastSessionId;let o=!1,a=null;const r=function(){a?a.close():(o=!0,i())},l=function(t){Yt(a,"sendRequest call when we're not connected not allowed."),a.sendRequest(t)};this.realtime_={close:r,sendRequest:l};const h=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[r,l]=await Promise.all([this.authTokenProvider_.getToken(h),this.appCheckTokenProvider_.getToken(h)]);o?Us("getToken() completed but was canceled"):(Us("getToken() completed. Creating connection."),this.authToken_=r&&r.accessToken,this.appCheckToken_=l&&l.token,a=new gn(s,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,t,e,i,(t=>{Qs(t+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")}),n))}catch(t){this.log_("Failed to get token: "+t),o||(this.repoInfo_.nodeAdmin&&Qs(t),r())}}}interrupt(t){Us("Interrupting connection for reason: "+t),this.interruptReasons_[t]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&&(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&&this.onRealtimeDisconnect_())}resume(t){Us("Resuming connection for reason: "+t),delete this.interruptReasons_[t],te(this.interruptReasons_)&&(this.reconnectDelay_=to,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(t){const e=t-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:e})}cancelSentTransactions_(){for(let t=0;tnn(t))).join("$"):"default";const s=this.removeListen_(t,i);s&&s.onComplete&&s.onComplete("permission_denied")}removeListen_(t,e){const i=new Vn(t).toString();let s;if(this.listens.has(i)){const t=this.listens.get(i);s=t.get(e),t.delete(e),0===t.size&&this.listens.delete(i)}else s=void 0;return s}onAuthRevoked_(t,e){Us("Auth token revoked: "+t+"/"+e),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==t&&"permission_denied"!==t||(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_>=3&&(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(t,e){Us("App check token revoked: "+t+"/"+e),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==t&&"permission_denied"!==t||(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_>=3&&this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(t){this.securityDebugCallback_?this.securityDebugCallback_(t):"msg"in t&&console.log("FIREBASE: "+t.msg.replace("\n","\nFIREBASE: "))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const t of this.listens.values())for(const e of t.values())this.sendListen_(e);for(let t=0;t0}peek(){if(0===this.nodeStack_.length)return null;const t=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(t.key,t.value):{key:t.key,value:t.value}}}class lo{constructor(t,e,i,s,n){this.key=t,this.value=e,this.color=null!=i?i:lo.RED,this.left=null!=s?s:ho.EMPTY_NODE,this.right=null!=n?n:ho.EMPTY_NODE}copy(t,e,i,s,n){return new lo(null!=t?t:this.key,null!=e?e:this.value,null!=i?i:this.color,null!=s?s:this.left,null!=n?n:this.right)}count(){return this.left.count()+1+this.right.count()}isEmpty(){return!1}inorderTraversal(t){return this.left.inorderTraversal(t)||!!t(this.key,this.value)||this.right.inorderTraversal(t)}reverseTraversal(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)}min_(){return this.left.isEmpty()?this:this.left.min_()}minKey(){return this.min_().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(t,e,i){let s=this;const n=i(t,s.key);return s=n<0?s.copy(null,null,null,s.left.insert(t,e,i),null):0===n?s.copy(null,e,null,null,null):s.copy(null,null,null,null,s.right.insert(t,e,i)),s.fixUp_()}removeMin_(){if(this.left.isEmpty())return ho.EMPTY_NODE;let t=this;return t.left.isRed_()||t.left.left.isRed_()||(t=t.moveRedLeft_()),t=t.copy(null,null,null,t.left.removeMin_(),null),t.fixUp_()}remove(t,e){let i,s;if(i=this,e(t,i.key)<0)i.left.isEmpty()||i.left.isRed_()||i.left.left.isRed_()||(i=i.moveRedLeft_()),i=i.copy(null,null,null,i.left.remove(t,e),null);else{if(i.left.isRed_()&&(i=i.rotateRight_()),i.right.isEmpty()||i.right.isRed_()||i.right.left.isRed_()||(i=i.moveRedRight_()),0===e(t,i.key)){if(i.right.isEmpty())return ho.EMPTY_NODE;s=i.right.min_(),i=i.copy(s.key,s.value,null,null,i.right.removeMin_())}i=i.copy(null,null,null,null,i.right.remove(t,e))}return i.fixUp_()}isRed_(){return this.color}fixUp_(){let t=this;return t.right.isRed_()&&!t.left.isRed_()&&(t=t.rotateLeft_()),t.left.isRed_()&&t.left.left.isRed_()&&(t=t.rotateRight_()),t.left.isRed_()&&t.right.isRed_()&&(t=t.colorFlip_()),t}moveRedLeft_(){let t=this.colorFlip_();return t.right.left.isRed_()&&(t=t.copy(null,null,null,null,t.right.rotateRight_()),t=t.rotateLeft_(),t=t.colorFlip_()),t}moveRedRight_(){let t=this.colorFlip_();return t.left.left.isRed_()&&(t=t.rotateRight_(),t=t.colorFlip_()),t}rotateLeft_(){const t=this.copy(null,null,lo.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight_(){const t=this.copy(null,null,lo.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip_(){const t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)}checkMaxDepth_(){const t=this.check_();return Math.pow(2,t)<=this.count()+1}check_(){if(this.isRed_()&&this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");const t=this.left.check_();if(t!==this.right.check_())throw new Error("Black depths differ");return t+(this.isRed_()?0:1)}}lo.RED=!0,lo.BLACK=!1;class ho{constructor(t,e=ho.EMPTY_NODE){this.comparator_=t,this.root_=e}insert(t,e){return new ho(this.comparator_,this.root_.insert(t,e,this.comparator_).copy(null,null,lo.BLACK,null,null))}remove(t){return new ho(this.comparator_,this.root_.remove(t,this.comparator_).copy(null,null,lo.BLACK,null,null))}get(t){let e,i=this.root_;for(;!i.isEmpty();){if(e=this.comparator_(t,i.key),0===e)return i.value;e<0?i=i.left:e>0&&(i=i.right)}return null}getPredecessorKey(t){let e,i=this.root_,s=null;for(;!i.isEmpty();){if(e=this.comparator_(t,i.key),0===e){if(i.left.isEmpty())return s?s.key:null;for(i=i.left;!i.right.isEmpty();)i=i.right;return i.key}e<0?i=i.left:e>0&&(s=i,i=i.right)}throw new Error("Attempted to find predecessor key for a nonexistent key. What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(t){return this.root_.inorderTraversal(t)}reverseTraversal(t){return this.root_.reverseTraversal(t)}getIterator(t){return new ro(this.root_,null,this.comparator_,!1,t)}getIteratorFrom(t,e){return new ro(this.root_,t,this.comparator_,!1,e)}getReverseIteratorFrom(t,e){return new ro(this.root_,t,this.comparator_,!0,e)}getReverseIterator(t){return new ro(this.root_,null,this.comparator_,!0,t)}}function co(t,e){return tn(t.name,e.name)}function Io(t,e){return tn(t,e)}let uo;ho.EMPTY_NODE=new class{copy(t,e,i,s,n){return this}insert(t,e,i){return new lo(t,e,null)}remove(t,e){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(t){return!1}reverseTraversal(t){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}};const po=function(t){return"number"==typeof t?"number:"+rn(t):"string:"+t},bo=function(t){if(t.isLeafNode()){const e=t.val();Yt("string"==typeof e||"number"==typeof e||"object"==typeof e&&$t(e,".sv"),"Priority must be a string or number.")}else Yt(t===uo||t.isEmpty(),"priority of unexpected type.");Yt(t===uo||t.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};let mo,yo,Lo;class Mo{constructor(t,e=Mo.__childrenNodeConstructor.EMPTY_NODE){this.value_=t,this.priorityNode_=e,this.lazyHash_=null,Yt(void 0!==this.value_&&null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),bo(this.priorityNode_)}static set __childrenNodeConstructor(t){mo=t}static get __childrenNodeConstructor(){return mo}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(t){return new Mo(this.value_,t)}getImmediateChild(t){return".priority"===t?this.priorityNode_:Mo.__childrenNodeConstructor.EMPTY_NODE}getChild(t){return Un(t)?this:".priority"===kn(t)?this.priorityNode_:Mo.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(t,e){return null}updateImmediateChild(t,e){return".priority"===t?this.updatePriority(e):e.isEmpty()&&".priority"!==t?this:Mo.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(t,e).updatePriority(this.priorityNode_)}updateChild(t,e){const i=kn(t);return null===i?e:e.isEmpty()&&".priority"!==i?this:(Yt(".priority"!==i||1===On(t),".priority must be the last token in a path"),this.updateImmediateChild(i,Mo.__childrenNodeConstructor.EMPTY_NODE.updateChild(Fn(t),e)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(t,e){return!1}val(t){return t&&!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(null===this.lazyHash_){let t="";this.priorityNode_.isEmpty()||(t+="priority:"+po(this.priorityNode_.val())+":");const e=typeof this.value_;t+=e+":",t+="number"===e?rn(this.value_):this.value_,this.lazyHash_=Js(t)}return this.lazyHash_}getValue(){return this.value_}compareTo(t){return t===Mo.__childrenNodeConstructor.EMPTY_NODE?1:t instanceof Mo.__childrenNodeConstructor?-1:(Yt(t.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(t))}compareToLeafNode_(t){const e=typeof t.value_,i=typeof this.value_,s=Mo.VALUE_TYPE_ORDER.indexOf(e),n=Mo.VALUE_TYPE_ORDER.indexOf(i);return Yt(s>=0,"Unknown leaf type: "+e),Yt(n>=0,"Unknown leaf type: "+i),s===n?"object"===i?0:this.value_{const n=Kt(this.indexSet_,s);if(Yt(n,"Missing index implementation for "+s),i===Co){if(n.isDefinedOn(t.node)){const i=[],s=e.getIterator(io.Wrap);let o=s.getNext();for(;o;)o.name!==t.name&&i.push(o),o=s.getNext();return i.push(t),jo(i,n.getCompare())}return Co}{const s=e.get(t.name);let n=i;return s&&(n=n.remove(new io(t.name,s))),n.insert(t,t.node)}}));return new Go(i,this.indexSet_)}removeFromIndexes(t,e){const i=ee(this.indexes_,(i=>{if(i===Co)return i;{const s=e.get(t.name);return s?i.remove(new io(t.name,s)):i}}));return new Go(i,this.indexSet_)}}let fo;class No{constructor(t,e,i){this.children_=t,this.priorityNode_=e,this.indexMap_=i,this.lazyHash_=null,this.priorityNode_&&bo(this.priorityNode_),this.children_.isEmpty()&&Yt(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}static get EMPTY_NODE(){return fo||(fo=new No(new ho(Io),null,Go.Default))}isLeafNode(){return!1}getPriority(){return this.priorityNode_||fo}updatePriority(t){return this.children_.isEmpty()?this:new No(this.children_,t,this.indexMap_)}getImmediateChild(t){if(".priority"===t)return this.getPriority();{const e=this.children_.get(t);return null===e?fo:e}}getChild(t){const e=kn(t);return null===e?this:this.getImmediateChild(e).getChild(Fn(t))}hasChild(t){return null!==this.children_.get(t)}updateImmediateChild(t,e){if(Yt(e,"We should always be passing snapshot nodes"),".priority"===t)return this.updatePriority(e);{const i=new io(t,e);let s,n;e.isEmpty()?(s=this.children_.remove(t),n=this.indexMap_.removeFromIndexes(i,this.children_)):(s=this.children_.insert(t,e),n=this.indexMap_.addToIndexes(i,this.children_));const o=s.isEmpty()?fo:this.priorityNode_;return new No(s,o,n)}}updateChild(t,e){const i=kn(t);if(null===i)return e;{Yt(".priority"!==kn(t)||1===On(t),".priority must be the last token in a path");const s=this.getImmediateChild(i).updateChild(Fn(t),e);return this.updateImmediateChild(i,s)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(t){if(this.isEmpty())return null;const e={};let i=0,s=0,n=!0;if(this.forEachChild(Wo,((o,a)=>{e[o]=a.val(t),i++,n&&No.INTEGER_REGEXP_.test(o)?s=Math.max(s,Number(o)):n=!1})),!t&&n&&s<2*i){const t=[];for(const i in e)t[i]=e[i];return t}return t&&!this.getPriority().isEmpty()&&(e[".priority"]=this.getPriority().val()),e}hash(){if(null===this.lazyHash_){let t="";this.getPriority().isEmpty()||(t+="priority:"+po(this.getPriority().val())+":"),this.forEachChild(Wo,((e,i)=>{const s=i.hash();""!==s&&(t+=":"+e+":"+s)})),this.lazyHash_=""===t?"":Js(t)}return this.lazyHash_}getPredecessorChildName(t,e,i){const s=this.resolveIndex_(i);if(s){const i=s.getPredecessorKey(new io(t,e));return i?i.name:null}return this.children_.getPredecessorKey(t)}getFirstChildName(t){const e=this.resolveIndex_(t);if(e){const t=e.minKey();return t&&t.name}return this.children_.minKey()}getFirstChild(t){const e=this.getFirstChildName(t);return e?new io(e,this.children_.get(e)):null}getLastChildName(t){const e=this.resolveIndex_(t);if(e){const t=e.maxKey();return t&&t.name}return this.children_.maxKey()}getLastChild(t){const e=this.getLastChildName(t);return e?new io(e,this.children_.get(e)):null}forEachChild(t,e){const i=this.resolveIndex_(t);return i?i.inorderTraversal((t=>e(t.name,t.node))):this.children_.inorderTraversal(e)}getIterator(t){return this.getIteratorFrom(t.minPost(),t)}getIteratorFrom(t,e){const i=this.resolveIndex_(e);if(i)return i.getIteratorFrom(t,(t=>t));{const i=this.children_.getIteratorFrom(t.name,io.Wrap);let s=i.peek();for(;null!=s&&e.compare(s,t)<0;)i.getNext(),s=i.peek();return i}}getReverseIterator(t){return this.getReverseIteratorFrom(t.maxPost(),t)}getReverseIteratorFrom(t,e){const i=this.resolveIndex_(e);if(i)return i.getReverseIteratorFrom(t,(t=>t));{const i=this.children_.getReverseIteratorFrom(t.name,io.Wrap);let s=i.peek();for(;null!=s&&e.compare(s,t)>0;)i.getNext(),s=i.peek();return i}}compareTo(t){return this.isEmpty()?t.isEmpty()?0:-1:t.isLeafNode()||t.isEmpty()?1:t===xo?-1:0}withIndex(t){if(t===ao||this.indexMap_.hasIndex(t))return this;{const e=this.indexMap_.addIndex(t,this.children_);return new No(this.children_,this.priorityNode_,e)}}isIndexed(t){return t===ao||this.indexMap_.hasIndex(t)}equals(t){if(t===this)return!0;if(t.isLeafNode())return!1;{const e=t;if(this.getPriority().equals(e.getPriority())){if(this.children_.count()===e.children_.count()){const t=this.getIterator(Wo),i=e.getIterator(Wo);let s=t.getNext(),n=i.getNext();for(;s&&n;){if(s.name!==n.name||!s.node.equals(n.node))return!1;s=t.getNext(),n=i.getNext()}return null===s&&null===n}return!1}return!1}}resolveIndex_(t){return t===ao?null:this.indexMap_.get(t.toString())}}No.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;const xo=new class extends No{constructor(){super(new ho(Io),No.EMPTY_NODE,Go.Default)}compareTo(t){return t===this?0:1}equals(t){return t===this}getPriority(){return this}getImmediateChild(t){return No.EMPTY_NODE}isEmpty(){return!1}};Object.defineProperties(io,{MIN:{value:new io($s,No.EMPTY_NODE)},MAX:{value:new io(Ks,xo)}}),oo.__EMPTY_NODE=No.EMPTY_NODE,Mo.__childrenNodeConstructor=No,uo=xo,Lo=xo;const Yo=!0;function Ro(t,e=null){if(null===t)return No.EMPTY_NODE;if("object"==typeof t&&".priority"in t&&(e=t[".priority"]),Yt(null===e||"string"==typeof e||"number"==typeof e||"object"==typeof e&&".sv"in e,"Invalid priority type found: "+typeof e),"object"==typeof t&&".value"in t&&null!==t[".value"]&&(t=t[".value"]),"object"!=typeof t||".sv"in t)return new Mo(t,Ro(e));if(t instanceof Array||!Yo){let i=No.EMPTY_NODE;return an(t,((e,s)=>{if($t(t,e)&&"."!==e.substring(0,1)){const t=Ro(s);!t.isLeafNode()&&t.isEmpty()||(i=i.updateImmediateChild(e,t))}})),i.updatePriority(Ro(e))}{const i=[];let s=!1;if(an(t,((t,e)=>{if("."!==t.substring(0,1)){const n=Ro(e);n.isEmpty()||(s=s||!n.getPriority().isEmpty(),i.push(new io(t,n)))}})),0===i.length)return No.EMPTY_NODE;const n=jo(i,co,(t=>t.name),Io);if(s){const t=jo(i,Wo.getCompare());return new No(n,Ro(e),new Go({".priority":t},{".priority":Wo}))}return new No(n,Ro(e),Go.Default)}}!function(t){yo=t}(Ro);class Ho extends so{constructor(t){super(),this.indexPath_=t,Yt(!Un(t)&&".priority"!==kn(t),"Can't create PathIndex with empty path or .priority key")}extractChild(t){return t.getChild(this.indexPath_)}isDefinedOn(t){return!t.getChild(this.indexPath_).isEmpty()}compare(t,e){const i=this.extractChild(t.node),s=this.extractChild(e.node),n=i.compareTo(s);return 0===n?tn(t.name,e.name):n}makePost(t,e){const i=Ro(t),s=No.EMPTY_NODE.updateChild(this.indexPath_,i);return new io(e,s)}maxPost(){const t=No.EMPTY_NODE.updateChild(this.indexPath_,xo);return new io(Ks,t)}toString(){return Xn(this.indexPath_,0).join("/")}}const go=new class extends so{compare(t,e){const i=t.node.compareTo(e.node);return 0===i?tn(t.name,e.name):i}isDefinedOn(t){return!0}indexedValueChanged(t,e){return!t.equals(e)}minPost(){return io.MIN}maxPost(){return io.MAX}makePost(t,e){const i=Ro(t);return new io(e,i)}toString(){return".value"}};function Ao(t){return{type:"value",snapshotNode:t}}function So(t,e){return{type:"child_added",snapshotNode:e,childName:t}}function zo(t,e){return{type:"child_removed",snapshotNode:e,childName:t}}function Vo(t,e,i){return{type:"child_changed",snapshotNode:e,childName:t,oldSnap:i}}class To{constructor(t){this.index_=t}updateChild(t,e,i,s,n,o){Yt(t.isIndexed(this.index_),"A node must be indexed if only a child is updated");const a=t.getImmediateChild(e);return a.getChild(s).equals(i.getChild(s))&&a.isEmpty()===i.isEmpty()?t:(null!=o&&(i.isEmpty()?t.hasChild(e)?o.trackChildChange(zo(e,a)):Yt(t.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(So(e,i)):o.trackChildChange(Vo(e,i,a))),t.isLeafNode()&&i.isEmpty()?t:t.updateImmediateChild(e,i).withIndex(this.index_))}updateFullNode(t,e,i){return null!=i&&(t.isLeafNode()||t.forEachChild(Wo,((t,s)=>{e.hasChild(t)||i.trackChildChange(zo(t,s))})),e.isLeafNode()||e.forEachChild(Wo,((e,s)=>{if(t.hasChild(e)){const n=t.getImmediateChild(e);n.equals(s)||i.trackChildChange(Vo(e,s,n))}else i.trackChildChange(So(e,s))}))),e.withIndex(this.index_)}updatePriority(t,e){return t.isEmpty()?No.EMPTY_NODE:t.updatePriority(e)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}class ko{constructor(t){this.indexedFilter_=new To(t.getIndex()),this.index_=t.getIndex(),this.startPost_=ko.getStartPost_(t),this.endPost_=ko.getEndPost_(t),this.startIsInclusive_=!t.startAfterSet_,this.endIsInclusive_=!t.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(t){const e=this.startIsInclusive_?this.index_.compare(this.getStartPost(),t)<=0:this.index_.compare(this.getStartPost(),t)<0,i=this.endIsInclusive_?this.index_.compare(t,this.getEndPost())<=0:this.index_.compare(t,this.getEndPost())<0;return e&&i}updateChild(t,e,i,s,n,o){return this.matches(new io(e,i))||(i=No.EMPTY_NODE),this.indexedFilter_.updateChild(t,e,i,s,n,o)}updateFullNode(t,e,i){e.isLeafNode()&&(e=No.EMPTY_NODE);let s=e.withIndex(this.index_);s=s.updatePriority(No.EMPTY_NODE);const n=this;return e.forEachChild(Wo,((t,e)=>{n.matches(new io(t,e))||(s=s.updateImmediateChild(t,No.EMPTY_NODE))})),this.indexedFilter_.updateFullNode(t,s,i)}updatePriority(t,e){return t}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(t){if(t.hasStart()){const e=t.getIndexStartName();return t.getIndex().makePost(t.getIndexStartValue(),e)}return t.getIndex().minPost()}static getEndPost_(t){if(t.hasEnd()){const e=t.getIndexEndName();return t.getIndex().makePost(t.getIndexEndValue(),e)}return t.getIndex().maxPost()}}class Oo{constructor(t){this.withinDirectionalStart=t=>this.reverse_?this.withinEndPost(t):this.withinStartPost(t),this.withinDirectionalEnd=t=>this.reverse_?this.withinStartPost(t):this.withinEndPost(t),this.withinStartPost=t=>{const e=this.index_.compare(this.rangedFilter_.getStartPost(),t);return this.startIsInclusive_?e<=0:e<0},this.withinEndPost=t=>{const e=this.index_.compare(t,this.rangedFilter_.getEndPost());return this.endIsInclusive_?e<=0:e<0},this.rangedFilter_=new ko(t),this.index_=t.getIndex(),this.limit_=t.getLimit(),this.reverse_=!t.isViewFromLeft(),this.startIsInclusive_=!t.startAfterSet_,this.endIsInclusive_=!t.endBeforeSet_}updateChild(t,e,i,s,n,o){return this.rangedFilter_.matches(new io(e,i))||(i=No.EMPTY_NODE),t.getImmediateChild(e).equals(i)?t:t.numChildren()t(i,e)}else o=this.index_.getCompare();const a=t;Yt(a.numChildren()===this.limit_,"");const r=new io(e,i),l=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),h=this.rangedFilter_.matches(r);if(a.hasChild(e)){const t=a.getImmediateChild(e);let c=s.getChildAfterChild(this.index_,l,this.reverse_);for(;null!=c&&(c.name===e||a.hasChild(c.name));)c=s.getChildAfterChild(this.index_,c,this.reverse_);const d=null==c?1:o(c,r);if(h&&!i.isEmpty()&&d>=0)return null!=n&&n.trackChildChange(Vo(e,i,t)),a.updateImmediateChild(e,i);{null!=n&&n.trackChildChange(zo(e,t));const i=a.updateImmediateChild(e,No.EMPTY_NODE);return null!=c&&this.rangedFilter_.matches(c)?(null!=n&&n.trackChildChange(So(c.name,c.node)),i.updateImmediateChild(c.name,c.node)):i}}return i.isEmpty()?t:h&&o(l,r)>=0?(null!=n&&(n.trackChildChange(zo(l.name,l.node)),n.trackChildChange(So(e,i))),a.updateImmediateChild(e,i).updateImmediateChild(l.name,No.EMPTY_NODE)):t}}class Fo{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=Wo}hasStart(){return this.startSet_}isViewFromLeft(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_}getIndexStartValue(){return Yt(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return Yt(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:$s}hasEnd(){return this.endSet_}getIndexEndValue(){return Yt(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return Yt(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:Ks}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&&""!==this.viewFrom_}getLimit(){return Yt(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&&this.index_===Wo}copy(){const t=new Fo;return t.limitSet_=this.limitSet_,t.limit_=this.limit_,t.startSet_=this.startSet_,t.startAfterSet_=this.startAfterSet_,t.indexStartValue_=this.indexStartValue_,t.startNameSet_=this.startNameSet_,t.indexStartName_=this.indexStartName_,t.endSet_=this.endSet_,t.endBeforeSet_=this.endBeforeSet_,t.indexEndValue_=this.indexEndValue_,t.endNameSet_=this.endNameSet_,t.indexEndName_=this.indexEndName_,t.index_=this.index_,t.viewFrom_=this.viewFrom_,t}}function Jo(t){const e={};if(t.isDefault())return e;let i;if(t.index_===Wo?i="$priority":t.index_===go?i="$value":t.index_===ao?i="$key":(Yt(t.index_ instanceof Ho,"Unrecognized index type!"),i=t.index_.toString()),e.orderBy=Qt(i),t.startSet_){const i=t.startAfterSet_?"startAfter":"startAt";e[i]=Qt(t.indexStartValue_),t.startNameSet_&&(e[i]+=","+Qt(t.indexStartName_))}if(t.endSet_){const i=t.endBeforeSet_?"endBefore":"endAt";e[i]=Qt(t.indexEndValue_),t.endNameSet_&&(e[i]+=","+Qt(t.indexEndName_))}return t.limitSet_&&(t.isViewFromLeft()?e.limitToFirst=t.limit_:e.limitToLast=t.limit_),e}function Xo(t){const e={};if(t.startSet_&&(e.sp=t.indexStartValue_,t.startNameSet_&&(e.sn=t.indexStartName_),e.sin=!t.startAfterSet_),t.endSet_&&(e.ep=t.indexEndValue_,t.endNameSet_&&(e.en=t.indexEndName_),e.ein=!t.endBeforeSet_),t.limitSet_){e.l=t.limit_;let i=t.viewFrom_;""===i&&(i=t.isViewFromLeft()?"l":"r"),e.vf=i}return t.index_!==Wo&&(e.i=t.index_.toString()),e}class Eo extends An{constructor(t,e,i,s){super(),this.repoInfo_=t,this.onDataUpdate_=e,this.authTokenProvider_=i,this.appCheckTokenProvider_=s,this.log_=Bs("p:rest:"),this.listens_={}}reportStats(t){throw new Error("Method not implemented.")}static getListenId_(t,e){return void 0!==e?"tag$"+e:(Yt(t._queryParams.isDefault(),"should have a tag if it's not a default query."),t._path.toString())}listen(t,e,i,s){const n=t._path.toString();this.log_("Listen called for "+n+" "+t._queryIdentifier);const o=Eo.getListenId_(t,i),a={};this.listens_[o]=a;const r=Jo(t._queryParams);this.restRequest_(n+".json",r,((t,e)=>{let r=e;if(404===t&&(r=null,t=null),null===t&&this.onDataUpdate_(n,r,!1,i),Kt(this.listens_,o)===a){let e;e=t?401===t?"permission_denied":"rest_error:"+t:"ok",s(e,null)}}))}unlisten(t,e){const i=Eo.getListenId_(t,e);delete this.listens_[i]}get(t){const e=Jo(t._queryParams),i=t._path.toString(),s=new Jt;return this.restRequest_(i+".json",e,((t,e)=>{let n=e;404===t&&(n=null,t=null),null===t?(this.onDataUpdate_(i,n,!1,null),s.resolve(n)):s.reject(new Error(n))})),s.promise}refreshAuthToken(t){}restRequest_(t,e={},i){return e.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then((([s,n])=>{s&&s.accessToken&&(e.auth=s.accessToken),n&&n.token&&(e.ac=n.token);const o=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+t+"?ns="+this.repoInfo_.namespace+function(t){const e=[];for(const[i,s]of Object.entries(t))Array.isArray(s)?s.forEach((t=>{e.push(encodeURIComponent(i)+"="+encodeURIComponent(t))})):e.push(encodeURIComponent(i)+"="+encodeURIComponent(s));return e.length?"&"+e.join("&"):""}(e);this.log_("Sending REST request for "+o);const a=new XMLHttpRequest;a.onreadystatechange=()=>{if(i&&4===a.readyState){this.log_("REST Response for "+o+" received. status:",a.status,"response:",a.responseText);let t=null;if(a.status>=200&&a.status<300){try{t=_t(a.responseText)}catch(t){Qs("Failed to parse JSON response for "+o+": "+a.responseText)}i(null,t)}else 401!==a.status&&404!==a.status&&Qs("Got unsuccessful REST response for "+o+" Status: "+a.status),i(a.status);i=null}},a.open("GET",o,!0),a.send()}))}}class Do{constructor(){this.rootNode_=No.EMPTY_NODE}getNode(t){return this.rootNode_.getChild(t)}updateSnapshot(t,e){this.rootNode_=this.rootNode_.updateChild(t,e)}}function Uo(){return{value:null,children:new Map}}function Bo(t,e,i){if(Un(e))t.value=i,t.children.clear();else if(null!==t.value)t.value=t.value.updateChild(e,i);else{const s=kn(e);t.children.has(s)||t.children.set(s,Uo()),Bo(t.children.get(s),e=Fn(e),i)}}function Po(t,e,i){null!==t.value?i(e,t.value):function(t,e){t.children.forEach(((t,i)=>{e(i,t)}))}(t,((t,s)=>{Po(s,new Vn(e.toString()+"/"+t),i)}))}class _o{constructor(t){this.collection_=t,this.last_=null}get(){const t=this.collection_.get(),e=Object.assign({},t);return this.last_&&an(this.last_,((t,i)=>{e[t]=e[t]-i})),this.last_=t,e}}class Qo{constructor(t,e){this.server_=e,this.statsToReport_={},this.statsListener_=new _o(t);const i=1e4+2e4*Math.random();dn(this.reportStats_.bind(this),Math.floor(i))}reportStats_(){const t=this.statsListener_.get(),e={};let i=!1;an(t,((t,s)=>{s>0&&$t(this.statsToReport_,t)&&(e[t]=s,i=!0)})),i&&this.server_.reportStats(e),dn(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))}}var qo;function $o(t){return{fromUser:!1,fromServer:!0,queryId:t,tagged:!0}}!function(t){t[t.OVERWRITE=0]="OVERWRITE",t[t.MERGE=1]="MERGE",t[t.ACK_USER_WRITE=2]="ACK_USER_WRITE",t[t.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(qo||(qo={}));class Ko{constructor(t,e,i){this.path=t,this.affectedTree=e,this.revert=i,this.type=qo.ACK_USER_WRITE,this.source={fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}operationForChild(t){if(Un(this.path)){if(null!=this.affectedTree.value)return Yt(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const e=this.affectedTree.subtree(new Vn(t));return new Ko(Tn(),e,this.revert)}}return Yt(kn(this.path)===t,"operationForChild called for unrelated child."),new Ko(Fn(this.path),this.affectedTree,this.revert)}}class ta{constructor(t,e){this.source=t,this.path=e,this.type=qo.LISTEN_COMPLETE}operationForChild(t){return Un(this.path)?new ta(this.source,Tn()):new ta(this.source,Fn(this.path))}}class ea{constructor(t,e,i){this.source=t,this.path=e,this.snap=i,this.type=qo.OVERWRITE}operationForChild(t){return Un(this.path)?new ea(this.source,Tn(),this.snap.getImmediateChild(t)):new ea(this.source,Fn(this.path),this.snap)}}class ia{constructor(t,e,i){this.source=t,this.path=e,this.children=i,this.type=qo.MERGE}operationForChild(t){if(Un(this.path)){const e=this.children.subtree(new Vn(t));return e.isEmpty()?null:e.value?new ea(this.source,Tn(),e.value):new ia(this.source,Tn(),e)}return Yt(kn(this.path)===t,"Can't get a merge for a child not on the path of the operation"),new ia(this.source,Fn(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}class sa{constructor(t,e,i){this.node_=t,this.fullyInitialized_=e,this.filtered_=i}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(t){if(Un(t))return this.isFullyInitialized()&&!this.filtered_;const e=kn(t);return this.isCompleteForChild(e)}isCompleteForChild(t){return this.isFullyInitialized()&&!this.filtered_||this.node_.hasChild(t)}getNode(){return this.node_}}class na{constructor(t){this.query_=t,this.index_=this.query_._queryParams.getIndex()}}function oa(t,e,i,s,n,o){const a=s.filter((t=>t.type===i));a.sort(((e,i)=>function(t,e,i){if(null==e.childName||null==i.childName)throw Rt("Should only compare child_ events.");const s=new io(e.childName,e.snapshotNode),n=new io(i.childName,i.snapshotNode);return t.index_.compare(s,n)}(t,e,i))),a.forEach((i=>{const s=function(t,e,i){return"value"===e.type||"child_removed"===e.type||(e.prevName=i.getPredecessorChildName(e.childName,e.snapshotNode,t.index_)),e}(t,i,o);n.forEach((n=>{n.respondsTo(i.type)&&e.push(n.createEvent(s,t.query_))}))}))}function aa(t,e){return{eventCache:t,serverCache:e}}function ra(t,e,i,s){return aa(new sa(e,i,s),t.serverCache)}function la(t,e,i,s){return aa(t.eventCache,new sa(e,i,s))}function ha(t){return t.eventCache.isFullyInitialized()?t.eventCache.getNode():null}function ca(t){return t.serverCache.isFullyInitialized()?t.serverCache.getNode():null}let da;class Ia{constructor(t,e=(()=>(da||(da=new ho(en)),da))()){this.value=t,this.children=e}static fromObject(t){let e=new Ia(null);return an(t,((t,i)=>{e=e.set(new Vn(t),i)})),e}isEmpty(){return null===this.value&&this.children.isEmpty()}findRootMostMatchingPathAndValue(t,e){if(null!=this.value&&e(this.value))return{path:Tn(),value:this.value};if(Un(t))return null;{const i=kn(t),s=this.children.get(i);if(null!==s){const n=s.findRootMostMatchingPathAndValue(Fn(t),e);return null!=n?{path:Dn(new Vn(i),n.path),value:n.value}:null}return null}}findRootMostValueAndPath(t){return this.findRootMostMatchingPathAndValue(t,(()=>!0))}subtree(t){if(Un(t))return this;{const e=kn(t),i=this.children.get(e);return null!==i?i.subtree(Fn(t)):new Ia(null)}}set(t,e){if(Un(t))return new Ia(e,this.children);{const i=kn(t),s=(this.children.get(i)||new Ia(null)).set(Fn(t),e),n=this.children.insert(i,s);return new Ia(this.value,n)}}remove(t){if(Un(t))return this.children.isEmpty()?new Ia(null):new Ia(null,this.children);{const e=kn(t),i=this.children.get(e);if(i){const s=i.remove(Fn(t));let n;return n=s.isEmpty()?this.children.remove(e):this.children.insert(e,s),null===this.value&&n.isEmpty()?new Ia(null):new Ia(this.value,n)}return this}}get(t){if(Un(t))return this.value;{const e=kn(t),i=this.children.get(e);return i?i.get(Fn(t)):null}}setTree(t,e){if(Un(t))return e;{const i=kn(t),s=(this.children.get(i)||new Ia(null)).setTree(Fn(t),e);let n;return n=s.isEmpty()?this.children.remove(i):this.children.insert(i,s),new Ia(this.value,n)}}fold(t){return this.fold_(Tn(),t)}fold_(t,e){const i={};return this.children.inorderTraversal(((s,n)=>{i[s]=n.fold_(Dn(t,s),e)})),e(t,this.value,i)}findOnPath(t,e){return this.findOnPath_(t,Tn(),e)}findOnPath_(t,e,i){const s=!!this.value&&i(e,this.value);if(s)return s;if(Un(t))return null;{const s=kn(t),n=this.children.get(s);return n?n.findOnPath_(Fn(t),Dn(e,s),i):null}}foreachOnPath(t,e){return this.foreachOnPath_(t,Tn(),e)}foreachOnPath_(t,e,i){if(Un(t))return this;{this.value&&i(e,this.value);const s=kn(t),n=this.children.get(s);return n?n.foreachOnPath_(Fn(t),Dn(e,s),i):new Ia(null)}}foreach(t){this.foreach_(Tn(),t)}foreach_(t,e){this.children.inorderTraversal(((i,s)=>{s.foreach_(Dn(t,i),e)})),this.value&&e(t,this.value)}foreachChild(t){this.children.inorderTraversal(((e,i)=>{i.value&&t(e,i.value)}))}}class ua{constructor(t){this.writeTree_=t}static empty(){return new ua(new Ia(null))}}function pa(t,e,i){if(Un(e))return new ua(new Ia(i));{const s=t.writeTree_.findRootMostValueAndPath(e);if(null!=s){const n=s.path;let o=s.value;const a=Bn(n,e);return o=o.updateChild(a,i),new ua(t.writeTree_.set(n,o))}{const s=new Ia(i),n=t.writeTree_.setTree(e,s);return new ua(n)}}}function ba(t,e,i){let s=t;return an(i,((t,i)=>{s=pa(s,Dn(e,t),i)})),s}function ma(t,e){if(Un(e))return ua.empty();{const i=t.writeTree_.setTree(e,new Ia(null));return new ua(i)}}function ya(t,e){return null!=La(t,e)}function La(t,e){const i=t.writeTree_.findRootMostValueAndPath(e);return null!=i?t.writeTree_.get(i.path).getChild(Bn(i.path,e)):null}function Ma(t){const e=[],i=t.writeTree_.value;return null!=i?i.isLeafNode()||i.forEachChild(Wo,((t,i)=>{e.push(new io(t,i))})):t.writeTree_.children.inorderTraversal(((t,i)=>{null!=i.value&&e.push(new io(t,i.value))})),e}function Wa(t,e){if(Un(e))return t;{const i=La(t,e);return new ua(null!=i?new Ia(i):t.writeTree_.subtree(e))}}function wa(t){return t.writeTree_.isEmpty()}function va(t,e){return ja(Tn(),t.writeTree_,e)}function ja(t,e,i){if(null!=e.value)return i.updateChild(t,e.value);{let s=null;return e.children.inorderTraversal(((e,n)=>{".priority"===e?(Yt(null!==n.value,"Priority writes must always be leaf nodes"),s=n.value):i=ja(Dn(t,e),n,i)})),i.getChild(t).isEmpty()||null===s||(i=i.updateChild(Dn(t,".priority"),s)),i}}function Za(t,e){return Sa(e,t)}function Ca(t,e){if(t.snap)return _n(t.path,e);for(const i in t.children)if(t.children.hasOwnProperty(i)&&_n(Dn(t.path,i),e))return!0;return!1}function Ga(t){return t.visible}function fa(t,e,i){let s=ua.empty();for(let n=0;n{s=s.updateImmediateChild(t,e)})),s;if(i){const n=Wa(t.visibleWrites,e);return i.forEachChild(Wo,((t,e)=>{const i=va(Wa(n,new Vn(t)),e);s=s.updateImmediateChild(t,i)})),Ma(n).forEach((t=>{s=s.updateImmediateChild(t.name,t.node)})),s}return Ma(Wa(t.visibleWrites,e)).forEach((t=>{s=s.updateImmediateChild(t.name,t.node)})),s}(t.writeTree,t.treePath,e)}function Ra(t,e,i,s){return function(t,e,i,s,n){Yt(s||n,"Either existingEventSnap or existingServerSnap must exist");const o=Dn(e,i);if(ya(t.visibleWrites,o))return null;{const e=Wa(t.visibleWrites,o);return wa(e)?n.getChild(i):va(e,n.getChild(i))}}(t.writeTree,t.treePath,e,i,s)}function Ha(t,e){return function(t,e){return La(t.visibleWrites,e)}(t.writeTree,Dn(t.treePath,e))}function ga(t,e,i){return function(t,e,i,s){const n=Dn(e,i),o=La(t.visibleWrites,n);return null!=o?o:s.isCompleteForChild(i)?va(Wa(t.visibleWrites,n),s.getNode().getImmediateChild(i)):null}(t.writeTree,t.treePath,e,i)}function Aa(t,e){return Sa(Dn(t.treePath,e),t.writeTree)}function Sa(t,e){return{treePath:t,writeTree:e}}class za{constructor(){this.changeMap=new Map}trackChildChange(t){const e=t.type,i=t.childName;Yt("child_added"===e||"child_changed"===e||"child_removed"===e,"Only child changes supported for tracking"),Yt(".priority"!==i,"Only non-priority child changes can be tracked.");const s=this.changeMap.get(i);if(s){const n=s.type;if("child_added"===e&&"child_removed"===n)this.changeMap.set(i,Vo(i,t.snapshotNode,s.snapshotNode));else if("child_removed"===e&&"child_added"===n)this.changeMap.delete(i);else if("child_removed"===e&&"child_changed"===n)this.changeMap.set(i,zo(i,s.oldSnap));else if("child_changed"===e&&"child_added"===n)this.changeMap.set(i,So(i,t.snapshotNode));else{if("child_changed"!==e||"child_changed"!==n)throw Rt("Illegal combination of changes: "+t+" occurred after "+s);this.changeMap.set(i,Vo(i,t.snapshotNode,s.oldSnap))}}else this.changeMap.set(i,t)}getChanges(){return Array.from(this.changeMap.values())}}const Va=new class{getCompleteChild(t){return null}getChildAfterChild(t,e,i){return null}};class Ta{constructor(t,e,i=null){this.writes_=t,this.viewCache_=e,this.optCompleteServerCache_=i}getCompleteChild(t){const e=this.viewCache_.eventCache;if(e.isCompleteForChild(t))return e.getNode().getImmediateChild(t);{const e=null!=this.optCompleteServerCache_?new sa(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return ga(this.writes_,t,e)}}getChildAfterChild(t,e,i){const s=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:ca(this.viewCache_),n=function(t,e,i,s,n,o){return function(t,e,i,s,n,o,a){let r;const l=Wa(t.visibleWrites,e),h=La(l,Tn());if(null!=h)r=h;else{if(null==i)return[];r=va(l,i)}if(r=r.withIndex(a),r.isEmpty()||r.isLeafNode())return[];{const t=[],e=a.getCompare(),i=o?r.getReverseIteratorFrom(s,a):r.getIteratorFrom(s,a);let l=i.getNext();for(;l&&t.length1)return e;const n=Fn(i),o=l.getNode().getImmediateChild(t).updateChild(n,s);h=".priority"===t?c.updatePriority(l.getNode(),o):c.updateChild(l.getNode(),t,o,n,Va,null)}const d=la(e,h,l.isFullyInitialized()||Un(i),c.filtersNodes());return ka(t,d,i,n,new Ta(n,d,o),r)}function Fa(t,e,i,s,n,o,a){const r=e.eventCache;let l,h;const c=new Ta(n,e,o);if(Un(i))h=t.filter.updateFullNode(e.eventCache.getNode(),s,a),l=ra(e,h,!0,t.filter.filtersNodes());else{const n=kn(i);if(".priority"===n)h=t.filter.updatePriority(e.eventCache.getNode(),s),l=ra(e,h,r.isFullyInitialized(),r.isFiltered());else{const o=Fn(i),h=r.getNode().getImmediateChild(n);let d;if(Un(o))d=s;else{const t=c.getCompleteChild(n);d=null!=t?".priority"===Jn(o)&&t.getChild(En(o)).isEmpty()?t:t.updateChild(o,s):No.EMPTY_NODE}l=h.equals(d)?e:ra(e,t.filter.updateChild(r.getNode(),n,d,o,c,a),r.isFullyInitialized(),t.filter.filtersNodes())}}return l}function Ja(t,e){return t.eventCache.isCompleteForChild(e)}function Xa(t,e,i){return i.foreach(((t,i)=>{e=e.updateChild(t,i)})),e}function Ea(t,e,i,s,n,o,a,r){if(e.serverCache.getNode().isEmpty()&&!e.serverCache.isFullyInitialized())return e;let l,h=e;l=Un(i)?s:new Ia(null).setTree(i,s);const c=e.serverCache.getNode();return l.children.inorderTraversal(((i,s)=>{if(c.hasChild(i)){const l=Xa(0,e.serverCache.getNode().getImmediateChild(i),s);h=Oa(t,h,new Vn(i),l,n,o,a,r)}})),l.children.inorderTraversal(((i,s)=>{const l=!e.serverCache.isCompleteForChild(i)&&null===s.value;if(!c.hasChild(i)&&!l){const l=Xa(0,e.serverCache.getNode().getImmediateChild(i),s);h=Oa(t,h,new Vn(i),l,n,o,a,r)}})),h}class Da{constructor(t,e){this.query_=t,this.eventRegistrations_=[];const i=this.query_._queryParams,s=new To(i.getIndex()),n=(o=i).loadsAllData()?new To(o.getIndex()):o.hasLimit()?new Oo(o):new ko(o);var o;this.processor_=function(t){return{filter:t}}(n);const a=e.serverCache,r=e.eventCache,l=s.updateFullNode(No.EMPTY_NODE,a.getNode(),null),h=n.updateFullNode(No.EMPTY_NODE,r.getNode(),null),c=new sa(l,a.isFullyInitialized(),s.filtersNodes()),d=new sa(h,r.isFullyInitialized(),n.filtersNodes());this.viewCache_=aa(d,c),this.eventGenerator_=new na(this.query_)}get query(){return this.query_}}function Ua(t,e){const i=ca(t.viewCache_);return i&&(t.query._queryParams.loadsAllData()||!Un(e)&&!i.getImmediateChild(kn(e)).isEmpty())?i.getChild(e):null}function Ba(t){return 0===t.eventRegistrations_.length}function Pa(t,e,i){const s=[];if(i){Yt(null==e,"A cancel should cancel all event registrations.");const n=t.query._path;t.eventRegistrations_.forEach((t=>{const e=t.createCancelEvent(i,n);e&&s.push(e)}))}if(e){let i=[];for(let s=0;s{const h=Dn(i,s);Ja(e,kn(h))&&(r=Fa(t,r,h,l,n,o,a))})),s.foreach(((s,l)=>{const h=Dn(i,s);Ja(e,kn(h))||(r=Fa(t,r,h,l,n,o,a))})),r}(t,e,l.path,l.children,s,n,o):(Yt(l.source.fromServer,"Unknown source."),r=l.source.tagged||e.serverCache.isFiltered(),a=Ea(t,e,l.path,l.children,s,n,r,o))}else if(i.type===qo.ACK_USER_WRITE){const r=i;a=r.revert?function(t,e,i,s,n,o){let a;if(null!=Ha(s,i))return e;{const r=new Ta(s,e,n),l=e.eventCache.getNode();let h;if(Un(i)||".priority"===kn(i)){let i;if(e.serverCache.isFullyInitialized())i=xa(s,ca(e));else{const t=e.serverCache.getNode();Yt(t instanceof No,"serverChildren would be complete if leaf node"),i=Ya(s,t)}h=t.filter.updateFullNode(l,i,o)}else{const n=kn(i);let c=ga(s,n,e.serverCache);null==c&&e.serverCache.isCompleteForChild(n)&&(c=l.getImmediateChild(n)),h=null!=c?t.filter.updateChild(l,n,c,Fn(i),r,o):e.eventCache.getNode().hasChild(n)?t.filter.updateChild(l,n,No.EMPTY_NODE,Fn(i),r,o):l,h.isEmpty()&&e.serverCache.isFullyInitialized()&&(a=xa(s,ca(e)),a.isLeafNode()&&(h=t.filter.updateFullNode(h,a,o)))}return a=e.serverCache.isFullyInitialized()||null!=Ha(s,Tn()),ra(e,h,a,t.filter.filtersNodes())}}(t,e,r.path,s,n,o):function(t,e,i,s,n,o,a){if(null!=Ha(n,i))return e;const r=e.serverCache.isFiltered(),l=e.serverCache;if(null!=s.value){if(Un(i)&&l.isFullyInitialized()||l.isCompleteForPath(i))return Oa(t,e,i,l.getNode().getChild(i),n,o,r,a);if(Un(i)){let s=new Ia(null);return l.getNode().forEachChild(ao,((t,e)=>{s=s.set(new Vn(t),e)})),Ea(t,e,i,s,n,o,r,a)}return e}{let h=new Ia(null);return s.foreach(((t,e)=>{const s=Dn(i,t);l.isCompleteForPath(s)&&(h=h.set(t,l.getNode().getChild(s)))})),Ea(t,e,i,h,n,o,r,a)}}(t,e,r.path,r.affectedTree,s,n,o)}else{if(i.type!==qo.LISTEN_COMPLETE)throw Rt("Unknown operation type: "+i.type);a=function(t,e,i,s,n){const o=e.serverCache;return ka(t,la(e,o.getNode(),o.isFullyInitialized()||Un(i),o.isFiltered()),i,s,Va,n)}(t,e,i.path,s,o)}const l=o.getChanges();return function(t,e,i){const s=e.eventCache;if(s.isFullyInitialized()){const n=s.getNode().isLeafNode()||s.getNode().isEmpty(),o=ha(t);(i.length>0||!t.eventCache.isFullyInitialized()||n&&!s.getNode().equals(o)||!s.getNode().getPriority().equals(o.getPriority()))&&i.push(Ao(ha(e)))}}(e,a,l),{viewCache:a,changes:l}}(t.processor_,n,e,i,s);var a,r;return a=t.processor_,r=o.viewCache,Yt(r.eventCache.getNode().isIndexed(a.filter.getIndex()),"Event snap not indexed"),Yt(r.serverCache.getNode().isIndexed(a.filter.getIndex()),"Server snap not indexed"),Yt(o.viewCache.serverCache.isFullyInitialized()||!n.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),t.viewCache_=o.viewCache,Qa(t,o.changes,o.viewCache.eventCache.getNode(),null)}function Qa(t,e,i,s){const n=s?[s]:t.eventRegistrations_;return function(t,e,i,s){const n=[],o=[];return e.forEach((e=>{var i;"child_changed"===e.type&&t.index_.indexedValueChanged(e.oldSnap,e.snapshotNode)&&o.push((i=e.childName,{type:"child_moved",snapshotNode:e.snapshotNode,childName:i}))})),oa(t,n,"child_removed",e,s,i),oa(t,n,"child_added",e,s,i),oa(t,n,"child_moved",o,s,i),oa(t,n,"child_changed",e,s,i),oa(t,n,"value",e,s,i),n}(t.eventGenerator_,e,i,n)}let qa,$a;class Ka{constructor(){this.views=new Map}}function tr(t,e,i,s){const n=e.source.queryId;if(null!==n){const o=t.views.get(n);return Yt(null!=o,"SyncTree gave us an op for an invalid query."),_a(o,e,i,s)}{let n=[];for(const o of t.views.values())n=n.concat(_a(o,e,i,s));return n}}function er(t,e,i,s,n){const o=e._queryIdentifier,a=t.views.get(o);if(!a){let t=xa(i,n?s:null),o=!1;t?o=!0:s instanceof No?(t=Ya(i,s),o=!1):(t=No.EMPTY_NODE,o=!1);const a=aa(new sa(t,o,!1),new sa(s,n,!1));return new Da(e,a)}return a}function ir(t){const e=[];for(const i of t.views.values())i.query._queryParams.loadsAllData()||e.push(i);return e}function sr(t,e){let i=null;for(const s of t.views.values())i=i||Ua(s,e);return i}function nr(t,e){if(e._queryParams.loadsAllData())return rr(t);{const i=e._queryIdentifier;return t.views.get(i)}}function or(t,e){return null!=nr(t,e)}function ar(t){return null!=rr(t)}function rr(t){for(const e of t.views.values())if(e.query._queryParams.loadsAllData())return e;return null}let lr=1;class hr{constructor(t){this.listenProvider_=t,this.syncPointTree_=new Ia(null),this.pendingWriteTree_={visibleWrites:ua.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function cr(t,e,i,s,n){return function(t,e,i,s,n){Yt(s>t.lastWriteId,"Stacking an older write on top of newer ones"),void 0===n&&(n=!0),t.allWrites.push({path:e,snap:i,writeId:s,visible:n}),n&&(t.visibleWrites=pa(t.visibleWrites,e,i)),t.lastWriteId=s}(t.pendingWriteTree_,e,i,s,n),n?yr(t,new ea({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},e,i)):[]}function dr(t,e,i=!1){const s=function(t,e){for(let i=0;it.writeId===e));Yt(i>=0,"removeWrite called with nonexistent writeId.");const s=t.allWrites[i];t.allWrites.splice(i,1);let n=s.visible,o=!1,a=t.allWrites.length-1;for(;n&&a>=0;){const e=t.allWrites[a];e.visible&&(a>=i&&Ca(e,s.path)?n=!1:_n(s.path,e.path)&&(o=!0)),a--}return!!n&&(o?(function(t){t.visibleWrites=fa(t.allWrites,Ga,Tn()),t.allWrites.length>0?t.lastWriteId=t.allWrites[t.allWrites.length-1].writeId:t.lastWriteId=-1}(t),!0):(s.snap?t.visibleWrites=ma(t.visibleWrites,s.path):an(s.children,(e=>{t.visibleWrites=ma(t.visibleWrites,Dn(s.path,e))})),!0))}(t.pendingWriteTree_,e)){let e=new Ia(null);return null!=s.snap?e=e.set(Tn(),!0):an(s.children,(t=>{e=e.set(new Vn(t),!0)})),yr(t,new Ko(s.path,e,i))}return[]}function Ir(t,e,i){return yr(t,new ea({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},e,i))}function ur(t,e,i,s,n=!1){const o=e._path,a=t.syncPointTree_.get(o);let r=[];if(a&&("default"===e._queryIdentifier||or(a,e))){const l=function(t,e,i,s){const n=e._queryIdentifier,o=[];let a=[];const r=ar(t);if("default"===n)for(const[e,n]of t.views.entries())a=a.concat(Pa(n,i,s)),Ba(n)&&(t.views.delete(e),n.query._queryParams.loadsAllData()||o.push(n.query));else{const e=t.views.get(n);e&&(a=a.concat(Pa(e,i,s)),Ba(e)&&(t.views.delete(n),e.query._queryParams.loadsAllData()||o.push(e.query)))}return r&&!ar(t)&&o.push(new(Yt(qa,"Reference.ts has not been loaded"),qa)(e._repo,e._path)),{removed:o,events:a}}(a,e,i,s);0===a.views.size&&(t.syncPointTree_=t.syncPointTree_.remove(o));const h=l.removed;if(r=l.events,!n){const i=-1!==h.findIndex((t=>t._queryParams.loadsAllData())),n=t.syncPointTree_.findOnPath(o,((t,e)=>ar(e)));if(i&&!n){const e=t.syncPointTree_.subtree(o);if(!e.isEmpty()){const i=function(t){return t.fold(((t,e,i)=>{if(e&&ar(e))return[rr(e)];{let t=[];return e&&(t=ir(e)),an(i,((e,i)=>{t=t.concat(i)})),t}}))}(e);for(let e=0;e0&&!s)if(i){const i=null;t.listenProvider_.stopListening(Gr(e),i)}else h.forEach((e=>{const i=t.queryToTagMap.get(vr(e));t.listenProvider_.stopListening(Gr(e),i)}))}!function(t,e){for(let i=0;i{const i=Bn(t,n);o=o||sr(e,i),a=a||ar(e)}));let r,l=t.syncPointTree_.get(n);l?(a=a||ar(l),o=o||sr(l,Tn())):(l=new Ka,t.syncPointTree_=t.syncPointTree_.set(n,l)),null!=o?r=!0:(r=!1,o=No.EMPTY_NODE,t.syncPointTree_.subtree(n).foreachChild(((t,e)=>{const i=sr(e,Tn());i&&(o=o.updateImmediateChild(t,i))})));const h=or(l,e);if(!h&&!e._queryParams.loadsAllData()){const i=vr(e);Yt(!t.queryToTagMap.has(i),"View does not exist, but we have a tag");const s=lr++;t.queryToTagMap.set(i,s),t.tagToQueryMap.set(s,i)}let c=function(t,e,i,s,n,o){const a=er(t,e,s,n,o);return t.views.has(e._queryIdentifier)||t.views.set(e._queryIdentifier,a),function(t,e){t.eventRegistrations_.push(e)}(a,i),function(t,e){const i=t.viewCache_.eventCache,s=[];return i.getNode().isLeafNode()||i.getNode().forEachChild(Wo,((t,e)=>{s.push(So(t,e))})),i.isFullyInitialized()&&s.push(Ao(i.getNode())),Qa(t,s,i.getNode(),e)}(a,i)}(l,e,i,Za(t.pendingWriteTree_,n),o,r);if(!h&&!a&&!s){const i=nr(l,e);c=c.concat(function(t,e,i){const s=e._path,n=wr(t,e),o=Wr(t,i),a=t.listenProvider_.startListening(Gr(e),n,o.hashFn,o.onComplete),r=t.syncPointTree_.subtree(s);if(n)Yt(!ar(r.value),"If we're adding a query, it shouldn't be shadowed");else{const e=r.fold(((t,e,i)=>{if(!Un(t)&&e&&ar(e))return[rr(e).query];{let t=[];return e&&(t=t.concat(ir(e).map((t=>t.query)))),an(i,((e,i)=>{t=t.concat(i)})),t}}));for(let i=0;i{const s=sr(i,Bn(t,e));if(s)return s}));return Na(s,e,n,i,!0)}function yr(t,e){return Lr(e,t.syncPointTree_,null,Za(t.pendingWriteTree_,Tn()))}function Lr(t,e,i,s){if(Un(t.path))return Mr(t,e,i,s);{const n=e.get(Tn());null==i&&null!=n&&(i=sr(n,Tn()));let o=[];const a=kn(t.path),r=t.operationForChild(a),l=e.children.get(a);if(l&&r){const t=i?i.getImmediateChild(a):null,e=Aa(s,a);o=o.concat(Lr(r,l,t,e))}return n&&(o=o.concat(tr(n,t,s,i))),o}}function Mr(t,e,i,s){const n=e.get(Tn());null==i&&null!=n&&(i=sr(n,Tn()));let o=[];return e.children.inorderTraversal(((e,n)=>{const a=i?i.getImmediateChild(e):null,r=Aa(s,e),l=t.operationForChild(e);l&&(o=o.concat(Mr(l,n,a,r)))})),n&&(o=o.concat(tr(n,t,s,i))),o}function Wr(t,e){const i=e.query,s=wr(t,i);return{hashFn:()=>{const t=function(t){return t.viewCache_.serverCache.getNode()}(e)||No.EMPTY_NODE;return t.hash()},onComplete:e=>{if("ok"===e)return s?function(t,e,i){const s=jr(t,i);if(s){const i=Zr(s),n=i.path,o=i.queryId,a=Bn(n,e);return Cr(t,n,new ta($o(o),a))}return[]}(t,i._path,s):function(t,e){return yr(t,new ta({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},e))}(t,i._path);{const s=function(t,e){let i="Unknown Error";"too_big"===t?i="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"===t?i="Client doesn't have permission to access the desired data.":"unavailable"===t&&(i="The service is unavailable");const s=new Error(t+" at "+e._path.toString()+": "+i);return s.code=t.toUpperCase(),s}(e,i);return ur(t,i,null,s)}}}}function wr(t,e){const i=vr(e);return t.queryToTagMap.get(i)}function vr(t){return t._path.toString()+"$"+t._queryIdentifier}function jr(t,e){return t.tagToQueryMap.get(e)}function Zr(t){const e=t.indexOf("$");return Yt(-1!==e&&e{const n=Sr(s,e.getImmediateChild(t),i);n!==s&&(o=o.updateImmediateChild(t,n))})),o}}class zr{constructor(t="",e=null,i={children:{},childCount:0}){this.name=t,this.parent=e,this.node=i}}function Vr(t,e){let i=e instanceof Vn?e:new Vn(e),s=t,n=kn(i);for(;null!==n;){const t=Kt(s.node.children,n)||{children:{},childCount:0};s=new zr(n,s,t),i=Fn(i),n=kn(i)}return s}function Tr(t){return t.node.value}function kr(t,e){t.node.value=e,Er(t)}function Or(t){return t.node.childCount>0}function Fr(t,e){an(t.node.children,((i,s)=>{e(new zr(i,t,s))}))}function Jr(t,e,i,s){i&&!s&&e(t),Fr(t,(t=>{Jr(t,e,!0,s)})),i&&s&&e(t)}function Xr(t){return new Vn(null===t.parent?t.name:Xr(t.parent)+"/"+t.name)}function Er(t){null!==t.parent&&function(t,e,i){const s=function(t){return void 0===Tr(t)&&!Or(t)}(i),n=$t(t.node.children,e);s&&n?(delete t.node.children[e],t.node.childCount--,Er(t)):s||n||(t.node.children[e]=i.node,t.node.childCount++,Er(t))}(t.parent,t.name,t)}const Dr=/[\[\].#$\/\u0000-\u001F\u007F]/,Ur=/[\[\].#$\u0000-\u001F\u007F]/,Br=10485760,Pr=function(t){return"string"==typeof t&&0!==t.length&&!Dr.test(t)},_r=function(t){return"string"==typeof t&&0!==t.length&&!Ur.test(t)},Qr=function(t,e,i){const s=i instanceof Vn?new Qn(i,t):i;if(void 0===e)throw new Error(t+"contains undefined "+$n(s));if("function"==typeof e)throw new Error(t+"contains a function "+$n(s)+" with contents = "+e.toString());if(qs(e))throw new Error(t+"contains "+e.toString()+" "+$n(s));if("string"==typeof e&&e.length>Br/3&&ae(e)>Br)throw new Error(t+"contains a string greater than "+Br+" utf8 bytes "+$n(s)+" ('"+e.substring(0,50)+"...')");if(e&&"object"==typeof e){let i=!1,n=!1;if(an(e,((e,o)=>{if(".value"===e)i=!0;else if(".priority"!==e&&".sv"!==e&&(n=!0,!Pr(e)))throw new Error(t+" contains an invalid key ("+e+") "+$n(s)+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');!function(t,e){t.parts_.length>0&&(t.byteLength_+=1),t.parts_.push(e),t.byteLength_+=ae(e),qn(t)}(s,e),Qr(t,o,s),function(t){const e=t.parts_.pop();t.byteLength_-=ae(e),t.parts_.length>0&&(t.byteLength_-=1)}(s)})),i&&n)throw new Error(t+' contains ".value" child '+$n(s)+" in addition to actual children.")}},qr=function(t,e,i,s){if(!(s&&void 0===i||_r(i)))throw new Error(oe(t,e)+'was an invalid path = "'+i+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},$r=function(t,e,i,s){i&&(i=i.replace(/^\/*\.info(\/|$)/,"/")),qr(t,e,i,s)};class Kr{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function tl(t,e){let i=null;for(let s=0;s_n(t,e)||_n(e,t)))}function il(t){for(let e=0;e=0)t.server_=new Eo(t.repoInfo_,((e,i,s,n)=>{ll(t,e,i,s,n)}),t.authTokenProvider_,t.appCheckProvider_),setTimeout((()=>hl(t,!0)),0);else{if(null!=i){if("object"!=typeof i)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{Qt(i)}catch(t){throw new Error("Invalid authOverride provided: "+t)}}t.persistentConnection_=new eo(t.repoInfo_,e,((e,i,s,n)=>{ll(t,e,i,s,n)}),(e=>{hl(t,e)}),(e=>{!function(t,e){an(e,((e,i)=>{cl(t,e,i)}))}(t,e)}),t.authTokenProvider_,t.appCheckProvider_,i),t.server_=t.persistentConnection_}t.authTokenProvider_.addTokenChangeListener((e=>{t.server_.refreshAuthToken(e)})),t.appCheckProvider_.addTokenChangeListener((e=>{t.server_.refreshAppCheckToken(e.token)})),t.statsReporter_=function(e,i){const s=e.toString();return Zn[s]||(Zn[s]=new Qo(t.stats_,t.server_)),Zn[s]}(t.repoInfo_),t.infoData_=new Do,t.infoSyncTree_=new hr({startListening:(e,i,s,n)=>{let o=[];const a=t.infoData_.getNode(e._path);return a.isEmpty()||(o=Ir(t.infoSyncTree_,e._path,a),setTimeout((()=>{n("ok")}),0)),o},stopListening:()=>{}}),cl(t,"connected",!1),t.serverSyncTree_=new hr({startListening:(e,i,s,n)=>(t.server_.listen(e,s,i,((i,s)=>{const o=n(i,s);el(t.eventQueue_,e._path,o)})),[]),stopListening:(e,i)=>{t.server_.unlisten(e,i)}})}function al(t){const e=t.infoData_.getNode(new Vn(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+e}function rl(t){return xr({timestamp:al(t)})}function ll(t,e,i,s,n){t.dataUpdateCount++;const o=new Vn(e);i=t.interceptServerDataCallback_?t.interceptServerDataCallback_(e,i):i;let a=[];if(n)if(s){const e=ee(i,(t=>Ro(t)));a=function(t,e,i,s){const n=jr(t,s);if(n){const s=Zr(n),o=s.path,a=s.queryId,r=Bn(o,e),l=Ia.fromObject(i);return Cr(t,o,new ia($o(a),r,l))}return[]}(t.serverSyncTree_,o,e,n)}else{const e=Ro(i);a=pr(t.serverSyncTree_,o,e,n)}else if(s){const e=ee(i,(t=>Ro(t)));a=function(t,e,i){const s=Ia.fromObject(i);return yr(t,new ia({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},e,s))}(t.serverSyncTree_,o,e)}else{const e=Ro(i);a=Ir(t.serverSyncTree_,o,e)}let r=o;a.length>0&&(r=ml(t,o)),el(t.eventQueue_,r,a)}function hl(t,e){cl(t,"connected",e),!1===e&&function(t){ul(t,"onDisconnectEvents");const e=rl(t),i=Uo();Po(t.onDisconnect_,Tn(),((s,n)=>{const o=gr(s,n,t.serverSyncTree_,e);Bo(i,s,o)}));let s=[];Po(i,Tn(),((e,i)=>{s=s.concat(Ir(t.serverSyncTree_,e,i));const n=wl(t,e);ml(t,n)})),t.onDisconnect_=Uo(),el(t.eventQueue_,Tn(),s)}(t)}function cl(t,e,i){const s=new Vn("/.info/"+e),n=Ro(i);t.infoData_.updateSnapshot(s,n);const o=Ir(t.infoSyncTree_,s,n);el(t.eventQueue_,s,o)}function dl(t){return t.nextWriteId_++}function Il(t,e,i,s,n){ul(t,"set",{path:e.toString(),value:i,priority:s});const o=rl(t),a=Ro(i,s),r=mr(t.serverSyncTree_,e),l=Ar(a,r,o),h=dl(t),c=cr(t.serverSyncTree_,e,l,h,!0);tl(t.eventQueue_,c),t.server_.put(e.toString(),a.val(!0),((i,s)=>{const o="ok"===i;o||Qs("set at "+e+" failed: "+i);const a=dr(t.serverSyncTree_,h,!o);el(t.eventQueue_,e,a),function(t,e,i,s){e&&cn((()=>{if("ok"===i)e(null);else{const t=(i||"error").toUpperCase();let n=t;s&&(n+=": "+s);const o=new Error(n);o.code=t,e(o)}}))}(0,n,i,s)}));const d=wl(t,e);ml(t,d),el(t.eventQueue_,d,[])}function ul(t,...e){let i="";t.persistentConnection_&&(i=t.persistentConnection_.id+":"),Us(i,...e)}function pl(t,e,i){return mr(t.serverSyncTree_,e,i)||No.EMPTY_NODE}function bl(t,e=t.transactionQueueTree_){if(e||Wl(t,e),Tr(e)){const i=Ll(t,e);Yt(i.length>0,"Sending zero length transaction queue"),i.every((t=>0===t.status))&&function(t,e,i){const s=i.map((t=>t.currentWriteId)),n=pl(t,e,s);let o=n;const a=n.hash();for(let t=0;t{ul(t,"transaction put response",{path:l.toString(),status:s});let n=[];if("ok"===s){const s=[];for(let e=0;ei[e].onComplete(null,!0,i[e].currentOutputSnapshotResolved))),i[e].unwatcher();Wl(t,Vr(t.transactionQueueTree_,e)),bl(t,t.transactionQueueTree_),el(t.eventQueue_,e,n);for(let t=0;t{bl(t,e)}))}function ml(t,e){const i=yl(t,e),s=Xr(i);return function(t,e,i){if(0===e.length)return;const s=[];let n=[];const o=e.filter((t=>0===t.status)).map((t=>t.currentWriteId));for(let r=0;r=sl)d=!0,c="maxretry",n=n.concat(dr(t.serverSyncTree_,l.currentWriteId,!0));else{const i=pl(t,l.path,o);l.currentInputSnapshot=i;const s=e[r].update(i.val());if(void 0!==s){Qr("transaction failed: Data returned ",s,l.path);let e=Ro(s);"object"==typeof s&&null!=s&&$t(s,".priority")||(e=e.updatePriority(i.getPriority()));const a=l.currentWriteId,r=rl(t),h=Ar(e,i,r);l.currentOutputSnapshotRaw=e,l.currentOutputSnapshotResolved=h,l.currentWriteId=dl(t),o.splice(o.indexOf(a),1),n=n.concat(cr(t.serverSyncTree_,l.path,h,l.currentWriteId,l.applyLocally)),n=n.concat(dr(t.serverSyncTree_,a,!0))}else d=!0,c="nodata",n=n.concat(dr(t.serverSyncTree_,l.currentWriteId,!0))}el(t.eventQueue_,i,n),n=[],d&&(e[r].status=2,a=e[r].unwatcher,setTimeout(a,Math.floor(0)),e[r].onComplete&&("nodata"===c?s.push((()=>e[r].onComplete(null,!1,e[r].currentInputSnapshot))):s.push((()=>e[r].onComplete(new Error(c),!1,null)))))}var a;Wl(t,t.transactionQueueTree_);for(let t=0;tt.order-e.order)),i}function Ml(t,e,i){const s=Tr(e);if(s)for(let t=0;t{Ml(t,e,i)}))}function Wl(t,e){const i=Tr(e);if(i){let t=0;for(let e=0;e0?i:void 0)}Fr(e,(e=>{Wl(t,e)}))}function wl(t,e){const i=Xr(yl(t,e)),s=Vr(t.transactionQueueTree_,e);return function(t,e,i){let s=t.parent;for(;null!==s;){if(e(s))return!0;s=s.parent}}(s,(e=>{vl(t,e)})),vl(t,s),Jr(s,(e=>{vl(t,e)})),i}function vl(t,e){const i=Tr(e);if(i){const s=[];let n=[],o=-1;for(let e=0;e.firebaseio.com instead"),s&&"undefined"!==s||"localhost"===i.domain||_s("Cannot parse Firebase url. Please use https://.firebaseio.com"),i.secure||"undefined"!=typeof window&&window.location&&window.location.protocol&&-1!==window.location.protocol.indexOf("https:")&&Qs("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");const n="ws"===i.scheme||"wss"===i.scheme;return{repoInfo:new Wn(i.host,i.secure,s,n,e,"",s!==i.subdomain),path:new Vn(i.pathString)}},Zl=function(t){let e="",i="",s="",n="",o="",a=!0,r="https",l=443;if("string"==typeof t){let h=t.indexOf("//");h>=0&&(r=t.substring(0,h-1),t=t.substring(h+2));let c=t.indexOf("/");-1===c&&(c=t.length);let d=t.indexOf("?");-1===d&&(d=t.length),e=t.substring(0,Math.min(c,d)),c0){let s=i[t];try{s=decodeURIComponent(s.replace(/\+/g," "))}catch(t){}e+="/"+s}return e}(t.substring(c,d)));const I=function(t){const e={};"?"===t.charAt(0)&&(t=t.substring(1));for(const i of t.split("&")){if(0===i.length)continue;const s=i.split("=");2===s.length?e[decodeURIComponent(s[0])]=decodeURIComponent(s[1]):Qs(`Invalid query segment '${i}' in query '${t}'`)}return e}(t.substring(Math.min(t.length,d)));h=e.indexOf(":"),h>=0?(a="https"===r||"wss"===r,l=parseInt(e.substring(h+1),10)):h=e.length;const u=e.slice(0,h);if("localhost"===u.toLowerCase())i="localhost";else if(u.split(".").length<=2)i=u;else{const t=e.indexOf(".");s=e.substring(0,t).toLowerCase(),i=e.substring(t+1),o=s}"ns"in I&&(o=I.ns)}return{host:e,port:l,domain:i,subdomain:s,secure:a,scheme:r,pathString:n,namespace:o}};class Cl{constructor(t,e,i,s){this.eventType=t,this.eventRegistration=e,this.snapshot=i,this.prevName=s}getPath(){const t=this.snapshot.ref;return"value"===this.eventType?t._path:t.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+Qt(this.snapshot.exportVal())}}class Gl{constructor(t,e,i){this.eventRegistration=t,this.error=e,this.path=i}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}class fl{constructor(t,e){this.snapshotCallback=t,this.cancelCallback=e}onValue(t,e){this.snapshotCallback.call(null,t,e)}onCancel(t){return Yt(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,t)}get hasCancelCallback(){return!!this.cancelCallback}matches(t){return this.snapshotCallback===t.snapshotCallback||void 0!==this.snapshotCallback.userCallback&&this.snapshotCallback.userCallback===t.snapshotCallback.userCallback&&this.snapshotCallback.context===t.snapshotCallback.context}}class Nl{constructor(t,e,i,s){this._repo=t,this._path=e,this._queryParams=i,this._orderByCalled=s}get key(){return Un(this._path)?null:Jn(this._path)}get ref(){return new xl(this._repo,this._path)}get _queryIdentifier(){const t=Xo(this._queryParams),e=nn(t);return"{}"===e?"default":e}get _queryObject(){return Xo(this._queryParams)}isEqual(t){if(!((t=Ie(t))instanceof Nl))return!1;const e=this._repo===t._repo,i=Pn(this._path,t._path),s=this._queryIdentifier===t._queryIdentifier;return e&&i&&s}toJSON(){return this.toString()}toString(){return this._repo.toString()+function(t){let e="";for(let i=t.pieceNum_;it(new Yl(i,Rl(this.ref,e),Wo))))}hasChild(t){const e=new Vn(t);return!this._node.getChild(e).isEmpty()}hasChildren(){return!this._node.isLeafNode()&&!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function Rl(t,e){return null===kn((t=Ie(t))._path)?$r("child","path",e,!1):qr("child","path",e,!1),new xl(t._repo,Dn(t._path,e))}function Hl(t,e){(function(t,e){if(".info"===kn(e))throw new Error(t+" failed = Can't modify data under /.info/")})("set",(t=Ie(t))._path),function(t,e,i,s){s&&void 0===e||Qr(oe(t,"value"),e,i)}("set",e,t._path,!1);const i=new Jt;return Il(t._repo,t._path,e,null,i.wrapCallback((()=>{}))),i.promise}function gl(t){t=Ie(t);const e=new fl((()=>{})),i=new Al(e);return function(t,e,i){const s=function(t,e){const i=e._path;let s=null;t.syncPointTree_.foreachOnPath(i,((t,e)=>{const n=Bn(t,i);s=s||sr(e,n)}));let n=t.syncPointTree_.get(i);n?s=s||sr(n,Tn()):(n=new Ka,t.syncPointTree_=t.syncPointTree_.set(i,n));const o=null!=s,a=o?new sa(s,!0,!1):null;return ha(er(n,e,Za(t.pendingWriteTree_,e._path),o?a.getNode():No.EMPTY_NODE,o).viewCache_)}(t.serverSyncTree_,e);return null!=s?Promise.resolve(s):t.server_.get(e).then((s=>{const n=Ro(s).withIndex(e._queryParams.getIndex());let o;if(br(t.serverSyncTree_,e,i,!0),e._queryParams.loadsAllData())o=Ir(t.serverSyncTree_,e._path,n);else{const i=wr(t.serverSyncTree_,e);o=pr(t.serverSyncTree_,e._path,n,i)}return el(t.eventQueue_,e._path,o),ur(t.serverSyncTree_,e,i,null,!0),n}),(i=>(ul(t,"get for query "+Qt(e)+" failed: "+i),Promise.reject(new Error(i)))))}(t._repo,t,i).then((e=>new Yl(e,new xl(t._repo,t._path),t._queryParams.getIndex())))}class Al{constructor(t){this.callbackContext=t}respondsTo(t){return"value"===t}createEvent(t,e){const i=e._queryParams.getIndex();return new Cl("value",this,new Yl(t.snapshotNode,new xl(e._repo,e._path),i))}getEventRunner(t){return"cancel"===t.getEventType()?()=>this.callbackContext.onCancel(t.error):()=>this.callbackContext.onValue(t.snapshot,null)}createCancelEvent(t,e){return this.callbackContext.hasCancelCallback?new Gl(this,t,e):null}matches(t){return t instanceof Al&&(!t.callbackContext||!this.callbackContext||t.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}!function(t){Yt(!qa,"__referenceConstructor has already been defined"),qa=t}(xl),function(t){Yt(!$a,"__referenceConstructor has already been defined"),$a=t}(xl);const Sl={};function zl(t,e,i,s,n){let o=s||t.options.databaseURL;void 0===o&&(t.options.projectId||_s("Can't determine Firebase Database URL. Be sure to include a Project ID when calling firebase.initializeApp()."),Us("Using default host for project ",t.options.projectId),o=`${t.options.projectId}-default-rtdb.firebaseio.com`);let a,r,l=jl(o,n),h=l.repoInfo;"undefined"!=typeof process&&process.env&&(r=process.env.FIREBASE_DATABASE_EMULATOR_HOST),r?(a=!0,o=`http://${r}?ns=${h.namespace}`,l=jl(o,n),h=l.repoInfo):a=!l.repoInfo.secure;const c=n&&a?new pn(pn.OWNER):new un(t.name,t.options,e);(function(t,e){const i=e.path.toString();if("string"!=typeof e.repoInfo.host||0===e.repoInfo.host.length||!Pr(e.repoInfo.namespace)&&"localhost"!==e.repoInfo.host.split(":")[0]||0!==i.length&&!function(t){return t&&(t=t.replace(/^\/*\.info(\/|$)/,"/")),_r(t)}(i))throw new Error(oe(t,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')})("Invalid Firebase Database URL",l),Un(l.path)||_s("Database URL must point to the root of a Firebase Database (not including a child path).");const d=function(t,e,i,s){let n=Sl[e.name];n||(n={},Sl[e.name]=n);let o=n[t.toURLString()];return o&&_s("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),o=new nl(t,false,i,s),n[t.toURLString()]=o,o}(h,t,c,new In(t.name,i));return new Vl(d,t)}class Vl{constructor(t,e){this._repoInternal=t,this.app=e,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(ol(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new xl(this._repo,Tn())),this._rootInternal}_delete(){return null!==this._rootInternal&&(function(t,e){const i=Sl[e];i&&i[t.key]===t||_s(`Database ${e}(${t.repoInfo_}) has already been deleted.`),function(t){t.persistentConnection_&&t.persistentConnection_.interrupt("repo_interrupt")}(t),delete i[t.key]}(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(t){null===this._rootInternal&&_s("Cannot call "+t+" on a deleted database.")}}function Tl(t){const e=Object.create(Storage.prototype);return e.getItem=e=>t.get(e),e.setItem=(e,i)=>t.set(e,i),e.removeItem=e=>{t.delete(e)},e.clear=()=>t.clear(),e.key=e=>t.keys()[e]||null,Object.defineProperty(e,"length",{get:()=>t.size,enumerable:!1,configurable:!1}),Object.freeze(e)}function kl(t){const e=Object.create(null);return e.has=e=>e in t,e.get=e=>t[e]||null,e.set=(e,i)=>{t[e]=i},e.delete=e=>delete t[e],e.clear=()=>{for(const e of Object.keys(t))delete t[e]},e.keys=()=>Object.keys(t),e.values=()=>{const e=[];for(const i of Object.keys(t))e.push(t[i]);return e},e.entries=()=>{const e=[];for(const i of Object.keys(t))e.push([i,t[i]]);return e},Object.defineProperties(e,{size:{get:()=>Object.keys(t).length,enumerable:!1,configurable:!1}}),Object.freeze(e)}function Ol(t){const e=Object.create(null);return e.has=e=>null!==t.getItem(e),e.get=e=>t.getItem(e),e.set=(e,i)=>t.setItem(e,i),e.clear=()=>t.clear(),e.delete=e=>(t.removeItem(e),!0),e.keys=()=>{const e=t.length,i=new Array(e);for(let s=0;s{const e=t.length,i=new Array(e);for(let s=0;s{const e=t.length,i=new Array(e);for(let s=0;st.length,enumerable:!1,configurable:!1}}),Object.freeze(e)}eo.prototype.simpleListen=function(t,e){this.sendRequest("q",{p:t},e)},eo.prototype.echo=function(t,e){this.sendRequest("echo",{d:t},e)},As="10.8.0",qe(new ue("database",((t,{instanceIdentifier:e})=>zl(t.getProvider("app").getImmediate(),t.getProvider("auth-internal"),t.getProvider("app-check-internal"),e)),"PUBLIC").setMultipleInstances(!0)),si(Hs,gs,void 0),si(Hs,gs,"esm2017");const Fl=function(...t){if(1!==t.length)throw new Error("Invalid arguments");const e=t[0];if("object"!=typeof e)throw new Error("Invalid arguments");const i=Object.create(Jl);try{const t=e.localStorage,s=e.sessionStorage;if("object"!=typeof t||"object"!=typeof s)throw new Error;i.storageEnabled=!0,i.localStorage=Ol(t),i.sessionStorage=Ol(s)}catch(t){i.storageEnabled=!1,i.localStorage=kl(Object.create(null)),i.sessionStorage=kl(Object.create(null))}return Object.defineProperties(e,{localStorage:{value:Tl(i.localStorage),writable:!1,enumerable:!1,configurable:!1},sessionStorage:{value:Tl(i.sessionStorage),writable:!1,enumerable:!1,configurable:!1}}),Object.freeze(i)},Jl=Object.freeze(Object.create(null));Object.defineProperty(Fl,"prototype",{value:Jl,writable:!1,enumerable:!1,configurable:!1}),Object.setPrototypeOf(Fl,null),Object.freeze(Fl);const Xl=Fl;var El=i(984);function Dl(t,e){let i="";switch(e.type){case"VariableDeclaration":switch(e.kind){case"var":case"let":for(const s of e.declarations){i+='window["'+s.id.name+'"] = ';const e=s.init;if(null!=e){const s=t.slice(e.start,e.end).trim();";"!==s[s.length-1]?i+=s+";\n":i+=s+"\n"}else i+="void 0;\n"}break;case"const":for(const s of e.declarations){i+='Object.defineProperty(window, "'+s.id.name+'", { value: ';const e=s.init;if(null!=e){const s=t.slice(e.start,e.end).trim(),n=s.length-1;";"===s[n]?i+=s.slice(0,n):i+=s}else i+="void 0";i+=", writable: false, enumerable: false, configurable: false });\n"}break;default:i+="// invalid expression\n"}break;case"InterfaceDeclaration":case"FunctionDeclaration":case"ClassDeclaration":case"EnumDeclaration":{const s=e.id;null!=s&&(i+='window["'+s.name+'"] = ');const n=t.slice(e.start,e.end).trim();";"!==n[n.length-1]?i+=n+";\n":i+=n+"\n"}break;case"EmptyStatement":case"DebuggerStatement":break;case"ExpressionStatement":{const s=e.expression;switch(s.type){case"AwaitExpression":case"YieldExpression":{const e=s.argument;if(null!=e){const s=t.slice(e.start,e.end).trim();";"!==s[s.length-1]?i+="await "+s+";\n":i+="await "+s+"\n"}}}}break;default:{const s=t.slice(e.start,e.end).trim();";"!==s[s.length-1]?i+=s+";\n":i+=s+"\n"}}return i}const Ul=ei({apiKey:"AIzaSyCPXTy7dt3fpcLd8kVTBtXy0xuBdeuhbFc",authDomain:"whitespider.firebaseapp.com",projectId:"whitespider",storageBucket:"whitespider.appspot.com",messagingSenderId:"176227430389",appId:"1:176227430389:web:94270de43b7eb971c03abc",measurementId:"G-F72WBJT57S"}),Bl=(function(t=ii()){const e=$e(t=Ie(t),is);e.isInitialized()?e.getImmediate():function(t,e={}){const i=$e(t,is);if(i.isInitialized()){const t=i.getImmediate();if(ie(e,i.getOptions()))return t;throw hs.create("already-initialized")}i.initialize({options:e})}(t)}(Ul),function(t=ii(),e){const i=$e(t,"database").getImmediate({identifier:e});if(!i._instanceStarted){const t=(t=>{const e=(t=>{var e,i;return null===(i=null===(e=Ot())||void 0===e?void 0:e.emulatorHosts)||void 0===i?void 0:i[t]})(t);if(!e)return;const i=e.lastIndexOf(":");if(i<=0||i+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const s=parseInt(e.substring(i+1),10);return"["===e[0]?[e.substring(1,i-1),s]:[e.substring(0,i),s]})("database");t&&function(t,e,i,s={}){(t=Ie(t))._checkNotDeleted("useEmulator"),t._instanceStarted&&_s("Cannot call useEmulator() after instance has already been initialized.");const n=t._repoInternal;let o;if(n.repoInfo_.nodeAdmin)s.mockUserToken&&_s('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new pn(pn.OWNER);else if(s.mockUserToken){const e="string"==typeof s.mockUserToken?s.mockUserToken:function(t,e){if(t.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const i=e||"demo-project",s=t.iat||0,n=t.sub||t.user_id;if(!n)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${i}`,aud:i,iat:s,exp:s+3600,auth_time:s,sub:n,user_id:n,firebase:{sign_in_provider:"custom",identities:{}}},t);return[zt(JSON.stringify({alg:"none",type:"JWT"})),zt(JSON.stringify(o)),""].join(".")}(s.mockUserToken,t.app.options.projectId);o=new pn(e)}!function(t,e,i,s){t.repoInfo_=new Wn(`${e}:${i}`,!1,t.repoInfo_.namespace,t.repoInfo_.webSocketOnly,t.repoInfo_.nodeAdmin,t.repoInfo_.persistenceKey,t.repoInfo_.includeNamespaceInQueryParams,!0),s&&(t.authTokenProvider_=s)}(n,e,i,o)}(i,...t)}return i}(Ul));(async({window:t,document:e})=>{var i;function s(t){const i=e.getElementById(t);if(null==i)throw new Error("Element does not exist: "+t);return i}function n(t){const i=e.querySelector(t);if(i instanceof HTMLElement)return i;throw new Error("Failed to query selector: "+t)}const a=t.location,h=s("error"),c=new DOMParser;t.onerror=(t,e,i,s,n)=>{let o="Unhandled error at "+(e||"unknown source ");null!=i&&(o+=i),null!=s&&(o+=":"+s),null!=n&&(o+="\n\n"+n),h.textContent=o,h.style.display="block"},t.onkeydown=t=>{if(t.ctrlKey&&!t.altKey&&!t.metaKey&&!t.shiftKey)switch(t.key){case"q":t.preventDefault(),t.stopPropagation(),a.replace("https://www.google.com/webhp?igu=1");break;case"b":t.preventDefault(),t.stopPropagation();const{body:i}=e;i.hasAttribute("style")?i.removeAttribute("style"):i.setAttribute("style","filter: blur(15px);");break;case"h":t.preventDefault(),t.stopPropagation(),"WhiteSpider"===e.title?(e.title="Google",n("link[rel*='icon']").href="/res/google.ico"):(e.title="WhiteSpider",n("link[rel*='icon']").href="/favicon.ico")}},await new Promise((t=>{const i=setInterval((()=>{"complete"===e.readyState&&(clearInterval(i),t())}),50)}));const d=t["xz z\ud800\ud812"];if("function"!=typeof d)return void y("Internal Error");const I=s("frame"),u=s("frame-view"),p=s("video"),b=s("video-frame"),m=s("status");function y(t){null!=t?(h.textContent=t,h.style.display="block"):h.style.display="none"}function L(t){I.appendChild(W(t)),u.style.display="flex"}function M(t){p.appendChild(function(t){const i=e.createElement("iframe");return i.setAttribute("width","1024"),i.setAttribute("height","768"),i.setAttribute("allow",""),i.setAttribute("allowfullscreen","true"),i.setAttribute("allowpaymentrequest","true"),i.setAttribute("sandbox","allow-scripts allow-same-origin"),i.setAttribute("loading","lazy"),i.setAttribute("credentialless","true"),i.setAttribute("referrerpolicy","no-referrer"),null!=t&&i.setAttribute("src","data:application/xhtml+xml;base64,"+o.encode(r.encode(`\n\n\n\t\n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\tGoogle \n\t\n\t\n\t\t \n\t\n`))),i}(t)),b.style.display="flex"}function W(t){const i=e.createElement("embed");return i.type="text/plain",i.width="1024",i.height="768",i.src=t.startsWith("http://")?"https://"+t.substring(7):t,i}function w(t){try{return new URL(t)}catch(t){return null}}function v(e){const i=t.open(void 0,"_blank","");if(null==i)return void y("Please allow popups in your browser settings and try again.");i.focus();const s=c.parseFromString(`\n\n\n\t\n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\tGoogle \n\t\n\t\n\t\t\x3c!-- dummy --\x3e\n\t\n`,"application/xml");e.remove(),s.body.appendChild(e),i.document.documentElement.replaceWith(s.documentElement)}if(m.innerHTML="Connecting...",m.style.color="#808000",t!==t.top){const S=a.ancestorOrigins;if("null"===S[S.length-1]){const z=e.createElement("div");return z.textContent="Click here to continue",z.onclick=()=>v(W("https://whitespider.dev/")),z.setAttribute("style","padding: 15px;"),e.body.innerHTML="",void e.body.appendChild(z)}if("https://whitespider.dev"!==a.origin)return void a.replace("https://whitespider.dev/")}await new Promise((t=>setTimeout(t,500))),h.onclick=()=>{h.innerHTML="",h.style.display="none"};const j=Xl(t),Z=(N="gamelist_v2",(f=Ie(f=Bl))._checkNotDeleted("ref"),void 0!==N?Rl(f._root,N):f._root),C=t.navigator.serviceWorker,{localStorage:G}=j;var f,N;let x,Y=null,R=null,H=null;if(null!=C&&j.storageEnabled)try{await C.register("/sw.js",{type:"classic",scope:"/",updateViaCache:"none"}),await C.ready;const V=await t.fetch("/manifest.json",{cache:"no-cache",method:"GET",headers:{Accept:"application/json"}});if(V.ok){const{version:k}=await V.json();if(k!==G.get("__mf_version")){document.body.innerHTML="Updating contents...";const O=t.caches;for(const F of await O.keys())await O.delete(F);return G.delete("__new_read"),G.set("__mf_version",k),void a.reload()}s("version").textContent="v"+k}const T=G.get("__oauth_token")||"";if(T.length>0){const J=parseInt(G.get("__oauth_expr")||"",10);!Number.isNaN(J)&&J>Date.now()&&(Y=T)}}catch(X){}else y("Warning: Cookies are blocked by your browser. Some features might not work properly, and your game data will NOT be saved.");{const E=await Promise.race([gl(Z),new Promise((t=>setTimeout(t,2500)))]);if(null!=E&&E.exists())for(const D of(null===(i=E.val())||void 0===i?void 0:i.data)||[])null!=D&&"object"==typeof D&&l.push({0:D[0],1:3,2:D[2],3:[]})}{const U=n("link[rel*='icon']"),B=s("backend-url"),P=s("theme"),_=s("tab-cloaking");let Q;function q(t){if(0===t.length){const e=(new Date).getUTCHours();t=e>20||e<9?"https://gq.whitespider.dev/":"https://tk.whitespider.dev/"}null!=x&&(x.disconnect(),x.close()),x=xt(t,{path:"/untrihexium_v2/",secure:!0,upgrade:!0,timeout:1e4,forceNew:!0,multiplex:!1,protocols:[],transports:["polling","websocket"],autoConnect:!0,reconnection:!0,rememberUpgrade:!0,reconnectionDelay:5e3,reconnectionDelayMax:1e4}),x.io.on("error",(t=>{m.title="Server connection error. Message: "+t.message,m.innerHTML="✕Disconnected",m.style.color="#ff0000"})),x.io.on("reconnect_attempt",(()=>{m.title="",m.innerHTML="Connecting...",m.style.color="#808000"})),x.io.on("reconnect_failed",(()=>{m.title="",m.innerHTML="✕Disconnected",m.style.color="#ff0000"})),x.io.on("reconnect",(()=>{m.title="",m.innerHTML="✓Connected",m.style.color="#008000",null!=R&&R()})),x.once("connect",(()=>{m.innerHTML="✓Connected",m.style.color="#008000"}))}function $(t){switch(null==Q&&(Q=e.createElement("link"),Q.rel="stylesheet",Q.type="text/css",Q.href="data:text/css;base64,",e.head.appendChild(Q)),t){case"light":Q.href="data:text/css;base64,",Q.removeAttribute("media");break;case"dark":Q.href="index.dark.css",Q.removeAttribute("media");break;default:Q.href="index.dark.css",Q.media="all and (prefers-color-scheme: dark)"}}function K(t){switch(t){case"empty":e.title="",U.type="image/x-icon",U.href="/res/empty.ico";break;case"google":e.title="Google",U.type="image/x-icon",U.href="/res/google.ico";break;case"classroom":e.title="Home",U.type="image/png",U.href="/res/classroom.png";break;default:e.title="WhiteSpider",U.type="image/x-icon",U.href="/favicon.ico"}}B.onblur=()=>{const t=w(B.value.trim());if(null!=t&&"https:"===t.protocol){const e=t.href;q(e),G.set("__backendURL_",e)}else q(""),G.delete("__backendURL_")},P.onchange=()=>{const t=P.value;$(t),G.set("__set_theme",t)},_.onchange=()=>{const t=_.value;K(t),G.set("__set_tabc",t)};{const tt=G.get("__backendURL_")||"";q(tt),B.value=tt}{const et=G.get("__set_theme")||"default";$(et),P.value=et}{const it=G.get("__set_tabc")||"disabled";K(it),_.value=it}}{const st=s("game-container"),nt=s("gnav-page-number"),ot=s("gnav-back"),at=s("gnav-forward"),rt=s("submit-game-frame"),lt=s("game-name"),ht=s("game-url"),ct=s("error-msg"),dt=s("cancel"),It=s("submit"),ut=[];let pt=0,bt="all",mt="";{const Wt=s("game-search"),wt=n("#game-search>input");let vt=0;function jt(){mt=wt.value.toLowerCase().trim(),yt()}Wt.onsubmit=t=>{t.preventDefault(),t.stopPropagation(),clearTimeout(vt),jt()},wt.onblur=()=>{clearTimeout(vt),jt()},wt.oninput=()=>{clearTimeout(vt),vt=setTimeout((()=>{jt()}),1e3)}}{const Zt=e.querySelectorAll("#game-category>button");for(const Ct of Zt)Ct.onclick=()=>{for(const t of Zt)t.removeAttribute("current");Ct.setAttribute("current","true"),bt=Ct.getAttribute("match")||"all",yt()}}{const Gt=n('#game-category>button[match="new"]');G.has("__new_read")||(Gt.setAttribute("unread","true"),Gt.addEventListener("click",(()=>{Gt.removeAttribute("unread"),G.set("__new_read","1")}),{once:!0,passive:!0}))}function yt(){pt=0,ut.length=0;const t=[];switch(bt){case"all":for(const e of l)(!mt||e[0].toLowerCase().indexOf(mt)>=0)&&t.push(e);break;case"html5":for(const e of l)0===e[1]&&(!mt||e[0].toLowerCase().indexOf(mt)>=0)&&t.push(e);break;case"flash":for(const e of l)1===e[1]&&(!mt||e[0].toLowerCase().indexOf(mt)>=0)&&t.push(e);break;case"dos":for(const e of l)2===e[1]&&(!mt||e[0].toLowerCase().indexOf(mt)>=0)&&t.push(e);break;default:for(const e of l)e[3].indexOf(bt)>=0&&(!mt||e[0].toLowerCase().indexOf(mt)>=0)&&t.push(e)}if(0===t.length)return ot.disabled=!0,at.disabled=!0,void(st.innerHTML="No results found :(");for(let e=0;e=ut.length-1?at.disabled=!0:at.disabled=!1;for(const t of ut[pt]){const i=t[0],s=t[1],n=t[4],o=e.createElement("div");o.onclick=()=>L("player.html?type="+s+"&url="+encodeURIComponent(t[2])),o.oncontextmenu=t=>{t.preventDefault(),t.stopPropagation()},o.style.backgroundImage=null!=n?'url("'+n+'")':3===s?'url("/res/preview.svg")':'url("/d/'+encodeURIComponent(i)+'.jpg"), url("/res/preview.svg")';const a=e.createElement("div");a.textContent=i,o.appendChild(a);const r=e.createElement("label");switch(s){case 0:r.textContent="HTML5",r.style.background="#ff9933";break;case 1:r.textContent="Flash",r.style.background="#00cc99";break;case 2:r.textContent="Dos",r.style.background="#80bfff";break;case 3:r.textContent="User",r.style.background="#ff0000"}o.appendChild(r),st.appendChild(o)}}function Mt(t){const e=t.length;for(let i=0;i90)&&(s<97||s>122)&&(s<48||s>57)){if(0===i&&40!==s)return!1;if(i===e-1&&41!==s)return!1;switch(s){case 32:case 39:case 40:case 41:case 45:break;default:return!1}}}return!0}ot.onclick=()=>{pt--,Lt(),st.scrollIntoView({behavior:"instant",inline:"start",block:"start"})},at.onclick=()=>{pt++,Lt(),st.scrollIntoView({behavior:"instant",inline:"start",block:"start"})},dt.onclick=()=>{rt.style.display="none",lt.value="",ht.value="",ct.innerHTML="",ct.style.display="none"},It.onclick=async()=>{var t;const e=lt.value.replace(/\s+/g," ").trim(),i=w(ht.value.trim());if(0===e.length)return ct.textContent="Game name must not be empty.",void(ct.style.display="block");if(null==i)return ct.textContent="Invalid URL",void(ct.style.display="block");if("https:"!==i.protocol)return ct.textContent="URL protocol must be 'https:'. (Insecure 'http:' URLs are not supported)",void(ct.style.display="block");if(!Mt(e))return ct.textContent="Game name contains illegal characters.",void(ct.style.display="block");dt.disabled=!0,It.disabled=!0;const s=await gl(Z);if(!s.exists())return ct.textContent="Failed to retrieve remote data. (Internal Error)",void(ct.style.display="block");const n={0:e,2:i.href},o=((null===(t=s.val())||void 0===t?void 0:t.data)||[]).filter((t=>t&&"object"==typeof t));o.push(n),await Hl(Z,{data:o}),n[1]=3,n[3]=[],l.push(n),yt(),pt=ut.length-1,Lt(),dt.disabled=!1,It.disabled=!1,dt.click()},s("frame-close").onclick=()=>{I.innerHTML="",u.style.display="none"},s("frame-newtab").onclick=()=>{const t=I.firstElementChild;null!=t&&(I.innerHTML="",u.style.display="none",v(t))},s("video-close").onclick=()=>{p.innerHTML="",b.style.display="none"},s("video-fullscreen").onclick=()=>{if(e.fullscreenEnabled)return void p.requestFullscreen({navigationUI:"hide"});const t=p.firstElementChild;null!=t&&(p.innerHTML="",b.style.display="none",v(t))},s("submit-game").onclick=()=>{rt.style.display="block"},yt(),d()}{const ft=s("tabs"),Nt=s("mode-select"),Yt=s("u-frame"),Rt=s("address"),Ht=s("message"),gt=s("container"),At=[],St=["left","middle","right","back","forward"],zt=Yt.getContext("bitmaprenderer",{alpha:!1}),Vt={width:e.documentElement.clientWidth,height:e.documentElement.clientHeight-120,touch:t.navigator.maxTouchPoints>0};let Tt=-1;{const Pt=s("prox-btn"),_t=s("unbl-content");Nt.value=G.get("__unbl_mode_")||"puppeteer",Pt.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,Pt.setAttribute("current","true"),_t.setAttribute("current","true"),"puppeteer"===Nt.value&&(R=()=>{kt("Restoring session..."),Bt()},H=()=>{kt(null),R=null,H=null,Tt=-1,At.length=0,ft.innerHTML="",x.emit("end_session"),x.removeAllListeners()},kt("Requesting new session..."),Bt())},Nt.onchange=()=>{"puppeteer"===Nt.value?(G.set("__unbl_mode_","puppeteer"),Pt.click()):(null!=H&&H(),G.set("__unbl_mode_","raw-embed"))}}function kt(t){null!=t?(Ht.textContent=t,Ht.style.display="block"):Ht.style.display="none"}function Ot(t){return t.preventDefault(),t.stopPropagation(),t.returnValue=!1,x.emit("event",{type:t.type,x:t.offsetX,y:t.offsetY,button:St[t.button]}),!1}function Ft(t){t.preventDefault(),t.stopPropagation(),t.returnValue=!1;const e=t.touches;if(0==e.length)return x.emit("event",{type:t.type}),!1;const i=Yt.getBoundingClientRect();for(const s of e)x.emit("event",{type:t.type,x:s.clientX-i.x,y:s.clientY-i.y});return!1}function Jt(t){return t.preventDefault(),t.stopPropagation(),t.returnValue=!1,x.emit("event",{type:t.type,deltaX:t.deltaX,deltaY:t.deltaY}),!1}function Xt(t){return t.preventDefault(),t.stopPropagation(),t.returnValue=!1,x.emit("event",{type:t.type,key:t.key}),!1}function Et(t){return t.preventDefault(),t.stopPropagation(),t.returnValue=!1,Yt.focus({preventScroll:!0}),!1}function Dt(t){t=t.toLowerCase();for(let e=0;e57)&&(i<97||i>122)&&45!==i&&46!==i)return!1}return!0}function Ut(t,e){const i=w(t=t.replace(/\s+/g," ").trim());if(null!=i)return i.href;if(t.includes(" "))return e+encodeURIComponent(t);const s=t.indexOf("/");if(0===s)return e+encodeURIComponent(t);if(s>0){if(Dt(t.substring(0,s)))return"http://"+t}else if(Dt(t)&&t.includes("."))return"http://"+t;return e+encodeURIComponent(t)}async function Bt(){if(null==zt)throw new Error("Failed initialize canvas context");x.removeAllListeners(),x.emit("request_new_session",Vt);const{width:t,height:i}=await new Promise((t=>{x.once("session_ready",(e=>t(e)))}));gt.style.width=t+"px",gt.style.height=i+"px",Yt.width=t,Yt.height=i;for(const t of At)x.emit("newtab"),await new Promise((t=>{x.once("tabopen",t)})),x.emit("navigate",t.url),await new Promise((e=>{x.once("tabinfo",(i=>{const s=ft.children[i.id];t.title=s.querySelector("div").textContent=i.title||"Untitled",t.favicon=s.querySelector("img").src=i.favicon||"/res/empty.ico",e()}))}));x.on("url",(t=>{At[Tt].url=t,e.activeElement!==Rt&&(Rt.value=t)})),x.on("frame",(async e=>{const s=await createImageBitmap(new Blob([e],{type:"image/jpeg",endings:"native"}),0,0,t,i,{resizeQuality:"pixelated",imageOrientation:"none",premultiplyAlpha:"none",colorSpaceConversion:"none"});zt.transferFromImageBitmap(s),s.close()})),x.on("tabinfo",(t=>{const{id:e}=t,i=ft.children[e],s=At[e];s.title=i.querySelector("div").textContent=t.title||"Untitled",s.favicon=i.querySelector("img").src=t.favicon||"/res/empty.ico"})),x.on("tabopen",(()=>{const t=e.createElement("div");t.innerHTML='Untitled
',t.onclick=()=>{for(const t of ft.children)t.removeAttribute("current");t.setAttribute("current","true"),x.emit("focustab",Tt=At.indexOf(s))};const i=e.createElement("button");i.type="button",i.title="Close",i.onclick=t=>{t.preventDefault(),t.stopPropagation(),x.emit("closetab",At.indexOf(s))},t.appendChild(i);for(const t of ft.children)t.removeAttribute("current");t.setAttribute("current","true");const s={url:"",title:"",favicon:""};Tt=At.length,At.push(s),ft.appendChild(t)})),x.on("tabclose",(t=>{const e=ft.children;t===Tt&&(t>1?e[Tt=t-1].setAttribute("current","true"):At.length>0&&e[Tt=0].setAttribute("current","true")),e[t].remove(),At.splice(t,1)})),-1===Tt?x.emit("newtab"):x.emit("focustab",Tt),kt(null),Yt.autofocus=!0,Yt.focus({preventScroll:!0})}s("back").onclick=()=>x.emit("goback"),s("forward").onclick=()=>x.emit("goforward"),s("refresh").onclick=()=>x.emit("refresh"),s("new-tab").onclick=()=>x.emit("newtab"),Rt.onfocus=t=>{t.preventDefault(),t.stopPropagation(),Rt.select()},Rt.onkeydown=t=>{if("Enter"===t.key){t.preventDefault(),t.stopPropagation();const e=Rt.value.trim();e.length>0&&("puppeteer"===Nt.value?(Yt.focus({preventScroll:!0}),x.emit("navigate",Ut(e,"https://www.google.com/search?q="))):L(Ut(e,"https://www.bing.com/search?q=")))}},Rt.ondragstart=t=>{t.preventDefault(),t.stopPropagation(),Rt.selectionEnd=Rt.selectionStart||(Rt.selectionStart=0)},Yt.addEventListener("mousedown",Ot,{passive:!1}),Yt.addEventListener("mouseup",Ot,{passive:!1}),Yt.addEventListener("mousemove",Ot,{passive:!1}),Yt.addEventListener("touchstart",Ft,{passive:!1}),Yt.addEventListener("touchend",Ft,{passive:!1}),Yt.addEventListener("touchmove",Ft,{passive:!1}),Yt.addEventListener("wheel",Jt,{passive:!1}),Yt.addEventListener("keydown",Xt,{passive:!1}),Yt.addEventListener("keyup",Xt,{passive:!1}),Yt.addEventListener("click",Et,{passive:!1}),Yt.addEventListener("contextmenu",Et,{passive:!1})}{const Qt=s("dialog"),qt=n("#chatgpt>input"),$t=n("#chatgpt>button"),Kt=[];function te(t,i){const s=e.createElement("div");{const i=e.createElement("img");i.src=t?"/res/user.svg":"/res/bot.svg",i.width=36,i.height=36,i.draggable=!1,s.appendChild(i)}{const t=e.createElement("div");t.textContent=i,s.appendChild(t)}return Qt.appendChild(s),s.scrollIntoView({behavior:"instant",block:"start",inline:"start"}),s}function ee(t){const i=e.createElement("span");return i.textContent=t,Qt.appendChild(i),i.scrollIntoView({behavior:"instant",block:"start",inline:"start"}),i}function ie(){qt.disabled=!1,$t.disabled=!1,x.removeAllListeners()}s("chatgpt").onsubmit=t=>{t.preventDefault(),t.stopPropagation();const e=qt.value.trim();if(e.length<2)return void ee("Error: Input message must not be empty.");if(!x.connected)return void ee("Error: Disconnected from the backend server.");qt.blur(),qt.value="",qt.disabled=!0,$t.disabled=!0,te(!0,e),Kt.push({role:"user",content:e});const i=te(!1,"Processing...\n"),s=i.lastElementChild;let n="";x.on("gpt_response",(t=>{n+=t,s.textContent+=t})),x.once("gpt_end",(()=>{Kt.push({role:"assistant",content:s.textContent=n}),ie()})),x.once("gpt_error",(()=>{i.remove(),Kt.pop(),ie(),ee("Error: Failed to retrieve data from the server.")})),x.emit("gpt_request",Kt)},s("new-topic").onclick=t=>{t.preventDefault(),t.stopPropagation(),Qt.innerHTML="",Kt.length=0,qt.value=""}}{const se=s("yt-search"),ne=n("#yt-search>input"),oe=n("#yt-search>button"),ae=s("yt-api-key"),re=s("yt-order"),le=s("yt-results"),he=s("yt-load-more"),ce=s("yt-max-results");let de;function ue(t){switch(t.host){case"youtube.com":case"youtube-nocookie.com":case"www.youtube.com":case"www.youtube-nocookie.com":const e=t.pathname;return"/watch"===e?t.searchParams.get("v")||null:e.startsWith("/embed/")&&e.substring(7)||null;case"youtu.be":return t.pathname.substring(1)||null;default:return null}}async function pe(){const e=new URL("https://youtube.googleapis.com/youtube/v3/search"),i=e.searchParams;i.set("q",ne.value),i.set("key",ae.value||"AIzaSyARuwknsJhvP-ysM8-DwbqqJ5e-EaTL-UY"),i.set("type","video"),i.set("part","snippet"),i.set("order",re.value),i.set("maxResults",ce.value),i.set("safeSearch","none"),i.set("videoEmbeddable","true"),null!=de&&i.set("pageToken",de);const s=await t.fetch(e,{cache:"no-cache",method:"GET",headers:{Accept:"application/json"}});return"application/json"===(s.headers.get("content-type")||"").split(";",2)[0].trim()?await s.json():null}async function be(){y(null),oe.disabled=!0,ne.disabled=!0,he.style.display="none";const t=await pe();if(null==t)return void y("API server returned invalid data.");if("error"in t){const{message:e,code:i}=t.error;return void y(e+" (Code: "+i+")")}const i=t.items;if(0==i.length)return void y("No results match your search.");for(const t of i){const i=t.id.videoId,s=t.snippet,n=e.createElement("div");n.onclick=()=>M("https://www.youtube-nocookie.com/embed/"+i+"?autoplay=1&controls=1&rel=0&color=white");const o=e.createElement("img");o.width=160,o.height=90,o.title="Video Preview",o.draggable=!1,o.src=s.thumbnails.medium.url,n.appendChild(o);const a=e.createElement("div");n.appendChild(a);const r=e.createElement("div");r.className="title",r.textContent=s.title,a.appendChild(r);const l=e.createElement("div");l.className="desc",l.textContent=s.description,a.appendChild(l);const h=e.createElement("div");h.className="time",h.textContent=s.publishTime,a.appendChild(h),le.appendChild(n)}const s=t.nextPageToken;null!=s&&(he.style.display="block",he.onclick=()=>{de=s,be().then((()=>{oe.disabled=!1,ne.disabled=!1}))})}ae.value=G.get("__yt_apikey")||"",se.onsubmit=t=>{t.preventDefault(),t.stopPropagation(),de=null,le.innerHTML="";const e=w(ne.value);if(null==e)return void be().then((()=>{oe.disabled=!1,ne.disabled=!1}));y(null),he.style.display="none";const i=ue(e);null!=i?M("https://www.youtube-nocookie.com/embed/"+i+"?autoplay=1&controls=1&rel=0&color=white"):y("Error: Failed to parse YouTube video ID from the provided URL.")},ae.onblur=()=>{const t=ae.value.trim();return 0===t.length?(G.delete("__yt_apikey"),void(ae.value="")):t.length<30?(y("Invalid API key."),void(ae.value="")):void G.set("__yt_apikey",ae.value=t)},ce.onblur=()=>{const t=parseInt(ce.value);isNaN(t)?ce.value="10":t<1?ce.value="1":t>30&&(ce.value="30")}}const g=e.querySelectorAll("#nav-bar>button, #content>div:not(#footer), #unbl-content"),A=s("side-menu");{const me=s("home-btn"),ye=s("chai-btn"),Le=s("apps-btn"),Me=s("chat-btn"),We=s("unbl-btn"),we=s("settings"),ve=s("home-page"),je=s("chatgpt-page"),Ze=s("services-page"),Ce=s("community-page"),Ge=s("site-blocked-page"),fe=s("settings-page");me.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,me.setAttribute("current","true"),ve.setAttribute("current","true")},ye.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,ye.setAttribute("current","true"),je.setAttribute("current","true")},Le.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,Le.setAttribute("current","true"),Ze.setAttribute("current","true")},Me.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,Me.setAttribute("current","true"),Ce.setAttribute("current","true")},We.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,We.setAttribute("current","true"),Ge.setAttribute("current","true")},we.onclick=t=>{if(t.preventDefault(),t.stopPropagation(),null!=H&&H(),fe.hasAttribute("current")){for(const t of g)t.removeAttribute("current");me.setAttribute("current","true"),ve.setAttribute("current","true")}else{for(const t of g)t.removeAttribute("current");fe.setAttribute("current","true")}A.checked=!1}}{const Ne=s("accn-btn"),xe=s("accountinfo-page");function Ye(){Ne.innerHTML="My Account",Ne.onclick=t=>{t.preventDefault(),t.stopPropagation(),null!=H&&H();for(const t of g)t.removeAttribute("current");A.checked=!1,Ne.setAttribute("current","true"),xe.setAttribute("current","true")},s("signout").onclick=()=>{{const t=e.createElement("form");t.method="post",t.target="_blank",t.action="https://oauth2.googleapis.com/revoke",t.enctype="application/x-www-form-urlencoded";const i=e.createElement("input");i.type="hidden",i.name="token",i.value=Y,t.appendChild(i),e.body.appendChild(t),t.submit(),t.remove()}G.delete("__oauth_token"),G.delete("__oauth_expr"),setTimeout((()=>a.reload()),500)}}if(null!=Y)return void Ye();Ne.onclick=()=>{const e=t.open(void 0,"_blank","width="+screen.availWidth+",height="+screen.availHeight+",left=0,top=0,popup");if(null==e)return void y("Please allow popups in your browser settings and try again.");e.stop(),e.focus();const i=new URL("https://accounts.google.com/o/oauth2/v2/auth"),s=i.searchParams;s.set("client_id","176227430389-qkdboctmfhe9jnvnk2vmarafc5p8amuf.apps.googleusercontent.com"),s.set("redirect_uri",t.origin+"/auth.xht"),s.set("response_type","token"),s.set("state","12"),s.set("scope","email profile"),s.set("include_granted_scopes","true"),s.set("enable_granular_consent","true"),e.location.replace(i)},t.addEventListener("message",(e=>{e.preventDefault(),e.stopPropagation();const i=e.data;if(e.origin===t.origin&&"string"==typeof i){const t=new URLSearchParams(i),e=t.get("access_token")||"",s=t.get("expires_in")||"";if(0===e.length||0===s.length)return void y("External Server Error: Failed to receive login data.");G.set("__oauth_expr",String(1e3*parseInt(s,10)+Date.now())),G.set("__oauth_token",Y=e),Ye()}}),{passive:!1})}{const Re=n("#console-input>input"),He=s("console-output"),ge=[];let Ae=0;function Se(t,i,s){const n=e.createElement("span");return n.style.color=i||"",n.style.whiteSpace="pre-wrap",n.style.overflowWrap="break-word",n.textContent=t,(s||He).appendChild(n),n}function ze(){He.appendChild(e.createElement("hr"))}function Ve(t,i,s){const n=i?100:1e3,o=t.length;if(o>n){const i=Se('"'+Ee(t.slice(0,n))+"\n..."+(o-n)+" more characters","#008000",s),a=e.createElement("button");a.type="button",a.textContent="Expand",a.onclick=()=>{i.textContent='"'+Ee(t)+'"',a.remove()},He.appendChild(a)}else Se('"'+Ee(t)+'"',"#008000",s)}function Te(t,e,i){Se("[\n",void 0,e);for(const i of t)Se("\t",void 0,e),Je(i,!0,e),Se(",\n",void 0,e);Se(i||"]",void 0,e)}function ke(t,i,s){const n=t.length;if(0!==n)if(i)Se("[...]",void 0,s);else if(n>20){const i=e.createElement("span");Te(t.slice(0,20),i,"\t..."+(n-20)+" more items");const o=e.createElement("button");o.type="button",o.textContent="Expand",o.onclick=()=>{i.innerHTML="",Te(t,i)},i.appendChild(o),(s||He).appendChild(i)}else Te(t,s);else Se("[]",void 0,s)}function Oe(t,e,i,s){var n,o,a,r,l,h;const c=Xe(t);c.length>0?Se(c+" {\n",void 0,i):Se("{\n",void 0,i);const d=Object.getPrototypeOf(t);null!=d&&(Se("\t[[prototype]]: ",void 0,i),Fe(d,!0,i),Se(",\n",void 0,i));for(const s of e){Se("\t",void 0,i);const e=Object.getOwnPropertyDescriptor(t,s)||{value:void 0};"value"in e?(null===(n=e.writable)||void 0===n||n||Se("readonly ","#000080",i),null===(o=e.configurable)||void 0===o||o||Se("final ","#000080",i),Se("string"==typeof s?s:"["+s.toString()+"]",null===(a=e.enumerable)||void 0===a||a?"#008000":"#808080",i),Se(": ",void 0,i),Je(e.value,!0,i),Se(",\n",void 0,i)):(null===(r=e.configurable)||void 0===r||r||Se("final ","#000080",i),"get"in e&&(Se("get ","#000080",i),Se("string"==typeof s?s:"["+s.toString()+"]",null===(l=e.enumerable)||void 0===l||l?"#008000":"#808080",i),Se("() { ... }, ",void 0,i)),"set"in e&&(Se("set ","#000080",i),Se("string"==typeof s?s:"["+s.toString()+"]",null===(h=e.enumerable)||void 0===h||h?"#008000":"#808080",i),Se("(v) { ... }, ",void 0,i)),Se("\n",void 0,i))}Se(s||"}",void 0,i)}function Fe(t,i,s){if(null==t)return void Se("null","#000080",s);if(Array.isArray(t))return void ke(t,i);if(i){const e=Xe(t);return void Se((e.length>0?e+" {":"{")+(Object.keys(t).length>0?"...":"")+"}",void 0,s)}const n=Object.getOwnPropertyNames(t).sort();if(n.push.apply(n,Object.getOwnPropertySymbols(t)),n.length>20){const i=e.createElement("span");Oe(t,n.slice(0,20),i,"\t...\n}");const o=e.createElement("button");o.type="button",o.textContent="Expand",o.onclick=()=>{i.innerHTML="",Oe(t,n,i)},i.appendChild(o),(s||He).appendChild(i)}else Oe(t,n,s)}function Je(t,e,i){switch(typeof t){case"boolean":Se(t?"true":"false","#000080",i);break;case"number":Se(t.toString(10),"#0000ff",i);break;case"bigint":Se(String(t)+"n","#0000ff",i);break;case"symbol":Se(t.toString(),"#800080",i);break;case"function":Se(String(t),void 0,i);break;case"undefined":Se("undefined","#000080",i);break;case"string":Ve(t,e,i);break;default:Fe(t,e,i)}}function Xe(t){try{const e=t[Symbol.toStringTag];if("string"==typeof e)return e;const i=t.constructor;if("function"==typeof i){const{name:t}=i;if("string"==typeof t)return t}}catch(t){}return""}function Ee(t){return t.replace(/[\"\'\n\r\\]/g,(t=>{switch(t){case"\n":return"\\n";case"\r":return"\\r";case'"':return'\\"';case"'":return"\\'";case"\\":return"\\\\";default:return""}}))}function De(t){const e=t.replace(/\s+/g," ").split(" ");switch(t=e[0]){case"clear":if(e.length>1)return Se("Invalid arguments. Try '/help' for more information.\n","#ff0000"),void ze();He.innerHTML="";break;case"help":Se("JSConsole version 0.1.0 by WhiteSpider Dev\n\n","#0000ff"),Se("All inputs that starts with '/' will be treated as a built-in command.\n","#808000"),Se("All other inputs will be executed as JavaScript code with 'eval(code)'.\n\n","#808000"),Se("Built-in commands:\n","#008000"),Se("\t/clear\t\t\t\t- Clear the console.\n","#008000"),Se("\t/help\t\t\t\t- Show version info and built-in command list.\n\n","#008000"),ze();break;default:Se(t+": command not found. \nTry '/help' for a list of built-in commands.\n","#ff0000")}}async function Ue(i){if(Se("-> ","#808080"),Se(i=i.trim(),"#323232"),ze(),"/"===i[0])return void De(i.slice(1));try{i=function(t){const{body:e}=(0,El.K0)(t,{ranges:!0,tokens:!1,strictMode:!0,sourceType:"script",attachComment:!1,allowAwaitOutsideFunction:!0,allowReturnOutsideFunction:!0}).program,i=e.pop();let s="";for(const i of e)s+=Dl(t,i);return null!=i&&("ExpressionStatement"===i.type?s+="return "+t.slice(i.start,i.end):s+=Dl(t,i)),s}(i)}catch(t){return Se(String(t)+"\n","#ff0000"),void ze()}let s;try{s=await new Be("window","document",'"use strict;"\n'+i).apply(t,[t,e])}catch(t){return Se("Uncaught "+String(t)+"\n","#ff0000"),void ze()}Je(s,!1),ze()}Re.onkeydown=t=>{switch(t.key){case"Enter":t.preventDefault(),t.stopPropagation();const{value:e}=Re;e.length>0&&(ge.push(e),Ae=ge.length,Re.value="",Re.disabled=!0,Ue(e).then((()=>{Re.disabled=!1,Re.scrollIntoView({behavior:"instant",block:"start",inline:"start"}),Re.focus({preventScroll:!0})})));break;case"ArrowUp":t.preventDefault(),t.stopPropagation(),Ae>0&&(Re.value=ge[--Ae]);break;case"ArrowDown":t.preventDefault(),t.stopPropagation(),Ae