sveld 0.37.8 → 0.37.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -6
- package/cli.js +7 -0
- package/lib/browser.d.ts +2 -0
- package/lib/browser.js +149 -149
- package/lib/chunk-81w3m3mq.js +8 -0
- package/lib/chunk-f8nq2w4s.js +325 -0
- package/lib/chunk-fk1w3bnw.js +29 -0
- package/lib/chunk-fz6nj0w3.js +4 -0
- package/lib/chunk-r92p6t72.js +1 -0
- package/lib/{chunk-0s0w60zm.js → chunk-wd6xaaes.js} +9 -9
- package/lib/{chunk-dh2cbpn0.js → chunk-yp6p39jn.js} +2 -2
- package/lib/cli-entry.js +1 -1
- package/lib/index.d.ts +1348 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/lib/chunk-1tbcz36r.js +0 -1
- package/lib/chunk-2vte7cyp.js +0 -356
- package/lib/chunk-p9hkwnfy.js +0 -1
- package/lib/chunk-sg7vsn8d.js +0 -6
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{n,ge}from"./chunk-f8nq2w4s.js";var B=!0,Vt=new WeakMap;function qt(r){let o=r.Parser.acorn||r,c=Vt.get(o);if(!c){let P=function(L){return L===y.name||L===y.string||L===y.num||D.includes(L)||z.includes(L)},b=function(L){return L===y.name||D.includes(L)||z.includes(L)},I=function(L){return L===y.name||z.includes(L)},f=function(L){return L===M.abstract||L===M.declare||L===M.enum||L===M.module||L===M.namespace||L===M.interface||L===M.type},S=function(L){return L===M.keyof||L===M.readonly||L===M.unique},C=function(L){return L===y.invalidTemplate},{tokTypes:y,keywordTypes:O}=o,D=Object.values(O),M=i(),z=Object.values(M),G=E(),w=m(),V=new RegExp(`^(?:${Object.keys(M).join("|")})$`);G.jsxTagStart.updateContext=function(){this.context.push(w.tc_expr),this.context.push(w.tc_oTag),this.exprAllowed=!1},G.jsxTagEnd.updateContext=function(L){let Z=this.context.pop();if(Z===w.tc_oTag&&L===y.slash||Z===w.tc_cTag)this.context.pop(),this.exprAllowed=this.curContext()===w.tc_expr;else this.exprAllowed=!0},c={tokTypes:{...M,...G},tokContexts:{...w},keywordsRegExp:V,tokenIsLiteralPropertyName:P,tokenIsKeywordOrIdentifier:b,tokenIsIdentifier:I,tokenIsTSDeclarationStart:f,tokenIsTSTypeOperator:S,tokenIsTemplate:C}}return c;function p(P,b={}){return new o.TokenType("name",b)}function m(){return{tc_oTag:new o.TokContext("<tag",!1,!1),tc_cTag:new o.TokContext("</tag",!1,!1),tc_expr:new o.TokContext("<tag>...</tag>",!0,!0)}}function E(){return{at:new o.TokenType("@"),jsxName:new o.TokenType("jsxName"),jsxText:new o.TokenType("jsxText",{beforeExpr:!0}),jsxTagStart:new o.TokenType("jsxTagStart",{startsExpr:!0}),jsxTagEnd:new o.TokenType("jsxTagEnd")}}function i(){return{assert:p("assert",{startsExpr:B}),asserts:p("asserts",{startsExpr:B}),global:p("global",{startsExpr:B}),keyof:p("keyof",{startsExpr:B}),readonly:p("readonly",{startsExpr:B}),unique:p("unique",{startsExpr:B}),abstract:p("abstract",{startsExpr:B}),declare:p("declare",{startsExpr:B}),enum:p("enum",{startsExpr:B}),module:p("module",{startsExpr:B}),namespace:p("namespace",{startsExpr:B}),interface:p("interface",{startsExpr:B}),type:p("type",{startsExpr:B})}}}var Wt=1048576,J=2097152,X=1,st=2,Xt=4,ct=8,zt=16,Nt=64,kt=128,Gt=256,Jt=512,It=1024,ve=X|st|ct|kt,Me=X|0|ct|0,Oe=X|0|Xt|0,Re=X|0|zt|0,Be=0|st|0|kt,Fe=0|st|0|0,$t=X|st|ct|Gt,je=0|It,Ue=0|Nt,Ke=X|0|0|Nt,He=$t|Jt,Ve=0|It,wt=4,Lt=2,_t=1,qe=Lt|_t,We=Lt|wt,Xe=_t|wt,Yt=/(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/y,Pt=new RegExp("(?=("+Yt.source+"))\\1"+/(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source,"y"),Y=class{constructor(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1}};function Qt(r,o){let c="true";if(o.type==="MethodDefinition"&&(o.kind==="get"||o.kind==="set"))c=(o.static?"s":"i")+o.kind;if(r==="iget"&&c==="iset"||r==="iset"&&c==="iget"||r==="sget"&&c==="sset"||r==="sset"&&c==="sget")return[!1,"true"];if(!r)return[!1,c];return[!0,r]}function At(r,o){let{computed:c,key:p}=r;return!c&&(p.type==="Identifier"&&p.name===o||p.type==="Literal"&&p.value===o)}var A={AbstractMethodHasImplementation:({methodName:r})=>`Method '${r}' cannot have an implementation because it is marked abstract.`,AbstractPropertyHasInitializer:({propertyName:r})=>`Property '${r}' 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.",CannotFindName:({name:r})=>`Cannot find name '${r}'.`,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:r})=>`'declare' is not allowed in ${r}ters.`,DeclareClassFieldHasInitializer:"Initializers are not allowed in ambient contexts.",DeclareFunctionHasImplementation:"An implementation cannot be declared in ambient contexts.",DuplicateAccessibilityModifier:()=>"Accessibility modifier already seen.",DuplicateModifier:({modifier:r})=>`Duplicate modifier: '${r}'.`,EmptyHeritageClauseType:({token:r})=>`'${r}' 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'.",IncompatibleModifiers:({modifiers:r})=>`'${r[0]}' modifier cannot be used with '${r[1]}' modifier.`,IndexSignatureHasAbstract:"Index signatures cannot have the 'abstract' modifier.",IndexSignatureHasAccessibility:({modifier:r})=>`Index signatures cannot have an accessibility modifier ('${r}').`,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:r})=>`'${r}' modifier cannot appear on a type member.`,InvalidModifierOnTypeParameter:({modifier:r})=>`'${r}' modifier cannot appear on a type parameter.`,InvalidModifierOnTypeParameterPositions:({modifier:r})=>`'${r}' modifier can only appear on a type parameter of a class, interface or type alias.`,InvalidModifiersOrder:({orderedModifiers:r})=>`'${r[0]}' modifier must precede '${r[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:r})=>`Private elements cannot have an accessibility modifier ('${r}').`,PrivateMethodsHasAccessibility:({modifier:r})=>`Private methods cannot have an accessibility modifier ('${r}').`,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 `<T,>() => ...`.",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:r})=>`Single type parameter ${r} should have a trailing comma. Example usage: <${r},>.`,StaticBlockCannotHaveModifier:"Static class blocks cannot have any modifier.",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.",GenericsEndWithComma:"Trailing comma is not allowed at the end of generics.",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:r})=>`Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${r}.`,LetInLexicalBinding:"'let' is not allowed to be used as a name in 'let' or 'const' declarations."},et={UnexpectedLeadingDecorator:"Leading decorators must be attached to a class declaration.",DecoratorConstructor:"Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",TrailingDecorator:"Decorators must be attached to a class element.",SpreadElementDecorator:"Decorators can't be used with SpreadElement"};function Zt(r,o,c){let{tokTypes:p}=c,{tokTypes:m}=o;return class extends r{takeDecorators(i){let P=this.decoratorStack[this.decoratorStack.length-1];if(P.length)i.decorators=P,this.resetStartLocationFromNode(i,P[0]),this.decoratorStack[this.decoratorStack.length-1]=[]}parseDecorators(i){let P=this.decoratorStack[this.decoratorStack.length-1];while(this.match(m.at)){let b=this.parseDecorator();P.push(b)}if(this.match(p._export)){if(!i)this.unexpected()}else if(!this.canHaveLeadingDecorator())this.raise(this.start,et.UnexpectedLeadingDecorator)}parseDecorator(){let i=this.startNode();this.next(),this.decoratorStack.push([]);let P=this.start,b=this.startLoc,I;if(this.match(p.parenL)){let f=this.start,S=this.startLoc;if(this.next(),I=this.parseExpression(),this.expect(p.parenR),this.options.preserveParens){let C=this.startNodeAt(f,S);C.expression=I,I=this.finishNode(C,"ParenthesizedExpression")}}else{I=this.parseIdent(!1);while(this.eat(p.dot)){let f=this.startNodeAt(P,b);f.object=I,f.property=this.parseIdent(!0),f.computed=!1,I=this.finishNode(f,"MemberExpression")}}return i.expression=this.parseMaybeDecoratorArguments(I),this.decoratorStack.pop(),this.finishNode(i,"Decorator")}parseMaybeDecoratorArguments(i){if(this.eat(p.parenL)){let P=this.startNodeAtNode(i);return P.callee=i,P.arguments=this.parseExprList(p.parenR,!1),this.finishNode(P,"CallExpression")}return i}}}var St={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:"♦"},te=/^[\da-fA-F]+$/,ee=/^\d+$/;function Q(r){if(!r)return r;if(r.type==="JSXIdentifier")return r.name;if(r.type==="JSXNamespacedName")return r.namespace.name+":"+r.name.name;if(r.type==="JSXMemberExpression")return Q(r.object)+"."+Q(r.property)}function se(r,o,c,p){let m=r.tokTypes,E=o.tokTypes,{isNewLine:i,isIdentifierChar:P}=r,b=Object.assign({allowNamespaces:!0,allowNamespacedObjects:!0},p||{});return class extends c{jsx_readToken(){let f="",S=this.pos;for(;;){if(this.pos>=this.input.length)this.raise(this.start,"Unterminated JSX contents");let C=this.input.charCodeAt(this.pos);switch(C){case 60:case 123:if(this.pos===this.start){if(C===60&&this.exprAllowed)return++this.pos,this.finishToken(E.jsxTagStart);return this.getTokenFromCode(C)}return f+=this.input.slice(S,this.pos),this.finishToken(E.jsxText,f);case 38:f+=this.input.slice(S,this.pos),f+=this.jsx_readEntity(),S=this.pos;break;case 62:case 125:this.raise(this.pos,"Unexpected token `"+this.input[this.pos]+"`. Did you mean `"+(C===62?">":"}")+'` or `{"'+this.input[this.pos]+'"}`?');default:if(i(C))f+=this.input.slice(S,this.pos),f+=this.jsx_readNewLine(!0),S=this.pos;else++this.pos}}}jsx_readNewLine(f){let S=this.input.charCodeAt(this.pos),C;if(++this.pos,S===13&&this.input.charCodeAt(this.pos)===10)++this.pos,C=f?`
|
|
2
|
+
`:`\r
|
|
3
|
+
`;else C=String.fromCharCode(S);if(this.options.locations)++this.curLine,this.lineStart=this.pos;return C}jsx_readString(f){let S="",C=++this.pos;for(;;){if(this.pos>=this.input.length)this.raise(this.start,"Unterminated string constant");let y=this.input.charCodeAt(this.pos);if(y===f)break;if(y===38)S+=this.input.slice(C,this.pos),S+=this.jsx_readEntity(),C=this.pos;else if(i(y))S+=this.input.slice(C,this.pos),S+=this.jsx_readNewLine(!1),C=this.pos;else++this.pos}return S+=this.input.slice(C,this.pos++),this.finishToken(m.string,S)}jsx_readEntity(){let f="",S=0,C,y=this.input[this.pos];if(y!=="&")this.raise(this.pos,"Entity must start with an ampersand");let O=++this.pos;while(this.pos<this.input.length&&S++<10){if(y=this.input[this.pos++],y===";"){if(f[0]==="#"){let D;if(f[1]==="x"||f[1]==="X"){if(f=f.substr(2),te.test(f))D=parseInt(f,16)}else if(f=f.substr(1),ee.test(f))D=parseInt(f,10);if(D!==void 0&&D<=1114111)C=String.fromCodePoint(D)}else if(Object.prototype.hasOwnProperty.call(St,f))C=St[f];break}f+=y}if(C===void 0)return this.pos=O,"&";return C}jsx_readWord(){let f,S=this.pos;do f=this.input.charCodeAt(++this.pos);while(P(f)||f===45);return this.finishToken(E.jsxName,this.input.slice(S,this.pos))}jsx_parseIdentifier(){let f=this.startNode();if(this.type===E.jsxName)f.name=this.value;else if(this.type.keyword)f.name=this.type.keyword;else this.unexpected();return this.next(),this.finishNode(f,"JSXIdentifier")}jsx_parseNamespacedName(){let f=this.start,S=this.startLoc,C=this.jsx_parseIdentifier();if(!b.allowNamespaces||!this.eat(m.colon))return C;var y=this.startNodeAt(f,S);return y.namespace=C,y.name=this.jsx_parseIdentifier(),this.finishNode(y,"JSXNamespacedName")}jsx_parseElementName(){if(this.type===E.jsxTagEnd)return"";let f=this.start,S=this.startLoc,C=this.jsx_parseNamespacedName();if(this.type===m.dot&&C.type==="JSXNamespacedName"&&!b.allowNamespacedObjects)this.unexpected();while(this.eat(m.dot)){let y=this.startNodeAt(f,S);y.object=C,y.property=this.jsx_parseIdentifier(),C=this.finishNode(y,"JSXMemberExpression")}return C}jsx_parseAttributeValue(){switch(this.type){case m.braceL:let f=this.jsx_parseExpressionContainer();if(f.expression.type==="JSXEmptyExpression")this.raise(f.start,"JSX attributes must only be assigned a non-empty expression");return f;case E.jsxTagStart:case m.string:return this.parseExprAtom();default:this.raise(this.start,"JSX value should be either an expression or a quoted JSX text")}}jsx_parseEmptyExpression(){let f=this.startNodeAt(this.lastTokEnd,this.lastTokEndLoc);return this.finishNodeAt(f,"JSXEmptyExpression",this.start,this.startLoc)}jsx_parseExpressionContainer(){let f=this.startNode();if(this.next(),this.eat(m.ellipsis))return f.expression=this.parseExpression(),this.expect(m.braceR),this.finishNode(f,"JSXSpreadChild");return f.expression=this.type===m.braceR?this.jsx_parseEmptyExpression():this.parseExpression(),this.expect(m.braceR),this.finishNode(f,"JSXExpressionContainer")}jsx_parseAttribute(){let f=this.startNode();if(this.eat(m.braceL))return this.expect(m.ellipsis),f.argument=this.parseMaybeAssign(),this.expect(m.braceR),this.finishNode(f,"JSXSpreadAttribute");return f.name=this.jsx_parseNamespacedName(),f.value=this.eat(m.eq)?this.jsx_parseAttributeValue():null,this.finishNode(f,"JSXAttribute")}jsx_parseOpeningElementAt(f,S){let C=this.startNodeAt(f,S);C.attributes=[];let y=this.jsx_parseElementName();if(y)C.name=y;while(this.type!==m.slash&&this.type!==E.jsxTagEnd)C.attributes.push(this.jsx_parseAttribute());return C.selfClosing=this.eat(m.slash),this.expect(E.jsxTagEnd),this.finishNode(C,y?"JSXOpeningElement":"JSXOpeningFragment")}jsx_parseClosingElementAt(f,S){let C=this.startNodeAt(f,S),y=this.jsx_parseElementName();if(y)C.name=y;return this.expect(E.jsxTagEnd),this.finishNode(C,y?"JSXClosingElement":"JSXClosingFragment")}jsx_parseElementAt(f,S){let C=this.startNodeAt(f,S),y=[],O=this.jsx_parseOpeningElementAt(f,S),D=null;if(!O.selfClosing){t:for(;;)switch(this.type){case E.jsxTagStart:if(f=this.start,S=this.startLoc,this.next(),this.eat(m.slash)){D=this.jsx_parseClosingElementAt(f,S);break t}y.push(this.jsx_parseElementAt(f,S));break;case E.jsxText:y.push(this.parseExprAtom());break;case m.braceL:y.push(this.jsx_parseExpressionContainer());break;default:this.unexpected()}if(Q(D.name)!==Q(O.name))this.raise(D.start,"Expected corresponding JSX closing tag for <"+Q(O.name)+">")}let M=O.name?"Element":"Fragment";if(C["opening"+M]=O,C["closing"+M]=D,C.children=y,this.type===m.relational&&this.value==="<")this.raise(this.start,"Adjacent JSX elements must be wrapped in an enclosing tag");return this.finishNode(C,"JSX"+M)}jsx_parseText(){let f=this.parseLiteral(this.value);return f.type="JSXText",f}jsx_parseElement(){let f=this.start,S=this.startLoc;return this.next(),this.jsx_parseElementAt(f,S)}}}function ie(r,o,c){let{tokTypes:p}=o,{tokTypes:m}=c;return class extends r{parseMaybeImportAttributes(i){if(this.type===m._with||this.type===p.assert){this.next();let P=this.parseImportAttributes();if(P)i.attributes=P}}parseImportAttributes(){this.expect(m.braceL);let i=this.parseWithEntries();return this.expect(m.braceR),i}parseWithEntries(){let i=[],P=new Set;do{if(this.type===m.braceR)break;let b=this.startNode(),I;if(this.type===m.string)I=this.parseLiteral(this.value);else I=this.parseIdent(!0);if(this.next(),b.key=I,P.has(b.key.name))this.raise(this.pos,"Duplicated key in attributes");if(P.add(b.key.name),this.type!==m.string)this.raise(this.pos,"Only string is supported as an attribute value");b.value=this.parseLiteral(this.value),i.push(this.finishNode(b,"ImportAttribute"))}while(this.eat(m.comma));return i}}}var ot=["onToken","onComment","onInsertedSemicolon","onTrailingComma"];function vt(){return{_tag:"BufferedParserEvents",segments:[]}}var re=vt();function Ct(r){return r.segments.length>0}var ae=class{constructor(r,o){this.options=r,this.state=o,this.callbacks={},this.callbackWrappers={},this.frames=[],this.undoLog=[],this.hasCallbacks=this.captureCallbacks()}get active(){return this.frames.length>0}begin(){let r={_tag:"ParseEffectFrame",depth:this.frames.length,undoMark:this.undoLog.length,checkpoint:this.state?.capture()};if(this.frames.push(r),r.depth===0&&this.hasCallbacks)this.activateCallbacks();return r}commit(r){this.close(r);let o=this.currentFrame();if(o){if(r.output)this.appendOutput(this.outputFor(o),r.output);return}if(this.undoLog.length=r.undoMark,r.output)this.flush(r.output)}rollback(r){this.close(r),this.unwind(r.undoMark),this.restore(r)}rollbackWithEvents(r){return this.close(r),this.unwind(r.undoMark),this.restore(r),r.output??re}replay(r){if(!Ct(r))return;let o=this.currentFrame();if(o){this.appendOutput(this.outputFor(o),r);return}this.flush(r)}set(r,o,c){this.willSet(r,o),r[o]=c}remove(r,o){this.willSet(r,o),delete r[o]}append(r,o){this.willAppend(r),r.push(o)}pop(r){return this.willMutateTail(r,1),r.pop()}truncate(r,o){if(o<r.length)this.willMutateTail(r,r.length-o);else this.willAppend(r);r.length=o}modify(r,o,c){let[p,m]=c(r[o]);return this.set(r,o,m),p}willAppend(r){if(!this.active)return;this.undoLog.push({_tag:"ArrayLength",target:r,length:r.length})}willMutateTail(r,o){if(!this.active)return;let c=Math.max(0,r.length-o);this.undoLog.push({_tag:"ArrayTail",target:r,start:c,values:r.slice(c)})}willSet(r,o){if(!this.active)return;let c=r;this.undoLog.push({_tag:"Property",target:c,key:o,had:Object.prototype.hasOwnProperty.call(c,o),value:c[o]})}captureCallbacks(){let r=!1;for(let o of ot){let c=this.options[o];if(!c)continue;r=!0,this.callbacks[o]=c,this.callbackWrappers[o]=(...p)=>{this.emit({name:o,args:p})}}return r}activateCallbacks(){for(let r of ot){let o=this.callbackWrappers[r];if(o)this.options[r]=o}}deactivateCallbacks(){for(let r of ot){let o=this.callbacks[r];if(o)this.options[r]=o}}emit(r){let o=this.currentFrame();if(!o){this.invoke(r);return}let c=this.outputFor(o).segments,p=c[c.length-1];if(Array.isArray(p))p.push(r);else c.push([r])}appendOutput(r,o){if(Ct(o))r.segments.push(o)}outputFor(r){return r.output??=vt()}flush(r){let o=[];for(let c=r.segments.length-1;c>=0;c--)o.push(r.segments[c]);while(o.length>0){let c=o.pop();if(Array.isArray(c)){for(let p of c)this.invoke(p);continue}for(let p=c.segments.length-1;p>=0;p--)o.push(c.segments[p])}}invoke(r){this.callbacks[r.name]?.apply(this.options,r.args)}currentFrame(){return this.frames[this.frames.length-1]}close(r){if(this.currentFrame()!==r||r.depth!==this.frames.length-1)throw Error("Parse effect scopes must be closed in order");if(this.frames.pop(),this.frames.length===0&&this.hasCallbacks)this.deactivateCallbacks()}restore(r){if(this.state)this.state.restore(r.checkpoint)}unwind(r){for(let o=this.undoLog.length-1;o>=r;o--){let c=this.undoLog[o];switch(c._tag){case"ArrayLength":if(c.target.length<c.length)throw Error("A parse effect shortened an append-only array");c.target.length=c.length;break;case"ArrayTail":c.target.length=c.start;for(let p of c.values)c.target.push(p);break;case"Property":if(c.had)c.target[c.key]=c.value;else delete c.target[c.key];break}}this.undoLog.length=r}};function W(r,o,c){if(r.length===o)return r;if(r.length<o)throw Error(`A parse branch shortened the ${c} below its checkpoint`);return r.length=o,r}function ne(r){return{lookahead:r.getCurLookaheadState(),context:r.context,contextLength:r.context.length,scopeStack:r.scopeStack,scopeStackLength:r.scopeStack.length,importsStack:r.importsStack,importsStackLength:r.importsStack.length,labels:r.labels,labelsLength:r.labels.length,privateNameStack:r.privateNameStack,privateNameStackLength:r.privateNameStack.length,decoratorStack:r.decoratorStack,decoratorStackLength:r.decoratorStack.length,strict:r.strict,potentialArrowAt:r.potentialArrowAt,potentialArrowInForAwait:r.potentialArrowInForAwait,yieldPos:r.yieldPos,awaitPos:r.awaitPos,awaitIdentPos:r.awaitIdentPos,preValue:r.preValue,preToken:r.preToken,isLookahead:r.isLookahead,isAmbientContext:r.isAmbientContext,inAbstractClass:r.inAbstractClass,inType:r.inType,inDisallowConditionalTypesContext:r.inDisallowConditionalTypesContext,maybeInArrowParameters:r.maybeInArrowParameters,shouldParseArrowReturnType:r.shouldParseArrowReturnType,shouldParseAsyncArrowReturnType:r.shouldParseAsyncArrowReturnType,importOrExportOuterKind:r.importOrExportOuterKind}}function oe(r,o){r.setLookaheadTokenState(o.lookahead),r.context=W(o.context,o.contextLength,"token context stack"),r.scopeStack=W(o.scopeStack,o.scopeStackLength,"scope stack"),r.importsStack=W(o.importsStack,o.importsStackLength,"import stack"),r.labels=W(o.labels,o.labelsLength,"label stack"),r.privateNameStack=W(o.privateNameStack,o.privateNameStackLength,"private-name stack"),r.decoratorStack=W(o.decoratorStack,o.decoratorStackLength,"decorator stack"),r.strict=o.strict,r.potentialArrowAt=o.potentialArrowAt,r.potentialArrowInForAwait=o.potentialArrowInForAwait,r.yieldPos=o.yieldPos,r.awaitPos=o.awaitPos,r.awaitIdentPos=o.awaitIdentPos,r.regexpState=null,r.preValue=o.preValue,r.preToken=o.preToken,r.isLookahead=o.isLookahead,r.isAmbientContext=o.isAmbientContext,r.inAbstractClass=o.inAbstractClass,r.inType=o.inType,r.inDisallowConditionalTypesContext=o.inDisallowConditionalTypesContext,r.maybeInArrowParameters=o.maybeInArrowParameters,r.shouldParseArrowReturnType=o.shouldParseArrowReturnType,r.shouldParseAsyncArrowReturnType=o.shouldParseAsyncArrowReturnType,r.importOrExportOuterKind=o.importOrExportOuterKind}function he(r){return{capture:()=>ne(r),restore:(o)=>oe(r,o)}}function le(r,o){let{acornTokenTypes:c,typeScriptTokenTypes:p,scope:m}=o,E=m.SCOPE_TOP|m.SCOPE_FUNCTION|m.SCOPE_CLASS_STATIC_BLOCK;return class extends r{constructor(P,b,I){super(P,b,I);this.parseEffects=new ae(this.options,he(this))}overrideContext(P){if(this.curContext()!==P)this.parseEffects?.willMutateTail(this.context,1);return super.overrideContext(P)}takeDecorators(P){let b=this.decoratorStack.length-1;if(this.decoratorStack[b].length>0)this.parseEffects?.willSet(this.decoratorStack,String(b));return super.takeDecorators(P)}parseDecorators(P){let b=this.decoratorStack[this.decoratorStack.length-1];return this.parseEffects?.willAppend(b),super.parseDecorators(P)}parseDecorator(){return this.parseEffects?.willAppend(this.decoratorStack),super.parseDecorator()}parseIdentNode(){if((this.type.keyword==="class"||this.type.keyword==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46))this.parseEffects?.willMutateTail(this.context,1);return super.parseIdentNode()}parseLabeledStatement(P,b,I,f){for(let S=this.labels.length-1;S>=0;S--){let C=this.labels[S];if(C.statementStart!==P.start)break;this.parseEffects?.willSet(C,"statementStart"),this.parseEffects?.willSet(C,"kind")}return this.parseEffects?.willAppend(this.labels),super.parseLabeledStatement(P,b,I,f)}enterClassBody(){return this.parseEffects?.willAppend(this.privateNameStack),super.enterClassBody()}exitClassBody(){let P=this.privateNameStack[this.privateNameStack.length-2];if(P)this.parseEffects?.willAppend(P.used);return this.parseEffects?.willMutateTail(this.privateNameStack,1),super.exitClassBody()}parsePrivateIdent(){if(this.options.checkPrivateFields&&this.privateNameStack.length>0){let P=this.privateNameStack[this.privateNameStack.length-1];this.parseEffects?.willAppend(P.used)}return super.parsePrivateIdent()}parseClassField(P){return this.parseEffects?.willSet(this.currentThisScope(),"inClassFieldInit"),super.parseClassField(P)}updateContext(P){let{type:b}=this;if(b===c.parenR||b===c.braceR||b===c.braceL||b===c.dollarBraceL||b===c.parenL||b===c._function||b===c._class||b===c.colon||b===c.backQuote||b===c.star||b===p.jsxTagStart||b===p.jsxTagEnd||b===c.slash&&P===p.jsxTagStart)this.parseEffects?.willMutateTail(this.context,2);return super.updateContext(P)}enterScope(P){return this.parseEffects?.willAppend(this.scopeStack),super.enterScope(P)}exitScope(){return this.parseEffects?.willMutateTail(this.scopeStack,1),super.exitScope()}declareName(P,b,I){let f=this.parseEffects;if(f?.active)if(b===m.BIND_LEXICAL){let S=this.currentScope();if(f.willAppend(S.lexical),this.inModule&&S.flags&m.SCOPE_TOP)f.willSet(this.undefinedExports,P)}else if(b===m.BIND_SIMPLE_CATCH)f.willAppend(this.currentScope().lexical);else if(b===m.BIND_FUNCTION)f.willAppend(this.currentScope().functions);else for(let S=this.scopeStack.length-1;S>=0;S--){let C=this.scopeStack[S];if(f.willAppend(C.var),this.inModule&&C.flags&m.SCOPE_TOP)f.willSet(this.undefinedExports,P);if(C.flags&E)break}return super.declareName(P,b,I)}checkLocalExport(P){return this.parseEffects?.willSet(this.undefinedExports,P.name),super.checkLocalExport(P)}}}var ht=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;function Et(r){if(!r)throw Error("Assert fail")}function ce(r){return r==="accessor"}function pe(r){return r==="in"||r==="out"}var tt=1,bt=2,ue=4,N={SCOPE_TOP:1,SCOPE_FUNCTION:2,SCOPE_ASYNC:4,SCOPE_GENERATOR:8,SCOPE_ARROW:16,SCOPE_SIMPLE_CATCH:32,SCOPE_SUPER:64,SCOPE_DIRECT_SUPER:128,SCOPE_CLASS_STATIC_BLOCK:256,SCOPE_VAR:256,BIND_NONE:0,BIND_VAR:1,BIND_LEXICAL:2,BIND_FUNCTION:3,BIND_SIMPLE_CATCH:4,BIND_OUTSIDE:5,BIND_TS_TYPE:6,BIND_TS_INTERFACE:7,BIND_TS_NAMESPACE:1032,BIND_FLAGS_TS_EXPORT_ONLY:1024,BIND_FLAGS_TS_IMPORT:4096,BIND_FLAGS_TS_ENUM:256,BIND_FLAGS_TS_CONST_ENUM:512,BIND_TS_ENUM:258,BIND_TS_CONST_ENUM:770,BIND_FLAGS_CLASS:128};function lt(r,o){return N.SCOPE_FUNCTION|(r?N.SCOPE_ASYNC:0)|(o?N.SCOPE_GENERATOR:0)}function de(r){if(r.type!=="MemberExpression")return!1;let{computed:o,property:c}=r;if(o&&(c.type!=="TemplateLiteral"||c.expressions.length>0))return!1;return Mt(r.object)}function fe(r){return r.type==="UnaryExpression"&&(r.operator==="-"||r.operator==="+")&&r.argument.type==="Literal"&&(typeof r.argument.value==="number"||typeof r.argument.value==="bigint")}function Mt(r){if(r.type==="Identifier")return!0;if(r.type!=="MemberExpression")return!1;if(r.computed)return!1;return Mt(r.object)}function gt(r){return r==="private"||r==="public"||r==="protected"}function me(r){return Boolean(r.startsExpr)}function ye(r){if(r==null)throw Error(`Unexpected ${r} value.`);return r}function Te(r){switch(r){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}}function Ot(r){let{dts:o=!1}=r||{},c=!!r?.jsx;return function(p){let m=p.acorn||ge,E=qt(m),{tokTypes:i,keywordTypes:P,isIdentifierStart:b,lineBreak:I,isNewLine:f,tokContexts:S,isIdentifierChar:C}=m,{tokTypes:y,tokContexts:O,keywordsRegExp:D,tokenIsLiteralPropertyName:M,tokenIsTemplate:z,tokenIsTSDeclarationStart:G,tokenIsIdentifier:w,tokenIsKeywordOrIdentifier:V,tokenIsTSTypeOperator:L}=E;function Z(t,e,s=t.length){for(let a=e;a<s;a++){let h=t.charCodeAt(a);if(f(h))return a<s-1&&h===13&&t.charCodeAt(a+1)===10?a+2:a+1}return-1}if(p=Zt(p,E,m),r?.jsx)p=se(m,E,p,typeof r.jsx==="boolean"?{}:r.jsx);p=ie(p,E,m);let Ht=le(p,{acornTokenTypes:i,typeScriptTokenTypes:y,scope:N});class xt extends Ht{constructor(t,e,s){super(t,e,s);this.preValue=null,this.preToken=null,this.isLookahead=!1,this.isAmbientContext=!1,this.inAbstractClass=!1,this.inType=!1,this.inDisallowConditionalTypesContext=!1,this.maybeInArrowParameters=!1,this.shouldParseArrowReturnType=void 0,this.shouldParseAsyncArrowReturnType=void 0,this.decoratorStack=[[]],this.importsStack=[[]],this.importOrExportOuterKind=void 0,this.tsParseConstModifier=(a)=>{this.tsParseModifiers({modified:a,allowedModifiers:["const"],disallowedModifiers:["in","out"],errorTemplate:A.InvalidModifierOnTypeParameterPositions})},this.ecmaVersion=this.options.ecmaVersion}static get acornTypeScript(){return E}get acornTypeScript(){return E}getTokenFromCodeInType(t){if(t===62)return this.finishOp(i.relational,1);if(t===60)return this.finishOp(i.relational,1);return super.getTokenFromCode(t)}readToken(t){if(!this.inType){let e=this.curContext();if(e===O.tc_expr)return this.jsx_readToken();if(e===O.tc_oTag||e===O.tc_cTag){if(b(t))return this.jsx_readWord();if(t==62)return++this.pos,this.finishToken(y.jsxTagEnd);if((t===34||t===39)&&e==O.tc_oTag)return this.jsx_readString(t)}if(t===60&&this.exprAllowed&&this.input.charCodeAt(this.pos+1)!==33)if(++this.pos,r?.jsx)return this.finishToken(y.jsxTagStart);else return this.finishToken(i.relational,"<")}return super.readToken(t)}getTokenFromCode(t){if(this.inType)return this.getTokenFromCodeInType(t);if(t===64)return++this.pos,this.finishToken(y.at);return super.getTokenFromCode(t)}isAbstractClass(){return this.ts_isContextual(y.abstract)&&this.lookahead().type===i._class}isDeclareClass(){if(!this.ts_isContextual(y.declare))return!1;let t=this.nextTokenStart();if(this.isUnparsedContextual(t,"class"))return!0;if(!this.isUnparsedContextual(t,"abstract"))return!1;let e=this.nextTokenStartSince(t+8);return this.isUnparsedContextual(e,"class")}finishNode(t,e){if(t.type!==""&&t.end!==0)return t;return super.finishNode(t,e)}tryParse(t){let e={},s=this.beginParseEffectScope(),a;try{a=t(()=>{throw e})}catch(h){let l=h===e;if(!l&&!(h instanceof SyntaxError))throw this.parseEffects.rollback(s),h;let u={events:this.parseEffects.rollbackWithEvents(s),selected:!1};return l?{node:null,error:null,thrown:!1,aborted:!0,failState:u}:{node:null,error:h,thrown:!0,aborted:!1,failState:u}}return this.parseEffects.commit(s),{node:a,error:null,thrown:!1,aborted:!1,failState:null}}setOptionalParametersError(t,e){t.optionalParametersLoc=e?.loc??this.startLoc}reScan_lt_gt(){if(this.type===i.relational)this.pos-=1,this.readToken_lt_gt(this.fullCharCodeAtPos())}reScan_lt(){let{type:t}=this;if(t===i.bitShift)return this.pos-=2,this.finishOp(i.relational,1),i.relational;return t}resetEndLocation(t,e=this.lastTokEnd,s=this.lastTokEndLoc){if(t.end=e,t.loc.end=s,this.options.ranges)t.range[1]=e}startNodeAtNode(t){return super.startNodeAt(t.start,t.loc.start)}nextTokenStart(){return this.nextTokenStartSince(this.pos)}tsHasSomeModifiers(t,e){return e.some((s)=>{if(gt(s))return t.accessibility===s;return!!t[s]})}tsIsStartOfStaticBlocks(){return this.isContextual("static")&&this.lookaheadCharCode()===123}tsCheckForInvalidTypeCasts(t){t.forEach((e)=>{if(e?.type==="TSTypeCastExpression")this.raise(e.typeAnnotation.start,A.UnexpectedTypeAnnotation)})}atPossibleAsyncArrow(t){return t.type==="Identifier"&&t.name==="async"&&this.lastTokEnd===t.end&&!this.canInsertSemicolon()&&t.end-t.start===5&&t.start===this.potentialArrowAt}tsIsIdentifier(){return w(this.type)}tsTryParseTypeOrTypePredicateAnnotation(){return this.match(i.colon)?this.tsParseTypeOrTypePredicateAnnotation(i.colon):void 0}tsTryParseGenericAsyncArrowFunction(t,e,s){if(!this.tsMatchLeftRelational())return;let a=this.maybeInArrowParameters;this.maybeInArrowParameters=!0;let h=this.tsTryParseAndCatch(()=>{let l=this.startNodeAt(t,e);return l.typeParameters=this.tsParseTypeParameters(this.tsParseConstModifier),super.parseFunctionParams(l),l.returnType=this.tsTryParseTypeOrTypePredicateAnnotation(),this.expect(i.arrow),l});if(this.maybeInArrowParameters=a,!h)return;return this.parseArrowExpression(h,h.params,!0,s)}tsParseTypeArgumentsInExpression(){if(this.reScan_lt()!==i.relational)return;return this.tsParseTypeArguments(!0)}tsInNoContext(t){let e=this.context;this.context=[e[0]];try{return t()}finally{this.context=e}}tsTryParseTypeAnnotation(){return this.match(i.colon)?this.tsParseTypeAnnotation():void 0}isUnparsedContextual(t,e){let s=t+e.length;if(this.input.slice(t,s)===e){let a=this.input.charCodeAt(s);return!(C(a)||(a&64512)===55296)}return!1}isAbstractConstructorSignature(){return this.ts_isContextual(y.abstract)&&this.lookahead().type===i._new}nextTokenStartSince(t){return ht.lastIndex=t,ht.test(this.input)?ht.lastIndex:t}lookaheadCharCode(){return this.input.charCodeAt(this.nextTokenStart())}createLookaheadState(){this.value=null,this.context=[this.curContext()]}getCurLookaheadState(){return{endLoc:this.endLoc,lastTokEnd:this.lastTokEnd,lastTokStart:this.lastTokStart,lastTokStartLoc:this.lastTokStartLoc,pos:this.pos,value:this.value,type:this.type,exprAllowed:this.exprAllowed,start:this.start,end:this.end,context:this.context,startLoc:this.startLoc,lastTokEndLoc:this.lastTokEndLoc,curLine:this.curLine,lineStart:this.lineStart,containsEsc:this.containsEsc}}setLookaheadTokenState(t){this.pos=t.pos,this.value=t.value,this.exprAllowed=t.exprAllowed,this.endLoc=t.endLoc,this.lastTokEnd=t.lastTokEnd,this.lastTokStart=t.lastTokStart,this.lastTokStartLoc=t.lastTokStartLoc,this.type=t.type,this.start=t.start,this.end=t.end,this.startLoc=t.startLoc,this.lastTokEndLoc=t.lastTokEndLoc,this.curLine=t.curLine,this.lineStart=t.lineStart,this.containsEsc=t.containsEsc}setLookaheadState(t){this.setLookaheadTokenState(t),this.context=t.context&&t.context.slice()}beginParseEffectScope(){return this.parseEffects.begin()}selectTryParseResult(t){let e=t.failState;if(!e)return;if(e.selected)throw Error("A parse branch result can only be selected once");e.selected=!0,this.parseEffects.replay(e.events)}tsLookAhead(t){let e=this.beginParseEffectScope();try{return t()}finally{this.parseEffects.rollback(e)}}lookahead(t){let e=this.getCurLookaheadState(),s=this.context,a=this.preValue,h=this.preToken,l=this.isLookahead;try{if(this.createLookaheadState(),this.isLookahead=!0,t!==void 0)for(let u=0;u<t;u++)this.nextToken();else this.nextToken();return this.getCurLookaheadState()}finally{this.setLookaheadTokenState(e),this.context=s,this.preValue=a,this.preToken=h,this.isLookahead=l}}readWord(){let t=this.readWord1(),e=i.name;if(this.keywords.test(t))e=P[t];else if(new RegExp(D).test(t))e=y[t];return this.finishToken(e,t)}skipBlockComment(){let t;if(!this.isLookahead)t=this.options.onComment&&this.curPosition();let e=this.pos,s=this.input.indexOf("*/",this.pos+=2);if(s===-1)this.raise(this.pos-2,"Unterminated comment");if(this.pos=s+2,this.options.locations)for(let a,h=e;(a=Z(this.input,h,this.pos))>-1;)++this.curLine,h=this.lineStart=a;if(this.isLookahead)return;if(this.options.onComment)this.options.onComment(!0,this.input.slice(e+2,s),e,this.pos,t,this.curPosition())}skipLineComment(t){let e=this.pos,s;if(!this.isLookahead)s=this.options.onComment&&this.curPosition();let a=this.input.charCodeAt(this.pos+=t);while(this.pos<this.input.length&&!f(a))a=this.input.charCodeAt(++this.pos);if(this.isLookahead)return;if(this.options.onComment)this.options.onComment(!1,this.input.slice(e+t,this.pos),e,this.pos,s,this.curPosition())}finishToken(t,e){if(this.preValue=this.value,this.preToken=this.type,this.end=this.pos,this.options.locations)this.endLoc=this.curPosition();let s=this.type;if(this.type=t,this.value=e,!this.isLookahead)this.updateContext(s)}resetStartLocation(t,e,s){if(t.start=e,t.loc.start=s,this.options.ranges)t.range[0]=e}isLineTerminator(){return this.eat(i.semi)||super.canInsertSemicolon()}hasFollowingLineBreak(){return Pt.lastIndex=this.end,Pt.test(this.input)}addExtra(t,e,s,a=!0){if(!t)return;let h=t.extra=t.extra||{};if(a)h[e]=s;else Object.defineProperty(h,e,{enumerable:a,value:s})}isLiteralPropertyName(){return M(this.type)}hasPrecedingLineBreak(){return I.test(this.input.slice(this.lastTokEnd,this.start))}createIdentifier(t,e){return t.name=e,this.finishNode(t,"Identifier")}resetStartLocationFromNode(t,e){this.resetStartLocation(t,e.start,e.loc.start)}isThisParam(t){return t.type==="Identifier"&&t.name==="this"}isLookaheadContextual(t){let e=this.nextTokenStart();return this.isUnparsedContextual(e,t)}ts_type_isContextual(t,e){return t===e&&!this.containsEsc}ts_isContextual(t){return this.type===t&&!this.containsEsc}ts_isContextualWithState(t,e){return t.type===e&&!t.containsEsc}isContextualWithState(t,e){return e.type===i.name&&e.value===t&&!e.containsEsc}tsIsStartOfMappedType(){if(this.next(),this.eat(i.plusMin))return this.ts_isContextual(y.readonly);if(this.ts_isContextual(y.readonly))this.next();if(!this.match(i.bracketL))return!1;if(this.next(),!this.tsIsIdentifier())return!1;return this.next(),this.match(i._in)}tsInDisallowConditionalTypesContext(t){let e=this.inDisallowConditionalTypesContext;this.inDisallowConditionalTypesContext=!0;try{return t()}finally{this.inDisallowConditionalTypesContext=e}}tsTryParseType(){return this.tsEatThenParseType(i.colon)}match(t){return this.type===t}matchJsx(t){return this.type===E.tokTypes[t]}ts_eatWithState(t,e,s){let a=s.type;if(t===a){for(let h=0;h<e;h++)this.next();return!0}else return!1}ts_eatContextualWithState(t,e,s){if(D.test(t)){if(this.ts_isContextualWithState(s,y[t])){for(let a=0;a<e;a++)this.next();return!0}return!1}else{if(!this.isContextualWithState(t,s))return!1;for(let a=0;a<e;a++)this.next();return!0}}canHaveLeadingDecorator(){return this.match(i._class)||this.isAbstractClass()||this.isDeclareClass()}eatContextual(t){if(D.test(t)){if(this.ts_isContextual(y[t]))return this.next(),!0;return!1}else return super.eatContextual(t)}tsIsExternalModuleReference(){return this.isContextual("require")&&this.lookaheadCharCode()===40}tsParseExternalModuleReference(){let t=this.startNode();if(this.expectContextual("require"),this.expect(i.parenL),!this.match(i.string))this.unexpected();return t.expression=this.parseExprAtom(),this.expect(i.parenR),this.finishNode(t,"TSExternalModuleReference")}tsParseEntityName(t=!0){let e=this.parseIdent(t);while(this.eat(i.dot)){let s=this.startNodeAtNode(e);s.left=e,s.right=this.parseIdent(t),e=this.finishNode(s,"TSQualifiedName")}return e}tsParseEnumMember(){let t=this.startNode();if(t.id=this.match(i.string)?this.parseLiteral(this.value):this.parseIdent(!0),this.eat(i.eq))t.initializer=this.parseMaybeAssign();return this.finishNode(t,"TSEnumMember")}tsParseEnumDeclaration(t,e={}){if(e.const)t.const=!0;if(e.declare)t.declare=!0;this.expectContextual("enum"),t.id=this.parseIdent();let s=e.const?N.BIND_TS_CONST_ENUM:N.BIND_TS_ENUM;return this.checkLValSimple(t.id,s),this.expect(i.braceL),t.members=this.tsParseDelimitedList("EnumMembers",this.tsParseEnumMember.bind(this)),this.expect(i.braceR),this.finishNode(t,"TSEnumDeclaration")}tsParseModuleBlock(){let t=this.startNode();this.enterScope(Wt),this.expect(i.braceL),t.body=[];while(this.type!==i.braceR){let e=this.parseStatement(null,!0);t.body.push(e)}return this.next(),super.exitScope(),this.finishNode(t,"TSModuleBlock")}tsParseAmbientExternalModuleDeclaration(t){if(this.ts_isContextual(y.global))t.global=!0,t.id=this.parseIdent();else if(this.match(i.string))t.id=this.parseLiteral(this.value);else this.unexpected();if(this.match(i.braceL))this.enterScope(J),t.body=this.tsParseModuleBlock(),super.exitScope();else super.semicolon();return this.finishNode(t,"TSModuleDeclaration")}tsTryParseDeclare(t){if(this.isLineTerminator())return;let e=this.type,s;if(this.isContextual("let"))e=i._var,s="let";return this.tsInAmbientContext(()=>{if(e===i._function)return t.declare=!0,this.parseFunctionStatement(t,!1,!0);if(e===i._class)return t.declare=!0,this.parseClass(t,!0);if(e===y.enum)return this.tsParseEnumDeclaration(t,{declare:!0});if(e===y.global)return this.tsParseAmbientExternalModuleDeclaration(t);if(e===i._const||e===i._var){if(!this.match(i._const)||!this.isLookaheadContextual("enum"))return t.declare=!0,this.parseVarStatement(t,s||this.value,!0);return this.expect(i._const),this.tsParseEnumDeclaration(t,{const:!0,declare:!0})}if(e===y.interface){let a=this.tsParseInterfaceDeclaration(t,{declare:!0});if(a)return a}if(w(e))return this.tsParseDeclaration(t,this.value,!0)})}tsIsListTerminator(t){switch(t){case"EnumMembers":case"TypeMembers":return this.match(i.braceR);case"HeritageClauseElement":return this.match(i.braceL);case"TupleElementTypes":return this.match(i.bracketR);case"TypeParametersOrArguments":return this.tsMatchRightRelational()}}tsParseDelimitedListWorker(t,e,s,a){let h=[],l=-1;for(;;){if(this.tsIsListTerminator(t))break;l=-1;let u=e();if(u==null)return;if(h.push(u),this.eat(i.comma)){l=this.lastTokStart;continue}if(this.tsIsListTerminator(t))break;if(s)this.expect(i.comma);return}if(a)a.value=l;return h}tsParseDelimitedList(t,e,s){return ye(this.tsParseDelimitedListWorker(t,e,!0,s))}tsParseBracketedList(t,e,s,a,h){if(!a)if(s)this.expect(i.bracketL);else this.expect(i.relational);let l=this.tsParseDelimitedList(t,e,h);if(s)this.expect(i.bracketR);else this.expect(i.relational);return l}tsParseTypeParameterName(){return this.parseIdent().name}tsEatThenParseType(t){return!this.match(t)?void 0:this.tsNextThenParseType()}tsExpectThenParseType(t){return this.tsDoThenParseType(()=>this.expect(t))}tsNextThenParseType(){return this.tsDoThenParseType(()=>this.next())}tsDoThenParseType(t){return this.tsInType(()=>(t(),this.tsParseType()))}tsSkipParameterStart(){if(w(this.type)||this.match(i._this))return this.next(),!0;if(this.match(i.braceL))try{return this.parseObj(!0),!0}catch{return!1}if(this.match(i.bracketL)){this.next();try{return this.parseBindingList(i.bracketR,!0,!0),!0}catch{return!1}}return!1}tsIsUnambiguouslyStartOfFunctionType(){if(this.next(),this.match(i.parenR)||this.match(i.ellipsis))return!0;if(this.tsSkipParameterStart()){if(this.match(i.colon)||this.match(i.comma)||this.match(i.question)||this.match(i.eq))return!0;if(this.match(i.parenR)){if(this.next(),this.match(i.arrow))return!0}}return!1}tsIsStartOfFunctionType(){if(this.tsMatchLeftRelational())return!0;return this.match(i.parenL)&&this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))}tsInAllowConditionalTypesContext(t){let e=this.inDisallowConditionalTypesContext;this.inDisallowConditionalTypesContext=!1;try{return t()}finally{this.inDisallowConditionalTypesContext=e}}tsParseBindingListForSignature(){return super.parseBindingList(i.parenR,!0,!0).map((t)=>{if(t.type!=="Identifier"&&t.type!=="RestElement"&&t.type!=="ObjectPattern"&&t.type!=="ArrayPattern")this.raise(t.start,A.UnsupportedSignatureParameterKind({type:t.type}));return t})}tsParseTypePredicateAsserts(){if(this.type!==y.asserts)return!1;let t=this.containsEsc;if(this.next(),!w(this.type)&&!this.match(i._this))return!1;if(t)this.raise(this.lastTokStart,"Escape sequence in keyword asserts");return!0}tsParseThisTypeNode(){let t=this.startNode();return this.next(),this.finishNode(t,"TSThisType")}tsParseTypeAnnotation(t=!0,e=this.startNode()){return this.tsInType(()=>{if(t)this.expect(i.colon);e.typeAnnotation=this.tsParseType()}),this.finishNode(e,"TSTypeAnnotation")}tsParseThisTypePredicate(t){this.next();let e=this.startNodeAtNode(t);return e.parameterName=t,e.typeAnnotation=this.tsParseTypeAnnotation(!1),e.asserts=!1,this.finishNode(e,"TSTypePredicate")}tsParseThisTypeOrThisTypePredicate(){let t=this.tsParseThisTypeNode();if(this.isContextual("is")&&!this.hasPrecedingLineBreak())return this.tsParseThisTypePredicate(t);else return t}tsParseTypePredicatePrefix(){let t=this.parseIdent();if(this.isContextual("is")&&!this.hasPrecedingLineBreak())return this.next(),t}tsParseTypeOrTypePredicateAnnotation(t){return this.tsInType(()=>{let e=this.startNode();this.expect(t);let s=this.startNode(),a=this.tsIsIdentifier()&&this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));if(a){let x=this.tsParseTypeAnnotation(!1);return s.parameterName=a,s.typeAnnotation=x,s.asserts=!1,e.typeAnnotation=this.finishNode(s,"TSTypePredicate"),this.finishNode(e,"TSTypeAnnotation")}let h=!!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));if(h&&this.match(i._this)){let x=this.tsParseThisTypeOrThisTypePredicate();if(x.type==="TSThisType")s.parameterName=x,s.asserts=!0,s.typeAnnotation=null,x=this.finishNode(s,"TSTypePredicate");else this.resetStartLocationFromNode(x,s),x.asserts=!0;return e.typeAnnotation=x,this.finishNode(e,"TSTypeAnnotation")}let l=h&&this.tsIsIdentifier()&&this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));if(!l){if(!h)return this.tsParseTypeAnnotation(!1,e);return s.parameterName=this.parseIdent(),s.asserts=h,s.typeAnnotation=null,e.typeAnnotation=this.finishNode(s,"TSTypePredicate"),this.finishNode(e,"TSTypeAnnotation")}let u=this.tsParseTypeAnnotation(!1);return s.parameterName=l,s.typeAnnotation=u,s.asserts=h,e.typeAnnotation=this.finishNode(s,"TSTypePredicate"),this.finishNode(e,"TSTypeAnnotation")})}tsFillSignature(t,e){let s=t===i.arrow,a="parameters",h="typeAnnotation";if(e.typeParameters=this.tsTryParseTypeParameters(),this.expect(i.parenL),e.parameters=this.tsParseBindingListForSignature(),s)e.typeAnnotation=this.tsParseTypeOrTypePredicateAnnotation(t);else if(this.match(t))e.typeAnnotation=this.tsParseTypeOrTypePredicateAnnotation(t)}tsTryNextParseConstantContext(){if(this.lookahead().type!==i._const)return null;this.next();let t=this.tsParseTypeReference();if(t.typeParameters||t.typeArguments)this.raise(t.typeName.start,A.CannotFindName({name:"const"}));return t}tsParseFunctionOrConstructorType(t,e){let s=this.startNode();if(t==="TSConstructorType"){if(s.abstract=!!e,e)this.next();this.next()}return this.tsInAllowConditionalTypesContext(()=>this.tsFillSignature(i.arrow,s)),this.finishNode(s,t)}tsParseUnionOrIntersectionType(t,e,s){let a=this.startNode(),h=this.eat(s),l=[];do l.push(e());while(this.eat(s));if(l.length===1&&!h)return l[0];return a.types=l,this.finishNode(a,t)}tsCheckTypeAnnotationForReadOnly(t){switch(t.typeAnnotation.type){case"TSTupleType":case"TSArrayType":return;default:this.raise(t.start,A.UnexpectedReadonly)}}tsParseTypeOperator(){let t=this.startNode(),e=this.value;if(this.next(),t.operator=e,t.typeAnnotation=this.tsParseTypeOperatorOrHigher(),e==="readonly")this.tsCheckTypeAnnotationForReadOnly(t);return this.finishNode(t,"TSTypeOperator")}tsParseConstraintForInferType(){if(this.eat(i._extends)){let t=this.tsInDisallowConditionalTypesContext(()=>this.tsParseType());if(this.inDisallowConditionalTypesContext||!this.match(i.question))return t}}tsParseInferType(){let t=this.startNode();this.expectContextual("infer");let e=this.startNode();return e.name=this.tsParseTypeParameterName(),e.constraint=this.tsTryParse(()=>this.tsParseConstraintForInferType()),t.typeParameter=this.finishNode(e,"TSTypeParameter"),this.finishNode(t,"TSInferType")}tsParseLiteralTypeNode(){let t=this.startNode();return t.literal=(()=>{switch(this.type){case i.num:case i.string:case i._true:case i._false:return this.parseExprAtom();default:this.unexpected()}})(),this.finishNode(t,"TSLiteralType")}tsParseImportType(){let t=this.startNode();if(this.expect(i._import),this.expect(i.parenL),!this.match(i.string))this.raise(this.start,A.UnsupportedImportTypeArgument);if(t.argument=this.parseExprAtom(),this.expect(i.parenR),this.eat(i.dot))t.qualifier=this.tsParseEntityName();if(this.tsMatchLeftRelational())t.typeArguments=this.tsParseTypeArguments();return this.finishNode(t,"TSImportType")}tsParseTypeQuery(){let t=this.startNode();if(this.expect(i._typeof),this.match(i._import))t.exprName=this.tsParseImportType();else t.exprName=this.tsParseEntityName();if(!this.hasPrecedingLineBreak()&&this.tsMatchLeftRelational())t.typeArguments=this.tsParseTypeArguments();return this.finishNode(t,"TSTypeQuery")}tsParseMappedTypeParameter(){let t=this.startNode();return t.name=this.tsParseTypeParameterName(),t.constraint=this.tsExpectThenParseType(i._in),this.finishNode(t,"TSTypeParameter")}tsParseMappedType(){let t=this.startNode();if(this.expect(i.braceL),this.match(i.plusMin))t.readonly=this.value,this.next(),this.expectContextual("readonly");else if(this.eatContextual("readonly"))t.readonly=!0;if(this.expect(i.bracketL),t.typeParameter=this.tsParseMappedTypeParameter(),t.nameType=this.eatContextual("as")?this.tsParseType():null,this.expect(i.bracketR),this.match(i.plusMin))t.optional=this.value,this.next(),this.expect(i.question);else if(this.eat(i.question))t.optional=!0;return t.typeAnnotation=this.tsTryParseType(),this.semicolon(),this.expect(i.braceR),this.finishNode(t,"TSMappedType")}tsParseTypeLiteral(){let t=this.startNode();return t.members=this.tsParseObjectTypeMembers(),this.finishNode(t,"TSTypeLiteral")}tsIsTupleElementLabel(){if(!V(this.type))return!1;let t=this.lookahead();if(t.type===i.colon)return!0;if(t.type!==i.question)return!1;return this.lookahead(2).type===i.colon}tsParseTupleElementType(){let t=this.startLoc,e=this.start,s=this.eat(i.ellipsis),a;if(this.tsIsTupleElementLabel()){let h=this.startNode();h.label=this.parseIdent(!0),h.optional=this.eat(i.question),this.expect(i.colon),h.elementType=this.tsParseType(),a=this.finishNode(h,"TSNamedTupleMember")}else{a=this.tsParseType();let h=this.eat(i.question);if(this.eat(i.colon))this.raise(a.start,A.InvalidTupleMemberLabel);if(h){let l=this.startNodeAtNode(a);l.typeAnnotation=a,a=this.finishNode(l,"TSOptionalType")}}if(s){let h=this.startNodeAt(e,t);h.typeAnnotation=a,a=this.finishNode(h,"TSRestType")}return a}tsParseTupleType(){let t=this.startNode();t.elementTypes=this.tsParseBracketedList("TupleElementTypes",this.tsParseTupleElementType.bind(this),!0,!1);let e=!1;return t.elementTypes.forEach((s)=>{let{type:a}=s;if(e&&a!=="TSRestType"&&a!=="TSOptionalType"&&!(a==="TSNamedTupleMember"&&s.optional))this.raise(s.start,A.OptionalTypeBeforeRequired);if(e||=a==="TSNamedTupleMember"&&s.optional||a==="TSOptionalType",a==="TSRestType")s=s.typeAnnotation}),this.finishNode(t,"TSTupleType")}tsParseTemplateLiteralType(){let t=this.startNode();return t.literal=this.parseTemplate({isTagged:!1}),this.finishNode(t,"TSLiteralType")}tsParseTypeReference(){let t=this.startNode();if(t.typeName=this.tsParseEntityName(),!this.hasPrecedingLineBreak()&&this.tsMatchLeftRelational())t.typeArguments=this.tsParseTypeArguments();return this.finishNode(t,"TSTypeReference")}tsMatchLeftRelational(){return this.match(i.relational)&&this.value==="<"}tsMatchRightRelational(){return this.match(i.relational)&&this.value===">"}tsParseParenthesizedType(){let t=this.startNode();return this.expect(i.parenL),t.typeAnnotation=this.tsParseType(),this.expect(i.parenR),this.finishNode(t,"TSParenthesizedType")}tsParseNonArrayType(){switch(this.type){case i.string:case i.num:case i._true:case i._false:return this.tsParseLiteralTypeNode();case i.plusMin:if(this.value==="-"){let t=this.startNode();if(this.lookahead().type!==i.num)this.unexpected();return t.literal=this.parseMaybeUnary(),this.finishNode(t,"TSLiteralType")}break;case i._this:return this.tsParseThisTypeOrThisTypePredicate();case i._typeof:return this.tsParseTypeQuery();case i._import:return this.tsParseImportType();case i.braceL:return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))?this.tsParseMappedType():this.tsParseTypeLiteral();case i.bracketL:return this.tsParseTupleType();case i.parenL:return this.tsParseParenthesizedType();case i.backQuote:case i.dollarBraceL:return this.tsParseTemplateLiteralType();default:{let{type:t}=this;if(V(t)||t===i._void||t===i._null){let e=t===i._void?"TSVoidKeyword":t===i._null?"TSNullKeyword":Te(this.value);if(e!==void 0&&this.lookaheadCharCode()!==46){let s=this.startNode();return this.next(),this.finishNode(s,e)}return this.tsParseTypeReference()}}}this.unexpected()}tsParseArrayTypeOrHigher(){let t=this.tsParseNonArrayType();while(!this.hasPrecedingLineBreak()&&this.eat(i.bracketL))if(this.match(i.bracketR)){let e=this.startNodeAtNode(t);e.elementType=t,this.expect(i.bracketR),t=this.finishNode(e,"TSArrayType")}else{let e=this.startNodeAtNode(t);e.objectType=t,e.indexType=this.tsParseType(),this.expect(i.bracketR),t=this.finishNode(e,"TSIndexedAccessType")}return t}tsParseTypeOperatorOrHigher(){return L(this.type)&&!this.containsEsc?this.tsParseTypeOperator():this.isContextual("infer")?this.tsParseInferType():this.tsInAllowConditionalTypesContext(()=>this.tsParseArrayTypeOrHigher())}tsParseIntersectionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSIntersectionType",this.tsParseTypeOperatorOrHigher.bind(this),i.bitwiseAND)}tsParseUnionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSUnionType",this.tsParseIntersectionTypeOrHigher.bind(this),i.bitwiseOR)}tsParseNonConditionalType(){if(this.tsIsStartOfFunctionType())return this.tsParseFunctionOrConstructorType("TSFunctionType");if(this.match(i._new))return this.tsParseFunctionOrConstructorType("TSConstructorType");else if(this.isAbstractConstructorSignature())return this.tsParseFunctionOrConstructorType("TSConstructorType",!0);return this.tsParseUnionTypeOrHigher()}tsParseType(){Et(this.inType);let t=this.tsParseNonConditionalType();if(this.inDisallowConditionalTypesContext||this.hasPrecedingLineBreak()||!this.eat(i._extends))return t;let e=this.startNodeAtNode(t);return e.checkType=t,e.extendsType=this.tsInDisallowConditionalTypesContext(()=>this.tsParseNonConditionalType()),this.expect(i.question),e.trueType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.expect(i.colon),e.falseType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.finishNode(e,"TSConditionalType")}tsIsUnambiguouslyIndexSignature(){if(this.next(),w(this.type))return this.next(),this.match(i.colon);return!1}tsInType(t){let e=this.inType;this.inType=!0;try{return t()}finally{this.inType=e}}tsTryParseIndexSignature(t){if(!(this.match(i.bracketL)&&this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))))return;this.expect(i.bracketL);let e=this.parseIdent();e.typeAnnotation=this.tsParseTypeAnnotation(),this.resetEndLocation(e),this.expect(i.bracketR),t.parameters=[e];let s=this.tsTryParseTypeAnnotation();if(s)t.typeAnnotation=s;return this.tsParseTypeMemberSemicolon(),this.finishNode(t,"TSIndexSignature")}tsParseNoneModifiers(t){this.tsParseModifiers({modified:t,allowedModifiers:[],disallowedModifiers:["in","out"],errorTemplate:A.InvalidModifierOnTypeParameterPositions})}tsParseTypeParameter(t=this.tsParseNoneModifiers.bind(this)){let e=this.startNode();return t(e),e.name=this.tsParseTypeParameterName(),e.constraint=this.tsEatThenParseType(i._extends),e.default=this.tsEatThenParseType(i.eq),this.finishNode(e,"TSTypeParameter")}tsParseTypeParameters(t){let e=this.startNode();if(this.tsMatchLeftRelational()||this.matchJsx("jsxTagStart"))this.next();else this.unexpected();let s={value:-1};if(e.params=this.tsParseBracketedList("TypeParametersOrArguments",this.tsParseTypeParameter.bind(this,t),!1,!0,s),e.params.length===0)this.raise(this.start,A.EmptyTypeParameters);if(s.value!==-1)this.addExtra(e,"trailingComma",s.value);return this.finishNode(e,"TSTypeParameterDeclaration")}tsTryParseTypeParameters(t){if(this.tsMatchLeftRelational())return this.tsParseTypeParameters(t)}tsTryParse(t){let e=this.beginParseEffectScope(),s;try{s=t()}catch(a){throw this.parseEffects.rollback(e),a}if(s!==void 0&&s!==!1)return this.parseEffects.commit(e),s;this.parseEffects.rollback(e);return}tsTokenCanFollowModifier(){return(this.match(i.bracketL)||this.match(i.braceL)||this.match(i.star)||this.match(i.ellipsis)||this.match(i.privateId)||this.isLiteralPropertyName())&&!this.hasPrecedingLineBreak()}tsNextTokenCanFollowModifier(){return this.next(!0),this.tsTokenCanFollowModifier()}tsParseModifier(t,e){let s=this.value;if(t.indexOf(s)!==-1&&!this.containsEsc){if(e&&this.tsIsStartOfStaticBlocks())return;if(this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this)))return s}return}tsParseModifiersByMap({modified:t,map:e}){for(let s of Object.keys(e))t[s]=e[s]}tsParseModifiers({modified:t,allowedModifiers:e,disallowedModifiers:s,stopOnStartOfClassStaticBlock:a,errorTemplate:h=A.InvalidModifierOnTypeMember}){let l={},u=(T,d,g,v)=>{if(d===g&&t[v])this.raise(T.column,A.InvalidModifiersOrder({orderedModifiers:[g,v]}))},x=(T,d,g,v)=>{if(t[g]&&d===v||t[v]&&d===g)this.raise(T.column,A.IncompatibleModifiers({modifiers:[g,v]}))};for(;;){let T=this.startLoc,d=this.tsParseModifier(e.concat(s??[]),a);if(!d)break;if(gt(d))if(t.accessibility)this.raise(this.start,A.DuplicateAccessibilityModifier());else u(T,d,d,"override"),u(T,d,d,"static"),u(T,d,d,"readonly"),u(T,d,d,"accessor"),l.accessibility=d,t.accessibility=d;else if(pe(d))if(t[d])this.raise(this.start,A.DuplicateModifier({modifier:d}));else u(T,d,"in","out"),l[d]=d,t[d]=!0;else if(ce(d))if(t[d])this.raise(this.start,A.DuplicateModifier({modifier:d}));else x(T,d,"accessor","readonly"),x(T,d,"accessor","override"),l[d]=d,t[d]=!0;else if(d==="const")if(t[d])this.raise(this.start,A.DuplicateModifier({modifier:d}));else l[d]=d,t[d]=!0;else if(Object.hasOwnProperty.call(t,d))this.raise(this.start,A.DuplicateModifier({modifier:d}));else u(T,d,"static","readonly"),u(T,d,"static","override"),u(T,d,"override","readonly"),u(T,d,"abstract","override"),x(T,d,"declare","override"),x(T,d,"static","abstract"),l[d]=d,t[d]=!0;if(s?.includes(d))this.raise(this.start,h)}return l}tsParseInOutModifiers(t){this.tsParseModifiers({modified:t,allowedModifiers:["in","out"],disallowedModifiers:["public","private","protected","readonly","declare","abstract","override"],errorTemplate:A.InvalidModifierOnTypeParameter})}tsParseClassTypeParameterModifiers(t){this.tsParseModifiers({modified:t,allowedModifiers:["const","in","out"],disallowedModifiers:["public","private","protected","readonly","declare","abstract","override"],errorTemplate:A.InvalidModifierOnTypeParameter})}parseMaybeUnary(t,e,s,a){if(!r?.jsx&&this.tsMatchLeftRelational())return this.tsParseTypeAssertion();else return super.parseMaybeUnary(t,e,s,a)}tsParseTypeAssertion(){if(c)this.raise(this.start,A.ReservedTypeAssertion);let t=this.tryParse(()=>{let e=this.startNode(),s=this.tsTryNextParseConstantContext();return e.typeAnnotation=s||this.tsNextThenParseType(),this.expect(i.relational),e.expression=this.parseMaybeUnary(),this.finishNode(e,"TSTypeAssertion")});if(t.error)return this.tsParseTypeParameters(this.tsParseConstModifier);else return t.node}tsParseTypeArguments(t=!1){let e=this.startNode();if(e.params=this.tsInType(()=>this.tsInNoContext(()=>(this.expect(i.relational),this.tsParseDelimitedList("TypeParametersOrArguments",this.tsParseType.bind(this))))),e.params.length===0)this.raise(this.start,A.EmptyTypeArguments);if(t&&this.curContext()!==O.tc_oTag)this.reScan_lt_gt();if(!this.tsMatchRightRelational())this.unexpected();return this.exprAllowed=!1,this.next(),this.finishNode(e,"TSTypeParameterInstantiation")}tsParseHeritageClause(t){let e=this.start,s=this.tsParseDelimitedList("HeritageClauseElement",()=>{let a=this.startNode();if(a.expression=this.tsParseEntityName(),this.tsMatchLeftRelational())a.typeParameters=this.tsParseTypeArguments();return this.finishNode(a,"TSExpressionWithTypeArguments")});if(!s.length)this.raise(e,A.EmptyHeritageClauseType({token:t}));return s}tsParseTypeMemberSemicolon(){if(!this.eat(i.comma)&&!this.isLineTerminator())this.expect(i.semi)}tsTryParseAndCatch(t){let e=this.tryParse((s)=>t()||s());if(e.aborted||!e.node)return;return e.node}tsParseSignatureMember(t,e){return this.tsFillSignature(i.colon,e),this.tsParseTypeMemberSemicolon(),this.finishNode(e,t)}tsParsePropertyOrMethodSignature(t,e){if(this.eat(i.question))t.optional=!0;let s=t;if(this.match(i.parenL)||this.tsMatchLeftRelational()){if(e)this.raise(t.start,A.ReadonlyForMethodSignature);let a=s;if(a.kind&&this.tsMatchLeftRelational())this.raise(this.start,A.AccesorCannotHaveTypeParameters);this.tsFillSignature(i.colon,a),this.tsParseTypeMemberSemicolon();let h="parameters",l="typeAnnotation";if(a.kind==="get"){if(a[h].length>0){if(this.raise(this.start,"A 'get' accesor must not have any formal parameters."),this.isThisParam(a[h][0]))this.raise(this.start,A.AccesorCannotDeclareThisParameter)}}else if(a.kind==="set"){if(a[h].length!==1)this.raise(this.start,"A 'get' accesor must not have any formal parameters.");else{let u=a[h][0];if(this.isThisParam(u))this.raise(this.start,A.AccesorCannotDeclareThisParameter);if(u.type==="Identifier"&&u.optional)this.raise(this.start,A.SetAccesorCannotHaveOptionalParameter);if(u.type==="RestElement")this.raise(this.start,A.SetAccesorCannotHaveRestParameter)}if(a[l])this.raise(a[l].start,A.SetAccesorCannotHaveReturnType)}else a.kind="method";return this.finishNode(a,"TSMethodSignature")}else{let a=s;if(e)a.readonly=!0;let h=this.tsTryParseTypeAnnotation();if(h)a.typeAnnotation=h;return this.tsParseTypeMemberSemicolon(),this.finishNode(a,"TSPropertySignature")}}tsParseTypeMember(){let t=this.startNode();if(this.match(i.parenL)||this.tsMatchLeftRelational())return this.tsParseSignatureMember("TSCallSignatureDeclaration",t);if(this.match(i._new)){let s=this.startNode();if(this.next(),this.match(i.parenL)||this.tsMatchLeftRelational())return this.tsParseSignatureMember("TSConstructSignatureDeclaration",t);else return t.key=this.createIdentifier(s,"new"),this.tsParsePropertyOrMethodSignature(t,!1)}this.tsParseModifiers({modified:t,allowedModifiers:["readonly"],disallowedModifiers:["declare","abstract","private","protected","public","static","override"]});let e=this.tsTryParseIndexSignature(t);if(e)return e;if(this.parsePropertyName(t),!t.computed&&t.key.type==="Identifier"&&(t.key.name==="get"||t.key.name==="set")&&this.tsTokenCanFollowModifier())t.kind=t.key.name,this.parsePropertyName(t);return this.tsParsePropertyOrMethodSignature(t,!!t.readonly)}tsParseList(t,e){let s=[];while(!this.tsIsListTerminator(t))s.push(e());return s}tsParseObjectTypeMembers(){this.expect(i.braceL);let t=this.tsParseList("TypeMembers",this.tsParseTypeMember.bind(this));return this.expect(i.braceR),t}tsParseInterfaceDeclaration(t,e={}){if(this.hasFollowingLineBreak())return null;if(this.expectContextual("interface"),e.declare)t.declare=!0;if(w(this.type)){t.id=this.parseIdent(),this.checkLValSimple(t.id,N.BIND_TS_INTERFACE);let a=this.currentScope();this.maybeExportDefined(a,t.id.name)}else t.id=null,this.raise(this.start,A.MissingInterfaceName);if(t.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this)),this.eat(i._extends))t.extends=this.tsParseHeritageClause("extends");let s=this.startNode();return s.body=this.tsParseInterfaceBody(),t.body=this.finishNode(s,"TSInterfaceBody"),this.finishNode(t,"TSInterfaceDeclaration")}tsParseInterfaceBody(){this.expect(i.braceL);let t=this.inType;this.inType=!0;let e=this.tsParseList("TypeMembers",this.tsParseTypeMember.bind(this));return this.inType=t,this.expect(i.braceR),e}tsParseAbstractDeclaration(t){if(this.match(i._class))return t.abstract=!0,this.parseClass(t,!0);else if(this.ts_isContextual(y.interface)){if(!this.hasFollowingLineBreak())return t.abstract=!0,this.tsParseInterfaceDeclaration(t)}else this.unexpected(t.start)}tsIsDeclarationStart(){return G(this.type)}tsParseExpressionStatement(t,e){switch(e.name){case"declare":{let s=this.tsTryParseDeclare(t);if(s)return s.declare=!0,s;break}case"global":if(this.match(i.braceL)){this.enterScope(J);let s=t;return s.global=!0,s.id=e,s.body=this.tsParseModuleBlock(),super.exitScope(),this.finishNode(s,"TSModuleDeclaration")}break;default:return this.tsParseDeclaration(t,e.name,!1)}}tsParseModuleReference(){return this.tsIsExternalModuleReference()?this.tsParseExternalModuleReference():this.tsParseEntityName(!1)}tsIsExportDefaultSpecifier(){let{type:t}=this,e=this.isAsyncFunction(),s=this.isLet();if(w(t)){if(e&&!this.containsEsc||s)return!1;if((t===y.type||t===y.interface)&&!this.containsEsc){let l=this.lookahead();if(w(l.type)&&!this.isContextualWithState("from",l)||l.type===i.braceL)return!1}}else if(!this.match(i._default))return!1;let a=this.nextTokenStart(),h=this.isUnparsedContextual(a,"from");if(this.input.charCodeAt(a)===44||w(this.type)&&h)return!0;if(this.match(i._default)&&h){let l=this.input.charCodeAt(this.nextTokenStartSince(a+4));return l===34||l===39}return!1}tsInAmbientContext(t){let e=this.isAmbientContext;this.isAmbientContext=!0;try{return t()}finally{this.isAmbientContext=e}}tsCheckLineTerminator(t){if(t){if(this.hasFollowingLineBreak())return!1;return this.next(),!0}return!this.isLineTerminator()}tsParseModuleOrNamespaceDeclaration(t,e=!1){if(t.id=this.parseIdent(),!e)this.checkLValSimple(t.id,N.BIND_TS_NAMESPACE);if(this.eat(i.dot)){let s=this.startNode();this.tsParseModuleOrNamespaceDeclaration(s,!0),t.body=s}else this.enterScope(J),t.body=this.tsParseModuleBlock(),super.exitScope();return this.finishNode(t,"TSModuleDeclaration")}checkLValSimple(t,e=N.BIND_NONE,s){while(t.type==="TSNonNullExpression"||t.type==="TSAsExpression"||t.type==="TSSatisfiesExpression"||t.type==="TSTypeAssertion")t=t.expression;return super.checkLValSimple(t,e,s)}isSimpleAssignTarget(t){while(t.type==="TSNonNullExpression"||t.type==="TSAsExpression"||t.type==="TSSatisfiesExpression"||t.type==="TSTypeAssertion")t=t.expression;return super.isSimpleAssignTarget(t)}tsParseTypeAliasDeclaration(t){t.id=this.parseIdent(),this.checkLValSimple(t.id,N.BIND_TS_TYPE);let e=this.currentScope();return this.maybeExportDefined(e,t.id.name),t.typeAnnotation=this.tsInType(()=>{if(t.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutModifiers.bind(this)),this.expect(i.eq),this.ts_isContextual(y.interface)&&this.lookahead().type!==i.dot){let s=this.startNode();return this.next(),this.finishNode(s,"TSIntrinsicKeyword")}return this.tsParseType()}),this.semicolon(),this.finishNode(t,"TSTypeAliasDeclaration")}tsParseDeclaration(t,e,s){switch(e){case"abstract":if(this.tsCheckLineTerminator(s)&&(this.match(i._class)||w(this.type)))return this.tsParseAbstractDeclaration(t);break;case"module":if(this.tsCheckLineTerminator(s)){if(this.match(i.string))return this.tsParseAmbientExternalModuleDeclaration(t);else if(w(this.type))return this.tsParseModuleOrNamespaceDeclaration(t)}break;case"namespace":if(this.tsCheckLineTerminator(s)&&w(this.type))return this.tsParseModuleOrNamespaceDeclaration(t);break;case"type":if(this.tsCheckLineTerminator(s)&&w(this.type))return this.tsParseTypeAliasDeclaration(t);break}}tsTryParseExportDeclaration(){return this.tsParseDeclaration(this.startNode(),this.value,!0)}tsParseImportEqualsDeclaration(t,e){t.isExport=e||!1,t.id=this.parseIdent(),this.checkLValSimple(t.id,N.BIND_LEXICAL),super.expect(i.eq);let s=this.tsParseModuleReference();if(t.importKind==="type"&&s.type!=="TSExternalModuleReference")this.raise(s.start,A.ImportAliasHasImportType);return t.moduleReference=s,super.semicolon(),this.finishNode(t,"TSImportEqualsDeclaration")}isExportDefaultSpecifier(){if(this.tsIsDeclarationStart())return!1;let{type:t}=this;if(w(t)){if(this.isContextual("async")||this.isContextual("let"))return!1;if((t===y.type||t===y.interface)&&!this.containsEsc){let a=this.lookahead();if(w(a.type)&&!this.isContextualWithState("from",a)||a.type===i.braceL)return!1}}else if(!this.match(i._default))return!1;let e=this.nextTokenStart(),s=this.isUnparsedContextual(e,"from");if(this.input.charCodeAt(e)===44||w(this.type)&&s)return!0;if(this.match(i._default)&&s){let a=this.input.charCodeAt(this.nextTokenStartSince(e+4));return a===34||a===39}return!1}parseTemplate({isTagged:t=!1}={}){let e=this.startNode();this.next(),e.expressions=[];let s=this.parseTemplateElement({isTagged:t});e.quasis=[s];while(!s.tail){if(this.type===i.eof)this.raise(this.pos,"Unterminated template literal");this.expect(i.dollarBraceL),e.expressions.push(this.inType?this.tsParseType():this.parseExpression()),this.expect(i.braceR),e.quasis.push(s=this.parseTemplateElement({isTagged:t}))}return this.next(),this.finishNode(e,"TemplateLiteral")}parseFunction(t,e,s,a,h){if(this.initFunction(t),this.ecmaVersion>=9||this.ecmaVersion>=6&&!a){if(this.type===i.star&&e&bt)this.unexpected();t.generator=this.eat(i.star)}if(this.ecmaVersion>=8)t.async=!!a;if(e&tt)t.id=e&ue&&this.type!==i.name?null:this.parseIdent();let l=this.yieldPos,u=this.awaitPos,x=this.awaitIdentPos,T=this.maybeInArrowParameters;if(this.maybeInArrowParameters=!1,this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(lt(t.async,t.generator)),!(e&tt))t.id=this.type===i.name?this.parseIdent():null;this.parseFunctionParams(t);let d=e&tt;if(this.parseFunctionBody(t,s,!1,h,{isFunctionDeclaration:d}),d&&this.isAmbientContext&&t.id){if(this.currentScope().flags&N.SCOPE_TOP)this.declareName(t.id.name,N.BIND_FLAGS_TS_EXPORT_ONLY,t.id.start)}if(this.yieldPos=l,this.awaitPos=u,this.awaitIdentPos=x,e&tt&&t.id&&!(e&bt))if(t.body)this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?N.BIND_VAR:N.BIND_LEXICAL:N.BIND_FUNCTION);else this.checkLValSimple(t.id,N.BIND_NONE);return this.maybeInArrowParameters=T,this.finishNode(t,d?"FunctionDeclaration":"FunctionExpression")}parseFunctionBody(t,e=!1,s=!1,a=!1,h){if(this.match(i.colon))t.returnType=this.tsParseTypeOrTypePredicateAnnotation(i.colon);let l=h?.isFunctionDeclaration?"TSDeclareFunction":h?.isClassMethod?"TSDeclareMethod":void 0;if(l&&!this.match(i.braceL)&&this.isLineTerminator())return this.exitScope(),this.finishNode(t,l);if(l==="TSDeclareFunction"&&this.isAmbientContext){if(this.raise(t.start,A.DeclareFunctionHasImplementation),t.declare)return super.parseFunctionBody(t,e,s,!1),this.finishNode(t,l)}return super.parseFunctionBody(t,e,s,a),t}parseNew(){if(this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword new");let t=this.startNode(),e=this.parseIdent(!0);if(this.ecmaVersion>=6&&this.eat(i.dot)){t.meta=e;let u=this.containsEsc;if(t.property=this.parseIdent(!0),t.property.name!=="target")this.raiseRecoverable(t.property.start,"The only valid meta property for new is 'new.target'");if(u)this.raiseRecoverable(t.start,"'new.target' must not contain escaped characters");if(!this.allowNewDotTarget)this.raiseRecoverable(t.start,"'new.target' can only be used in functions and class static block");return this.finishNode(t,"MetaProperty")}let s=this.start,a=this.startLoc,h=this.type===i._import;if(t.callee=this.parseSubscripts(this.parseExprAtom(),s,a,!0,!1),h&&t.callee.type==="ImportExpression")this.raise(s,"Cannot use new with import()");let{callee:l}=t;if(l.type==="TSInstantiationExpression"&&!l.extra?.parenthesized)t.typeArguments=l.typeArguments,t.callee=l.expression;if(this.eat(i.parenL))t.arguments=this.parseExprList(i.parenR,this.ecmaVersion>=8,!1);else t.arguments=[];return this.finishNode(t,"NewExpression")}parseExprOp(t,e,s,a,h){if(i._in.binop>a&&!this.hasPrecedingLineBreak()){let l;if(this.isContextual("as"))l="TSAsExpression";if(this.isContextual("satisfies"))l="TSSatisfiesExpression";if(l){let u=this.startNodeAt(e,s);u.expression=t;let x=this.tsTryNextParseConstantContext();if(x)u.typeAnnotation=x;else u.typeAnnotation=this.tsNextThenParseType();return this.finishNode(u,l),this.reScan_lt_gt(),this.parseExprOp(u,e,s,a,h)}}return super.parseExprOp(t,e,s,a,h)}parseImportSpecifiers(){let t=[],e=!0;if(E.tokenIsIdentifier(this.type)){if(t.push(this.parseImportDefaultSpecifier()),!this.eat(i.comma))return t}if(this.type===i.star)return t.push(this.parseImportNamespaceSpecifier()),t;this.expect(i.braceL);while(!this.eat(i.braceR)){if(!e){if(this.expect(i.comma),this.afterTrailingComma(i.braceR))break}else e=!1;t.push(this.parseImportSpecifier())}return t}parseImport(t){let e=this.lookahead();if(t.importKind="value",this.importOrExportOuterKind="value",w(e.type)||this.match(i.star)||this.match(i.braceL)){let s=this.lookahead(2);if(s.type!==i.comma&&!this.isContextualWithState("from",s)&&s.type!==i.eq&&this.ts_eatContextualWithState("type",1,e))this.importOrExportOuterKind="type",t.importKind="type",e=this.lookahead(),s=this.lookahead(2);if(w(e.type)&&s.type===i.eq){this.next();let a=this.tsParseImportEqualsDeclaration(t);return this.importOrExportOuterKind="value",a}}if(this.next(),this.type===i.string)t.specifiers=[],t.source=this.parseExprAtom();else t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.type===i.string?this.parseExprAtom():this.unexpected();if(this.parseMaybeImportAttributes(t),this.semicolon(),this.finishNode(t,"ImportDeclaration"),this.importOrExportOuterKind="value",t.importKind==="type"&&t.specifiers.length>1&&t.specifiers[0].type==="ImportDefaultSpecifier")this.raise(t.start,A.TypeImportCannotSpecifyDefaultAndNamed);return t}parseExportDefaultDeclaration(){if(this.isAbstractClass()){let t=this.startNode();return this.next(),t.abstract=!0,this.parseClass(t,!0)}if(this.match(y.interface)){let t=this.tsParseInterfaceDeclaration(this.startNode());if(t)return t}return super.parseExportDefaultDeclaration()}parseExportAllDeclaration(t,e){if(this.ecmaVersion>=11)if(this.eatContextual("as"))t.exported=this.parseModuleExportName(),this.checkExport(e,t.exported,this.lastTokStart);else t.exported=null;if(this.expectContextual("from"),this.type!==i.string)this.unexpected();return t.source=this.parseExprAtom(),this.parseMaybeImportAttributes(t),this.semicolon(),this.finishNode(t,"ExportAllDeclaration")}parseDynamicImport(t){if(this.next(),t.source=this.parseMaybeAssign(),this.eat(i.comma)){let e=this.parseExpression();t.arguments=[e]}if(!this.eat(i.parenR)){let e=this.start;if(this.eat(i.comma)&&this.eat(i.parenR))this.raiseRecoverable(e,"Trailing comma is not allowed in import()");else this.unexpected(e)}return this.finishNode(t,"ImportExpression")}parseExport(t,e){let s=this.lookahead();if(this.ts_eatWithState(i._import,2,s)){if(this.ts_isContextual(y.type)&&this.lookaheadCharCode()!==61)t.importKind="type",this.importOrExportOuterKind="type",this.next();else t.importKind="value",this.importOrExportOuterKind="value";let a=this.tsParseImportEqualsDeclaration(t,!0);return this.importOrExportOuterKind=void 0,a}else if(this.ts_eatWithState(i.eq,2,s)){let a=t;return a.expression=this.parseExpression(),this.semicolon(),this.importOrExportOuterKind=void 0,this.finishNode(a,"TSExportAssignment")}else if(this.ts_eatContextualWithState("as",2,s)){let a=t;return this.expectContextual("namespace"),a.id=this.parseIdent(),this.semicolon(),this.importOrExportOuterKind=void 0,this.finishNode(a,"TSNamespaceExportDeclaration")}else{let a=this.lookahead(2).type;if(this.ts_isContextualWithState(s,y.type)&&(a===i.braceL||a===i.star))this.next(),this.importOrExportOuterKind="type",t.exportKind="type";else this.importOrExportOuterKind="value",t.exportKind="value";if(this.next(),this.eat(i.star))return this.parseExportAllDeclaration(t,e);if(this.eat(i._default))return this.checkExport(e,"default",this.lastTokStart),t.declaration=this.parseExportDefaultDeclaration(),this.finishNode(t,"ExportDefaultDeclaration");if(this.shouldParseExportStatement()){if(t.declaration=this.parseExportDeclaration(t),t.declaration.type==="VariableDeclaration")this.checkVariableExport(e,t.declaration.declarations);else this.checkExport(e,t.declaration.id,t.declaration.id.start);t.specifiers=[],t.source=null}else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from")){if(this.type!==i.string)this.unexpected();t.source=this.parseExprAtom(),this.parseMaybeImportAttributes(t)}else{for(let h of t.specifiers)if(this.checkUnreserved(h.local),this.checkLocalExport(h.local),h.local.type==="Literal")this.raise(h.local.start,"A string literal cannot be used as an exported binding without `from`.");t.source=null}this.semicolon()}return this.finishNode(t,"ExportNamedDeclaration")}}checkExport(t,e,s){if(!t)return;if(typeof e!=="string")e=e.type==="Identifier"?e.name:e.value;t[e]=!0}parseMaybeDefault(t,e,s){let a=super.parseMaybeDefault(t,e,s);if(a.type==="AssignmentPattern"&&a.typeAnnotation&&a.right.start<a.typeAnnotation.start)this.raise(a.typeAnnotation.start,A.TypeAnnotationAfterAssign);return a}typeCastToParameter(t){return t.expression.typeAnnotation=t.typeAnnotation,this.resetEndLocation(t.expression,t.typeAnnotation.end,t.typeAnnotation.loc?.end),t.expression}toAssignableList(t,e){if(!t)t=[];for(let s=0;s<t.length;s++){let a=t[s];if(a?.type==="TSTypeCastExpression")t[s]=this.typeCastToParameter(a)}return super.toAssignableList(t,e)}reportReservedArrowTypeParam(t){if(t.params.length===1&&!t.extra?.trailingComma&&c)this.raise(t.start,A.ReservedArrowTypeParam)}parseExprAtom(t,e,s){if(this.type===y.jsxText)return this.jsx_parseText();else if(this.type===y.jsxTagStart)return this.jsx_parseElement();else if(this.type===y.at)return this.parseDecorators(),this.parseExprAtom();else if(w(this.type)){let a=this.potentialArrowAt===this.start,h=this.start,l=this.startLoc,u=this.containsEsc,x=this.parseIdent(!1);if(this.ecmaVersion>=8&&!u&&x.name==="async"&&!this.canInsertSemicolon()&&this.eat(i._function))return this.overrideContext(S.f_expr),this.parseFunction(this.startNodeAt(h,l),0,!1,!0,e);if(a&&!this.canInsertSemicolon()){if(this.eat(i.arrow))return this.parseArrowExpression(this.startNodeAt(h,l),[x],!1,e);if(this.ecmaVersion>=8&&x.name==="async"&&this.type===i.name&&!u&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc)){if(x=this.parseIdent(!1),this.canInsertSemicolon()||!this.eat(i.arrow))this.unexpected();return this.parseArrowExpression(this.startNodeAt(h,l),[x],!0,e)}}return x}else return super.parseExprAtom(t,e,s)}parseExprAtomDefault(){if(w(this.type)){let t=this.potentialArrowAt===this.start,e=this.containsEsc,s=this.parseIdent();if(!e&&s.name==="async"&&!this.canInsertSemicolon()){let{type:a}=this;if(a===i._function)return this.next(),this.parseFunction(this.startNodeAtNode(s),void 0,!0,!0);else if(w(a))if(this.lookaheadCharCode()===61){let h=this.parseIdent(!1);if(this.canInsertSemicolon()||!this.eat(i.arrow))this.unexpected();return this.parseArrowExpression(this.startNodeAtNode(s),[h],!0)}else return s}if(t&&this.match(i.arrow)&&!this.canInsertSemicolon())return this.next(),this.parseArrowExpression(this.startNodeAtNode(s),[s],!1);return s}else this.unexpected()}parseIdentNode(){let t=this.startNode();if(V(this.type)&&!((this.type.keyword==="class"||this.type.keyword==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)))t.name=this.value;else return super.parseIdentNode();return t}parseVarStatement(t,e,s=!1){let{isAmbientContext:a}=this;this.next(),super.parseVar(t,!1,e,s||a),this.semicolon();let h=this.finishNode(t,"VariableDeclaration");if(!a)return h;for(let{id:l,init:u}of h.declarations){if(!u)continue;if(e!=="const"||!!l.typeAnnotation)this.raise(u.start,A.InitializerNotAllowedInAmbientContext);else if(u.type!=="Literal"&&(u.type!=="TemplateLiteral"||u.expressions.length>0)&&!fe(u)&&!de(u))this.raise(u.start,A.ConstInitiailizerMustBeStringOrNumericLiteralOrLiteralEnumReference)}return h}parseStatement(t,e,s){if(this.match(y.at))this.parseDecorators(!0);if(this.match(i._const)&&this.isLookaheadContextual("enum")){let a=this.startNode();return this.expect(i._const),this.tsParseEnumDeclaration(a,{const:!0})}if(this.ts_isContextual(y.enum))return this.tsParseEnumDeclaration(this.startNode());if(this.ts_isContextual(y.interface)){let a=this.tsParseInterfaceDeclaration(this.startNode());if(a)return a}return super.parseStatement(t,e,s)}parseAccessModifier(){return this.tsParseModifier(["public","protected","private"])}parsePostMemberNameModifiers(t){if(this.eat(i.question))t.optional=!0;if(t.readonly&&this.match(i.parenL))this.raise(t.start,A.ClassMethodHasReadonly);if(t.declare&&this.match(i.parenL))this.raise(t.start,A.ClassMethodHasDeclare)}parseExpressionStatement(t,e){return(e.type==="Identifier"?this.tsParseExpressionStatement(t,e):void 0)||super.parseExpressionStatement(t,e)}shouldParseExportStatement(){if(this.tsIsDeclarationStart())return!0;if(this.match(y.at))return!0;return super.shouldParseExportStatement()}parseConditional(t,e,s,a,h){if(this.eat(i.question)){let l=this.startNodeAt(e,s);return l.test=t,l.consequent=this.parseMaybeAssign(),this.expect(i.colon),l.alternate=this.parseMaybeAssign(a),this.finishNode(l,"ConditionalExpression")}return t}parseMaybeConditional(t,e){let s=this.start,a=this.startLoc,h=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return h;if(!this.maybeInArrowParameters||!this.match(i.question))return this.parseConditional(h,s,a,t,e);let l=this.tryParse(()=>this.parseConditional(h,s,a,t,e));if(!l.node){if(l.error)this.setOptionalParametersError(e,l.error);return h}return l.node}parseParenItem(t){let e=this.start,s=this.startLoc;if(t=super.parseParenItem(t),this.eat(i.question))t.optional=!0,this.resetEndLocation(t);if(this.match(i.colon)){let a=this.startNodeAt(e,s);return a.expression=t,a.typeAnnotation=this.tsParseTypeAnnotation(),this.finishNode(a,"TSTypeCastExpression")}return t}parseExportDeclaration(t){if(!this.isAmbientContext&&this.ts_isContextual(y.declare))return this.tsInAmbientContext(()=>this.parseExportDeclaration(t));let e=this.start,s=this.startLoc,a=this.eatContextual("declare");if(a&&(this.ts_isContextual(y.declare)||!this.shouldParseExportStatement()))this.raise(this.start,A.ExpectedAmbientAfterExportDeclare);let l=w(this.type)&&this.tsTryParseExportDeclaration()||this.parseStatement(null);if(!l)return null;if(l.type==="TSInterfaceDeclaration"||l.type==="TSTypeAliasDeclaration"||a)t.exportKind="type";if(a)this.resetStartLocation(l,e,s),l.declare=!0;return l}parseClassId(t,e){if(!e&&this.isContextual("implements"))return;super.parseClassId(t,e);let s=this.tsTryParseTypeParameters(this.tsParseClassTypeParameterModifiers.bind(this));if(s)t.typeParameters=s}parseClassPropertyAnnotation(t){if(!t.optional){if(this.value==="!"&&this.eat(i.prefix))t.definite=!0;else if(this.eat(i.question))t.optional=!0}let e=this.tsTryParseTypeAnnotation();if(e)t.typeAnnotation=e}parseClassField(t){if(t.key.type==="PrivateIdentifier"){if(t.abstract)this.raise(t.start,A.PrivateElementHasAbstract);if(t.accessibility)this.raise(t.start,A.PrivateElementHasAccessibility({modifier:t.accessibility}));this.parseClassPropertyAnnotation(t)}else{if(this.parseClassPropertyAnnotation(t),this.isAmbientContext&&!(t.readonly&&!t.typeAnnotation)&&this.match(i.eq))this.raise(this.start,A.DeclareClassFieldHasInitializer);if(t.abstract&&this.match(i.eq)){let{key:s}=t;this.raise(this.start,A.AbstractPropertyHasInitializer({propertyName:s.type==="Identifier"&&!t.computed?s.name:`[${this.input.slice(s.start,s.end)}]`}))}}return super.parseClassField(t)}parseClassMethod(t,e,s,a){let h=t.kind==="constructor",l=t.key.type==="PrivateIdentifier",u=this.tsTryParseTypeParameters(this.tsParseConstModifier);if(l){if(u)t.typeParameters=u;if(t.accessibility)this.raise(t.start,A.PrivateMethodsHasAccessibility({modifier:t.accessibility}))}else if(u&&h)this.raise(u.start,A.ConstructorHasTypeParameters);let{declare:x=!1,kind:T}=t;if(x&&(T==="get"||T==="set"))this.raise(t.start,A.DeclareAccessor({kind:T}));if(u)t.typeParameters=u;let d=t.key;if(t.kind==="constructor"){if(e)this.raise(d.start,"Constructor can't be a generator");if(s)this.raise(d.start,"Constructor can't be an async method")}else if(t.static&&At(t,"prototype"))this.raise(d.start,"Classes may not have a static property named prototype");let g=t.value=this.parseMethod(e,s,a,!0,t);if(t.kind==="get"&&g.params.length!==0)this.raiseRecoverable(g.start,"getter should have no params");if(t.kind==="set"&&g.params.length!==1)this.raiseRecoverable(g.start,"setter should have exactly one param");if(t.kind==="set"&&g.params[0].type==="RestElement")this.raiseRecoverable(g.params[0].start,"Setter cannot use rest params");return this.finishNode(t,"MethodDefinition")}isClassMethod(){return this.match(i.relational)}parseClassElement(t){if(this.eat(i.semi))return null;let e=this.startNode(),s="",a=!1,h=!1,l="method",u=!1,x=["declare","private","public","protected","accessor","override","abstract","readonly","static"],T=this.tsParseModifiers({modified:e,allowedModifiers:x,disallowedModifiers:["in","out"],stopOnStartOfClassStaticBlock:!0,errorTemplate:A.InvalidModifierOnTypeParameterPositions});u=Boolean(T.static);let d=()=>{if(this.tsIsStartOfStaticBlocks()){if(this.next(),this.next(),this.tsHasSomeModifiers(e,x))this.raise(this.start,A.StaticBlockCannotHaveModifier);if(this.ecmaVersion>=13)return super.parseClassStaticBlock(e),e}else{let g=this.tsTryParseIndexSignature(e);if(g){if(e.abstract)this.raise(e.start,A.IndexSignatureHasAbstract);if(e.accessibility)this.raise(e.start,A.IndexSignatureHasAccessibility({modifier:e.accessibility}));if(e.declare)this.raise(e.start,A.IndexSignatureHasDeclare);if(e.override)this.raise(e.start,A.IndexSignatureHasOverride);return g}if(!this.inAbstractClass&&e.abstract)this.raise(e.start,A.NonAbstractClassHasAbstractMethod);if(e.override){if(!t)this.raise(e.start,A.OverrideNotInSubClass)}if(e.static=u,u){if(!(this.isClassElementNameStart()||this.type===i.star))s="static"}if(!s&&this.ecmaVersion>=8&&this.eatContextual("async"))if((this.isClassElementNameStart()||this.type===i.star)&&!this.canInsertSemicolon())h=!0;else s="async";if(!s&&(this.ecmaVersion>=9||!h)&&this.eat(i.star))a=!0;if(!s&&!h&&!a){let v=this.value;if(this.eatContextual("get")||this.eatContextual("set"))if(this.isClassElementNameStart())l=v;else s=v}if(s)e.computed=!1,e.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),e.key.name=s,this.finishNode(e.key,"Identifier");else this.parseClassElementName(e);if(this.parsePostMemberNameModifiers(e),this.isClassMethod()||this.ecmaVersion<13||this.type===i.parenL||l!=="method"||a||h){let v=!e.static&&At(e,"constructor"),_=v&&t;if(v&&l!=="method")this.raise(e.key.start,"Constructor can't have get/set modifier");e.kind=v?"constructor":l,this.parseClassMethod(e,a,h,_)}else this.parseClassField(e);return e}};if(e.declare)this.tsInAmbientContext(d);else d();return e}isClassElementNameStart(){if(this.tsIsIdentifier())return!0;return super.isClassElementNameStart()}parseClassSuper(t){if(super.parseClassSuper(t),t.superClass&&(this.tsMatchLeftRelational()||this.match(i.bitShift)))t.superTypeParameters=this.tsParseTypeArgumentsInExpression();if(this.eatContextual("implements"))t.implements=this.tsParseHeritageClause("implements")}parseFunctionParams(t){let e=this.tsTryParseTypeParameters(this.tsParseConstModifier);if(e)t.typeParameters=e;super.parseFunctionParams(t)}parseVarId(t,e){if(super.parseVarId(t,e),t.id.type==="Identifier"&&!this.hasPrecedingLineBreak()&&this.value==="!"&&this.eat(i.prefix))t.definite=!0;let s=this.tsTryParseTypeAnnotation();if(s)t.id.typeAnnotation=s,this.resetEndLocation(t.id)}parseArrowExpression(t,e,s,a){if(this.match(i.colon))t.returnType=this.tsParseTypeAnnotation();let h=this.yieldPos,l=this.awaitPos,u=this.awaitIdentPos;this.enterScope(lt(s,!1)|N.SCOPE_ARROW),this.initFunction(t);let x=this.maybeInArrowParameters;if(this.ecmaVersion>=8)t.async=!!s;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.maybeInArrowParameters=!0,t.params=this.toAssignableList(e,!0),this.maybeInArrowParameters=!1,this.parseFunctionBody(t,!0,!1,a),this.yieldPos=h,this.awaitPos=l,this.awaitIdentPos=u,this.maybeInArrowParameters=x,this.finishNode(t,"ArrowFunctionExpression")}parseYield(t){if(!this.yieldPos)this.yieldPos=this.start;let e=this.startNode();this.next();let s=this.tsMatchLeftRelational();if(!(!this.match(i.semi)&&!this.canInsertSemicolon()&&(this.match(i.star)||this.type.startsExpr||s)))return e.delegate=!1,e.argument=null,this.finishNode(e,"YieldExpression");return e.delegate=this.eat(i.star),e.argument=this.parseMaybeAssign(t),this.finishNode(e,"YieldExpression")}parseMaybeAssignOrigin(t,e,s){if(this.isContextual("yield"))if(this.inGenerator)return this.parseYield(t);else this.exprAllowed=!1;let a=!1,h=-1,l=-1,u=-1;if(e)h=e.parenthesizedAssign,l=e.trailingComma,u=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1;else e=new Y,a=!0;let x=this.start,T=this.startLoc;if(this.type===i.parenL||w(this.type))this.potentialArrowAt=this.start,this.potentialArrowInForAwait=t==="await";let d=this.parseMaybeConditional(t,e);if(s)d=s.call(this,d,x,T);if(this.type.isAssign){let g=this.startNodeAt(x,T);if(g.operator=this.value,this.type===i.eq)d=this.toAssignable(d,!0,e,!0);if(!a)e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1;if(e.shorthandAssign>=d.start)e.shorthandAssign=-1;if(!this.maybeInArrowParameters)if(this.type===i.eq)this.checkLValPattern(d);else this.checkLValSimple(d);if(g.left=d,this.next(),g.right=this.parseMaybeAssign(t),u>-1)e.doubleProto=u;return this.finishNode(g,"AssignmentExpression")}else if(a)this.checkExpressionErrors(e,!0);if(h>-1)e.parenthesizedAssign=h;if(l>-1)e.trailingComma=l;return d}parseMaybeAssign(t,e,s){let a,h;if(r?.jsx&&(this.matchJsx("jsxTagStart")||this.tsMatchLeftRelational())){if(a=this.tryParse(()=>this.parseMaybeAssignOrigin(t,e,s)),!a.error)return a.node;let x=this.context,T=x[x.length-1],d=x[x.length-2];if(T===E.tokContexts.tc_oTag&&d===E.tokContexts.tc_expr)this.parseEffects.pop(x),this.parseEffects.pop(x);else if(T===E.tokContexts.tc_oTag||T===E.tokContexts.tc_expr)this.parseEffects.pop(x)}if(!a?.error&&!this.tsMatchLeftRelational())return this.parseMaybeAssignOrigin(t,e,s);let l,u=this.tryParse((x)=>{l=this.tsParseTypeParameters(this.tsParseConstModifier);let T=this.parseMaybeAssignOrigin(t,e,s);if(T.type!=="ArrowFunctionExpression"||T.extra?.parenthesized)x();if(l?.params.length!==0)this.resetStartLocationFromNode(T,l);return T.typeParameters=l,T});if(!u.error&&!u.aborted){if(l)this.reportReservedArrowTypeParam(l);return u.node}if(!a){if(Et(!0),h=this.tryParse(()=>this.parseMaybeAssignOrigin(t,e,s)),!h.error)return h.node}if(a?.thrown)throw this.selectTryParseResult(a),a.error;if(u.thrown)throw this.selectTryParseResult(u),u.error;if(h?.thrown)throw this.selectTryParseResult(h),h.error;throw a?.error||u.error||h?.error}parseAssignableListItem(t){let e=[];while(this.match(y.at))e.push(this.parseDecorator());let s=this.start,a=this.startLoc,h,l=!1,u=!1;if(t!==void 0){let d={};if(this.tsParseModifiers({modified:d,allowedModifiers:["public","private","protected","override","readonly"]}),h=d.accessibility,u=d.override,l=d.readonly,t===!1&&(h||l||u))this.raise(a.column,A.UnexpectedParameterModifier)}let x=this.parseMaybeDefault(s,a);this.parseBindingListItem(x);let T=this.parseMaybeDefault(x.start,x.loc.start,x);if(e.length)T.decorators=e;if(h||l||u){let d=this.startNodeAt(s,a);if(h)d.accessibility=h;if(l)d.readonly=l;if(u)d.override=u;if(T.type!=="Identifier"&&T.type!=="AssignmentPattern")this.raise(d.start,A.UnsupportedParameterPropertyKind);return d.parameter=T,this.finishNode(d,"TSParameterProperty")}return T}checkLValInnerPattern(t,e=N.BIND_NONE,s){switch(t.type){case"TSParameterProperty":this.checkLValInnerPattern(t.parameter,e,s);break;default:{super.checkLValInnerPattern(t,e,s);break}}}parseBindingListItem(t){if(this.eat(i.question)){if(t.type!=="Identifier"&&!this.isAmbientContext&&!this.inType)this.raise(t.start,A.PatternIsOptional);t.optional=!0}let e=this.tsTryParseTypeAnnotation();if(e)t.typeAnnotation=e;return this.resetEndLocation(t),t}isAssignable(t,e){switch(t.type){case"TSTypeCastExpression":return this.isAssignable(t.expression,e);case"TSParameterProperty":return!0;case"Identifier":case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":return!0;case"ObjectExpression":{let s=t.properties.length-1;return t.properties.every((a,h)=>a.type!=="ObjectMethod"&&(h===s||a.type!=="SpreadElement")&&this.isAssignable(a))}case"Property":case"ObjectProperty":return this.isAssignable(t.value);case"SpreadElement":return this.isAssignable(t.argument);case"ArrayExpression":return t.elements.every((s)=>s===null||this.isAssignable(s));case"AssignmentExpression":return t.operator==="=";case"ParenthesizedExpression":return this.isAssignable(t.expression);case"MemberExpression":case"OptionalMemberExpression":return!e;default:return!1}}toAssignable(t,e=!1,s=new Y,a=!1){switch(t.type){case"ParenthesizedExpression":return this.toAssignableParenthesizedExpression(t,e,s,a);case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":if(e);else this.raise(t.start,A.UnexpectedTypeCastInParameter);let h=this.toAssignable(t.expression,e,s,a);if(a)return t.expression=h,t;return h;case"MemberExpression":break;case"AssignmentExpression":if(!e&&t.left.type==="TSTypeCastExpression")t.left=this.typeCastToParameter(t.left);return super.toAssignable(t,e,s);case"TSTypeCastExpression":return this.typeCastToParameter(t);default:return super.toAssignable(t,e,s)}return t}toAssignableParenthesizedExpression(t,e,s,a=!1){switch(t.expression.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"ParenthesizedExpression":let h=this.toAssignable(t.expression,e,s,a);if(a)return t.expression=h,t;return h;default:return super.toAssignable(t,e,s)}}parseBindingAtom(){switch(this.type){case i._this:return this.parseIdent(!0);default:return super.parseBindingAtom()}}shouldParseArrow(t){let e;if(this.match(i.colon))e=t.every((s)=>this.isAssignable(s,!0));else e=!this.canInsertSemicolon();if(e){if(this.match(i.colon)){let s=this.tryParse((a)=>{let h=this.tsParseTypeOrTypePredicateAnnotation(i.colon);if(this.canInsertSemicolon()||!this.match(i.arrow))a();return h});if(s.aborted)return this.shouldParseArrowReturnType=void 0,!1;if(!s.thrown)this.shouldParseArrowReturnType=s.node}if(!this.match(i.arrow))return this.shouldParseArrowReturnType=void 0,!1;return!0}return this.shouldParseArrowReturnType=void 0,e}parseParenArrowList(t,e,s,a){let h=this.startNodeAt(t,e);return h.returnType=this.shouldParseArrowReturnType,this.shouldParseArrowReturnType=void 0,this.parseArrowExpression(h,s,!1,a)}parseParenAndDistinguishExpression(t,e){let s=this.start,a=this.startLoc,h,l=this.ecmaVersion>=8;if(this.ecmaVersion>=6){let u=this.maybeInArrowParameters;this.maybeInArrowParameters=!0,this.next();let x=this.start,T=this.startLoc,d=[],g=!0,v=!1,_=new Y,j=this.yieldPos,U=this.awaitPos,K;this.yieldPos=0,this.awaitPos=0;while(this.type!==i.parenR)if(g?g=!1:this.expect(i.comma),l&&this.afterTrailingComma(i.parenR,!0)){v=!0;break}else if(this.type===i.ellipsis){if(K=this.start,d.push(this.parseParenItem(this.parseRestBinding())),this.type===i.comma)this.raise(this.start,"Comma is not permitted after the rest element");break}else d.push(this.parseMaybeAssign(!1,_,this.parseParenItem));let q=this.lastTokEnd,R=this.lastTokEndLoc;if(this.expect(i.parenR),this.maybeInArrowParameters=u,t&&this.shouldParseArrow(d)&&this.eat(i.arrow))return this.checkPatternErrors(_,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=j,this.awaitPos=U,this.parseParenArrowList(s,a,d,e);if(!d.length||v)this.unexpected(this.lastTokStart);if(K)this.unexpected(K);if(this.checkExpressionErrors(_,!0),this.yieldPos=j||this.yieldPos,this.awaitPos=U||this.awaitPos,d.length>1)h=this.startNodeAt(x,T),h.expressions=d,this.finishNodeAt(h,"SequenceExpression",q,R);else h=d[0]}else h=this.parseParenExpression();if(this.options.preserveParens){let u=this.startNodeAt(s,a);return u.expression=h,this.finishNode(u,"ParenthesizedExpression")}else return h}parseTaggedTemplateExpression(t,e,s,a){let h=this.startNodeAt(e,s);if(h.tag=t,h.quasi=this.parseTemplate({isTagged:!0}),a)this.raise(e,"Tagged Template Literals are not allowed in optionalChain.");return this.finishNode(h,"TaggedTemplateExpression")}shouldParseAsyncArrow(){if(this.match(i.colon)){let t=this.tryParse((e)=>{let s=this.tsParseTypeOrTypePredicateAnnotation(i.colon);if(this.canInsertSemicolon()||!this.match(i.arrow))e();return s});if(t.aborted)return this.shouldParseAsyncArrowReturnType=void 0,!1;if(!t.thrown)return this.shouldParseAsyncArrowReturnType=t.node,!this.canInsertSemicolon()&&this.eat(i.arrow)}else return!this.canInsertSemicolon()&&this.eat(i.arrow)}parseSubscriptAsyncArrow(t,e,s,a){let h=this.startNodeAt(t,e);return h.returnType=this.shouldParseAsyncArrowReturnType,this.shouldParseAsyncArrowReturnType=void 0,this.parseArrowExpression(h,s,!0,a)}parseExprList(t,e,s,a){let h=[],l=!0;while(!this.eat(t)){if(!l){if(this.expect(i.comma),e&&this.afterTrailingComma(t))break}else l=!1;let u;if(s&&this.type===i.comma)u=null;else if(this.type===i.ellipsis){if(u=this.parseSpread(a),this.maybeInArrowParameters&&this.match(i.colon))u.typeAnnotation=this.tsParseTypeAnnotation();if(a&&this.type===i.comma&&a.trailingComma<0)a.trailingComma=this.start}else u=this.parseMaybeAssign(!1,a,this.parseParenItem);h.push(u)}return h}parseMaybeDecoratorArguments(t){let e=this.tsMatchLeftRelational()||this.match(i.bitShift)?this.tsParseTypeArgumentsInExpression():void 0;if(this.eat(i.parenL)){let s=this.startNodeAtNode(t);if(s.callee=t,s.arguments=this.parseExprList(i.parenR,!1),e)s.typeArguments=e;return this.finishNode(s,"CallExpression")}if(e){let s=this.startNodeAtNode(t);return s.expression=t,s.typeArguments=e,this.finishNode(s,"TSInstantiationExpression")}return t}parseSubscript(t,e,s,a,h,l,u){let x=l;if(!this.hasPrecedingLineBreak()&&this.value==="!"&&this.match(i.prefix)){this.exprAllowed=!1,this.next();let _=this.startNodeAt(e,s);return _.expression=t,t=this.finishNode(_,"TSNonNullExpression"),t}let T=!1;if(this.match(i.questionDot)&&this.lookaheadCharCode()===60){if(a)return t;t.optional=!0,x=T=!0,this.next()}if(this.tsMatchLeftRelational()||this.match(i.bitShift)){let _,j=this.tsTryParseAndCatch(()=>{if(!a&&this.atPossibleAsyncArrow(t)){let R=this.tsTryParseGenericAsyncArrowFunction(e,s,u);if(R)return t=R,t}let U=this.tsParseTypeArgumentsInExpression();if(!U)return t;if(T&&!this.match(i.parenL))return _=this.curPosition(),t;if(z(this.type)||this.type===i.backQuote){let R=this.parseTaggedTemplateExpression(t,e,s,x);return R.typeArguments=U,R}if(!a&&this.eat(i.parenL)){let R=new Y,F=this.startNodeAt(e,s);if(F.callee=t,F.arguments=this.parseExprList(i.parenR,this.ecmaVersion>=8,!1,R),this.tsCheckForInvalidTypeCasts(F.arguments),F.typeArguments=U,x)F.optional=T;return this.checkExpressionErrors(R,!0),t=this.finishNode(F,"CallExpression"),t}let K=this.type;if(this.tsMatchRightRelational()||K===i.bitShift||K!==i.parenL&&me(K)&&!this.hasPrecedingLineBreak())return;let q=this.startNodeAt(e,s);return q.expression=t,q.typeArguments=U,this.finishNode(q,"TSInstantiationExpression")});if(_)this.unexpected(_);if(j){if(j.type==="TSInstantiationExpression"&&(this.match(i.dot)||this.match(i.questionDot)&&this.lookaheadCharCode()!==40))this.raise(this.start,A.InvalidPropertyAccessAfterInstantiationExpression);return t=j,t}}let d=this.ecmaVersion>=11,g=d&&this.eat(i.questionDot);if(a&&g)this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");let v=this.eat(i.bracketL);if(v||g&&this.type!==i.parenL&&this.type!==i.backQuote||this.eat(i.dot)){let _=this.startNodeAt(e,s);if(_.object=t,v)_.property=this.parseExpression(),this.expect(i.bracketR);else if(this.type===i.privateId&&t.type!=="Super")_.property=this.parsePrivateIdent();else _.property=this.parseIdent(this.options.allowReserved!=="never");if(_.computed=!!v,d)_.optional=g;t=this.finishNode(_,"MemberExpression")}else if(!a&&this.eat(i.parenL)){let _=this.maybeInArrowParameters;this.maybeInArrowParameters=!0;let j=new Y,U=this.yieldPos,K=this.awaitPos,q=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;let R=this.parseExprList(i.parenR,this.ecmaVersion>=8,!1,j);if(h&&!g&&this.shouldParseAsyncArrow()){if(this.checkPatternErrors(j,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0)this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function");this.yieldPos=U,this.awaitPos=K,this.awaitIdentPos=q,t=this.parseSubscriptAsyncArrow(e,s,R,u)}else{this.checkExpressionErrors(j,!0),this.yieldPos=U||this.yieldPos,this.awaitPos=K||this.awaitPos,this.awaitIdentPos=q||this.awaitIdentPos;let F=this.startNodeAt(e,s);if(F.callee=t,F.arguments=R,d)F.optional=g;t=this.finishNode(F,"CallExpression")}this.maybeInArrowParameters=_}else if(this.type===i.backQuote){if(g||x)this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");let _=this.startNodeAt(e,s);_.tag=t,_.quasi=this.parseTemplate({isTagged:!0}),t=this.finishNode(_,"TaggedTemplateExpression")}return t}parseGetterSetter(t){t.kind=t.key.name,this.parsePropertyName(t);let e=this.tsTryParseTypeParameters(this.tsParseConstModifier);if(t.value=this.parseMethod(!1),e)t.value.typeParameters=e;let s=t.kind==="get"?0:1,a=t.value.params[0];if(s=a&&this.isThisParam(a)?s+1:s,t.value.params.length!==s){let l=t.value.start;if(t.kind==="get")this.raiseRecoverable(l,"getter should have no params");else this.raiseRecoverable(l,"setter should have exactly one param")}else if(t.kind==="set"&&t.value.params[0].type==="RestElement")this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")}parsePropertyValue(t,e,s,a,h,l,u,x){if(this.tsMatchLeftRelational()){if(e)this.unexpected();t.kind="init",t.method=!0;let T=this.tsTryParseTypeParameters(this.tsParseConstModifier);if(t.value=this.parseMethod(s,a),T)t.value.typeParameters=T;return}return super.parsePropertyValue(t,e,s,a,h,l,u,x)}parseProperty(t,e){if(!t){let s=[];if(this.match(y.at))while(this.match(y.at))s.push(this.parseDecorator());let a=super.parseProperty(t,e);if(a.type==="SpreadElement"){if(s.length)this.raise(a.start,et.SpreadElementDecorator)}if(s.length)a.decorators=s,s=[];return a}return super.parseProperty(t,e)}parseCatchClauseParam(){let t=this.parseBindingAtom(),e=t.type==="Identifier";this.enterScope(e?N.SCOPE_SIMPLE_CATCH:0),this.checkLValPattern(t,e?N.BIND_SIMPLE_CATCH:N.BIND_LEXICAL);let s=this.tsTryParseTypeAnnotation();if(s)t.typeAnnotation=s,this.resetEndLocation(t);return this.expect(i.parenR),t}parseClass(t,e){let s=this.inAbstractClass;this.inAbstractClass=!!t.abstract;try{this.next(),this.takeDecorators(t);let a=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);let h=this.enterClassBody(),l=this.startNode(),u=!1;l.body=[];let x=[];this.expect(i.braceL);while(this.type!==i.braceR){if(this.match(y.at)){x.push(this.parseDecorator());continue}let T=this.parseClassElement(t.superClass!==null);if(x.length)T.decorators=x,this.resetStartLocationFromNode(T,x[0]),x=[];if(T){if(l.body.push(T),T.type==="MethodDefinition"&&T.kind==="constructor"&&T.value.type==="FunctionExpression"){if(u)this.raiseRecoverable(T.start,"Duplicate constructor in the same class");if(u=!0,T.decorators&&T.decorators.length>0)this.raise(T.start,et.DecoratorConstructor)}else if(T.key&&T.key.type==="PrivateIdentifier"&&T.value?.type!=="TSDeclareMethod"){let d=T.key.name;if(this.parseEffects.modify(h,d,(v)=>Qt(v,T)))this.raiseRecoverable(T.key.start,`Identifier '#${d}' has already been declared`)}}}if(this.strict=a,this.next(),x.length)this.raise(this.start,et.TrailingDecorator);return t.body=this.finishNode(l,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")}finally{this.inAbstractClass=s}}parseClassFunctionParams(){let t=this.tsTryParseTypeParameters(),e=this.parseBindingList(i.parenR,!1,this.ecmaVersion>=8,!0);if(t)e.typeParameters=t;return e}parseMethod(t,e,s,a,h){let l=this.startNode(),u=this.yieldPos,x=this.awaitPos,T=this.awaitIdentPos;if(this.initFunction(l),this.ecmaVersion>=6)l.generator=t;if(this.ecmaVersion>=8)l.async=!!e;if(this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(lt(e,l.generator)|N.SCOPE_SUPER|(s?N.SCOPE_DIRECT_SUPER:0)),this.expect(i.parenL),l.params=this.parseClassFunctionParams(),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(l,!1,!0,!1,{isClassMethod:a}),this.yieldPos=u,this.awaitPos=x,this.awaitIdentPos=T,h&&h.abstract){if(!!l.body){let{key:g}=h;this.raise(h.start,A.AbstractMethodHasImplementation({methodName:g.type==="Identifier"&&!h.computed?g.name:`[${this.input.slice(g.start,g.end)}]`}))}}return this.finishNode(l,"FunctionExpression")}static parse(t,e){if(e.locations===!1)throw Error("You have to enable options.locations while using acorn-typescript");else e.locations=!0;let s=new this(e,t);if(o)s.isAmbientContext=!0;return s.parse()}static parseExpressionAt(t,e,s){if(s.locations===!1)throw Error("You have to enable options.locations while using acorn-typescript");else s.locations=!0;let a=new this(s,t,e);if(o)a.isAmbientContext=!0;return a.nextToken(),a.parseExpression()}parseImportSpecifier(){if(this.ts_isContextual(y.type)){let e=this.startNode();return e.imported=this.parseModuleExportName(),this.parseTypeOnlyImportExportSpecifier(e,!0,this.importOrExportOuterKind==="type"),this.finishNode(e,"ImportSpecifier")}else{let e=super.parseImportSpecifier();return e.importKind="value",e}}parseExportSpecifier(t){let e=this.ts_isContextual(y.type);if(!this.match(i.string)&&e){let a=this.startNode();return a.local=this.parseModuleExportName(),this.parseTypeOnlyImportExportSpecifier(a,!1,this.importOrExportOuterKind==="type"),this.finishNode(a,"ExportSpecifier"),this.checkExport(t,a.exported,a.exported.start),a}else{let a=super.parseExportSpecifier(t);return a.exportKind="value",a}}parseTypeOnlyImportExportSpecifier(t,e,s){let a=e?"imported":"local",h=e?"local":"exported",l=t[a],u,x=!1,T=!0,d=l.start;if(this.isContextual("as")){let v=this.parseIdent();if(this.isContextual("as")){let _=this.parseIdent();if(V(this.type))x=!0,l=v,u=e?this.parseIdent():this.parseModuleExportName(),T=!1;else u=_,T=!1}else if(V(this.type))T=!1,u=e?this.parseIdent():this.parseModuleExportName();else x=!0,l=v}else if(V(this.type))if(x=!0,e){if(l=super.parseIdent(!0),!this.isContextual("as"))this.checkUnreserved(l)}else l=this.parseModuleExportName();if(x&&s)this.raise(d,e?A.TypeModifierIsUsedInTypeImports:A.TypeModifierIsUsedInTypeExports);t[a]=l,t[h]=u;let g=e?"importKind":"exportKind";if(t[g]=x?"type":"value",T&&this.eatContextual("as"))t[h]=e?this.parseIdent():this.parseModuleExportName();if(!t[h])t[h]=this.copyNode(t[a]);if(e)this.checkLValSimple(t[h],N.BIND_LEXICAL)}raiseCommonCheck(t,e,s){switch(e){case"Comma is not permitted after the rest element":if(this.isAmbientContext&&this.match(i.comma)&&this.lookaheadCharCode()===41){this.next();return}else return super.raise(t,e)}return s?super.raiseRecoverable(t,e):super.raise(t,e)}raiseRecoverable(t,e){return this.raiseCommonCheck(t,e,!0)}raise(t,e){return this.raiseCommonCheck(t,e,!0)}updateContext(t){let{type:e}=this;if(e==i.braceL){var s=this.curContext();if(s==O.tc_oTag)this.parseEffects.append(this.context,S.b_expr);else if(s==O.tc_expr)this.parseEffects.append(this.context,S.b_tmpl);else super.updateContext(t);this.exprAllowed=!0}else if(e===i.slash&&t===y.jsxTagStart)this.parseEffects.truncate(this.context,this.context.length-2),this.parseEffects.append(this.context,O.tc_cTag),this.exprAllowed=!1;else return super.updateContext(t)}jsx_parseOpeningElementAt(t,e){let s=this.startNodeAt(t,e),a=this.jsx_parseElementName();if(a)s.name=a;if(this.match(i.relational)||this.match(i.bitShift)){let h=this.tsTryParseAndCatch(()=>this.tsParseTypeArgumentsInExpression());if(h)s.typeArguments=h}s.attributes=[];while(this.type!==i.slash&&this.type!==y.jsxTagEnd)s.attributes.push(this.jsx_parseAttribute());return s.selfClosing=this.eat(i.slash),this.expect(y.jsxTagEnd),this.finishNode(s,a?"JSXOpeningElement":"JSXOpeningFragment")}enterScope(t){let e=t===J;if(e)this.parseEffects.append(this.importsStack,[]);let s=e?t|N.SCOPE_CLASS_STATIC_BLOCK:t;super.enterScope(s);let a=super.currentScope();a.types=[],a.enums=[],a.constEnums=[],a.classes=[],a.exportOnlyBindings=[]}exitScope(){if(super.currentScope().flags&J)this.parseEffects.pop(this.importsStack);super.exitScope()}hasImport(t,e){let s=this.importsStack.length;if(this.importsStack[s-1].indexOf(t)>-1)return!0;if(!e&&s>1){for(let a=0;a<s-1;a++)if(this.importsStack[a].indexOf(t)>-1)return!0}return!1}maybeExportDefined(t,e){if(this.inModule&&t.flags&N.SCOPE_TOP)this.parseEffects.remove(this.undefinedExports,e)}declareName(t,e,s){if(e&N.BIND_FLAGS_TS_IMPORT){if(this.hasImport(t,!0))this.raise(s,`Identifier '${t}' has already been declared.`);this.parseEffects.append(this.importsStack[this.importsStack.length-1],t);return}let a=this.currentScope();if(e&N.BIND_FLAGS_TS_EXPORT_ONLY){this.maybeExportDefined(a,t),this.parseEffects.append(a.exportOnlyBindings,t);return}if(e===N.BIND_TS_TYPE||e===N.BIND_TS_INTERFACE){if(e===N.BIND_TS_TYPE&&a.types.includes(t))this.raise(s,`type '${t}' has already been declared.`);this.parseEffects.append(a.types,t)}else if(e&N.BIND_FLAGS_TS_ENUM){if(a.enums.includes(t))return;super.declareName(t,N.BIND_LEXICAL,s)}else super.declareName(t,e,s);if(e&N.BIND_FLAGS_TS_ENUM)this.parseEffects.append(a.enums,t);if(e&N.BIND_FLAGS_TS_CONST_ENUM)this.parseEffects.append(a.constEnums,t);if(e&N.BIND_FLAGS_CLASS)this.parseEffects.append(a.classes,t)}checkLocalExport(t){let{name:e}=t;if(this.hasImport(e))return;let s=this.scopeStack.length;for(let a=s-1;a>=0;a--){let h=this.scopeStack[a];if(h.types.indexOf(e)>-1||h.exportOnlyBindings.indexOf(e)>-1)return}super.checkLocalExport(t)}}return xt}}var xe=/\n/,Pe=/[ \t]/,Ae=/^[,) \t]*$/,it="",Dt=[];function rt(r,o){it=r,Dt=o}function at(r,o,c,p){let m=o;if(r&&xe.test(m)){let E=c;while(E>0&&it[E-1]!==`
|
|
4
|
+
`)E-=1;let i=E;while(Pe.test(it[i]))i+=1;let P=it.slice(E,i);m=Se(m,P)}Dt.push({type:r?"Block":"Line",value:m,start:c,end:p})}function Se(r,o){if(o==="")return r;return(r.startsWith(o)?r.slice(o.length):r).replaceAll(`
|
|
5
|
+
${o}`,`
|
|
6
|
+
`)}function dt(r,o,c,p){let m=Ce(c,p);if(m>=c.length)return;ut(r,void 0,c,{index:m},o)}function Ce(r,o){let c=0,p=r.length;while(c<p){let m=c+p>>>1;if(r[m].start<o)c=m+1;else p=m}return c}function ut(r,o,c,p,m){while(p.index<c.length&&c[p.index].start<(r.start??0))r.leadingComments??=[],r.leadingComments.push(c[p.index]),p.index++;if(p.index>=c.length)return;let E=c[p.index].start,i=r.end,b=i===void 0||i>E?Object.keys(r):[];for(let I=0;I<b.length;I++){let f=b[I];if(f==="type"||f==="leadingComments")continue;let S=r[f];if(!S||typeof S!=="object")continue;if(Array.isArray(S)){for(let C of S)if(C&&typeof C==="object"&&typeof C.type==="string"){if(ut(C,r,c,p,m),p.index>=c.length)return}}else if(typeof S.type==="string"){if(ut(S,r,c,p,m),p.index>=c.length)return}}if(p.index<c.length){let I=c[p.index];if(o===void 0||r.end!==o.end){let f=m.slice(r.end??0,I.start);if((o?.type==="BlockStatement"||o?.type==="Program")&&pt(o.body,r)||o?.type==="ArrayExpression"&&pt(o.elements,r)||o?.type==="ObjectExpression"&&pt(o.properties,r))while(p.index<c.length){if(o&&c[p.index].start>=(o.end??Number.POSITIVE_INFINITY))break;p.index++}else if((r.end??0)<=I.start&&Ae.test(f))p.index++}}}function pt(r,o){return!!r&&r.indexOf(o)===r.length-1}var nt={sawParenthesized:!1},Ft=(r)=>class extends r{parseParenAndDistinguishExpression(o,c){let p=super.parseParenAndDistinguishExpression(o,c);if(p.type==="ParenthesizedExpression")nt.sawParenthesized=!0;return p}parseDecorator(){return nt.sawParenthesized=!0,super.parseDecorator()}},jt=(r)=>class extends r{checkLocalExport(){}},Ee=n.extend(Ft,jt),be=n.extend(Ot(),Ft,jt);function Tt(r){return r?be:Ee}var Ne={onComment:at,sourceType:"module",ecmaVersion:16},Ut={onComment:at,sourceType:"module",ecmaVersion:16,preserveParens:!0},ke={onComment:at,sourceType:"module",ecmaVersion:16},Rt={...Ut,startLocation:null},ft=/\r\n?|\n|\u2028|\u2029/g;function Ie(r,o){if(o?.breakEnds)return o.breakEnds;let c=[];ft.lastIndex=0;while(ft.test(r))c.push(ft.lastIndex);if(o)o.breakEnds=c;return c}function we(r,o,c){let p=r.lastIndexOf(`
|
|
7
|
+
`,o-1)+1,m=Ie(r,c),E=0,i=m.length;while(E<i){let P=E+i>>>1;if(m[P]<=p)E=P+1;else i=P}return{line:E+1,column:o-p}}function Kt(r,o,c,p,m){if(c.length===m)return;dt(r,o,c,p)}function k(r,o,c){let p=c.length;rt(r,c);let m=Tt(o).parse(r,Ne);if(c.length>0)dt(m,r,c,p);return m}var Le={count:0};function H(r,o,c,p,m){Le.count+=1;let E=p.length;rt(r,p),nt.sawParenthesized=!1;let i=Ut;if(c)Rt.startLocation=we(r,o,m),i=Rt;let P=Tt(c).parseExpressionAt(r,o,i);Kt(P,r,p,o,E);let b=p.length>E?p.at(-1):void 0,I=b&&b.end>(P.end??0)?b.end:P.end??0;return{node:nt.sawParenthesized?_e(P):P,end:I}}function De(r,o,c,p){let m=p.length,E=Tt(c);rt(r,p);let i=new E(ke,r,o);i.nextToken();let P=i.parseStatement(null,!0,Object.create(null));return Kt(P,r,p,o,m),P}function Bt(r){return r!==null&&typeof r==="object"&&typeof r.type==="string"}function mt(r){let o=r;while(o.type==="ParenthesizedExpression"&&o.expression)o=o.expression;return o}function _e(r){let o=mt(r);return yt(o),o}function yt(r){for(let o in r){let c=r[o];if(!c||typeof c!=="object")continue;if(Array.isArray(c))for(let p=0;p<c.length;p++){let m=c[p];if(!Bt(m))continue;let E=mt(m);if(E!==m)c[p]=E;yt(E)}else if(Bt(c)){let p=mt(c);if(p!==c)r[o]=p;yt(p)}}}
|
|
8
|
+
export{k,H,De};
|