driftjs-compiler 0.0.12 → 0.0.13
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/dist/index-cjs.js +5 -14
- package/dist/index-es.js +711 -4277
- package/package.json +2 -2
package/dist/index-cjs.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e={TagOpen:`TagOpen`,TagOpenSlash:`TagOpenSlash`,TagClose:`TagClose`,TagSelfClose:`TagSelfClose`,Equals:`Equals`,Identifier:`Identifier`,StringLiteral:`StringLiteral`,Text:`Text`,Interpolation:`Interpolation`,Comment:`Comment`,DirectiveIf:`DirectiveIf`,DirectiveElseIf:`DirectiveElseIf`,DirectiveElse:`DirectiveElse`,DirectiveFor:`DirectiveFor`,DirectiveSwitch:`DirectiveSwitch`,DirectiveCase:`DirectiveCase`,DirectiveDefault:`DirectiveDefault`,BlockOpen:`BlockOpen`,BlockClose:`BlockClose`,EOF:`EOF`},
|
|
2
|
-
`&&(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`&&(u=!1);continue}if(d){v+=i,i===`/`&&v.endsWith(`*/`)&&(d=!1);continue}if(f){v+=i,l?l=!1:i===`\\`?l=!0:i===`[`?p=!0:i===`]`&&p?p=!1:i===`/`&&!p&&(f=!1,h=n.IdentifierOrLiteral);continue}if(c!==null){if(v+=i,l)l=!1;else if(i===`\\`)l=!0;else if(i===c)c=null,h=n.IdentifierOrLiteral;else if(c==="`"&&i===`{`&&v.endsWith("${")){let e=0;for(let t=v.length-3;t>=0&&v[t]===`\\`;t--)e++;e%2==0&&(_.push(s),c=null,s++,h=n.Start)}continue}if(i===`/`&&!l){let e=this.peek();if(e===`/`){u=!0,v+=i;continue}else if(e===`*`){d=!0,v+=i;continue}else if(this.isRegexStart(h)){f=!0,p=!1,v+=i;continue}else h=n.Punctuator}if(i===`"`||i===`'`||i==="`"){inQuote:c=i;v+=i;continue}if(i===`(`){h=n.Start,v+=i;continue}if(i===`)`){h=n.IdentifierOrLiteral,v+=i;continue}if(i===`[`){h=n.Start,v+=i;continue}if(i===`]`){h=n.IdentifierOrLiteral,v+=i;continue}if(i===`{`){s++,h=n.Start,v+=i;continue}if(i===`}`){if(s--,_.length>0&&s===_[_.length-1]&&(_.pop(),c="`"),h=n.IdentifierOrLiteral,s===0)return a===`attribute`&&o!==null?this.transitionTo({kind:t.BeforeAttributeName,tagName:o,isClosingTag:!1,entersRawText:m(o)}):this.transitionTo({kind:t.Data}),this.createToken(e.Interpolation,v,r);v+=i;continue}if(i===`+`||i===`-`){if(this.peek()===i){let e=this.advance();v+=i+e,h=h===n.IdentifierOrLiteral?n.PostfixOp:n.Start;continue}h=n.Punctuator,v+=i;continue}if(`=(,:;!&|?*%<>~^`.includes(i)){h=n.Punctuator,v+=i;continue}if(/[a-zA-Z0-9_$]/.test(i)){let e=i;for(;!this.isAtEnd()&&/[a-zA-Z0-9_$]/.test(this.peek());)e+=this.advance();h=g.has(e)?n.Keyword:n.IdentifierOrLiteral,v+=e;continue}v+=i}throw new i(`Unterminated interpolation expression, expected closing brace '}'`,r.line,r.column,r.offset)}readRawTextToken(){let n=this.state;if(n.kind!==t.RawText)throw Error(`Expected RawText state but found '${n.kind}'.`);let r=this.getLocation(),i=`</${n.tagName}`;if(this.isAtEnd())return this.transitionTo({kind:t.EOF}),this.getOrCreateEOFToken(r);if(this.isRawTextClosingTagAhead(i))return this.consumePattern(`</`),this.transitionTo({kind:t.EndTagOpen}),this.createToken(e.TagOpenSlash,`</`,r);let a=``;for(;!this.isAtEnd()&&!this.isRawTextClosingTagAhead(i);)a+=this.advance();return a.length>0?this.createToken(e.Text,a,r):(this.transitionTo({kind:t.EOF}),this.getOrCreateEOFToken(r))}readTextToken(){let t=this.getLocation(),n=``,r=()=>this.blockDepth>0&&this.blockElementDepthStack.length>0&&this.elementDepth===this.blockElementDepthStack[this.blockElementDepthStack.length-1];for(;!this.isAtEnd();){let e=this.peek();if(e===`<`||e===`{`||e===`@`||e===`}`&&r())break;n+=this.advance()}return this.createToken(e.Text,n,t)}readQuotedStringToken(n,r,a){let o=``,s=!1;for(;!this.isAtEnd();){let i=this.peek();if(s){s=!1,o+=this.advance();continue}if(i===`\\`){s=!0,this.advance();continue}if(i===r)return this.advance(),this.transitionTo({kind:t.BeforeAttributeName,tagName:a,isClosingTag:!1,entersRawText:m(a)}),this.createToken(e.StringLiteral,o,n);o+=this.advance()}throw new i(`Unterminated string literal, expected closing quote ${r}`,n.line,n.column,n.offset)}readIdentifierValue(){let e=``;for(;!this.isAtEnd()&&this.isIdentifierChar(this.peek());)e+=this.advance();return e}getOrCreateEOFToken(t=this.getLocation()){return this.eofToken===null&&(this.eofToken={type:e.EOF,value:``,loc:{start:t,end:t}}),this.eofToken}createToken(e,t,n){return{type:e,value:t,loc:{start:n,end:this.getLocation()}}}createUnexpectedEOFError(e){let t=this.getLocation();return new i(`Unexpected end of input ${e}`,t.line,t.column,t.offset)}transitionTo(e){if(!p[this.state.kind].some(t=>t.to===e.kind))throw Error(`Invalid lexer transition from '${this.state.kind}' to '${e.kind}'.`);this.state=e}getLocation(){return{line:this.line,column:this.column,offset:this.offset}}isAtEnd(){return this.offset>=this.source.length}peek(e=0){let t=this.offset+e;return t>=this.source.length?``:this.source[t]??``}advance(){let e=this.source[this.offset]??``;return this.offset++,e===`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("driftjs-shared"),l=require("acorn");l=s(l,1);let u=require("acorn-walk");u=s(u,1);var d={TagOpen:`TagOpen`,TagOpenSlash:`TagOpenSlash`,TagClose:`TagClose`,TagSelfClose:`TagSelfClose`,Equals:`Equals`,Identifier:`Identifier`,StringLiteral:`StringLiteral`,Text:`Text`,Interpolation:`Interpolation`,Comment:`Comment`,DirectiveIf:`DirectiveIf`,DirectiveElseIf:`DirectiveElseIf`,DirectiveElse:`DirectiveElse`,DirectiveFor:`DirectiveFor`,DirectiveSwitch:`DirectiveSwitch`,DirectiveCase:`DirectiveCase`,DirectiveDefault:`DirectiveDefault`,BlockOpen:`BlockOpen`,BlockClose:`BlockClose`,EOF:`EOF`},f={Data:`Data`,TagOpen:`TagOpen`,EndTagOpen:`EndTagOpen`,BeforeAttributeName:`BeforeAttributeName`,AttributeName:`AttributeName`,AfterAttributeName:`AfterAttributeName`,BeforeAttributeValue:`BeforeAttributeValue`,AttributeValueQuoted:`AttributeValueQuoted`,AttributeValueInterpolation:`AttributeValueInterpolation`,Comment:`Comment`,Interpolation:`Interpolation`,RawText:`RawText`,EOF:`EOF`},p=function(e){return e[e.Start=0]=`Start`,e[e.Punctuator=1]=`Punctuator`,e[e.Keyword=2]=`Keyword`,e[e.IdentifierOrLiteral=3]=`IdentifierOrLiteral`,e[e.PostfixOp=4]=`PostfixOp`,e}({}),m={Program:`Program`,Element:`Element`,Text:`Text`,Interpolation:`Interpolation`,Attribute:`Attribute`,Comment:`Comment`,If:`If`,For:`For`,Switch:`Switch`},h=class extends Error{line;column;offset;constructor(e,t,n,r){super(`LexerError [${t}:${n}]: ${e}`),this.line=t,this.column=n,this.offset=r,this.name=`DriftLexerError`}},g=class extends Error{line;column;offset;constructor(e,t,n,r){super(`ParserError [${t}:${n}]: ${e}`),this.line=t,this.column=n,this.offset=r,this.name=`DriftParserError`}},_=function(e){return e[e.RETURN=0]=`RETURN`,e[e.CREATE_ELEMENT=1]=`CREATE_ELEMENT`,e[e.CREATE_TEXT=2]=`CREATE_TEXT`,e[e.CREATE_COMMENT=3]=`CREATE_COMMENT`,e[e.APPEND_CHILD=4]=`APPEND_CHILD`,e[e.SET_ATTR=5]=`SET_ATTR`,e[e.CREATE_FRAGMENT=6]=`CREATE_FRAGMENT`,e[e.INTERPOLATE_TEXT=7]=`INTERPOLATE_TEXT`,e[e.EXEC_SCRIPT=12]=`EXEC_SCRIPT`,e[e.REACTIVE_IF=13]=`REACTIVE_IF`,e[e.REACTIVE_FOR=14]=`REACTIVE_FOR`,e[e.MOUNT_COMPONENT=15]=`MOUNT_COMPONENT`,e}({}),v={[f.Data]:[{to:f.Comment,when:`The next characters are <!--`,emits:`Comment`},{to:f.EndTagOpen,when:`The next characters are </`,emits:`TagOpenSlash`},{to:f.TagOpen,when:`The next character is '<' for a start tag`,emits:`TagOpen`},{to:f.Interpolation,when:`The next character is '{' in element content`,emits:`Interpolation`},{to:f.Data,when:`Plain content is consumed up to the next control delimiter`,emits:`Text`},{to:f.EOF,when:`The source has been fully consumed`,emits:`EOF`}],[f.TagOpen]:[{to:f.BeforeAttributeName,when:`A valid opening tag name is consumed`,emits:`Identifier`}],[f.EndTagOpen]:[{to:f.BeforeAttributeName,when:`A valid closing tag name is consumed`,emits:`Identifier`}],[f.BeforeAttributeName]:[{to:f.AttributeName,when:`An attribute name begins in an opening tag`,emits:`Identifier`},{to:f.Data,when:`A tag is closed with '>' and raw-text mode does not apply`,emits:`TagClose`},{to:f.RawText,when:`A script/style start tag is closed with '>'`,emits:`TagClose`},{to:f.Data,when:`A tag is self-closed with '/>'`,emits:`TagSelfClose`}],[f.AttributeName]:[{to:f.AfterAttributeName,when:`The attribute identifier has been fully consumed`,emits:`Identifier`}],[f.AfterAttributeName]:[{to:f.BeforeAttributeValue,when:`The next character is '='`,emits:`Equals`},{to:f.BeforeAttributeName,when:`The attribute is boolean and the lexer moves to the next attribute or tag boundary`,emits:`No token`}],[f.BeforeAttributeValue]:[{to:f.AttributeValueQuoted,when:`The attribute value starts with a quote`,emits:`StringLiteral`},{to:f.AttributeValueInterpolation,when:`The attribute value starts with '{'`,emits:`Interpolation`}],[f.AttributeValueQuoted]:[{to:f.BeforeAttributeName,when:`The closing quote is consumed`,emits:`StringLiteral`}],[f.AttributeValueInterpolation]:[{to:f.BeforeAttributeName,when:`The interpolation closes and the attribute value is complete`,emits:`Interpolation`}],[f.Comment]:[{to:f.Data,when:`The terminating --> delimiter is consumed`,emits:`Comment`}],[f.Interpolation]:[{to:f.Data,when:`A content interpolation closes with a matching brace`,emits:`Interpolation`},{to:f.BeforeAttributeName,when:`An attribute interpolation closes with a matching brace`,emits:`Interpolation`}],[f.RawText]:[{to:f.RawText,when:`Plain raw-text content is consumed before the matching closing tag`,emits:`Text`},{to:f.EndTagOpen,when:`The matching raw-text closing tag begins with </`,emits:`TagOpenSlash`},{to:f.EOF,when:`The raw-text block reaches end of input before a closing tag appears`,emits:`EOF`}],[f.EOF]:[{to:f.EOF,when:`Additional parser requests are made after end of input`,emits:`EOF`}]};function y(e){return e===`script`||e===`style`}var b=new Set([`if`,`else`,`for`,`switch`,`case`,`default`]),x=new Set([`return`,`yield`,`await`,`case`,`typeof`,`void`,`delete`,`instanceof`,`in`,`do`,`throw`,`new`]),S=class{source;offset=0;line=1;column=1;emittedTokenCount=0;eofToken=null;state={kind:f.Data};blockDepth=0;elementDepth=0;blockElementDepthStack=[];constructor(e){this.source=e}nextToken(){let e=this.readNextToken();return this.emittedTokenCount++,e}getCurrentState(){return this.state}getEmittedTokenCount(){return this.emittedTokenCount}readNextToken(){switch(this.state.kind){case f.Data:return this.readDataToken();case f.TagOpen:return this.readTagNameToken(!1);case f.EndTagOpen:return this.readTagNameToken(!0);case f.BeforeAttributeName:return this.readBeforeAttributeNameToken();case f.AttributeName:return this.readAttributeNameToken();case f.AfterAttributeName:return this.readAfterAttributeNameToken();case f.BeforeAttributeValue:return this.readBeforeAttributeValueToken();case f.Comment:case f.Interpolation:case f.AttributeValueQuoted:case f.AttributeValueInterpolation:throw Error(`Lexer entered transient state '${this.state.kind}' unexpectedly.`);case f.RawText:return this.readRawTextToken();case f.EOF:return this.getOrCreateEOFToken()}}readDataToken(){let e=this.getLocation();if(this.isAtEnd())return this.transitionTo({kind:f.EOF}),this.getOrCreateEOFToken(e);if(this.startsWith(`<!--`))return this.consumePattern(`<!--`),this.transitionTo({kind:f.Comment}),this.readCommentToken(e);if(this.startsWith(`</`))return this.consumePattern(`</`),this.transitionTo({kind:f.EndTagOpen}),this.createToken(d.TagOpenSlash,`</`,e);if(this.peek()===`<`)return this.advance(),this.transitionTo({kind:f.TagOpen}),this.createToken(d.TagOpen,`<`,e);if(this.peek()===`{`)return this.advance(),this.transitionTo({kind:f.Interpolation,context:`content`,tagName:null}),this.readInterpolationToken(e,`content`,null);let t=this.blockDepth>0&&this.blockElementDepthStack.length>0&&this.elementDepth===this.blockElementDepthStack[this.blockElementDepthStack.length-1];return this.peek()===`}`&&t?(this.advance(),this.blockDepth--,this.blockElementDepthStack.pop(),this.createToken(d.BlockClose,`}`,e)):this.peek()===`@`?this.readDirectiveToken(e):this.readTextToken()}readDirectiveToken(e){this.advance();let t=``;for(;!this.isAtEnd()&&/[a-zA-Z]/.test(this.peek());)t+=this.advance();if(!b.has(t))throw new h(`Unknown directive '@${t}'`,e.line,e.column,e.offset);if(t===`if`)return this.readDirectiveHeader(e,d.DirectiveIf);if(t===`else`){if(this.skipWhitespace(),this.startsWith(`if`)&&!/[a-zA-Z0-9_]/.test(this.peek(2)))return this.consumePattern(`if`),this.readDirectiveHeader(e,d.DirectiveElseIf);if(this.skipWhitespace(),this.peek()===`{`)return this.advance(),this.blockDepth++,this.blockElementDepthStack.push(this.elementDepth),this.createToken(d.DirectiveElse,``,e);throw new h(`Expected '{' after @else directive`,e.line,e.column,e.offset)}else if(t===`for`)return this.readDirectiveHeader(e,d.DirectiveFor);else if(t===`switch`)return this.readDirectiveHeader(e,d.DirectiveSwitch);else if(t===`case`)return this.readDirectiveHeader(e,d.DirectiveCase);else return this.skipWhitespace(),this.peek()===`{`&&(this.advance(),this.blockDepth++,this.blockElementDepthStack.push(this.elementDepth)),this.createToken(d.DirectiveDefault,``,e)}readDirectiveHeader(e,t){this.skipWhitespace();let n=``,r=0,i=0,a=0,o=[],s=null,c=!1,l=!1,u=!1,d=!1,f=!1,m=p.Start;for(;!this.isAtEnd();){let h=this.advance();if(l){n+=h,h===`
|
|
2
|
+
`&&(l=!1);continue}if(u){n+=h,h===`/`&&n.endsWith(`*/`)&&(u=!1);continue}if(d){n+=h,c?c=!1:h===`\\`?c=!0:h===`[`?f=!0:h===`]`&&f?f=!1:h===`/`&&!f&&(d=!1,m=p.IdentifierOrLiteral);continue}if(s!==null){if(n+=h,c)c=!1;else if(h===`\\`)c=!0;else if(h===s)s=null,m=p.IdentifierOrLiteral;else if(s==="`"&&h===`{`&&n.endsWith("${")){let e=0;for(let t=n.length-3;t>=0&&n[t]===`\\`;t--)e++;e%2==0&&(o.push(a),s=null,a++,m=p.Start)}continue}if(h===`/`&&!c){let e=this.peek();if(e===`/`){l=!0,n+=h;continue}else if(e===`*`){u=!0,n+=h;continue}else if(this.isRegexStart(m)){d=!0,f=!1,n+=h;continue}else m=p.Punctuator}if(h===`"`||h===`'`||h==="`"){s=h,n+=h;continue}if(h===`(`){r++,m=p.Start,n+=h;continue}if(h===`)`){r>0&&r--,m=p.IdentifierOrLiteral,n+=h;continue}if(h===`[`){i++,m=p.Start,n+=h;continue}if(h===`]`){i>0&&i--,m=p.IdentifierOrLiteral,n+=h;continue}if(h===`{`){if(r===0&&i===0&&a===0&&o.length===0)return this.blockDepth++,this.blockElementDepthStack.push(this.elementDepth),this.createToken(t,n.trim(),e);a++,m=p.Start,n+=h;continue}if(h===`}`){a--,o.length>0&&a===o[o.length-1]&&(o.pop(),s="`"),m=p.IdentifierOrLiteral,n+=h;continue}if(h===`+`||h===`-`){if(this.peek()===h){let e=this.advance();n+=h+e,m=m===p.IdentifierOrLiteral?p.PostfixOp:p.Start;continue}m=p.Punctuator,n+=h;continue}if(`=(,:;!&|?*%<>~^`.includes(h)){m=p.Punctuator,n+=h;continue}if(/[a-zA-Z0-9_$]/.test(h)){let e=h;for(;!this.isAtEnd()&&/[a-zA-Z0-9_$]/.test(this.peek());)e+=this.advance();m=x.has(e)?p.Keyword:p.IdentifierOrLiteral,n+=e;continue}n+=h}throw new h(`Unterminated directive header, expected '{'`,e.line,e.column,e.offset)}readTagNameToken(e){if(this.isAtEnd())throw this.createUnexpectedEOFError(e?`after closing tag opener`:`after opening tag opener`);let t=this.getLocation(),n=this.peek();if(!this.isIdentifierStart(n))throw new h(`Expected tag name but found '${n||`EOF`}'`,t.line,t.column,t.offset);let r=this.readIdentifierValue(),i=!e&&y(r);return this.transitionTo({kind:f.BeforeAttributeName,tagName:r,isClosingTag:e,entersRawText:i}),this.createToken(d.Identifier,r,t)}readBeforeAttributeNameToken(){let e=this.state;if(e.kind!==f.BeforeAttributeName)throw Error(`Expected BeforeAttributeName state but found '${e.kind}'.`);if(this.skipWhitespace(),this.isAtEnd())throw this.createUnexpectedEOFError(`inside tag <${e.tagName}>`);let t=this.getLocation();if(e.isClosingTag){if(this.peek()!==`>`)throw new h(`Unexpected character '${this.peek()}' inside closing tag </${e.tagName}>`,t.line,t.column,t.offset);return this.advance(),this.elementDepth>0&&this.elementDepth--,this.transitionTo({kind:f.Data}),this.createToken(d.TagClose,`>`,t)}if(this.peek()===`/`){let e=1;for(;this.peek(e)===` `||this.peek(e)===` `||this.peek(e)===`
|
|
3
|
+
`||this.peek(e)===`\r`;)e++;if(this.peek(e)===`>`){for(let t=0;t<=e;t++)this.advance();return this.transitionTo({kind:f.Data}),this.createToken(d.TagSelfClose,`/>`,t)}}if(this.peek()===`>`)return this.advance(),c.VOID_ELEMENTS.has(e.tagName.toLowerCase())||this.elementDepth++,e.entersRawText&&y(e.tagName)?this.transitionTo({kind:f.RawText,tagName:e.tagName}):this.transitionTo({kind:f.Data}),this.createToken(d.TagClose,`>`,t);if(!this.isIdentifierStart(this.peek()))throw new h(`Unexpected character '${this.peek()}' inside tag <${e.tagName}>`,t.line,t.column,t.offset);return this.transitionTo({kind:f.AttributeName,tagName:e.tagName,attributeName:null}),this.readAttributeNameToken()}readAttributeNameToken(){let e=this.state;if(e.kind!==f.AttributeName)throw Error(`Expected AttributeName state but found '${e.kind}'.`);let t=this.getLocation();if(!this.isIdentifierStart(this.peek()))throw new h(`Expected attribute name but found '${this.peek()||`EOF`}'`,t.line,t.column,t.offset);let n=this.readIdentifierValue(),r=e.tagName;return this.transitionTo({kind:f.AfterAttributeName,tagName:r,attributeName:n}),this.createToken(d.Identifier,n,t)}readAfterAttributeNameToken(){let e=this.state;if(e.kind!==f.AfterAttributeName)throw Error(`Expected AfterAttributeName state but found '${e.kind}'.`);let t=e.tagName,n=e.attributeName;if(this.skipWhitespace(),this.isAtEnd())throw this.createUnexpectedEOFError(`after attribute '${n}' in <${t}>`);if(this.peek()===`=`){let e=this.getLocation();return this.advance(),this.transitionTo({kind:f.BeforeAttributeValue,tagName:t,attributeName:n}),this.createToken(d.Equals,`=`,e)}return this.transitionTo({kind:f.BeforeAttributeName,tagName:t,isClosingTag:!1,entersRawText:y(t)}),this.readBeforeAttributeNameToken()}readBeforeAttributeValueToken(){let e=this.state;if(e.kind!==f.BeforeAttributeValue)throw Error(`Expected BeforeAttributeValue state but found '${e.kind}'.`);let t=e.tagName,n=e.attributeName;if(this.skipWhitespace(),this.isAtEnd())throw this.createUnexpectedEOFError(`before value for attribute '${n}' in <${t}>`);let r=this.getLocation(),i=this.peek();if(i===`"`||i===`'`)return this.advance(),this.transitionTo({kind:f.AttributeValueQuoted,tagName:t,attributeName:n,quote:i}),this.readQuotedStringToken(r,i,t);if(i===`{`)return this.advance(),this.transitionTo({kind:f.AttributeValueInterpolation,tagName:t,attributeName:n}),this.readInterpolationToken(r,`attribute`,t);throw new h(`Expected quoted string or interpolation for attribute '${n}' in <${t}>`,r.line,r.column,r.offset)}readCommentToken(e){let t=``;for(;!this.isAtEnd();){if(this.startsWith(`-->`))return this.consumePattern(`-->`),this.transitionTo({kind:f.Data}),this.createToken(d.Comment,t,e);t+=this.advance()}throw new h(`Unterminated XML comment`,e.line,e.column,e.offset)}isRegexStart(e){return e===p.Start||e===p.Punctuator||e===p.Keyword}readInterpolationToken(e,t,n){let r=1,i=null,a=!1,o=!1,s=!1,c=!1,l=!1,u=p.Start,m=[],g=``;for(;!this.isAtEnd();){let h=this.advance();if(o){g+=h,h===`
|
|
4
|
+
`&&(o=!1);continue}if(s){g+=h,h===`/`&&g.endsWith(`*/`)&&(s=!1);continue}if(c){g+=h,a?a=!1:h===`\\`?a=!0:h===`[`?l=!0:h===`]`&&l?l=!1:h===`/`&&!l&&(c=!1,u=p.IdentifierOrLiteral);continue}if(i!==null){if(g+=h,a)a=!1;else if(h===`\\`)a=!0;else if(h===i)i=null,u=p.IdentifierOrLiteral;else if(i==="`"&&h===`{`&&g.endsWith("${")){let e=0;for(let t=g.length-3;t>=0&&g[t]===`\\`;t--)e++;e%2==0&&(m.push(r),i=null,r++,u=p.Start)}continue}if(h===`/`&&!a){let e=this.peek();if(e===`/`){o=!0,g+=h;continue}else if(e===`*`){s=!0,g+=h;continue}else if(this.isRegexStart(u)){c=!0,l=!1,g+=h;continue}else u=p.Punctuator}if(h===`"`||h===`'`||h==="`"){inQuote:i=h;g+=h;continue}if(h===`(`){u=p.Start,g+=h;continue}if(h===`)`){u=p.IdentifierOrLiteral,g+=h;continue}if(h===`[`){u=p.Start,g+=h;continue}if(h===`]`){u=p.IdentifierOrLiteral,g+=h;continue}if(h===`{`){r++,u=p.Start,g+=h;continue}if(h===`}`){if(r--,m.length>0&&r===m[m.length-1]&&(m.pop(),i="`"),u=p.IdentifierOrLiteral,r===0)return t===`attribute`&&n!==null?this.transitionTo({kind:f.BeforeAttributeName,tagName:n,isClosingTag:!1,entersRawText:y(n)}):this.transitionTo({kind:f.Data}),this.createToken(d.Interpolation,g,e);g+=h;continue}if(h===`+`||h===`-`){if(this.peek()===h){let e=this.advance();g+=h+e,u=u===p.IdentifierOrLiteral?p.PostfixOp:p.Start;continue}u=p.Punctuator,g+=h;continue}if(`=(,:;!&|?*%<>~^`.includes(h)){u=p.Punctuator,g+=h;continue}if(/[a-zA-Z0-9_$]/.test(h)){let e=h;for(;!this.isAtEnd()&&/[a-zA-Z0-9_$]/.test(this.peek());)e+=this.advance();u=x.has(e)?p.Keyword:p.IdentifierOrLiteral,g+=e;continue}g+=h}throw new h(`Unterminated interpolation expression, expected closing brace '}'`,e.line,e.column,e.offset)}readRawTextToken(){let e=this.state;if(e.kind!==f.RawText)throw Error(`Expected RawText state but found '${e.kind}'.`);let t=this.getLocation(),n=`</${e.tagName}`;if(this.isAtEnd())return this.transitionTo({kind:f.EOF}),this.getOrCreateEOFToken(t);if(this.isRawTextClosingTagAhead(n))return this.consumePattern(`</`),this.transitionTo({kind:f.EndTagOpen}),this.createToken(d.TagOpenSlash,`</`,t);let r=``;for(;!this.isAtEnd()&&!this.isRawTextClosingTagAhead(n);)r+=this.advance();return r.length>0?this.createToken(d.Text,r,t):(this.transitionTo({kind:f.EOF}),this.getOrCreateEOFToken(t))}readTextToken(){let e=this.getLocation(),t=``,n=()=>this.blockDepth>0&&this.blockElementDepthStack.length>0&&this.elementDepth===this.blockElementDepthStack[this.blockElementDepthStack.length-1];for(;!this.isAtEnd();){let e=this.peek();if(e===`<`||e===`{`||e===`@`||e===`}`&&n())break;t+=this.advance()}return this.createToken(d.Text,t,e)}readQuotedStringToken(e,t,n){let r=``,i=!1;for(;!this.isAtEnd();){let a=this.peek();if(i){i=!1,r+=this.advance();continue}if(a===`\\`){i=!0,this.advance();continue}if(a===t)return this.advance(),this.transitionTo({kind:f.BeforeAttributeName,tagName:n,isClosingTag:!1,entersRawText:y(n)}),this.createToken(d.StringLiteral,r,e);r+=this.advance()}throw new h(`Unterminated string literal, expected closing quote ${t}`,e.line,e.column,e.offset)}readIdentifierValue(){let e=``;for(;!this.isAtEnd()&&this.isIdentifierChar(this.peek());)e+=this.advance();return e}getOrCreateEOFToken(e=this.getLocation()){return this.eofToken===null&&(this.eofToken={type:d.EOF,value:``,loc:{start:e,end:e}}),this.eofToken}createToken(e,t,n){return{type:e,value:t,loc:{start:n,end:this.getLocation()}}}createUnexpectedEOFError(e){let t=this.getLocation();return new h(`Unexpected end of input ${e}`,t.line,t.column,t.offset)}transitionTo(e){if(!v[this.state.kind].some(t=>t.to===e.kind))throw Error(`Invalid lexer transition from '${this.state.kind}' to '${e.kind}'.`);this.state=e}getLocation(){return{line:this.line,column:this.column,offset:this.offset}}isAtEnd(){return this.offset>=this.source.length}peek(e=0){let t=this.offset+e;return t>=this.source.length?``:this.source[t]??``}advance(){let e=this.source[this.offset]??``;return this.offset++,e===`
|
|
6
5
|
`?(this.line++,this.column=1):this.column++,e}startsWith(e){return this.source.startsWith(e,this.offset)}consumePattern(e){for(let t=0;t<e.length;t++)this.advance()}skipWhitespace(){for(;!this.isAtEnd();){let e=this.peek();if(e===` `||e===` `||e===`\r`||e===`
|
|
7
6
|
`)this.advance();else break}}isIdentifierStart(e){if(e.length===0)return!1;let t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122||t===95||t===36}isIdentifierChar(e){if(e.length===0)return!1;let t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||t===95||t===36||t===45}isRawTextClosingTagAhead(e){let t=e.length;if(this.source.slice(this.offset,this.offset+t).toLowerCase()!==e.toLowerCase())return!1;let n=this.peek(t);return n===``||n===`>`||n===` `||n===` `||n===`\r`||n===`
|
|
8
|
-
`}},v=class{tokens;current=0;constructor(e){this.tokens=e}nextToken(){if(this.current>=this.tokens.length)return this.tokens[this.tokens.length-1];let e=this.tokens[this.current];return this.current++,e}},ee={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`,nbsp:`\xA0`,copy:`©`,reg:`®`,trade:`™`,mdash:`—`,ndash:`–`,hellip:`…`,laquo:`«`,raquo:`»`,ldquo:`“`,rdquo:`”`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,bdquo:`„`,bull:`•`,times:`×`,divide:`÷`,plusmn:`±`,euro:`€`,pound:`£`,yen:`¥`,cent:`¢`,deg:`°`,para:`¶`,sect:`§`,micro:`µ`,middot:`·`,frac14:`¼`,frac12:`½`,frac34:`¾`,sup1:`¹`,sup2:`²`,sup3:`³`,dagger:`†`,Dagger:`‡`,permil:`‰`,prime:`′`,Prime:`″`,infin:`∞`,radic:`√`,sim:`∼`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,sum:`∑`,prod:`∏`,minus:`−`,lowast:`∗`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,cong:`≅`,ang:`∠`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`};function te(e){return!e||!e.includes(`&`)?e:e.replace(/&(?:#(\d+)|#x([0-9a-fA-F]+)|([a-zA-Z0-9]+));/g,(e,t,n,r)=>{if(t){let e=parseInt(t,10);try{return!isNaN(e)&&e>=0&&e<=1114111&&(e<55296||e>57343)?String.fromCodePoint?String.fromCodePoint(e):String.fromCharCode(e):`�`}catch{return`�`}}if(n){let e=parseInt(n,16);try{return!isNaN(e)&&e>=0&&e<=1114111&&(e<55296||e>57343)?String.fromCodePoint?String.fromCodePoint(e):String.fromCharCode(e):`�`}catch{return`�`}}return r&&ee[r]||e})}var ne=class{tokenSource;lookahead=[];constructor(e){this.tokenSource=Array.isArray(e)?new v(e):e}parse(){return this.lookahead.length=0,this.parseProgram()}parseProgram(){let e=this.peek().loc.start,t=[];for(;!this.isAtEnd();)t.push(this.parseChild());let n=this.peek().loc.end;return{type:r.Program,body:t,loc:{start:e,end:n}}}parseChild(){let t=this.peek();if(t.type===e.Comment)return this.advance(),{type:r.Comment,content:t.value,loc:t.loc};if(t.type===e.Interpolation)return this.advance(),{type:r.Interpolation,expression:t.value,loc:t.loc};if(t.type===e.TagOpen)return this.parseElement();if(t.type===e.DirectiveIf)return this.parseIfDirective();if(t.type===e.DirectiveFor)return this.parseForDirective();if(t.type===e.DirectiveSwitch)return this.parseSwitchDirective();if(t.type===e.Text)return this.advance(),{type:r.Text,content:te(t.value),loc:t.loc};throw t.type===e.TagOpenSlash?new a(`Unexpected closing tag '</${this.peek(1).value}>' without opening tag`,t.loc.start.line,t.loc.start.column,t.loc.start.offset):new a(`Unexpected token '${t.value}' of type '${t.type}'`,t.loc.start.line,t.loc.start.column,t.loc.start.offset)}parseElement(){let t=this.consume(e.TagOpen,`Expected opening tag bracket`).loc.start,n=this.consume(e.Identifier,`Expected tag name after opening bracket`).value,i=[];for(;!this.check(e.TagClose)&&!this.check(e.TagSelfClose)&&!this.isAtEnd();)i.push(this.parseAttribute());if(this.check(e.TagSelfClose)){let e=this.advance();return{type:r.Element,tagName:n,attributes:i,children:[],isSelfClosing:!0,loc:{start:t,end:e.loc.end}}}let o=this.consume(e.TagClose,`Expected closing bracket after attributes`);if(s.has(n.toLowerCase()))return{type:r.Element,tagName:n,attributes:i,children:[],isSelfClosing:!0,loc:{start:t,end:o.loc.end}};let c=n.toLowerCase()===`script`||n.toLowerCase()===`style`,l=[];for(;!this.check(e.TagOpenSlash)&&!this.isAtEnd();)if(c&&this.check(e.Text)){let e=this.advance();l.push({type:r.Text,content:e.value,loc:e.loc})}else l.push(this.parseChild());if(this.isAtEnd())throw new a(`Unclosed element '<${n}>', expected closing tag '</${n}>'`,t.line,t.column,t.offset);this.consume(e.TagOpenSlash,`Expected closing tag '</${n}>'`);let u=this.consume(e.Identifier,`Expected closing tag name`);if(u.value!==n&&u.value.toLowerCase()!==n.toLowerCase())throw new a(`Mismatched closing tag. Expected '</${n}>' but got '</${u.value}>'`,u.loc.start.line,u.loc.start.column,u.loc.start.offset);let d=this.consume(e.TagClose,`Expected '>' after closing tag name`);return{type:r.Element,tagName:n,attributes:i,children:l,isSelfClosing:!1,loc:{start:t,end:d.loc.end}}}parseAttribute(){let t=this.consume(e.Identifier,`Expected attribute name`),n=t.loc.start,i=t.value;if(this.matchToken(e.Equals)){let t=this.peek();if(t.type===e.StringLiteral)return this.advance(),{type:r.Attribute,name:i,value:te(t.value),loc:{start:n,end:t.loc.end}};if(t.type===e.Interpolation){this.advance();let e={type:r.Interpolation,expression:t.value,loc:t.loc};return{type:r.Attribute,name:i,value:e,loc:{start:n,end:t.loc.end}}}throw new a(`Expected string literal or interpolation after '=' for attribute '${i}'`,t.loc.start.line,t.loc.start.column,t.loc.start.offset)}return{type:r.Attribute,name:i,value:null,loc:{start:n,end:t.loc.end}}}parseIfDirective(){let t=this.consume(e.DirectiveIf,`Expected @if directive`),n=t.loc.start,i=t.value,a=[];for(;!this.check(e.BlockClose)&&!this.isAtEnd();)a.push(this.parseChild());let o=this.consume(e.BlockClose,`Expected closing brace } for @if block`),s=null,c=o.loc.end;if(this.skipWhitespaceTokens(),this.check(e.DirectiveElseIf))s=this.parseElseIfChain(),c=s.loc.end;else if(this.check(e.DirectiveElse)){this.advance();let t=[];for(;!this.check(e.BlockClose)&&!this.isAtEnd();)t.push(this.parseChild());let n=this.consume(e.BlockClose,`Expected closing brace } for @else block`);s=t,c=n.loc.end}return{type:r.If,test:i,consequent:a,alternate:s,loc:{start:n,end:c}}}parseElseIfChain(){let t=this.consume(e.DirectiveElseIf,`Expected @else if directive`),n=t.loc.start,i=t.value,a=[];for(;!this.check(e.BlockClose)&&!this.isAtEnd();)a.push(this.parseChild());let o=this.consume(e.BlockClose,`Expected closing brace } for @else if block`),s=null,c=o.loc.end;if(this.skipWhitespaceTokens(),this.check(e.DirectiveElseIf))s=this.parseElseIfChain(),c=s.loc.end;else if(this.check(e.DirectiveElse)){this.advance();let t=[];for(;!this.check(e.BlockClose)&&!this.isAtEnd();)t.push(this.parseChild());let n=this.consume(e.BlockClose,`Expected closing brace } for @else block`);s=t,c=n.loc.end}return{type:r.If,test:i,consequent:a,alternate:s,loc:{start:n,end:c}}}parseForDirective(){let t=this.consume(e.DirectiveFor,`Expected @for directive`),n=t.loc.start,i=t.value.trim();function o(e){return l(e,(t,n)=>{if(n===`i`&&e[t+1]===`n`){let n=t===0||!/[a-zA-Z0-9_$]/.test(e[t-1]),r=t+2>=e.length||!/[a-zA-Z0-9_$]/.test(e[t+2]);if(n&&r){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0||e[n]!==`.`)return!0}}})}function s(e){return u(e,`,`)}function c(e){let t=-1;return l(e,n=>{if(e.slice(n,n+3)===`key`){let r=n===0||!/[a-zA-Z0-9_$]/.test(e[n-1]),i=n+3>=e.length||!/[a-zA-Z0-9_$]/.test(e[n+3]);if(r&&i){let r=n-1;for(;r>=0&&/\s/.test(e[r]);)r--;if((r<0||e[r]!==`.`&&e[r]!==`?`)&&e.slice(n+3).trim().length>0)return t=n,!0}}}),t===-1?null:{index:t,keyExpr:e.slice(t+3).trim()}}for(;d(i);)i=i.slice(1,-1).trim();let f=o(i);if(f===-1&&d(i)){let e=i.slice(1,-1).trim(),t=o(e);t!==-1&&(i=e,f=t)}if(f===-1)throw new a(`Invalid @for header syntax '${i}'. Expected format: 'item in list' or '(item, index) in list'`,t.loc.start.line,t.loc.start.column,t.loc.start.offset);let p=i.slice(0,f).trim(),m=i.slice(f+2).trim(),h=null,g=c(m);g&&(h=g.keyExpr,m=m.slice(0,g.index).trim());let _=m,v=p,ee=null;for(;d(v);)v=v.slice(1,-1).trim();let te=s(v);if(te!==-1){let e=v.slice(0,te).trim();for(ee=v.slice(te+1).trim()||null,v=e;d(v);)v=v.slice(1,-1).trim()}if(!v||!_)throw new a(`Invalid @for header syntax '${t.value.trim()}'. Expected format: 'item in list' or '(item, index) in list'`,t.loc.start.line,t.loc.start.column,t.loc.start.offset);let ne=[];for(;!this.check(e.BlockClose)&&!this.isAtEnd();)ne.push(this.parseChild());let re=this.consume(e.BlockClose,`Expected closing brace } for @for block`);return{type:r.For,item:v,index:ee,iterable:_,key:h,body:ne,loc:{start:n,end:re.loc.end}}}parseSwitchDirective(){let t=this.consume(e.DirectiveSwitch,`Expected @switch directive`),n=t.loc.start,i=t.value,o=[];for(this.skipWhitespaceTokens();!this.check(e.BlockClose)&&!this.isAtEnd();){if(this.check(e.DirectiveCase)){let t=this.advance(),n=[];for(;!this.check(e.BlockClose)&&!this.isAtEnd();)n.push(this.parseChild());let r=this.consume(e.BlockClose,`Expected closing brace } for @case block`);o.push({expression:t.value,body:n,loc:{start:t.loc.start,end:r.loc.end}})}else if(this.check(e.DirectiveDefault)){let t=this.advance(),n=[];for(;!this.check(e.BlockClose)&&!this.isAtEnd();)n.push(this.parseChild());let r=this.consume(e.BlockClose,`Expected closing brace } for @default block`);o.push({expression:null,body:n,loc:{start:t.loc.start,end:r.loc.end}})}else throw new a(`Unexpected token '${this.peek().value}' inside @switch block. Expected @case or @default.`,this.peek().loc.start.line,this.peek().loc.start.column,this.peek().loc.start.offset);this.skipWhitespaceTokens()}let s=this.consume(e.BlockClose,`Expected closing brace } for @switch block`);return{type:r.Switch,discriminant:i,cases:o,loc:{start:n,end:s.loc.end}}}skipWhitespaceTokens(){for(;this.check(e.Text)&&this.peek().value.trim().length===0;)this.advance()}isAtEnd(){return this.peek().type===e.EOF}peek(e=0){return this.ensureLookahead(e),this.lookahead[Math.min(e,this.lookahead.length-1)]}advance(){let t=this.peek();return t.type!==e.EOF&&this.lookahead.shift(),t}check(e){return this.peek().type===e}matchToken(e){return this.check(e)?(this.advance(),!0):!1}consume(e,t){if(this.check(e))return this.advance();let n=this.peek();throw new a(t,n.loc.start.line,n.loc.start.column,n.loc.start.offset)}ensureLookahead(t){for(;this.lookahead.length<=t;){let t=this.tokenSource.nextToken();if(this.lookahead.push(t),t.type===e.EOF)break}}},re=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,78,5,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,266,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],ie=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,57,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,261,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],ae=`·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ--ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,oe=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,se={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`},ce=`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`,le={5:ce,"5module":ce+` export import`,6:ce+` const class extends export import super`},ue=/^in(stanceof)?$/,de=RegExp(`[`+oe+`]`),fe=RegExp(`[`+oe+ae+`]`);function pe(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function y(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&de.test(String.fromCharCode(e)):t!==!1&&pe(e,ie)}function b(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&fe.test(String.fromCharCode(e)):t===!1?!1:pe(e,ie)||pe(e,re)}var x=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function S(e,t){return new x(e,{beforeExpr:!0,binop:t})}var C={beforeExpr:!0},w={startsExpr:!0},me={};function T(e,t){return t===void 0&&(t={}),t.keyword=e,me[e]=new x(e,t)}var E={num:new x(`num`,w),regexp:new x(`regexp`,w),string:new x(`string`,w),name:new x(`name`,w),privateId:new x(`privateId`,w),eof:new x(`eof`),bracketL:new x(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new x(`]`),braceL:new x(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new x(`}`),parenL:new x(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new x(`)`),comma:new x(`,`,C),semi:new x(`;`,C),colon:new x(`:`,C),dot:new x(`.`),question:new x(`?`,C),questionDot:new x(`?.`),arrow:new x(`=>`,C),template:new x(`template`),invalidTemplate:new x(`invalidTemplate`),ellipsis:new x(`...`,C),backQuote:new x("`",w),dollarBraceL:new x("${",{beforeExpr:!0,startsExpr:!0}),eq:new x(`=`,{beforeExpr:!0,isAssign:!0}),assign:new x(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new x(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new x(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:S(`||`,1),logicalAND:S(`&&`,2),bitwiseOR:S(`|`,3),bitwiseXOR:S(`^`,4),bitwiseAND:S(`&`,5),equality:S(`==/!=/===/!==`,6),relational:S(`</>/<=/>=`,7),bitShift:S(`<</>>/>>>`,8),plusMin:new x(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:S(`%`,10),star:S(`*`,10),slash:S(`/`,10),starstar:new x(`**`,{beforeExpr:!0}),coalesce:S(`??`,1),_break:T(`break`),_case:T(`case`,C),_catch:T(`catch`),_continue:T(`continue`),_debugger:T(`debugger`),_default:T(`default`,C),_do:T(`do`,{isLoop:!0,beforeExpr:!0}),_else:T(`else`,C),_finally:T(`finally`),_for:T(`for`,{isLoop:!0}),_function:T(`function`,w),_if:T(`if`),_return:T(`return`,C),_switch:T(`switch`),_throw:T(`throw`,C),_try:T(`try`),_var:T(`var`),_const:T(`const`),_while:T(`while`,{isLoop:!0}),_with:T(`with`),_new:T(`new`,{beforeExpr:!0,startsExpr:!0}),_this:T(`this`,w),_super:T(`super`,w),_class:T(`class`,w),_extends:T(`extends`,C),_export:T(`export`),_import:T(`import`,w),_null:T(`null`,w),_true:T(`true`,w),_false:T(`false`,w),_in:T(`in`,{beforeExpr:!0,binop:7}),_instanceof:T(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:T(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:T(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:T(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},D=/\r\n?|\n|\u2028|\u2029/,he=new RegExp(D.source,`g`);function ge(e){return e===10||e===13||e===8232||e===8233}function _e(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(ge(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var ve=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,O=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ye=Object.prototype,be=ye.hasOwnProperty,xe=ye.toString,Se=Object.hasOwn||(function(e,t){return be.call(e,t)}),Ce=Array.isArray||(function(e){return xe.call(e)===`[object Array]`}),we=Object.create(null);function k(e){return we[e]||(we[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function A(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var Te=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Ee=function(e,t){this.line=e,this.column=t};Ee.prototype.offset=function(e){return new Ee(this.line,this.column+e)};var De=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function Oe(e,t){for(var n=1,r=0;;){var i=_e(e,r,t);if(i<0)return new Ee(n,t-r);++n,r=i}}var ke={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,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Ae=!1;function je(e){var t={};for(var n in ke)t[n]=e&&Se(e,n)?e[n]:ke[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!Ae&&typeof console==`object`&&console.warn&&(Ae=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
9
|
-
Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved??=t.ecmaVersion<5,(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),Ce(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(Ce(t.onComment)&&(t.onComment=Me(t,t.onComment)),t.sourceType===`commonjs`&&t.allowAwaitOutsideFunction)throw Error(`Cannot use allowAwaitOutsideFunction with sourceType: commonjs`);return t}function Me(e,t){return function(n,r,i,a,o,s){var c={type:n?`Block`:`Line`,value:r,start:i,end:a};e.locations&&(c.loc=new De(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}var Ne=1,j=2,Pe=4,Fe=8,Ie=16,Le=32,Re=64,ze=128,M=256,Be=512,Ve=1024,He=Ne|j|M;function Ue(e,t){return j|(e?Pe:0)|(t?Fe:0)}var We=0,Ge=1,N=2,Ke=3,qe=4,Je=5,P=function(e,t,n){this.options=e=je(e),this.sourceFile=e.sourceFile,this.keywords=k(le[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;e.allowReserved!==!0&&(r=se[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=k(r);var i=(r?r+` `:``)+se.strict;this.reservedWordsStrict=k(i),this.reservedWordsStrictBind=k(i+` `+se.strictBind),this.input=String(t),this.containsEsc=!1,n?(this.pos=n,this.lineStart=this.input.lastIndexOf(`
|
|
10
|
-
`,n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(D).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=E.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=e.sourceType===`module`,this.strict=this.inModule||e.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&&e.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType===`commonjs`?j:Ne),this.regexpState=null,this.privateNameStack=[]},F={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}};P.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},F.inFunction.get=function(){return(this.currentVarScope().flags&j)>0},F.inGenerator.get=function(){return(this.currentVarScope().flags&Fe)>0},F.inAsync.get=function(){return(this.currentVarScope().flags&Pe)>0},F.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(M|Be))return!1;if(t&j)return(t&Pe)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},F.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&Ne)},F.allowSuper.get=function(){return(this.currentThisScope().flags&Re)>0||this.options.allowSuperOutsideMethod},F.allowDirectSuper.get=function(){return(this.currentThisScope().flags&ze)>0},F.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},F.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(M|Be)||t&j&&!(t&Ie))return!0}return!1},F.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&Ve||!this.inModule&&e&Ne)},F.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&M)>0},P.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,r=0;r<e.length;r++)n=e[r](n);return n},P.parse=function(e,t){return new this(t,e).parse()},P.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},P.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(P.prototype,F);var I=P.prototype,Ye=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;I.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){O.lastIndex=e,e+=O.exec(this.input)[0].length;var t=Ye.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){O.lastIndex=e+t[0].length;var n=O.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||D.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`)}e+=t[0].length,O.lastIndex=e,e+=O.exec(this.input)[0].length,this.input[e]===`;`&&e++}},I.eat=function(e){return this.type===e?(this.next(),!0):!1},I.isContextual=function(e){return this.type===E.name&&this.value===e&&!this.containsEsc},I.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},I.catchStackOverflow=function(e){try{return e()}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}},I.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},I.canInsertSemicolon=function(){return this.type===E.eof||this.type===E.braceR||D.test(this.input.slice(this.lastTokEnd,this.start))},I.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},I.semicolon=function(){!this.eat(E.semi)&&!this.insertSemicolon()&&this.unexpected()},I.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},I.expect=function(e){this.eat(e)||this.unexpected()},I.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var Xe=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};I.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,`Comma is not permitted after the rest element`);var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?`Assigning to rvalue`:`Parenthesized pattern`)}},I.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,`Shorthand property assignments are valid only in destructuring patterns`),r>=0&&this.raiseRecoverable(r,`Redefinition of __proto__ property`)},I.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,`Yield expression cannot be a default value`),this.awaitPos&&this.raise(this.awaitPos,`Await expression cannot be a default value`)},I.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var L=P.prototype;L.parseTopLevel=function(e){var t=Object.create(null);for(e.body||=[];this.type!==E.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[r];this.raiseRecoverable(this.undefinedExports[a].start,`Export '`+a+`' is not defined`)}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType===`commonjs`?`script`:this.options.sourceType,this.finishNode(e,`Program`)};var Ze={kind:`loop`},Qe={kind:`switch`};L.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;O.lastIndex=this.pos;var t=O.exec(this.input),n=this.pos+t[0].length,r=this.fullCharCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123)return!0;if(y(r)){var i=n;do n+=r<=65535?1:2;while(b(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!ue.test(a))return!0}return!1},L.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;O.lastIndex=this.pos;var e=O.exec(this.input),t=this.pos+e[0].length,n;return!D.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(b(n=this.fullCharCodeAt(t+8))||n===92))},L.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;O.lastIndex=this.pos;var n=O.exec(this.input),r=this.pos+n[0].length;if(D.test(this.input.slice(this.pos,r)))return!1;if(e){var i=r+5,a;if(this.input.slice(r,i)!==`using`||i===this.input.length||b(a=this.fullCharCodeAt(i))||a===92)return!1;O.lastIndex=i;var o=O.exec(this.input);if(r=i+o[0].length,o&&D.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!y(s)&&s!==92)return!1;var c=r;do r+=s<=65535?1:2;while(b(s=this.fullCharCodeAt(r)));if(s===92)return!0;var l=this.input.slice(c,r);if(ue.test(l))return!1;if(t&&!e&&l===`of`){O.lastIndex=r;var u=O.exec(this.input);if(r+=u[0].length,this.input.charCodeAt(r)!==61||(s=this.input.charCodeAt(r+1))===61||s===62)return!1}return!0},L.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},L.isUsing=function(e){return this.isUsingKeyword(!1,e)},L.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=E._var,a=`let`),r){case E._break:case E._continue:return this.parseBreakContinueStatement(i,r.keyword);case E._debugger:return this.parseDebuggerStatement(i);case E._do:return this.parseDoStatement(i);case E._for:return this.parseForStatement(i);case E._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case E._class:return e&&this.unexpected(),this.parseClass(i,!0);case E._if:return this.parseIfStatement(i);case E._return:return this.parseReturnStatement(i);case E._switch:return this.parseSwitchStatement(i);case E._throw:return this.parseThrowStatement(i);case E._try:return this.parseTryStatement(i);case E._const:case E._var:return a||=this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case E._while:return this.parseWhileStatement(i);case E._with:return this.parseWithStatement(i);case E.braceL:return this.parseBlock(!0,i);case E.semi:return this.parseEmptyStatement(i);case E._export:case E._import:if(this.options.ecmaVersion>10&&r===E._import){O.lastIndex=this.pos;var o=O.exec(this.input),s=this.pos+o[0].length,c=this.input.charCodeAt(s);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,`'import' and 'export' may only appear at the top level`),this.inModule||this.raise(this.start,`'import' and 'export' may appear only with 'sourceType: module'`)),r===E._import?this.parseImport(i):this.parseExport(i,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(l)return 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"),e&&this.raise(this.start,`Using declaration is not allowed in single-statement positions`),l===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,`VariableDeclaration`);var u=this.value,d=this.parseExpression();return r===E.name&&d.type===`Identifier`&&this.eat(E.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},L.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(E.semi)||this.insertSemicolon()?e.label=null:this.type===E.name?(e.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind===`loop`)||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,`Unsyntactic `+t),this.finishNode(e,n?`BreakStatement`:`ContinueStatement`)},L.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},L.parseDoStatement=function(e){return this.next(),this.labels.push(Ze),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(E._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(E.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},L.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(Ze),this.enterScope(0),this.expect(E.parenL),this.type===E.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===E._var||this.type===E._const||n){var r=this.startNode(),i=n?`let`:this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,`VariableDeclaration`),this.parseForAfterInit(e,r,t)}var a=this.isContextual(`let`),o=!1,s=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(s){var c=this.startNode();return this.next(),s===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new Xe,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===E._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===E._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(f.start===d&&!l&&f.type===`Identifier`&&f.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&o&&this.raise(f.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(f,!1,u),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))},L.parseForAfterInit=function(e,t,n){return(this.type===E._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===E._in?((t.kind===`using`||t.kind===`await using`)&&!t.declarations[0].init&&this.raise(this.start,`Using declaration is not allowed in for-in loops`),this.options.ecmaVersion>=9&&n>-1&&this.unexpected(n)):this.options.ecmaVersion>=9&&(e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},L.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,et|(n?0:tt),!1,t)},L.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(E._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},L.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(E.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},L.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(E.braceL),this.labels.push(Qe),this.enterScope(Ve);for(var t,n=!1;this.type!==E.braceR;)if(this.type===E._case||this.type===E._default){var r=this.type===E._case;t&&this.finishNode(t,`SwitchCase`),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,`Multiple default clauses`),n=!0,t.test=null),this.expect(E.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,`SwitchCase`),this.next(),this.labels.pop(),this.finishNode(e,`SwitchStatement`)},L.parseThrowStatement=function(e){return this.next(),D.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,`Illegal newline after throw`),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,`ThrowStatement`)};var $e=[];L.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?Le:0),this.checkLValPattern(e,t?qe:N),this.expect(E.parenR),e},L.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===E._catch){var t=this.startNode();this.next(),this.eat(E.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat(E._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},L.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},L.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Ze),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},L.parseWithStatement=function(e){return this.strict&&this.raise(this.start,`'with' in strict mode`),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(`with`),this.finishNode(e,`WithStatement`)},L.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},L.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1)a[i].name===t&&this.raise(n.start,`Label '`+t+`' is already declared`);for(var o=this.type.isLoop?`loop`:this.type===E._switch?`switch`:null,s=this.labels.length-1;s>=0;s--){var c=this.labels[s];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf(`label`)===-1?r+`label`:r:`label`),this.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)},L.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},L.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(E.braceL),e&&this.enterScope(0);this.type!==E.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},L.parseFor=function(e,t){return e.init=t,this.expect(E.semi),e.test=this.type===E.semi?null:this.parseExpression(),this.expect(E.semi),e.update=this.type===E.parenR?null:this.parseExpression(),this.expect(E.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},L.parseForIn=function(e,t){var n=this.type===E._in;return this.next(),t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(t.start,(n?`for-in`:`for-of`)+` loop variable declaration may not have an initializer`),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(E.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},L.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(E.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===E._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==E._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&!(t&&(this.type===E._in||this.isContextual(`of`)))?this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):i.init=null,e.declarations.push(this.finishNode(i,`VariableDeclarator`)),!this.eat(E.comma))break}return e},L.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?Ge:N,!1)};var et=1,tt=2,nt=4;L.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===E.star&&t&tt&&this.unexpected(),e.generator=this.eat(E.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&et&&(e.id=t&nt&&this.type!==E.name?null:this.parseIdent(),e.id&&!(t&tt)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Ge:N:Ke));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ue(e.async,e.generator)),t&et||(e.id=this.type===E.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(e,t&et?`FunctionDeclaration`:`FunctionExpression`)},L.parseFunctionParams=function(e){this.expect(E.parenL),e.params=this.parseBindingList(E.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},L.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(E.braceL);this.type!==E.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(i.body.push(o),o.type===`MethodDefinition`&&o.kind===`constructor`?(a&&this.raiseRecoverable(o.start,`Duplicate constructor in the same class`),a=!0):o.key&&o.key.type===`PrivateIdentifier`&&rt(r,o)&&this.raiseRecoverable(o.key.start,`Identifier '#`+o.key.name+`' has already been declared`))}return this.strict=n,this.next(),e.body=this.finishNode(i,`ClassBody`),this.exitClassBody(),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)},L.parseClassElement=function(e){if(this.eat(E.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r=``,i=!1,a=!1,o=`method`,s=!1;if(this.eatContextual(`static`)){if(t>=13&&this.eat(E.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===E.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===E.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(E.star)&&(i=!0),!r&&!a&&!i){var c=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?o=c:r=c)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,`Identifier`)):this.parseClassElementName(n),t<13||this.type===E.parenL||o!==`method`||i||a){var l=!n.static&&it(n,`constructor`),u=l&&e;l&&o!==`method`&&this.raise(n.key.start,`Constructor can't have get/set modifier`),n.kind=l?`constructor`:o,this.parseClassMethod(n,i,a,u)}else this.parseClassField(n);return n},L.isClassElementNameStart=function(){return this.type===E.name||this.type===E.privateId||this.type===E.num||this.type===E.string||this.type===E.bracketL||this.type.keyword},L.parseClassElementName=function(e){this.type===E.privateId?(this.value===`constructor`&&this.raise(this.start,`Classes can't have an element named '#constructor'`),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},L.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind===`constructor`?(t&&this.raise(i.start,`Constructor can't be a generator`),n&&this.raise(i.start,`Constructor can't be an async method`)):e.static&&it(e,`prototype`)&&this.raise(i.start,`Classes may not have a static property named prototype`);var a=e.value=this.parseMethod(t,n,r);return e.kind===`get`&&a.params.length!==0&&this.raiseRecoverable(a.start,`getter should have no params`),e.kind===`set`&&a.params.length!==1&&this.raiseRecoverable(a.start,`setter should have exactly one param`),e.kind===`set`&&a.params[0].type===`RestElement`&&this.raiseRecoverable(a.params[0].start,`Setter cannot use rest params`),this.finishNode(e,`MethodDefinition`)},L.parseClassField=function(e){return it(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&it(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(E.eq)?(this.enterScope(Be|Re),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},L.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(M|Re);this.type!==E.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},L.parseClassId=function(e,t){this.type===E.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,N,!1)):(t===!0&&this.unexpected(),e.id=null)},L.parseClassSuper=function(e){e.superClass=this.eat(E._extends)?this.parseExprSubscripts(null,!1):null},L.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},L.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var o=n[a];Se(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}};function rt(e,t){var n=t.key.name,r=e[n],i=`true`;return t.type===`MethodDefinition`&&(t.kind===`get`||t.kind===`set`)&&(i=(t.static?`s`:`i`)+t.kind),r===`iget`&&i===`iset`||r===`iset`&&i===`iget`||r===`sget`&&i===`sset`||r===`sset`&&i===`sget`?(e[n]=`true`,!1):r?!0:(e[n]=i,!1)}function it(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}L.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual(`as`)?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual(`from`),this.type!==E.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},L.parseExport=function(e,t){if(this.next(),this.eat(E.star))return this.parseExportAllDeclaration(e,t);if(this.eat(E._default))return this.checkExport(t,`default`,this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,`ExportDefaultDeclaration`);if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type===`VariableDeclaration`?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual(`from`))this.type!==E.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type===`Literal`&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,`ExportNamedDeclaration`)},L.parseExportDeclaration=function(e){return this.parseStatement(null)},L.parseExportDefaultDeclaration=function(){var e;if(this.type===E._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,et|nt,!1,e)}else if(this.type===E._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}else{var r=this.parseMaybeAssign();return this.semicolon(),r}},L.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),Se(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},L.checkPatternExport=function(e,t){var n=t.type;if(n===`Identifier`)this.checkExport(e,t,t.start);else if(n===`ObjectPattern`)for(var r=0,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n===`ArrayPattern`)for(var o=0,s=t.elements;o<s.length;o+=1){var c=s[o];c&&this.checkPatternExport(e,c)}else n===`Property`?this.checkPatternExport(e,t.value):n===`AssignmentPattern`?this.checkPatternExport(e,t.left):n===`RestElement`&&this.checkPatternExport(e,t.argument)},L.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}},L.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},L.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual(`as`)?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,`ExportSpecifier`)},L.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(E.braceL);!this.eat(E.braceR);){if(n)n=!1;else if(this.expect(E.comma),this.afterTrailingComma(E.braceR))break;t.push(this.parseExportSpecifier(e))}return t},L.parseImport=function(e){return this.next(),this.type===E.string?(e.specifiers=$e,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===E.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},L.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual(`as`)?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,N),this.finishNode(e,`ImportSpecifier`)},L.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,N),this.finishNode(e,`ImportDefaultSpecifier`)},L.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,N),this.finishNode(e,`ImportNamespaceSpecifier`)},L.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===E.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(E.comma)))return e;if(this.type===E.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(E.braceL);!this.eat(E.braceR);){if(t)t=!1;else if(this.expect(E.comma),this.afterTrailingComma(E.braceR))break;e.push(this.parseImportSpecifier())}return e},L.parseWithClause=function(){var e=[];if(!this.eat(E._with))return e;this.expect(E.braceL);for(var t={},n=!0;!this.eat(E.braceR);){if(n)n=!1;else if(this.expect(E.comma),this.afterTrailingComma(E.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;Se(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},L.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===E.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(E.colon),this.type!==E.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},L.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===E.string){var e=this.parseLiteral(this.value);return Te.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},L.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},L.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type===`ExpressionStatement`&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(this.input[e.start]===`"`||this.input[e.start]===`'`)};var R=P.prototype;R.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case`Identifier`:this.inAsync&&e.name===`await`&&this.raise(e.start,`Cannot use 'await' as identifier inside an async function`);break;case`ObjectPattern`:case`ArrayPattern`:case`AssignmentPattern`:case`RestElement`:break;case`ObjectExpression`:e.type=`ObjectPattern`,n&&this.checkPatternErrors(n,!0);for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.toAssignable(a,t),a.type===`RestElement`&&(a.argument.type===`ArrayPattern`||a.argument.type===`ObjectPattern`)&&this.raise(a.argument.start,`Unexpected token`)}break;case`Property`:e.kind!==`init`&&this.raise(e.key.start,`Object pattern can't contain getter or setter`),this.toAssignable(e.value,t);break;case`ArrayExpression`:e.type=`ArrayPattern`,n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case`SpreadElement`:e.type=`RestElement`,this.toAssignable(e.argument,t),e.argument.type===`AssignmentPattern`&&this.raise(e.argument.start,`Rest elements cannot have a default value`);break;case`AssignmentExpression`:e.operator!==`=`&&this.raise(e.left.end,`Only '=' operator can be used for specifying default value.`),e.type=`AssignmentPattern`,delete e.operator,this.toAssignable(e.left,t);break;case`ParenthesizedExpression`:this.toAssignable(e.expression,t,n);break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:if(!t)break;default:this.raise(e.start,`Assigning to rvalue`)}else n&&this.checkPatternErrors(n,!0);return e},R.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e[r];i&&this.toAssignable(i,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type===`RestElement`&&a.argument.type!==`Identifier`&&this.unexpected(a.argument.start)}return e},R.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},R.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==E.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},R.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case E.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(E.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case E.braceL:return this.parseObj(!0)}return this.parseIdent()},R.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(E.comma),t&&this.type===E.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===E.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===E.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(e);break}else i.push(this.parseAssignableListItem(r));return i},R.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},R.parseBindingListItem=function(e){return e},R.parseMaybeDefault=function(e,t,n){if(n||=this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(E.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},R.checkLValSimple=function(e,t,n){t===void 0&&(t=We);var r=t!==We;switch(e.type){case`Identifier`:this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?`Binding `:`Assigning to `)+e.name+` in strict mode`),r&&(t===N&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(Se(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==Je&&this.declareName(e.name,t,e.start));break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:r&&this.raiseRecoverable(e.start,`Binding member expression`);break;case`ParenthesizedExpression`:return r&&this.raiseRecoverable(e.start,`Binding parenthesized expression`),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?`Binding`:`Assigning to`)+` rvalue`)}},R.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=We),e.type){case`ObjectPattern`:for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,t,n)}break;case`ArrayPattern`:for(var o=0,s=e.elements;o<s.length;o+=1){var c=s[o];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},R.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=We),e.type){case`Property`:this.checkLValInnerPattern(e.value,t,n);break;case`AssignmentPattern`:this.checkLValPattern(e.left,t,n);break;case`RestElement`:this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var z=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},B={b_stat:new z(`{`,!1),b_expr:new z(`{`,!0),b_tmpl:new z("${",!1),p_stat:new z(`(`,!1),p_expr:new z(`(`,!0),q_tmpl:new z("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new z(`function`,!1),f_expr:new z(`function`,!0),f_expr_gen:new z(`function`,!0,!1,null,!0),f_gen:new z(`function`,!1,!1,null,!0)},at=P.prototype;at.initialContext=function(){return[B.b_stat]},at.curContext=function(){return this.context[this.context.length-1]},at.braceIsBlock=function(e){var t=this.curContext();return t===B.f_expr||t===B.f_stat?!0:e===E.colon&&(t===B.b_stat||t===B.b_expr)?!t.isExpr:e===E._return||e===E.name&&this.exprAllowed?D.test(this.input.slice(this.lastTokEnd,this.start)):e===E._else||e===E.semi||e===E.eof||e===E.parenR||e===E.arrow?!0:e===E.braceL?t===B.b_stat:e===E._var||e===E._const||e===E.name?!1:!this.exprAllowed},at.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token===`function`)return t.generator}return!1},at.updateContext=function(e){var t,n=this.type;n.keyword&&e===E.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},at.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},E.parenR.updateContext=E.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===B.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},E.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?B.b_stat:B.b_expr),this.exprAllowed=!0},E.dollarBraceL.updateContext=function(){this.context.push(B.b_tmpl),this.exprAllowed=!0},E.parenL.updateContext=function(e){var t=e===E._if||e===E._for||e===E._with||e===E._while;this.context.push(t?B.p_stat:B.p_expr),this.exprAllowed=!0},E.incDec.updateContext=function(){},E._function.updateContext=E._class.updateContext=function(e){e.beforeExpr&&e!==E._else&&!(e===E.semi&&this.curContext()!==B.p_stat)&&!(e===E._return&&D.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===E.colon||e===E.braceL)&&this.curContext()===B.b_stat)?this.context.push(B.f_expr):this.context.push(B.f_stat),this.exprAllowed=!1},E.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},E.backQuote.updateContext=function(){this.curContext()===B.q_tmpl?this.context.pop():this.context.push(B.q_tmpl),this.exprAllowed=!1},E.star.updateContext=function(e){if(e===E._function){var t=this.context.length-1;this.context[t]===B.f_expr?this.context[t]=B.f_expr_gen:this.context[t]=B.f_gen}this.exprAllowed=!0},E.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==E.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var V=P.prototype;V.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type===`SpreadElement`)&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,i;switch(r.type){case`Identifier`:i=r.name;break;case`Literal`:i=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6){i===`__proto__`&&a===`init`&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,`Redefinition of __proto__ property`)),t.proto=!0);return}i=`$`+i;var o=t[i];o?(a===`init`?this.strict&&o.init||o.get||o.set:o.init||o[a])&&this.raiseRecoverable(r.start,`Redefinition of property`):o=t[i]={init:!1,get:!1,set:!1},o[a]=!0}},V.parseExpression=function(e,t){var n=this;return this.catchStackOverflow(function(){var r=n.start,i=n.startLoc,a=n.parseMaybeAssign(e,t);if(n.type===E.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat(E.comma);)o.expressions.push(n.parseMaybeAssign(e,t));return n.finishNode(o,`SequenceExpression`)}return a})},V.parseMaybeAssign=function(e,t,n){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,o=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Xe,r=!0);var s=this.start,c=this.startLoc;(this.type===E.parenL||this.type===E.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e===`await`);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,s,c)),this.type.isAssign){var u=this.startNodeAt(s,c);return u.operator=this.value,this.type===E.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===E.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(u,`AssignmentExpression`)}else r&&this.checkExpressionErrors(t,!0);return i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},V.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(!(i.type===`ArrowFunctionExpression`&&i.start===n)&&this.eat(E.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(E.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},V.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type===`ArrowFunctionExpression`?i:this.parseExprOp(i,n,r,-1,e)},V.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==E._in)&&a>r){var o=this.type===E.logicalOR||this.type===E.logicalAND,s=this.type===E.coalesce;s&&(a=E.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,u,a,i),f=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===E.coalesce||s&&(this.type===E.logicalOR||this.type===E.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(f,t,n,r,i)}return e},V.buildBinary=function(e,t,n,r,i,a){r.type===`PrivateIdentifier`&&this.raise(r.start,`Private identifier can only be left side of binary expression`);var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?`LogicalExpression`:`BinaryExpression`)},V.parseMaybeUnary=function(e,t,n,r){var i=this.start,a=this.startLoc,o;if(this.isContextual(`await`)&&this.canAwait)o=this.parseAwait(r),t=!0;else if(this.type.prefix){var s=this.startNode(),c=this.type===E.incDec;s.operator=this.value,s.prefix=!0,this.next(),s.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(s.argument):this.strict&&s.operator===`delete`&&ot(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&st(s.argument)?this.raiseRecoverable(s.start,`Private fields can not be deleted`):t=!0,o=this.finishNode(s,c?`UpdateExpression`:`UnaryExpression`)}else if(!t&&this.type===E.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==E._in&&this.unexpected();else{if(o=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return o;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,a);l.operator=this.value,l.prefix=!1,l.argument=o,this.checkLValSimple(o),this.next(),o=this.finishNode(l,`UpdateExpression`)}}if(!n&&this.eat(E.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,o,this.parseMaybeUnary(null,!1,!1,r),`**`,!1);else return o};function ot(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&ot(e.expression)}function st(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&st(e.expression)||e.type===`ParenthesizedExpression`&&st(e.expression)}V.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprAtom(e,t);if(i.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return i;var a=this.parseSubscripts(i,n,r,!1,t);return e&&a.type===`MemberExpression`&&(e.parenthesizedAssign>=a.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=a.start&&(e.parenthesizedBind=-1),e.trailingComma>=a.start&&(e.trailingComma=-1)),a},V.parseSubscripts=function(e,t,n,r,i){for(var a=this.options.ecmaVersion>=8&&e.type===`Identifier`&&e.name===`async`&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,o=!1;;){var s=this.parseSubscript(e,t,n,r,a,o,i);if(s.optional&&(o=!0),s===e||s.type===`ArrowFunctionExpression`){if(o){var c=this.startNodeAt(t,n);c.expression=s,s=this.finishNode(c,`ChainExpression`)}return s}e=s}},V.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(E.arrow)},V.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},V.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat(E.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(E.bracketL);if(l||c&&this.type!==E.parenL&&this.type!==E.backQuote||this.eat(E.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(E.bracketR)):this.type===E.privateId&&e.type!==`Super`?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat(E.parenL)){var d=new Xe,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList(E.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=f,this.awaitPos=p,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,h,o);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var g=this.startNodeAt(t,n);g.callee=e,g.arguments=h,s&&(g.optional=c),e=this.finishNode(g,`CallExpression`)}else if(this.type===E.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var _=this.startNodeAt(t,n);_.tag=e,_.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(_,`TaggedTemplateExpression`)}return e},V.parseExprAtom=function(e,t,n){this.type===E.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case E._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===E.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==E.dot&&this.type!==E.bracketL&&this.type!==E.parenL&&this.unexpected(),this.finishNode(r,`Super`);case E._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case E.name:var a=this.start,o=this.startLoc,s=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!s&&c.name===`async`&&!this.canInsertSemicolon()&&this.eat(E._function))return this.overrideContext(B.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(E.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===E.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(E.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case E.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case E.num:case E.string:return this.parseLiteral(this.value);case E._null:case E._true:case E._false:return r=this.startNode(),r.value=this.type===E._null?null:this.type===E._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case E.parenL:var u=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),d;case E.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(E.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case E.braceL:return this.overrideContext(B.b_expr),this.parseObj(!1,e);case E._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case E._class:return this.parseClass(this.startNode(),!1);case E._new:return this.parseNew();case E.backQuote:return this.parseTemplate();case E._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},V.parseExprAtomDefault=function(){this.unexpected()},V.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===E.parenL&&!e)return this.parseDynamicImport(t);if(this.type===E.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name=`import`,t.meta=this.finishNode(n,`Identifier`),this.parseImportMeta(t)}else this.unexpected()},V.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(E.parenR)?e.options=null:(this.expect(E.comma),this.afterTrailingComma(E.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(E.parenR)||(this.expect(E.comma),this.afterTrailingComma(E.parenR)||this.unexpected())));else if(!this.eat(E.parenR)){var t=this.start;this.eat(E.comma)&&this.eat(E.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},V.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`meta`&&this.raiseRecoverable(e.property.start,`The only valid meta property for import is 'import.meta'`),t&&this.raiseRecoverable(e.start,`'import.meta' must not contain escaped characters`),this.options.sourceType!==`module`&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,`Cannot use 'import.meta' outside a module`),this.finishNode(e,`MetaProperty`)},V.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value==null?t.raw.slice(0,-1).replace(/_/g,``):t.value.toString()),this.next(),this.finishNode(t,`Literal`)},V.parseParenExpression=function(){this.expect(E.parenL);var e=this.parseExpression();return this.expect(E.parenR),e},V.shouldParseArrow=function(e){return!this.canInsertSemicolon()},V.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,s=this.startLoc,c=[],l=!0,u=!1,d=new Xe,f=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==E.parenR;)if(l?l=!1:this.expect(E.comma),a&&this.afterTrailingComma(E.parenR,!0)){u=!0;break}else if(this.type===E.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===E.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}else c.push(this.parseMaybeAssign(!1,d,this.parseParenItem));var h=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(E.parenR),e&&this.shouldParseArrow(c)&&this.eat(E.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=p,this.parseParenArrowList(n,r,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,c.length>1?(i=this.startNodeAt(o,s),i.expressions=c,this.finishNodeAt(i,`SequenceExpression`,h,g)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var _=this.startNodeAt(n,r);return _.expression=i,this.finishNode(_,`ParenthesizedExpression`)}else return i},V.parseParenItem=function(e){return e},V.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var ct=[];V.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword new`);var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===E.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name=`new`,e.meta=this.finishNode(t,`Identifier`),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`target`&&this.raiseRecoverable(e.property.start,`The only valid meta property for new is 'new.target'`),n&&this.raiseRecoverable(e.start,`'new.target' must not contain escaped characters`),this.allowNewDotTarget||this.raiseRecoverable(e.start,`'new.target' can only be used in functions and class static block`),this.finishNode(e,`MetaProperty`)}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),e.callee.type===`Super`&&this.raiseRecoverable(r,`Invalid use of 'super'`),this.eat(E.parenL)?e.arguments=this.parseExprList(E.parenR,this.options.ecmaVersion>=8,!1):e.arguments=ct,this.finishNode(e,`NewExpression`)},V.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===E.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\r\n?/g,`
|
|
11
|
-
`),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
12
|
-
`),cooked:this.value},this.next(),n.tail=this.type===E.backQuote,this.finishNode(n,`TemplateElement`)},V.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===E.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(E.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(E.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},V.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===E.name||this.type===E.num||this.type===E.string||this.type===E.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===E.star)&&!D.test(this.input.slice(this.lastTokEnd,this.start))},V.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(E.braceR);){if(r)r=!1;else if(this.expect(E.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(E.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),n.properties.push(a)}return this.finishNode(n,e?`ObjectPattern`:`ObjectExpression`)},V.parseProperty=function(e,t){var n=this.startNode(),r,i,a,o;if(this.options.ecmaVersion>=9&&this.eat(E.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===E.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.finishNode(n,`RestElement`)):(n.argument=this.parseMaybeAssign(!1,t),this.type===E.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,`SpreadElement`));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,o=this.startLoc),e||(r=this.eat(E.star)));var s=this.containsEsc;return this.parsePropertyName(n),!e&&!s&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(E.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,o,t,s),this.finishNode(n,`Property`)},V.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind===`get`?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind===`get`?this.raiseRecoverable(r,`getter should have no params`):this.raiseRecoverable(r,`setter should have exactly one param`)}else e.kind===`set`&&e.value.params[0].type===`RestElement`&&this.raiseRecoverable(e.value.params[0].start,`Setter cannot use rest params`)},V.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===E.colon&&this.unexpected(),this.eat(E.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===E.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind=`init`):!t&&!s&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.type!==E.comma&&this.type!==E.braceR&&this.type!==E.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type===`Identifier`?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===E.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind=`init`,e.shorthand=!0):this.unexpected()},V.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(E.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(E.bracketR),e.key;e.computed=!1}return e.key=this.type===E.num||this.type===E.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},V.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},V.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ue(t,r.generator)|Re|(n?ze:0)),this.expect(E.parenL),r.params=this.parseBindingList(E.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(r,`FunctionExpression`)},V.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(Ue(n,!1)|Ie),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,`ArrowFunctionExpression`)},V.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==E.braceL,a=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||s)&&(o=this.strictDirective(this.end),o&&s&&this.raiseRecoverable(e.start,`Illegal 'use strict' directive in function with non-simple parameter list`));var c=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!a&&!o&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Je),e.body=this.parseBlock(!1,void 0,o&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},V.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1)if(n[t].type!==`Identifier`)return!1;return!0},V.checkParams=function(e,t){for(var n=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,Ge,t?null:n)}},V.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(E.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===E.comma?o=null:this.type===E.ellipsis?(o=this.parseSpread(r),r&&this.type===E.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},V.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;this.inGenerator&&r===`yield`&&this.raiseRecoverable(t,`Cannot use 'yield' as identifier inside a generator`),this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use 'await' as identifier inside an async function`),!(this.currentThisScope().flags&He)&&r===`arguments`&&this.raiseRecoverable(t,`Cannot use 'arguments' in class field initializer`),this.inClassStaticBlock&&(r===`arguments`||r===`await`)&&this.raise(t,`Cannot use `+r+` in class static initialization block`),this.keywords.test(r)&&this.raise(t,`Unexpected keyword '`+r+`'`),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf(`\\`)!==-1)&&(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(!this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use keyword 'await' outside an async function`),this.raiseRecoverable(t,`The keyword '`+r+`' is reserved`))},V.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,`Identifier`),e||(this.checkUnreserved(t),t.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},V.parseIdentNode=function(){var e=this.startNode();return this.type===E.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name===`class`||e.name===`function`)&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=E.name):this.unexpected(),e},V.parsePrivateIdent=function(){var e=this.startNode();return this.type===E.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,`PrivateIdentifier`),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,`Private field '#`+e.name+`' must be declared in an enclosing class`):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},V.parseYield=function(e){this.yieldPos||=this.start;var t=this.startNode();return this.next(),this.type===E.semi||this.canInsertSemicolon()||this.type!==E.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(E.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},V.parseAwait=function(e){this.awaitPos||=this.start;var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,`AwaitExpression`)};var lt=P.prototype;lt.raise=function(e,t){var n=Oe(this.input,e);t+=` (`+n.line+`:`+n.column+`)`,this.sourceFile&&(t+=` in `+this.sourceFile);var r=SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r},lt.raiseRecoverable=lt.raise,lt.curPosition=function(){if(this.options.locations)return new Ee(this.curLine,this.pos-this.lineStart)};var H=P.prototype,ut=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};H.enterScope=function(e){this.scopeStack.push(new ut(e))},H.exitScope=function(){this.scopeStack.pop()},H.treatFunctionsAsVarInScope=function(e){return e.flags&j||!this.inModule&&e.flags&Ne},H.declareName=function(e,t,n){var r=!1;if(t===N){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&Ne&&delete this.undefinedExports[e]}else if(t===qe)this.currentScope().lexical.push(e);else if(t===Ke){var a=this.currentScope();r=this.treatFunctionsAsVar?a.lexical.indexOf(e)>-1:a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var s=this.scopeStack[o];if(s.lexical.indexOf(e)>-1&&!(s.flags&Le&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&Ne&&delete this.undefinedExports[e],s.flags&He)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},H.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},H.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},H.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(He|Be|M))return t}},H.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(He|Be|M)&&!(t.flags&Ie))return t}};var dt=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new De(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},ft=P.prototype;ft.startNode=function(){return new dt(this,this.start,this.startLoc)},ft.startNodeAt=function(e,t){return new dt(this,e,t)};function pt(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}ft.finishNode=function(e,t){return pt.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},ft.finishNodeAt=function(e,t,n,r){return pt.call(this,e,t,n,r)},ft.copyNode=function(e){var t=new dt(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var mt=`Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz`,ht=`ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS`,gt=ht+` Extended_Pictographic`,_t=gt,vt=_t+` EBase EComp EMod EPres ExtPict`,yt=vt,bt={9:ht,10:gt,11:_t,12:vt,13:yt,14:yt},xt={9:``,10:``,11:``,12:``,13:``,14:`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`},St=`Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu`,Ct=`Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb`,wt=Ct+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,Tt=wt+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,Et=Tt+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,Dt=Et+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,Ot={9:Ct,10:wt,11:Tt,12:Et,13:Dt,14:Dt+` `+mt},kt={};function At(e){var t=kt[e]={binary:k(bt[e]+` `+St),binaryOfStrings:k(xt[e]),nonBinary:{General_Category:k(St),Script:k(Ot[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var jt=0,Mt=[9,10,11,12,13,14];jt<Mt.length;jt+=1){var Nt=Mt[jt];At(Nt)}var U=P.prototype,Pt=function(e,t){this.parent=e,this.base=t||this};Pt.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1},Pt.prototype.sibling=function(){return new Pt(this.parent,this.base)};var W=function(e){this.parser=e,this.validFlags=`gim`+(e.options.ecmaVersion>=6?`uy`:``)+(e.options.ecmaVersion>=9?`s`:``)+(e.options.ecmaVersion>=13?`d`:``)+(e.options.ecmaVersion>=15?`v`:``),this.unicodeProperties=kt[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source=``,this.flags=``,this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue=``,this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};W.prototype.reset=function(e,t,n){var r=n.indexOf(`v`)!==-1,i=n.indexOf(`u`)!==-1;this.start=e|0,this.source=t+``,this.flags=n,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},W.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},W.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return-1;var i=n.charCodeAt(e);if(!(t||this.switchU)||i<=55295||i>=57344||e+1>=r)return i;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(i<<10)+a-56613888:i},W.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return r;var i=n.charCodeAt(e),a;return!(t||this.switchU)||i<=55295||i>=57344||e+1>=r||(a=n.charCodeAt(e+1))<56320||a>57343?e+1:e+2},W.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},W.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},W.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},W.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1},W.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,r=0,i=e;r<i.length;r+=1){var a=i[r],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},U.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,i=!1,a=0;a<n.length;a++){var o=n.charAt(a);t.indexOf(o)===-1&&this.raise(e.start,`Invalid regular expression flag`),n.indexOf(o,a+1)>-1&&this.raise(e.start,`Duplicate regular expression flag`),o===`u`&&(r=!0),o===`v`&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,`Invalid regular expression flag`)};function Ft(e){for(var t in e)return!0;return!1}U.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Ft(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},U.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue=``,e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise(`Unmatched ')'`),(e.eat(93)||e.eat(125))&&e.raise(`Lone quantifier brackets`)),e.maxBackReference>e.numCapturingParens&&e.raise(`Invalid escape`);for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise(`Invalid named capture referenced`)}},U.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new Pt(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise(`Nothing to repeat`),e.eat(123)&&e.raise(`Lone quantifier brackets`)},U.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},U.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise(`Invalid quantifier`),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1},U.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise(`Unterminated group`),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},U.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1},U.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},U.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i<r&&!t&&e.raise(`numbers out of order in {} quantifier`),!0;e.switchU&&!t&&e.raise(`Incomplete quantifier`),e.pos=n}return!1},U.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},U.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},U.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var i=0;i<n.length;i++){var a=n.charAt(i);n.indexOf(a,i+1)>-1&&e.raise(`Duplicate regular expression modifiers`)}if(r){var o=this.regexp_eatModifiers(e);!n&&!o&&e.current()===58&&e.raise(`Invalid regular expression modifiers`);for(var s=0;s<o.length;s++){var c=o.charAt(s);(o.indexOf(c,s+1)>-1||n.indexOf(c)>-1)&&e.raise(`Duplicate regular expression modifiers`)}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise(`Unterminated group`)}}e.pos=t}return!1},U.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise(`Invalid group`),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise(`Unterminated group`)}return!1},U.regexp_eatModifiers=function(e){for(var t=``,n=0;(n=e.current())!==-1&&It(n);)t+=A(n),e.advance();return t};function It(e){return e===105||e===109||e===115}U.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},U.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise(`Nothing to repeat`),!1},U.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Lt(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Lt(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}U.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!Lt(n);)e.advance();return e.pos!==t},U.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1},U.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise(`Invalid group`);var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var r=0,i=n;r<i.length;r+=1)i[r].separatedFrom(e.branchID)||e.raise(`Duplicate capture group name`);else e.raise(`Duplicate capture group name`);t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},U.regexp_eatGroupName=function(e){if(e.lastStringValue=``,e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise(`Invalid capture group name`)}return!1},U.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue=``,this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=A(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=A(e.lastIntValue);return!0}return!1},U.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),Rt(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function Rt(e){return y(e,!0)||e===36||e===95}U.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),zt(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function zt(e){return b(e,!0)||e===36||e===95||e===8204||e===8205}U.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise(`Invalid unicode escape`),e.raise(`Invalid escape`)),!1)},U.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},U.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise(`Invalid named reference`)}return!1},U.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},U.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},U.regexp_eatZero=function(e){return e.current()===48&&!Yt(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1},U.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1},U.regexp_eatControlLetter=function(e){var t=e.current();return Bt(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Bt(e){return e>=65&&e<=90||e>=97&&e<=122}U.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(r&&i>=55296&&i<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var o=e.lastIntValue;if(o>=56320&&o<=57343)return e.lastIntValue=(i-55296)*1024+(o-56320)+65536,!0}e.pos=a,e.lastIntValue=i}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&Vt(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function Vt(e){return e>=0&&e<=1114111}U.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1},U.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Ht=0,G=1,K=2;U.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Ut(t))return e.lastIntValue=-1,e.advance(),G;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===K&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return Ht};function Ut(e){return e===100||e===68||e===115||e===83||e===119||e===87}U.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),G}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Ht},U.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Se(e.unicodeProperties.nonBinary,t)||e.raise(`Invalid property name`),e.unicodeProperties.nonBinary[t].test(n)||e.raise(`Invalid property value`)},U.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return G;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return K;e.raise(`Invalid property name`)},U.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;Wt(t=e.current());)e.lastStringValue+=A(t),e.advance();return e.lastStringValue!==``};function Wt(e){return Bt(e)||e===95}U.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;Gt(t=e.current());)e.lastStringValue+=A(t),e.advance();return e.lastStringValue!==``};function Gt(e){return Wt(e)||Yt(e)}U.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},U.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise(`Unterminated character class`),t&&n===K&&e.raise(`Negated character class may contain strings`),!0}return!1},U.regexp_classContents=function(e){return e.current()===93?G:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),G)},U.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise(`Invalid character class`),t!==-1&&n!==-1&&t>n&&e.raise(`Range out of order in character class`)}}},U.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Qt(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r===93?!1:(e.lastIntValue=r,e.advance(),!0)},U.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},U.regexp_classSetExpression=function(e){var t=G,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===K&&(t=K);for(var r=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==K&&(t=G);continue}e.raise(`Invalid character in character class`)}if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise(`Invalid character in character class`);if(r!==e.pos)return t}else e.raise(`Invalid character in character class`);for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===K&&(t=K)}},U.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise(`Range out of order in character class`),!0}e.pos=t}return!1},U.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?G:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},U.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===K&&e.raise(`Negated character class may contain strings`),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},U.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise(`Invalid escape`);e.pos=t}return null},U.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===K&&(t=K);return t},U.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?G:K},U.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&Kt(n)||qt(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function Kt(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function qt(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}U.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Jt(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Jt(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}U.regexp_eatClassControlLetter=function(e){var t=e.current();return Yt(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1},U.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise(`Invalid escape`),e.pos=t}return!1},U.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Yt(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function Yt(e){return e>=48&&e<=57}U.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Xt(n=e.current());)e.lastIntValue=16*e.lastIntValue+Zt(n),e.advance();return e.pos!==t};function Xt(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Zt(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}U.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1},U.regexp_eatOctalDigit=function(e){var t=e.current();return Qt(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Qt(e){return e>=48&&e<=55}U.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!Xt(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Zt(i),e.advance()}return!0};var $t=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new De(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},q=P.prototype;q.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword `+this.type.keyword),this.options.onToken&&this.options.onToken(new $t(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},q.getToken=function(){return this.next(),new $t(this)},typeof Symbol<`u`&&(q[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===E.eof,value:t}}}}),q.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(E.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},q.readToken=function(e){return y(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},q.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var n=this.input.charCodeAt(e+1);return n<=56319||n>=57344?t:(t<<10)+n-56613888},q.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},q.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf(`*/`,this.pos+=2);if(n===-1&&this.raise(this.pos-2,`Unterminated comment`),this.pos=n+2,this.options.locations)for(var r=void 0,i=t;(r=_e(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},q.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!ge(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},q.skipSpace=function(){loop:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++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(e>8&&e<14||e>=5760&&ve.test(String.fromCharCode(e)))++this.pos;else break loop}}},q.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},q.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(E.ellipsis)):(++this.pos,this.finishToken(E.dot))},q.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(E.assign,2):this.finishOp(E.slash,1)},q.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?E.star:E.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=E.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(E.assign,n+1):this.finishOp(r,n)},q.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(E.assign,3):this.finishOp(e===124?E.logicalOR:E.logicalAND,2):t===61?this.finishOp(E.assign,2):this.finishOp(e===124?E.bitwiseOR:E.bitwiseAND,1)},q.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(E.assign,2):this.finishOp(E.bitwiseXOR,1)},q.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||D.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(E.incDec,2):t===61?this.finishOp(E.assign,2):this.finishOp(E.plusMin,1)},q.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(E.assign,n+1):this.finishOp(E.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(E.relational,n))},q.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(E.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(E.arrow)):this.finishOp(e===61?E.eq:E.prefix,1)},q.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(E.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(E.assign,3):this.finishOp(E.coalesce,2)}return this.finishOp(E.question,1)},q.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),y(t,!0)||t===92))return this.finishToken(E.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+A(t)+`'`)},q.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(E.parenL);case 41:return++this.pos,this.finishToken(E.parenR);case 59:return++this.pos,this.finishToken(E.semi);case 44:return++this.pos,this.finishToken(E.comma);case 91:return++this.pos,this.finishToken(E.bracketL);case 93:return++this.pos,this.finishToken(E.bracketR);case 123:return++this.pos,this.finishToken(E.braceL);case 125:return++this.pos,this.finishToken(E.braceR);case 58:return++this.pos,this.finishToken(E.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(E.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===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(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(E.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+A(e)+`'`)},q.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},q.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,`Unterminated regular expression`);var r=this.input.charAt(this.pos);if(D.test(r)&&this.raise(n,`Unterminated regular expression`),e)e=!1;else{if(r===`[`)t=!0;else if(r===`]`&&t)t=!1;else if(r===`/`&&!t)break;e=r===`\\`}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var s=this.regexpState||=new W(this);s.reset(n,i,o),this.validateRegExpFlags(s),this.validateRegExpPattern(s);var c=null;try{c=new RegExp(i,o)}catch{}return this.finishToken(E.regexp,{pattern:i,flags:o,value:c})},q.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,s=0,c=0,l=t??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),d=void 0;if(r&&u===95){i&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),s===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),c===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),s=u;continue}if(d=u>=97?u-97+10:u>=65?u-65+10:u>=48&&u<=57?u-48:1/0,d>=e)break;s=u,o=o*e+d}return r&&s===95&&this.raiseRecoverable(this.pos-1,`Numeric separator is not allowed at the last of digits`),this.pos===a||t!=null&&this.pos-a!==t?null:o};function en(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function tn(e){return typeof BigInt==`function`?BigInt(e.replace(/_/g,``)):null}q.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n??this.raise(this.start+2,`Expected number in radix `+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=tn(this.input.slice(t,this.pos)),++this.pos):y(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(E.num,n)},q.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,`Invalid number`);var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,`Invalid number`);var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var i=tn(this.input.slice(t,this.pos));return++this.pos,y(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(E.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!n&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,`Invalid number`)),y(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=en(this.input.slice(t,this.pos),n);return this.finishToken(E.num,a)},q.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf(`}`,this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,`Code point out of bounds`)}else t=this.readHexChar(4);return t},q.readString=function(e){for(var t=``,n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,`Unterminated string constant`),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(ge(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(E.string,t)};var nn={};q.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===nn)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},q.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw nn;this.raise(e,t)},q.readTmplToken=function(){for(var e=``,t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated template`);var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===E.template||this.type===E.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(E.dollarBraceL)):(++this.pos,this.finishToken(E.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(E.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(ge(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
|
|
13
|
-
`;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},q.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(E.invalidTemplate,this.input.slice(this.start,this.pos));case`\r`:this.input[this.pos+1]===`
|
|
14
|
-
`&&++this.pos;case`
|
|
15
|
-
`:case`\u2028`:case`\u2029`:++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,`Unterminated template`)},q.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
|
|
16
|
-
`;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return A(this.readCodePoint());case 116:return` `;case 98:return`\b`;case 118:return`\v`;case 102:return`\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!==`0`||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return ge(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},q.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},q.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(b(i,r))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\uXXXX`),++this.pos;var o=this.readCodePoint();(t?y:b)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=A(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},q.readWord=function(){var e=this.readWord1(),t=E.name;return this.keywords.test(e)&&(t=me[e]),this.finishToken(t,e)},P.acorn={Parser:P,version:`8.17.0`,defaultOptions:ke,Position:Ee,SourceLocation:De,getLineInfo:Oe,Node:dt,TokenType:x,tokTypes:E,keywordTypes:me,TokContext:z,tokContexts:B,isIdentifierChar:b,isIdentifierStart:y,Token:$t,isNewLine:ge,lineBreak:D,lineBreakG:he,nonASCIIwhitespace:ve};function rn(e,t){return P.parse(e,t)}function an(e,t,n){return P.parseExpressionAt(e,t,n)}function on(e,t){function n(e,t){let n=[];for(let r of e){let e=i(r,t);e!==null&&(Array.isArray(e)?n.push(...e):n.push(e))}return n}function i(e,a){if(!e||typeof e!=`object`)return e;let o=e;if(t.enter){let e=t.enter(o,a);if(e!==void 0){if(e===null||Array.isArray(e))return e;o=e}}let s=t[o.type];if(s){let e=s(o,a);if(e!==void 0){if(e===null||Array.isArray(e))return e;o=e}}switch(o.type){case r.Program:{let e=n(o.body,o);o={...o,body:e};break}case r.Element:{let e=o.attributes;if(t.Attribute&&Array.isArray(o.attributes)){let n=[];for(let e of o.attributes){let r=t.Attribute(e,o);r==null?r===void 0&&n.push(e):n.push(r)}e=n}let r=n(o.children,o);o={...o,attributes:e,children:r};break}case r.If:{let e=n(o.consequent,o),t=o.alternate;Array.isArray(o.alternate)?t=n(o.alternate,o):o.alternate!==null&&typeof o.alternate==`object`&&(t=i(o.alternate,o)),o={...o,consequent:e,alternate:t};break}case r.For:{let e=n(o.body,o);o={...o,body:e};break}case r.Switch:if(Array.isArray(o.cases)){let e=o.cases.map(e=>({...e,body:n(e.body,o)}));o={...o,cases:e}}break}if(t.leave){let e=t.leave(o,a);if(e!==void 0)return e}return o}return i(e,null)}var sn=class{rawAst;switchCounter=0;constructor(e){this.rawAst=e}transform(){return on(on(on(this.rawAst,{Text:e=>{if(typeof e.content==`string`&&this.isWhitespaceOnly(e.content))return null}}),{Switch:e=>this.transformSwitchToIfChain(e)}),{Interpolation:e=>this.transformInterpolation(e),Element:e=>{if(e.tagName===`script`)return this.transformScriptElement(e);if(e.attributes.some(e=>e.value!==null&&typeof e.value!=`string`))return{...e,attributes:e.attributes.map(e=>e.type===r.Attribute&&e.value!==null&&typeof e.value!=`string`&&e.value.type===r.Interpolation?{...e,value:this.transformInterpolation(e.value)}:e)}},If:e=>{if(typeof e.test==`string`&&e.test.trim().length>0)return{...e,test:an(e.test,0,{ecmaVersion:`latest`})}},For:e=>({...e,iterable:typeof e.iterable==`string`?an(e.iterable,0,{ecmaVersion:`latest`}):e.iterable,key:typeof e.key==`string`&&e.key.trim().length>0?an(e.key,0,{ecmaVersion:`latest`}):e.key??null})})}transformSwitchToIfChain(e){let t=typeof e.discriminant==`string`?an(e.discriminant,0,{ecmaVersion:`latest`}):e.discriminant,n=t.type===`Identifier`||t.type===`Literal`||t.type===`MemberExpression`,i=`__drift_sw_${this.switchCounter++}`,a=!0,o=s=>{let c=e.cases[s];if(!c)return null;if(c.expression===null){let e=[...c.body],t=o(s+1),n=null;return(Array.isArray(t)||t!==null&&t.type===r.If)&&(n=t),s>0&&n===null?e:{type:r.If,test:{type:`Literal`,value:!0,raw:`true`,start:0,end:0},consequent:e,alternate:n,loc:c.loc}}let l=typeof c.expression==`string`&&c.expression.trim().length>0?an(c.expression,0,{ecmaVersion:`latest`}):c.expression,u;n?u=structuredClone(t):a?(a=!1,u={type:`AssignmentExpression`,operator:`=`,left:{type:`Identifier`,name:i,start:0,end:0},right:structuredClone(t),start:0,end:0}):u={type:`Identifier`,name:i,start:0,end:0};let d={type:`BinaryExpression`,operator:`===`,left:u,right:l,start:0,end:0},f=[...c.body],p=o(s+1),m=null;return(Array.isArray(p)||p!==null&&p.type===r.If)&&(m=p),{type:r.If,test:d,consequent:f,alternate:m,extraDeps:structuredClone(t),loc:c.loc}},s=o(0);return s?Array.isArray(s)?s.length===0?{type:r.Comment,content:`empty switch`,loc:e.loc}:{type:r.If,test:{type:`Literal`,value:!0,raw:`true`,start:0,end:0},consequent:s,alternate:null,loc:e.loc}:s:{type:r.Comment,content:`empty switch`,loc:e.loc}}transformInterpolation(e){if(typeof e.expression!=`string`)return e;let t;try{t=an(e.expression,0,{ecmaVersion:`latest`,allowAwaitOutsideFunction:!0})}catch(t){throw new a(`Failed to parse JS expression in interpolation: ${t instanceof Error?t.message:String(t)}`,e.loc.start.line,e.loc.start.column,e.loc.start.offset)}return{...e,expression:t}}transformScriptElement(e){let t=e.children.map(e=>{if(e.type===r.Text&&typeof e.content==`string`){let t;try{let n=rn(e.content,{ecmaVersion:`latest`,sourceType:`module`,allowAwaitOutsideFunction:!0,allowReturnOutsideFunction:!0});t=n.body.length===1&&n.body[0]!==void 0?n.body[0]:n.body}catch(t){throw new a(`Failed to parse script tag JS content: ${t instanceof Error?t.message:String(t)}`,e.loc.start.line,e.loc.start.column,e.loc.start.offset)}return{...e,content:t}}return e});return{...e,children:t}}isWhitespaceOnly(e){return e.length>0&&/^\s*$/.test(e)}};function cn(e,t,n,r,i){var a=[];n||=Y,(function e(r,i,o){var s=o||r.type,c=r!==a[a.length-1];c&&a.push(r),un(n,s,r,i,e),t[s]&&t[s](r,i||a,a),c&&a.pop()})(e,r,i)}function ln(e,t,n){n(e,t)}function J(e,t,n){}function un(e,t,n,r,i){if(e[t]==null)throw Error(`No walker function defined for node type `+t);e[t](n,r,i)}var Y={};Y.Program=Y.BlockStatement=Y.StaticBlock=function(e,t,n){for(var r=0,i=e.body;r<i.length;r+=1){var a=i[r];n(a,t,`Statement`)}},Y.Statement=ln,Y.EmptyStatement=J,Y.ExpressionStatement=Y.ParenthesizedExpression=Y.ChainExpression=function(e,t,n){return n(e.expression,t,`Expression`)},Y.IfStatement=function(e,t,n){n(e.test,t,`Expression`),n(e.consequent,t,`Statement`),e.alternate&&n(e.alternate,t,`Statement`)},Y.LabeledStatement=function(e,t,n){return n(e.body,t,`Statement`)},Y.BreakStatement=Y.ContinueStatement=J,Y.WithStatement=function(e,t,n){n(e.object,t,`Expression`),n(e.body,t,`Statement`)},Y.SwitchStatement=function(e,t,n){n(e.discriminant,t,`Expression`);for(var r=0,i=e.cases;r<i.length;r+=1){var a=i[r];n(a,t)}},Y.SwitchCase=function(e,t,n){e.test&&n(e.test,t,`Expression`);for(var r=0,i=e.consequent;r<i.length;r+=1){var a=i[r];n(a,t,`Statement`)}},Y.ReturnStatement=Y.YieldExpression=Y.AwaitExpression=function(e,t,n){e.argument&&n(e.argument,t,`Expression`)},Y.ThrowStatement=Y.SpreadElement=function(e,t,n){return n(e.argument,t,`Expression`)},Y.TryStatement=function(e,t,n){n(e.block,t,`Statement`),e.handler&&n(e.handler,t),e.finalizer&&n(e.finalizer,t,`Statement`)},Y.CatchClause=function(e,t,n){e.param&&n(e.param,t,`Pattern`),n(e.body,t,`Statement`)},Y.WhileStatement=Y.DoWhileStatement=function(e,t,n){n(e.test,t,`Expression`),n(e.body,t,`Statement`)},Y.ForStatement=function(e,t,n){e.init&&n(e.init,t,`ForInit`),e.test&&n(e.test,t,`Expression`),e.update&&n(e.update,t,`Expression`),n(e.body,t,`Statement`)},Y.ForInStatement=Y.ForOfStatement=function(e,t,n){n(e.left,t,`ForInit`),n(e.right,t,`Expression`),n(e.body,t,`Statement`)},Y.ForInit=function(e,t,n){e.type===`VariableDeclaration`?n(e,t):n(e,t,`Expression`)},Y.DebuggerStatement=J,Y.FunctionDeclaration=function(e,t,n){return n(e,t,`Function`)},Y.VariableDeclaration=function(e,t,n){for(var r=0,i=e.declarations;r<i.length;r+=1){var a=i[r];n(a,t)}},Y.VariableDeclarator=function(e,t,n){n(e.id,t,`Pattern`),e.init&&n(e.init,t,`Expression`)},Y.Function=function(e,t,n){e.id&&n(e.id,t,`Pattern`);for(var r=0,i=e.params;r<i.length;r+=1){var a=i[r];n(a,t,`Pattern`)}n(e.body,t,e.expression?`Expression`:`Statement`)},Y.Pattern=function(e,t,n){e.type===`Identifier`?n(e,t,`VariablePattern`):e.type===`MemberExpression`?n(e,t,`MemberPattern`):n(e,t)},Y.VariablePattern=J,Y.MemberPattern=ln,Y.RestElement=function(e,t,n){return n(e.argument,t,`Pattern`)},Y.ArrayPattern=function(e,t,n){for(var r=0,i=e.elements;r<i.length;r+=1){var a=i[r];a&&n(a,t,`Pattern`)}},Y.ObjectPattern=function(e,t,n){for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];a.type===`Property`?(a.computed&&n(a.key,t,`Expression`),n(a.value,t,`Pattern`)):a.type===`RestElement`&&n(a.argument,t,`Pattern`)}},Y.Expression=ln,Y.ThisExpression=Y.Super=Y.MetaProperty=J,Y.ArrayExpression=function(e,t,n){for(var r=0,i=e.elements;r<i.length;r+=1){var a=i[r];a&&n(a,t,`Expression`)}},Y.ObjectExpression=function(e,t,n){for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];n(a,t)}},Y.FunctionExpression=Y.ArrowFunctionExpression=Y.FunctionDeclaration,Y.SequenceExpression=function(e,t,n){for(var r=0,i=e.expressions;r<i.length;r+=1){var a=i[r];n(a,t,`Expression`)}},Y.TemplateLiteral=function(e,t,n){for(var r=0,i=e.quasis;r<i.length;r+=1){var a=i[r];n(a,t)}for(var o=0,s=e.expressions;o<s.length;o+=1){var c=s[o];n(c,t,`Expression`)}},Y.TemplateElement=J,Y.UnaryExpression=Y.UpdateExpression=function(e,t,n){n(e.argument,t,`Expression`)},Y.BinaryExpression=Y.LogicalExpression=function(e,t,n){n(e.left,t,`Expression`),n(e.right,t,`Expression`)},Y.AssignmentExpression=Y.AssignmentPattern=function(e,t,n){n(e.left,t,`Pattern`),n(e.right,t,`Expression`)},Y.ConditionalExpression=function(e,t,n){n(e.test,t,`Expression`),n(e.consequent,t,`Expression`),n(e.alternate,t,`Expression`)},Y.NewExpression=Y.CallExpression=function(e,t,n){if(n(e.callee,t,`Expression`),e.arguments)for(var r=0,i=e.arguments;r<i.length;r+=1){var a=i[r];n(a,t,`Expression`)}},Y.MemberExpression=function(e,t,n){n(e.object,t,`Expression`),e.computed&&n(e.property,t,`Expression`)},Y.ExportNamedDeclaration=Y.ExportDefaultDeclaration=function(e,t,n){if(e.declaration&&n(e.declaration,t,e.type===`ExportNamedDeclaration`||e.declaration.id?`Statement`:`Expression`),e.source&&n(e.source,t,`Expression`),e.attributes)for(var r=0,i=e.attributes;r<i.length;r+=1){var a=i[r];n(a,t)}},Y.ExportAllDeclaration=function(e,t,n){if(e.exported&&n(e.exported,t),n(e.source,t,`Expression`),e.attributes)for(var r=0,i=e.attributes;r<i.length;r+=1){var a=i[r];n(a,t)}},Y.ImportAttribute=function(e,t,n){n(e.value,t,`Expression`)},Y.ImportDeclaration=function(e,t,n){for(var r=0,i=e.specifiers;r<i.length;r+=1){var a=i[r];n(a,t)}if(n(e.source,t,`Expression`),e.attributes)for(var o=0,s=e.attributes;o<s.length;o+=1){var c=s[o];n(c,t)}},Y.ImportExpression=function(e,t,n){n(e.source,t,`Expression`),e.options&&n(e.options,t,`Expression`)},Y.ImportSpecifier=Y.ImportDefaultSpecifier=Y.ImportNamespaceSpecifier=Y.Identifier=Y.PrivateIdentifier=Y.Literal=J,Y.TaggedTemplateExpression=function(e,t,n){n(e.tag,t,`Expression`),n(e.quasi,t,`Expression`)},Y.ClassDeclaration=Y.ClassExpression=function(e,t,n){return n(e,t,`Class`)},Y.Class=function(e,t,n){e.id&&n(e.id,t,`Pattern`),e.superClass&&n(e.superClass,t,`Expression`),n(e.body,t)},Y.ClassBody=function(e,t,n){for(var r=0,i=e.body;r<i.length;r+=1){var a=i[r];n(a,t)}},Y.MethodDefinition=Y.PropertyDefinition=Y.Property=function(e,t,n){e.computed&&n(e.key,t,`Expression`),e.value&&n(e.value,t,`Expression`)};var dn=class{ast;bytecode=[];constants=[];nextRegisterId=0;declaredVars=new Set;imports=[];bindingPositions=new Map;derivedBindings=[];pendingDerived=[];constructor(e){this.ast=e}generate(){if(this.bytecode=[],this.constants=[],this.nextRegisterId=0,this.declaredVars=new Set,this.imports=[],this.bindingPositions=new Map,this.derivedBindings=[],this.pendingDerived=[],this.collectDeclaredVars(this.ast.body),this.processDerivedBindings(),this.ast.body.length===0){let e=this.allocRegister();return this.emit(o.CREATE_FRAGMENT,e),{bytecode:this.bytecode,constants:this.constants,reactiveBindings:this.buildReactiveBindings(),declaredVars:[...this.declaredVars],derived:this.derivedBindings,imports:this.imports}}if(this.ast.body.length===1&&this.ast.body[0]?.type===r.Element){let e=this.allocRegister();this.compileElement(this.ast.body[0],e)}else{let e=this.allocRegister();this.emit(o.CREATE_FRAGMENT,e);for(let t of this.ast.body)this.compileNode(t,e)}return{bytecode:this.bytecode,constants:this.constants,reactiveBindings:this.buildReactiveBindings(),declaredVars:[...this.declaredVars],derived:this.derivedBindings,imports:this.imports}}compileNode(e,t){switch(e.type){case r.Element:e.tagName===`script`?this.compileScriptElement(e):this.compileElementNode(e,t);break;case r.Text:this.compileTextNode(e,t);break;case r.Interpolation:this.compileInterpolationNode(e,t);break;case r.Comment:this.compileCommentNode(e,t);break;case r.If:this.compileIfNode(e,t);break;case r.For:this.compileForNode(e,t);break}}filterRuntimeScriptAst(e){if(Array.isArray(e)){let t=e.map(e=>this.filterScriptStatement(e)).filter(Boolean);return t.length===1?t[0]:t}return this.filterScriptStatement(e)}filterScriptStatement(e){if(!e||typeof e!=`object`)return e;if(e.type===`ImportDeclaration`)return null;if(e.type===`VariableDeclaration`){let t=e.declarations.filter(e=>!(e.init?.type===`CallExpression`&&e.init.callee?.type===`Identifier`&&e.init.callee.name===`derive`));return t.length===0?null:{...e,declarations:t}}return e}compileScriptElement(e){for(let t of e.children)if(t.type===r.Text&&typeof t.content==`object`&&t.content!==null){let e=this.filterRuntimeScriptAst(t.content);if(e!==null&&(!Array.isArray(e)||e.length>0)){let t=this.addConstant(e);this.emit(o.EXEC_SCRIPT,t)}}}isComponentTag(e){if(this.imports.some(t=>t.localName===e))return!0;let t=e.charAt(0);return t!==``&&t===t.toUpperCase()&&t!==t.toLowerCase()}compileElement(e,t){let n=this.isComponentTag(e.tagName),i=this.addConstant(e.tagName);if(n){let n={__drift_props__:!0};for(let t of e.attributes)if(t.type===r.Attribute){if(t.value===null)n[t.name]=!0;else if(typeof t.value==`string`)n[t.name]=t.value;else if(t.value.type===r.Interpolation){let e=t.value.expression;if(e&&typeof e==`object`&&e.type){let r=$(e);n[t.name]={__drift_fn__:`(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable, _get) => (${r})`}}else n[t.name]=e}}let a=null;if(e.children&&e.children.length>0){let t=e.children.filter(e=>!(e.type===r.Text&&typeof e.content==`string`&&e.content.trim()===``));t.length>0&&(a=this.compileNodesToSubModule(t),n.__drift_children__=this.addConstant(a))}let s=Object.keys(n).length>1?this.addConstant(n):255,c=this.bytecode.length;this.emit(o.MOUNT_COMPONENT,t,i,s),this.emit(o.RETURN);for(let t of e.attributes)t.type===r.Attribute&&t.value!==null&&typeof t.value!=`string`&&t.value.type===r.Interpolation&&this.recordBindingPositions(t.value.expression,c);if(a)for(let e of a.reactiveBindings)this.declaredVars.has(e.variable)&&(this.bindingPositions.has(e.variable)||this.bindingPositions.set(e.variable,[]),this.bindingPositions.get(e.variable).push(c))}else{this.emit(o.CREATE_ELEMENT,t,i);for(let n of e.attributes)this.compileAttributeNode(n,t);for(let n of e.children)this.compileNode(n,t)}}compileElementNode(e,t){let n=this.allocRegister();this.compileElement(e,n),this.emit(o.APPEND_CHILD,t,n)}compileAttributeNode(e,t){let n=this.addConstant(e.name);if(e.value===null){let e=this.addConstant(!0);this.emit(o.SET_ATTR,t,n,e,0)}else if(typeof e.value==`string`){let r=this.addConstant(e.value);this.emit(o.SET_ATTR,t,n,r,0)}else if(e.value.type===r.Interpolation){let r=this.addConstant(e.value.expression),i=this.bytecode.length;this.emit(o.SET_ATTR,t,n,r,1),this.emit(o.RETURN),this.recordBindingPositions(e.value.expression,i)}}compileTextNode(e,t){let n=this.allocRegister(),r=this.addConstant(e.content);this.emit(o.CREATE_TEXT,n,r),this.emit(o.APPEND_CHILD,t,n)}compileInterpolationNode(e,t){let n=this.allocRegister(),r=this.addConstant(e.expression),i=this.bytecode.length;this.emit(o.INTERPOLATE_TEXT,n,r),this.emit(o.RETURN),this.emit(o.APPEND_CHILD,t,n),this.recordBindingPositions(e.expression,i)}compileCommentNode(e,t){let n=this.allocRegister(),r=this.addConstant(e.content);this.emit(o.CREATE_COMMENT,n,r),this.emit(o.APPEND_CHILD,t,n)}compileNodesToSubModule(e){let t=this.bytecode,n=this.constants,r=this.nextRegisterId,i=this.bindingPositions;this.bytecode=[],this.constants=[],this.nextRegisterId=0,this.bindingPositions=new Map;let a=this.allocRegister();this.emit(o.CREATE_FRAGMENT,a);for(let t of e)this.compileNode(t,a);let s={bytecode:this.bytecode,constants:this.constants,reactiveBindings:this.buildReactiveBindings()};return this.bytecode=t,this.constants=n,this.nextRegisterId=r,this.bindingPositions=i,s}collectDepsFromSubModule(e,t){let n=new Set;for(let t=0;t<e.reactiveBindings.length;t++)n.add(e.reactiveBindings[t].variable);if(t)for(let e of this.extractIdentifiers(t))this.declaredVars.has(e)&&n.add(e);return[...n]}compileIfNode(e,t){let n=this.compileNodesToSubModule(e.consequent),r=this.addConstant(n),i=255,a=null;if(e.alternate!==null){let t;t=Array.isArray(e.alternate)?e.alternate:[e.alternate],a=this.compileNodesToSubModule(t),i=this.addConstant(a)}let s=new Set(this.collectDepsFromSubModule(n,e.test));if(e.extraDeps){for(let t of this.extractIdentifiers(e.extraDeps))this.declaredVars.has(t)&&s.add(t);let t=Array.from(s);n.constants&&!n.constants.some(e=>Array.isArray(e))&&n.constants.push(t)}if(a)for(let e of this.collectDepsFromSubModule(a))s.add(e);let c=this.addConstant(Array.from(s)),l=this.addConstant(e.test);this.emit(o.REACTIVE_IF,t,l,r,i,c)}compileForNode(e,t){let n=this.compileNodesToSubModule(e.body),r=this.addConstant(n),i=this.addConstant(e.iterable),a=this.addConstant(e.item),s=e.index===null?255:this.addConstant(e.index),c=e.key?this.addConstant(e.key):255,l=this.collectDepsFromSubModule(n,e.iterable),u=this.addConstant(l);this.emit(o.REACTIVE_FOR,t,i,a,s,c,r,u)}collectDeclaredVars(e){for(let t of e)if(t.type===r.Element&&t.tagName===`script`){for(let e of t.children)if(e.type===r.Text&&typeof e.content==`object`&&e.content!==null){let t=e.content;if(Array.isArray(t))for(let e of t)this.extractVarNames(e);else this.extractVarNames(t)}}}extractVarNames(e){if(!(!e||typeof e!=`object`)){if(e.type===`VariableDeclaration`)for(let t of e.declarations){for(let e of X(t.id))this.declaredVars.add(e);t.id?.type===`Identifier`&&t.init?.type===`CallExpression`&&t.init.callee?.type===`Identifier`&&t.init.callee.name===`derive`&&t.init.arguments&&t.init.arguments.length>0&&this.pendingDerived.push({name:t.id.name,arg:t.init.arguments[0]})}else if((e.type===`FunctionDeclaration`||e.type===`ClassDeclaration`)&&e.id?.type===`Identifier`)this.declaredVars.add(e.id.name);else if(e.type===`ImportDeclaration`&&Array.isArray(e.specifiers)){let t=typeof e.source?.value==`string`?e.source.value:``;if(e.specifiers.length===0)this.imports.push({localName:``,source:t,isDefault:!1,isSideEffect:!0});else for(let n of e.specifiers)if(n.local?.type===`Identifier`){let e=n.local.name;this.declaredVars.add(e);let r=n.type===`ImportDefaultSpecifier`,i=n.type===`ImportNamespaceSpecifier`,a=n.type===`ImportSpecifier`&&n.imported?.type===`Identifier`?n.imported.name:void 0;this.imports.push({localName:e,source:t,isDefault:r,isNamespace:i,importedName:a})}}}}processDerivedBindings(){for(let e of this.pendingDerived){let{name:t,arg:n}=e,r=n,i=!1;(n.type===`ArrowFunctionExpression`||n.type===`FunctionExpression`)&&(n.body?.type===`BlockStatement`&&(i=!0),r=n.body);let a=[...this.extractIdentifiers(r)].filter(e=>e!==t&&this.declaredVars.has(e)),o=$(r),s;s=i?{__drift_fn__:`(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable, _get) => ${o}`}:{__drift_fn__:`(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable, _get) => (${o})`};let c=this.addConstant(s);this.derivedBindings.push({name:t,deps:a,exprIdx:c})}}extractIdentifiers(e){let t=new Set;if(!e||typeof e!=`object`)return t;try{cn(e,{Identifier(e,n){let r=n[n.length-2];r&&(r.type===`MemberExpression`&&r.property===e&&!r.computed||(r.type===`Property`||r.type===`MethodDefinition`||r.type===`PropertyDefinition`)&&r.key===e&&!r.computed)||t.add(e.name)}})}catch{}return t}recordBindingPositions(e,t){if(this.declaredVars.size===0)return;let n=this.extractIdentifiers(e);for(let e of n)this.declaredVars.has(e)&&(this.bindingPositions.has(e)||this.bindingPositions.set(e,[]),this.bindingPositions.get(e).push(t))}buildReactiveBindings(){let e=[];for(let[t,n]of this.bindingPositions)e.push({variable:t,positions:n});return e}allocRegister(){return this.nextRegisterId++}addConstant(e){e&&typeof e==`object`&&e.type&&typeof e.type==`string`?e={__drift_fn__:`(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable, _get) => (${$(e)})`}:Array.isArray(e)&&e.length>0&&typeof e[0]==`object`&&e[0]?.type&&(e={__drift_fn__:`(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable, _get) => { ${$(e)}; }`});let t=this.constants.findIndex(t=>this.isConstantEqual(t,e));return t===-1?(this.constants.push(e),this.constants.length-1):t}isConstantEqual(e,t){return e===t||typeof e==`object`&&typeof t==`object`&&e!==null&&t!==null&&JSON.stringify(e)===JSON.stringify(t)}emit(e,...t){this.bytecode.push(e,...t)}};function fn(e){return!e||typeof e!=`object`?null:e.type===`Identifier`?e.name:e.type===`MemberExpression`?fn(e.object):null}function X(e){let t=[];function n(e){if(!(!e||typeof e!=`object`))if(e.type===`Identifier`)t.push(e.name);else if(e.type===`ObjectPattern`&&Array.isArray(e.properties))for(let t of e.properties)t.type===`Property`?n(t.value):t.type===`RestElement`&&n(t.argument);else if(e.type===`ArrayPattern`&&Array.isArray(e.elements))for(let t of e.elements)t&&n(t);else e.type===`AssignmentPattern`?n(e.left):e.type===`RestElement`&&n(e.argument)}return n(e),t}function Z(e,t){if(!e)return``;switch(e.type){case`Identifier`:return e.name;case`AssignmentPattern`:return`${Z(e.left,t)} = ${$(e.right,t)}`;case`RestElement`:return`...${Z(e.argument,t)}`;case`ArrayPattern`:return`[${(e.elements||[]).map(e=>e?Z(e,t):``).join(`, `)}]`;case`ObjectPattern`:return`{ ${(e.properties||[]).map(e=>{if(e.type===`Property`){let n=e.key?.name||(typeof e.key?.value==`string`?JSON.stringify(e.key.value):e.key?.value?String(e.key.value):$(e.key,t));if(e.value?.type===`AssignmentPattern`){let r=e.value.left?.name||Z(e.value.left,t),i=$(e.value.right,t);return n===r||e.shorthand?`${n} = ${i}`:`${n}: ${r} = ${i}`}else if(e.value?.type===`Identifier`&&e.value.name===n)return n;else return`${n}: ${Z(e.value,t)}`}else if(e.type===`RestElement`)return`...${Z(e.argument,t)}`;return``}).filter(Boolean).join(`, `)} }`;default:return e.name||$(e,t)}}function Q(e,t,n){return n&&n.has(e)?`(${e} = ${t})`:`(typeof setScopeValue === 'function' && scope ? setScopeValue(scope, ${JSON.stringify(e)}, ${t}) : ((scope || {})[${JSON.stringify(e)}] = ${t}))`}function pn(e,t,n,r={count:0}){let i=[];if(!e)return i;if(e.type===`Identifier`)return i.push(Q(e.name,t,n)),i;if(e.type===`AssignmentPattern`){let a=`((${t} !== undefined) ? ${t} : ${$(e.right,n)})`;if(e.left?.type===`Identifier`)i.push(Q(e.left.name,a,n));else{let t=`_t${r.count++}`;i.push(`const ${t} = ${a}`),i.push(...pn(e.left,t,n,r))}return i}if(e.type===`ObjectPattern`){for(let a of e.properties||[])if(a.type===`Property`){let e=a.computed?$(a.key,n):a.key?.name===void 0?typeof a.key?.value==`string`||typeof a.key?.value==`number`?JSON.stringify(a.key.value):$(a.key,n):JSON.stringify(a.key.name);if(a.value?.type===`Identifier`){let r=`(${t} ? ${t}[${e}] : undefined)`;i.push(Q(a.value.name,r,n))}else if(a.value?.type===`AssignmentPattern`){let o=`((${t} && ${t}[${e}] !== undefined) ? ${t}[${e}] : ${$(a.value.right,n)})`;if(a.value.left?.type===`Identifier`)i.push(Q(a.value.left.name,o,n));else{let e=`_t${r.count++}`;i.push(`const ${e} = ${o}`),i.push(...pn(a.value.left,e,n,r))}}else if(a.value?.type===`ObjectPattern`||a.value?.type===`ArrayPattern`){let o=`_t${r.count++}`,s=`(${t} ? ${t}[${e}] : undefined)`;i.push(`const ${o} = ${s}`),i.push(...pn(a.value,o,n,r))}else{let r=a.value?.name||$(a.value,n);if(r){let a=`(${t} ? ${t}[${e}] : undefined)`;i.push(Q(r,a,n))}}}else if(a.type===`RestElement`){let r=a.argument?.name||$(a.argument,n);if(r){let a=(e.properties||[]).filter(e=>e.type===`Property`).map(e=>e.key?.name||(typeof e.key?.value==`string`?e.key.value:``)).filter(Boolean),o=`(() => { const _r = Object.assign({}, ${t}); ${JSON.stringify(a)}.forEach(k => delete _r[k]); return _r; })()`;i.push(Q(r,o,n))}}return i}if(e.type===`ArrayPattern`){let a=`_a${r.count++}`;i.push(`const ${a} = (typeof resolveIterable === 'function' ? resolveIterable(${t}) : (${t} || []))`);let o=e.elements||[];for(let e=0;e<o.length;e++){let t=o[e];if(t){if(t.type===`Identifier`){let r=`(${a} ? ${a}[${e}] : undefined)`;i.push(Q(t.name,r,n))}else if(t.type===`AssignmentPattern`){let o=$(t.right,n),s=`((${a} && ${a}[${e}] !== undefined) ? ${a}[${e}] : ${o})`;if(t.left?.type===`Identifier`)i.push(Q(t.left.name,s,n));else{let e=`_t${r.count++}`;i.push(`const ${e} = ${s}`),i.push(...pn(t.left,e,n,r))}}else if(t.type===`RestElement`){let r=t.argument?.name||$(t.argument,n);if(r){let t=`((${a} && typeof ${a}.slice === 'function') ? ${a}.slice(${e}) : [])`;i.push(Q(r,t,n))}}else if(t.type===`ObjectPattern`||t.type===`ArrayPattern`){let o=`_t${r.count++}`,s=`(${a} ? ${a}[${e}] : undefined)`;i.push(`const ${o} = ${s}`),i.push(...pn(t,o,n,r))}}}return i}return i}function $(e,t){if(e==null)return`undefined`;if(typeof e!=`object`)return typeof e==`string`?JSON.stringify(e):String(e);if(Array.isArray(e))return e.map(e=>$(e,t)).join(`; `);switch(e.type){case`Identifier`:return t&&t.has(e.name)?e.name:`(typeof _get === 'function' ? _get(scope, ${JSON.stringify(e.name)}) : (typeof inScopeChain === 'function' && inScopeChain(scope, ${JSON.stringify(e.name)}) ? scope[${JSON.stringify(e.name)}] : (typeof globalThis !== 'undefined' && globalThis && (${JSON.stringify(e.name)} in globalThis) ? globalThis[${JSON.stringify(e.name)}] : (scope || {})[${JSON.stringify(e.name)}])))`;case`Literal`:return typeof e.raw==`string`?e.raw:typeof e.value==`string`?JSON.stringify(e.value):String(e.value);case`BinaryExpression`:case`LogicalExpression`:return`(${$(e.left,t)} ${e.operator} ${$(e.right,t)})`;case`UnaryExpression`:return`(${e.operator} ${$(e.argument,t)})`;case`AwaitExpression`:return`(await ${$(e.argument,t)})`;case`YieldExpression`:return e.delegate?`(yield* ${e.argument?$(e.argument,t):``})`:`(yield ${e.argument?$(e.argument,t):``})`;case`ConditionalExpression`:return`(${$(e.test,t)} ? ${$(e.consequent,t)} : ${$(e.alternate,t)})`;case`MemberExpression`:{let n=e.optional?`?.`:`.`;return e.computed?e.optional?`(${$(e.object,t)}?.[${$(e.property,t)}])`:`(${$(e.object,t)}[${$(e.property,t)}])`:`(${$(e.object,t)}${n}${e.property.name})`}case`CallExpression`:{let n=$(e.callee,t),r=e.arguments?e.arguments.map(e=>$(e,t)).join(`, `):``,i=`(${n}${e.optional?`?.(`:`(`}${r}))`;if(e.callee?.type===`MemberExpression`&&e.callee.property?.type===`Identifier`){let n=fn(e.callee.object),r=e.callee.property.name;if(n&&[`push`,`pop`,`shift`,`unshift`,`splice`,`sort`,`reverse`].includes(r)&&(!t||!t.has(n)))return`(() => { const _res = ${i}; if (typeof setScopeValue === 'function' && scope && typeof inScopeChain === 'function' && inScopeChain(scope, ${JSON.stringify(n)})) setScopeValue(scope, ${JSON.stringify(n)}, scope[${JSON.stringify(n)}]); return _res; })()`}return i}case`AssignmentExpression`:{let n=$(e.right,t);if(e.left?.type===`Identifier`){let r=e.left.name;if(t&&t.has(r))return`(${r} ${e.operator} ${n})`;if(e.operator===`=`)return`(typeof setScopeValue === 'function' ? setScopeValue(scope, ${JSON.stringify(r)}, ${n}) : ((scope || {})[${JSON.stringify(r)}] = ${n}))`;{let t=e.operator.slice(0,-1);return`(typeof setScopeValue === 'function' ? setScopeValue(scope, ${JSON.stringify(r)}, (scope[${JSON.stringify(r)}] ${t} ${n})) : ((scope || {})[${JSON.stringify(r)}] ${e.operator} ${n}))`}}if(e.left?.type===`MemberExpression`){let r=fn(e.left),i=`(${$(e.left,t)} ${e.operator} ${n})`;if(r&&(!t||!t.has(r)))return`(() => { const _res = ${i}; if (typeof setScopeValue === 'function' && scope && typeof inScopeChain === 'function' && inScopeChain(scope, ${JSON.stringify(r)})) setScopeValue(scope, ${JSON.stringify(r)}, scope[${JSON.stringify(r)}]); return _res; })()`}return e.left?.type===`ObjectPattern`||e.left?.type===`ArrayPattern`?`((_val) => { ${pn(e.left,`_val`,t).join(`; `)}; return _val; })(${n})`:`(${$(e.left,t)} ${e.operator} ${n})`}case`UpdateExpression`:if(e.argument?.type===`Identifier`){let n=e.argument.name;if(t&&t.has(n))return e.prefix?`(${e.operator}${n})`:`(${n}${e.operator})`;let r=e.operator===`++`?`+`:`-`;return e.prefix?`(typeof setScopeValue === 'function' ? (setScopeValue(scope, ${JSON.stringify(n)}, (Number(scope[${JSON.stringify(n)}]) || 0) ${r} 1), scope[${JSON.stringify(n)}]) : ((scope || {})[${JSON.stringify(n)}] = (Number((scope || {})[${JSON.stringify(n)}]) || 0) ${r} 1))`:`(() => { const _v = Number(scope[${JSON.stringify(n)}]) || 0; if (typeof setScopeValue === 'function') setScopeValue(scope, ${JSON.stringify(n)}, _v ${r} 1); else (scope || {})[${JSON.stringify(n)}] = _v ${r} 1; return _v; })()`}if(e.argument?.type===`MemberExpression`){let n=fn(e.argument),r=e.prefix?`(${e.operator}${$(e.argument,t)})`:`(${$(e.argument,t)}${e.operator})`;if(n&&(!t||!t.has(n)))return`(() => { const _res = ${r}; if (typeof setScopeValue === 'function' && scope && typeof inScopeChain === 'function' && inScopeChain(scope, ${JSON.stringify(n)})) setScopeValue(scope, ${JSON.stringify(n)}, scope[${JSON.stringify(n)}]); return _res; })()`}return e.prefix?`(${e.operator}${$(e.argument,t)})`:`(${$(e.argument,t)}${e.operator})`;case`SequenceExpression`:return`(${e.expressions?e.expressions.map(e=>$(e,t)).join(`, `):``})`;case`ArrayExpression`:return`[${e.elements?e.elements.map(e=>e?.type===`SpreadElement`?`...`+$(e.argument,t):$(e,t)).join(`, `):``}]`;case`ObjectExpression`:return`{${e.properties?e.properties.map(e=>{if(e.type===`SpreadElement`)return`...`+$(e.argument,t);let n=e.computed?`[${$(e.key,t)}]`:e.key?.name||(typeof e.key?.value==`string`?JSON.stringify(e.key.value):String(e.key?.value??``));if(e.kind===`get`||e.kind===`set`){let r=e.value,i=new Set(t),a=[];if(r.params)for(let e of r.params){for(let t of X(e))i.add(t);a.push(Z(e,i))}let o=r.body?.type===`BlockStatement`?`{ ${r.body.body.map(e=>$(e,i)).filter(Boolean).join(`; `)}; }`:`{ ${$(r.body,i)}; }`;return`${e.kind} ${n}(${a.join(`, `)}) ${o}`}if(e.method){let r=e.value,i=new Set(t),a=[];if(r.params)for(let e of r.params){for(let t of X(e))i.add(t);a.push(Z(e,i))}let o=r.async?`async `:``,s=r.generator?`*`:``,c=r.body?.type===`BlockStatement`?`{ ${r.body.body.map(e=>$(e,i)).filter(Boolean).join(`; `)}; }`:`{ ${$(r.body,i)}; }`;return`${o}${s}${n}(${a.join(`, `)}) ${c}`}return`${n}: ${$(e.value,t)}`}).join(`, `):``}}`;case`RestElement`:case`SpreadElement`:return`...${$(e.argument,t)}`;case`AssignmentPattern`:return`${$(e.left,t)} = ${$(e.right,t)}`;case`TemplateLiteral`:return`\`${e.quasis?e.quasis.map((n,r)=>(n.value?.raw??``)+(e.expressions&&e.expressions[r]?"${"+$(e.expressions[r],t)+`}`:``)).join(``):``}\``;case`TaggedTemplateExpression`:return`${$(e.tag,t)}${$(e.quasi,t)}`;case`ThisExpression`:return`this`;case`Super`:return`super`;case`BlockStatement`:{let n=new Set(t);if(Array.isArray(e.body))for(let t of e.body)if(t.type===`VariableDeclaration`&&Array.isArray(t.declarations))for(let e of t.declarations)for(let t of X(e.id))n.add(t);else t.type===`FunctionDeclaration`&&t.id?.name&&n.add(t.id.name);return`{ ${(e.body?e.body.map(e=>$(e,n)).filter(Boolean):[]).join(`; `)}; }`}case`ExpressionStatement`:return $(e.expression,t);case`ReturnStatement`:return`return ${e.argument?$(e.argument,t):``}`;case`ThrowStatement`:return`throw ${e.argument?$(e.argument,t):``}`;case`BreakStatement`:return e.label?`break ${e.label.name}`:`break`;case`ContinueStatement`:return e.label?`continue ${e.label.name}`:`continue`;case`LabeledStatement`:return`${e.label.name}: ${$(e.body,t)}`;case`TryStatement`:return`try ${$(e.block,t)} ${e.handler?$(e.handler,t):``} ${e.finalizer?`finally ${$(e.finalizer,t)}`:``}`.trim();case`CatchClause`:{let n=new Set(t),r=``;if(e.param){for(let t of X(e.param))n.add(t);r=Z(e.param,n)}let i=$(e.body,n);return r?`catch (${r}) ${i}`:`catch ${i}`}case`SwitchStatement`:return`switch (${$(e.discriminant,t)}) { ${e.cases?e.cases.map(e=>$(e,t)).join(` `):``} }`;case`SwitchCase`:{let n=e.test?`case ${$(e.test,t)}:`:`default:`,r=e.consequent?e.consequent.map(e=>$(e,t)).filter(Boolean).join(`; `):``;return`${n} ${r?r+`;`:``}`}case`IfStatement`:return`if (${$(e.test,t)}) ${e.consequent.type===`BlockStatement`?$(e.consequent,t):`{ ${$(e.consequent,t)}; }`}${e.alternate?` else ${e.alternate.type===`BlockStatement`||e.alternate.type===`IfStatement`?$(e.alternate,t):`{ ${$(e.alternate,t)}; }`}`:``}`;case`ForStatement`:{let n=new Set(t);if(e.init?.type===`VariableDeclaration`&&e.init.declarations)for(let t of e.init.declarations)for(let e of X(t.id))n.add(e);let r=``;e.init?.type===`VariableDeclaration`&&e.init.declarations?r=(e.init.kind||`let`)+` `+e.init.declarations.map(e=>`${e.id?.type===`Identifier`?e.id.name:$(e.id,n)}${e.init?` = ${$(e.init,n)}`:``}`).join(`, `):e.init&&(r=$(e.init,n));let i=e.test?$(e.test,n):``,a=e.update?$(e.update,n):``,o=e.body?.type===`BlockStatement`?$(e.body,n):`{ ${e.body?$(e.body,n):``}; }`;return`for (${r}; ${i}; ${a}) ${o}`}case`ForOfStatement`:{let n=new Set(t),r=``;if(e.left?.type===`VariableDeclaration`){let t=e.left.kind||`let`,i=e.left.declarations?.[0];if(i){for(let e of X(i.id))n.add(e);r=`${t} ${i.id?.type===`Identifier`?i.id.name:$(i.id,n)}`}}else e.left?.type===`Identifier`?(n.add(e.left.name),r=e.left.name):e.left&&(r=$(e.left,n));let i=`(typeof resolveIterable === 'function' ? resolveIterable : (x) => x || [])(${$(e.right,t)})`,a=e.body?.type===`BlockStatement`?$(e.body,n):`{ ${e.body?$(e.body,n):``}; }`;return`for ${e.await?`await `:``}(${r} of ${i}) ${a}`}case`ForInStatement`:{let n=new Set(t),r=``;if(e.left?.type===`VariableDeclaration`){let t=e.left.kind||`let`,i=e.left.declarations?.[0];if(i){for(let e of X(i.id))n.add(e);r=`${t} ${i.id?.type===`Identifier`?i.id.name:$(i.id,n)}`}}else e.left?.type===`Identifier`?(n.add(e.left.name),r=e.left.name):e.left&&(r=$(e.left,n));let i=$(e.right,t),a=e.body?.type===`BlockStatement`?$(e.body,n):`{ ${e.body?$(e.body,n):``}; }`;return`for (${r} in ${i}) ${a}`}case`WhileStatement`:return`while (${$(e.test,t)}) ${e.body?.type===`BlockStatement`?$(e.body,t):`{ ${e.body?$(e.body,t):``}; }`}`;case`DoWhileStatement`:{let n=$(e.test,t);return`do ${e.body?.type===`BlockStatement`?$(e.body,t):`{ ${e.body?$(e.body,t):``}; }`} while (${n})`}case`ArrayPattern`:return`[ ${e.elements?e.elements.map(e=>e?e.type===`RestElement`?`...`+$(e.argument,t):e.type===`AssignmentPattern`?`${$(e.left,t)} = ${$(e.right,t)}`:e.name||$(e,t):``).join(`, `):``} ]`;case`ObjectPattern`:return`{ ${e.properties?e.properties.map(e=>{if(e.type===`Property`){let n=e.key?.name||$(e.key,t),r=e.value?.name||$(e.value,t);return n===r?n:`${n}: ${r}`}return e.type===`RestElement`?`...${$(e.argument,t)}`:``}).filter(Boolean).join(`, `):``} }`;case`VariableDeclaration`:{if(t){let n=[];if(e.declarations)for(let r of e.declarations){let e=r.id?.type===`Identifier`?r.id.name:$(r.id,t),i=r.init?$(r.init,t):void 0;i===void 0?n.push(`${e}`):n.push(`${e} = ${i}`)}return`${e.kind||`let`} ${n.join(`, `)}`}let n=[];if(e.declarations)for(let r of e.declarations)if(r.id?.type===`ObjectPattern`||r.id?.type===`ArrayPattern`){let e=r.init?$(r.init,t):`undefined`,i=pn(r.id,`_init`,t);n.push(`((_init) => { ${i.join(`; `)}; return _init; })(${e})`)}else{let e=r.id?.name||$(r.id,t),i=r.init?$(r.init,t):`undefined`;n.push(`((scope || {})[${JSON.stringify(e)}] = ${i})`)}return`(${n.filter(Boolean).join(`, `)||`undefined`})`}case`FunctionDeclaration`:{let n=e.id?.name,r=new Set(t);n&&r.add(n);let i=[];if(e.params)for(let t of e.params){for(let e of X(t))r.add(e);i.push(Z(t,r))}if(e.body?.type===`BlockStatement`&&Array.isArray(e.body.body))for(let t of e.body.body)if(t.type===`VariableDeclaration`&&Array.isArray(t.declarations))for(let e of t.declarations)for(let t of X(e.id))r.add(t);else t.type===`FunctionDeclaration`&&t.id?.name&&r.add(t.id.name);let a=i.join(`, `),o=e.body?.type===`BlockStatement`?`{ ${e.body.body.map(e=>$(e,r)).filter(Boolean).join(`; `)}; }`:`{ ${$(e.body,r)}; }`,s=`${e.async?`async `:``}function${e.generator?`*`:``} ${n||``}(${a}) ${o}`;return n?`((scope || {})[${JSON.stringify(n)}] = ${s})`:s}case`ArrowFunctionExpression`:case`FunctionExpression`:{let n=new Set(t);e.id?.name&&n.add(e.id.name);let r=[];if(e.params)for(let t of e.params){for(let e of X(t))n.add(e);r.push(Z(t,n))}if(e.body?.type===`BlockStatement`&&Array.isArray(e.body.body))for(let t of e.body.body)if(t.type===`VariableDeclaration`&&Array.isArray(t.declarations))for(let e of t.declarations)for(let t of X(e.id))n.add(t);else t.type===`FunctionDeclaration`&&t.id?.name&&n.add(t.id.name);let i=r.join(`, `),a=e.async?`async `:``;if(e.type===`ArrowFunctionExpression`)return e.body?.type===`BlockStatement`?`(${a}(${i}) => ${`{ ${e.body.body.map(e=>$(e,n)).filter(Boolean).join(`; `)}; }`})`:`(${a}(${i}) => ${$(e.body,n)})`;{let t=e.generator?`*`:``,r=e.body?.type===`BlockStatement`?`{ ${e.body.body.map(e=>$(e,n)).filter(Boolean).join(`; `)}; }`:`{ ${$(e.body,n)}; }`;return`(${a}function${t} ${e.id?.name||``}(${i}) ${r})`}}case`ClassDeclaration`:case`ClassExpression`:{let n=e.id?.name,r=new Set(t);n&&r.add(n);let i=e.superClass?` extends ${$(e.superClass,t)}`:``,a=$(e.body,r),o=`class ${n||``}${i} ${a}`;return e.type===`ClassDeclaration`&&n?`((scope || {})[${JSON.stringify(n)}] = ${o})`:`(${o})`}case`ClassBody`:return`{ ${(e.body?e.body.map(e=>$(e,t)).filter(Boolean):[]).join(`; `)} }`;case`MethodDefinition`:{let n=e.static?`static `:``,r=e.kind===`get`||e.kind===`set`?`${e.kind} `:``,i=e.value?.async?`async `:``,a=e.value?.generator?`*`:``,o=e.computed?`[${$(e.key,t)}]`:e.key?.name||$(e.key,t),s=new Set(t),c=[];if(e.value?.params)for(let t of e.value.params){for(let e of X(t))s.add(e);c.push(Z(t,s))}if(e.value?.body?.type===`BlockStatement`&&Array.isArray(e.value.body.body))for(let t of e.value.body.body)if(t.type===`VariableDeclaration`&&Array.isArray(t.declarations))for(let e of t.declarations)for(let t of X(e.id))s.add(t);else t.type===`FunctionDeclaration`&&t.id?.name&&s.add(t.id.name);return`${n}${i}${a}${r}${o}(${c.join(`, `)}) ${e.value?.body?$(e.value.body,s):`{}`}`}case`PropertyDefinition`:return`${e.static?`static `:``}${e.computed?`[${$(e.key,t)}]`:e.key?.name||$(e.key,t)}${e.value?` = ${$(e.value,t)}`:``}`;case`NewExpression`:return`new (${$(e.callee,t)})(${e.arguments?e.arguments.map(e=>$(e,t)).join(`, `):``})`;case`EmptyStatement`:case`ImportDeclaration`:case`ImportSpecifier`:case`ImportDefaultSpecifier`:case`ImportNamespaceSpecifier`:return``;case`ParenthesizedExpression`:case`ChainExpression`:return $(e.expression,t);default:return``}}function mn(e,t=!1){let n=new sn(new ne(new _(e)).parse()).transform(),r=new dn(n).generate();return t&&(console.log(`--- Transformed AST ---`),console.log(JSON.stringify(n,null,2)),console.log(`--- Compiled Module ---`),console.log(JSON.stringify(r,null,2))),r}exports.ASTNodeType=r,exports.DriftGenerator=dn,exports.DriftLexer=_,exports.DriftLexerError=i,exports.DriftParser=ne,exports.DriftParserError=a,exports.DriftTransformer=sn,exports.ExprTokenKind=n,exports.LexerStateKind=t,exports.Opcode=o,exports.TokenType=e,exports.astToJS=$,exports.compile=mn,exports.extractBindingNames=X,exports.traverseTemplateAST=on;
|
|
7
|
+
`}},C=class{tokens;current=0;constructor(e){this.tokens=e}nextToken(){if(this.current>=this.tokens.length)return this.tokens[this.tokens.length-1];let e=this.tokens[this.current];return this.current++,e}},w={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`,nbsp:`\xA0`,copy:`©`,reg:`®`,trade:`™`,mdash:`—`,ndash:`–`,hellip:`…`,laquo:`«`,raquo:`»`,ldquo:`“`,rdquo:`”`,lsquo:`‘`,rsquo:`’`,sbquo:`‚`,bdquo:`„`,bull:`•`,times:`×`,divide:`÷`,plusmn:`±`,euro:`€`,pound:`£`,yen:`¥`,cent:`¢`,deg:`°`,para:`¶`,sect:`§`,micro:`µ`,middot:`·`,frac14:`¼`,frac12:`½`,frac34:`¾`,sup1:`¹`,sup2:`²`,sup3:`³`,dagger:`†`,Dagger:`‡`,permil:`‰`,prime:`′`,Prime:`″`,infin:`∞`,radic:`√`,sim:`∼`,asymp:`≈`,ne:`≠`,equiv:`≡`,le:`≤`,ge:`≥`,sub:`⊂`,sup:`⊃`,nsub:`⊄`,sube:`⊆`,supe:`⊇`,oplus:`⊕`,otimes:`⊗`,perp:`⊥`,sdot:`⋅`,sum:`∑`,prod:`∏`,minus:`−`,lowast:`∗`,forall:`∀`,part:`∂`,exist:`∃`,empty:`∅`,nabla:`∇`,isin:`∈`,notin:`∉`,ni:`∋`,and:`∧`,or:`∨`,cap:`∩`,cup:`∪`,int:`∫`,there4:`∴`,cong:`≅`,ang:`∠`,loz:`◊`,spades:`♠`,clubs:`♣`,hearts:`♥`,diams:`♦`,larr:`←`,uarr:`↑`,rarr:`→`,darr:`↓`,harr:`↔`,crarr:`↵`,Alpha:`Α`,Beta:`Β`,Gamma:`Γ`,Delta:`Δ`,Epsilon:`Ε`,Zeta:`Ζ`,Eta:`Η`,Theta:`Θ`,Iota:`Ι`,Kappa:`Κ`,Lambda:`Λ`,Mu:`Μ`,Nu:`Ν`,Xi:`Ξ`,Omicron:`Ο`,Pi:`Π`,Rho:`Ρ`,Sigma:`Σ`,Tau:`Τ`,Upsilon:`Υ`,Phi:`Φ`,Chi:`Χ`,Psi:`Ψ`,Omega:`Ω`,alpha:`α`,beta:`β`,gamma:`γ`,delta:`δ`,epsilon:`ε`,zeta:`ζ`,eta:`η`,theta:`θ`,iota:`ι`,kappa:`κ`,lambda:`λ`,mu:`μ`,nu:`ν`,xi:`ξ`,omicron:`ο`,pi:`π`,rho:`ρ`,sigmaf:`ς`,sigma:`σ`,tau:`τ`,upsilon:`υ`,phi:`φ`,chi:`χ`,psi:`ψ`,omega:`ω`};function T(e){return!e||!e.includes(`&`)?e:e.replace(/&(?:#(\d+)|#x([0-9a-fA-F]+)|([a-zA-Z0-9]+));/g,(e,t,n,r)=>{if(t){let e=parseInt(t,10);try{return!isNaN(e)&&e>=0&&e<=1114111&&(e<55296||e>57343)?String.fromCodePoint?String.fromCodePoint(e):String.fromCharCode(e):`�`}catch{return`�`}}if(n){let e=parseInt(n,16);try{return!isNaN(e)&&e>=0&&e<=1114111&&(e<55296||e>57343)?String.fromCodePoint?String.fromCodePoint(e):String.fromCharCode(e):`�`}catch{return`�`}}return r&&w[r]||e})}var E=class{tokenSource;lookahead=[];constructor(e){this.tokenSource=Array.isArray(e)?new C(e):e}parse(){return this.lookahead.length=0,this.parseProgram()}parseProgram(){let e=this.peek().loc.start,t=[];for(;!this.isAtEnd();)t.push(this.parseChild());let n=this.peek().loc.end;return{type:m.Program,body:t,loc:{start:e,end:n}}}parseChild(){let e=this.peek();if(e.type===d.Comment)return this.advance(),{type:m.Comment,content:e.value,loc:e.loc};if(e.type===d.Interpolation)return this.advance(),{type:m.Interpolation,expression:e.value,loc:e.loc};if(e.type===d.TagOpen)return this.parseElement();if(e.type===d.DirectiveIf)return this.parseIfDirective();if(e.type===d.DirectiveFor)return this.parseForDirective();if(e.type===d.DirectiveSwitch)return this.parseSwitchDirective();if(e.type===d.Text)return this.advance(),{type:m.Text,content:T(e.value),loc:e.loc};throw e.type===d.TagOpenSlash?new g(`Unexpected closing tag '</${this.peek(1).value}>' without opening tag`,e.loc.start.line,e.loc.start.column,e.loc.start.offset):new g(`Unexpected token '${e.value}' of type '${e.type}'`,e.loc.start.line,e.loc.start.column,e.loc.start.offset)}parseElement(){let e=this.consume(d.TagOpen,`Expected opening tag bracket`).loc.start,t=this.consume(d.Identifier,`Expected tag name after opening bracket`).value,n=[];for(;!this.check(d.TagClose)&&!this.check(d.TagSelfClose)&&!this.isAtEnd();)n.push(this.parseAttribute());if(this.check(d.TagSelfClose)){let r=this.advance();return{type:m.Element,tagName:t,attributes:n,children:[],isSelfClosing:!0,loc:{start:e,end:r.loc.end}}}let r=this.consume(d.TagClose,`Expected closing bracket after attributes`);if(c.VOID_ELEMENTS.has(t.toLowerCase()))return{type:m.Element,tagName:t,attributes:n,children:[],isSelfClosing:!0,loc:{start:e,end:r.loc.end}};let i=t.toLowerCase()===`script`||t.toLowerCase()===`style`,a=[];for(;!this.check(d.TagOpenSlash)&&!this.isAtEnd();)if(i&&this.check(d.Text)){let e=this.advance();a.push({type:m.Text,content:e.value,loc:e.loc})}else a.push(this.parseChild());if(this.isAtEnd())throw new g(`Unclosed element '<${t}>', expected closing tag '</${t}>'`,e.line,e.column,e.offset);this.consume(d.TagOpenSlash,`Expected closing tag '</${t}>'`);let o=this.consume(d.Identifier,`Expected closing tag name`);if(o.value!==t&&o.value.toLowerCase()!==t.toLowerCase())throw new g(`Mismatched closing tag. Expected '</${t}>' but got '</${o.value}>'`,o.loc.start.line,o.loc.start.column,o.loc.start.offset);let s=this.consume(d.TagClose,`Expected '>' after closing tag name`);return{type:m.Element,tagName:t,attributes:n,children:a,isSelfClosing:!1,loc:{start:e,end:s.loc.end}}}parseAttribute(){let e=this.consume(d.Identifier,`Expected attribute name`),t=e.loc.start,n=e.value;if(this.matchToken(d.Equals)){let e=this.peek();if(e.type===d.StringLiteral)return this.advance(),{type:m.Attribute,name:n,value:T(e.value),loc:{start:t,end:e.loc.end}};if(e.type===d.Interpolation){this.advance();let r={type:m.Interpolation,expression:e.value,loc:e.loc};return{type:m.Attribute,name:n,value:r,loc:{start:t,end:e.loc.end}}}throw new g(`Expected string literal or interpolation after '=' for attribute '${n}'`,e.loc.start.line,e.loc.start.column,e.loc.start.offset)}return{type:m.Attribute,name:n,value:null,loc:{start:t,end:e.loc.end}}}parseIfDirective(){let e=this.consume(d.DirectiveIf,`Expected @if directive`),t=e.loc.start,n=e.value,r=[];for(;!this.check(d.BlockClose)&&!this.isAtEnd();)r.push(this.parseChild());let i=this.consume(d.BlockClose,`Expected closing brace } for @if block`),a=null,o=i.loc.end;if(this.skipWhitespaceTokens(),this.check(d.DirectiveElseIf))a=this.parseElseIfChain(),o=a.loc.end;else if(this.check(d.DirectiveElse)){this.advance();let e=[];for(;!this.check(d.BlockClose)&&!this.isAtEnd();)e.push(this.parseChild());let t=this.consume(d.BlockClose,`Expected closing brace } for @else block`);a=e,o=t.loc.end}return{type:m.If,test:n,consequent:r,alternate:a,loc:{start:t,end:o}}}parseElseIfChain(){let e=this.consume(d.DirectiveElseIf,`Expected @else if directive`),t=e.loc.start,n=e.value,r=[];for(;!this.check(d.BlockClose)&&!this.isAtEnd();)r.push(this.parseChild());let i=this.consume(d.BlockClose,`Expected closing brace } for @else if block`),a=null,o=i.loc.end;if(this.skipWhitespaceTokens(),this.check(d.DirectiveElseIf))a=this.parseElseIfChain(),o=a.loc.end;else if(this.check(d.DirectiveElse)){this.advance();let e=[];for(;!this.check(d.BlockClose)&&!this.isAtEnd();)e.push(this.parseChild());let t=this.consume(d.BlockClose,`Expected closing brace } for @else block`);a=e,o=t.loc.end}return{type:m.If,test:n,consequent:r,alternate:a,loc:{start:t,end:o}}}parseForDirective(){let e=this.consume(d.DirectiveFor,`Expected @for directive`),t=e.loc.start,n=e.value.trim();function r(e){return(0,c.scanBalancedDelimiters)(e,(t,n)=>{if(n===`i`&&e[t+1]===`n`){let n=t===0||!/[a-zA-Z0-9_$]/.test(e[t-1]),r=t+2>=e.length||!/[a-zA-Z0-9_$]/.test(e[t+2]);if(n&&r){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0||e[n]!==`.`)return!0}}})}function i(e){return(0,c.findTopLevelChar)(e,`,`)}function a(e){let t=-1;return(0,c.scanBalancedDelimiters)(e,n=>{if(e.slice(n,n+3)===`key`){let r=n===0||!/[a-zA-Z0-9_$]/.test(e[n-1]),i=n+3>=e.length||!/[a-zA-Z0-9_$]/.test(e[n+3]);if(r&&i){let r=n-1;for(;r>=0&&/\s/.test(e[r]);)r--;if((r<0||e[r]!==`.`&&e[r]!==`?`)&&e.slice(n+3).trim().length>0)return t=n,!0}}}),t===-1?null:{index:t,keyExpr:e.slice(t+3).trim()}}for(;(0,c.hasMatchingOuterParens)(n);)n=n.slice(1,-1).trim();let o=r(n);if(o===-1&&(0,c.hasMatchingOuterParens)(n)){let e=n.slice(1,-1).trim(),t=r(e);t!==-1&&(n=e,o=t)}if(o===-1)throw new g(`Invalid @for header syntax '${n}'. Expected format: 'item in list' or '(item, index) in list'`,e.loc.start.line,e.loc.start.column,e.loc.start.offset);let s=n.slice(0,o).trim(),l=n.slice(o+2).trim(),u=null,f=a(l);f&&(u=f.keyExpr,l=l.slice(0,f.index).trim());let p=l,h=s,_=null;for(;(0,c.hasMatchingOuterParens)(h);)h=h.slice(1,-1).trim();let v=i(h);if(v!==-1){let e=h.slice(0,v).trim();for(_=h.slice(v+1).trim()||null,h=e;(0,c.hasMatchingOuterParens)(h);)h=h.slice(1,-1).trim()}if(!h||!p)throw new g(`Invalid @for header syntax '${e.value.trim()}'. Expected format: 'item in list' or '(item, index) in list'`,e.loc.start.line,e.loc.start.column,e.loc.start.offset);let y=[];for(;!this.check(d.BlockClose)&&!this.isAtEnd();)y.push(this.parseChild());let b=this.consume(d.BlockClose,`Expected closing brace } for @for block`);return{type:m.For,item:h,index:_,iterable:p,key:u,body:y,loc:{start:t,end:b.loc.end}}}parseSwitchDirective(){let e=this.consume(d.DirectiveSwitch,`Expected @switch directive`),t=e.loc.start,n=e.value,r=[];for(this.skipWhitespaceTokens();!this.check(d.BlockClose)&&!this.isAtEnd();){if(this.check(d.DirectiveCase)){let e=this.advance(),t=[];for(;!this.check(d.BlockClose)&&!this.isAtEnd();)t.push(this.parseChild());let n=this.consume(d.BlockClose,`Expected closing brace } for @case block`);r.push({expression:e.value,body:t,loc:{start:e.loc.start,end:n.loc.end}})}else if(this.check(d.DirectiveDefault)){let e=this.advance(),t=[];for(;!this.check(d.BlockClose)&&!this.isAtEnd();)t.push(this.parseChild());let n=this.consume(d.BlockClose,`Expected closing brace } for @default block`);r.push({expression:null,body:t,loc:{start:e.loc.start,end:n.loc.end}})}else throw new g(`Unexpected token '${this.peek().value}' inside @switch block. Expected @case or @default.`,this.peek().loc.start.line,this.peek().loc.start.column,this.peek().loc.start.offset);this.skipWhitespaceTokens()}let i=this.consume(d.BlockClose,`Expected closing brace } for @switch block`);return{type:m.Switch,discriminant:n,cases:r,loc:{start:t,end:i.loc.end}}}skipWhitespaceTokens(){for(;this.check(d.Text)&&this.peek().value.trim().length===0;)this.advance()}isAtEnd(){return this.peek().type===d.EOF}peek(e=0){return this.ensureLookahead(e),this.lookahead[Math.min(e,this.lookahead.length-1)]}advance(){let e=this.peek();return e.type!==d.EOF&&this.lookahead.shift(),e}check(e){return this.peek().type===e}matchToken(e){return this.check(e)?(this.advance(),!0):!1}consume(e,t){if(this.check(e))return this.advance();let n=this.peek();throw new g(t,n.loc.start.line,n.loc.start.column,n.loc.start.offset)}ensureLookahead(e){for(;this.lookahead.length<=e;){let e=this.tokenSource.nextToken();if(this.lookahead.push(e),e.type===d.EOF)break}}};function D(e,t){function n(e,t){let n=[];for(let i of e){let e=r(i,t);e!==null&&(Array.isArray(e)?n.push(...e):n.push(e))}return n}function r(e,i){if(!e||typeof e!=`object`)return e;let a=e;if(t.enter){let e=t.enter(a,i);if(e!==void 0){if(e===null||Array.isArray(e))return e;a=e}}let o=t[a.type];if(o){let e=o(a,i);if(e!==void 0){if(e===null||Array.isArray(e))return e;a=e}}switch(a.type){case m.Program:{let e=n(a.body,a);a={...a,body:e};break}case m.Element:{let e=a.attributes;if(t.Attribute&&Array.isArray(a.attributes)){let n=[];for(let e of a.attributes){let r=t.Attribute(e,a);r==null?r===void 0&&n.push(e):n.push(r)}e=n}let r=n(a.children,a);a={...a,attributes:e,children:r};break}case m.If:{let e=n(a.consequent,a),t=a.alternate;Array.isArray(a.alternate)?t=n(a.alternate,a):a.alternate!==null&&typeof a.alternate==`object`&&(t=r(a.alternate,a)),a={...a,consequent:e,alternate:t};break}case m.For:{let e=n(a.body,a);a={...a,body:e};break}case m.Switch:if(Array.isArray(a.cases)){let e=a.cases.map(e=>({...e,body:n(e.body,a)}));a={...a,cases:e}}break}if(t.leave){let e=t.leave(a,i);if(e!==void 0)return e}return a}return r(e,null)}var O=class{rawAst;switchCounter=0;constructor(e){this.rawAst=e}transform(){return D(D(D(this.rawAst,{Text:e=>{if(typeof e.content==`string`&&this.isWhitespaceOnly(e.content))return null}}),{Switch:e=>this.transformSwitchToIfChain(e)}),{Interpolation:e=>this.transformInterpolation(e),Element:e=>{if(e.tagName===`script`)return this.transformScriptElement(e);if(e.attributes.some(e=>e.value!==null&&typeof e.value!=`string`))return{...e,attributes:e.attributes.map(e=>e.type===m.Attribute&&e.value!==null&&typeof e.value!=`string`&&e.value.type===m.Interpolation?{...e,value:this.transformInterpolation(e.value)}:e)}},If:e=>{if(typeof e.test==`string`&&e.test.trim().length>0)return{...e,test:l.parseExpressionAt(e.test,0,{ecmaVersion:`latest`})}},For:e=>({...e,iterable:typeof e.iterable==`string`?l.parseExpressionAt(e.iterable,0,{ecmaVersion:`latest`}):e.iterable,key:typeof e.key==`string`&&e.key.trim().length>0?l.parseExpressionAt(e.key,0,{ecmaVersion:`latest`}):e.key??null})})}transformSwitchToIfChain(e){let t=typeof e.discriminant==`string`?l.parseExpressionAt(e.discriminant,0,{ecmaVersion:`latest`}):e.discriminant,n=t.type===`Identifier`||t.type===`Literal`||t.type===`MemberExpression`,r=`__drift_sw_${this.switchCounter++}`,i=!0,a=o=>{let s=e.cases[o];if(!s)return null;if(s.expression===null){let e=[...s.body],t=a(o+1),n=null;return(Array.isArray(t)||t!==null&&t.type===m.If)&&(n=t),o>0&&n===null?e:{type:m.If,test:{type:`Literal`,value:!0,raw:`true`,start:0,end:0},consequent:e,alternate:n,loc:s.loc}}let c=typeof s.expression==`string`&&s.expression.trim().length>0?l.parseExpressionAt(s.expression,0,{ecmaVersion:`latest`}):s.expression,u;n?u=structuredClone(t):i?(i=!1,u={type:`AssignmentExpression`,operator:`=`,left:{type:`Identifier`,name:r,start:0,end:0},right:structuredClone(t),start:0,end:0}):u={type:`Identifier`,name:r,start:0,end:0};let d={type:`BinaryExpression`,operator:`===`,left:u,right:c,start:0,end:0},f=[...s.body],p=a(o+1),h=null;return(Array.isArray(p)||p!==null&&p.type===m.If)&&(h=p),{type:m.If,test:d,consequent:f,alternate:h,extraDeps:structuredClone(t),loc:s.loc}},o=a(0);return o?Array.isArray(o)?o.length===0?{type:m.Comment,content:`empty switch`,loc:e.loc}:{type:m.If,test:{type:`Literal`,value:!0,raw:`true`,start:0,end:0},consequent:o,alternate:null,loc:e.loc}:o:{type:m.Comment,content:`empty switch`,loc:e.loc}}transformInterpolation(e){if(typeof e.expression!=`string`)return e;let t;try{t=l.parseExpressionAt(e.expression,0,{ecmaVersion:`latest`,allowAwaitOutsideFunction:!0})}catch(t){throw new g(`Failed to parse JS expression in interpolation: ${t instanceof Error?t.message:String(t)}`,e.loc.start.line,e.loc.start.column,e.loc.start.offset)}return{...e,expression:t}}transformScriptElement(e){let t=e.children.map(e=>{if(e.type===m.Text&&typeof e.content==`string`){let t;try{let n=l.parse(e.content,{ecmaVersion:`latest`,sourceType:`module`,allowAwaitOutsideFunction:!0,allowReturnOutsideFunction:!0});t=n.body.length===1&&n.body[0]!==void 0?n.body[0]:n.body}catch(t){throw new g(`Failed to parse script tag JS content: ${t instanceof Error?t.message:String(t)}`,e.loc.start.line,e.loc.start.column,e.loc.start.offset)}return{...e,content:t}}return e});return{...e,children:t}}isWhitespaceOnly(e){return e.length>0&&/^\s*$/.test(e)}},k=class{ast;bytecode=[];constants=[];nextRegisterId=0;declaredVars=new Set;imports=[];bindingPositions=new Map;derivedBindings=[];pendingDerived=[];effectBindings=[];pendingEffects=[];constructor(e){this.ast=e}generate(){if(this.bytecode=[],this.constants=[],this.nextRegisterId=0,this.declaredVars=new Set,this.imports=[],this.bindingPositions=new Map,this.derivedBindings=[],this.pendingDerived=[],this.effectBindings=[],this.pendingEffects=[],this.collectDeclaredVars(this.ast.body),this.processDerivedBindings(),this.processEffectBindings(),this.ast.body.length===0){let e=this.allocRegister();return this.emit(_.CREATE_FRAGMENT,e),{bytecode:this.bytecode,constants:this.constants,reactiveBindings:this.buildReactiveBindings(),declaredVars:[...this.declaredVars],derived:this.derivedBindings,effects:this.effectBindings,imports:this.imports}}if(this.ast.body.length===1&&this.ast.body[0]?.type===m.Element){let e=this.allocRegister();this.compileElement(this.ast.body[0],e)}else{let e=this.allocRegister();this.emit(_.CREATE_FRAGMENT,e);for(let t of this.ast.body)this.compileNode(t,e)}return{bytecode:this.bytecode,constants:this.constants,reactiveBindings:this.buildReactiveBindings(),declaredVars:[...this.declaredVars],derived:this.derivedBindings,effects:this.effectBindings,imports:this.imports}}compileNode(e,t){switch(e.type){case m.Element:e.tagName===`script`?this.compileScriptElement(e):this.compileElementNode(e,t);break;case m.Text:this.compileTextNode(e,t);break;case m.Interpolation:this.compileInterpolationNode(e,t);break;case m.Comment:this.compileCommentNode(e,t);break;case m.If:this.compileIfNode(e,t);break;case m.For:this.compileForNode(e,t);break}}filterRuntimeScriptAst(e){if(Array.isArray(e)){let t=e.map(e=>this.filterScriptStatement(e)).filter(Boolean);return t.length===1?t[0]:t}return this.filterScriptStatement(e)}filterScriptStatement(e){if(!e||typeof e!=`object`)return e;if(e.type===`ImportDeclaration`||e.type===`ExpressionStatement`&&e.expression?.type===`CallExpression`&&e.expression.callee?.type===`Identifier`&&e.expression.callee.name===`effect`)return null;if(e.type===`VariableDeclaration`){let t=e.declarations.filter(e=>!(e.init?.type===`CallExpression`&&e.init.callee?.type===`Identifier`&&e.init.callee.name===`derive`));return t.length===0?null:{...e,declarations:t}}return e}compileScriptElement(e){for(let t of e.children)if(t.type===m.Text&&typeof t.content==`object`&&t.content!==null){let e=this.filterRuntimeScriptAst(t.content);if(e!==null&&(!Array.isArray(e)||e.length>0)){let t=this.addConstant(e);this.emit(_.EXEC_SCRIPT,t)}}}isComponentTag(e){if(this.imports.some(t=>t.localName===e))return!0;let t=e.charAt(0);return t!==``&&t===t.toUpperCase()&&t!==t.toLowerCase()}compileElement(e,t){let n=this.isComponentTag(e.tagName),r=this.addConstant(e.tagName);if(n){let n={__drift_props__:!0};for(let t of e.attributes)if(t.type===m.Attribute){if(t.value===null)n[t.name]=!0;else if(typeof t.value==`string`)n[t.name]=t.value;else if(t.value.type===m.Interpolation){let e=t.value.expression;if(e&&typeof e==`object`&&e.type){let r=F(e);n[t.name]={__drift_fn__:`(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable, _get) => (${r})`}}else n[t.name]=e}}let i=null;if(e.children&&e.children.length>0){let t=e.children.filter(e=>!(e.type===m.Text&&typeof e.content==`string`&&e.content.trim()===``));t.length>0&&(i=this.compileNodesToSubModule(t),n.__drift_children__=this.addConstant(i))}let a=Object.keys(n).length>1?this.addConstant(n):255,o=this.bytecode.length;this.emit(_.MOUNT_COMPONENT,t,r,a),this.emit(_.RETURN);for(let t of e.attributes)t.type===m.Attribute&&t.value!==null&&typeof t.value!=`string`&&t.value.type===m.Interpolation&&this.recordBindingPositions(t.value.expression,o);if(i)for(let e of i.reactiveBindings)this.declaredVars.has(e.variable)&&(this.bindingPositions.has(e.variable)||this.bindingPositions.set(e.variable,[]),this.bindingPositions.get(e.variable).push(o))}else{this.emit(_.CREATE_ELEMENT,t,r);for(let n of e.attributes)this.compileAttributeNode(n,t);for(let n of e.children)this.compileNode(n,t)}}compileElementNode(e,t){let n=this.allocRegister();this.compileElement(e,n),this.emit(_.APPEND_CHILD,t,n)}compileAttributeNode(e,t){let n=this.addConstant(e.name);if(e.value===null){let e=this.addConstant(!0);this.emit(_.SET_ATTR,t,n,e,0)}else if(typeof e.value==`string`){let r=this.addConstant(e.value);this.emit(_.SET_ATTR,t,n,r,0)}else if(e.value.type===m.Interpolation){let r=this.addConstant(e.value.expression),i=this.bytecode.length;this.emit(_.SET_ATTR,t,n,r,1),this.emit(_.RETURN),this.recordBindingPositions(e.value.expression,i)}}compileTextNode(e,t){let n=this.allocRegister(),r=this.addConstant(e.content);this.emit(_.CREATE_TEXT,n,r),this.emit(_.APPEND_CHILD,t,n)}compileInterpolationNode(e,t){let n=this.allocRegister(),r=this.addConstant(e.expression),i=this.bytecode.length;this.emit(_.INTERPOLATE_TEXT,n,r),this.emit(_.RETURN),this.emit(_.APPEND_CHILD,t,n),this.recordBindingPositions(e.expression,i)}compileCommentNode(e,t){let n=this.allocRegister(),r=this.addConstant(e.content);this.emit(_.CREATE_COMMENT,n,r),this.emit(_.APPEND_CHILD,t,n)}compileNodesToSubModule(e){let t=this.bytecode,n=this.constants,r=this.nextRegisterId,i=this.bindingPositions;this.bytecode=[],this.constants=[],this.nextRegisterId=0,this.bindingPositions=new Map;let a=this.allocRegister();this.emit(_.CREATE_FRAGMENT,a);for(let t of e)this.compileNode(t,a);let o={bytecode:this.bytecode,constants:this.constants,reactiveBindings:this.buildReactiveBindings()};return this.bytecode=t,this.constants=n,this.nextRegisterId=r,this.bindingPositions=i,o}collectDepsFromSubModule(e,t){let n=new Set;for(let t=0;t<e.reactiveBindings.length;t++)n.add(e.reactiveBindings[t].variable);if(t)for(let e of this.extractIdentifiers(t))this.declaredVars.has(e)&&n.add(e);return[...n]}compileIfNode(e,t){let n=this.compileNodesToSubModule(e.consequent),r=this.addConstant(n),i=255,a=null;if(e.alternate!==null){let t;t=Array.isArray(e.alternate)?e.alternate:[e.alternate],a=this.compileNodesToSubModule(t),i=this.addConstant(a)}let o=new Set(this.collectDepsFromSubModule(n,e.test));if(e.extraDeps){for(let t of this.extractIdentifiers(e.extraDeps))this.declaredVars.has(t)&&o.add(t);let t=Array.from(o);n.constants&&!n.constants.some(e=>Array.isArray(e))&&n.constants.push(t)}if(a)for(let e of this.collectDepsFromSubModule(a))o.add(e);let s=this.addConstant(Array.from(o)),c=this.addConstant(e.test);this.emit(_.REACTIVE_IF,t,c,r,i,s)}compileForNode(e,t){let n=this.compileNodesToSubModule(e.body),r=this.addConstant(n),i=this.addConstant(e.iterable),a=this.addConstant(e.item),o=e.index===null?255:this.addConstant(e.index),s=e.key?this.addConstant(e.key):255,c=this.collectDepsFromSubModule(n,e.iterable),l=this.addConstant(c);this.emit(_.REACTIVE_FOR,t,i,a,o,s,r,l)}collectDeclaredVars(e){for(let t of e)if(t.type===m.Element&&t.tagName===`script`){for(let e of t.children)if(e.type===m.Text&&typeof e.content==`object`&&e.content!==null){let t=e.content;if(Array.isArray(t))for(let e of t)this.extractVarNames(e);else this.extractVarNames(t)}}}extractVarNames(e){if(!(!e||typeof e!=`object`)){if(e.type===`VariableDeclaration`)for(let t of e.declarations){for(let e of j(t.id))this.declaredVars.add(e);t.id?.type===`Identifier`&&t.init?.type===`CallExpression`&&t.init.callee?.type===`Identifier`&&t.init.callee.name===`derive`&&t.init.arguments&&t.init.arguments.length>0&&this.pendingDerived.push({name:t.id.name,arg:t.init.arguments[0]})}else if(e.type===`ExpressionStatement`&&e.expression?.type===`CallExpression`&&e.expression.callee?.type===`Identifier`&&e.expression.callee.name===`effect`&&Array.isArray(e.expression.arguments)&&e.expression.arguments.length>0)this.pendingEffects.push({arg:e.expression.arguments[0]});else if((e.type===`FunctionDeclaration`||e.type===`ClassDeclaration`)&&e.id?.type===`Identifier`)this.declaredVars.add(e.id.name);else if(e.type===`ImportDeclaration`&&Array.isArray(e.specifiers)){let t=typeof e.source?.value==`string`?e.source.value:``;if(e.specifiers.length===0)this.imports.push({localName:``,source:t,isDefault:!1,isSideEffect:!0});else for(let n of e.specifiers)if(n.local?.type===`Identifier`){let e=n.local.name;this.declaredVars.add(e);let r=n.type===`ImportDefaultSpecifier`,i=n.type===`ImportNamespaceSpecifier`,a=n.type===`ImportSpecifier`&&n.imported?.type===`Identifier`?n.imported.name:void 0;this.imports.push({localName:e,source:t,isDefault:r,isNamespace:i,importedName:a})}}}}processDerivedBindings(){for(let e of this.pendingDerived){let{name:t,arg:n}=e,r=n,i=!1;(n.type===`ArrowFunctionExpression`||n.type===`FunctionExpression`)&&(n.body?.type===`BlockStatement`&&(i=!0),r=n.body);let a=[...this.extractIdentifiers(r)].filter(e=>e!==t&&this.declaredVars.has(e)),o=F(r),s;s=i?{__drift_fn__:`(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable, _get) => ${o}`}:{__drift_fn__:`(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable, _get) => (${o})`};let c=this.addConstant(s);this.derivedBindings.push({name:t,deps:a,exprIdx:c})}}processEffectBindings(){for(let e of this.pendingEffects){let{arg:t}=e,n=t,r=!1,i=!!t?.async;(t.type===`ArrowFunctionExpression`||t.type===`FunctionExpression`)&&(t.body?.type===`BlockStatement`&&(r=!0),n=t.body);let a=[...this.extractIdentifiers(n)].filter(e=>this.declaredVars.has(e)),o=F(n),s=i?`async `:``,c;c=r?{__drift_fn__:`${s}(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable, _get) => ${o}`}:{__drift_fn__:`${s}(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable, _get) => (${o})`};let l=this.addConstant(c);this.effectBindings.push({deps:a,exprIdx:l})}}extractIdentifiers(e){let t=new Set;if(!e||typeof e!=`object`)return t;try{u.ancestor(e,{Identifier(e,n){let r=n[n.length-2];r&&(r.type===`MemberExpression`&&r.property===e&&!r.computed||(r.type===`Property`||r.type===`MethodDefinition`||r.type===`PropertyDefinition`)&&r.key===e&&!r.computed)||t.add(e.name)}})}catch{}return t}recordBindingPositions(e,t){if(this.declaredVars.size===0)return;let n=this.extractIdentifiers(e);for(let e of n)this.declaredVars.has(e)&&(this.bindingPositions.has(e)||this.bindingPositions.set(e,[]),this.bindingPositions.get(e).push(t))}buildReactiveBindings(){let e=[];for(let[t,n]of this.bindingPositions)e.push({variable:t,positions:n});return e}allocRegister(){return this.nextRegisterId++}addConstant(e){e&&typeof e==`object`&&e.type&&typeof e.type==`string`?e={__drift_fn__:`(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable, _get) => (${F(e)})`}:Array.isArray(e)&&e.length>0&&typeof e[0]==`object`&&e[0]?.type&&(e={__drift_fn__:`(scope, declaredVars, setScopeValue, inScopeChain, resolveIterable, _get) => { ${F(e)}; }`});let t=this.constants.findIndex(t=>this.isConstantEqual(t,e));return t===-1?(this.constants.push(e),this.constants.length-1):t}isConstantEqual(e,t){return e===t||typeof e==`object`&&typeof t==`object`&&e!==null&&t!==null&&JSON.stringify(e)===JSON.stringify(t)}emit(e,...t){this.bytecode.push(e,...t)}};function A(e){return!e||typeof e!=`object`?null:e.type===`Identifier`?e.name:e.type===`MemberExpression`?A(e.object):null}function j(e){let t=[];function n(e){if(!(!e||typeof e!=`object`))if(e.type===`Identifier`)t.push(e.name);else if(e.type===`ObjectPattern`&&Array.isArray(e.properties))for(let t of e.properties)t.type===`Property`?n(t.value):t.type===`RestElement`&&n(t.argument);else if(e.type===`ArrayPattern`&&Array.isArray(e.elements))for(let t of e.elements)t&&n(t);else e.type===`AssignmentPattern`?n(e.left):e.type===`RestElement`&&n(e.argument)}return n(e),t}function M(e,t){if(!e)return``;switch(e.type){case`Identifier`:return e.name;case`AssignmentPattern`:return`${M(e.left,t)} = ${F(e.right,t)}`;case`RestElement`:return`...${M(e.argument,t)}`;case`ArrayPattern`:return`[${(e.elements||[]).map(e=>e?M(e,t):``).join(`, `)}]`;case`ObjectPattern`:return`{ ${(e.properties||[]).map(e=>{if(e.type===`Property`){let n=e.key?.name||(typeof e.key?.value==`string`?JSON.stringify(e.key.value):e.key?.value?String(e.key.value):F(e.key,t));if(e.value?.type===`AssignmentPattern`){let r=e.value.left?.name||M(e.value.left,t),i=F(e.value.right,t);return n===r||e.shorthand?`${n} = ${i}`:`${n}: ${r} = ${i}`}else if(e.value?.type===`Identifier`&&e.value.name===n)return n;else return`${n}: ${M(e.value,t)}`}else if(e.type===`RestElement`)return`...${M(e.argument,t)}`;return``}).filter(Boolean).join(`, `)} }`;default:return e.name||F(e,t)}}function N(e,t,n){return n&&n.has(e)?`(${e} = ${t})`:`(typeof setScopeValue === 'function' && scope ? setScopeValue(scope, ${JSON.stringify(e)}, ${t}) : ((scope || {})[${JSON.stringify(e)}] = ${t}))`}function P(e,t,n,r={count:0}){let i=[];if(!e)return i;if(e.type===`Identifier`)return i.push(N(e.name,t,n)),i;if(e.type===`AssignmentPattern`){let a=`((${t} !== undefined) ? ${t} : ${F(e.right,n)})`;if(e.left?.type===`Identifier`)i.push(N(e.left.name,a,n));else{let t=`_t${r.count++}`;i.push(`const ${t} = ${a}`),i.push(...P(e.left,t,n,r))}return i}if(e.type===`ObjectPattern`){for(let a of e.properties||[])if(a.type===`Property`){let e=a.computed?F(a.key,n):a.key?.name===void 0?typeof a.key?.value==`string`||typeof a.key?.value==`number`?JSON.stringify(a.key.value):F(a.key,n):JSON.stringify(a.key.name);if(a.value?.type===`Identifier`){let r=`(${t} ? ${t}[${e}] : undefined)`;i.push(N(a.value.name,r,n))}else if(a.value?.type===`AssignmentPattern`){let o=`((${t} && ${t}[${e}] !== undefined) ? ${t}[${e}] : ${F(a.value.right,n)})`;if(a.value.left?.type===`Identifier`)i.push(N(a.value.left.name,o,n));else{let e=`_t${r.count++}`;i.push(`const ${e} = ${o}`),i.push(...P(a.value.left,e,n,r))}}else if(a.value?.type===`ObjectPattern`||a.value?.type===`ArrayPattern`){let o=`_t${r.count++}`,s=`(${t} ? ${t}[${e}] : undefined)`;i.push(`const ${o} = ${s}`),i.push(...P(a.value,o,n,r))}else{let r=a.value?.name||F(a.value,n);if(r){let a=`(${t} ? ${t}[${e}] : undefined)`;i.push(N(r,a,n))}}}else if(a.type===`RestElement`){let r=a.argument?.name||F(a.argument,n);if(r){let a=(e.properties||[]).filter(e=>e.type===`Property`).map(e=>e.key?.name||(typeof e.key?.value==`string`?e.key.value:``)).filter(Boolean),o=`(() => { const _r = Object.assign({}, ${t}); ${JSON.stringify(a)}.forEach(k => delete _r[k]); return _r; })()`;i.push(N(r,o,n))}}return i}if(e.type===`ArrayPattern`){let a=`_a${r.count++}`;i.push(`const ${a} = (typeof resolveIterable === 'function' ? resolveIterable(${t}) : (${t} || []))`);let o=e.elements||[];for(let e=0;e<o.length;e++){let t=o[e];if(t){if(t.type===`Identifier`){let r=`(${a} ? ${a}[${e}] : undefined)`;i.push(N(t.name,r,n))}else if(t.type===`AssignmentPattern`){let o=F(t.right,n),s=`((${a} && ${a}[${e}] !== undefined) ? ${a}[${e}] : ${o})`;if(t.left?.type===`Identifier`)i.push(N(t.left.name,s,n));else{let e=`_t${r.count++}`;i.push(`const ${e} = ${s}`),i.push(...P(t.left,e,n,r))}}else if(t.type===`RestElement`){let r=t.argument?.name||F(t.argument,n);if(r){let t=`((${a} && typeof ${a}.slice === 'function') ? ${a}.slice(${e}) : [])`;i.push(N(r,t,n))}}else if(t.type===`ObjectPattern`||t.type===`ArrayPattern`){let o=`_t${r.count++}`,s=`(${a} ? ${a}[${e}] : undefined)`;i.push(`const ${o} = ${s}`),i.push(...P(t,o,n,r))}}}return i}return i}function F(e,t){if(e==null)return`undefined`;if(typeof e!=`object`)return typeof e==`string`?JSON.stringify(e):String(e);if(Array.isArray(e))return e.map(e=>F(e,t)).join(`; `);switch(e.type){case`Identifier`:return t&&t.has(e.name)?e.name:`(typeof _get === 'function' ? _get(scope, ${JSON.stringify(e.name)}) : (typeof inScopeChain === 'function' && inScopeChain(scope, ${JSON.stringify(e.name)}) ? scope[${JSON.stringify(e.name)}] : (typeof globalThis !== 'undefined' && globalThis && (${JSON.stringify(e.name)} in globalThis) ? globalThis[${JSON.stringify(e.name)}] : (scope || {})[${JSON.stringify(e.name)}])))`;case`Literal`:return typeof e.raw==`string`?e.raw:typeof e.value==`string`?JSON.stringify(e.value):String(e.value);case`BinaryExpression`:case`LogicalExpression`:return`(${F(e.left,t)} ${e.operator} ${F(e.right,t)})`;case`UnaryExpression`:return`(${e.operator} ${F(e.argument,t)})`;case`AwaitExpression`:return`(await ${F(e.argument,t)})`;case`YieldExpression`:return e.delegate?`(yield* ${e.argument?F(e.argument,t):``})`:`(yield ${e.argument?F(e.argument,t):``})`;case`ConditionalExpression`:return`(${F(e.test,t)} ? ${F(e.consequent,t)} : ${F(e.alternate,t)})`;case`MemberExpression`:{let n=e.optional?`?.`:`.`;return e.computed?e.optional?`(${F(e.object,t)}?.[${F(e.property,t)}])`:`(${F(e.object,t)}[${F(e.property,t)}])`:`(${F(e.object,t)}${n}${e.property.name})`}case`CallExpression`:{let n=F(e.callee,t),r=e.arguments?e.arguments.map(e=>F(e,t)).join(`, `):``,i=`(${n}${e.optional?`?.(`:`(`}${r}))`;if(e.callee?.type===`MemberExpression`&&e.callee.property?.type===`Identifier`){let n=A(e.callee.object),r=e.callee.property.name;if(n&&[`push`,`pop`,`shift`,`unshift`,`splice`,`sort`,`reverse`].includes(r)&&(!t||!t.has(n)))return`(() => { const _res = ${i}; if (typeof setScopeValue === 'function' && scope && typeof inScopeChain === 'function' && inScopeChain(scope, ${JSON.stringify(n)})) setScopeValue(scope, ${JSON.stringify(n)}, scope[${JSON.stringify(n)}]); return _res; })()`}return i}case`AssignmentExpression`:{let n=F(e.right,t);if(e.left?.type===`Identifier`){let r=e.left.name;if(t&&t.has(r))return`(${r} ${e.operator} ${n})`;if(e.operator===`=`)return`(typeof setScopeValue === 'function' ? setScopeValue(scope, ${JSON.stringify(r)}, ${n}) : ((scope || {})[${JSON.stringify(r)}] = ${n}))`;{let t=e.operator.slice(0,-1);return`(typeof setScopeValue === 'function' ? setScopeValue(scope, ${JSON.stringify(r)}, (scope[${JSON.stringify(r)}] ${t} ${n})) : ((scope || {})[${JSON.stringify(r)}] ${e.operator} ${n}))`}}if(e.left?.type===`MemberExpression`){let r=A(e.left),i=`(${F(e.left,t)} ${e.operator} ${n})`;if(r&&(!t||!t.has(r)))return`(() => { const _res = ${i}; if (typeof setScopeValue === 'function' && scope && typeof inScopeChain === 'function' && inScopeChain(scope, ${JSON.stringify(r)})) setScopeValue(scope, ${JSON.stringify(r)}, scope[${JSON.stringify(r)}]); return _res; })()`}return e.left?.type===`ObjectPattern`||e.left?.type===`ArrayPattern`?`((_val) => { ${P(e.left,`_val`,t).join(`; `)}; return _val; })(${n})`:`(${F(e.left,t)} ${e.operator} ${n})`}case`UpdateExpression`:if(e.argument?.type===`Identifier`){let n=e.argument.name;if(t&&t.has(n))return e.prefix?`(${e.operator}${n})`:`(${n}${e.operator})`;let r=e.operator===`++`?`+`:`-`;return e.prefix?`(typeof setScopeValue === 'function' ? (setScopeValue(scope, ${JSON.stringify(n)}, (Number(scope[${JSON.stringify(n)}]) || 0) ${r} 1), scope[${JSON.stringify(n)}]) : ((scope || {})[${JSON.stringify(n)}] = (Number((scope || {})[${JSON.stringify(n)}]) || 0) ${r} 1))`:`(() => { const _v = Number(scope[${JSON.stringify(n)}]) || 0; if (typeof setScopeValue === 'function') setScopeValue(scope, ${JSON.stringify(n)}, _v ${r} 1); else (scope || {})[${JSON.stringify(n)}] = _v ${r} 1; return _v; })()`}if(e.argument?.type===`MemberExpression`){let n=A(e.argument),r=e.prefix?`(${e.operator}${F(e.argument,t)})`:`(${F(e.argument,t)}${e.operator})`;if(n&&(!t||!t.has(n)))return`(() => { const _res = ${r}; if (typeof setScopeValue === 'function' && scope && typeof inScopeChain === 'function' && inScopeChain(scope, ${JSON.stringify(n)})) setScopeValue(scope, ${JSON.stringify(n)}, scope[${JSON.stringify(n)}]); return _res; })()`}return e.prefix?`(${e.operator}${F(e.argument,t)})`:`(${F(e.argument,t)}${e.operator})`;case`SequenceExpression`:return`(${e.expressions?e.expressions.map(e=>F(e,t)).join(`, `):``})`;case`ArrayExpression`:return`[${e.elements?e.elements.map(e=>e?.type===`SpreadElement`?`...`+F(e.argument,t):F(e,t)).join(`, `):``}]`;case`ObjectExpression`:return`{${e.properties?e.properties.map(e=>{if(e.type===`SpreadElement`)return`...`+F(e.argument,t);let n=e.computed?`[${F(e.key,t)}]`:e.key?.name||(typeof e.key?.value==`string`?JSON.stringify(e.key.value):String(e.key?.value??``));if(e.kind===`get`||e.kind===`set`){let r=e.value,i=new Set(t),a=[];if(r.params)for(let e of r.params){for(let t of j(e))i.add(t);a.push(M(e,i))}let o=r.body?.type===`BlockStatement`?`{ ${r.body.body.map(e=>F(e,i)).filter(Boolean).join(`; `)}; }`:`{ ${F(r.body,i)}; }`;return`${e.kind} ${n}(${a.join(`, `)}) ${o}`}if(e.method){let r=e.value,i=new Set(t),a=[];if(r.params)for(let e of r.params){for(let t of j(e))i.add(t);a.push(M(e,i))}let o=r.async?`async `:``,s=r.generator?`*`:``,c=r.body?.type===`BlockStatement`?`{ ${r.body.body.map(e=>F(e,i)).filter(Boolean).join(`; `)}; }`:`{ ${F(r.body,i)}; }`;return`${o}${s}${n}(${a.join(`, `)}) ${c}`}return`${n}: ${F(e.value,t)}`}).join(`, `):``}}`;case`RestElement`:case`SpreadElement`:return`...${F(e.argument,t)}`;case`AssignmentPattern`:return`${F(e.left,t)} = ${F(e.right,t)}`;case`TemplateLiteral`:return`\`${e.quasis?e.quasis.map((n,r)=>(n.value?.raw??``)+(e.expressions&&e.expressions[r]?"${"+F(e.expressions[r],t)+`}`:``)).join(``):``}\``;case`TaggedTemplateExpression`:return`${F(e.tag,t)}${F(e.quasi,t)}`;case`ThisExpression`:return`this`;case`Super`:return`super`;case`BlockStatement`:{let n=new Set(t);if(Array.isArray(e.body))for(let t of e.body)if(t.type===`VariableDeclaration`&&Array.isArray(t.declarations))for(let e of t.declarations)for(let t of j(e.id))n.add(t);else t.type===`FunctionDeclaration`&&t.id?.name&&n.add(t.id.name);return`{ ${(e.body?e.body.map(e=>F(e,n)).filter(Boolean):[]).join(`; `)}; }`}case`ExpressionStatement`:return F(e.expression,t);case`ReturnStatement`:return`return ${e.argument?F(e.argument,t):``}`;case`ThrowStatement`:return`throw ${e.argument?F(e.argument,t):``}`;case`BreakStatement`:return e.label?`break ${e.label.name}`:`break`;case`ContinueStatement`:return e.label?`continue ${e.label.name}`:`continue`;case`LabeledStatement`:return`${e.label.name}: ${F(e.body,t)}`;case`TryStatement`:return`try ${F(e.block,t)} ${e.handler?F(e.handler,t):``} ${e.finalizer?`finally ${F(e.finalizer,t)}`:``}`.trim();case`CatchClause`:{let n=new Set(t),r=``;if(e.param){for(let t of j(e.param))n.add(t);r=M(e.param,n)}let i=F(e.body,n);return r?`catch (${r}) ${i}`:`catch ${i}`}case`SwitchStatement`:return`switch (${F(e.discriminant,t)}) { ${e.cases?e.cases.map(e=>F(e,t)).join(` `):``} }`;case`SwitchCase`:{let n=e.test?`case ${F(e.test,t)}:`:`default:`,r=e.consequent?e.consequent.map(e=>F(e,t)).filter(Boolean).join(`; `):``;return`${n} ${r?r+`;`:``}`}case`IfStatement`:return`if (${F(e.test,t)}) ${e.consequent.type===`BlockStatement`?F(e.consequent,t):`{ ${F(e.consequent,t)}; }`}${e.alternate?` else ${e.alternate.type===`BlockStatement`||e.alternate.type===`IfStatement`?F(e.alternate,t):`{ ${F(e.alternate,t)}; }`}`:``}`;case`ForStatement`:{let n=new Set(t);if(e.init?.type===`VariableDeclaration`&&e.init.declarations)for(let t of e.init.declarations)for(let e of j(t.id))n.add(e);let r=``;e.init?.type===`VariableDeclaration`&&e.init.declarations?r=(e.init.kind||`let`)+` `+e.init.declarations.map(e=>`${e.id?.type===`Identifier`?e.id.name:F(e.id,n)}${e.init?` = ${F(e.init,n)}`:``}`).join(`, `):e.init&&(r=F(e.init,n));let i=e.test?F(e.test,n):``,a=e.update?F(e.update,n):``,o=e.body?.type===`BlockStatement`?F(e.body,n):`{ ${e.body?F(e.body,n):``}; }`;return`for (${r}; ${i}; ${a}) ${o}`}case`ForOfStatement`:{let n=new Set(t),r=``;if(e.left?.type===`VariableDeclaration`){let t=e.left.kind||`let`,i=e.left.declarations?.[0];if(i){for(let e of j(i.id))n.add(e);r=`${t} ${i.id?.type===`Identifier`?i.id.name:F(i.id,n)}`}}else e.left?.type===`Identifier`?(n.add(e.left.name),r=e.left.name):e.left&&(r=F(e.left,n));let i=`(typeof resolveIterable === 'function' ? resolveIterable : (x) => x || [])(${F(e.right,t)})`,a=e.body?.type===`BlockStatement`?F(e.body,n):`{ ${e.body?F(e.body,n):``}; }`;return`for ${e.await?`await `:``}(${r} of ${i}) ${a}`}case`ForInStatement`:{let n=new Set(t),r=``;if(e.left?.type===`VariableDeclaration`){let t=e.left.kind||`let`,i=e.left.declarations?.[0];if(i){for(let e of j(i.id))n.add(e);r=`${t} ${i.id?.type===`Identifier`?i.id.name:F(i.id,n)}`}}else e.left?.type===`Identifier`?(n.add(e.left.name),r=e.left.name):e.left&&(r=F(e.left,n));let i=F(e.right,t),a=e.body?.type===`BlockStatement`?F(e.body,n):`{ ${e.body?F(e.body,n):``}; }`;return`for (${r} in ${i}) ${a}`}case`WhileStatement`:return`while (${F(e.test,t)}) ${e.body?.type===`BlockStatement`?F(e.body,t):`{ ${e.body?F(e.body,t):``}; }`}`;case`DoWhileStatement`:{let n=F(e.test,t);return`do ${e.body?.type===`BlockStatement`?F(e.body,t):`{ ${e.body?F(e.body,t):``}; }`} while (${n})`}case`ArrayPattern`:return`[ ${e.elements?e.elements.map(e=>e?e.type===`RestElement`?`...`+F(e.argument,t):e.type===`AssignmentPattern`?`${F(e.left,t)} = ${F(e.right,t)}`:e.name||F(e,t):``).join(`, `):``} ]`;case`ObjectPattern`:return`{ ${e.properties?e.properties.map(e=>{if(e.type===`Property`){let n=e.key?.name||F(e.key,t),r=e.value?.name||F(e.value,t);return n===r?n:`${n}: ${r}`}return e.type===`RestElement`?`...${F(e.argument,t)}`:``}).filter(Boolean).join(`, `):``} }`;case`VariableDeclaration`:{if(t){let n=[];if(e.declarations)for(let r of e.declarations){let e=r.id?.type===`Identifier`?r.id.name:F(r.id,t),i=r.init?F(r.init,t):void 0;i===void 0?n.push(`${e}`):n.push(`${e} = ${i}`)}return`${e.kind||`let`} ${n.join(`, `)}`}let n=[];if(e.declarations)for(let r of e.declarations)if(r.id?.type===`ObjectPattern`||r.id?.type===`ArrayPattern`){let e=r.init?F(r.init,t):`undefined`,i=P(r.id,`_init`,t);n.push(`((_init) => { ${i.join(`; `)}; return _init; })(${e})`)}else{let e=r.id?.name||F(r.id,t),i=r.init?F(r.init,t):`undefined`;n.push(`((scope || {})[${JSON.stringify(e)}] = ${i})`)}return`(${n.filter(Boolean).join(`, `)||`undefined`})`}case`FunctionDeclaration`:{let n=e.id?.name,r=new Set(t);n&&r.add(n);let i=[];if(e.params)for(let t of e.params){for(let e of j(t))r.add(e);i.push(M(t,r))}if(e.body?.type===`BlockStatement`&&Array.isArray(e.body.body))for(let t of e.body.body)if(t.type===`VariableDeclaration`&&Array.isArray(t.declarations))for(let e of t.declarations)for(let t of j(e.id))r.add(t);else t.type===`FunctionDeclaration`&&t.id?.name&&r.add(t.id.name);let a=i.join(`, `),o=e.body?.type===`BlockStatement`?`{ ${e.body.body.map(e=>F(e,r)).filter(Boolean).join(`; `)}; }`:`{ ${F(e.body,r)}; }`,s=`${e.async?`async `:``}function${e.generator?`*`:``} ${n||``}(${a}) ${o}`;return n?`((scope || {})[${JSON.stringify(n)}] = ${s})`:s}case`ArrowFunctionExpression`:case`FunctionExpression`:{let n=new Set(t);e.id?.name&&n.add(e.id.name);let r=[];if(e.params)for(let t of e.params){for(let e of j(t))n.add(e);r.push(M(t,n))}if(e.body?.type===`BlockStatement`&&Array.isArray(e.body.body))for(let t of e.body.body)if(t.type===`VariableDeclaration`&&Array.isArray(t.declarations))for(let e of t.declarations)for(let t of j(e.id))n.add(t);else t.type===`FunctionDeclaration`&&t.id?.name&&n.add(t.id.name);let i=r.join(`, `),a=e.async?`async `:``;if(e.type===`ArrowFunctionExpression`)return e.body?.type===`BlockStatement`?`(${a}(${i}) => ${`{ ${e.body.body.map(e=>F(e,n)).filter(Boolean).join(`; `)}; }`})`:`(${a}(${i}) => ${F(e.body,n)})`;{let t=e.generator?`*`:``,r=e.body?.type===`BlockStatement`?`{ ${e.body.body.map(e=>F(e,n)).filter(Boolean).join(`; `)}; }`:`{ ${F(e.body,n)}; }`;return`(${a}function${t} ${e.id?.name||``}(${i}) ${r})`}}case`ClassDeclaration`:case`ClassExpression`:{let n=e.id?.name,r=new Set(t);n&&r.add(n);let i=e.superClass?` extends ${F(e.superClass,t)}`:``,a=F(e.body,r),o=`class ${n||``}${i} ${a}`;return e.type===`ClassDeclaration`&&n?`((scope || {})[${JSON.stringify(n)}] = ${o})`:`(${o})`}case`ClassBody`:return`{ ${(e.body?e.body.map(e=>F(e,t)).filter(Boolean):[]).join(`; `)} }`;case`MethodDefinition`:{let n=e.static?`static `:``,r=e.kind===`get`||e.kind===`set`?`${e.kind} `:``,i=e.value?.async?`async `:``,a=e.value?.generator?`*`:``,o=e.computed?`[${F(e.key,t)}]`:e.key?.name||F(e.key,t),s=new Set(t),c=[];if(e.value?.params)for(let t of e.value.params){for(let e of j(t))s.add(e);c.push(M(t,s))}if(e.value?.body?.type===`BlockStatement`&&Array.isArray(e.value.body.body))for(let t of e.value.body.body)if(t.type===`VariableDeclaration`&&Array.isArray(t.declarations))for(let e of t.declarations)for(let t of j(e.id))s.add(t);else t.type===`FunctionDeclaration`&&t.id?.name&&s.add(t.id.name);return`${n}${i}${a}${r}${o}(${c.join(`, `)}) ${e.value?.body?F(e.value.body,s):`{}`}`}case`PropertyDefinition`:return`${e.static?`static `:``}${e.computed?`[${F(e.key,t)}]`:e.key?.name||F(e.key,t)}${e.value?` = ${F(e.value,t)}`:``}`;case`NewExpression`:return`new (${F(e.callee,t)})(${e.arguments?e.arguments.map(e=>F(e,t)).join(`, `):``})`;case`EmptyStatement`:case`ImportDeclaration`:case`ImportSpecifier`:case`ImportDefaultSpecifier`:case`ImportNamespaceSpecifier`:return``;case`ParenthesizedExpression`:case`ChainExpression`:return F(e.expression,t);default:return``}}function I(e,t=!1){let n=new O(new E(new S(e)).parse()).transform(),r=new k(n).generate();return t&&(console.log(`--- Transformed AST ---`),console.log(JSON.stringify(n,null,2)),console.log(`--- Compiled Module ---`),console.log(JSON.stringify(r,null,2))),r}exports.ASTNodeType=m,exports.DriftGenerator=k,exports.DriftLexer=S,exports.DriftLexerError=h,exports.DriftParser=E,exports.DriftParserError=g,exports.DriftTransformer=O,exports.ExprTokenKind=p,exports.LexerStateKind=f,exports.Opcode=_,exports.TokenType=d,exports.astToJS=F,exports.compile=I,exports.extractBindingNames=j,exports.traverseTemplateAST=D;
|