sveast 0.9.4 → 0.9.6
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 +28 -5
- package/core.js +1 -1
- package/entities.js +1 -1
- package/index.d.ts +42 -8
- package/index.js +1 -1
- package/is-valid-type.js +1 -1
- package/lexer.d.ts +39 -7
- package/lexer.js +3 -3
- package/module.js +1 -1
- package/package.json +1 -1
- package/parse-imports-exports.js +1 -1
- package/parse-module.js +1 -1
- package/parse-sections.js +1 -1
- package/parse.js +1 -1
- package/runes.js +1 -1
- package/scope.d.ts +3 -1
- package/scope.js +1 -1
- package/shared-2pngd0mg.js +10 -0
- package/shared-5tpb3h6x.js +2 -0
- package/shared-a23q4q40.js +3 -0
- package/shared-as9z0pac.js +2 -0
- package/shared-bzqbnvee.js +2 -0
- package/shared-cs1ezg1f.js +2 -0
- package/shared-dgdrqgdn.js +2 -0
- package/shared-drb44hb9.js +2 -0
- package/shared-e4gbs4rb.js +3 -0
- package/shared-h6z1kjbb.js +2 -0
- package/shared-jpvd0875.js +2 -0
- package/shared-ke0fgd3r.js +2 -0
- package/shared-m0dcdh24.js +5 -0
- package/shared-m3dr31c3.js +2 -0
- package/shared-nan648gn.js +10 -0
- package/shared-qkp49nav.js +2 -0
- package/shared-tapcgcpr.js +2 -0
- package/shared-xwzsb4m8.js +3 -0
- package/shared-z9y4mrek.js +2 -0
- package/typescript.js +1 -1
- package/walk.js +1 -1
- package/shared-2by923ar.js +0 -3
- package/shared-3371ehgf.js +0 -2
- package/shared-4wqe6a27.js +0 -5
- package/shared-4zk9ntab.js +0 -2
- package/shared-artd3d80.js +0 -2
- package/shared-c9gzmr05.js +0 -2
- package/shared-h6c4cer7.js +0 -2
- package/shared-hjcsmz9f.js +0 -2
- package/shared-jxkrk6hx.js +0 -10
- package/shared-n0fpkmn8.js +0 -2
- package/shared-n1wnwhk8.js +0 -3
- package/shared-nbaaegmc.js +0 -2
- package/shared-rh41v5ez.js +0 -3
- package/shared-shxvsq2a.js +0 -2
- package/shared-stdj6se1.js +0 -2
- package/shared-v0nj05q2.js +0 -2
- package/shared-vjpq32kx.js +0 -2
- package/shared-xyqvjc3m.js +0 -10
- package/shared-znzncsf2.js +0 -2
package/scope.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o,f}from"./shared-4wqe6a27.js";import{p,I,g}from"./shared-4zk9ntab.js";import{W,P}from"./shared-znzncsf2.js";class c{node;parent;porous;declarations=new Map;constructor(e,n,t){this.node=e,this.parent=n,this.porous=t}get(e){for(let n=this;n;n=n.parent){let t=n.declarations.get(e);if(t!==void 0)return t}return null}}class v{name;kind;node;declaration;initial;scope;references=[];rune=null;prop=null;constructor(e,n,t,i,r,s){this.name=e,this.kind=n,this.node=t,this.declaration=i,this.initial=r,this.scope=s}}class m{node;parent;scope;binding=null;reads;writes;mutates;store=!1;constructor(e,n,t,i,r,s){this.node=e,this.parent=n,this.scope=t,this.reads=i,this.writes=r,this.mutates=s}}var y=Object.assign(Object.create(null),g),b=new Set(["SvelteElement","RegularElement","SvelteFragment","Component","SvelteComponent","SvelteSelf","SlotElement"]),N=new Map;function R(e){return new S(e)}class S{module;instance;instanceProgram=null;component;scopeIn=new Map;made=new Map;declared=new Map;references=new Map;pending=[];declarators=[];implicit=[];stores=new Map;constructor(e){if(e.type==="Program")this.component=!1,this.module=new c(e,null,!1),this.instance=this.module,this.made.set(e,this.module),this.visit(e,null,this.module);else{this.component=!0;let n=e.module?.content??null,t=e.instance?.content??null;this.module=new c(n,null,!1),this.instance=new c(t,this.module,!1),this.instanceProgram=t,this.scopeIn.set(e,this.module);for(let[i,r]of[[e.module,this.module],[e.instance,this.instance]]){if(i===void 0)continue;this.scopeIn.set(i,r),this.made.set(i.content,r);for(let s of i.attributes)this.visit(s,i,r);this.visit(i.content,i,r)}this.visit(e.fragment,e,this.instance)}this.declareImplicit(),this.resolve(),this.findRunesAndProps()}scopeOf(e){return this.scopeIn.get(e)??null}bindingOf(e){return this.declared.get(e)??this.references.get(e)?.binding??null}referenceOf(e){return this.references.get(e)??null}declaredIn(e){return this.made.get(e)?.declarations??N}child(e,n,t){let i=new c(n,e,t);return this.made.set(n,i),i}declare(e,n,t,i,r,s){let l=e;if(i==="var")while(l.porous&&l.parent!==null)l=l.parent;let a=l.declarations.get(t);if(a!==void 0&&a.declaration.type!=="TSDeclareFunction"){if(n!==null)this.declared.set(n,a);return}let u=new v(t,i,n,r,s,l);if(l.declarations.set(t,u),n!==null)this.declared.set(n,u)}reference(e,n,t,i,r,s){this.pending.push(new m(e,n,t,i,r,s))}referenceName(e,n,t,i){let r=e.split(".")[0],s={type:"Identifier",name:r,start:n,end:n+r.length};this.scopeIn.set(s,i),this.reference(s,t,i,!0,!1,!1)}visit(e,n,t){switch(this.scopeIn.set(e,t),e.type){case"Identifier":if(n!==null&&I(e,n))this.reference(e,n,t,!0,!1,!1);this.visitFields(e,t);return;case"ImportDeclaration":for(let i of e.specifiers){if(this.scopeIn.set(i,t),this.scopeIn.set(i.local,t),i.type==="ImportSpecifier")this.scopeIn.set(i.imported,t);this.declare(t,i.local,i.local.name,"import",i,e)}this.visit(e.source,e,t);for(let i of e.attributes??[])this.visit(i,e,t);return;case"ExportNamedDeclaration":if(e.declaration)this.visit(e.declaration,e,t);for(let i of e.specifiers)if(this.scopeIn.set(i,t),this.scopeIn.set(i.local,t),this.scopeIn.set(i.exported,t),!e.source&&i.local.type==="Identifier")this.reference(i.local,i,t,!0,!1,!1);if(e.source)this.visit(e.source,e,t);for(let i of e.attributes??[])this.visit(i,e,t);return;case"VariableDeclaration":this.visitDeclaration(e,n,t);return;case"FunctionDeclaration":if(e.id)this.scopeIn.set(e.id,t),this.declare(t,e.id,e.id.name,"function",e,e);this.visitFunction(e,this.child(t,e,!0));return;case"FunctionExpression":{let i=this.child(t,e,!0);if(e.id)this.scopeIn.set(e.id,i),this.declare(i,e.id,e.id.name,"function",e,e);this.visitFunction(e,i);return}case"ArrowFunctionExpression":this.visitFunction(e,this.child(t,e,!0));return;case"ClassDeclaration":case"ClassExpression":{let i=t;if(e.id){if(e.type==="ClassExpression")i=this.child(t,e,!1);this.scopeIn.set(e.id,i),this.declare(i,e.id,e.id.name,"class",e,e)}for(let r of e.decorators??[])this.visit(r,e,t);if(e.superClass)this.visit(e.superClass,e,i);this.visit(e.body,e,i);return}case"BlockStatement":this.visitFields(e,this.child(t,e,!(n!==null&&T(n)&&n.body===e)));return;case"StaticBlock":this.visitFields(e,this.child(t,e,!1));return;case"ForStatement":case"SwitchStatement":this.visitFields(e,this.child(t,e,!0));return;case"ForInStatement":case"ForOfStatement":{let i=this.child(t,e,!0);if(e.left.type==="VariableDeclaration")this.visit(e.left,e,i);else this.visitTarget(e.left,e,i,!1);this.visit(e.right,e,i),this.visit(e.body,e,i);return}case"CatchClause":{if(!e.param)break;let i=this.child(t,e,!0);this.declarePattern(e.param,e,i,"catch",e,null),this.visit(e.body,e,i);return}case"AssignmentExpression":this.visitTarget(e.left,e,t,e.operator!=="="),this.visit(e.right,e,t);return;case"UpdateExpression":this.visitTarget(e.argument,e,t,!0);return;case"LabeledStatement":if(n===this.instanceProgram&&e.label.name==="$"){this.visitReactive(e,t);return}break;case"TSEnumDeclaration":{this.scopeIn.set(e.id,t),this.declare(t,e.id,e.id.name,"enum",e,e);let i=this.child(t,e,!1);for(let r of e.members)if(this.scopeIn.set(r,i),this.scopeIn.set(r.id,i),r.id.type==="Identifier")this.declare(i,r.id,r.id.name,"enum-member",r,r.initializer??null);for(let r of e.members)if(r.initializer)this.visit(r.initializer,r,i);return}case"TSModuleDeclaration":if(this.scopeIn.set(e.id,t),e.id.type==="Identifier"&&!e.global)this.declare(t,e.id,e.id.name,"namespace",e,e);if(e.body)this.visit(e.body,e,this.child(t,e,!1));return;case"TSImportEqualsDeclaration":{this.scopeIn.set(e.id,t),this.declare(t,e.id,e.id.name,"import",e,e.moduleReference);let i=e.moduleReference;while(i.type==="TSQualifiedName")this.scopeIn.set(i,t),this.scopeIn.set(i.right,t),i=i.left;if(i.type==="Identifier")this.scopeIn.set(i,t),this.reference(i,e,t,!0,!1,!1);else this.visit(i,e,t);return}case"TSDeclareFunction":if(e.id){if(this.scopeIn.set(e.id,t),!t.declarations.has(e.id.name))this.declare(t,e.id,e.id.name,"function",e,e)}return;case"Fragment":this.visitFields(e,this.child(t,e,!1));return;case"RegularElement":case"SvelteElement":case"SlotElement":case"SvelteFragment":this.visitFields(e,this.child(t,e,!1));return;case"Component":case"SvelteComponent":case"SvelteSelf":this.visitComponent(e,t);return;case"LetDirective":this.visitLet(e,t);return;case"EachBlock":this.visitEach(e,t);return;case"AwaitBlock":this.visitAwait(e,t);return;case"SnippetBlock":{this.scopeIn.set(e.expression,t);let{name:i}=e.expression;this.declare(t,e.expression,i,"snippet",e,e);let r=this.child(t,e,!1);for(let s of e.parameters??[])this.declarePattern(s,e,r,"snippet-param",e,null);this.visit(e.body,e,r);return}case"BindDirective":if(e.expression.type==="SequenceExpression")break;this.visitTarget(e.expression,e,t,!0);return;case"TransitionDirective":case"AnimateDirective":case"UseDirective":{this.referenceName(e.name,e.start+x(e),e,t);break}case"StyleDirective":if(e.value===!0)this.referenceName(e.name,e.start+6,e,t);break}this.visitFields(e,t)}visitFields(e,n){let t=y[e.type];if(t===void 0)throw Error(`unknown node type: ${e.type}`);let i=f(e);for(let r=0;r<t.length;r++){let s=i[t[r]];if(Array.isArray(s))for(let l=0;l<s.length;l++){let a=s[l];if(o(a))this.visit(a,e,n)}else if(o(s))this.visit(s,e,n)}}visitDeclaration(e,n,t){let i=e.kind==="await using"?"using":e.kind;if(n?.type==="ConstTag")i="const-tag";for(let r of e.declarations)if(this.scopeIn.set(r,t),this.declarePattern(r.id,r,t,i,r,r.init??null),this.declarators.push([r,t]),r.init)this.visit(r.init,r,t)}visitFunction(e,n){for(let t of e.params){if(t.type==="Identifier"&&t.name==="this"){this.scopeIn.set(t,n);continue}this.declarePattern(t,e,n,"param",e,null)}this.visit(e.body,e,n)}declarePattern(e,n,t,i,r,s){switch(this.scopeIn.set(e,t),e.type){case"Identifier":this.declare(t,e,e.name,i,r,s);break;case"ObjectPattern":for(let l of e.properties){if(this.scopeIn.set(l,t),l.type==="RestElement"){this.declarePattern(l,e,t,i,r,s);continue}if(l.computed)this.visit(l.key,l,t);else this.scopeIn.set(l.key,t);this.declarePattern(l.value,l,t,i,r,s)}break;case"ArrayPattern":for(let l of e.elements)if(l)this.declarePattern(l,e,t,i,r,s);break;case"RestElement":this.declarePattern(e.argument,e,t,i,r,s);break;case"AssignmentPattern":this.declarePattern(e.left,e,t,i,r,s),this.visit(e.right,e,t);break;case"TSParameterProperty":this.declarePattern(e.parameter,e,t,i,r,s);break;default:this.visit(e,n,t);return}if("decorators"in e&&e.decorators)for(let l of e.decorators)this.visit(l,e,t)}visitTarget(e,n,t,i){switch(this.scopeIn.set(e,t),e.type){case"Identifier":this.reference(e,n,t,i,!0,!1);return;case"MemberExpression":{let r=e,s=n;while(r.type==="MemberExpression"){if(this.scopeIn.set(r,t),r.computed)this.visit(r.property,r,t);else this.scopeIn.set(r.property,t);s=r,r=r.object}if(r.type==="Identifier")this.scopeIn.set(r,t),this.reference(r,s,t,!0,!1,!0);else this.visit(r,s,t);return}case"ObjectPattern":for(let r of e.properties){if(this.scopeIn.set(r,t),r.type==="RestElement"){this.visitTarget(r,e,t,!1);continue}if(r.computed)this.visit(r.key,r,t);else this.scopeIn.set(r.key,t);this.visitTarget(r.value,r,t,!1)}return;case"ArrayPattern":for(let r of e.elements)if(r)this.visitTarget(r,e,t,!1);return;case"RestElement":this.visitTarget(e.argument,e,t,!1);return;case"AssignmentPattern":this.visitTarget(e.left,e,t,!1),this.visit(e.right,e,t);return}if(e.type==="TSAsExpression"||e.type==="TSSatisfiesExpression"||e.type==="TSNonNullExpression"||e.type==="TSTypeAssertion"){this.visitTarget(e.expression,e,t,i);return}this.visit(e,n,t)}visitReactive(e,n){let t=this.child(n,e,!1);this.scopeIn.set(e.label,n);let{body:i}=e;if(i.type==="ExpressionStatement"&&i.expression.type==="AssignmentExpression"){let{left:r,right:s}=i.expression;for(let l of p(r))if(!l.name.startsWith("$"))this.implicit.push([l,e,s])}this.visit(i,e,t)}visitComponent(e,n){if(e.type==="Component")this.referenceName(e.name,e.start+1,e,n);let t=d(e)!==null,i=new c(e,n,!1),r=t?n:i;if(this.made.set(e,r),e.type==="SvelteComponent")this.visit(e.expression,e,n);for(let s of e.attributes)this.visit(s,e,s.type==="LetDirective"?r:n);this.scopeIn.set(e.fragment,i);for(let s of e.fragment.nodes){let l=d(s);this.visit(s,e.fragment,l===null?i:this.child(n,s,!1))}}visitLet(e,n){if(e.expression===null){this.declare(n,null,e.name,"let-directive",e,null);return}let t=(i)=>{switch(this.scopeIn.set(i,n),i.type){case"Identifier":this.declare(n,i,i.name,"let-directive",e,null);return;case"ObjectExpression":for(let r of i.properties)if(this.scopeIn.set(r,n),r.type==="SpreadElement")t(r.argument);else this.scopeIn.set(r.key,n),t(r.value);return;case"ArrayExpression":for(let r of i.elements){if(r===null)continue;if(r.type==="SpreadElement")this.scopeIn.set(r,n),t(r.argument);else t(r)}}};t(e.expression)}visitEach(e,n){if(this.visit(e.expression,e,n),e.fallback)this.visit(e.fallback,e,n);let t=this.child(n,e,!1);if(e.context)this.declarePattern(e.context,e,t,"each",e,null);if(e.index!==void 0)this.declare(t,null,e.index,"each-index",e,e);if(e.key)this.visit(e.key,e,t);this.scopeIn.set(e.body,t);for(let i of e.body.nodes)this.visit(i,e.body,t)}visitAwait(e,n){if(this.visit(e.expression,e,n),e.pending)this.visit(e.pending,e,n);for(let[t,i,r]of[[e.then,e.value,"await-value"],[e.catch,e.error,"await-error"]]){if(t===null)continue;this.visit(t,e,n);let s=this.made.get(t);if(i!==null&&s!==void 0)this.declarePattern(i,e,s,r,e,null)}}declareImplicit(){for(let[e,n,t]of this.implicit)if(this.instance.get(e.name)===null)this.declare(this.instance,e,e.name,"reactive",n,t)}resolve(){let e=new Set;for(let n of this.pending){let{node:t}=n,i=this.declared.get(t);if(i!==void 0&&i.kind!=="reactive")continue;this.references.set(t,n);let r=n.scope.get(t.name);if(r===null&&this.component){let s=this.storeOf(t.name);if(s!==!1)n.store=!0,n.mutates||=n.writes,n.reads=!0,n.writes=!1,r=s}if(r!==null){n.binding=r;let s=r.references.at(-1);if(s!==void 0&&s.node.start>t.start)e.add(r);r.references.push(n)}}for(let n of e)n.references.sort((t,i)=>t.node.start-i.node.start)}storeOf(e){let n=this.stores.get(e);if(n!==void 0)return n;let t=!1;if(e.length>1&&e.startsWith("$")&&!e.startsWith("$$")){let i=this.instance.get(e.slice(1));if(!P.has(e))t=i;else if(i!==null){let r=i.initial,s=h(r,this.instance,null);if((s===null||e!=="$props"&&s==="$props")&&!(e==="$derived"&&r?.type==="ImportDeclaration"&&r.source.value==="svelte/store"))t=i}}return this.stores.set(e,t),t}findRunesAndProps(){for(let[e,n]of this.declarators){let t=h(e.init??null,n,this.references);if(t===null)continue;for(let i of p(e.id)){let r=this.declared.get(i);if(r?.declaration===e)r.rune=t}if(t!=="$props")continue;if(e.id.type==="Identifier"){let i=this.declared.get(e.id);if(i)i.initial=null;continue}if(e.id.type!=="ObjectPattern")continue;for(let i of e.id.properties){if(i.type==="RestElement"){for(let l of p(i)){let a=this.declared.get(l);if(a)a.initial=null}continue}let r=i.value.type==="AssignmentPattern"?i.value.left:i.value,s=r.type==="Identifier"?this.declared.get(r):void 0;if(s===void 0||i.computed)continue;s.prop=E(i.key),s.initial=i.value.type==="AssignmentPattern"?A(i.value.right):null}}this.findLegacyProps()}findLegacyProps(){if(this.instanceProgram===null)return;for(let e of this.instanceProgram.body){if(e.type!=="ExportNamedDeclaration")continue;let{declaration:n}=e;if(n?.type==="VariableDeclaration"){if(n.kind!=="let"&&n.kind!=="var")continue;for(let t of n.declarations)for(let i of p(t.id)){let r=this.declared.get(i);if(r)r.prop=i.name}continue}if(e.source)continue;for(let t of e.specifiers){if(t.local.type!=="Identifier")continue;let i=this.instance.declarations.get(t.local.name);if(i?.kind!=="let"&&i?.kind!=="var")continue;i.prop=t.exported.type==="Identifier"?t.exported.name:String(t.exported.value)}}}}function T(e){return e.type==="ArrowFunctionExpression"||e.type==="FunctionExpression"||e.type==="FunctionDeclaration"}function d(e){if(!b.has(e.type)||!("attributes"in e))return null;for(let n of e.attributes??[])if(n.type==="Attribute"&&n.name==="slot"&&Array.isArray(n.value)&&n.value.length===1&&n.value[0].type==="Text")return n.value[0].data;return null}function h(e,n,t){if(e?.type!=="CallExpression")return null;let i=e.callee,r="";while(i.type==="MemberExpression"){if(i.computed||i.property.type!=="Identifier")return null;r=`.${i.property.name}${r}`,i=i.object}if(i.type==="CallExpression"&&i.callee.type==="Identifier")r=`()${r}`,i=i.callee;if(i.type!=="Identifier")return null;if(t!==null){let s=t.get(i);if(s?.binding!==null||s.store)return null}else if(n.get(i.name)!==null)return null;return r=i.name+r,W.has(r)?r:null}function A(e){if(e.type==="CallExpression"&&e.callee.type==="Identifier"&&e.callee.name==="$bindable"){let[n]=e.arguments;return n===void 0||n.type==="SpreadElement"?null:n}return e}function x(e){if(e.type==="UseDirective")return 4;if(e.type==="AnimateDirective")return 8;if(e.intro&&e.outro)return 11;return e.intro?3:4}function E(e){if(e.type==="Identifier")return e.name;return e.type==="Literal"?String(e.value):null}export{R as analyzeScopes};
|
|
1
|
+
import{isNode,fieldsOf}from"./shared-m0dcdh24.js";import{extractIdentifiers2,isReference2,valueVisitorKeys2}from"./shared-jpvd0875.js";import{RUNES,RUNE_NAMES}from"./shared-m3dr31c3.js";class ScopeNode{node;parent;porous;index;declarations=new Map;constructor(node,parent,porous,index){this.node=node,this.parent=parent,this.porous=porous,this.index=index}get(name){for(let scope=this;scope;scope=scope.parent){let binding=scope.declarations.get(name);if(binding!==void 0)return binding}return null}}class BindingNode{name;kind;node;declaration;initial;scope;references=[];rune=null;prop=null;constructor(name,kind,node,declaration,initial,scope){this.name=name,this.kind=kind,this.node=node,this.declaration=declaration,this.initial=initial,this.scope=scope}}class ReferenceNode{node;parent;scope;binding=null;reads;writes;mutates;store=!1;constructor(node,parent,scope,reads,writes,mutates){this.node=node,this.parent=parent,this.scope=scope,this.reads=reads,this.writes=writes,this.mutates=mutates}}var keysByType=Object.assign(Object.create(null),valueVisitorKeys2),ELEMENTS=new Set(["SvelteElement","RegularElement","SvelteFragment","Component","SvelteComponent","SvelteSelf","SlotElement"]),NO_BINDINGS=new Map;function analyzeScopes(ast){return new Analysis(ast,!1)}class Analysis{module;instance;instanceProgram=null;component;ast;scopes=[];scopeIn;synthetic=new Map;recorded;made=new Map;declared=new Map;references=new Map;pending=[];declarators=[];implicit=[];stores=new Map;constructor(ast,record){if(this.ast=ast,this.scopeIn=record?new Map:null,ast.type==="Program")this.component=!1,this.module=this.scope(ast,null,!1),this.instance=this.module,this.made.set(ast,this.module),this.visit(ast,null,this.module);else{this.component=!0;let module=ast.module?.content??null,instance=ast.instance?.content??null;this.module=this.scope(module,null,!1),this.instance=this.scope(instance,this.module,!1),this.instanceProgram=instance,this.scopeIn?.set(ast,this.module);for(let[script,scope]of[[ast.module,this.module],[ast.instance,this.instance]]){if(script===void 0)continue;this.scopeIn?.set(script,scope),this.made.set(script.content,scope);for(let attribute of script.attributes)this.visit(attribute,script,scope);this.visit(script.content,script,scope)}this.visit(ast.fragment,ast,this.instance)}this.declareImplicit(),this.resolve(),this.findRunesAndProps()}scopeOf(node){let synthetic=this.synthetic.get(node);if(synthetic!==void 0)return synthetic;if(this.scopeIn!==null)return this.scopeIn.get(node)??null;this.recorded??=new Analysis(this.ast,!0);let recorded=this.recorded.scopeIn?.get(node);return recorded===void 0?null:this.scopes[recorded.index]}scope(node,parent,porous){let scope=new ScopeNode(node,parent,porous,this.scopes.length);return this.scopes.push(scope),scope}bindingOf(node){return this.declared.get(node)??this.references.get(node)?.binding??null}referenceOf(node){return this.references.get(node)??null}declaredIn(node){return this.made.get(node)?.declarations??NO_BINDINGS}child(scope,node,porous){let made=this.scope(node,scope,porous);return this.made.set(node,made),made}declare(scope,node,name,kind,declaration,initial){let target=scope;if(kind==="var")while(target.porous&&target.parent!==null)target=target.parent;let existing=target.declarations.get(name);if(existing!==void 0&&existing.declaration.type!=="TSDeclareFunction"){if(node!==null)this.declared.set(node,existing);return}let binding=new BindingNode(name,kind,node,declaration,initial,target);if(target.declarations.set(name,binding),node!==null)this.declared.set(node,binding)}reference(node,parent,scope,reads,writes,mutates){this.pending.push(new ReferenceNode(node,parent,scope,reads,writes,mutates))}referenceName(name,start,parent,scope){let root=name.split(".")[0],node={type:"Identifier",name:root,start,end:start+root.length};this.synthetic.set(node,scope),this.reference(node,parent,scope,!0,!1,!1)}visit(node,parent,scope){switch(this.scopeIn?.set(node,scope),node.type){case"Identifier":if(parent!==null&&isReference2(node,parent))this.reference(node,parent,scope,!0,!1,!1);this.visitFields(node,scope);return;case"ImportDeclaration":for(let specifier of node.specifiers){if(this.scopeIn?.set(specifier,scope),this.scopeIn?.set(specifier.local,scope),specifier.type==="ImportSpecifier")this.scopeIn?.set(specifier.imported,scope);this.declare(scope,specifier.local,specifier.local.name,"import",specifier,node)}this.visit(node.source,node,scope);for(let attribute of node.attributes??[])this.visit(attribute,node,scope);return;case"ExportNamedDeclaration":if(node.declaration)this.visit(node.declaration,node,scope);for(let specifier of node.specifiers)if(this.scopeIn?.set(specifier,scope),this.scopeIn?.set(specifier.local,scope),this.scopeIn?.set(specifier.exported,scope),!node.source&&specifier.local.type==="Identifier")this.reference(specifier.local,specifier,scope,!0,!1,!1);if(node.source)this.visit(node.source,node,scope);for(let attribute of node.attributes??[])this.visit(attribute,node,scope);return;case"VariableDeclaration":this.visitDeclaration(node,parent,scope);return;case"FunctionDeclaration":if(node.id)this.scopeIn?.set(node.id,scope),this.declare(scope,node.id,node.id.name,"function",node,node);this.visitFunction(node,this.child(scope,node,!0));return;case"FunctionExpression":{let inner=this.child(scope,node,!0);if(node.id)this.scopeIn?.set(node.id,inner),this.declare(inner,node.id,node.id.name,"function",node,node);this.visitFunction(node,inner);return}case"ArrowFunctionExpression":this.visitFunction(node,this.child(scope,node,!0));return;case"ClassDeclaration":case"ClassExpression":{let inner=scope;if(node.id){if(node.type==="ClassExpression")inner=this.child(scope,node,!1);this.scopeIn?.set(node.id,inner),this.declare(inner,node.id,node.id.name,"class",node,node)}for(let decorator of node.decorators??[])this.visit(decorator,node,scope);if(node.superClass)this.visit(node.superClass,node,inner);this.visit(node.body,node,inner);return}case"BlockStatement":this.visitFields(node,this.child(scope,node,!(parent!==null&&isFunction(parent)&&parent.body===node)));return;case"StaticBlock":this.visitFields(node,this.child(scope,node,!1));return;case"ForStatement":case"SwitchStatement":this.visitFields(node,this.child(scope,node,!0));return;case"ForInStatement":case"ForOfStatement":{let inner=this.child(scope,node,!0);if(node.left.type==="VariableDeclaration")this.visit(node.left,node,inner);else this.visitTarget(node.left,node,inner,!1);this.visit(node.right,node,inner),this.visit(node.body,node,inner);return}case"CatchClause":{if(!node.param)break;let inner=this.child(scope,node,!0);this.declarePattern(node.param,node,inner,"catch",node,null),this.visit(node.body,node,inner);return}case"AssignmentExpression":this.visitTarget(node.left,node,scope,node.operator!=="="),this.visit(node.right,node,scope);return;case"UpdateExpression":this.visitTarget(node.argument,node,scope,!0);return;case"LabeledStatement":if(parent===this.instanceProgram&&node.label.name==="$"){this.visitReactive(node,scope);return}break;case"TSEnumDeclaration":{this.scopeIn?.set(node.id,scope),this.declare(scope,node.id,node.id.name,"enum",node,node);let inner=this.child(scope,node,!1);for(let member of node.members)if(this.scopeIn?.set(member,inner),this.scopeIn?.set(member.id,inner),member.id.type==="Identifier")this.declare(inner,member.id,member.id.name,"enum-member",member,member.initializer??null);for(let member of node.members)if(member.initializer)this.visit(member.initializer,member,inner);return}case"TSModuleDeclaration":if(this.scopeIn?.set(node.id,scope),node.id.type==="Identifier"&&!node.global)this.declare(scope,node.id,node.id.name,"namespace",node,node);if(node.body)this.visit(node.body,node,this.child(scope,node,!1));return;case"TSImportEqualsDeclaration":{this.scopeIn?.set(node.id,scope),this.declare(scope,node.id,node.id.name,"import",node,node.moduleReference);let name=node.moduleReference;while(name.type==="TSQualifiedName")this.scopeIn?.set(name,scope),this.scopeIn?.set(name.right,scope),name=name.left;if(name.type==="Identifier")this.scopeIn?.set(name,scope),this.reference(name,node,scope,!0,!1,!1);else this.visit(name,node,scope);return}case"TSDeclareFunction":if(node.id){if(this.scopeIn?.set(node.id,scope),!scope.declarations.has(node.id.name))this.declare(scope,node.id,node.id.name,"function",node,node)}return;case"Fragment":this.visitFields(node,this.child(scope,node,!1));return;case"RegularElement":case"SvelteElement":case"SlotElement":case"SvelteFragment":this.visitFields(node,this.child(scope,node,!1));return;case"Component":case"SvelteComponent":case"SvelteSelf":this.visitComponent(node,scope);return;case"LetDirective":this.visitLet(node,scope);return;case"EachBlock":this.visitEach(node,scope);return;case"AwaitBlock":this.visitAwait(node,scope);return;case"SnippetBlock":{this.scopeIn?.set(node.expression,scope);let{name}=node.expression;this.declare(scope,node.expression,name,"snippet",node,node);let inner=this.child(scope,node,!1);for(let parameter of node.parameters??[])this.declarePattern(parameter,node,inner,"snippet-param",node,null);this.visit(node.body,node,inner);return}case"BindDirective":if(node.expression.type==="SequenceExpression")break;this.visitTarget(node.expression,node,scope,!0);return;case"TransitionDirective":case"AnimateDirective":case"UseDirective":{this.referenceName(node.name,node.start+prefixLength(node),node,scope);break}case"StyleDirective":if(node.value===!0)this.referenceName(node.name,node.start+6,node,scope);break}this.visitFields(node,scope)}visitFields(node,scope){let keys=keysByType[node.type];if(keys===void 0)throw Error(`unknown node type: ${node.type}`);let fields=fieldsOf(node);for(let k=0;k<keys.length;k++){let value=fields[keys[k]];if(Array.isArray(value))for(let i=0;i<value.length;i++){let child=value[i];if(isNode(child))this.visit(child,node,scope)}else if(isNode(value))this.visit(value,node,scope)}}visitDeclaration(node,parent,scope){let kind=node.kind==="await using"?"using":node.kind;if(parent?.type==="ConstTag")kind="const-tag";for(let declarator of node.declarations)if(this.scopeIn?.set(declarator,scope),this.declarePattern(declarator.id,declarator,scope,kind,declarator,declarator.init??null),this.declarators.push([declarator,scope]),declarator.init)this.visit(declarator.init,declarator,scope)}visitFunction(node,scope){for(let param of node.params){if(param.type==="Identifier"&¶m.name==="this"){this.scopeIn?.set(param,scope);continue}this.declarePattern(param,node,scope,"param",node,null)}this.visit(node.body,node,scope)}declarePattern(pattern,parent,scope,kind,declaration,initial){switch(this.scopeIn?.set(pattern,scope),pattern.type){case"Identifier":this.declare(scope,pattern,pattern.name,kind,declaration,initial);break;case"ObjectPattern":for(let property of pattern.properties){if(this.scopeIn?.set(property,scope),property.type==="RestElement"){this.declarePattern(property,pattern,scope,kind,declaration,initial);continue}if(property.computed)this.visit(property.key,property,scope);else this.scopeIn?.set(property.key,scope);this.declarePattern(property.value,property,scope,kind,declaration,initial)}break;case"ArrayPattern":for(let element of pattern.elements)if(element)this.declarePattern(element,pattern,scope,kind,declaration,initial);break;case"RestElement":this.declarePattern(pattern.argument,pattern,scope,kind,declaration,initial);break;case"AssignmentPattern":this.declarePattern(pattern.left,pattern,scope,kind,declaration,initial),this.visit(pattern.right,pattern,scope);break;case"TSParameterProperty":this.declarePattern(pattern.parameter,pattern,scope,kind,declaration,initial);break;default:this.visit(pattern,parent,scope);return}if("decorators"in pattern&&pattern.decorators)for(let decorator of pattern.decorators)this.visit(decorator,pattern,scope)}visitTarget(target,parent,scope,reads){switch(this.scopeIn?.set(target,scope),target.type){case"Identifier":this.reference(target,parent,scope,reads,!0,!1);return;case"MemberExpression":{let object=target,holder=parent;while(object.type==="MemberExpression"){if(this.scopeIn?.set(object,scope),object.computed)this.visit(object.property,object,scope);else this.scopeIn?.set(object.property,scope);holder=object,object=object.object}if(object.type==="Identifier")this.scopeIn?.set(object,scope),this.reference(object,holder,scope,!0,!1,!0);else this.visit(object,holder,scope);return}case"ObjectPattern":for(let property of target.properties){if(this.scopeIn?.set(property,scope),property.type==="RestElement"){this.visitTarget(property,target,scope,!1);continue}if(property.computed)this.visit(property.key,property,scope);else this.scopeIn?.set(property.key,scope);this.visitTarget(property.value,property,scope,!1)}return;case"ArrayPattern":for(let element of target.elements)if(element)this.visitTarget(element,target,scope,!1);return;case"RestElement":this.visitTarget(target.argument,target,scope,!1);return;case"AssignmentPattern":this.visitTarget(target.left,target,scope,!1),this.visit(target.right,target,scope);return}if(target.type==="TSAsExpression"||target.type==="TSSatisfiesExpression"||target.type==="TSNonNullExpression"||target.type==="TSTypeAssertion"){this.visitTarget(target.expression,target,scope,reads);return}this.visit(target,parent,scope)}visitReactive(node,scope){let inner=this.child(scope,node,!1);this.scopeIn?.set(node.label,scope);let{body}=node;if(body.type==="ExpressionStatement"&&body.expression.type==="AssignmentExpression"){let{left,right}=body.expression;for(let id of extractIdentifiers2(left))if(!id.name.startsWith("$"))this.implicit.push([id,node,right])}this.visit(body,node,inner)}visitComponent(node,scope){if(node.type==="Component")this.referenceName(node.name,node.start+1,node,scope);let slotted=slotOf(node)!==null,defaults=this.scope(node,scope,!1),lets=slotted?scope:defaults;if(this.made.set(node,lets),node.type==="SvelteComponent")this.visit(node.expression,node,scope);for(let attribute of node.attributes)this.visit(attribute,node,attribute.type==="LetDirective"?lets:scope);this.scopeIn?.set(node.fragment,defaults);for(let child of node.fragment.nodes){let slot=slotOf(child);this.visit(child,node.fragment,slot===null?defaults:this.child(scope,child,!1))}}visitLet(node,scope){if(node.expression===null){this.declare(scope,null,node.name,"let-directive",node,null);return}let declare=(expression)=>{switch(this.scopeIn?.set(expression,scope),expression.type){case"Identifier":this.declare(scope,expression,expression.name,"let-directive",node,null);return;case"ObjectExpression":for(let property of expression.properties)if(this.scopeIn?.set(property,scope),property.type==="SpreadElement")declare(property.argument);else this.scopeIn?.set(property.key,scope),declare(property.value);return;case"ArrayExpression":for(let element of expression.elements){if(element===null)continue;if(element.type==="SpreadElement")this.scopeIn?.set(element,scope),declare(element.argument);else declare(element)}}};declare(node.expression)}visitEach(node,scope){if(this.visit(node.expression,node,scope),node.fallback)this.visit(node.fallback,node,scope);let inner=this.child(scope,node,!1);if(node.context)this.declarePattern(node.context,node,inner,"each",node,null);if(node.index!==void 0)this.declare(inner,null,node.index,"each-index",node,node);if(node.key)this.visit(node.key,node,inner);this.scopeIn?.set(node.body,inner);for(let child of node.body.nodes)this.visit(child,node.body,inner)}visitAwait(node,scope){if(this.visit(node.expression,node,scope),node.pending)this.visit(node.pending,node,scope);for(let[fragment,pattern,kind]of[[node.then,node.value,"await-value"],[node.catch,node.error,"await-error"]]){if(fragment===null)continue;this.visit(fragment,node,scope);let inner=this.made.get(fragment);if(pattern!==null&&inner!==void 0)this.declarePattern(pattern,node,inner,kind,node,null)}}declareImplicit(){for(let[id,label,right]of this.implicit)if(this.instance.get(id.name)===null)this.declare(this.instance,id,id.name,"reactive",label,right)}resolve(){let unordered=new Set;for(let reference of this.pending){let{node}=reference,declared=this.declared.get(node);if(declared!==void 0&&declared.kind!=="reactive")continue;this.references.set(node,reference);let binding=reference.scope.get(node.name);if(binding===null&&this.component){let store=this.storeOf(node.name);if(store!==!1)reference.store=!0,reference.mutates||=reference.writes,reference.reads=!0,reference.writes=!1,binding=store}if(binding!==null){reference.binding=binding;let last=binding.references.at(-1);if(last!==void 0&&last.node.start>node.start)unordered.add(binding);binding.references.push(reference)}}for(let binding of unordered)binding.references.sort((a,b)=>a.node.start-b.node.start)}storeOf(name){let cached=this.stores.get(name);if(cached!==void 0)return cached;let store=!1;if(name.length>1&&name.startsWith("$")&&!name.startsWith("$$")){let declaration=this.instance.get(name.slice(1));if(!RUNE_NAMES.has(name))store=declaration;else if(declaration!==null){let initial=declaration.initial,rune=runeOf(initial,this.instance,null);if((rune===null||name!=="$props"&&rune==="$props")&&!(name==="$derived"&&initial?.type==="ImportDeclaration"&&initial.source.value==="svelte/store"))store=declaration}}return this.stores.set(name,store),store}findRunesAndProps(){for(let[declarator,scope]of this.declarators){let rune=runeOf(declarator.init??null,scope,this.references);if(rune===null)continue;for(let id of extractIdentifiers2(declarator.id)){let binding=this.declared.get(id);if(binding?.declaration===declarator)binding.rune=rune}if(rune!=="$props")continue;if(declarator.id.type==="Identifier"){let binding=this.declared.get(declarator.id);if(binding)binding.initial=null;continue}if(declarator.id.type!=="ObjectPattern")continue;for(let property of declarator.id.properties){if(property.type==="RestElement"){for(let id of extractIdentifiers2(property)){let binding=this.declared.get(id);if(binding)binding.initial=null}continue}let value=property.value.type==="AssignmentPattern"?property.value.left:property.value,binding=value.type==="Identifier"?this.declared.get(value):void 0;if(binding===void 0||property.computed)continue;binding.prop=keyName(property.key),binding.initial=property.value.type==="AssignmentPattern"?unwrapBindable(property.value.right):null}}this.findLegacyProps()}findLegacyProps(){if(this.instanceProgram===null)return;for(let statement of this.instanceProgram.body){if(statement.type!=="ExportNamedDeclaration")continue;let{declaration}=statement;if(declaration?.type==="VariableDeclaration"){if(declaration.kind!=="let"&&declaration.kind!=="var")continue;for(let declarator of declaration.declarations)for(let id of extractIdentifiers2(declarator.id)){let binding=this.declared.get(id);if(binding)binding.prop=id.name}continue}if(statement.source)continue;for(let specifier of statement.specifiers){if(specifier.local.type!=="Identifier")continue;let binding=this.instance.declarations.get(specifier.local.name);if(binding?.kind!=="let"&&binding?.kind!=="var")continue;binding.prop=specifier.exported.type==="Identifier"?specifier.exported.name:String(specifier.exported.value)}}}}function isFunction(node){return node.type==="ArrowFunctionExpression"||node.type==="FunctionExpression"||node.type==="FunctionDeclaration"}function slotOf(node){if(!ELEMENTS.has(node.type)||!("attributes"in node))return null;for(let attribute of node.attributes??[])if(attribute.type==="Attribute"&&attribute.name==="slot"&&Array.isArray(attribute.value)&&attribute.value.length===1&&attribute.value[0].type==="Text")return attribute.value[0].data;return null}function runeOf(initial,scope,references){if(initial?.type!=="CallExpression")return null;let node=initial.callee,keypath="";while(node.type==="MemberExpression"){if(node.computed||node.property.type!=="Identifier")return null;keypath=`.${node.property.name}${keypath}`,node=node.object}if(node.type==="CallExpression"&&node.callee.type==="Identifier")keypath=`()${keypath}`,node=node.callee;if(node.type!=="Identifier")return null;if(references!==null){let reference=references.get(node);if(reference?.binding!==null||reference.store)return null}else if(scope.get(node.name)!==null)return null;return keypath=node.name+keypath,RUNES.has(keypath)?keypath:null}function unwrapBindable(node){if(node.type==="CallExpression"&&node.callee.type==="Identifier"&&node.callee.name==="$bindable"){let[argument]=node.arguments;return argument===void 0||argument.type==="SpreadElement"?null:argument}return node}function prefixLength(node){if(node.type==="UseDirective")return 4;if(node.type==="AnimateDirective")return 8;if(node.intro&&node.outro)return 11;return node.intro?3:4}function keyName(key){if(key.type==="Identifier")return key.name;return key.type==="Literal"?String(key.value):null}export{analyzeScopes};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var reservedWords={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},ecma5AndLessKeywords="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",keywords$1={5:ecma5AndLessKeywords,"5module":ecma5AndLessKeywords+" export import",6:ecma5AndLessKeywords+" const class extends export import super"},keywordRelationalOperator=/^in(stanceof)?$/,nonASCIIidentifierStart=/\p{ID_Start}/u,nonASCIIidentifier=/[\p{ID_Continue}\u200c\u200d]/u;function isIdentifierStart(code,astral){if(code<65)return code===36;if(code<91)return!0;if(code<97)return code===95;if(code<123)return!0;if(code>65535&&astral===!1)return!1;return code>=170&&nonASCIIidentifierStart.test(String.fromCodePoint(code))}function isIdentifierChar(code,astral){if(code<48)return code===36;if(code<58)return!0;if(code<65)return!1;if(code<91)return!0;if(code<97)return code===95;if(code<123)return!0;if(code>65535&&astral===!1)return!1;return code>=170&&nonASCIIidentifier.test(String.fromCodePoint(code))}var TokenType=function(label,conf){if(conf===void 0)conf={};this.label=label,this.keyword=conf.keyword,this.beforeExpr=!!conf.beforeExpr,this.startsExpr=!!conf.startsExpr,this.isLoop=!!conf.isLoop,this.isAssign=!!conf.isAssign,this.prefix=!!conf.prefix,this.postfix=!!conf.postfix,this.binop=conf.binop||null,this.updateContext=null};function binop(name,prec){return new TokenType(name,{beforeExpr:!0,binop:prec})}var beforeExpr={beforeExpr:!0},startsExpr={startsExpr:!0},keywords={};function kw(name,options){if(options===void 0)options={};return options.keyword=name,keywords[name]=new TokenType(name,options)}var types$1={num:new TokenType("num",startsExpr),regexp:new TokenType("regexp",startsExpr),string:new TokenType("string",startsExpr),name:new TokenType("name",startsExpr),privateId:new TokenType("privateId",startsExpr),eof:new TokenType("eof"),bracketL:new TokenType("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new TokenType("]"),braceL:new TokenType("{",{beforeExpr:!0,startsExpr:!0}),braceR:new TokenType("}"),parenL:new TokenType("(",{beforeExpr:!0,startsExpr:!0}),parenR:new TokenType(")"),comma:new TokenType(",",beforeExpr),semi:new TokenType(";",beforeExpr),colon:new TokenType(":",beforeExpr),dot:new TokenType("."),question:new TokenType("?",beforeExpr),questionDot:new TokenType("?."),arrow:new TokenType("=>",beforeExpr),template:new TokenType("template"),invalidTemplate:new TokenType("invalidTemplate"),ellipsis:new TokenType("...",beforeExpr),backQuote:new TokenType("`",startsExpr),dollarBraceL:new TokenType("${",{beforeExpr:!0,startsExpr:!0}),eq:new TokenType("=",{beforeExpr:!0,isAssign:!0}),assign:new TokenType("_=",{beforeExpr:!0,isAssign:!0}),incDec:new TokenType("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new TokenType("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:binop("||",1),logicalAND:binop("&&",2),bitwiseOR:binop("|",3),bitwiseXOR:binop("^",4),bitwiseAND:binop("&",5),equality:binop("==/!=/===/!==",6),relational:binop("</>/<=/>=",7),bitShift:binop("<</>>/>>>",8),plusMin:new TokenType("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:binop("%",10),star:binop("*",10),slash:binop("/",10),starstar:new TokenType("**",{beforeExpr:!0}),coalesce:binop("??",1),_break:kw("break"),_case:kw("case",beforeExpr),_catch:kw("catch"),_continue:kw("continue"),_debugger:kw("debugger"),_default:kw("default",beforeExpr),_do:kw("do",{isLoop:!0,beforeExpr:!0}),_else:kw("else",beforeExpr),_finally:kw("finally"),_for:kw("for",{isLoop:!0}),_function:kw("function",startsExpr),_if:kw("if"),_return:kw("return",beforeExpr),_switch:kw("switch"),_throw:kw("throw",beforeExpr),_try:kw("try"),_var:kw("var"),_const:kw("const"),_while:kw("while",{isLoop:!0}),_with:kw("with"),_new:kw("new",{beforeExpr:!0,startsExpr:!0}),_this:kw("this",startsExpr),_super:kw("super",startsExpr),_class:kw("class",startsExpr),_extends:kw("extends",beforeExpr),_export:kw("export"),_import:kw("import",startsExpr),_null:kw("null",startsExpr),_true:kw("true",startsExpr),_false:kw("false",startsExpr),_in:kw("in",{beforeExpr:!0,binop:7}),_instanceof:kw("instanceof",{beforeExpr:!0,binop:7}),_typeof:kw("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:kw("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:kw("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},lineBreak=/\r\n?|\n|\u2028|\u2029/,lineBreakG=new RegExp(lineBreak.source,"g");function isNewLine(code){return code===10||code===13||code===8232||code===8233}function nextLineBreak(code,from,end){if(end===void 0)end=code.length;for(var i=from;i<end;i++){var next=code.charCodeAt(i);if(isNewLine(next))return i<end-1&&next===13&&code.charCodeAt(i+1)===10?i+2:i+1}return-1}var nonASCIIwhitespace=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,skipWhiteSpace=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ref=Object.prototype,{hasOwnProperty,toString}=ref,hasOwn=Object.hasOwn||function(obj,propName){return hasOwnProperty.call(obj,propName)},isArray=Array.isArray||function(obj){return toString.call(obj)==="[object Array]"},regexpCache=Object.create(null);function wordsRegexp(words){return regexpCache[words]||(regexpCache[words]=new RegExp("^(?:"+words.replace(/ /g,"|")+")$"))}function codePointToString(code){if(code<=65535)return String.fromCharCode(code);return code-=65536,String.fromCharCode((code>>10)+55296,(code&1023)+56320)}var loneSurrogate=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Position=function(line,col){this.line=line,this.column=col};Position.prototype.offset=function(n){return new Position(this.line,this.column+n)};var SourceLocation=function(p,start,end){if(this.start=start,this.end=end,p.sourceFile!==null)this.source=p.sourceFile};function getLineInfo(input,offset){for(var line=1,cur=0;;){var nextBreak=nextLineBreak(input,cur,offset);if(nextBreak<0)return new Position(line,offset-cur);++line,cur=nextBreak}}var defaultOptions={ecmaVersion:null,sourceType:"script",strict:!1,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,startLocation:null,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},warnedAboutEcmaVersion=!1;function getOptions(opts){var options={};for(var opt in defaultOptions)options[opt]=opts&&hasOwn(opts,opt)?opts[opt]:defaultOptions[opt];if(options.ecmaVersion==="latest")options.ecmaVersion=1e8;else if(options.ecmaVersion==null){if(!warnedAboutEcmaVersion&&typeof console==="object"&&console.warn)warnedAboutEcmaVersion=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
2
|
+
Defaulting to 2020, but this will stop working in the future.`);options.ecmaVersion=11}else if(options.ecmaVersion>=2015)options.ecmaVersion-=2009;if(options.allowReserved==null)options.allowReserved=options.ecmaVersion<5;if(!opts||opts.allowHashBang==null)options.allowHashBang=options.ecmaVersion>=14;if(isArray(options.onToken)){var tokens=options.onToken;options.onToken=function(token){return tokens.push(token)}}if(isArray(options.onComment))options.onComment=pushComment(options,options.onComment);if(options.sourceType==="commonjs"&&options.allowAwaitOutsideFunction)throw Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");return options}function pushComment(options,array){return function(block,text,start,end,startLoc,endLoc){var comment={type:block?"Block":"Line",value:text,start,end};if(options.locations)comment.loc=new SourceLocation(this,startLoc,endLoc);if(options.ranges)comment.range=[start,end];array.push(comment)}}var 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_CLASS_FIELD_INIT=512,SCOPE_SWITCH=1024,SCOPE_VAR=SCOPE_TOP|SCOPE_FUNCTION|SCOPE_CLASS_STATIC_BLOCK;function functionFlags(async,generator){return SCOPE_FUNCTION|(async?SCOPE_ASYNC:0)|(generator?SCOPE_GENERATOR:0)}var BIND_NONE=0,BIND_VAR=1,BIND_LEXICAL=2,BIND_FUNCTION=3,BIND_SIMPLE_CATCH=4,BIND_OUTSIDE=5,Parser=function(options,input,startPos){this.options=options=getOptions(options),this.sourceFile=options.sourceFile,this.keywords=wordsRegexp(keywords$1[options.ecmaVersion>=6?6:options.sourceType==="module"?"5module":5]);var reserved="";if(options.allowReserved!==!0){if(reserved=reservedWords[options.ecmaVersion>=6?6:options.ecmaVersion===5?5:3],options.sourceType==="module")reserved+=" await"}this.reservedWords=wordsRegexp(reserved);var reservedStrict=(reserved?reserved+" ":"")+reservedWords.strict;if(this.reservedWordsStrict=wordsRegexp(reservedStrict),this.reservedWordsStrictBind=wordsRegexp(reservedStrict+" "+reservedWords.strictBind),this.input=String(input),this.containsEsc=!1,this.pos=startPos||0,this.curLine=1,options.startLocation)this.lineStart=this.pos-options.startLocation.column,this.curLine=options.startLocation.line;else if(startPos){if(this.lineStart=this.input.lastIndexOf(`
|
|
3
|
+
`,startPos-1)+1,this.options.locations)this.curLine=this.input.slice(0,this.lineStart).split(lineBreak).length}else this.lineStart=0;if(this.type=types$1.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=options.sourceType==="module",this.strict=this.inModule||options.strict===!0||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&options.allowHashBang&&this.input.slice(0,2)==="#!")this.skipLineComment(2);this.scopeStack=[],this.enterScope(this.options.sourceType==="commonjs"?SCOPE_FUNCTION:SCOPE_TOP),this.regexpState=null,this.privateNameStack=[]},prototypeAccessors={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};Parser.prototype.parse=function(){var this$1$1=this,node=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return this$1$1.parseTopLevel(node)})};prototypeAccessors.inFunction.get=function(){return(this.currentVarScope().flags&SCOPE_FUNCTION)>0};prototypeAccessors.inGenerator.get=function(){return(this.currentVarScope().flags&SCOPE_GENERATOR)>0};prototypeAccessors.inAsync.get=function(){return(this.currentVarScope().flags&SCOPE_ASYNC)>0};prototypeAccessors.canAwait.get=function(){for(var i=this.scopeStack.length-1;i>=0;i--){var ref=this.scopeStack[i],flags=ref.flags;if(flags&(SCOPE_CLASS_STATIC_BLOCK|SCOPE_CLASS_FIELD_INIT))return!1;if(flags&SCOPE_FUNCTION)return(flags&SCOPE_ASYNC)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};prototypeAccessors.allowReturn.get=function(){if(this.inFunction)return!0;if(this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&SCOPE_TOP)return!0;return!1};prototypeAccessors.allowSuper.get=function(){var ref=this.currentThisScope(),flags=ref.flags;return(flags&SCOPE_SUPER)>0||this.options.allowSuperOutsideMethod};prototypeAccessors.allowDirectSuper.get=function(){return(this.currentThisScope().flags&SCOPE_DIRECT_SUPER)>0};prototypeAccessors.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};prototypeAccessors.allowNewDotTarget.get=function(){for(var i=this.scopeStack.length-1;i>=0;i--){var ref=this.scopeStack[i],flags=ref.flags;if(flags&(SCOPE_CLASS_STATIC_BLOCK|SCOPE_CLASS_FIELD_INIT)||flags&SCOPE_FUNCTION&&!(flags&SCOPE_ARROW))return!0}return!1};prototypeAccessors.allowUsing.get=function(){var ref=this.currentScope(),flags=ref.flags;if(flags&SCOPE_SWITCH)return!1;if(!this.inModule&&flags&SCOPE_TOP)return!1;return!0};prototypeAccessors.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&SCOPE_CLASS_STATIC_BLOCK)>0};Parser.extend=function(){var plugins=[],len=arguments.length;while(len--)plugins[len]=arguments[len];var cls=this;for(var i=0;i<plugins.length;i++)cls=plugins[i](cls);return cls};Parser.parse=function(input,options){return new this(options,input).parse()};Parser.parseExpressionAt=function(input,pos,options){var parser=new this(options,input,pos);return parser.nextToken(),parser.parseExpression()};Parser.tokenizer=function(input,options){return new this(options,input)};Object.defineProperties(Parser.prototype,prototypeAccessors);var pp$9=Parser.prototype,literal=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;pp$9.strictDirective=function(start){if(this.options.ecmaVersion<5)return!1;for(;;){skipWhiteSpace.lastIndex=start,start+=skipWhiteSpace.exec(this.input)[0].length;var match=literal.exec(this.input.slice(start));if(!match)return!1;if((match[1]||match[2])==="use strict"){skipWhiteSpace.lastIndex=start+match[0].length;var spaceAfter=skipWhiteSpace.exec(this.input),end=spaceAfter.index+spaceAfter[0].length,next=this.input.charAt(end);return next===";"||next==="}"||lineBreak.test(spaceAfter[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(next)||next==="!"&&this.input.charAt(end+1)==="=")}if(start+=match[0].length,skipWhiteSpace.lastIndex=start,start+=skipWhiteSpace.exec(this.input)[0].length,this.input[start]===";")start++}};pp$9.eat=function(type){if(this.type===type)return this.next(),!0;else return!1};pp$9.isContextual=function(name){return this.type===types$1.name&&this.value===name&&!this.containsEsc};pp$9.eatContextual=function(name){if(!this.isContextual(name))return!1;return this.next(),!0};pp$9.catchStackOverflow=function(f){try{return f()}catch(e){if(e instanceof Error&&(/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message)||/\btoo much recursion\b/i.test(e.message)))this.raise(this.start,"Not enough stack space to parse input");else throw e}};pp$9.expectContextual=function(name){if(!this.eatContextual(name))this.unexpected()};pp$9.canInsertSemicolon=function(){return this.type===types$1.eof||this.type===types$1.braceR||lineBreak.test(this.input.slice(this.lastTokEnd,this.start))};pp$9.insertSemicolon=function(){if(this.canInsertSemicolon()){if(this.options.onInsertedSemicolon)this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc);return!0}};pp$9.semicolon=function(){if(!this.eat(types$1.semi)&&!this.insertSemicolon())this.unexpected()};pp$9.afterTrailingComma=function(tokType,notNext){if(this.type===tokType){if(this.options.onTrailingComma)this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc);if(!notNext)this.next();return!0}};pp$9.expect=function(type){this.eat(type)||this.unexpected()};pp$9.unexpected=function(pos){this.raise(pos!=null?pos:this.start,"Unexpected token")};var DestructuringErrors=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};pp$9.checkPatternErrors=function(refDestructuringErrors,isAssign){if(!refDestructuringErrors)return;if(refDestructuringErrors.trailingComma>-1)this.raiseRecoverable(refDestructuringErrors.trailingComma,"Comma is not permitted after the rest element");var parens=isAssign?refDestructuringErrors.parenthesizedAssign:refDestructuringErrors.parenthesizedBind;if(parens>-1)this.raiseRecoverable(parens,isAssign?"Assigning to rvalue":"Parenthesized pattern")};pp$9.checkExpressionErrors=function(refDestructuringErrors,andThrow){if(!refDestructuringErrors)return!1;var{shorthandAssign,doubleProto}=refDestructuringErrors;if(!andThrow)return shorthandAssign>=0||doubleProto>=0;if(shorthandAssign>=0)this.raise(shorthandAssign,"Shorthand property assignments are valid only in destructuring patterns");if(doubleProto>=0)this.raiseRecoverable(doubleProto,"Redefinition of __proto__ property")};pp$9.checkYieldAwaitInDefaultParams=function(){if(this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos))this.raise(this.yieldPos,"Yield expression cannot be a default value");if(this.awaitPos)this.raise(this.awaitPos,"Await expression cannot be a default value")};pp$9.isSimpleAssignTarget=function(expr){if(expr.type==="ParenthesizedExpression")return this.isSimpleAssignTarget(expr.expression);return expr.type==="Identifier"||expr.type==="MemberExpression"};var pp$8=Parser.prototype;pp$8.parseTopLevel=function(node){var exports$1=Object.create(null);if(!node.body)node.body=[];while(this.type!==types$1.eof){var stmt=this.parseStatement(null,!0,exports$1);node.body.push(stmt)}if(this.inModule)for(var i=0,list=Object.keys(this.undefinedExports);i<list.length;i+=1){var name=list[i];this.raiseRecoverable(this.undefinedExports[name].start,"Export '"+name+"' is not defined")}return this.adaptDirectivePrologue(node.body),this.next(),node.sourceType=this.options.sourceType==="commonjs"?"script":this.options.sourceType,this.finishNode(node,"Program")};var loopLabel={kind:"loop"},switchLabel={kind:"switch"};pp$8.isLet=function(context){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;skipWhiteSpace.lastIndex=this.pos;var skip=skipWhiteSpace.exec(this.input),next=this.pos+skip[0].length,nextCh=this.fullCharCodeAt(next);if(nextCh===91||nextCh===92)return!0;if(context)return!1;if(nextCh===123)return!0;if(isIdentifierStart(nextCh)){var start=next;do next+=nextCh<=65535?1:2;while(isIdentifierChar(nextCh=this.fullCharCodeAt(next)));if(nextCh===92)return!0;var ident=this.input.slice(start,next);if(!keywordRelationalOperator.test(ident))return!0}return!1};pp$8.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;skipWhiteSpace.lastIndex=this.pos;var skip=skipWhiteSpace.exec(this.input),next=this.pos+skip[0].length,after;return!lineBreak.test(this.input.slice(this.pos,next))&&this.input.slice(next,next+8)==="function"&&(next+8===this.input.length||!(isIdentifierChar(after=this.fullCharCodeAt(next+8))||after===92))};pp$8.isUsingKeyword=function(isAwaitUsing,isFor){if(this.options.ecmaVersion<17||!this.isContextual(isAwaitUsing?"await":"using"))return!1;skipWhiteSpace.lastIndex=this.pos;var skip=skipWhiteSpace.exec(this.input),next=this.pos+skip[0].length;if(lineBreak.test(this.input.slice(this.pos,next)))return!1;if(isAwaitUsing){var usingEndPos=next+5,after;if(this.input.slice(next,usingEndPos)!=="using"||usingEndPos===this.input.length||isIdentifierChar(after=this.fullCharCodeAt(usingEndPos))||after===92)return!1;skipWhiteSpace.lastIndex=usingEndPos;var skipAfterUsing=skipWhiteSpace.exec(this.input);if(next=usingEndPos+skipAfterUsing[0].length,skipAfterUsing&&lineBreak.test(this.input.slice(usingEndPos,next)))return!1}var ch=this.fullCharCodeAt(next);if(!isIdentifierStart(ch)&&ch!==92)return!1;var idStart=next;do next+=ch<=65535?1:2;while(isIdentifierChar(ch=this.fullCharCodeAt(next)));if(ch===92)return!0;var id=this.input.slice(idStart,next);if(keywordRelationalOperator.test(id))return!1;if(isFor&&!isAwaitUsing&&id==="of"){skipWhiteSpace.lastIndex=next;var skipAfterOf=skipWhiteSpace.exec(this.input);if(next=next+skipAfterOf[0].length,this.input.charCodeAt(next)!==61||(ch=this.input.charCodeAt(next+1))===61||ch===62)return!1}return!0};pp$8.isAwaitUsing=function(isFor){return this.isUsingKeyword(!0,isFor)};pp$8.isUsing=function(isFor){return this.isUsingKeyword(!1,isFor)};pp$8.parseStatement=function(context,topLevel,exports$1){var starttype=this.type,node=this.startNode(),kind;if(this.isLet(context))starttype=types$1._var,kind="let";switch(starttype){case types$1._break:case types$1._continue:return this.parseBreakContinueStatement(node,starttype.keyword);case types$1._debugger:return this.parseDebuggerStatement(node);case types$1._do:return this.parseDoStatement(node);case types$1._for:return this.parseForStatement(node);case types$1._function:if(context&&(this.strict||context!=="if"&&context!=="label")&&this.options.ecmaVersion>=6)this.unexpected();return this.parseFunctionStatement(node,!1,!context);case types$1._class:if(context)this.unexpected();return this.parseClass(node,!0);case types$1._if:return this.parseIfStatement(node);case types$1._return:return this.parseReturnStatement(node);case types$1._switch:return this.parseSwitchStatement(node);case types$1._throw:return this.parseThrowStatement(node);case types$1._try:return this.parseTryStatement(node);case types$1._const:case types$1._var:if(kind=kind||this.value,context&&kind!=="var")this.unexpected();return this.parseVarStatement(node,kind);case types$1._while:return this.parseWhileStatement(node);case types$1._with:return this.parseWithStatement(node);case types$1.braceL:return this.parseBlock(!0,node);case types$1.semi:return this.parseEmptyStatement(node);case types$1._export:case types$1._import:if(this.options.ecmaVersion>10&&starttype===types$1._import){skipWhiteSpace.lastIndex=this.pos;var skip=skipWhiteSpace.exec(this.input),next=this.pos+skip[0].length,nextCh=this.input.charCodeAt(next);if(nextCh===40||nextCh===46)return this.parseExpressionStatement(node,this.parseExpression())}if(!this.options.allowImportExportEverywhere){if(!topLevel)this.raise(this.start,"'import' and 'export' may only appear at the top level");if(!this.inModule)this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")}return starttype===types$1._import?this.parseImport(node):this.parseExport(node,exports$1);default:if(this.isAsyncFunction()){if(context)this.unexpected();return this.next(),this.parseFunctionStatement(node,!0,!context)}var usingKind=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(usingKind){if(!this.allowUsing)this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement");if(context)this.raise(this.start,"Using declaration is not allowed in single-statement positions");if(usingKind==="await using"){if(!this.canAwait)this.raise(this.start,"Await using cannot appear outside of async function");this.next()}return this.next(),this.parseVar(node,!1,usingKind),this.semicolon(),this.finishNode(node,"VariableDeclaration")}var maybeName=this.value,expr=this.parseExpression();if(starttype===types$1.name&&expr.type==="Identifier"&&this.eat(types$1.colon))return this.parseLabeledStatement(node,maybeName,expr,context);else return this.parseExpressionStatement(node,expr)}};pp$8.parseBreakContinueStatement=function(node,keyword){var isBreak=keyword==="break";if(this.next(),this.eat(types$1.semi)||this.insertSemicolon())node.label=null;else if(this.type!==types$1.name)this.unexpected();else node.label=this.parseIdent(),this.semicolon();var i=0;for(;i<this.labels.length;++i){var lab=this.labels[i];if(node.label==null||lab.name===node.label.name){if(lab.kind!=null&&(isBreak||lab.kind==="loop"))break;if(node.label&&isBreak)break}}if(i===this.labels.length)this.raise(node.start,"Unsyntactic "+keyword);return this.finishNode(node,isBreak?"BreakStatement":"ContinueStatement")};pp$8.parseDebuggerStatement=function(node){return this.next(),this.semicolon(),this.finishNode(node,"DebuggerStatement")};pp$8.parseDoStatement=function(node){if(this.next(),this.labels.push(loopLabel),node.body=this.parseStatement("do"),this.labels.pop(),this.expect(types$1._while),node.test=this.parseParenExpression(),this.options.ecmaVersion>=6)this.eat(types$1.semi);else this.semicolon();return this.finishNode(node,"DoWhileStatement")};pp$8.parseForStatement=function(node){this.next();var awaitAt=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(loopLabel),this.enterScope(0),this.expect(types$1.parenL),this.type===types$1.semi){if(awaitAt>-1)this.unexpected(awaitAt);return this.parseFor(node,null)}var isLet=this.isLet();if(this.type===types$1._var||this.type===types$1._const||isLet){var init$1=this.startNode(),kind=isLet?"let":this.value;return this.next(),this.parseVar(init$1,!0,kind),this.finishNode(init$1,"VariableDeclaration"),this.parseForAfterInit(node,init$1,awaitAt)}var startsWithLet=this.isContextual("let"),isForOf=!1,usingKind=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(usingKind){var init$2=this.startNode();if(this.next(),usingKind==="await using"){if(!this.canAwait)this.raise(this.start,"Await using cannot appear outside of async function");this.next()}return this.parseVar(init$2,!0,usingKind),this.finishNode(init$2,"VariableDeclaration"),this.parseForAfterInit(node,init$2,awaitAt)}var containsEsc=this.containsEsc,refDestructuringErrors=new DestructuringErrors,initPos=this.start,init=awaitAt>-1?this.parseExprSubscripts(refDestructuringErrors,"await"):this.parseExpression(!0,refDestructuringErrors);if(this.type===types$1._in||(isForOf=this.options.ecmaVersion>=6&&this.isContextual("of"))){if(awaitAt>-1){if(this.type===types$1._in)this.unexpected(awaitAt);node.await=!0}else if(isForOf&&this.options.ecmaVersion>=8){if(init.start===initPos&&!containsEsc&&init.type==="Identifier"&&init.name==="async")this.unexpected();else if(this.options.ecmaVersion>=9)node.await=!1}if(startsWithLet&&isForOf)this.raise(init.start,"The left-hand side of a for-of loop may not start with 'let'.");return this.toAssignable(init,!1,refDestructuringErrors),this.checkLValPattern(init),this.parseForIn(node,init)}else this.checkExpressionErrors(refDestructuringErrors,!0);if(awaitAt>-1)this.unexpected(awaitAt);return this.parseFor(node,init)};pp$8.parseForAfterInit=function(node,init,awaitAt){if((this.type===types$1._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&init.declarations.length===1){if(this.type===types$1._in){if((init.kind==="using"||init.kind==="await using")&&!init.declarations[0].init)this.raise(this.start,"Using declaration is not allowed in for-in loops");if(this.options.ecmaVersion>=9&&awaitAt>-1)this.unexpected(awaitAt)}else if(this.options.ecmaVersion>=9)node.await=awaitAt>-1;return this.parseForIn(node,init)}if(awaitAt>-1)this.unexpected(awaitAt);return this.parseFor(node,init)};pp$8.parseFunctionStatement=function(node,isAsync,declarationPosition){return this.next(),this.parseFunction(node,FUNC_STATEMENT|(declarationPosition?0:FUNC_HANGING_STATEMENT),!1,isAsync)};pp$8.parseIfStatement=function(node){return this.next(),node.test=this.parseParenExpression(),node.consequent=this.parseStatement("if"),node.alternate=this.eat(types$1._else)?this.parseStatement("if"):null,this.finishNode(node,"IfStatement")};pp$8.parseReturnStatement=function(node){if(!this.allowReturn)this.raise(this.start,"'return' outside of function");if(this.next(),this.eat(types$1.semi)||this.insertSemicolon())node.argument=null;else node.argument=this.parseExpression(),this.semicolon();return this.finishNode(node,"ReturnStatement")};pp$8.parseSwitchStatement=function(node){this.next(),node.discriminant=this.parseParenExpression(),node.cases=[],this.expect(types$1.braceL),this.labels.push(switchLabel),this.enterScope(SCOPE_SWITCH);var cur;for(var sawDefault=!1;this.type!==types$1.braceR;)if(this.type===types$1._case||this.type===types$1._default){var isCase=this.type===types$1._case;if(cur)this.finishNode(cur,"SwitchCase");if(node.cases.push(cur=this.startNode()),cur.consequent=[],this.next(),isCase)cur.test=this.parseExpression();else{if(sawDefault)this.raiseRecoverable(this.lastTokStart,"Multiple default clauses");sawDefault=!0,cur.test=null}this.expect(types$1.colon)}else{if(!cur)this.unexpected();cur.consequent.push(this.parseStatement(null))}if(this.exitScope(),cur)this.finishNode(cur,"SwitchCase");return this.next(),this.labels.pop(),this.finishNode(node,"SwitchStatement")};pp$8.parseThrowStatement=function(node){if(this.next(),lineBreak.test(this.input.slice(this.lastTokEnd,this.start)))this.raise(this.lastTokEnd,"Illegal newline after throw");return node.argument=this.parseExpression(),this.semicolon(),this.finishNode(node,"ThrowStatement")};var empty$1=[];pp$8.parseCatchClauseParam=function(){var param=this.parseBindingAtom(),simple=param.type==="Identifier";return this.enterScope(simple?SCOPE_SIMPLE_CATCH:0),this.checkLValPattern(param,simple?BIND_SIMPLE_CATCH:BIND_LEXICAL),this.expect(types$1.parenR),param};pp$8.parseTryStatement=function(node){if(this.next(),node.block=this.parseBlock(),node.handler=null,this.type===types$1._catch){var clause=this.startNode();if(this.next(),this.eat(types$1.parenL))clause.param=this.parseCatchClauseParam();else{if(this.options.ecmaVersion<10)this.unexpected();clause.param=null,this.enterScope(0)}clause.body=this.parseBlock(!1),this.exitScope(),node.handler=this.finishNode(clause,"CatchClause")}if(node.finalizer=this.eat(types$1._finally)?this.parseBlock():null,!node.handler&&!node.finalizer)this.raise(node.start,"Missing catch or finally clause");return this.finishNode(node,"TryStatement")};pp$8.parseVarStatement=function(node,kind,allowMissingInitializer){return this.next(),this.parseVar(node,!1,kind,allowMissingInitializer),this.semicolon(),this.finishNode(node,"VariableDeclaration")};pp$8.parseWhileStatement=function(node){return this.next(),node.test=this.parseParenExpression(),this.labels.push(loopLabel),node.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(node,"WhileStatement")};pp$8.parseWithStatement=function(node){if(this.strict)this.raise(this.start,"'with' in strict mode");return this.next(),node.object=this.parseParenExpression(),node.body=this.parseStatement("with"),this.finishNode(node,"WithStatement")};pp$8.parseEmptyStatement=function(node){return this.next(),this.finishNode(node,"EmptyStatement")};pp$8.parseLabeledStatement=function(node,maybeName,expr,context){for(var i$1=0,list=this.labels;i$1<list.length;i$1+=1){var label=list[i$1];if(label.name===maybeName)this.raise(expr.start,"Label '"+maybeName+"' is already declared")}var kind=this.type.isLoop?"loop":this.type===types$1._switch?"switch":null;for(var i=this.labels.length-1;i>=0;i--){var label$1=this.labels[i];if(label$1.statementStart===node.start)label$1.statementStart=this.start,label$1.kind=kind;else break}return this.labels.push({name:maybeName,kind,statementStart:this.start}),node.body=this.parseStatement(context?context.indexOf("label")===-1?context+"label":context:"label"),this.labels.pop(),node.label=expr,this.finishNode(node,"LabeledStatement")};pp$8.parseExpressionStatement=function(node,expr){return node.expression=expr,this.semicolon(),this.finishNode(node,"ExpressionStatement")};pp$8.parseBlock=function(createNewLexicalScope,node,exitStrict){if(createNewLexicalScope===void 0)createNewLexicalScope=!0;if(node===void 0)node=this.startNode();if(node.body=[],this.expect(types$1.braceL),createNewLexicalScope)this.enterScope(0);while(this.type!==types$1.braceR){var stmt=this.parseStatement(null);node.body.push(stmt)}if(exitStrict)this.strict=!1;if(this.next(),createNewLexicalScope)this.exitScope();return this.finishNode(node,"BlockStatement")};pp$8.parseFor=function(node,init){return node.init=init,this.expect(types$1.semi),node.test=this.type===types$1.semi?null:this.parseExpression(),this.expect(types$1.semi),node.update=this.type===types$1.parenR?null:this.parseExpression(),this.expect(types$1.parenR),node.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(node,"ForStatement")};pp$8.parseForIn=function(node,init){var isForIn=this.type===types$1._in;if(this.next(),init.type==="VariableDeclaration"&&init.declarations[0].init!=null&&(!isForIn||this.options.ecmaVersion<8||this.strict||init.kind!=="var"||init.declarations[0].id.type!=="Identifier"))this.raise(init.start,(isForIn?"for-in":"for-of")+" loop variable declaration may not have an initializer");return node.left=init,node.right=isForIn?this.parseExpression():this.parseMaybeAssign(),this.expect(types$1.parenR),node.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(node,isForIn?"ForInStatement":"ForOfStatement")};pp$8.parseVar=function(node,isFor,kind,allowMissingInitializer){node.declarations=[],node.kind=kind;for(;;){var decl=this.startNode();if(this.parseVarId(decl,kind),this.eat(types$1.eq))decl.init=this.parseMaybeAssign(isFor);else if(!allowMissingInitializer&&kind==="const"&&!(this.type===types$1._in||this.options.ecmaVersion>=6&&this.isContextual("of")))this.unexpected();else if(!allowMissingInitializer&&(kind==="using"||kind==="await using")&&this.options.ecmaVersion>=17&&this.type!==types$1._in&&!this.isContextual("of"))this.raise(this.lastTokEnd,"Missing initializer in "+kind+" declaration");else if(!allowMissingInitializer&&decl.id.type!=="Identifier"&&!(isFor&&(this.type===types$1._in||this.isContextual("of"))))this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value");else decl.init=null;if(node.declarations.push(this.finishNode(decl,"VariableDeclarator")),!this.eat(types$1.comma))break}return node};pp$8.parseVarId=function(decl,kind){decl.id=kind==="using"||kind==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(decl.id,kind==="var"?BIND_VAR:BIND_LEXICAL,!1)};var FUNC_STATEMENT=1,FUNC_HANGING_STATEMENT=2,FUNC_NULLABLE_ID=4;pp$8.parseFunction=function(node,statement,allowExpressionBody,isAsync,forInit){if(this.initFunction(node),this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!isAsync){if(this.type===types$1.star&&statement&FUNC_HANGING_STATEMENT)this.unexpected();node.generator=this.eat(types$1.star)}if(this.options.ecmaVersion>=8)node.async=!!isAsync;if(statement&FUNC_STATEMENT){if(node.id=statement&FUNC_NULLABLE_ID&&this.type!==types$1.name?null:this.parseIdent(),node.id&&!(statement&FUNC_HANGING_STATEMENT))this.checkLValSimple(node.id,this.strict||node.generator||node.async?this.treatFunctionsAsVar?BIND_VAR:BIND_LEXICAL:BIND_FUNCTION)}var oldYieldPos=this.yieldPos,oldAwaitPos=this.awaitPos,oldAwaitIdentPos=this.awaitIdentPos;if(this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(functionFlags(node.async,node.generator)),!(statement&FUNC_STATEMENT))node.id=this.type===types$1.name?this.parseIdent():null;return this.parseFunctionParams(node),this.parseFunctionBody(node,allowExpressionBody,!1,forInit),this.yieldPos=oldYieldPos,this.awaitPos=oldAwaitPos,this.awaitIdentPos=oldAwaitIdentPos,this.finishNode(node,statement&FUNC_STATEMENT?"FunctionDeclaration":"FunctionExpression")};pp$8.parseFunctionParams=function(node){this.expect(types$1.parenL),node.params=this.parseBindingList(types$1.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};pp$8.parseClass=function(node,isStatement){this.next();var oldStrict=this.strict;this.strict=!0,this.parseClassId(node,isStatement),this.parseClassSuper(node);var privateNameMap=this.enterClassBody(),classBody=this.startNode(),hadConstructor=!1;classBody.body=[],this.expect(types$1.braceL);while(this.type!==types$1.braceR){var element=this.parseClassElement(node.superClass!==null);if(element){if(classBody.body.push(element),element.type==="MethodDefinition"&&element.kind==="constructor"){if(hadConstructor)this.raiseRecoverable(element.start,"Duplicate constructor in the same class");hadConstructor=!0}else if(element.key&&element.key.type==="PrivateIdentifier"&&isPrivateNameConflicted(privateNameMap,element))this.raiseRecoverable(element.key.start,"Identifier '#"+element.key.name+"' has already been declared")}}return this.strict=oldStrict,this.next(),node.body=this.finishNode(classBody,"ClassBody"),this.exitClassBody(),this.finishNode(node,isStatement?"ClassDeclaration":"ClassExpression")};pp$8.parseClassElement=function(constructorAllowsSuper){if(this.eat(types$1.semi))return null;var ecmaVersion=this.options.ecmaVersion,node=this.startNode(),keyName="",isGenerator=!1,isAsync=!1,kind="method",isStatic=!1;if(this.eatContextual("static")){if(ecmaVersion>=13&&this.eat(types$1.braceL))return this.parseClassStaticBlock(node),node;if(this.isClassElementNameStart()||this.type===types$1.star)isStatic=!0;else keyName="static"}if(node.static=isStatic,!keyName&&ecmaVersion>=8&&this.eatContextual("async"))if((this.isClassElementNameStart()||this.type===types$1.star)&&!this.canInsertSemicolon())isAsync=!0;else keyName="async";if(!keyName&&(ecmaVersion>=9||!isAsync)&&this.eat(types$1.star))isGenerator=!0;if(!keyName&&!isAsync&&!isGenerator){var lastValue=this.value;if(this.eatContextual("get")||this.eatContextual("set"))if(this.isClassElementNameStart())kind=lastValue;else keyName=lastValue}if(keyName)node.computed=!1,node.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),node.key.name=keyName,this.finishNode(node.key,"Identifier");else this.parseClassElementName(node);if(ecmaVersion<13||this.type===types$1.parenL||kind!=="method"||isGenerator||isAsync){var isConstructor=!node.static&&checkKeyName(node,"constructor"),allowsDirectSuper=isConstructor&&constructorAllowsSuper;if(isConstructor&&kind!=="method")this.raise(node.key.start,"Constructor can't have get/set modifier");node.kind=isConstructor?"constructor":kind,this.parseClassMethod(node,isGenerator,isAsync,allowsDirectSuper)}else this.parseClassField(node);return node};pp$8.isClassElementNameStart=function(){return this.type===types$1.name||this.type===types$1.privateId||this.type===types$1.num||this.type===types$1.string||this.type===types$1.bracketL||this.type.keyword};pp$8.parseClassElementName=function(element){if(this.type===types$1.privateId){if(this.value==="constructor")this.raise(this.start,"Classes can't have an element named '#constructor'");element.computed=!1,element.key=this.parsePrivateIdent()}else this.parsePropertyName(element)};pp$8.parseClassMethod=function(method,isGenerator,isAsync,allowsDirectSuper){var key=method.key;if(method.kind==="constructor"){if(isGenerator)this.raise(key.start,"Constructor can't be a generator");if(isAsync)this.raise(key.start,"Constructor can't be an async method")}else if(method.static&&checkKeyName(method,"prototype"))this.raise(key.start,"Classes may not have a static property named prototype");var value=method.value=this.parseMethod(isGenerator,isAsync,allowsDirectSuper);if(method.kind==="get"&&value.params.length!==0)this.raiseRecoverable(value.start,"getter should have no params");if(method.kind==="set"&&value.params.length!==1)this.raiseRecoverable(value.start,"setter should have exactly one param");if(method.kind==="set"&&value.params[0].type==="RestElement")this.raiseRecoverable(value.params[0].start,"Setter cannot use rest params");return this.finishNode(method,"MethodDefinition")};pp$8.parseClassField=function(field){if(checkKeyName(field,"constructor"))this.raise(field.key.start,"Classes can't have a field named 'constructor'");else if(field.static&&checkKeyName(field,"prototype"))this.raise(field.key.start,"Classes can't have a static field named 'prototype'");if(this.eat(types$1.eq))this.enterScope(SCOPE_CLASS_FIELD_INIT|SCOPE_SUPER),field.value=this.parseMaybeAssign(),this.exitScope();else field.value=null;return this.semicolon(),this.finishNode(field,"PropertyDefinition")};pp$8.parseClassStaticBlock=function(node){node.body=[];var oldLabels=this.labels;this.labels=[],this.enterScope(SCOPE_CLASS_STATIC_BLOCK|SCOPE_SUPER);while(this.type!==types$1.braceR){var stmt=this.parseStatement(null);node.body.push(stmt)}return this.next(),this.exitScope(),this.labels=oldLabels,this.finishNode(node,"StaticBlock")};pp$8.parseClassId=function(node,isStatement){if(this.type===types$1.name){if(node.id=this.parseIdent(),isStatement)this.checkLValSimple(node.id,BIND_LEXICAL,!1)}else{if(isStatement===!0)this.unexpected();node.id=null}};pp$8.parseClassSuper=function(node){node.superClass=this.eat(types$1._extends)?this.parseExprSubscripts(null,!1):null};pp$8.enterClassBody=function(){var element={declared:Object.create(null),used:[]};return this.privateNameStack.push(element),element.declared};pp$8.exitClassBody=function(){var ref=this.privateNameStack.pop(),{declared,used}=ref;if(!this.options.checkPrivateFields)return;var len=this.privateNameStack.length,parent=len===0?null:this.privateNameStack[len-1];for(var i=0;i<used.length;++i){var id=used[i];if(!hasOwn(declared,id.name))if(parent)parent.used.push(id);else this.raiseRecoverable(id.start,"Private field '#"+id.name+"' must be declared in an enclosing class")}};function isPrivateNameConflicted(privateNameMap,element){var name=element.key.name,curr=privateNameMap[name],next="true";if(element.type==="MethodDefinition"&&(element.kind==="get"||element.kind==="set"))next=(element.static?"s":"i")+element.kind;if(curr==="iget"&&next==="iset"||curr==="iset"&&next==="iget"||curr==="sget"&&next==="sset"||curr==="sset"&&next==="sget")return privateNameMap[name]="true",!1;else if(!curr)return privateNameMap[name]=next,!1;else return!0}function checkKeyName(node,name){var{computed,key}=node;return!computed&&(key.type==="Identifier"&&key.name===name||key.type==="Literal"&&key.value===name)}pp$8.parseExportAllDeclaration=function(node,exports$1){if(this.options.ecmaVersion>=11)if(this.eatContextual("as"))node.exported=this.parseModuleExportName(),this.checkExport(exports$1,node.exported,this.lastTokStart);else node.exported=null;if(this.expectContextual("from"),this.type!==types$1.string)this.unexpected();if(node.source=this.parseExprAtom(),this.options.ecmaVersion>=16)node.attributes=this.parseWithClause();return this.semicolon(),this.finishNode(node,"ExportAllDeclaration")};pp$8.parseExport=function(node,exports$1){if(this.next(),this.eat(types$1.star))return this.parseExportAllDeclaration(node,exports$1);if(this.eat(types$1._default))return this.checkExport(exports$1,"default",this.lastTokStart),node.declaration=this.parseExportDefaultDeclaration(),this.finishNode(node,"ExportDefaultDeclaration");if(this.shouldParseExportStatement()){if(node.declaration=this.parseExportDeclaration(node),node.declaration.type==="VariableDeclaration")this.checkVariableExport(exports$1,node.declaration.declarations);else this.checkExport(exports$1,node.declaration.id,node.declaration.id.start);if(node.specifiers=[],node.source=null,this.options.ecmaVersion>=16)node.attributes=[]}else{if(node.declaration=null,node.specifiers=this.parseExportSpecifiers(exports$1),this.eatContextual("from")){if(this.type!==types$1.string)this.unexpected();if(node.source=this.parseExprAtom(),this.options.ecmaVersion>=16)node.attributes=this.parseWithClause()}else{for(var i=0,list=node.specifiers;i<list.length;i+=1){var spec=list[i];if(this.checkUnreserved(spec.local),this.checkLocalExport(spec.local),spec.local.type==="Literal")this.raise(spec.local.start,"A string literal cannot be used as an exported binding without `from`.")}if(node.source=null,this.options.ecmaVersion>=16)node.attributes=[]}this.semicolon()}return this.finishNode(node,"ExportNamedDeclaration")};pp$8.parseExportDeclaration=function(node){return this.parseStatement(null)};pp$8.parseExportDefaultDeclaration=function(){var isAsync;if(this.type===types$1._function||(isAsync=this.isAsyncFunction())){var fNode=this.startNode();if(this.next(),isAsync)this.next();return this.parseFunction(fNode,FUNC_STATEMENT|FUNC_NULLABLE_ID,!1,isAsync)}else if(this.type===types$1._class){var cNode=this.startNode();return this.parseClass(cNode,"nullableID")}else{var declaration=this.parseMaybeAssign();return this.semicolon(),declaration}};pp$8.checkExport=function(exports$1,name,pos){if(!exports$1)return;if(typeof name!=="string")name=name.type==="Identifier"?name.name:name.value;if(hasOwn(exports$1,name))this.raiseRecoverable(pos,"Duplicate export '"+name+"'");exports$1[name]=!0};pp$8.checkPatternExport=function(exports$1,pat){var type=pat.type;if(type==="Identifier")this.checkExport(exports$1,pat,pat.start);else if(type==="ObjectPattern")for(var i=0,list=pat.properties;i<list.length;i+=1){var prop=list[i];this.checkPatternExport(exports$1,prop)}else if(type==="ArrayPattern")for(var i$1=0,list$1=pat.elements;i$1<list$1.length;i$1+=1){var elt=list$1[i$1];if(elt)this.checkPatternExport(exports$1,elt)}else if(type==="Property")this.checkPatternExport(exports$1,pat.value);else if(type==="AssignmentPattern")this.checkPatternExport(exports$1,pat.left);else if(type==="RestElement")this.checkPatternExport(exports$1,pat.argument)};pp$8.checkVariableExport=function(exports$1,decls){if(!exports$1)return;for(var i=0,list=decls;i<list.length;i+=1){var decl=list[i];this.checkPatternExport(exports$1,decl.id)}};pp$8.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};pp$8.parseExportSpecifier=function(exports$1){var node=this.startNode();return node.local=this.parseModuleExportName(),node.exported=this.eatContextual("as")?this.parseModuleExportName():node.local,this.checkExport(exports$1,node.exported,node.exported.start),this.finishNode(node,"ExportSpecifier")};pp$8.parseExportSpecifiers=function(exports$1){var nodes=[],first=!0;this.expect(types$1.braceL);while(!this.eat(types$1.braceR)){if(!first){if(this.expect(types$1.comma),this.afterTrailingComma(types$1.braceR))break}else first=!1;nodes.push(this.parseExportSpecifier(exports$1))}return nodes};pp$8.parseImport=function(node){if(this.next(),this.type===types$1.string)node.specifiers=empty$1,node.source=this.parseExprAtom();else node.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),node.source=this.type===types$1.string?this.parseExprAtom():this.unexpected();if(this.options.ecmaVersion>=16)node.attributes=this.parseWithClause();return this.semicolon(),this.finishNode(node,"ImportDeclaration")};pp$8.parseImportSpecifier=function(){var node=this.startNode();if(node.imported=this.parseModuleExportName(),this.eatContextual("as"))node.local=this.parseIdent();else this.checkUnreserved(node.imported),node.local=node.imported;return this.checkLValSimple(node.local,BIND_LEXICAL),this.finishNode(node,"ImportSpecifier")};pp$8.parseImportDefaultSpecifier=function(){var node=this.startNode();return node.local=this.parseIdent(),this.checkLValSimple(node.local,BIND_LEXICAL),this.finishNode(node,"ImportDefaultSpecifier")};pp$8.parseImportNamespaceSpecifier=function(){var node=this.startNode();return this.next(),this.expectContextual("as"),node.local=this.parseIdent(),this.checkLValSimple(node.local,BIND_LEXICAL),this.finishNode(node,"ImportNamespaceSpecifier")};pp$8.parseImportSpecifiers=function(){var nodes=[],first=!0;if(this.type===types$1.name){if(nodes.push(this.parseImportDefaultSpecifier()),!this.eat(types$1.comma))return nodes}if(this.type===types$1.star)return nodes.push(this.parseImportNamespaceSpecifier()),nodes;this.expect(types$1.braceL);while(!this.eat(types$1.braceR)){if(!first){if(this.expect(types$1.comma),this.afterTrailingComma(types$1.braceR))break}else first=!1;nodes.push(this.parseImportSpecifier())}return nodes};pp$8.parseWithClause=function(){var nodes=[];if(!this.eat(types$1._with))return nodes;this.expect(types$1.braceL);var attributeKeys={},first=!0;while(!this.eat(types$1.braceR)){if(!first){if(this.expect(types$1.comma),this.afterTrailingComma(types$1.braceR))break}else first=!1;var attr=this.parseImportAttribute(),keyName=attr.key.type==="Identifier"?attr.key.name:attr.key.value;if(hasOwn(attributeKeys,keyName))this.raiseRecoverable(attr.key.start,"Duplicate attribute key '"+keyName+"'");attributeKeys[keyName]=!0,nodes.push(attr)}return nodes};pp$8.parseImportAttribute=function(){var node=this.startNode();if(node.key=this.type===types$1.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(types$1.colon),this.type!==types$1.string)this.unexpected();return node.value=this.parseExprAtom(),this.finishNode(node,"ImportAttribute")};pp$8.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===types$1.string){var stringLiteral=this.parseLiteral(this.value);if(loneSurrogate.test(stringLiteral.value))this.raise(stringLiteral.start,"An export name cannot include a lone surrogate.");return stringLiteral}return this.parseIdent(!0)};pp$8.adaptDirectivePrologue=function(statements){for(var i=0;i<statements.length&&this.isDirectiveCandidate(statements[i]);++i)statements[i].directive=statements[i].expression.raw.slice(1,-1)};pp$8.isDirectiveCandidate=function(statement){return this.options.ecmaVersion>=5&&statement.type==="ExpressionStatement"&&statement.expression.type==="Literal"&&typeof statement.expression.value==="string"&&(this.input[statement.start]==='"'||this.input[statement.start]==="'")};var pp$7=Parser.prototype;pp$7.toAssignable=function(node,isBinding,refDestructuringErrors){if(this.options.ecmaVersion>=6&&node)switch(node.type){case"Identifier":if(this.inAsync&&node.name==="await")this.raise(node.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":if(node.type="ObjectPattern",refDestructuringErrors)this.checkPatternErrors(refDestructuringErrors,!0);for(var i=0,list=node.properties;i<list.length;i+=1){var prop=list[i];if(this.toAssignable(prop,isBinding),prop.type==="RestElement"&&(prop.argument.type==="ArrayPattern"||prop.argument.type==="ObjectPattern"))this.raise(prop.argument.start,"Unexpected token")}break;case"Property":if(node.kind!=="init")this.raise(node.key.start,"Object pattern can't contain getter or setter");this.toAssignable(node.value,isBinding);break;case"ArrayExpression":if(node.type="ArrayPattern",refDestructuringErrors)this.checkPatternErrors(refDestructuringErrors,!0);this.toAssignableList(node.elements,isBinding);break;case"SpreadElement":if(node.type="RestElement",this.toAssignable(node.argument,isBinding),node.argument.type==="AssignmentPattern")this.raise(node.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":if(node.operator!=="=")this.raise(node.left.end,"Only '=' operator can be used for specifying default value.");node.type="AssignmentPattern",delete node.operator,this.toAssignable(node.left,isBinding);break;case"ParenthesizedExpression":this.toAssignable(node.expression,isBinding,refDestructuringErrors);break;case"ChainExpression":this.raiseRecoverable(node.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!isBinding)break;default:this.raise(node.start,"Assigning to rvalue")}else if(refDestructuringErrors)this.checkPatternErrors(refDestructuringErrors,!0);return node};pp$7.toAssignableList=function(exprList,isBinding){var end=exprList.length;for(var i=0;i<end;i++){var elt=exprList[i];if(elt)this.toAssignable(elt,isBinding)}if(end){var last=exprList[end-1];if(this.options.ecmaVersion===6&&isBinding&&last&&last.type==="RestElement"&&last.argument.type!=="Identifier")this.unexpected(last.argument.start)}return exprList};pp$7.parseSpread=function(refDestructuringErrors){var node=this.startNode();return this.next(),node.argument=this.parseMaybeAssign(!1,refDestructuringErrors),this.finishNode(node,"SpreadElement")};pp$7.parseRestBinding=function(){var node=this.startNode();if(this.next(),this.options.ecmaVersion===6&&this.type!==types$1.name)this.unexpected();return node.argument=this.parseBindingAtom(),this.finishNode(node,"RestElement")};pp$7.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case types$1.bracketL:var node=this.startNode();return this.next(),node.elements=this.parseBindingList(types$1.bracketR,!0,!0),this.finishNode(node,"ArrayPattern");case types$1.braceL:return this.parseObj(!0)}return this.parseIdent()};pp$7.parseBindingList=function(close,allowEmpty,allowTrailingComma,allowModifiers){var elts=[],first=!0;while(!this.eat(close)){if(first)first=!1;else this.expect(types$1.comma);if(allowEmpty&&this.type===types$1.comma)elts.push(null);else if(allowTrailingComma&&this.afterTrailingComma(close))break;else if(this.type===types$1.ellipsis){var rest=this.parseRestBinding();if(this.parseBindingListItem(rest),elts.push(rest),this.type===types$1.comma)this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");this.expect(close);break}else elts.push(this.parseAssignableListItem(allowModifiers))}return elts};pp$7.parseAssignableListItem=function(allowModifiers){var elem=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(elem),elem};pp$7.parseBindingListItem=function(param){return param};pp$7.parseMaybeDefault=function(startPos,startLoc,left){if(left=left||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(types$1.eq))return left;var node=this.startNodeAt(startPos,startLoc);return node.left=left,node.right=this.parseMaybeAssign(),this.finishNode(node,"AssignmentPattern")};pp$7.checkLValSimple=function(expr,bindingType,checkClashes){if(bindingType===void 0)bindingType=BIND_NONE;var isBind=bindingType!==BIND_NONE;switch(expr.type){case"Identifier":if(this.strict&&this.reservedWordsStrictBind.test(expr.name))this.raiseRecoverable(expr.start,(isBind?"Binding ":"Assigning to ")+expr.name+" in strict mode");if(isBind){if(bindingType===BIND_LEXICAL&&expr.name==="let")this.raiseRecoverable(expr.start,"let is disallowed as a lexically bound name");if(checkClashes){if(hasOwn(checkClashes,expr.name))this.raiseRecoverable(expr.start,"Argument name clash");checkClashes[expr.name]=!0}if(bindingType!==BIND_OUTSIDE)this.declareName(expr.name,bindingType,expr.start)}break;case"ChainExpression":this.raiseRecoverable(expr.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(isBind)this.raiseRecoverable(expr.start,"Binding member expression");break;case"ParenthesizedExpression":if(isBind)this.raiseRecoverable(expr.start,"Binding parenthesized expression");return this.checkLValSimple(expr.expression,bindingType,checkClashes);default:this.raise(expr.start,(isBind?"Binding":"Assigning to")+" rvalue")}};pp$7.checkLValPattern=function(expr,bindingType,checkClashes){if(bindingType===void 0)bindingType=BIND_NONE;switch(expr.type){case"ObjectPattern":for(var i=0,list=expr.properties;i<list.length;i+=1){var prop=list[i];this.checkLValInnerPattern(prop,bindingType,checkClashes)}break;case"ArrayPattern":for(var i$1=0,list$1=expr.elements;i$1<list$1.length;i$1+=1){var elem=list$1[i$1];if(elem)this.checkLValInnerPattern(elem,bindingType,checkClashes)}break;default:this.checkLValSimple(expr,bindingType,checkClashes)}};pp$7.checkLValInnerPattern=function(expr,bindingType,checkClashes){if(bindingType===void 0)bindingType=BIND_NONE;switch(expr.type){case"Property":this.checkLValInnerPattern(expr.value,bindingType,checkClashes);break;case"AssignmentPattern":this.checkLValPattern(expr.left,bindingType,checkClashes);break;case"RestElement":this.checkLValPattern(expr.argument,bindingType,checkClashes);break;default:this.checkLValPattern(expr,bindingType,checkClashes)}};var TokContext=function(token,isExpr,preserveSpace,override,generator){this.token=token,this.isExpr=!!isExpr,this.preserveSpace=!!preserveSpace,this.override=override,this.generator=!!generator},types={b_stat:new TokContext("{",!1),b_expr:new TokContext("{",!0),b_tmpl:new TokContext("${",!1),p_stat:new TokContext("(",!1),p_expr:new TokContext("(",!0),q_tmpl:new TokContext("`",!0,!0,function(p){return p.tryReadTemplateToken()}),f_stat:new TokContext("function",!1),f_expr:new TokContext("function",!0),f_expr_gen:new TokContext("function",!0,!1,null,!0),f_gen:new TokContext("function",!1,!1,null,!0)},pp$6=Parser.prototype;pp$6.initialContext=function(){return[types.b_stat]};pp$6.curContext=function(){return this.context[this.context.length-1]};pp$6.braceIsBlock=function(prevType){var parent=this.curContext();if(parent===types.f_expr||parent===types.f_stat)return!0;if(prevType===types$1.colon&&(parent===types.b_stat||parent===types.b_expr))return!parent.isExpr;if(prevType===types$1._return||prevType===types$1.name&&this.exprAllowed)return lineBreak.test(this.input.slice(this.lastTokEnd,this.start));if(prevType===types$1._else||prevType===types$1.semi||prevType===types$1.eof||prevType===types$1.parenR||prevType===types$1.arrow)return!0;if(prevType===types$1.braceL)return parent===types.b_stat;if(prevType===types$1._var||prevType===types$1._const||prevType===types$1.name)return!1;return!this.exprAllowed};pp$6.inGeneratorContext=function(){for(var i=this.context.length-1;i>=1;i--){var context=this.context[i];if(context.token==="function")return context.generator}return!1};pp$6.updateContext=function(prevType){var update,type=this.type;if(type.keyword&&prevType===types$1.dot)this.exprAllowed=!1;else if(update=type.updateContext)update.call(this,prevType);else this.exprAllowed=type.beforeExpr};pp$6.overrideContext=function(tokenCtx){if(this.curContext()!==tokenCtx)this.context[this.context.length-1]=tokenCtx};types$1.parenR.updateContext=types$1.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var out=this.context.pop();if(out===types.b_stat&&this.curContext().token==="function")out=this.context.pop();this.exprAllowed=!out.isExpr};types$1.braceL.updateContext=function(prevType){this.context.push(this.braceIsBlock(prevType)?types.b_stat:types.b_expr),this.exprAllowed=!0};types$1.dollarBraceL.updateContext=function(){this.context.push(types.b_tmpl),this.exprAllowed=!0};types$1.parenL.updateContext=function(prevType){var statementParens=prevType===types$1._if||prevType===types$1._for||prevType===types$1._with||prevType===types$1._while;this.context.push(statementParens?types.p_stat:types.p_expr),this.exprAllowed=!0};types$1.incDec.updateContext=function(){};types$1._function.updateContext=types$1._class.updateContext=function(prevType){if(prevType.beforeExpr&&prevType!==types$1._else&&!(prevType===types$1.semi&&this.curContext()!==types.p_stat)&&!(prevType===types$1._return&&lineBreak.test(this.input.slice(this.lastTokEnd,this.start)))&&!((prevType===types$1.colon||prevType===types$1.braceL)&&this.curContext()===types.b_stat))this.context.push(types.f_expr);else this.context.push(types.f_stat);this.exprAllowed=!1};types$1.colon.updateContext=function(){if(this.curContext().token==="function")this.context.pop();this.exprAllowed=!0};types$1.backQuote.updateContext=function(){if(this.curContext()===types.q_tmpl)this.context.pop();else this.context.push(types.q_tmpl);this.exprAllowed=!1};types$1.star.updateContext=function(prevType){if(prevType===types$1._function){var index=this.context.length-1;if(this.context[index]===types.f_expr)this.context[index]=types.f_expr_gen;else this.context[index]=types.f_gen}this.exprAllowed=!0};types$1.name.updateContext=function(prevType){var allowed=!1;if(this.options.ecmaVersion>=6&&prevType!==types$1.dot){if(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())allowed=!0}this.exprAllowed=allowed};var pp$5=Parser.prototype;pp$5.checkPropClash=function(prop,propHash,refDestructuringErrors){if(this.options.ecmaVersion>=9&&prop.type==="SpreadElement")return;if(this.options.ecmaVersion>=6&&(prop.computed||prop.method||prop.shorthand))return;var key=prop.key,name;switch(key.type){case"Identifier":name=key.name;break;case"Literal":name=String(key.value);break;default:return}var kind=prop.kind;if(this.options.ecmaVersion>=6){if(name==="__proto__"&&kind==="init"){if(propHash.proto)if(refDestructuringErrors){if(refDestructuringErrors.doubleProto<0)refDestructuringErrors.doubleProto=key.start}else this.raiseRecoverable(key.start,"Redefinition of __proto__ property");propHash.proto=!0}return}name="$"+name;var other=propHash[name];if(other){var redefinition;if(kind==="init")redefinition=this.strict&&other.init||other.get||other.set;else redefinition=other.init||other[kind];if(redefinition)this.raiseRecoverable(key.start,"Redefinition of property")}else other=propHash[name]={init:!1,get:!1,set:!1};other[kind]=!0};pp$5.parseExpression=function(forInit,refDestructuringErrors){var this$1$1=this;return this.catchStackOverflow(function(){var{start:startPos,startLoc}=this$1$1,expr=this$1$1.parseMaybeAssign(forInit,refDestructuringErrors);if(this$1$1.type===types$1.comma){var node=this$1$1.startNodeAt(startPos,startLoc);node.expressions=[expr];while(this$1$1.eat(types$1.comma))node.expressions.push(this$1$1.parseMaybeAssign(forInit,refDestructuringErrors));return this$1$1.finishNode(node,"SequenceExpression")}return expr})};pp$5.parseMaybeAssign=function(forInit,refDestructuringErrors,afterLeftParse){if(this.isContextual("yield"))if(this.inGenerator)return this.parseYield(forInit);else this.exprAllowed=!1;var ownDestructuringErrors=!1,oldParenAssign=-1,oldTrailingComma=-1,oldDoubleProto=-1;if(refDestructuringErrors)oldParenAssign=refDestructuringErrors.parenthesizedAssign,oldTrailingComma=refDestructuringErrors.trailingComma,oldDoubleProto=refDestructuringErrors.doubleProto,refDestructuringErrors.parenthesizedAssign=refDestructuringErrors.trailingComma=-1;else refDestructuringErrors=new DestructuringErrors,ownDestructuringErrors=!0;var startPos=this.start,startLoc=this.startLoc;if(this.type===types$1.parenL||this.type===types$1.name)this.potentialArrowAt=this.start,this.potentialArrowInForAwait=forInit==="await";var left=this.parseMaybeConditional(forInit,refDestructuringErrors);if(afterLeftParse)left=afterLeftParse.call(this,left,startPos,startLoc);if(this.type.isAssign){var node=this.startNodeAt(startPos,startLoc);if(node.operator=this.value,this.type===types$1.eq)left=this.toAssignable(left,!1,refDestructuringErrors);if(!ownDestructuringErrors)refDestructuringErrors.parenthesizedAssign=refDestructuringErrors.trailingComma=refDestructuringErrors.doubleProto=-1;if(refDestructuringErrors.shorthandAssign>=left.start)refDestructuringErrors.shorthandAssign=-1;if(this.type===types$1.eq)this.checkLValPattern(left);else this.checkLValSimple(left);if(node.left=left,this.next(),node.right=this.parseMaybeAssign(forInit),oldDoubleProto>-1)refDestructuringErrors.doubleProto=oldDoubleProto;return this.finishNode(node,"AssignmentExpression")}else if(ownDestructuringErrors)this.checkExpressionErrors(refDestructuringErrors,!0);if(oldParenAssign>-1)refDestructuringErrors.parenthesizedAssign=oldParenAssign;if(oldTrailingComma>-1)refDestructuringErrors.trailingComma=oldTrailingComma;return left};pp$5.parseMaybeConditional=function(forInit,refDestructuringErrors){var startPos=this.start,startLoc=this.startLoc,expr=this.parseExprOps(forInit,refDestructuringErrors);if(this.checkExpressionErrors(refDestructuringErrors))return expr;if(!(expr.type==="ArrowFunctionExpression"&&expr.start===startPos)&&this.eat(types$1.question)){var node=this.startNodeAt(startPos,startLoc);return node.test=expr,node.consequent=this.parseMaybeAssign(),this.expect(types$1.colon),node.alternate=this.parseMaybeAssign(forInit),this.finishNode(node,"ConditionalExpression")}return expr};pp$5.parseExprOps=function(forInit,refDestructuringErrors){var startPos=this.start,startLoc=this.startLoc,expr=this.parseMaybeUnary(refDestructuringErrors,!1,!1,forInit);if(this.checkExpressionErrors(refDestructuringErrors))return expr;return expr.start===startPos&&expr.type==="ArrowFunctionExpression"?expr:this.parseExprOp(expr,startPos,startLoc,-1,forInit)};pp$5.parseExprOp=function(left,leftStartPos,leftStartLoc,minPrec,forInit){var prec=this.type.binop;if(prec!=null&&(!forInit||this.type!==types$1._in)){if(prec>minPrec){var logical=this.type===types$1.logicalOR||this.type===types$1.logicalAND,coalesce=this.type===types$1.coalesce;if(coalesce)prec=types$1.logicalAND.binop;var op=this.value;this.next();var startPos=this.start,startLoc=this.startLoc,right=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,forInit),startPos,startLoc,prec,forInit),node=this.buildBinary(leftStartPos,leftStartLoc,left,right,op,logical||coalesce);if(logical&&this.type===types$1.coalesce||coalesce&&(this.type===types$1.logicalOR||this.type===types$1.logicalAND))this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");return this.parseExprOp(node,leftStartPos,leftStartLoc,minPrec,forInit)}}return left};pp$5.buildBinary=function(startPos,startLoc,left,right,op,logical){if(right.type==="PrivateIdentifier")this.raise(right.start,"Private identifier can only be left side of binary expression");var node=this.startNodeAt(startPos,startLoc);return node.left=left,node.operator=op,node.right=right,this.finishNode(node,logical?"LogicalExpression":"BinaryExpression")};pp$5.parseMaybeUnary=function(refDestructuringErrors,sawUnary,incDec,forInit){var startPos=this.start,startLoc=this.startLoc,expr;if(this.isContextual("await")&&this.canAwait)expr=this.parseAwait(forInit),sawUnary=!0;else if(this.type.prefix){var node=this.startNode(),update=this.type===types$1.incDec;if(node.operator=this.value,node.prefix=!0,this.next(),node.argument=this.parseMaybeUnary(null,!0,update,forInit),this.checkExpressionErrors(refDestructuringErrors,!0),update)this.checkLValSimple(node.argument);else if(this.strict&&node.operator==="delete"&&isLocalVariableAccess(node.argument))this.raiseRecoverable(node.start,"Deleting local variable in strict mode");else if(node.operator==="delete"&&isPrivateFieldAccess(node.argument))this.raiseRecoverable(node.start,"Private fields can not be deleted");else sawUnary=!0;expr=this.finishNode(node,update?"UpdateExpression":"UnaryExpression")}else if(!sawUnary&&this.type===types$1.privateId){if((forInit||this.privateNameStack.length===0)&&this.options.checkPrivateFields)this.unexpected();if(expr=this.parsePrivateIdent(),this.type!==types$1._in)this.unexpected()}else{if(expr=this.parseExprSubscripts(refDestructuringErrors,forInit),this.checkExpressionErrors(refDestructuringErrors))return expr;while(this.type.postfix&&!this.canInsertSemicolon()){var node$1=this.startNodeAt(startPos,startLoc);node$1.operator=this.value,node$1.prefix=!1,node$1.argument=expr,this.checkLValSimple(expr),this.next(),expr=this.finishNode(node$1,"UpdateExpression")}}if(!incDec&&!(expr.type==="ArrowFunctionExpression"&&expr.start===startPos)&&this.eat(types$1.starstar))if(sawUnary)this.unexpected(this.lastTokStart);else return this.buildBinary(startPos,startLoc,expr,this.parseMaybeUnary(null,!1,!1,forInit),"**",!1);else return expr};function isLocalVariableAccess(node){return node.type==="Identifier"||node.type==="ParenthesizedExpression"&&isLocalVariableAccess(node.expression)}function isPrivateFieldAccess(node){return node.type==="MemberExpression"&&node.property.type==="PrivateIdentifier"||node.type==="ChainExpression"&&isPrivateFieldAccess(node.expression)||node.type==="ParenthesizedExpression"&&isPrivateFieldAccess(node.expression)}pp$5.parseExprSubscripts=function(refDestructuringErrors,forInit){var startPos=this.start,startLoc=this.startLoc,expr=this.parseExprAtom(refDestructuringErrors,forInit);if(expr.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return expr;var result=this.parseSubscripts(expr,startPos,startLoc,!1,forInit);if(refDestructuringErrors&&result.type==="MemberExpression"){if(refDestructuringErrors.parenthesizedAssign>=result.start)refDestructuringErrors.parenthesizedAssign=-1;if(refDestructuringErrors.parenthesizedBind>=result.start)refDestructuringErrors.parenthesizedBind=-1;if(refDestructuringErrors.trailingComma>=result.start)refDestructuringErrors.trailingComma=-1}return result};pp$5.parseSubscripts=function(base,startPos,startLoc,noCalls,forInit){var maybeAsyncArrow=this.options.ecmaVersion>=8&&base.type==="Identifier"&&base.name==="async"&&this.lastTokEnd===base.end&&!this.canInsertSemicolon()&&base.end-base.start===5&&this.potentialArrowAt===base.start,optionalChained=!1;while(!0){var element=this.parseSubscript(base,startPos,startLoc,noCalls,maybeAsyncArrow,optionalChained,forInit);if(element.optional)optionalChained=!0;if(element===base||element.type==="ArrowFunctionExpression"){if(optionalChained){var chainNode=this.startNodeAt(startPos,startLoc);chainNode.expression=element,element=this.finishNode(chainNode,"ChainExpression")}return element}base=element}};pp$5.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(types$1.arrow)};pp$5.parseSubscriptAsyncArrow=function(startPos,startLoc,exprList,forInit){return this.parseArrowExpression(this.startNodeAt(startPos,startLoc),exprList,!0,forInit)};pp$5.parseSubscript=function(base,startPos,startLoc,noCalls,maybeAsyncArrow,optionalChained,forInit){var optionalSupported=this.options.ecmaVersion>=11,optional=optionalSupported&&this.eat(types$1.questionDot);if(noCalls&&optional)this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var computed=this.eat(types$1.bracketL);if(computed||optional&&this.type!==types$1.parenL&&this.type!==types$1.backQuote||this.eat(types$1.dot)){var node=this.startNodeAt(startPos,startLoc);if(node.object=base,computed)node.property=this.parseExpression(),this.expect(types$1.bracketR);else if(this.type===types$1.privateId&&base.type!=="Super")node.property=this.parsePrivateIdent();else node.property=this.parseIdent(this.options.allowReserved!=="never");if(node.computed=!!computed,optionalSupported)node.optional=optional;base=this.finishNode(node,"MemberExpression")}else if(!noCalls&&this.eat(types$1.parenL)){var refDestructuringErrors=new DestructuringErrors,oldYieldPos=this.yieldPos,oldAwaitPos=this.awaitPos,oldAwaitIdentPos=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var exprList=this.parseExprList(types$1.parenR,this.options.ecmaVersion>=8,!1,refDestructuringErrors);if(maybeAsyncArrow&&!optional&&this.shouldParseAsyncArrow()){if(this.checkPatternErrors(refDestructuringErrors,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0)this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function");return this.yieldPos=oldYieldPos,this.awaitPos=oldAwaitPos,this.awaitIdentPos=oldAwaitIdentPos,this.parseSubscriptAsyncArrow(startPos,startLoc,exprList,forInit)}this.checkExpressionErrors(refDestructuringErrors,!0),this.yieldPos=oldYieldPos||this.yieldPos,this.awaitPos=oldAwaitPos||this.awaitPos,this.awaitIdentPos=oldAwaitIdentPos||this.awaitIdentPos;var node$1=this.startNodeAt(startPos,startLoc);if(node$1.callee=base,node$1.arguments=exprList,optionalSupported)node$1.optional=optional;base=this.finishNode(node$1,"CallExpression")}else if(this.type===types$1.backQuote){if(optional||optionalChained)this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var node$2=this.startNodeAt(startPos,startLoc);node$2.tag=base,node$2.quasi=this.parseTemplate({isTagged:!0}),base=this.finishNode(node$2,"TaggedTemplateExpression")}return base};pp$5.parseExprAtom=function(refDestructuringErrors,forInit,forNew){if(this.type===types$1.slash)this.readRegexp();var node,canBeArrow=this.potentialArrowAt===this.start;switch(this.type){case types$1._super:if(!this.allowSuper)this.raise(this.start,"'super' keyword outside a method");if(node=this.startNode(),this.next(),this.type===types$1.parenL&&!this.allowDirectSuper)this.raise(node.start,"super() call outside constructor of a subclass");if(this.type!==types$1.dot&&this.type!==types$1.bracketL&&this.type!==types$1.parenL)this.unexpected();return this.finishNode(node,"Super");case types$1._this:return node=this.startNode(),this.next(),this.finishNode(node,"ThisExpression");case types$1.name:var startPos=this.start,startLoc=this.startLoc,containsEsc=this.containsEsc,id=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!containsEsc&&id.name==="async"&&!this.canInsertSemicolon()&&this.eat(types$1._function))return this.overrideContext(types.f_expr),this.parseFunction(this.startNodeAt(startPos,startLoc),0,!1,!0,forInit);if(canBeArrow&&!this.canInsertSemicolon()){if(this.eat(types$1.arrow))return this.parseArrowExpression(this.startNodeAt(startPos,startLoc),[id],!1,forInit);if(this.options.ecmaVersion>=8&&id.name==="async"&&this.type===types$1.name&&!containsEsc&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc)){if(id=this.parseIdent(!1),this.canInsertSemicolon()||!this.eat(types$1.arrow))this.unexpected();return this.parseArrowExpression(this.startNodeAt(startPos,startLoc),[id],!0,forInit)}}return id;case types$1.regexp:var value=this.value;return node=this.parseLiteral(value.value),node.regex={pattern:value.pattern,flags:value.flags},node;case types$1.num:case types$1.string:return this.parseLiteral(this.value);case types$1._null:case types$1._true:case types$1._false:return node=this.startNode(),node.value=this.type===types$1._null?null:this.type===types$1._true,node.raw=this.type.keyword,this.next(),this.finishNode(node,"Literal");case types$1.parenL:var start=this.start,expr=this.parseParenAndDistinguishExpression(canBeArrow,forInit);if(refDestructuringErrors){if(refDestructuringErrors.parenthesizedAssign<0&&!this.isSimpleAssignTarget(expr))refDestructuringErrors.parenthesizedAssign=start;if(refDestructuringErrors.parenthesizedBind<0)refDestructuringErrors.parenthesizedBind=start}return expr;case types$1.bracketL:return node=this.startNode(),this.next(),node.elements=this.parseExprList(types$1.bracketR,!0,!0,refDestructuringErrors),this.finishNode(node,"ArrayExpression");case types$1.braceL:return this.overrideContext(types.b_expr),this.parseObj(!1,refDestructuringErrors);case types$1._function:return node=this.startNode(),this.next(),this.parseFunction(node,0);case types$1._class:return this.parseClass(this.startNode(),!1);case types$1._new:return this.parseNew();case types$1.backQuote:return this.parseTemplate();case types$1._import:if(this.options.ecmaVersion>=11)return this.parseExprImport(forNew);else return this.unexpected();default:return this.parseExprAtomDefault()}};pp$5.parseExprAtomDefault=function(){this.unexpected()};pp$5.parseExprImport=function(forNew){var node=this.startNode();if(this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword import");if(this.next(),this.type===types$1.parenL&&!forNew)return this.parseDynamicImport(node);else if(this.type===types$1.dot){var meta=this.startNodeAt(node.start,node.loc&&node.loc.start);return meta.name="import",node.meta=this.finishNode(meta,"Identifier"),this.parseImportMeta(node)}else this.unexpected()};pp$5.parseDynamicImport=function(node){if(this.next(),node.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)if(!this.eat(types$1.parenR))if(this.expect(types$1.comma),!this.afterTrailingComma(types$1.parenR)){if(node.options=this.parseMaybeAssign(),!this.eat(types$1.parenR)){if(this.expect(types$1.comma),!this.afterTrailingComma(types$1.parenR))this.unexpected()}}else node.options=null;else node.options=null;else if(!this.eat(types$1.parenR)){var errorPos=this.start;if(this.eat(types$1.comma)&&this.eat(types$1.parenR))this.raiseRecoverable(errorPos,"Trailing comma is not allowed in import()");else this.unexpected(errorPos)}return this.finishNode(node,"ImportExpression")};pp$5.parseImportMeta=function(node){this.next();var containsEsc=this.containsEsc;if(node.property=this.parseIdent(!0),node.property.name!=="meta")this.raiseRecoverable(node.property.start,"The only valid meta property for import is 'import.meta'");if(containsEsc)this.raiseRecoverable(node.start,"'import.meta' must not contain escaped characters");if(this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere)this.raiseRecoverable(node.start,"Cannot use 'import.meta' outside a module");return this.finishNode(node,"MetaProperty")};pp$5.parseLiteral=function(value){var node=this.startNode();if(node.value=value,node.raw=this.input.slice(this.start,this.end),node.raw.charCodeAt(node.raw.length-1)===110)node.bigint=node.value!=null?node.value.toString():node.raw.slice(0,-1).replace(/_/g,"");return this.next(),this.finishNode(node,"Literal")};pp$5.parseParenExpression=function(){this.expect(types$1.parenL);var val=this.parseExpression();return this.expect(types$1.parenR),val};pp$5.shouldParseArrow=function(exprList){return!this.canInsertSemicolon()};pp$5.parseParenAndDistinguishExpression=function(canBeArrow,forInit){var startPos=this.start,startLoc=this.startLoc,val,allowTrailingComma=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var innerStartPos=this.start,innerStartLoc=this.startLoc,exprList=[],first=!0,lastIsComma=!1,refDestructuringErrors=new DestructuringErrors,oldYieldPos=this.yieldPos,oldAwaitPos=this.awaitPos,spreadStart;this.yieldPos=0,this.awaitPos=0;while(this.type!==types$1.parenR)if(first?first=!1:this.expect(types$1.comma),allowTrailingComma&&this.afterTrailingComma(types$1.parenR,!0)){lastIsComma=!0;break}else if(this.type===types$1.ellipsis){if(spreadStart=this.start,exprList.push(this.parseParenItem(this.parseRestBinding())),this.type===types$1.comma)this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else exprList.push(this.parseMaybeAssign(!1,refDestructuringErrors,this.parseParenItem));var innerEndPos=this.lastTokEnd,innerEndLoc=this.lastTokEndLoc;if(this.expect(types$1.parenR),canBeArrow&&this.shouldParseArrow(exprList)&&this.eat(types$1.arrow))return this.checkPatternErrors(refDestructuringErrors,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=oldYieldPos,this.awaitPos=oldAwaitPos,this.parseParenArrowList(startPos,startLoc,exprList,forInit);if(!exprList.length||lastIsComma)this.unexpected(this.lastTokStart);if(spreadStart)this.unexpected(spreadStart);if(this.checkExpressionErrors(refDestructuringErrors,!0),this.yieldPos=oldYieldPos||this.yieldPos,this.awaitPos=oldAwaitPos||this.awaitPos,exprList.length>1)val=this.startNodeAt(innerStartPos,innerStartLoc),val.expressions=exprList,this.finishNodeAt(val,"SequenceExpression",innerEndPos,innerEndLoc);else val=exprList[0]}else val=this.parseParenExpression();if(this.options.preserveParens){var par=this.startNodeAt(startPos,startLoc);return par.expression=val,this.finishNode(par,"ParenthesizedExpression")}else return val};pp$5.parseParenItem=function(item){return item};pp$5.parseParenArrowList=function(startPos,startLoc,exprList,forInit){return this.parseArrowExpression(this.startNodeAt(startPos,startLoc),exprList,!1,forInit)};var empty=[];pp$5.parseNew=function(){if(this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword new");var node=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===types$1.dot){var meta=this.startNodeAt(node.start,node.loc&&node.loc.start);meta.name="new",node.meta=this.finishNode(meta,"Identifier"),this.next();var containsEsc=this.containsEsc;if(node.property=this.parseIdent(!0),node.property.name!=="target")this.raiseRecoverable(node.property.start,"The only valid meta property for new is 'new.target'");if(containsEsc)this.raiseRecoverable(node.start,"'new.target' must not contain escaped characters");if(!this.allowNewDotTarget)this.raiseRecoverable(node.start,"'new.target' can only be used in functions and class static block");return this.finishNode(node,"MetaProperty")}var startPos=this.start,startLoc=this.startLoc;if(node.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),startPos,startLoc,!0,!1),node.callee.type==="Super")this.raiseRecoverable(startPos,"Invalid use of 'super'");if(this.eat(types$1.parenL))node.arguments=this.parseExprList(types$1.parenR,this.options.ecmaVersion>=8,!1);else node.arguments=empty;return this.finishNode(node,"NewExpression")};pp$5.parseTemplateElement=function(ref){var isTagged=ref.isTagged,elem=this.startNode();if(this.type===types$1.invalidTemplate){if(!isTagged)this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal");elem.value={raw:this.value.replace(/\r\n?/g,`
|
|
4
|
+
`),cooked:null}}else elem.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
5
|
+
`),cooked:this.value};return this.next(),elem.tail=this.type===types$1.backQuote,this.finishNode(elem,"TemplateElement")};pp$5.parseTemplate=function(ref){if(ref===void 0)ref={};var isTagged=ref.isTagged;if(isTagged===void 0)isTagged=!1;var node=this.startNode();this.next(),node.expressions=[];var curElt=this.parseTemplateElement({isTagged});node.quasis=[curElt];while(!curElt.tail){if(this.type===types$1.eof)this.raise(this.pos,"Unterminated template literal");this.expect(types$1.dollarBraceL),node.expressions.push(this.parseExpression()),this.expect(types$1.braceR),node.quasis.push(curElt=this.parseTemplateElement({isTagged}))}return this.next(),this.finishNode(node,"TemplateLiteral")};pp$5.isAsyncProp=function(prop){return!prop.computed&&prop.key.type==="Identifier"&&prop.key.name==="async"&&(this.type===types$1.name||this.type===types$1.num||this.type===types$1.string||this.type===types$1.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===types$1.star)&&!lineBreak.test(this.input.slice(this.lastTokEnd,this.start))};pp$5.parseObj=function(isPattern,refDestructuringErrors){var node=this.startNode(),first=!0,propHash={};node.properties=[],this.next();while(!this.eat(types$1.braceR)){if(!first){if(this.expect(types$1.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(types$1.braceR))break}else first=!1;var prop=this.parseProperty(isPattern,refDestructuringErrors);if(!isPattern)this.checkPropClash(prop,propHash,refDestructuringErrors);node.properties.push(prop)}return this.finishNode(node,isPattern?"ObjectPattern":"ObjectExpression")};pp$5.parseProperty=function(isPattern,refDestructuringErrors){var prop=this.startNode(),isGenerator,isAsync,startPos,startLoc;if(this.options.ecmaVersion>=9&&this.eat(types$1.ellipsis)){if(isPattern){if(prop.argument=this.parseIdent(!1),this.type===types$1.comma)this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");return this.finishNode(prop,"RestElement")}if(prop.argument=this.parseMaybeAssign(!1,refDestructuringErrors),this.type===types$1.comma&&refDestructuringErrors&&refDestructuringErrors.trailingComma<0)refDestructuringErrors.trailingComma=this.start;return this.finishNode(prop,"SpreadElement")}if(this.options.ecmaVersion>=6){if(prop.method=!1,prop.shorthand=!1,isPattern||refDestructuringErrors)startPos=this.start,startLoc=this.startLoc;if(!isPattern)isGenerator=this.eat(types$1.star)}var containsEsc=this.containsEsc;if(this.parsePropertyName(prop),!isPattern&&!containsEsc&&this.options.ecmaVersion>=8&&!isGenerator&&this.isAsyncProp(prop))isAsync=!0,isGenerator=this.options.ecmaVersion>=9&&this.eat(types$1.star),this.parsePropertyName(prop);else isAsync=!1;return this.parsePropertyValue(prop,isPattern,isGenerator,isAsync,startPos,startLoc,refDestructuringErrors,containsEsc),this.finishNode(prop,"Property")};pp$5.parseGetterSetter=function(prop){var kind=prop.key.name;this.parsePropertyName(prop),prop.value=this.parseMethod(!1),prop.kind=kind;var paramCount=prop.kind==="get"?0:1;if(prop.value.params.length!==paramCount){var start=prop.value.start;if(prop.kind==="get")this.raiseRecoverable(start,"getter should have no params");else this.raiseRecoverable(start,"setter should have exactly one param")}else if(prop.kind==="set"&&prop.value.params[0].type==="RestElement")this.raiseRecoverable(prop.value.params[0].start,"Setter cannot use rest params")};pp$5.parsePropertyValue=function(prop,isPattern,isGenerator,isAsync,startPos,startLoc,refDestructuringErrors,containsEsc){if((isGenerator||isAsync)&&this.type===types$1.colon)this.unexpected();if(this.eat(types$1.colon))prop.value=isPattern?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,refDestructuringErrors),prop.kind="init";else if(this.options.ecmaVersion>=6&&this.type===types$1.parenL){if(isPattern)this.unexpected();prop.method=!0,prop.value=this.parseMethod(isGenerator,isAsync),prop.kind="init"}else if(!isPattern&&!containsEsc&&this.options.ecmaVersion>=5&&!prop.computed&&prop.key.type==="Identifier"&&(prop.key.name==="get"||prop.key.name==="set")&&(this.type!==types$1.comma&&this.type!==types$1.braceR&&this.type!==types$1.eq)){if(isGenerator||isAsync)this.unexpected();this.parseGetterSetter(prop)}else if(this.options.ecmaVersion>=6&&!prop.computed&&prop.key.type==="Identifier"){if(isGenerator||isAsync)this.unexpected();if(this.checkUnreserved(prop.key),prop.key.name==="await"&&!this.awaitIdentPos)this.awaitIdentPos=startPos;if(isPattern)prop.value=this.parseMaybeDefault(startPos,startLoc,this.copyNode(prop.key));else if(this.type===types$1.eq&&refDestructuringErrors){if(refDestructuringErrors.shorthandAssign<0)refDestructuringErrors.shorthandAssign=this.start;prop.value=this.parseMaybeDefault(startPos,startLoc,this.copyNode(prop.key))}else prop.value=this.copyNode(prop.key);prop.kind="init",prop.shorthand=!0}else this.unexpected()};pp$5.parsePropertyName=function(prop){if(this.options.ecmaVersion>=6)if(this.eat(types$1.bracketL))return prop.computed=!0,prop.key=this.parseMaybeAssign(),this.expect(types$1.bracketR),prop.key;else prop.computed=!1;return prop.key=this.type===types$1.num||this.type===types$1.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};pp$5.initFunction=function(node){if(node.id=null,this.options.ecmaVersion>=6)node.generator=node.expression=!1;if(this.options.ecmaVersion>=8)node.async=!1};pp$5.parseMethod=function(isGenerator,isAsync,allowDirectSuper){var node=this.startNode(),oldYieldPos=this.yieldPos,oldAwaitPos=this.awaitPos,oldAwaitIdentPos=this.awaitIdentPos;if(this.initFunction(node),this.options.ecmaVersion>=6)node.generator=isGenerator;if(this.options.ecmaVersion>=8)node.async=!!isAsync;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(functionFlags(isAsync,node.generator)|SCOPE_SUPER|(allowDirectSuper?SCOPE_DIRECT_SUPER:0)),this.expect(types$1.parenL),node.params=this.parseBindingList(types$1.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(node,!1,!0,!1),this.yieldPos=oldYieldPos,this.awaitPos=oldAwaitPos,this.awaitIdentPos=oldAwaitIdentPos,this.finishNode(node,"FunctionExpression")};pp$5.parseArrowExpression=function(node,params,isAsync,forInit){var oldYieldPos=this.yieldPos,oldAwaitPos=this.awaitPos,oldAwaitIdentPos=this.awaitIdentPos;if(this.enterScope(functionFlags(isAsync,!1)|SCOPE_ARROW),this.initFunction(node),this.options.ecmaVersion>=8)node.async=!!isAsync;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,node.params=this.toAssignableList(params,!0),this.parseFunctionBody(node,!0,!1,forInit),this.yieldPos=oldYieldPos,this.awaitPos=oldAwaitPos,this.awaitIdentPos=oldAwaitIdentPos,this.finishNode(node,"ArrowFunctionExpression")};pp$5.parseFunctionBody=function(node,isArrowFunction,isMethod,forInit){var isExpression=isArrowFunction&&this.type!==types$1.braceL,oldStrict=this.strict,useStrict=!1;if(isExpression)node.body=this.parseMaybeAssign(forInit),node.expression=!0,this.checkParams(node,!1);else{var nonSimple=this.options.ecmaVersion>=7&&!this.isSimpleParamList(node.params);if(!oldStrict||nonSimple){if(useStrict=this.strictDirective(this.end),useStrict&&nonSimple)this.raiseRecoverable(node.start,"Illegal 'use strict' directive in function with non-simple parameter list")}var oldLabels=this.labels;if(this.labels=[],useStrict)this.strict=!0;if(this.checkParams(node,!oldStrict&&!useStrict&&!isArrowFunction&&!isMethod&&this.isSimpleParamList(node.params)),this.strict&&node.id)this.checkLValSimple(node.id,BIND_OUTSIDE);node.body=this.parseBlock(!1,void 0,useStrict&&!oldStrict),node.expression=!1,this.adaptDirectivePrologue(node.body.body),this.labels=oldLabels}this.exitScope()};pp$5.isSimpleParamList=function(params){for(var i=0,list=params;i<list.length;i+=1){var param=list[i];if(param.type!=="Identifier")return!1}return!0};pp$5.checkParams=function(node,allowDuplicates){var nameHash=Object.create(null);for(var i=0,list=node.params;i<list.length;i+=1){var param=list[i];this.checkLValInnerPattern(param,BIND_VAR,allowDuplicates?null:nameHash)}};pp$5.parseExprList=function(close,allowTrailingComma,allowEmpty,refDestructuringErrors){var elts=[],first=!0;while(!this.eat(close)){if(!first){if(this.expect(types$1.comma),allowTrailingComma&&this.afterTrailingComma(close))break}else first=!1;var elt=void 0;if(allowEmpty&&this.type===types$1.comma)elt=null;else if(this.type===types$1.ellipsis){if(elt=this.parseSpread(refDestructuringErrors),refDestructuringErrors&&this.type===types$1.comma&&refDestructuringErrors.trailingComma<0)refDestructuringErrors.trailingComma=this.start}else elt=this.parseMaybeAssign(!1,refDestructuringErrors);elts.push(elt)}return elts};pp$5.checkUnreserved=function(ref){var{start,end,name}=ref;if(this.inGenerator&&name==="yield")this.raiseRecoverable(start,"Cannot use 'yield' as identifier inside a generator");if(this.inAsync&&name==="await")this.raiseRecoverable(start,"Cannot use 'await' as identifier inside an async function");if(!(this.currentThisScope().flags&SCOPE_VAR)&&name==="arguments")this.raiseRecoverable(start,"Cannot use 'arguments' in class field initializer");if(this.inClassStaticBlock&&(name==="arguments"||name==="await"))this.raise(start,"Cannot use "+name+" in class static initialization block");if(this.keywords.test(name))this.raise(start,"Unexpected keyword '"+name+"'");if(this.options.ecmaVersion<6&&this.input.slice(start,end).indexOf("\\")!==-1)return;var re=this.strict?this.reservedWordsStrict:this.reservedWords;if(re.test(name)){if(!this.inAsync&&name==="await")this.raiseRecoverable(start,"Cannot use keyword 'await' outside an async function");this.raiseRecoverable(start,"The keyword '"+name+"' is reserved")}};pp$5.parseIdent=function(liberal){var node=this.parseIdentNode();if(this.next(!!liberal),this.finishNode(node,"Identifier"),!liberal){if(this.checkUnreserved(node),node.name==="await"&&!this.awaitIdentPos)this.awaitIdentPos=node.start}return node};pp$5.parseIdentNode=function(){var node=this.startNode();if(this.type===types$1.name)node.name=this.value;else if(this.type.keyword){if(node.name=this.type.keyword,(node.name==="class"||node.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46))this.context.pop();this.type=types$1.name}else this.unexpected();return node};pp$5.parsePrivateIdent=function(){var node=this.startNode();if(this.type===types$1.privateId)node.name=this.value;else this.unexpected();if(this.next(),this.finishNode(node,"PrivateIdentifier"),this.options.checkPrivateFields)if(this.privateNameStack.length===0)this.raise(node.start,"Private field '#"+node.name+"' must be declared in an enclosing class");else this.privateNameStack[this.privateNameStack.length-1].used.push(node);return node};pp$5.parseYield=function(forInit){if(!this.yieldPos)this.yieldPos=this.start;var node=this.startNode();if(this.next(),this.type===types$1.semi||this.canInsertSemicolon()||this.type!==types$1.star&&!this.type.startsExpr)node.delegate=!1,node.argument=null;else node.delegate=this.eat(types$1.star),node.argument=this.parseMaybeAssign(forInit);return this.finishNode(node,"YieldExpression")};pp$5.parseAwait=function(forInit){if(!this.awaitPos)this.awaitPos=this.start;var node=this.startNode();return this.next(),node.argument=this.parseMaybeUnary(null,!0,!1,forInit),this.finishNode(node,"AwaitExpression")};var pp$4=Parser.prototype;pp$4.raise=function(pos,message){var loc=getLineInfo(this.input,pos);if(message+=" ("+loc.line+":"+loc.column+")",this.sourceFile)message+=" in "+this.sourceFile;var err=SyntaxError(message);throw err.pos=pos,err.loc=loc,err.raisedAt=this.pos,err};pp$4.raiseRecoverable=pp$4.raise;pp$4.curPosition=function(){if(this.options.locations)return new Position(this.curLine,this.pos-this.lineStart)};var pp$3=Parser.prototype,Scope=function(flags){this.flags=flags,this.var=[],this.lexical=[],this.functions=[]};pp$3.enterScope=function(flags){this.scopeStack.push(new Scope(flags))};pp$3.exitScope=function(){this.scopeStack.pop()};pp$3.treatFunctionsAsVarInScope=function(scope){return scope.flags&SCOPE_FUNCTION||!this.inModule&&scope.flags&SCOPE_TOP};pp$3.declareName=function(name,bindingType,pos){var redeclared=!1;if(bindingType===BIND_LEXICAL){var scope=this.currentScope();if(redeclared=scope.lexical.indexOf(name)>-1||scope.functions.indexOf(name)>-1||scope.var.indexOf(name)>-1,scope.lexical.push(name),this.inModule&&scope.flags&SCOPE_TOP)delete this.undefinedExports[name]}else if(bindingType===BIND_SIMPLE_CATCH){var scope$1=this.currentScope();scope$1.lexical.push(name)}else if(bindingType===BIND_FUNCTION){var scope$2=this.currentScope();if(this.treatFunctionsAsVar)redeclared=scope$2.lexical.indexOf(name)>-1;else redeclared=scope$2.lexical.indexOf(name)>-1||scope$2.var.indexOf(name)>-1;scope$2.functions.push(name)}else for(var i=this.scopeStack.length-1;i>=0;--i){var scope$3=this.scopeStack[i];if(scope$3.lexical.indexOf(name)>-1&&!(scope$3.flags&SCOPE_SIMPLE_CATCH&&scope$3.lexical[0]===name)||!this.treatFunctionsAsVarInScope(scope$3)&&scope$3.functions.indexOf(name)>-1){redeclared=!0;break}if(scope$3.var.push(name),this.inModule&&scope$3.flags&SCOPE_TOP)delete this.undefinedExports[name];if(scope$3.flags&SCOPE_VAR)break}if(redeclared)this.raiseRecoverable(pos,"Identifier '"+name+"' has already been declared")};pp$3.checkLocalExport=function(id){if(this.scopeStack[0].lexical.indexOf(id.name)===-1&&this.scopeStack[0].var.indexOf(id.name)===-1)this.undefinedExports[id.name]=id};pp$3.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};pp$3.currentVarScope=function(){for(var i=this.scopeStack.length-1;;i--){var scope=this.scopeStack[i];if(scope.flags&(SCOPE_VAR|SCOPE_CLASS_FIELD_INIT|SCOPE_CLASS_STATIC_BLOCK))return scope}};pp$3.currentThisScope=function(){for(var i=this.scopeStack.length-1;;i--){var scope=this.scopeStack[i];if(scope.flags&(SCOPE_VAR|SCOPE_CLASS_FIELD_INIT|SCOPE_CLASS_STATIC_BLOCK)&&!(scope.flags&SCOPE_ARROW))return scope}};var Node=function(parser,pos,loc){if(this.type="",this.start=pos,this.end=0,parser.options.locations)this.loc=new SourceLocation(parser,loc);if(parser.options.directSourceFile)this.sourceFile=parser.options.directSourceFile;if(parser.options.ranges)this.range=[pos,0]},pp$2=Parser.prototype;pp$2.startNode=function(){return new Node(this,this.start,this.startLoc)};pp$2.startNodeAt=function(pos,loc){return new Node(this,pos,loc)};function finishNodeAt(node,type,pos,loc){if(node.type=type,node.end=pos,this.options.locations)node.loc.end=loc;if(this.options.ranges)node.range[1]=pos;return node}pp$2.finishNode=function(node,type){return finishNodeAt.call(this,node,type,this.lastTokEnd,this.lastTokEndLoc)};pp$2.finishNodeAt=function(node,type,pos,loc){return finishNodeAt.call(this,node,type,pos,loc)};pp$2.copyNode=function(node){var newNode=new Node(this,node.start,this.startLoc);for(var prop in node)newNode[prop]=node[prop];return newNode};var RegExpValidationState=function(){};RegExpValidationState.prototype.reset=function(){};Parser.prototype.validateRegExpFlags=function(){};Parser.prototype.validateRegExpPattern=function(){};var Token=function(p){if(this.type=p.type,this.value=p.value,this.start=p.start,this.end=p.end,p.options.locations)this.loc=new SourceLocation(p,p.startLoc,p.endLoc);if(p.options.ranges)this.range=[p.start,p.end]},pp=Parser.prototype;pp.next=function(ignoreEscapeSequenceInKeyword){if(!ignoreEscapeSequenceInKeyword&&this.type.keyword&&this.containsEsc)this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword);if(this.options.onToken)this.options.onToken(new Token(this));this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};pp.getToken=function(){return this.next(),new Token(this)};if(typeof Symbol<"u")pp[Symbol.iterator]=function(){var this$1$1=this;return{next:function(){var token=this$1$1.getToken();return{done:token.type===types$1.eof,value:token}}}};pp.nextToken=function(){var curContext=this.curContext();if(!curContext||!curContext.preserveSpace)this.skipSpace();if(this.start=this.pos,this.options.locations)this.startLoc=this.curPosition();if(this.pos>=this.input.length)return this.finishToken(types$1.eof);if(curContext.override)return curContext.override(this);else this.readToken(this.fullCharCodeAtPos())};pp.readToken=function(code){if(isIdentifierStart(code,this.options.ecmaVersion>=6)||code===92)return this.readWord();return this.getTokenFromCode(code)};pp.fullCharCodeAt=function(pos){var code=this.input.charCodeAt(pos);if(code<=55295||code>=56320)return code;var next=this.input.charCodeAt(pos+1);return next<=56319||next>=57344?code:(code<<10)+next-56613888};pp.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)};pp.skipBlockComment=function(){var startLoc=this.options.onComment&&this.curPosition(),start=this.pos,end=this.input.indexOf("*/",this.pos+=2);if(end===-1)this.raise(this.pos-2,"Unterminated comment");if(this.pos=end+2,this.options.locations)for(var nextBreak=void 0,pos=start;(nextBreak=nextLineBreak(this.input,pos,this.pos))>-1;)++this.curLine,pos=this.lineStart=nextBreak;if(this.options.onComment)this.options.onComment(!0,this.input.slice(start+2,end),start,this.pos,startLoc,this.curPosition())};pp.skipLineComment=function(startSkip){var start=this.pos,startLoc=this.options.onComment&&this.curPosition(),ch=this.input.charCodeAt(this.pos+=startSkip);while(this.pos<this.input.length&&!isNewLine(ch))ch=this.input.charCodeAt(++this.pos);if(this.options.onComment)this.options.onComment(!1,this.input.slice(start+startSkip,this.pos),start,this.pos,startLoc,this.curPosition())};pp.skipSpace=function(){loop:while(this.pos<this.input.length){var ch=this.input.charCodeAt(this.pos);switch(ch){case 32:case 160:++this.pos;break;case 13:if(this.input.charCodeAt(this.pos+1)===10)++this.pos;case 10:case 8232:case 8233:if(++this.pos,this.options.locations)++this.curLine,this.lineStart=this.pos;break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break loop}break;default:if(ch>8&&ch<14||ch>=5760&&nonASCIIwhitespace.test(String.fromCharCode(ch)))++this.pos;else break loop}}};pp.finishToken=function(type,val){if(this.end=this.pos,this.options.locations)this.endLoc=this.curPosition();var prevType=this.type;this.type=type,this.value=val,this.updateContext(prevType)};pp.readToken_dot=function(){var next=this.input.charCodeAt(this.pos+1);if(next>=48&&next<=57)return this.readNumber(!0);var next2=this.input.charCodeAt(this.pos+2);if(this.options.ecmaVersion>=6&&next===46&&next2===46)return this.pos+=3,this.finishToken(types$1.ellipsis);else return++this.pos,this.finishToken(types$1.dot)};pp.readToken_slash=function(){var next=this.input.charCodeAt(this.pos+1);if(this.exprAllowed)return++this.pos,this.readRegexp();if(next===61)return this.finishOp(types$1.assign,2);return this.finishOp(types$1.slash,1)};pp.readToken_mult_modulo_exp=function(code){var next=this.input.charCodeAt(this.pos+1),size=1,tokentype=code===42?types$1.star:types$1.modulo;if(this.options.ecmaVersion>=7&&code===42&&next===42)++size,tokentype=types$1.starstar,next=this.input.charCodeAt(this.pos+2);if(next===61)return this.finishOp(types$1.assign,size+1);return this.finishOp(tokentype,size)};pp.readToken_pipe_amp=function(code){var next=this.input.charCodeAt(this.pos+1);if(next===code){if(this.options.ecmaVersion>=12){var next2=this.input.charCodeAt(this.pos+2);if(next2===61)return this.finishOp(types$1.assign,3)}return this.finishOp(code===124?types$1.logicalOR:types$1.logicalAND,2)}if(next===61)return this.finishOp(types$1.assign,2);return this.finishOp(code===124?types$1.bitwiseOR:types$1.bitwiseAND,1)};pp.readToken_caret=function(){var next=this.input.charCodeAt(this.pos+1);if(next===61)return this.finishOp(types$1.assign,2);return this.finishOp(types$1.bitwiseXOR,1)};pp.readToken_plus_min=function(code){var next=this.input.charCodeAt(this.pos+1);if(next===code){if(next===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||lineBreak.test(this.input.slice(this.lastTokEnd,this.pos))))return this.skipLineComment(3),this.skipSpace(),this.nextToken();return this.finishOp(types$1.incDec,2)}if(next===61)return this.finishOp(types$1.assign,2);return this.finishOp(types$1.plusMin,1)};pp.readToken_lt_gt=function(code){var next=this.input.charCodeAt(this.pos+1),size=1;if(next===code){if(size=code===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+size)===61)return this.finishOp(types$1.assign,size+1);return this.finishOp(types$1.bitShift,size)}if(next===33&&code===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45)return this.skipLineComment(4),this.skipSpace(),this.nextToken();if(next===61)size=2;return this.finishOp(types$1.relational,size)};pp.readToken_eq_excl=function(code){var next=this.input.charCodeAt(this.pos+1);if(next===61)return this.finishOp(types$1.equality,this.input.charCodeAt(this.pos+2)===61?3:2);if(code===61&&next===62&&this.options.ecmaVersion>=6)return this.pos+=2,this.finishToken(types$1.arrow);return this.finishOp(code===61?types$1.eq:types$1.prefix,1)};pp.readToken_question=function(){var ecmaVersion=this.options.ecmaVersion;if(ecmaVersion>=11){var next=this.input.charCodeAt(this.pos+1);if(next===46){var next2=this.input.charCodeAt(this.pos+2);if(next2<48||next2>57)return this.finishOp(types$1.questionDot,2)}if(next===63){if(ecmaVersion>=12){var next2$1=this.input.charCodeAt(this.pos+2);if(next2$1===61)return this.finishOp(types$1.assign,3)}return this.finishOp(types$1.coalesce,2)}}return this.finishOp(types$1.question,1)};pp.readToken_numberSign=function(){var ecmaVersion=this.options.ecmaVersion,code=35;if(ecmaVersion>=13){if(++this.pos,code=this.fullCharCodeAtPos(),isIdentifierStart(code,!0)||code===92)return this.finishToken(types$1.privateId,this.readWord1())}this.raise(this.pos,"Unexpected character '"+codePointToString(code)+"'")};pp.getTokenFromCode=function(code){switch(code){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(types$1.parenL);case 41:return++this.pos,this.finishToken(types$1.parenR);case 59:return++this.pos,this.finishToken(types$1.semi);case 44:return++this.pos,this.finishToken(types$1.comma);case 91:return++this.pos,this.finishToken(types$1.bracketL);case 93:return++this.pos,this.finishToken(types$1.bracketR);case 123:return++this.pos,this.finishToken(types$1.braceL);case 125:return++this.pos,this.finishToken(types$1.braceR);case 58:return++this.pos,this.finishToken(types$1.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(types$1.backQuote);case 48:var next=this.input.charCodeAt(this.pos+1);if(next===120||next===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(next===111||next===79)return this.readRadixNumber(8);if(next===98||next===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(code);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(code);case 124:case 38:return this.readToken_pipe_amp(code);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(code);case 60:case 62:return this.readToken_lt_gt(code);case 61:case 33:return this.readToken_eq_excl(code);case 63:return this.readToken_question();case 126:return this.finishOp(types$1.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+codePointToString(code)+"'")};pp.finishOp=function(type,size){var str=this.input.slice(this.pos,this.pos+size);return this.pos+=size,this.finishToken(type,str)};pp.readRegexp=function(){var escaped,inClass,start=this.pos;for(;;){if(this.pos>=this.input.length)this.raise(start,"Unterminated regular expression");var ch=this.input.charAt(this.pos);if(lineBreak.test(ch))this.raise(start,"Unterminated regular expression");if(!escaped){if(ch==="[")inClass=!0;else if(ch==="]"&&inClass)inClass=!1;else if(ch==="/"&&!inClass)break;escaped=ch==="\\"}else escaped=!1;++this.pos}var pattern=this.input.slice(start,this.pos);++this.pos;var flagsStart=this.pos,flags=this.readWord1();if(this.containsEsc)this.unexpected(flagsStart);var state=this.regexpState||(this.regexpState=new RegExpValidationState(this));state.reset(start,pattern,flags),this.validateRegExpFlags(state),this.validateRegExpPattern(state);var value=null;try{value=new RegExp(pattern,flags)}catch(e){}return this.finishToken(types$1.regexp,{pattern,flags,value})};pp.readInt=function(radix,len,maybeLegacyOctalNumericLiteral){var allowSeparators=this.options.ecmaVersion>=12&&len===void 0,isLegacyOctalNumericLiteral=maybeLegacyOctalNumericLiteral&&this.input.charCodeAt(this.pos)===48,start=this.pos,total=0,lastCode=0;for(var i=0,e=len==null?1/0:len;i<e;++i,++this.pos){var code=this.input.charCodeAt(this.pos),val=void 0;if(allowSeparators&&code===95){if(isLegacyOctalNumericLiteral)this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals");if(lastCode===95)this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore");if(i===0)this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits");lastCode=code;continue}if(code>=97)val=code-97+10;else if(code>=65)val=code-65+10;else if(code>=48&&code<=57)val=code-48;else val=1/0;if(val>=radix)break;lastCode=code,total=total*radix+val}if(allowSeparators&&lastCode===95)this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits");if(this.pos===start||len!=null&&this.pos-start!==len)return null;return total};function stringToNumber(str,isLegacyOctalNumericLiteral){if(isLegacyOctalNumericLiteral)return parseInt(str,8);return parseFloat(str.replace(/_/g,""))}function stringToBigInt(str){if(typeof BigInt!=="function")return null;return BigInt(str.replace(/_/g,""))}pp.readRadixNumber=function(radix){var start=this.pos;this.pos+=2;var val=this.readInt(radix);if(val==null)this.raise(this.start+2,"Expected number in radix "+radix);if(this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110)val=stringToBigInt(this.input.slice(start,this.pos)),++this.pos;else if(isIdentifierStart(this.fullCharCodeAtPos()))this.raise(this.pos,"Identifier directly after number");return this.finishToken(types$1.num,val)};pp.readNumber=function(startsWithDot){var start=this.pos;if(!startsWithDot&&this.readInt(10,void 0,!0)===null)this.raise(start,"Invalid number");var octal=this.pos-start>=2&&this.input.charCodeAt(start)===48;if(octal&&this.strict)this.raise(start,"Invalid number");var next=this.input.charCodeAt(this.pos);if(!octal&&!startsWithDot&&this.options.ecmaVersion>=11&&next===110){var val$1=stringToBigInt(this.input.slice(start,this.pos));if(++this.pos,isIdentifierStart(this.fullCharCodeAtPos()))this.raise(this.pos,"Identifier directly after number");return this.finishToken(types$1.num,val$1)}if(octal&&/[89]/.test(this.input.slice(start,this.pos)))octal=!1;if(next===46&&!octal)++this.pos,this.readInt(10),next=this.input.charCodeAt(this.pos);if((next===69||next===101)&&!octal){if(next=this.input.charCodeAt(++this.pos),next===43||next===45)++this.pos;if(this.readInt(10)===null)this.raise(start,"Invalid number")}if(isIdentifierStart(this.fullCharCodeAtPos()))this.raise(this.pos,"Identifier directly after number");var val=stringToNumber(this.input.slice(start,this.pos),octal);return this.finishToken(types$1.num,val)};pp.readCodePoint=function(){var ch=this.input.charCodeAt(this.pos),code;if(ch===123){if(this.options.ecmaVersion<6)this.unexpected();var codePos=++this.pos;if(code=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,code>1114111)this.invalidStringToken(codePos,"Code point out of bounds")}else code=this.readHexChar(4);return code};pp.readString=function(quote){var out="",chunkStart=++this.pos;for(;;){if(this.pos>=this.input.length)this.raise(this.start,"Unterminated string constant");var ch=this.input.charCodeAt(this.pos);if(ch===quote)break;if(ch===92)out+=this.input.slice(chunkStart,this.pos),out+=this.readEscapedChar(!1),chunkStart=this.pos;else if(ch===8232||ch===8233){if(this.options.ecmaVersion<10)this.raise(this.start,"Unterminated string constant");if(++this.pos,this.options.locations)this.curLine++,this.lineStart=this.pos}else{if(isNewLine(ch))this.raise(this.start,"Unterminated string constant");++this.pos}}return out+=this.input.slice(chunkStart,this.pos++),this.finishToken(types$1.string,out)};var INVALID_TEMPLATE_ESCAPE_ERROR={};pp.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(err){if(err===INVALID_TEMPLATE_ESCAPE_ERROR)this.readInvalidTemplateToken();else throw err}this.inTemplateElement=!1};pp.invalidStringToken=function(position,message){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw INVALID_TEMPLATE_ESCAPE_ERROR;else this.raise(position,message)};pp.readTmplToken=function(){var out="",chunkStart=this.pos;for(;;){if(this.pos>=this.input.length)this.raise(this.start,"Unterminated template");var ch=this.input.charCodeAt(this.pos);if(ch===96||ch===36&&this.input.charCodeAt(this.pos+1)===123){if(this.pos===this.start&&(this.type===types$1.template||this.type===types$1.invalidTemplate))if(ch===36)return this.pos+=2,this.finishToken(types$1.dollarBraceL);else return++this.pos,this.finishToken(types$1.backQuote);return out+=this.input.slice(chunkStart,this.pos),this.finishToken(types$1.template,out)}if(ch===92)out+=this.input.slice(chunkStart,this.pos),out+=this.readEscapedChar(!0),chunkStart=this.pos;else if(isNewLine(ch)){switch(out+=this.input.slice(chunkStart,this.pos),++this.pos,ch){case 13:if(this.input.charCodeAt(this.pos)===10)++this.pos;case 10:out+=`
|
|
6
|
+
`;break;default:out+=String.fromCharCode(ch);break}if(this.options.locations)++this.curLine,this.lineStart=this.pos;chunkStart=this.pos}else++this.pos}};pp.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(types$1.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":if(this.input[this.pos+1]===`
|
|
7
|
+
`)++this.pos;case`
|
|
8
|
+
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};pp.readEscapedChar=function(inTemplate){var ch=this.input.charCodeAt(++this.pos);switch(++this.pos,ch){case 110:return`
|
|
9
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:if(this.input.charCodeAt(this.pos)===10)++this.pos;case 10:if(this.options.locations)this.lineStart=this.pos,++this.curLine;return"";case 56:case 57:if(this.strict)this.invalidStringToken(this.pos-1,"Invalid escape sequence");if(inTemplate){var codePos=this.pos-1;this.invalidStringToken(codePos,"Invalid escape sequence in template string")}default:if(ch>=48&&ch<=55){var octalStr=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],octal=parseInt(octalStr,8);if(octal>255)octalStr=octalStr.slice(0,-1),octal=parseInt(octalStr,8);if(this.pos+=octalStr.length-1,ch=this.input.charCodeAt(this.pos),(octalStr!=="0"||ch===56||ch===57)&&(this.strict||inTemplate))this.invalidStringToken(this.pos-1-octalStr.length,inTemplate?"Octal literal in template string":"Octal literal in strict mode");return String.fromCharCode(octal)}if(isNewLine(ch)){if(this.options.locations)this.lineStart=this.pos,++this.curLine;return""}return String.fromCharCode(ch)}};pp.readHexChar=function(len){var codePos=this.pos,n=this.readInt(16,len);if(n===null)this.invalidStringToken(codePos,"Bad character escape sequence");return n};pp.readWord1=function(){this.containsEsc=!1;var word="",first=!0,chunkStart=this.pos,astral=this.options.ecmaVersion>=6;while(this.pos<this.input.length){var ch=this.fullCharCodeAtPos();if(isIdentifierChar(ch,astral))this.pos+=ch<=65535?1:2;else if(ch===92){this.containsEsc=!0,word+=this.input.slice(chunkStart,this.pos);var escStart=this.pos;if(this.input.charCodeAt(++this.pos)!==117)this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX");++this.pos;var esc=this.readCodePoint();if(!(first?isIdentifierStart:isIdentifierChar)(esc,astral))this.invalidStringToken(escStart,"Invalid Unicode escape");word+=codePointToString(esc),chunkStart=this.pos}else break;first=!1}return word+this.input.slice(chunkStart,this.pos)};pp.readWord=function(){var word=this.readWord1(),type=types$1.name;if(this.keywords.test(word))type=keywords[word];return this.finishToken(type,word)};var version="8.18.0";Parser.acorn={Parser,version,defaultOptions,Position,SourceLocation,getLineInfo,Node,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};function definePlugin(plugin){return(BaseParser)=>plugin(BaseParser)}function extendParser(...plugins){return Parser.extend(...plugins)}function hasLineBreak(input,from,to){for(let i=from;i<to;i++){let code=input.charCodeAt(i);if(code===10||code===13||code===8232||code===8233)return!0}return!1}var sets=new WeakMap;function hasName(names,name){if(names===void 0)return!1;if(names.length<16)return names.includes(name);let entry=sets.get(names);if(entry===void 0||entry.length>names.length)entry={names:new Set,length:0},sets.set(names,entry);while(entry.length<names.length)entry.names.add(names[entry.length++]);return entry.names.has(name)}
|
|
10
|
+
export{isIdentifierStart,isIdentifierChar,Parser,definePlugin,extendParser,hasLineBreak,hasName};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var REGEX_LANG_ATTRIBUTE=/<!--[\s\S]*?-->|<script\s+(?:[^>]*|(?:[^=>'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)\s+)*)lang=(["'])?([^"' >]+)\1[^>]*>/y;function withoutByteOrderMark(source){return source.charCodeAt(0)===65279?source.slice(1):source}function isDigit(code){return code>=48&&code<=57}function isWhitespace(code){if(code===32||code<=13&&code>=9)return!0;if(code<160)return!1;return code===160||code===5760||code>=8192&&code<=8202||code===8232||code===8233||code===8239||code===8287||code===12288||code===65279}function skipWhitespace(source,from){let index=from;while(index<source.length&&isWhitespace(source.charCodeAt(index)))index++;return index}function isTypeScript(source){let index=source.indexOf("<");while(index!==-1){let next=source.charCodeAt(index+1);if(next===33||next===115){REGEX_LANG_ATTRIBUTE.lastIndex=index;let match=REGEX_LANG_ATTRIBUTE.exec(source);if(match){if(next===115)return match[2]==="ts";index=source.indexOf("<",REGEX_LANG_ATTRIBUTE.lastIndex);continue}}index=source.indexOf("<",index+1)}return!1}function closingScriptTag(source,from){let close=source.indexOf("</script",from);while(close!==-1){if(source.charCodeAt(skipWhitespace(source,close+8))===GT)return close;close=source.indexOf("</script",close+8)}return-1}function closingScriptTagEnd(source,close){return skipWhitespace(source,close+8)+1}var VOID_ELEMENTS=new Set("area base br col command embed hr img input keygen link meta param source track wbr".split(" "));function isVoid(name){return VOID_ELEMENTS.has(name)||name.charCodeAt(0)===33&&name.toLowerCase()==="!doctype"}function styleContentEnd(source,from){let index=from;while(index<source.length){let code=source.charCodeAt(index);if(code===47&&source.charCodeAt(index+1)===42){let end=source.indexOf("*/",index+2);index=end===-1?source.length:end+2}else if(code===34||code===39){index++;while(index<source.length){let next=source.charCodeAt(index);if(next===code||next===10)break;index+=next===92?2:1}index++}else if(code===60&&source.startsWith("</style",index))break;else index++}return Math.min(index,source.length)}var DOUBLE_QUOTE=34,SINGLE_QUOTE=39,SLASH=47,EQUALS=61,GT=62,isQuote=(code)=>code===DOUBLE_QUOTE||code===SINGLE_QUOTE;function nameEnd(source,from,isAttribute){let i=from;for(;i<source.length;i++){let code=source.charCodeAt(i);if(isWhitespace(code)||code===SLASH||code===GT)break;if(isAttribute&&(isQuote(code)||code===EQUALS))break}return i}function endsUnquotedValue(source,i){let code=source.charCodeAt(i);return isWhitespace(code)||isQuote(code)||code===EQUALS||code===60||code===GT||code===96||code===SLASH&&source.charCodeAt(i+1)===GT}
|
|
2
|
+
export{withoutByteOrderMark,isDigit,isWhitespace,skipWhitespace,isTypeScript,closingScriptTag,closingScriptTagEnd,isVoid,styleContentEnd,isQuote,nameEnd,endsUnquotedValue};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{closingTagOmitted}from"./shared-dgdrqgdn.js";import{withoutByteOrderMark,isWhitespace,skipWhitespace,isTypeScript,closingScriptTag,closingScriptTagEnd,isVoid,styleContentEnd,isQuote,nameEnd,endsUnquotedValue}from"./shared-5tpb3h6x.js";import{closingBracket}from"./shared-e4gbs4rb.js";var BLOCK="{",LT=60,GT=62,SLASH=47,EQUALS=61,BRACE=123,REGEX_CLOSING_STYLE_TAG_END=/\s*>/y,REGEX_CLOSING_TEXTAREA=/<\/textarea(\s[^>]*)?>/iy,SECTION_TAG_NAMES=["cript","tyle","velte:options"],CLOSING_OPTIONS_TAG="</svelte:options";function lexComponent2(input){let source=withoutByteOrderMark(input).trimEnd();return lex(source,isTypeScript(source),null)}function topLevelTags(source){let found={tags:[],comments:[]};return lex(source,!1,found),found}function lex(source,typescript,found){let component={typescript,instance:null,module:null,css:null,options:null},last=lastSectionTag(source),stack=[],i=0;while(i<=last){let code=source.charCodeAt(i);if(code===LT)i=readTag(source,i,stack,component,found);else if(code===BRACE)i=readMustache(source,i,stack);else i++}return component}function lastSectionTag(source){let last=-1,i=source.indexOf("<s");while(i!==-1){let end=sectionTagNameEnd(source,i+2);if(end!==-1){let code=source.charCodeAt(end);if(end===source.length||isWhitespace(code)||code===SLASH||code===GT)last=i}i=source.indexOf("<s",i+2)}return last}function sectionTagNameEnd(source,from){for(let name of SECTION_TAG_NAMES)if(source.startsWith(name,from))return from+name.length;return-1}function expressionEnd(source,from){return Math.min(closingBracket(source,from)+1,source.length)}function readMustache(source,start,stack){let i=skipWhitespace(source,start+1),code=source.charCodeAt(i),next=source.charCodeAt(i+1);if(code===35||code===58||code===64||code===SLASH&&next!==SLASH&&next!==42){i++;while(i<source.length){let letter=source.charCodeAt(i);if(letter<97||letter>122)break;i++}if(code===35)stack.push(BLOCK);else if(code===SLASH){let open=stack.lastIndexOf(BLOCK);if(open!==-1)stack.length=open}}return expressionEnd(source,i)}function readTag(source,start,stack,component,found){if(source.startsWith("!--",start+1)){let close=source.indexOf("-->",start+4),end=close===-1?source.length:close+3;if(found&&stack.length===0)found.comments.push(start,end);return end}if(source.charCodeAt(start+1)===SLASH){let nameStart=start+2,name=source.slice(nameStart,nameEnd(source,nameStart,!1)),open=stack.lastIndexOf(name);if(open!==-1)stack.length=open;return eatGreaterThan(source,skipWhitespace(source,nameStart+name.length))}let name=source.slice(start+1,nameEnd(source,start+1,!1)),i=skipWhitespace(source,start+1+name.length),parent=stack[stack.length-1];if(parent!==void 0&&closingTagOmitted(parent,name))stack.pop();let topLevel=stack.length===0;if(found&&topLevel&&(name==="script"||name==="style"||name==="svelte:options"))found.tags.push(start);if(topLevel&&(name==="script"||name==="style")){let attributes=[];if(i=eatGreaterThan(source,readStaticAttributes(source,i,attributes)),name==="script"){let script=readScript(source,start,i,attributes);if(script.context==="module")component.module??=script;else component.instance??=script;return script.end}let css=readStyle(source,start,i,attributes);return component.css??=css,css.end}let attributes=topLevel&&name==="svelte:options"?[]:null;if(i=readAttributes(source,i,attributes),source.charCodeAt(i)===SLASH||isVoid(name)){if(source.charCodeAt(i)===SLASH)i++;i=eatGreaterThan(source,i)}else{if(i=eatGreaterThan(source,i),name==="textarea")return textareaEnd(source,i);if(name==="script"||name==="style"){let closer=`</${name}>`,close=source.indexOf(closer,i);return close===-1?source.length:close+closer.length}if(attributes&&source.startsWith(CLOSING_OPTIONS_TAG,i))i=eatGreaterThan(source,skipWhitespace(source,i+CLOSING_OPTIONS_TAG.length));else return stack.push(name),i}if(attributes)component.options??={start,end:i,attributes};return i}function eatGreaterThan(source,i){return source.charCodeAt(i)===GT?i+1:i}function readScript(source,start,contentStart,attributes){let close=closingScriptTag(source,contentStart),contentEnd=close===-1?source.length:close,module=attributes.some((attribute)=>attribute.name==="module"||attribute.name==="context");return{start,end:close===-1?source.length:closingScriptTagEnd(source,close),context:module?"module":"default",attributes,content:{start:contentStart,end:contentEnd}}}function readStyle(source,start,contentStart,attributes){let contentEnd=styleContentEnd(source,contentStart),end=contentEnd;if(source.startsWith("</style",end)){end+=7,REGEX_CLOSING_STYLE_TAG_END.lastIndex=end;let close=REGEX_CLOSING_STYLE_TAG_END.exec(source);if(close)end+=close[0].length}return{start,end,attributes,content:{start:contentStart,end:contentEnd}}}function readStaticAttributes(source,from,into){let i=from;for(;;){let start=i,end=nameEnd(source,i,!0);if(end===start)return i;i=end;let value=!0;if(source.charCodeAt(i)===EQUALS){let at=skipWhitespace(source,i+1),quote=source.charCodeAt(at),valueEnd=-1;if(isQuote(quote)){let close=source.indexOf(source[at],at+1);if(close!==-1)valueEnd=close+1}if(valueEnd===-1){valueEnd=at;while(valueEnd<source.length&&source.charCodeAt(valueEnd)!==GT&&!isWhitespace(source.charCodeAt(valueEnd)))valueEnd++}let quotes=isQuote(quote)?1:0;value=source.slice(at+quotes,valueEnd-quotes),i=valueEnd}into.push({name:source.slice(start,end),value,start,end:i}),i=skipWhitespace(source,i)}}function readAttributes(source,from,into){let i=from;for(;;){for(;;){if(source.startsWith("/*",i)){let end=source.indexOf("*/",i+2);i=end===-1?source.length:end+2}else if(source.startsWith("//",i)){let end=source.indexOf(`
|
|
2
|
+
`,i+2);i=end===-1?source.length:end}else break;i=skipWhitespace(source,i)}let start=i;if(source.charCodeAt(i)===BRACE){i=skipWhitespace(source,expressionEnd(source,i+1));continue}let nameEndAt=nameEnd(source,i,!0);if(nameEndAt===start)return i;let end=nameEndAt,value=!0;if(i=skipWhitespace(source,nameEndAt),source.charCodeAt(i)===EQUALS){let at=skipWhitespace(source,i+1);end=source.startsWith("/>",at)?at+1:attributeValueEnd(source,at),value=isQuote(source.charCodeAt(at))?source.slice(at+1,Math.max(at+1,end-1)):source.slice(at,end),i=skipWhitespace(source,end)}into?.push({name:source.slice(start,nameEndAt),value,start,end})}}function attributeValueEnd(source,from){let quote=source.charCodeAt(from);if(isQuote(quote)){let i=from+1;while(i<source.length){let code=source.charCodeAt(i);if(code===quote)return i+1;i=code===BRACE?expressionEnd(source,i+1):i+1}return source.length}let i=from;while(i<source.length&&!endsUnquotedValue(source,i))i=source.charCodeAt(i)===BRACE?expressionEnd(source,i+1):i+1;return i}function textareaEnd(source,from){let i=from;while(i<source.length){let code=source.charCodeAt(i);if(code===LT){if(REGEX_CLOSING_TEXTAREA.lastIndex=i,REGEX_CLOSING_TEXTAREA.test(source))return REGEX_CLOSING_TEXTAREA.lastIndex}i=code===BRACE?expressionEnd(source,i+1):i+1}return source.length}
|
|
3
|
+
export{lexComponent2,topLevelTags};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{decodeCharacterReferences}from"./shared-bzqbnvee.js";import{readElement,componentState,finishComponent,readNode}from"./shared-xwzsb4m8.js";import{topLevelTags}from"./shared-a23q4q40.js";import{htmlEntityNames}from"./shared-drb44hb9.js";import{TypeScriptParser}from"./shared-ke0fgd3r.js";function parseComponentSections(source,options,support){let state=componentState(source,options,support);return readTopLevelTags(state),finishComponent(state)}function readTopLevelTags(state){let{source}=state,{tags,comments}=topLevelTags(source),nodes=state.root.fragment.nodes,appendText=(start,end)=>{if(end<=start)return;let raw=source.slice(start,end),data=raw.includes("<")||raw.includes("{")?raw:decodeCharacterReferences(raw,!1,state.entityNames);nodes.push({type:"Text",start,end,raw,data})},index=0,comment=0;for(let start of tags){for(;comment<comments.length&&comments[comment]<start;comment+=2){let commentStart=comments[comment];if(commentStart<index)continue;let end=comments[comment+1];appendText(index,commentStart),nodes.push({type:"Comment",start:commentStart,end,data:source.slice(commentStart+4,end-3)}),index=end}if(start<index)continue;appendText(index,start),state.index=start,readElement(state);while(state.stack.length>1&&state.index<source.length)readNode(state);index=state.index}let options=nodes.filter((node)=>node.type==="SvelteOptions");nodes.length=0,nodes.push(...options)}var support={typescript:TypeScriptParser,entityNames:htmlEntityNames};function parseSections2(source,options){return parseComponentSections(source,options,support)}
|
|
2
|
+
export{parseSections2};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var WINDOWS_1252=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376],REGEX_ENTITY_SEPARATOR=/[:!]/;function lazyEntityNames(encoded){let names;return()=>(names??=decodeEntityNames(encoded),names)}function decodeEntityNames(encoded){let table=new Map,longest=0,name="";for(let entry of encoded.split(" ")){let separator=entry.search(REGEX_ENTITY_SEPARATOR);name=name.slice(0,Number.parseInt(entry[0],36))+entry.slice(1,separator);let code=Number.parseInt(entry.slice(separator+1),36);if(table.set(`${name};`,code),entry[separator]==="!")table.set(name,code);longest=Math.max(longest,name.length+1)}return{table,longest}}var xmlEntityNames=lazyEntityNames("0amp!12 1pos:13 0gt!1q 0lt!1o 0quot!y"),isDigit=(code)=>code>=48&&code<=57,isHexDigit=(code)=>isDigit(code)||code>=65&&code<=70||code>=97&&code<=102,isAlphanumeric=(code)=>isDigit(code)||code>=65&&code<=90||code>=97&&code<=122,referenceEnd=0;function readReference(html,start,inAttribute,entityNames){if(html.charCodeAt(start)===35){let hex=(html.charCodeAt(start+1)|32)===120,digitsStart=start+(hex?2:1),end=digitsStart;while(end<html.length&&(hex?isHexDigit:isDigit)(html.charCodeAt(end)))end++;if(end===digitsStart)return 0;return referenceEnd=html.charCodeAt(end)===59?end+1:end,Number.parseInt(html.slice(digitsStart,end),hex?16:10)}let{table:names,longest}=entityNames(),runEnd=start;while(runEnd-start<longest&&isAlphanumeric(html.charCodeAt(runEnd)))runEnd++;if(html.charCodeAt(runEnd)===59){let code=names.get(html.slice(start,runEnd+1));if(code!==void 0)return referenceEnd=runEnd+1,code}for(let end=runEnd;end>start;end--){let code=names.get(html.slice(start,end));if(code===void 0)continue;if(inAttribute){let next=html.charCodeAt(end);if(isAlphanumeric(next)||next===95||next===61)continue}return referenceEnd=end,code}return 0}function validateCode(code,inAttribute){if(code===10&&!inAttribute)return 32;if(code<128)return code;if(code<=159)return WINDOWS_1252[code-128];if(code>=55296&&code<=57343)return 0;if(code<=196607)return code;if(code>=917504&&code<=917631||code>=917760&&code<=917999)return code;return 0}function decodeCharacterReferences(html,inAttribute,entityNames){let amp=html.indexOf("&");if(amp===-1)return html;let out="",copied=0;while(amp!==-1){let code=readReference(html,amp+1,inAttribute,entityNames);if(code)out+=html.slice(copied,amp)+String.fromCodePoint(validateCode(code,inAttribute)),copied=referenceEnd;amp=html.indexOf("&",code?copied:amp+1)}return out+html.slice(copied)}
|
|
2
|
+
export{lazyEntityNames,xmlEntityNames,decodeCharacterReferences};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{definePlugin,hasLineBreak,hasName}from"./shared-2pngd0mg.js";var SKIP_WHITESPACE=/(?:\s|\/\/.*|\/\*[\s\S]*?\*\/)*/g,KEYWORD_TYPES=new Map([["any","TSAnyKeyword"],["bigint","TSBigIntKeyword"],["boolean","TSBooleanKeyword"],["never","TSNeverKeyword"],["null","TSNullKeyword"],["number","TSNumberKeyword"],["object","TSObjectKeyword"],["string","TSStringKeyword"],["symbol","TSSymbolKeyword"],["undefined","TSUndefinedKeyword"],["unknown","TSUnknownKeyword"],["void","TSVoidKeyword"]]),CLASS_MODIFIERS=new Set("public private protected readonly declare abstract override static accessor".split(" ")),PARAMETER_MODIFIERS=new Set("public private protected readonly override".split(" ")),DECLARE_TARGETS=new Set("var let const function class abstract enum interface type namespace module global".split(" ")),DECLARE_FIRST=new Set("var let const function class interface enum".split(" ")),TS_EXPRESSION_WRAPPERS=new Set(["TSAsExpression","TSSatisfiesExpression","TSNonNullExpression","TSTypeAssertion"]),SCOPE_TOP=1,SCOPE_SIMPLE_CATCH=32,SCOPE_CLASS_STATIC_BLOCK=256,BIND_NONE=0,BIND_VAR=1,BIND_LEXICAL=2,BIND_FUNCTION=3,BIND_SIMPLE_CATCH=4,BIND_TS_TYPE=6,BIND_TS_INTERFACE=7,BIND_FLAGS_TS_ENUM=256,BIND_FLAGS_TS_EXPORT_ONLY=1024,BIND_TS_NAMESPACE=8|BIND_FLAGS_TS_EXPORT_ONLY,BIND_TS_ENUM=BIND_LEXICAL|BIND_FLAGS_TS_ENUM,FUNC_STATEMENT=1,FUNC_HANGING_STATEMENT=2,CHAR_PAREN_L=40,CHAR_PAREN_R=41,CHAR_COMMA=44,CHAR_DOT=46,CHAR_COLON=58,CHAR_EQ=61,CHAR_LT=60,CHAR_BRACE_L=123,CHAR_BRACKET_L=91,CHAR_STAR=42,CHAR_HASH=35,CHAR_DQUOTE=34,CHAR_SQUOTE=39,SPECULATION_FAILED=SyntaxError("speculative parse failed"),tsPlugin=definePlugin((Base)=>{let{tokTypes:tt,keywordTypes,isIdentifierChar,isIdentifierStart}=Base.acorn,atType=new Base.acorn.TokenType("@");class TSParser extends Base{inType=!1;$4=!1;$5=!1;$7=null;$k=null;$l=!1;$m=!1;$f=null;$9=[[]];$n=0;$t=0;$o=-1;constructor(options,input,startPos){super(options,input,startPos);let onComment=this.options.onComment;if(typeof onComment==="function")this.options.onComment=(block,text,start,end,startLoc,endLoc)=>{if(start<this.$t)return;this.$t=end,onComment.call(this,block,text,start,end,startLoc,endLoc)}}reset(){this.inType=!1,this.$4=!1,this.$5=!1,this.$7=null,this.$k=null,this.$l=!1,this.$m=!1,this.$f=null,this.$9=[[]],this.$n=0,this.$t=0,this.$o=-1}getTokenFromCode(code){if(code===64)return++this.pos,this.finishToken(atType);return super.getTokenFromCode(code)}readToken_lt_gt(code){if(this.inType)return this.finishOp(tt.relational,1);return super.readToken_lt_gt(code)}$a(fn){let old=this.inType;this.inType=!0;let result=fn();if(this.inType=old,!old&&this.type===tt.relational)this.pos=this.start,this.nextToken();return result}$1(){return this.type===tt.relational&&this.value==="<"}$p(){if(this.type===tt.bitShift&&this.value==="<<")this.pos=this.start+1,this.finishToken(tt.relational,"<");return this.$1()}$c(){return this.type===tt.relational&&this.value===">"}$u(){return this.type===tt.prefix&&this.value==="!"}hasPrecedingLineBreak(){return hasLineBreak(this.input,this.lastTokEnd,this.start)}$d(from=this.pos){return SKIP_WHITESPACE.lastIndex=from,SKIP_WHITESPACE.exec(this.input),SKIP_WHITESPACE.lastIndex}$2(){return this.input.charCodeAt(this.$d())}$3(){let start=this.$d(),end=start;while(end<this.input.length&&isIdentifierChar(this.input.charCodeAt(end)))end++;return this.input.slice(start,end)}$b(){return!hasLineBreak(this.input,this.pos,this.$d())}$14(){return this.$b()&&isIdentifierStart(this.$2())&&!Object.hasOwn(keywordTypes,this.$3())}$15(){return{pos:this.pos,type:this.type,value:this.value,start:this.start,end:this.end,startLoc:this.startLoc,endLoc:this.endLoc,lastTokStart:this.lastTokStart,lastTokEnd:this.lastTokEnd,lastTokStartLoc:this.lastTokStartLoc,lastTokEndLoc:this.lastTokEndLoc,curLine:this.curLine,lineStart:this.lineStart,context:this.context.slice(),exprAllowed:this.exprAllowed,containsEsc:this.containsEsc,inType:this.inType,$4:this.$4,$5:this.$5,$7:this.$7,scopes:this.scopeStack.length,privateNames:this.privateNameStack.length,labels:this.labels,labelCount:this.labels.length,strict:this.strict,yieldPos:this.yieldPos,awaitPos:this.awaitPos,awaitIdentPos:this.awaitIdentPos,potentialArrowAt:this.potentialArrowAt,potentialArrowInForAwait:this.potentialArrowInForAwait}}$16(state){this.pos=state.pos,this.type=state.type,this.value=state.value,this.start=state.start,this.end=state.end,this.startLoc=state.startLoc,this.endLoc=state.endLoc,this.lastTokStart=state.lastTokStart,this.lastTokEnd=state.lastTokEnd,this.lastTokStartLoc=state.lastTokStartLoc,this.lastTokEndLoc=state.lastTokEndLoc,this.curLine=state.curLine,this.lineStart=state.lineStart,this.context=state.context,this.exprAllowed=state.exprAllowed,this.containsEsc=state.containsEsc,this.inType=state.inType,this.$4=state.$4,this.$5=state.$5,this.$7=state.$7,this.scopeStack.length=state.scopes,this.privateNameStack.length=state.privateNames,this.labels=state.labels,this.labels.length=state.labelCount,this.strict=state.strict,this.yieldPos=state.yieldPos,this.awaitPos=state.awaitPos,this.awaitIdentPos=state.awaitIdentPos,this.potentialArrowAt=state.potentialArrowAt,this.potentialArrowInForAwait=state.potentialArrowInForAwait}raise(pos,message){if(this.$n>0)throw SPECULATION_FAILED;return super.raise(pos,message)}$1y(pos,message){try{super.raise(pos,message)}catch(error){if(error instanceof SyntaxError)error.$1z=!0;throw error}throw Error("unreachable")}$g(fn,lookahead=!1){let state=this.$15();this.$n++;try{let result=fn();if(lookahead||result===void 0)this.$16(state);return result}catch(error){if(!(error instanceof SyntaxError)||!lookahead&&error.$1z)throw error;this.$16(state);return}finally{this.$n--}}$v(fn){return this.$g(fn,!0)===!0}$17(node){if(node.end=this.lastTokEnd,this.options.locations)node.loc.end=this.lastTokEndLoc}$q(node,from){if(node.start=from.start,this.options.locations)node.loc.start=from.loc.start}$6(returnType=!1){let node=this.startNode();return node.typeAnnotation=this.$a(()=>(this.next(),returnType?this.$20():this.$0())),this.finishNode(node,"TSTypeAnnotation")}$h(node,optional){if(optional&&this.eat(tt.question))node.optional=!0,this.$17(node);if(this.type===tt.colon)node.typeAnnotation=this.$6(),this.$17(node);return node}$20(){if(this.type!==tt.name&&this.type!==tt._this)return this.$0();if(this.isContextual("asserts")&&this.$b()&&isIdentifierStart(this.$2())){let node=this.startNode();if(this.next(),node.parameterName=this.type===tt._this?this.$w():this.parseIdent(),this.isContextual("is")&&!this.hasPrecedingLineBreak())return this.$x(node,!0);return node.asserts=!0,node.typeAnnotation=null,this.finishNode(node,"TSTypePredicate")}if(this.$3()==="is"&&this.$b()){let node=this.startNode();return node.parameterName=this.type===tt._this?this.$w():this.parseIdent(!0),this.$x(node,!1)}return this.$0()}$x(node,asserts){this.next();let annotation=this.startNode();return annotation.typeAnnotation=this.$0(),node.typeAnnotation=this.finishNode(annotation,"TSTypeAnnotation"),node.asserts=asserts,this.finishNode(node,"TSTypePredicate")}$w(){let node=this.startNode();return this.next(),this.finishNode(node,"TSThisType")}parseWholeType(){this.inType=!0,this.nextToken();let type=this.$0();if(this.type!==tt.eof)this.unexpected();return type}$0(){let type=this.$18();if(this.$4||this.type!==tt._extends||this.hasPrecedingLineBreak())return type;let node=this.startNodeAt(type.start,type.loc?.start);return this.next(),node.checkType=type,node.extendsType=this.$i(!0,()=>this.$18()),this.expect(tt.question),node.trueType=this.$i(!1,()=>this.$0()),this.expect(tt.colon),node.falseType=this.$i(!1,()=>this.$0()),this.finishNode(node,"TSConditionalType")}$i(disallow,fn){let old=this.$4;this.$4=disallow;let result=fn();return this.$4=old,result}$18(){if(this.$21())return this.$19("TSFunctionType");if(this.type===tt._new||this.isContextual("abstract")&&this.$3()==="new")return this.$19("TSConstructorType");return this.$1a("TSUnionType",tt.bitwiseOR,()=>this.$1a("TSIntersectionType",tt.bitwiseAND,()=>this.$1b()))}$19(type){let node=this.startNode();if(type==="TSConstructorType"){if(node.abstract=this.isContextual("abstract"),node.abstract)this.next();this.next()}return this.$i(!1,()=>this.$r(node,tt.arrow)),this.finishNode(node,type)}$r(node,returnToken){if(this.$1())node.typeParameters=this.$8();if(this.expect(tt.parenL),node.parameters=this.parseBindingList(tt.parenR,!1,!0),this.type===returnToken)node.typeAnnotation=this.$6(!0);else if(returnToken===tt.arrow)this.unexpected()}$21(){if(this.$1())return!0;if(this.type!==tt.parenL)return!1;return this.$v(()=>{if(this.next(),this.type===tt.parenR||this.type===tt.ellipsis)return!0;if(this.type===tt.name||this.type===tt._this)this.next();else if(this.type===tt.braceL||this.type===tt.bracketL)this.parseBindingAtom();else return!1;let type=this.type;if(type===tt.colon||type===tt.comma||type===tt.question||type===tt.eq)return!0;if(type!==tt.parenR)return!1;return this.next(),this.type===tt.arrow})}$1a(type,operator,parseConstituent){let node=this.startNode(),hasLeadingOperator=this.eat(operator),types=[];do types.push(parseConstituent());while(this.eat(operator));if(types.length===1&&!hasLeadingOperator)return types[0];return node.types=types,this.finishNode(node,type)}$1b(){if(this.type===tt.name&&!this.containsEsc){let value=this.value;if(value==="keyof"||value==="unique"||value==="readonly"){let node=this.startNode();return this.next(),node.operator=value,node.typeAnnotation=this.$1b(),this.finishNode(node,"TSTypeOperator")}if(value==="infer"){let node=this.startNode();this.next();let parameter=this.startNode();parameter.name=this.$y();let constraint=this.$g(()=>this.$22());if(constraint)parameter.constraint=constraint;return node.typeParameter=this.finishNode(parameter,"TSTypeParameter"),this.finishNode(node,"TSInferType")}}return this.$i(!1,()=>this.$23())}$22(){if(!this.eat(tt._extends))return;let constraint=this.$i(!0,()=>this.$0());return this.$4||this.type!==tt.question?constraint:void 0}$y(){if(this.type!==tt.name&&!this.type.keyword)this.unexpected();let name=this.type===tt.name?this.value:this.type.keyword;return this.next(),name}$23(){let type=this.$24();while(!this.hasPrecedingLineBreak()&&this.eat(tt.bracketL)){let node=this.startNodeAt(type.start,type.loc?.start);if(this.eat(tt.bracketR))node.elementType=type,type=this.finishNode(node,"TSArrayType");else node.objectType=type,node.indexType=this.$0(),this.expect(tt.bracketR),type=this.finishNode(node,"TSIndexedAccessType")}return type}$24(){switch(this.type){case tt.name:case tt._void:case tt._null:{let keyword=KEYWORD_TYPES.get(this.value);if(keyword&&(this.type!==tt.name||!this.containsEsc&&this.$2()!==CHAR_DOT)){let node=this.startNode();return this.next(),this.finishNode(node,keyword)}return this.$1c()}case tt.string:case tt.num:case tt._true:case tt._false:{let node=this.startNode();return node.literal=this.parseExprAtom(),this.finishNode(node,"TSLiteralType")}case tt.plusMin:{if(this.value!=="-")break;let node=this.startNode(),unary=this.startNode();if(this.next(),this.type!==tt.num)this.unexpected();return unary.operator="-",unary.prefix=!0,unary.argument=this.parseExprAtom(),node.literal=this.finishNode(unary,"UnaryExpression"),this.finishNode(node,"TSLiteralType")}case tt.backQuote:return this.$25();case tt._this:{let thisType=this.$w();if(this.isContextual("is")&&!this.hasPrecedingLineBreak()){let node=this.startNodeAt(thisType.start,thisType.loc?.start);return node.parameterName=thisType,this.$x(node,!1)}return thisType}case tt._typeof:return this.$26();case tt._import:return this.$1d();case tt.braceL:return this.$27()?this.$28():this.$29();case tt.bracketL:return this.$2a();case tt.parenL:{let node=this.startNode();return this.next(),node.typeAnnotation=this.$0(),this.expect(tt.parenR),this.finishNode(node,"TSParenthesizedType")}default:if(this.type.keyword)return this.$1c()}return this.unexpected()}$1c(){let node=this.startNode();if(node.typeName=this.$j(),!this.hasPrecedingLineBreak()&&this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSTypeReference")}$j(){let entity=this.parseIdent(!0);while(this.eat(tt.dot)){let node=this.startNodeAt(entity.start,entity.loc?.start);node.left=entity,node.right=this.parseIdent(!0),entity=this.finishNode(node,"TSQualifiedName")}return entity}$26(){let node=this.startNode();if(this.next(),node.exprName=this.type===tt._import?this.$1d():this.$j(),!this.hasPrecedingLineBreak()&&this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSTypeQuery")}$1d(){let node=this.startNode();if(this.next(),node.argument=this.$1e(),this.eat(tt.dot))node.qualifier=this.$j();if(this.$1())node.typeArguments=this.$e();return this.finishNode(node,"TSImportType")}$z(){if(this.type!==tt.string)this.unexpected();return this.parseExprAtom()}$1e(){this.expect(tt.parenL);let string=this.$z();return this.expect(tt.parenR),string}$25(){let node=this.startNode(),literal=this.startNode();this.next(),literal.expressions=[];let element=this.parseTemplateElement({isTagged:!1});literal.quasis=[element];while(!element.tail){if(this.type===tt.eof)this.raise(this.pos,"Unterminated template literal");this.expect(tt.dollarBraceL),literal.expressions.push(this.$0()),this.expect(tt.braceR),element=this.parseTemplateElement({isTagged:!1}),literal.quasis.push(element)}return this.next(),node.literal=this.finishNode(literal,"TemplateLiteral"),this.finishNode(node,"TSLiteralType")}$27(){return this.$v(()=>{if(this.next(),this.type===tt.plusMin)return this.next(),this.isContextual("readonly");if(this.isContextual("readonly"))this.next();if(this.type!==tt.bracketL)return!1;if(this.next(),this.type!==tt.name)return!1;return this.next(),this.type===tt._in})}$28(){let node=this.startNode();if(this.expect(tt.braceL),this.type===tt.plusMin)node.readonly=this.value,this.next(),this.expectContextual("readonly");else if(this.eatContextual("readonly"))node.readonly=!0;this.expect(tt.bracketL);let parameter=this.startNode();if(parameter.name=this.$y(),this.expect(tt._in),parameter.constraint=this.$0(),node.typeParameter=this.finishNode(parameter,"TSTypeParameter"),node.nameType=this.eatContextual("as")?this.$0():null,this.expect(tt.bracketR),this.type===tt.plusMin)node.optional=this.value,this.next(),this.expect(tt.question);else if(this.eat(tt.question))node.optional=!0;if(this.eat(tt.colon))node.typeAnnotation=this.$0();return this.semicolon(),this.expect(tt.braceR),this.finishNode(node,"TSMappedType")}$29(){let node=this.startNode();return node.members=this.$1f(),this.finishNode(node,"TSTypeLiteral")}$1f(){this.expect(tt.braceL);let members=[];while(!this.eat(tt.braceR))members.push(this.$2b());return members}$2b(){let node=this.startNode(),type="TSPropertySignature",next=this.type===tt._new?this.$2():-1;if(this.type===tt.parenL||this.$1())type="TSCallSignatureDeclaration",this.$r(node,tt.colon);else if(next===CHAR_PAREN_L||next===CHAR_LT)type="TSConstructSignatureDeclaration",this.next(),this.$r(node,tt.colon);else{let newKey=this.type===tt._new?this.parseIdent(!0):null;if(this.isContextual("readonly")&&this.$s(!0))this.next(),node.readonly=!0;if(this.type===tt.bracketL&&this.$1g())return this.$1h(node);let kind="method";if(newKey)node.key=newKey;else{if((this.isContextual("get")||this.isContextual("set"))&&this.$s(!1))kind=this.value,this.next();this.parsePropertyName(node)}if(this.eat(tt.question))node.optional=!0;if(this.type===tt.parenL||this.$1()){if(type="TSMethodSignature",kind!=="method")node.kind=kind;this.$r(node,tt.colon),node.kind=kind}else if(this.type===tt.colon)node.typeAnnotation=this.$6()}return this.$1i(),this.finishNode(node,type)}$1i(){if(!this.eat(tt.comma))this.semicolon()}$1g(){return this.$v(()=>{if(this.next(),this.type!==tt.name)return!1;return this.next(),this.type===tt.colon})}$1h(node){if(this.expect(tt.bracketL),node.parameters=[this.$h(this.parseIdent(),!1)],this.expect(tt.bracketR),this.type===tt.colon)node.typeAnnotation=this.$6();return this.$1i(),this.finishNode(node,"TSIndexSignature")}$2a(){let node=this.startNode();this.expect(tt.bracketL),node.elementTypes=[];while(!this.eat(tt.bracketR))if(node.elementTypes.push(this.$2c()),this.type!==tt.bracketR)this.expect(tt.comma);return this.finishNode(node,"TSTupleType")}$2c(){let start=this.start,startLoc=this.startLoc,rest=this.eat(tt.ellipsis),element;if((this.type===tt.name||this.type.keyword)&&this.$2d()){let node=this.startNode();node.label=this.parseIdent(!0),node.optional=this.eat(tt.question),this.expect(tt.colon),node.elementType=this.$0(),element=this.finishNode(node,"TSNamedTupleMember")}else if(element=this.$0(),this.eat(tt.question)){let node=this.startNodeAt(element.start,element.loc?.start);node.typeAnnotation=element,element=this.finishNode(node,"TSOptionalType")}if(rest){let node=this.startNodeAt(start,startLoc);node.typeAnnotation=element,element=this.finishNode(node,"TSRestType")}return element}$2d(){let at=this.$d();if(this.input.charCodeAt(at)===63)at=this.$d(at+1);return this.input.charCodeAt(at)===CHAR_COLON}$8(){return this.$a(()=>{let node=this.startNode();this.next(),node.params=[];while(!this.$c()){let parameter=this.startNode();while((this.type===tt._const||this.type===tt._in||this.isContextual("out"))&&isIdentifierStart(this.$2()))parameter[this.value]=!0,this.next();if(parameter.name=this.$y(),this.eat(tt._extends))parameter.constraint=this.$0();if(this.eat(tt.eq))parameter.default=this.$0();if(node.params.push(this.finishNode(parameter,"TSTypeParameter")),!this.$c()){if(this.expect(tt.comma),this.$c())node.extra={trailingComma:this.lastTokStart}}}if(this.next(),node.params.length===0)this.$1y(this.start,"Type parameter list cannot be empty.");return this.finishNode(node,"TSTypeParameterDeclaration")})}$e(){return this.$a(()=>{let node=this.startNode();this.next(),node.params=[];while(!this.$c())if(node.params.push(this.$0()),!this.$c())this.expect(tt.comma);if(node.params.length===0)this.unexpected();return this.next(),this.finishNode(node,"TSTypeParameterInstantiation")})}$1j(){let list=[];do{let node=this.startNode();if(node.expression=this.$j(),this.$1())node.typeParameters=this.$e();list.push(this.finishNode(node,"TSExpressionWithTypeArguments"))}while(this.eat(tt.comma));return list}$1k(exported=!1){if(this.type!==tt.name||this.containsEsc){if(this.type===tt._const&&this.$3()==="enum")return this.$10(this.startNode());return}if(!this.$2e(this.value))return;if(this.value==="declare")return this.$2f(exported);return this.$1l(this.startNode(),this.value)}$2e(word){switch(word){case"interface":case"type":case"namespace":return this.$14();case"enum":return isIdentifierStart(this.$2());case"abstract":return this.$b()&&this.$3()==="class";case"module":{let next=this.$2();return this.$b()&&(next===CHAR_DQUOTE||next===CHAR_SQUOTE||isIdentifierStart(next))}case"declare":return this.$b()&&DECLARE_TARGETS.has(this.$3());case"global":return this.$b()&&this.$2()===CHAR_BRACE_L}return!1}$1l(node,word){switch(word){case"interface":return this.$1m(node);case"type":return this.$2g(node);case"enum":return this.$10(node);case"abstract":return this.$1n(node,!0);case"global":return node.global=!0,node.id=this.parseIdent(),node.body=this.$11(),this.finishNode(node,"TSModuleDeclaration")}return this.$2h(node)}$2f(exported){let old=this.$5;this.$5=!0;let node=this.startNode();this.next();let word=this.value;if(word==="const"&&this.$3()==="enum")node.const=!0;if(!exported&&DECLARE_FIRST.has(word))node.declare=!0;let declaration;if(node.const)declaration=this.$10(node);else if(word==="var"||word==="let"||word==="const")declaration=this.parseVarStatement(node,word,!0);else if(word==="function")this.next(),declaration=this.parseFunction(node,FUNC_STATEMENT,!1,!1);else if(word==="class")declaration=this.parseClass(node,!0);else declaration=this.$1l(node,word);return declaration.declare=!0,this.$5=old,declaration}$1n(node,isStatement){return this.next(),node.abstract=!0,this.parseClass(node,isStatement)}$1m(node){if(this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_INTERFACE),this.$1())node.typeParameters=this.$8();return this.$a(()=>{if(this.eat(tt._extends))node.extends=this.$1j();let body=this.startNode();body.body=this.$1f(),node.body=this.finishNode(body,"TSInterfaceBody")}),this.finishNode(node,"TSInterfaceDeclaration")}$2g(node){if(this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_TYPE),this.$1())node.typeParameters=this.$8();return node.typeAnnotation=this.$a(()=>(this.expect(tt.eq),this.$0())),this.semicolon(),this.finishNode(node,"TSTypeAliasDeclaration")}$10(node){if(this.type===tt._const)node.const=!0,this.next();this.next(),node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_ENUM),this.expect(tt.braceL),node.members=[];while(!this.eat(tt.braceR)){let member=this.startNode();if(member.id=this.type===tt.string?this.parseExprAtom():this.parseIdent(!0),this.eat(tt.eq))member.initializer=this.parseMaybeAssign();if(node.members.push(this.finishNode(member,"TSEnumMember")),this.type!==tt.braceR)this.expect(tt.comma)}return this.finishNode(node,"TSEnumDeclaration")}$2h(node){if(this.next(),this.type===tt.string){if(node.id=this.parseExprAtom(),this.type===tt.braceL)node.body=this.$11();else this.semicolon();return this.finishNode(node,"TSModuleDeclaration")}return node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_TS_NAMESPACE),this.$1o(node)}$1o(node){if(this.eat(tt.dot)){let inner=this.startNode();inner.id=this.parseIdent(),node.body=this.$1o(inner)}else node.body=this.$11();return this.finishNode(node,"TSModuleDeclaration")}$11(){this.enterScope(SCOPE_CLASS_STATIC_BLOCK);let node=this.startNode();this.enterScope(0),this.expect(tt.braceL),node.body=[];while(!this.eat(tt.braceR))node.body.push(this.parseStatement(null,!0));return this.exitScope(),this.exitScope(),this.finishNode(node,"TSModuleBlock")}$1p(node,isExport){if(node.isExport=isExport,node.id=this.parseIdent(),this.checkLValSimple(node.id,BIND_LEXICAL),this.expect(tt.eq),this.isContextual("require")&&this.$2()===CHAR_PAREN_L){let reference=this.startNode();this.next(),reference.expression=this.$1e(),node.moduleReference=this.finishNode(reference,"TSExternalModuleReference")}else node.moduleReference=this.$j();return this.semicolon(),this.finishNode(node,"TSImportEqualsDeclaration")}$2i(){let at=this.$d();if(this.input.charCodeAt(at)!==CHAR_EQ)return!1;let after=this.input.charCodeAt(at+1);return after!==CHAR_EQ&&after!==62}parseStatement(context,topLevel,exports){if(this.type===atType)this.$1q(!0);let declaration=this.$1k();if(declaration)return declaration;return super.parseStatement(context,topLevel,exports)}parseVarStatement(node,kind,allowMissingInitializer){return super.parseVarStatement(node,kind,allowMissingInitializer||this.$5)}parseVarId(decl,kind){if(super.parseVarId(decl,kind),decl.id.type==="Identifier"&&this.$u()&&!this.hasPrecedingLineBreak())this.next(),decl.definite=!0;this.$h(decl.id,!1)}parseCatchClauseParam(){let param=this.$h(this.parseBindingAtom(),!1),simple=param.type==="Identifier";return this.enterScope(simple?SCOPE_SIMPLE_CATCH:0),this.checkLValPattern(param,simple?BIND_SIMPLE_CATCH:BIND_LEXICAL),this.expect(tt.parenR),param}parseImport(node){if(this.next(),node.importKind="value",this.type===tt.string)node.specifiers=[],node.source=this.parseExprAtom();else{if(this.isContextual("type")){let next=this.$2();if(next===CHAR_BRACE_L||next===CHAR_STAR||isIdentifierStart(next)&&this.$3()!=="from")node.importKind="type",this.next()}if(this.type===tt.name&&this.$2i())return this.$1p(node,!1);node.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),node.source=this.$z()}return this.$1r(node),this.semicolon(),this.finishNode(node,"ImportDeclaration")}parseWithClause(){if(this.isContextual("assert")&&!this.hasPrecedingLineBreak())this.type=tt._with;return this.type===tt._with?super.parseWithClause():void 0}$1r(node){let attributes=this.parseWithClause();if(attributes)node.attributes=attributes}parseImportSpecifier(){return this.$1s("importKind",()=>super.parseImportSpecifier())}parseExportSpecifier(exports){return this.$1s("exportKind",()=>super.parseExportSpecifier(exports))}$1s(kindKey,parse){let next=this.isContextual("type")?this.$2():-1;if(next===CHAR_DQUOTE||next===CHAR_SQUOTE||isIdentifierStart(next)&&this.$3()!=="as"){let modifier=this.startNode();this.next();let node=parse();return this.$q(node,modifier),node[kindKey]="type",node}let node=parse();return node[kindKey]="value",node}parseExport(node,exports){if(this.next(),this.eat(tt._import)){if(node.importKind="value",this.isContextual("type")&&isIdentifierStart(this.$2())&&this.$3()!=="from")node.importKind="type",this.next();return this.$1p(node,!0)}if(this.eat(tt.eq))return node.expression=this.parseExpression(),this.semicolon(),this.finishNode(node,"TSExportAssignment");if(this.eatContextual("as"))return this.expectContextual("namespace"),node.id=this.parseIdent(),this.semicolon(),this.finishNode(node,"TSNamespaceExportDeclaration");if(node.exportKind="value",this.isContextual("type")){let next=this.$2();if(next===CHAR_BRACE_L||next===CHAR_STAR)node.exportKind="type",this.next()}if(this.eat(tt.star))return this.parseExportAllDeclaration(node,exports);if(this.eat(tt._default)){if(this.isContextual("interface")&&this.$14())node.declaration=this.$1m(this.startNode());else if(this.isContextual("abstract")&&this.$3()==="class")node.declaration=this.$1n(this.startNode(),"nullableID");else node.declaration=this.parseExportDefaultDeclaration();return this.finishNode(node,"ExportDefaultDeclaration")}let isDeclare=this.isContextual("declare"),declaration=this.$1k(!0);if(declaration||this.shouldParseExportStatement()){if(node.declaration=declaration??this.parseStatement(null),isDeclare||node.declaration.type==="TSInterfaceDeclaration"||node.declaration.type==="TSTypeAliasDeclaration")node.exportKind="type";return node.specifiers=[],node.source=null,this.finishNode(node,"ExportNamedDeclaration")}if(node.declaration=null,node.specifiers=this.parseExportSpecifiers(exports),this.eatContextual("from"))node.source=this.$z(),this.$1r(node);else{for(let spec of node.specifiers)if(this.checkUnreserved(spec.local),this.checkLocalExport(spec.local),spec.local.type==="Literal")this.raise(spec.local.start,"A string literal cannot be used as an exported binding without `from`.");node.source=null}return this.semicolon(),this.finishNode(node,"ExportNamedDeclaration")}parseFunction(node,statement,allowExpressionBody,isAsync,forInit){let isDeclaration=statement&FUNC_STATEMENT;if(isDeclaration)this.$f=node,this.$o=node.start;super.parseFunction(node,statement,allowExpressionBody,isAsync,forInit),this.$f=null;let bodiless=!node.body;if(bodiless)node.type="TSDeclareFunction";if(isDeclaration&&node.id){if(bodiless){if(this.$5&&this.currentScope().flags&SCOPE_TOP)this.declareName(node.id.name,BIND_FLAGS_TS_EXPORT_ONLY,node.id.start);this.checkLValSimple(node.id,BIND_NONE)}else if(!(statement&FUNC_HANGING_STATEMENT)){let bindingType=BIND_FUNCTION;if(this.strict||node.generator||node.async)bindingType=this.treatFunctionsAsVar?BIND_VAR:BIND_LEXICAL;this.checkLValSimple(node.id,bindingType)}}return node}parseFunctionParams(node){if(this.$1())node.typeParameters=this.$8();if(super.parseFunctionParams(node),this.type===tt.colon)node.returnType=this.$6(!0)}parseFunctionBody(node,isArrowFunction,isMethod,forInit){if(isMethod&&this.type===tt.colon)node.returnType=this.$6(!0);if(isArrowFunction||this.type===tt.braceL||node.start!==this.$o){super.parseFunctionBody(node,isArrowFunction,isMethod,forInit);return}this.semicolon(),this.exitScope()}parseMethod(isGenerator,isAsync,allowDirectSuper){let typeParameters=this.$k;this.$k=null;let node=super.parseMethod(isGenerator,isAsync,allowDirectSuper);if(!node.body)node.type="TSDeclareMethod";if(typeParameters)node.typeParameters=typeParameters;return node}parseBindingList(close,allowEmpty,allowTrailingComma,allowModifiers){let modifiers=allowModifiers===!0||this.$l;return this.$l=!1,super.parseBindingList(close,allowEmpty,allowTrailingComma,modifiers)}$s(allowLineBreak){if(!allowLineBreak&&!this.$b())return!1;let next=this.$2();return next===CHAR_BRACKET_L||next===CHAR_BRACE_L||next===CHAR_STAR||next===CHAR_DOT||next===CHAR_HASH||next===CHAR_DQUOTE||next===CHAR_SQUOTE||next>=48&&next<=57||isIdentifierStart(next)}parseAssignableListItem(allowModifiers){let decorators=this.$12(),start=this.start,startLoc=this.startLoc,accessibility,readonly=!1,override=!1;if(allowModifiers)while(this.type===tt.name&&PARAMETER_MODIFIERS.has(this.value)&&!this.containsEsc&&this.$s(!1)){if(this.value==="readonly")readonly=!0;else if(this.value==="override")override=!0;else accessibility=this.value;this.next()}let left;if(this.type===tt._this)left=this.startNode(),left.name="this",this.next(),this.finishNode(left,"Identifier");else left=this.parseBindingAtom();let element=this.type===tt.eq?this.parseMaybeDefault(start,startLoc,left):this.parseMaybeDefault(left.start,left.loc?.start,this.$h(left,!0));if(decorators.length>0)element.decorators=decorators;if(!accessibility&&!readonly&&!override)return element;let node=this.startNodeAt(start,startLoc);if(accessibility)node.accessibility=accessibility;if(readonly)node.readonly=!0;if(override)node.override=!0;return node.parameter=element,this.finishNode(node,"TSParameterProperty")}parseBindingListItem(param){if(param.type==="RestElement")this.$h(param,!0);return param}checkLValSimple(expr,bindingType,checkClashes){if(this.$f&&expr===this.$f.id){this.$f=null;return}if(!bindingType&&TS_EXPRESSION_WRAPPERS.has(expr.type)){this.checkLValSimple(expr.expression,bindingType,checkClashes);return}switch(expr.type){case"TSParameterProperty":this.checkLValInnerPattern(expr.parameter,bindingType,checkClashes);return;case"Identifier":if(expr.name==="this")return}super.checkLValSimple(expr,bindingType,checkClashes)}toAssignable(node,isBinding,refDestructuringErrors){if(node&&!isBinding&&TS_EXPRESSION_WRAPPERS.has(node.type))return node;return super.toAssignable(node,isBinding,refDestructuringErrors)}declareName(name,bindingType,pos){let scope=this.currentScope();if(bindingType&BIND_FLAGS_TS_EXPORT_ONLY){this.$1t(scope,name),scope.$1u??=[],scope.$1u.push(name);return}if(bindingType===BIND_TS_TYPE||bindingType===BIND_TS_INTERFACE){if(scope.$13??=[],bindingType===BIND_TS_TYPE&&hasName(scope.$13,name))this.raise(pos,`type '${name}' has already been declared.`);scope.$13.push(name),this.$1t(scope,name);return}if(bindingType&BIND_FLAGS_TS_ENUM){if(scope.$1v??=[],hasName(scope.$1v,name))return;super.declareName(name,BIND_LEXICAL,pos),scope.$1v.push(name);return}super.declareName(name,bindingType,pos)}$1t(scope,name){if(this.inModule&&scope.flags&SCOPE_TOP)delete this.undefinedExports[name]}checkLocalExport(id){for(let i=this.scopeStack.length-1;i>=0;i--){let scope=this.scopeStack[i];if(hasName(scope.$13,id.name)||hasName(scope.$1u,id.name))return}super.checkLocalExport(id)}checkExport(){}raiseRecoverable(pos,message){if(message==="Duplicate constructor in the same class")return;super.raiseRecoverable(pos,message)}$12(){let decorators=[];while(this.type===atType)decorators.push(this.$1w());return decorators}$1q(allowExport){let pending=this.$9[this.$9.length-1];while(this.type===atType)pending.push(this.$1w());if(this.type===tt._export){if(!allowExport)this.unexpected()}else if(this.type!==tt._class&&!((this.isContextual("abstract")||this.isContextual("declare"))&&this.$3()==="class"))this.raise(this.start,"Leading decorators must be attached to a class declaration.")}$1w(){let node=this.startNode();this.next(),this.$9.push([]);let startPos=this.start,startLoc=this.startLoc,expression;if(this.type===tt.parenL){if(this.next(),expression=this.parseExpression(),this.expect(tt.parenR),this.options.preserveParens){let paren=this.startNodeAt(startPos,startLoc);paren.expression=expression,expression=this.finishNode(paren,"ParenthesizedExpression")}}else{expression=this.parseIdent(!1);while(this.eat(tt.dot)){let member=this.startNodeAt(startPos,startLoc);member.object=expression,member.property=this.parseIdent(!0),member.computed=!1,expression=this.finishNode(member,"MemberExpression")}}let typeArguments=this.$p()?this.$e():void 0;if(this.eat(tt.parenL)){let call=this.startNodeAt(expression.start,expression.loc?.start);if(call.callee=expression,call.arguments=this.parseExprList(tt.parenR,!1,!1),typeArguments)call.typeArguments=typeArguments;expression=this.finishNode(call,"CallExpression")}else if(typeArguments){let instantiation=this.startNodeAt(expression.start,expression.loc?.start);instantiation.expression=expression,instantiation.typeArguments=typeArguments,expression=this.finishNode(instantiation,"TSInstantiationExpression")}return node.expression=expression,this.$9.pop(),this.finishNode(node,"Decorator")}shouldParseExportStatement(){return this.type===atType||super.shouldParseExportStatement()}parseExprAtom(refDestructuringErrors,forInit,forNew){if(this.type===atType)this.$1q(!1);return super.parseExprAtom(refDestructuringErrors,forInit,forNew)}parseProperty(isPattern,refDestructuringErrors){if(isPattern||this.type!==atType)return super.parseProperty(isPattern,refDestructuringErrors);let decorators=this.$12(),property=super.parseProperty(isPattern,refDestructuringErrors);if(property.type==="SpreadElement")this.raise(property.start,"Decorators can't be used with SpreadElement");return property.decorators=decorators,property}parseClassId(node,isStatement){let index=this.$9.length-1,decorators=this.$9[index];if(decorators.length>0)node.decorators=decorators,this.$q(node,decorators[0]),this.$9[index]=[];if(!this.isContextual("implements")||isStatement===!0)super.parseClassId(node,isStatement);if(this.$1())node.typeParameters=this.$8()}parseClassSuper(node){if(super.parseClassSuper(node),node.superClass&&this.$1())node.superTypeParameters=this.$e();if(this.eatContextual("implements"))node.implements=this.$a(()=>this.$1j())}parseClassElement(constructorAllowsSuper){if(this.type===atType){let decorators=this.$12();if(this.type===tt.braceR)this.raise(this.start,"Decorators must be attached to a class element.");let element=this.parseClassElement(constructorAllowsSuper);return element.decorators=decorators,this.$q(element,decorators[0]),element}if(this.eat(tt.semi))return null;let node=this.startNode();while(this.type===tt.name&&CLASS_MODIFIERS.has(this.value)&&!this.containsEsc&&this.$s(this.value==="static")){let modifier=this.value;if(this.next(),modifier==="static"&&this.type===tt.braceL)return this.next(),this.parseClassStaticBlock(node),node;if(modifier==="public"||modifier==="private"||modifier==="protected")node.accessibility=modifier;else node[modifier]=!0}if(this.type===tt.bracketL&&this.$1g())return this.$1h(node);node.static??=!1;let keyName="",isGenerator=!1,isAsync=!1,kind="method";if(this.eatContextual("async"))if((this.isClassElementNameStart()||this.type===tt.star)&&!this.canInsertSemicolon())isAsync=!0;else keyName="async";if(!keyName&&this.eat(tt.star))isGenerator=!0;if(!keyName&&!isAsync&&!isGenerator){let lastValue=this.value;if(this.eatContextual("get")||this.eatContextual("set"))if(this.isClassElementNameStart())kind=lastValue;else keyName=lastValue}if(keyName)node.computed=!1,node.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),node.key.name=keyName,this.finishNode(node.key,"Identifier");else this.parseClassElementName(node);if(this.eat(tt.question))node.optional=!0;if(this.type===tt.parenL||this.$1()||kind!=="method"||isGenerator||isAsync){let key=node.key,isConstructor=!node.static&&!node.computed&&(key.type==="Identifier"&&key.name==="constructor"||key.type==="Literal"&&key.value==="constructor");if(node.kind=isConstructor?"constructor":kind,this.$1())node.typeParameters=this.$8();this.$l=isConstructor,this.$o=this.start,this.parseClassMethod(node,isGenerator,isAsync,isConstructor&&constructorAllowsSuper)}else{if(!node.optional&&this.$u())this.next(),node.definite=!0;if(this.type===tt.colon)node.typeAnnotation=this.$6();this.parseClassField(node)}return node}parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse){if(this.$p()){let arrow=this.$g(()=>{let typeParameters=this.$8(),expr=super.parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse);if(expr.type!=="ArrowFunctionExpression")return;return expr.typeParameters=typeParameters,this.$q(expr,typeParameters),expr});if(arrow)return arrow}return super.parseMaybeAssign(forInit,refDestructuringErrors,afterLeftParse)}parseMaybeUnary(refDestructuringErrors,sawUnary,incDec,forInit){if(this.$p()){let node=this.startNode();return node.typeAnnotation=this.$a(()=>{this.next();let type=this.$0();if(!this.$c())this.unexpected();return this.next(),type}),node.expression=this.parseMaybeUnary(null,!1,!1,forInit),this.finishNode(node,"TSTypeAssertion")}return super.parseMaybeUnary(refDestructuringErrors,sawUnary,incDec,forInit)}parseMaybeConditional(forInit,refDestructuringErrors){let startPos=this.start,startLoc=this.startLoc,expr=this.parseExprOps(forInit,refDestructuringErrors);if(this.checkExpressionErrors(refDestructuringErrors))return expr;if(this.type===tt.question&&!(expr.type==="ArrowFunctionExpression"&&expr.start===startPos)&&!this.$2j()){this.next();let node=this.startNodeAt(startPos,startLoc);return node.test=expr,node.consequent=this.parseMaybeAssign(),this.expect(tt.colon),node.alternate=this.parseMaybeAssign(forInit),this.finishNode(node,"ConditionalExpression")}return expr}$2j(){let at=this.$d(),next=this.input.charCodeAt(at);if(next===CHAR_COLON||next===CHAR_COMMA||next===CHAR_PAREN_R)return!0;return next===CHAR_EQ&&this.input.charCodeAt(at+1)!==CHAR_EQ}parseParenItem(item){return this.$h(item,!0)}$1x(){if(this.type!==tt.colon)return!0;let returnType=this.$g(()=>{let type=this.$6(!0);return this.type===tt.arrow&&!this.canInsertSemicolon()?type:void 0});if(!returnType)return!1;return this.$7=returnType,!0}shouldParseArrow(exprList){return this.$1x()&&super.shouldParseArrow(exprList)}shouldParseAsyncArrow(){return this.$1x()&&super.shouldParseAsyncArrow()}parseArrowExpression(node,params,isAsync,forInit){if(this.$7)node.returnType=this.$7,this.$7=null;return super.parseArrowExpression(node,params,isAsync,forInit)}parseExprList(close,allowTrailingComma,allowEmpty,refDestructuringErrors){if(!this.$m)return super.parseExprList(close,allowTrailingComma,allowEmpty,refDestructuringErrors);this.$m=!1;let elements=[],first=!0;while(!this.eat(close)){if(first)first=!1;else if(this.expect(tt.comma),allowTrailingComma&&this.afterTrailingComma(close))break;if(this.type===tt.ellipsis){let spread=this.parseSpread(refDestructuringErrors);if(this.eat(tt.question))spread.optional=!0;if(this.type===tt.colon)spread.typeAnnotation=this.$6();elements.push(spread)}else elements.push(this.parseMaybeAssign(!1,refDestructuringErrors,this.parseParenItem))}return elements}parseSubscript(base,startPos,startLoc,noCalls,maybeAsyncArrow,optionalChained,forInit){if(this.$u()&&!this.hasPrecedingLineBreak()){let node=this.startNodeAt(startPos,startLoc);return this.exprAllowed=!1,this.next(),node.expression=base,this.finishNode(node,"TSNonNullExpression")}if(maybeAsyncArrow&&this.$1()){let arrow=this.$g(()=>this.$2k(startPos,startLoc,forInit));if(arrow)return arrow}let optional=this.type===tt.questionDot&&this.$2()===CHAR_LT;if(this.$1()||optional||this.type===tt.bitShift&&this.value==="<<"){let typeArguments=this.$g(()=>{if(optional)this.next();this.$p();let args=this.$e();if(this.type===tt.parenL&&!noCalls)return args;if(this.type===tt.backQuote)return optional?void 0:args;if(optional)return;if(this.$c()||this.type===tt.bitShift||this.type.startsExpr&&this.type!==tt.parenL&&!this.hasPrecedingLineBreak())return;return args});if(typeArguments){let node=this.startNodeAt(startPos,startLoc);if(this.type===tt.parenL&&!noCalls){if(this.next(),node.callee=base,node.arguments=this.parseExprList(tt.parenR,!0,!1),node.typeArguments=typeArguments,optional)base.optional=!0;if(optional||optionalChained)node.optional=optional;return this.finishNode(node,"CallExpression")}if(this.type===tt.backQuote)return node.tag=base,node.quasi=this.parseTemplate({isTagged:!0}),node.typeArguments=typeArguments,this.finishNode(node,"TaggedTemplateExpression");return node.expression=base,node.typeArguments=typeArguments,this.finishNode(node,"TSInstantiationExpression")}}if(maybeAsyncArrow&&this.type===tt.parenL)this.$m=!0;return super.parseSubscript(base,startPos,startLoc,noCalls,maybeAsyncArrow,optionalChained,forInit)}$2k(startPos,startLoc,forInit){let node=this.startNodeAt(startPos,startLoc);if(node.typeParameters=this.$8(),this.expect(tt.parenL),node.params=this.parseBindingList(tt.parenR,!1,!0),this.type===tt.colon)node.returnType=this.$6(!0);if(this.type!==tt.arrow||this.canInsertSemicolon())return;return this.next(),this.parseArrowExpression(node,node.params,!0,forInit)}parseDynamicImport(node){if(this.next(),node.source=this.parseMaybeAssign(),this.eat(tt.comma)&&this.type!==tt.parenR)node.arguments=[this.parseExpression()];return this.expect(tt.parenR),this.finishNode(node,"ImportExpression")}parseNew(){let node=super.parseNew();if(node.callee?.type!=="TSInstantiationExpression")return node;let result=this.startNodeAt(node.start,node.loc?.start);return result.callee=node.callee.expression,result.typeArguments=node.callee.typeArguments,result.arguments=node.arguments,this.finishNodeAt(result,"NewExpression",node.end,node.loc?.end)}parseExprOp(left,leftStartPos,leftStartLoc,minPrec,forInit){if(tt._in.binop>minPrec&&this.type===tt.name&&(this.value==="as"||this.value==="satisfies")&&!this.containsEsc&&!this.hasPrecedingLineBreak()){let isSatisfies=this.value==="satisfies",node=this.startNodeAt(leftStartPos,leftStartLoc);return node.expression=left,node.typeAnnotation=this.$a(()=>{if(this.next(),!isSatisfies&&this.type===tt._const){let reference=this.startNode();return reference.typeName=this.parseIdent(!0),this.finishNode(reference,"TSTypeReference")}return this.$0()}),this.finishNode(node,isSatisfies?"TSSatisfiesExpression":"TSAsExpression"),this.parseExprOp(node,leftStartPos,leftStartLoc,minPrec,forInit)}return super.parseExprOp(left,leftStartPos,leftStartLoc,minPrec,forInit)}parseGetterSetter(prop){prop.kind=prop.key.name,super.parseGetterSetter(prop)}parsePropertyValue(prop,isPattern,isGenerator,isAsync,startPos,startLoc,refDestructuringErrors,containsEsc){if(!isPattern&&this.$1()){if(this.$k=this.$8(),this.type!==tt.parenL)this.unexpected();prop.kind="init"}return super.parsePropertyValue(prop,isPattern,isGenerator,isAsync,startPos,startLoc,refDestructuringErrors,containsEsc)}}return TSParser});
|
|
2
|
+
export{tsPlugin};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var AUTOCLOSING_CHILDREN={li:["li"],dt:["dt","dd"],dd:["dt","dd"],p:"address article aside blockquote div dl fieldset footer form h1 h2 h3 h4 h5 h6 header hgroup hr main menu nav ol p pre section table ul".split(" "),rt:["rt","rp"],rp:["rt","rp"],optgroup:["optgroup"],option:["option","optgroup"],thead:["tbody","tfoot"],tbody:["tbody","tfoot"],tfoot:["tbody"],tr:["tr","tbody"],td:["td","th","tr"],th:["td","th","tr"]};function closingTagOmitted(current,next){return Object.hasOwn(AUTOCLOSING_CHILDREN,current)&&AUTOCLOSING_CHILDREN[current].includes(next)}
|
|
2
|
+
export{closingTagOmitted};
|