create-prisma-php-app 4.1.0-alpha.7 → 4.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
var
|
|
2
|
-
Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=11):e.ecmaVersion>=2015&&(e.ecmaVersion-=2009),e.allowReserved==null&&(e.allowReserved=e.ecmaVersion<5),(!
|
|
3
|
-
`,i-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(V).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=u.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||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(ge),this.regexpState=null,this.privateNameStack=[]},X={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};N.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};X.inFunction.get=function(){return(this.currentVarScope().flags&he)>0};X.inGenerator.get=function(){return(this.currentVarScope().flags&ot)>0};X.inAsync.get=function(){return(this.currentVarScope().flags&We)>0};X.canAwait.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],s=e.flags;if(s&(ne|Ee))return!1;if(s&he)return(s&We)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};X.allowSuper.get=function(){var t=this.currentThisScope(),e=t.flags;return(e&Te)>0||this.options.allowSuperOutsideMethod};X.allowDirectSuper.get=function(){return(this.currentThisScope().flags&ut)>0};X.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};X.allowNewDotTarget.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],s=e.flags;if(s&(ne|Ee)||s&he&&!(s&je))return!0}return!1};X.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&ne)>0};N.extend=function(){for(var e=[],s=arguments.length;s--;)e[s]=arguments[s];for(var i=this,n=0;n<e.length;n++)i=e[n](i);return i};N.parse=function(e,s){return new this(s,e).parse()};N.parseExpressionAt=function(e,s,i){var n=new this(i,e,s);return n.nextToken(),n.parseExpression()};N.tokenizer=function(e,s){return new this(s,e)};Object.defineProperties(N.prototype,X);var R=N.prototype,Qt=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;R.strictDirective=function(t){if(this.options.ecmaVersion<5)return!1;for(;;){M.lastIndex=t,t+=M.exec(this.input)[0].length;var e=Qt.exec(this.input.slice(t));if(!e)return!1;if((e[1]||e[2])==="use strict"){M.lastIndex=t+e[0].length;var s=M.exec(this.input),i=s.index+s[0].length,n=this.input.charAt(i);return n===";"||n==="}"||V.test(s[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(n)||n==="!"&&this.input.charAt(i+1)==="=")}t+=e[0].length,M.lastIndex=t,t+=M.exec(this.input)[0].length,this.input[t]===";"&&t++}};R.eat=function(t){return this.type===t?(this.next(),!0):!1};R.isContextual=function(t){return this.type===u.name&&this.value===t&&!this.containsEsc};R.eatContextual=function(t){return this.isContextual(t)?(this.next(),!0):!1};R.expectContextual=function(t){this.eatContextual(t)||this.unexpected()};R.canInsertSemicolon=function(){return this.type===u.eof||this.type===u.braceR||V.test(this.input.slice(this.lastTokEnd,this.start))};R.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};R.semicolon=function(){!this.eat(u.semi)&&!this.insertSemicolon()&&this.unexpected()};R.afterTrailingComma=function(t,e){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};R.expect=function(t){this.eat(t)||this.unexpected()};R.unexpected=function(t){this.raise(t??this.start,"Unexpected token")};var Pe=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};R.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var s=e?t.parenthesizedAssign:t.parenthesizedBind;s>-1&&this.raiseRecoverable(s,e?"Assigning to rvalue":"Parenthesized pattern")}};R.checkExpressionErrors=function(t,e){if(!t)return!1;var s=t.shorthandAssign,i=t.doubleProto;if(!e)return s>=0||i>=0;s>=0&&this.raise(s,"Shorthand property assignments are valid only in destructuring patterns"),i>=0&&this.raiseRecoverable(i,"Redefinition of __proto__ property")};R.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")};R.isSimpleAssignTarget=function(t){return t.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(t.expression):t.type==="Identifier"||t.type==="MemberExpression"};var b=N.prototype;b.parseTopLevel=function(t){var e=Object.create(null);for(t.body||(t.body=[]);this.type!==u.eof;){var s=this.parseStatement(null,!0,e);t.body.push(s)}if(this.inModule)for(var i=0,n=Object.keys(this.undefinedExports);i<n.length;i+=1){var r=n[i];this.raiseRecoverable(this.undefinedExports[r].start,"Export '"+r+"' is not defined")}return this.adaptDirectivePrologue(t.body),this.next(),t.sourceType=this.options.sourceType,this.finishNode(t,"Program")};var qe={kind:"loop"},Zt={kind:"switch"};b.isLet=function(t){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;M.lastIndex=this.pos;var e=M.exec(this.input),s=this.pos+e[0].length,i=this.input.charCodeAt(s);if(i===91||i===92)return!0;if(t)return!1;if(i===123||i>55295&&i<56320)return!0;if(z(i,!0)){for(var n=s+1;J(i=this.input.charCodeAt(n),!0);)++n;if(i===92||i>55295&&i<56320)return!0;var r=this.input.slice(s,n);if(!Wt.test(r))return!0}return!1};b.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;M.lastIndex=this.pos;var t=M.exec(this.input),e=this.pos+t[0].length,s;return!V.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(J(s=this.input.charCodeAt(e+8))||s>55295&&s<56320))};b.isUsingKeyword=function(t,e){if(this.options.ecmaVersion<17||!this.isContextual(t?"await":"using"))return!1;M.lastIndex=this.pos;var s=M.exec(this.input),i=this.pos+s[0].length;if(V.test(this.input.slice(this.pos,i)))return!1;if(t){var n=i+5,r;if(this.input.slice(i,n)!=="using"||n===this.input.length||J(r=this.input.charCodeAt(n))||r>55295&&r<56320)return!1;M.lastIndex=n;var a=M.exec(this.input);if(a&&V.test(this.input.slice(n,n+a[0].length)))return!1}if(e){var o=i+2,c;if(this.input.slice(i,o)==="of"&&(o===this.input.length||!J(c=this.input.charCodeAt(o))&&!(c>55295&&c<56320)))return!1}var l=this.input.charCodeAt(i);return z(l,!0)||l===92};b.isAwaitUsing=function(t){return this.isUsingKeyword(!0,t)};b.isUsing=function(t){return this.isUsingKeyword(!1,t)};b.parseStatement=function(t,e,s){var i=this.type,n=this.startNode(),r;switch(this.isLet(t)&&(i=u._var,r="let"),i){case u._break:case u._continue:return this.parseBreakContinueStatement(n,i.keyword);case u._debugger:return this.parseDebuggerStatement(n);case u._do:return this.parseDoStatement(n);case u._for:return this.parseForStatement(n);case u._function:return t&&(this.strict||t!=="if"&&t!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1,!t);case u._class:return t&&this.unexpected(),this.parseClass(n,!0);case u._if:return this.parseIfStatement(n);case u._return:return this.parseReturnStatement(n);case u._switch:return this.parseSwitchStatement(n);case u._throw:return this.parseThrowStatement(n);case u._try:return this.parseTryStatement(n);case u._const:case u._var:return r=r||this.value,t&&r!=="var"&&this.unexpected(),this.parseVarStatement(n,r);case u._while:return this.parseWhileStatement(n);case u._with:return this.parseWithStatement(n);case u.braceL:return this.parseBlock(!0,n);case u.semi:return this.parseEmptyStatement(n);case u._export:case u._import:if(this.options.ecmaVersion>10&&i===u._import){M.lastIndex=this.pos;var a=M.exec(this.input),o=this.pos+a[0].length,c=this.input.charCodeAt(o);if(c===40||c===46)return this.parseExpressionStatement(n,this.parseExpression())}return this.options.allowImportExportEverywhere||(e||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'")),i===u._import?this.parseImport(n):this.parseExport(n,s);default:if(this.isAsyncFunction())return t&&this.unexpected(),this.next(),this.parseFunctionStatement(n,!0,!t);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return e&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),l==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(n,!1,l),this.semicolon(),this.finishNode(n,"VariableDeclaration");var h=this.value,p=this.parseExpression();return i===u.name&&p.type==="Identifier"&&this.eat(u.colon)?this.parseLabeledStatement(n,h,p,t):this.parseExpressionStatement(n,p)}};b.parseBreakContinueStatement=function(t,e){var s=e==="break";this.next(),this.eat(u.semi)||this.insertSemicolon()?t.label=null:this.type!==u.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var i=0;i<this.labels.length;++i){var n=this.labels[i];if((t.label==null||n.name===t.label.name)&&(n.kind!=null&&(s||n.kind==="loop")||t.label&&s))break}return i===this.labels.length&&this.raise(t.start,"Unsyntactic "+e),this.finishNode(t,s?"BreakStatement":"ContinueStatement")};b.parseDebuggerStatement=function(t){return this.next(),this.semicolon(),this.finishNode(t,"DebuggerStatement")};b.parseDoStatement=function(t){return this.next(),this.labels.push(qe),t.body=this.parseStatement("do"),this.labels.pop(),this.expect(u._while),t.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(u.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")};b.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(qe),this.enterScope(0),this.expect(u.parenL),this.type===u.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var s=this.isLet();if(this.type===u._var||this.type===u._const||s){var i=this.startNode(),n=s?"let":this.value;return this.next(),this.parseVar(i,!0,n),this.finishNode(i,"VariableDeclaration"),this.parseForAfterInit(t,i,e)}var r=this.isContextual("let"),a=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var c=this.startNode();return this.next(),o==="await using"&&this.next(),this.parseVar(c,!0,o),this.finishNode(c,"VariableDeclaration"),this.parseForAfterInit(t,c,e)}var l=this.containsEsc,h=new Pe,p=this.start,f=e>-1?this.parseExprSubscripts(h,"await"):this.parseExpression(!0,h);return this.type===u._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===u._in&&this.unexpected(e),t.await=!0):a&&this.options.ecmaVersion>=8&&(f.start===p&&!l&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(t.await=!1)),r&&a&&this.raise(f.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(f,!1,h),this.checkLValPattern(f),this.parseForIn(t,f)):(this.checkExpressionErrors(h,!0),e>-1&&this.unexpected(e),this.parseFor(t,f))};b.parseForAfterInit=function(t,e,s){return(this.type===u._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&e.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===u._in?s>-1&&this.unexpected(s):t.await=s>-1),this.parseForIn(t,e)):(s>-1&&this.unexpected(s),this.parseFor(t,e))};b.parseFunctionStatement=function(t,e,s){return this.next(),this.parseFunction(t,de|(s?0:Fe),!1,e)};b.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement("if"),t.alternate=this.eat(u._else)?this.parseStatement("if"):null,this.finishNode(t,"IfStatement")};b.parseReturnStatement=function(t){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(u.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")};b.parseSwitchStatement=function(t){this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(u.braceL),this.labels.push(Zt),this.enterScope(0);for(var e,s=!1;this.type!==u.braceR;)if(this.type===u._case||this.type===u._default){var i=this.type===u._case;e&&this.finishNode(e,"SwitchCase"),t.cases.push(e=this.startNode()),e.consequent=[],this.next(),i?e.test=this.parseExpression():(s&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),s=!0,e.test=null),this.expect(u.colon)}else e||this.unexpected(),e.consequent.push(this.parseStatement(null));return this.exitScope(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")};b.parseThrowStatement=function(t){return this.next(),V.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var Yt=[];b.parseCatchClauseParam=function(){var t=this.parseBindingAtom(),e=t.type==="Identifier";return this.enterScope(e?ct:0),this.checkLValPattern(t,e?ht:Z),this.expect(u.parenR),t};b.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===u._catch){var e=this.startNode();this.next(),this.eat(u.parenL)?e.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterScope(0)),e.body=this.parseBlock(!1),this.exitScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(u._finally)?this.parseBlock():null,!t.handler&&!t.finalizer&&this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")};b.parseVarStatement=function(t,e,s){return this.next(),this.parseVar(t,!1,e,s),this.semicolon(),this.finishNode(t,"VariableDeclaration")};b.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(qe),t.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(t,"WhileStatement")};b.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement("with"),this.finishNode(t,"WithStatement")};b.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")};b.parseLabeledStatement=function(t,e,s,i){for(var n=0,r=this.labels;n<r.length;n+=1){var a=r[n];a.name===e&&this.raise(s.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===u._switch?"switch":null,c=this.labels.length-1;c>=0;c--){var l=this.labels[c];if(l.statementStart===t.start)l.statementStart=this.start,l.kind=o;else break}return this.labels.push({name:e,kind:o,statementStart:this.start}),t.body=this.parseStatement(i?i.indexOf("label")===-1?i+"label":i:"label"),this.labels.pop(),t.label=s,this.finishNode(t,"LabeledStatement")};b.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")};b.parseBlock=function(t,e,s){for(t===void 0&&(t=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(u.braceL),t&&this.enterScope(0);this.type!==u.braceR;){var i=this.parseStatement(null);e.body.push(i)}return s&&(this.strict=!1),this.next(),t&&this.exitScope(),this.finishNode(e,"BlockStatement")};b.parseFor=function(t,e){return t.init=e,this.expect(u.semi),t.test=this.type===u.semi?null:this.parseExpression(),this.expect(u.semi),t.update=this.type===u.parenR?null:this.parseExpression(),this.expect(u.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,"ForStatement")};b.parseForIn=function(t,e){var s=this.type===u._in;return this.next(),e.type==="VariableDeclaration"&&e.declarations[0].init!=null&&(!s||this.options.ecmaVersion<8||this.strict||e.kind!=="var"||e.declarations[0].id.type!=="Identifier")&&this.raise(e.start,(s?"for-in":"for-of")+" loop variable declaration may not have an initializer"),t.left=e,t.right=s?this.parseExpression():this.parseMaybeAssign(),this.expect(u.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,s?"ForInStatement":"ForOfStatement")};b.parseVar=function(t,e,s,i){for(t.declarations=[],t.kind=s;;){var n=this.startNode();if(this.parseVarId(n,s),this.eat(u.eq)?n.init=this.parseMaybeAssign(e):!i&&s==="const"&&!(this.type===u._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!i&&(s==="using"||s==="await using")&&this.options.ecmaVersion>=17&&this.type!==u._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+s+" declaration"):!i&&n.id.type!=="Identifier"&&!(e&&(this.type===u._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):n.init=null,t.declarations.push(this.finishNode(n,"VariableDeclarator")),!this.eat(u.comma))break}return t};b.parseVarId=function(t,e){t.id=e==="using"||e==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(t.id,e==="var"?He:Z,!1)};var de=1,Fe=2,ft=4;b.parseFunction=function(t,e,s,i,n){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!i)&&(this.type===u.star&&e&Fe&&this.unexpected(),t.generator=this.eat(u.star)),this.options.ecmaVersion>=8&&(t.async=!!i),e&de&&(t.id=e&ft&&this.type!==u.name?null:this.parseIdent(),t.id&&!(e&Fe)&&this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?He:Z:lt));var r=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ue(t.async,t.generator)),e&de||(t.id=this.type===u.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,s,!1,n),this.yieldPos=r,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(t,e&de?"FunctionDeclaration":"FunctionExpression")};b.parseFunctionParams=function(t){this.expect(u.parenL),t.params=this.parseBindingList(u.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};b.parseClass=function(t,e){this.next();var s=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);var i=this.enterClassBody(),n=this.startNode(),r=!1;for(n.body=[],this.expect(u.braceL);this.type!==u.braceR;){var a=this.parseClassElement(t.superClass!==null);a&&(n.body.push(a),a.type==="MethodDefinition"&&a.kind==="constructor"?(r&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),r=!0):a.key&&a.key.type==="PrivateIdentifier"&&Jt(i,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=s,this.next(),t.body=this.finishNode(n,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")};b.parseClassElement=function(t){if(this.eat(u.semi))return null;var e=this.options.ecmaVersion,s=this.startNode(),i="",n=!1,r=!1,a="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(u.braceL))return this.parseClassStaticBlock(s),s;this.isClassElementNameStart()||this.type===u.star?o=!0:i="static"}if(s.static=o,!i&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===u.star)&&!this.canInsertSemicolon()?r=!0:i="async"),!i&&(e>=9||!r)&&this.eat(u.star)&&(n=!0),!i&&!r&&!n){var c=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=c:i=c)}if(i?(s.computed=!1,s.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),s.key.name=i,this.finishNode(s.key,"Identifier")):this.parseClassElementName(s),e<13||this.type===u.parenL||a!=="method"||n||r){var l=!s.static&&ve(s,"constructor"),h=l&&t;l&&a!=="method"&&this.raise(s.key.start,"Constructor can't have get/set modifier"),s.kind=l?"constructor":a,this.parseClassMethod(s,n,r,h)}else this.parseClassField(s);return s};b.isClassElementNameStart=function(){return this.type===u.name||this.type===u.privateId||this.type===u.num||this.type===u.string||this.type===u.bracketL||this.type.keyword};b.parseClassElementName=function(t){this.type===u.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),t.computed=!1,t.key=this.parsePrivateIdent()):this.parsePropertyName(t)};b.parseClassMethod=function(t,e,s,i){var n=t.key;t.kind==="constructor"?(e&&this.raise(n.start,"Constructor can't be a generator"),s&&this.raise(n.start,"Constructor can't be an async method")):t.static&&ve(t,"prototype")&&this.raise(n.start,"Classes may not have a static property named prototype");var r=t.value=this.parseMethod(e,s,i);return t.kind==="get"&&r.params.length!==0&&this.raiseRecoverable(r.start,"getter should have no params"),t.kind==="set"&&r.params.length!==1&&this.raiseRecoverable(r.start,"setter should have exactly one param"),t.kind==="set"&&r.params[0].type==="RestElement"&&this.raiseRecoverable(r.params[0].start,"Setter cannot use rest params"),this.finishNode(t,"MethodDefinition")};b.parseClassField=function(t){return ve(t,"constructor")?this.raise(t.key.start,"Classes can't have a field named 'constructor'"):t.static&&ve(t,"prototype")&&this.raise(t.key.start,"Classes can't have a static field named 'prototype'"),this.eat(u.eq)?(this.enterScope(Ee|Te),t.value=this.parseMaybeAssign(),this.exitScope()):t.value=null,this.semicolon(),this.finishNode(t,"PropertyDefinition")};b.parseClassStaticBlock=function(t){t.body=[];var e=this.labels;for(this.labels=[],this.enterScope(ne|Te);this.type!==u.braceR;){var s=this.parseStatement(null);t.body.push(s)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(t,"StaticBlock")};b.parseClassId=function(t,e){this.type===u.name?(t.id=this.parseIdent(),e&&this.checkLValSimple(t.id,Z,!1)):(e===!0&&this.unexpected(),t.id=null)};b.parseClassSuper=function(t){t.superClass=this.eat(u._extends)?this.parseExprSubscripts(null,!1):null};b.enterClassBody=function(){var t={declared:Object.create(null),used:[]};return this.privateNameStack.push(t),t.declared};b.exitClassBody=function(){var t=this.privateNameStack.pop(),e=t.declared,s=t.used;if(this.options.checkPrivateFields)for(var i=this.privateNameStack.length,n=i===0?null:this.privateNameStack[i-1],r=0;r<s.length;++r){var a=s[r];le(e,a.name)||(n?n.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}};function Jt(t,e){var s=e.key.name,i=t[s],n="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(n=(e.static?"s":"i")+e.kind),i==="iget"&&n==="iset"||i==="iset"&&n==="iget"||i==="sget"&&n==="sset"||i==="sset"&&n==="sget"?(t[s]="true",!1):i?!0:(t[s]=n,!1)}function ve(t,e){var s=t.computed,i=t.key;return!s&&(i.type==="Identifier"&&i.name===e||i.type==="Literal"&&i.value===e)}b.parseExportAllDeclaration=function(t,e){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(t.exported=this.parseModuleExportName(),this.checkExport(e,t.exported,this.lastTokStart)):t.exported=null),this.expectContextual("from"),this.type!==u.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ExportAllDeclaration")};b.parseExport=function(t,e){if(this.next(),this.eat(u.star))return this.parseExportAllDeclaration(t,e);if(this.eat(u._default))return this.checkExport(e,"default",this.lastTokStart),t.declaration=this.parseExportDefaultDeclaration(),this.finishNode(t,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())t.declaration=this.parseExportDeclaration(t),t.declaration.type==="VariableDeclaration"?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id,t.declaration.id.start),t.specifiers=[],t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[]);else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==u.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause());else{for(var s=0,i=t.specifiers;s<i.length;s+=1){var n=i[s];this.checkUnreserved(n.local),this.checkLocalExport(n.local),n.local.type==="Literal"&&this.raise(n.local.start,"A string literal cannot be used as an exported binding without `from`.")}t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[])}this.semicolon()}return this.finishNode(t,"ExportNamedDeclaration")};b.parseExportDeclaration=function(t){return this.parseStatement(null)};b.parseExportDefaultDeclaration=function(){var t;if(this.type===u._function||(t=this.isAsyncFunction())){var e=this.startNode();return this.next(),t&&this.next(),this.parseFunction(e,de|ft,!1,t)}else if(this.type===u._class){var s=this.startNode();return this.parseClass(s,"nullableID")}else{var i=this.parseMaybeAssign();return this.semicolon(),i}};b.checkExport=function(t,e,s){t&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),le(t,e)&&this.raiseRecoverable(s,"Duplicate export '"+e+"'"),t[e]=!0)};b.checkPatternExport=function(t,e){var s=e.type;if(s==="Identifier")this.checkExport(t,e,e.start);else if(s==="ObjectPattern")for(var i=0,n=e.properties;i<n.length;i+=1){var r=n[i];this.checkPatternExport(t,r)}else if(s==="ArrayPattern")for(var a=0,o=e.elements;a<o.length;a+=1){var c=o[a];c&&this.checkPatternExport(t,c)}else s==="Property"?this.checkPatternExport(t,e.value):s==="AssignmentPattern"?this.checkPatternExport(t,e.left):s==="RestElement"&&this.checkPatternExport(t,e.argument)};b.checkVariableExport=function(t,e){if(t)for(var s=0,i=e;s<i.length;s+=1){var n=i[s];this.checkPatternExport(t,n.id)}};b.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};b.parseExportSpecifier=function(t){var e=this.startNode();return e.local=this.parseModuleExportName(),e.exported=this.eatContextual("as")?this.parseModuleExportName():e.local,this.checkExport(t,e.exported,e.exported.start),this.finishNode(e,"ExportSpecifier")};b.parseExportSpecifiers=function(t){var e=[],s=!0;for(this.expect(u.braceL);!this.eat(u.braceR);){if(s)s=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;e.push(this.parseExportSpecifier(t))}return e};b.parseImport=function(t){return this.next(),this.type===u.string?(t.specifiers=Yt,t.source=this.parseExprAtom()):(t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.type===u.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ImportDeclaration")};b.parseImportSpecifier=function(){var t=this.startNode();return t.imported=this.parseModuleExportName(),this.eatContextual("as")?t.local=this.parseIdent():(this.checkUnreserved(t.imported),t.local=t.imported),this.checkLValSimple(t.local,Z),this.finishNode(t,"ImportSpecifier")};b.parseImportDefaultSpecifier=function(){var t=this.startNode();return t.local=this.parseIdent(),this.checkLValSimple(t.local,Z),this.finishNode(t,"ImportDefaultSpecifier")};b.parseImportNamespaceSpecifier=function(){var t=this.startNode();return this.next(),this.expectContextual("as"),t.local=this.parseIdent(),this.checkLValSimple(t.local,Z),this.finishNode(t,"ImportNamespaceSpecifier")};b.parseImportSpecifiers=function(){var t=[],e=!0;if(this.type===u.name&&(t.push(this.parseImportDefaultSpecifier()),!this.eat(u.comma)))return t;if(this.type===u.star)return t.push(this.parseImportNamespaceSpecifier()),t;for(this.expect(u.braceL);!this.eat(u.braceR);){if(e)e=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;t.push(this.parseImportSpecifier())}return t};b.parseWithClause=function(){var t=[];if(!this.eat(u._with))return t;this.expect(u.braceL);for(var e={},s=!0;!this.eat(u.braceR);){if(s)s=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;var i=this.parseImportAttribute(),n=i.key.type==="Identifier"?i.key.name:i.key.value;le(e,n)&&this.raiseRecoverable(i.key.start,"Duplicate attribute key '"+n+"'"),e[n]=!0,t.push(i)}return t};b.parseImportAttribute=function(){var t=this.startNode();return t.key=this.type===u.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(u.colon),this.type!==u.string&&this.unexpected(),t.value=this.parseExprAtom(),this.finishNode(t,"ImportAttribute")};b.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===u.string){var t=this.parseLiteral(this.value);return Xt.test(t.value)&&this.raise(t.start,"An export name cannot include a lone surrogate."),t}return this.parseIdent(!0)};b.adaptDirectivePrologue=function(t){for(var e=0;e<t.length&&this.isDirectiveCandidate(t[e]);++e)t[e].directive=t[e].expression.raw.slice(1,-1)};b.isDirectiveCandidate=function(t){return this.options.ecmaVersion>=5&&t.type==="ExpressionStatement"&&t.expression.type==="Literal"&&typeof t.expression.value=="string"&&(this.input[t.start]==='"'||this.input[t.start]==="'")};var W=N.prototype;W.toAssignable=function(t,e,s){if(this.options.ecmaVersion>=6&&t)switch(t.type){case"Identifier":this.inAsync&&t.name==="await"&&this.raise(t.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",s&&this.checkPatternErrors(s,!0);for(var i=0,n=t.properties;i<n.length;i+=1){var r=n[i];this.toAssignable(r,e),r.type==="RestElement"&&(r.argument.type==="ArrayPattern"||r.argument.type==="ObjectPattern")&&this.raise(r.argument.start,"Unexpected token")}break;case"Property":t.kind!=="init"&&this.raise(t.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(t.value,e);break;case"ArrayExpression":t.type="ArrayPattern",s&&this.checkPatternErrors(s,!0),this.toAssignableList(t.elements,e);break;case"SpreadElement":t.type="RestElement",this.toAssignable(t.argument,e),t.argument.type==="AssignmentPattern"&&this.raise(t.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":t.operator!=="="&&this.raise(t.left.end,"Only '=' operator can be used for specifying default value."),t.type="AssignmentPattern",delete t.operator,this.toAssignable(t.left,e);break;case"ParenthesizedExpression":this.toAssignable(t.expression,e,s);break;case"ChainExpression":this.raiseRecoverable(t.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!e)break;default:this.raise(t.start,"Assigning to rvalue")}else s&&this.checkPatternErrors(s,!0);return t};W.toAssignableList=function(t,e){for(var s=t.length,i=0;i<s;i++){var n=t[i];n&&this.toAssignable(n,e)}if(s){var r=t[s-1];this.options.ecmaVersion===6&&e&&r&&r.type==="RestElement"&&r.argument.type!=="Identifier"&&this.unexpected(r.argument.start)}return t};W.parseSpread=function(t){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,t),this.finishNode(e,"SpreadElement")};W.parseRestBinding=function(){var t=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==u.name&&this.unexpected(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")};W.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case u.bracketL:var t=this.startNode();return this.next(),t.elements=this.parseBindingList(u.bracketR,!0,!0),this.finishNode(t,"ArrayPattern");case u.braceL:return this.parseObj(!0)}return this.parseIdent()};W.parseBindingList=function(t,e,s,i){for(var n=[],r=!0;!this.eat(t);)if(r?r=!1:this.expect(u.comma),e&&this.type===u.comma)n.push(null);else{if(s&&this.afterTrailingComma(t))break;if(this.type===u.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),n.push(a),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(t);break}else n.push(this.parseAssignableListItem(i))}return n};W.parseAssignableListItem=function(t){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};W.parseBindingListItem=function(t){return t};W.parseMaybeDefault=function(t,e,s){if(s=s||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(u.eq))return s;var i=this.startNodeAt(t,e);return i.left=s,i.right=this.parseMaybeAssign(),this.finishNode(i,"AssignmentPattern")};W.checkLValSimple=function(t,e,s){e===void 0&&(e=ye);var i=e!==ye;switch(t.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(t.name)&&this.raiseRecoverable(t.start,(i?"Binding ":"Assigning to ")+t.name+" in strict mode"),i&&(e===Z&&t.name==="let"&&this.raiseRecoverable(t.start,"let is disallowed as a lexically bound name"),s&&(le(s,t.name)&&this.raiseRecoverable(t.start,"Argument name clash"),s[t.name]=!0),e!==pt&&this.declareName(t.name,e,t.start));break;case"ChainExpression":this.raiseRecoverable(t.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":i&&this.raiseRecoverable(t.start,"Binding member expression");break;case"ParenthesizedExpression":return i&&this.raiseRecoverable(t.start,"Binding parenthesized expression"),this.checkLValSimple(t.expression,e,s);default:this.raise(t.start,(i?"Binding":"Assigning to")+" rvalue")}};W.checkLValPattern=function(t,e,s){switch(e===void 0&&(e=ye),t.type){case"ObjectPattern":for(var i=0,n=t.properties;i<n.length;i+=1){var r=n[i];this.checkLValInnerPattern(r,e,s)}break;case"ArrayPattern":for(var a=0,o=t.elements;a<o.length;a+=1){var c=o[a];c&&this.checkLValInnerPattern(c,e,s)}break;default:this.checkLValSimple(t,e,s)}};W.checkLValInnerPattern=function(t,e,s){switch(e===void 0&&(e=ye),t.type){case"Property":this.checkLValInnerPattern(t.value,e,s);break;case"AssignmentPattern":this.checkLValPattern(t.left,e,s);break;case"RestElement":this.checkLValPattern(t.argument,e,s);break;default:this.checkLValPattern(t,e,s)}};var H=function(e,s,i,n,r){this.token=e,this.isExpr=!!s,this.preserveSpace=!!i,this.override=n,this.generator=!!r},k={b_stat:new H("{",!1),b_expr:new H("{",!0),b_tmpl:new H("${",!1),p_stat:new H("(",!1),p_expr:new H("(",!0),q_tmpl:new H("`",!0,!0,function(t){return t.tryReadTemplateToken()}),f_stat:new H("function",!1),f_expr:new H("function",!0),f_expr_gen:new H("function",!0,!1,null,!0),f_gen:new H("function",!1,!1,null,!0)},pe=N.prototype;pe.initialContext=function(){return[k.b_stat]};pe.curContext=function(){return this.context[this.context.length-1]};pe.braceIsBlock=function(t){var e=this.curContext();return e===k.f_expr||e===k.f_stat?!0:t===u.colon&&(e===k.b_stat||e===k.b_expr)?!e.isExpr:t===u._return||t===u.name&&this.exprAllowed?V.test(this.input.slice(this.lastTokEnd,this.start)):t===u._else||t===u.semi||t===u.eof||t===u.parenR||t===u.arrow?!0:t===u.braceL?e===k.b_stat:t===u._var||t===u._const||t===u.name?!1:!this.exprAllowed};pe.inGeneratorContext=function(){for(var t=this.context.length-1;t>=1;t--){var e=this.context[t];if(e.token==="function")return e.generator}return!1};pe.updateContext=function(t){var e,s=this.type;s.keyword&&t===u.dot?this.exprAllowed=!1:(e=s.updateContext)?e.call(this,t):this.exprAllowed=s.beforeExpr};pe.overrideContext=function(t){this.curContext()!==t&&(this.context[this.context.length-1]=t)};u.parenR.updateContext=u.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var t=this.context.pop();t===k.b_stat&&this.curContext().token==="function"&&(t=this.context.pop()),this.exprAllowed=!t.isExpr};u.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?k.b_stat:k.b_expr),this.exprAllowed=!0};u.dollarBraceL.updateContext=function(){this.context.push(k.b_tmpl),this.exprAllowed=!0};u.parenL.updateContext=function(t){var e=t===u._if||t===u._for||t===u._with||t===u._while;this.context.push(e?k.p_stat:k.p_expr),this.exprAllowed=!0};u.incDec.updateContext=function(){};u._function.updateContext=u._class.updateContext=function(t){t.beforeExpr&&t!==u._else&&!(t===u.semi&&this.curContext()!==k.p_stat)&&!(t===u._return&&V.test(this.input.slice(this.lastTokEnd,this.start)))&&!((t===u.colon||t===u.braceL)&&this.curContext()===k.b_stat)?this.context.push(k.f_expr):this.context.push(k.f_stat),this.exprAllowed=!1};u.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};u.backQuote.updateContext=function(){this.curContext()===k.q_tmpl?this.context.pop():this.context.push(k.q_tmpl),this.exprAllowed=!1};u.star.updateContext=function(t){if(t===u._function){var e=this.context.length-1;this.context[e]===k.f_expr?this.context[e]=k.f_expr_gen:this.context[e]=k.f_gen}this.exprAllowed=!0};u.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&t!==u.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var S=N.prototype;S.checkPropClash=function(t,e,s){if(!(this.options.ecmaVersion>=9&&t.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var i=t.key,n;switch(i.type){case"Identifier":n=i.name;break;case"Literal":n=String(i.value);break;default:return}var r=t.kind;if(this.options.ecmaVersion>=6){n==="__proto__"&&r==="init"&&(e.proto&&(s?s.doubleProto<0&&(s.doubleProto=i.start):this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),e.proto=!0);return}n="$"+n;var a=e[n];if(a){var o;r==="init"?o=this.strict&&a.init||a.get||a.set:o=a.init||a[r],o&&this.raiseRecoverable(i.start,"Redefinition of property")}else a=e[n]={init:!1,get:!1,set:!1};a[r]=!0}};S.parseExpression=function(t,e){var s=this.start,i=this.startLoc,n=this.parseMaybeAssign(t,e);if(this.type===u.comma){var r=this.startNodeAt(s,i);for(r.expressions=[n];this.eat(u.comma);)r.expressions.push(this.parseMaybeAssign(t,e));return this.finishNode(r,"SequenceExpression")}return n};S.parseMaybeAssign=function(t,e,s){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(t);this.exprAllowed=!1}var i=!1,n=-1,r=-1,a=-1;e?(n=e.parenthesizedAssign,r=e.trailingComma,a=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new Pe,i=!0);var o=this.start,c=this.startLoc;(this.type===u.parenL||this.type===u.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=t==="await");var l=this.parseMaybeConditional(t,e);if(s&&(l=s.call(this,l,o,c)),this.type.isAssign){var h=this.startNodeAt(o,c);return h.operator=this.value,this.type===u.eq&&(l=this.toAssignable(l,!1,e)),i||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=l.start&&(e.shorthandAssign=-1),this.type===u.eq?this.checkLValPattern(l):this.checkLValSimple(l),h.left=l,this.next(),h.right=this.parseMaybeAssign(t),a>-1&&(e.doubleProto=a),this.finishNode(h,"AssignmentExpression")}else i&&this.checkExpressionErrors(e,!0);return n>-1&&(e.parenthesizedAssign=n),r>-1&&(e.trailingComma=r),l};S.parseMaybeConditional=function(t,e){var s=this.start,i=this.startLoc,n=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return n;if(this.eat(u.question)){var r=this.startNodeAt(s,i);return r.test=n,r.consequent=this.parseMaybeAssign(),this.expect(u.colon),r.alternate=this.parseMaybeAssign(t),this.finishNode(r,"ConditionalExpression")}return n};S.parseExprOps=function(t,e){var s=this.start,i=this.startLoc,n=this.parseMaybeUnary(e,!1,!1,t);return this.checkExpressionErrors(e)||n.start===s&&n.type==="ArrowFunctionExpression"?n:this.parseExprOp(n,s,i,-1,t)};S.parseExprOp=function(t,e,s,i,n){var r=this.type.binop;if(r!=null&&(!n||this.type!==u._in)&&r>i){var a=this.type===u.logicalOR||this.type===u.logicalAND,o=this.type===u.coalesce;o&&(r=u.logicalAND.binop);var c=this.value;this.next();var l=this.start,h=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,n),l,h,r,n),f=this.buildBinary(e,s,t,p,c,a||o);return(a&&this.type===u.coalesce||o&&(this.type===u.logicalOR||this.type===u.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(f,e,s,i,n)}return t};S.buildBinary=function(t,e,s,i,n,r){i.type==="PrivateIdentifier"&&this.raise(i.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(t,e);return a.left=s,a.operator=n,a.right=i,this.finishNode(a,r?"LogicalExpression":"BinaryExpression")};S.parseMaybeUnary=function(t,e,s,i){var n=this.start,r=this.startLoc,a;if(this.isContextual("await")&&this.canAwait)a=this.parseAwait(i),e=!0;else if(this.type.prefix){var o=this.startNode(),c=this.type===u.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,c,i),this.checkExpressionErrors(t,!0),c?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&dt(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&De(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):e=!0,a=this.finishNode(o,c?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===u.privateId)(i||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),a=this.parsePrivateIdent(),this.type!==u._in&&this.unexpected();else{if(a=this.parseExprSubscripts(t,i),this.checkExpressionErrors(t))return a;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(n,r);l.operator=this.value,l.prefix=!1,l.argument=a,this.checkLValSimple(a),this.next(),a=this.finishNode(l,"UpdateExpression")}}if(!s&&this.eat(u.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(n,r,a,this.parseMaybeUnary(null,!1,!1,i),"**",!1);else return a};function dt(t){return t.type==="Identifier"||t.type==="ParenthesizedExpression"&&dt(t.expression)}function De(t){return t.type==="MemberExpression"&&t.property.type==="PrivateIdentifier"||t.type==="ChainExpression"&&De(t.expression)||t.type==="ParenthesizedExpression"&&De(t.expression)}S.parseExprSubscripts=function(t,e){var s=this.start,i=this.startLoc,n=this.parseExprAtom(t,e);if(n.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return n;var r=this.parseSubscripts(n,s,i,!1,e);return t&&r.type==="MemberExpression"&&(t.parenthesizedAssign>=r.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=r.start&&(t.parenthesizedBind=-1),t.trailingComma>=r.start&&(t.trailingComma=-1)),r};S.parseSubscripts=function(t,e,s,i,n){for(var r=this.options.ecmaVersion>=8&&t.type==="Identifier"&&t.name==="async"&&this.lastTokEnd===t.end&&!this.canInsertSemicolon()&&t.end-t.start===5&&this.potentialArrowAt===t.start,a=!1;;){var o=this.parseSubscript(t,e,s,i,r,a,n);if(o.optional&&(a=!0),o===t||o.type==="ArrowFunctionExpression"){if(a){var c=this.startNodeAt(e,s);c.expression=o,o=this.finishNode(c,"ChainExpression")}return o}t=o}};S.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(u.arrow)};S.parseSubscriptAsyncArrow=function(t,e,s,i){return this.parseArrowExpression(this.startNodeAt(t,e),s,!0,i)};S.parseSubscript=function(t,e,s,i,n,r,a){var o=this.options.ecmaVersion>=11,c=o&&this.eat(u.questionDot);i&&c&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(u.bracketL);if(l||c&&this.type!==u.parenL&&this.type!==u.backQuote||this.eat(u.dot)){var h=this.startNodeAt(e,s);h.object=t,l?(h.property=this.parseExpression(),this.expect(u.bracketR)):this.type===u.privateId&&t.type!=="Super"?h.property=this.parsePrivateIdent():h.property=this.parseIdent(this.options.allowReserved!=="never"),h.computed=!!l,o&&(h.optional=c),t=this.finishNode(h,"MemberExpression")}else if(!i&&this.eat(u.parenL)){var p=new Pe,f=this.yieldPos,m=this.awaitPos,x=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var C=this.parseExprList(u.parenR,this.options.ecmaVersion>=8,!1,p);if(n&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=f,this.awaitPos=m,this.awaitIdentPos=x,this.parseSubscriptAsyncArrow(e,s,C,a);this.checkExpressionErrors(p,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=x||this.awaitIdentPos;var v=this.startNodeAt(e,s);v.callee=t,v.arguments=C,o&&(v.optional=c),t=this.finishNode(v,"CallExpression")}else if(this.type===u.backQuote){(c||r)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var A=this.startNodeAt(e,s);A.tag=t,A.quasi=this.parseTemplate({isTagged:!0}),t=this.finishNode(A,"TaggedTemplateExpression")}return t};S.parseExprAtom=function(t,e,s){this.type===u.slash&&this.readRegexp();var i,n=this.potentialArrowAt===this.start;switch(this.type){case u._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),i=this.startNode(),this.next(),this.type===u.parenL&&!this.allowDirectSuper&&this.raise(i.start,"super() call outside constructor of a subclass"),this.type!==u.dot&&this.type!==u.bracketL&&this.type!==u.parenL&&this.unexpected(),this.finishNode(i,"Super");case u._this:return i=this.startNode(),this.next(),this.finishNode(i,"ThisExpression");case u.name:var r=this.start,a=this.startLoc,o=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&c.name==="async"&&!this.canInsertSemicolon()&&this.eat(u._function))return this.overrideContext(k.f_expr),this.parseFunction(this.startNodeAt(r,a),0,!1,!0,e);if(n&&!this.canInsertSemicolon()){if(this.eat(u.arrow))return this.parseArrowExpression(this.startNodeAt(r,a),[c],!1,e);if(this.options.ecmaVersion>=8&&c.name==="async"&&this.type===u.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(u.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,a),[c],!0,e)}return c;case u.regexp:var l=this.value;return i=this.parseLiteral(l.value),i.regex={pattern:l.pattern,flags:l.flags},i;case u.num:case u.string:return this.parseLiteral(this.value);case u._null:case u._true:case u._false:return i=this.startNode(),i.value=this.type===u._null?null:this.type===u._true,i.raw=this.type.keyword,this.next(),this.finishNode(i,"Literal");case u.parenL:var h=this.start,p=this.parseParenAndDistinguishExpression(n,e);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(t.parenthesizedAssign=h),t.parenthesizedBind<0&&(t.parenthesizedBind=h)),p;case u.bracketL:return i=this.startNode(),this.next(),i.elements=this.parseExprList(u.bracketR,!0,!0,t),this.finishNode(i,"ArrayExpression");case u.braceL:return this.overrideContext(k.b_expr),this.parseObj(!1,t);case u._function:return i=this.startNode(),this.next(),this.parseFunction(i,0);case u._class:return this.parseClass(this.startNode(),!1);case u._new:return this.parseNew();case u.backQuote:return this.parseTemplate();case u._import:return this.options.ecmaVersion>=11?this.parseExprImport(s):this.unexpected();default:return this.parseExprAtomDefault()}};S.parseExprAtomDefault=function(){this.unexpected()};S.parseExprImport=function(t){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===u.parenL&&!t)return this.parseDynamicImport(e);if(this.type===u.dot){var s=this.startNodeAt(e.start,e.loc&&e.loc.start);return s.name="import",e.meta=this.finishNode(s,"Identifier"),this.parseImportMeta(e)}else this.unexpected()};S.parseDynamicImport=function(t){if(this.next(),t.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(u.parenR)?t.options=null:(this.expect(u.comma),this.afterTrailingComma(u.parenR)?t.options=null:(t.options=this.parseMaybeAssign(),this.eat(u.parenR)||(this.expect(u.comma),this.afterTrailingComma(u.parenR)||this.unexpected())));else if(!this.eat(u.parenR)){var e=this.start;this.eat(u.comma)&&this.eat(u.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(t,"ImportExpression")};S.parseImportMeta=function(t){this.next();var e=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!=="meta"&&this.raiseRecoverable(t.property.start,"The only valid meta property for import is 'import.meta'"),e&&this.raiseRecoverable(t.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(t.start,"Cannot use 'import.meta' outside a module"),this.finishNode(t,"MetaProperty")};S.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),e.raw.charCodeAt(e.raw.length-1)===110&&(e.bigint=e.value!=null?e.value.toString():e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};S.parseParenExpression=function(){this.expect(u.parenL);var t=this.parseExpression();return this.expect(u.parenR),t};S.shouldParseArrow=function(t){return!this.canInsertSemicolon()};S.parseParenAndDistinguishExpression=function(t,e){var s=this.start,i=this.startLoc,n,r=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a=this.start,o=this.startLoc,c=[],l=!0,h=!1,p=new Pe,f=this.yieldPos,m=this.awaitPos,x;for(this.yieldPos=0,this.awaitPos=0;this.type!==u.parenR;)if(l?l=!1:this.expect(u.comma),r&&this.afterTrailingComma(u.parenR,!0)){h=!0;break}else if(this.type===u.ellipsis){x=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else c.push(this.parseMaybeAssign(!1,p,this.parseParenItem));var C=this.lastTokEnd,v=this.lastTokEndLoc;if(this.expect(u.parenR),t&&this.shouldParseArrow(c)&&this.eat(u.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=m,this.parseParenArrowList(s,i,c,e);(!c.length||h)&&this.unexpected(this.lastTokStart),x&&this.unexpected(x),this.checkExpressionErrors(p,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,c.length>1?(n=this.startNodeAt(a,o),n.expressions=c,this.finishNodeAt(n,"SequenceExpression",C,v)):n=c[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var A=this.startNodeAt(s,i);return A.expression=n,this.finishNode(A,"ParenthesizedExpression")}else return n};S.parseParenItem=function(t){return t};S.parseParenArrowList=function(t,e,s,i){return this.parseArrowExpression(this.startNodeAt(t,e),s,!1,i)};var es=[];S.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var t=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===u.dot){var e=this.startNodeAt(t.start,t.loc&&t.loc.start);e.name="new",t.meta=this.finishNode(e,"Identifier"),this.next();var s=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!=="target"&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is 'new.target'"),s&&this.raiseRecoverable(t.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(t.start,"'new.target' can only be used in functions and class static block"),this.finishNode(t,"MetaProperty")}var i=this.start,n=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),i,n,!0,!1),this.eat(u.parenL)?t.arguments=this.parseExprList(u.parenR,this.options.ecmaVersion>=8,!1):t.arguments=es,this.finishNode(t,"NewExpression")};S.parseTemplateElement=function(t){var e=t.isTagged,s=this.startNode();return this.type===u.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),s.value={raw:this.value.replace(/\r\n?/g,`
|
|
4
|
-
`),cooked:null}):
|
|
5
|
-
`),cooked:this.value},this.next(),s.tail=this.type===u.backQuote,this.finishNode(s,"TemplateElement")};S.parseTemplate=function(t){t===void 0&&(t={});var e=t.isTagged;e===void 0&&(e=!1);var s=this.startNode();this.next(),s.expressions=[];var i=this.parseTemplateElement({isTagged:e});for(s.quasis=[i];!i.tail;)this.type===u.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(u.dollarBraceL),s.expressions.push(this.parseExpression()),this.expect(u.braceR),s.quasis.push(i=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(s,"TemplateLiteral")};S.isAsyncProp=function(t){return!t.computed&&t.key.type==="Identifier"&&t.key.name==="async"&&(this.type===u.name||this.type===u.num||this.type===u.string||this.type===u.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===u.star)&&!V.test(this.input.slice(this.lastTokEnd,this.start))};S.parseObj=function(t,e){var s=this.startNode(),i=!0,n={};for(s.properties=[],this.next();!this.eat(u.braceR);){if(i)i=!1;else if(this.expect(u.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(u.braceR))break;var r=this.parseProperty(t,e);t||this.checkPropClash(r,n,e),s.properties.push(r)}return this.finishNode(s,t?"ObjectPattern":"ObjectExpression")};S.parseProperty=function(t,e){var s=this.startNode(),i,n,r,a;if(this.options.ecmaVersion>=9&&this.eat(u.ellipsis))return t?(s.argument=this.parseIdent(!1),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(s,"RestElement")):(s.argument=this.parseMaybeAssign(!1,e),this.type===u.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(s,"SpreadElement"));this.options.ecmaVersion>=6&&(s.method=!1,s.shorthand=!1,(t||e)&&(r=this.start,a=this.startLoc),t||(i=this.eat(u.star)));var o=this.containsEsc;return this.parsePropertyName(s),!t&&!o&&this.options.ecmaVersion>=8&&!i&&this.isAsyncProp(s)?(n=!0,i=this.options.ecmaVersion>=9&&this.eat(u.star),this.parsePropertyName(s)):n=!1,this.parsePropertyValue(s,t,i,n,r,a,e,o),this.finishNode(s,"Property")};S.parseGetterSetter=function(t){var e=t.key.name;this.parsePropertyName(t),t.value=this.parseMethod(!1),t.kind=e;var s=t.kind==="get"?0:1;if(t.value.params.length!==s){var i=t.value.start;t.kind==="get"?this.raiseRecoverable(i,"getter should have no params"):this.raiseRecoverable(i,"setter should have exactly one param")}else t.kind==="set"&&t.value.params[0].type==="RestElement"&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")};S.parsePropertyValue=function(t,e,s,i,n,r,a,o){(s||i)&&this.type===u.colon&&this.unexpected(),this.eat(u.colon)?(t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),t.kind="init"):this.options.ecmaVersion>=6&&this.type===u.parenL?(e&&this.unexpected(),t.method=!0,t.value=this.parseMethod(s,i),t.kind="init"):!e&&!o&&this.options.ecmaVersion>=5&&!t.computed&&t.key.type==="Identifier"&&(t.key.name==="get"||t.key.name==="set")&&this.type!==u.comma&&this.type!==u.braceR&&this.type!==u.eq?((s||i)&&this.unexpected(),this.parseGetterSetter(t)):this.options.ecmaVersion>=6&&!t.computed&&t.key.type==="Identifier"?((s||i)&&this.unexpected(),this.checkUnreserved(t.key),t.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=n),e?t.value=this.parseMaybeDefault(n,r,this.copyNode(t.key)):this.type===u.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),t.value=this.parseMaybeDefault(n,r,this.copyNode(t.key))):t.value=this.copyNode(t.key),t.kind="init",t.shorthand=!0):this.unexpected()};S.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(u.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(u.bracketR),t.key;t.computed=!1}return t.key=this.type===u.num||this.type===u.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};S.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)};S.parseMethod=function(t,e,s){var i=this.startNode(),n=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(i),this.options.ecmaVersion>=6&&(i.generator=t),this.options.ecmaVersion>=8&&(i.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ue(e,i.generator)|Te|(s?ut:0)),this.expect(u.parenL),i.params=this.parseBindingList(u.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(i,!1,!0,!1),this.yieldPos=n,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(i,"FunctionExpression")};S.parseArrowExpression=function(t,e,s,i){var n=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(Ue(s,!1)|je),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!s),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0,!1,i),this.yieldPos=n,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(t,"ArrowFunctionExpression")};S.parseFunctionBody=function(t,e,s,i){var n=e&&this.type!==u.braceL,r=this.strict,a=!1;if(n)t.body=this.parseMaybeAssign(i),t.expression=!0,this.checkParams(t,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);(!r||o)&&(a=this.strictDirective(this.end),a&&o&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var c=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(t,!r&&!a&&!e&&!s&&this.isSimpleParamList(t.params)),this.strict&&t.id&&this.checkLValSimple(t.id,pt),t.body=this.parseBlock(!1,void 0,a&&!r),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=c}this.exitScope()};S.isSimpleParamList=function(t){for(var e=0,s=t;e<s.length;e+=1){var i=s[e];if(i.type!=="Identifier")return!1}return!0};S.checkParams=function(t,e){for(var s=Object.create(null),i=0,n=t.params;i<n.length;i+=1){var r=n[i];this.checkLValInnerPattern(r,He,e?null:s)}};S.parseExprList=function(t,e,s,i){for(var n=[],r=!0;!this.eat(t);){if(r)r=!1;else if(this.expect(u.comma),e&&this.afterTrailingComma(t))break;var a=void 0;s&&this.type===u.comma?a=null:this.type===u.ellipsis?(a=this.parseSpread(i),i&&this.type===u.comma&&i.trailingComma<0&&(i.trailingComma=this.start)):a=this.parseMaybeAssign(!1,i),n.push(a)}return n};S.checkUnreserved=function(t){var e=t.start,s=t.end,i=t.name;if(this.inGenerator&&i==="yield"&&this.raiseRecoverable(e,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&i==="await"&&this.raiseRecoverable(e,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&_e)&&i==="arguments"&&this.raiseRecoverable(e,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(i==="arguments"||i==="await")&&this.raise(e,"Cannot use "+i+" in class static initialization block"),this.keywords.test(i)&&this.raise(e,"Unexpected keyword '"+i+"'"),!(this.options.ecmaVersion<6&&this.input.slice(e,s).indexOf("\\")!==-1)){var n=this.strict?this.reservedWordsStrict:this.reservedWords;n.test(i)&&(!this.inAsync&&i==="await"&&this.raiseRecoverable(e,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(e,"The keyword '"+i+"' is reserved"))}};S.parseIdent=function(t){var e=this.parseIdentNode();return this.next(!!t),this.finishNode(e,"Identifier"),t||(this.checkUnreserved(e),e.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=e.start)),e};S.parseIdentNode=function(){var t=this.startNode();return this.type===u.name?t.name=this.value:this.type.keyword?(t.name=this.type.keyword,(t.name==="class"||t.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=u.name):this.unexpected(),t};S.parsePrivateIdent=function(){var t=this.startNode();return this.type===u.privateId?t.name=this.value:this.unexpected(),this.next(),this.finishNode(t,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(t.start,"Private field '#"+t.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(t)),t};S.parseYield=function(t){this.yieldPos||(this.yieldPos=this.start);var e=this.startNode();return this.next(),this.type===u.semi||this.canInsertSemicolon()||this.type!==u.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(u.star),e.argument=this.parseMaybeAssign(t)),this.finishNode(e,"YieldExpression")};S.parseAwait=function(t){this.awaitPos||(this.awaitPos=this.start);var e=this.startNode();return this.next(),e.argument=this.parseMaybeUnary(null,!0,!1,t),this.finishNode(e,"AwaitExpression")};var Se=N.prototype;Se.raise=function(t,e){var s=at(this.input,t);e+=" ("+s.line+":"+s.column+")",this.sourceFile&&(e+=" in "+this.sourceFile);var i=new SyntaxError(e);throw i.pos=t,i.loc=s,i.raisedAt=this.pos,i};Se.raiseRecoverable=Se.raise;Se.curPosition=function(){if(this.options.locations)return new me(this.curLine,this.pos-this.lineStart)};var ee=N.prototype,ts=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};ee.enterScope=function(t){this.scopeStack.push(new ts(t))};ee.exitScope=function(){this.scopeStack.pop()};ee.treatFunctionsAsVarInScope=function(t){return t.flags&he||!this.inModule&&t.flags&ge};ee.declareName=function(t,e,s){var i=!1;if(e===Z){var n=this.currentScope();i=n.lexical.indexOf(t)>-1||n.functions.indexOf(t)>-1||n.var.indexOf(t)>-1,n.lexical.push(t),this.inModule&&n.flags&ge&&delete this.undefinedExports[t]}else if(e===ht){var r=this.currentScope();r.lexical.push(t)}else if(e===lt){var a=this.currentScope();this.treatFunctionsAsVar?i=a.lexical.indexOf(t)>-1:i=a.lexical.indexOf(t)>-1||a.var.indexOf(t)>-1,a.functions.push(t)}else for(var o=this.scopeStack.length-1;o>=0;--o){var c=this.scopeStack[o];if(c.lexical.indexOf(t)>-1&&!(c.flags&ct&&c.lexical[0]===t)||!this.treatFunctionsAsVarInScope(c)&&c.functions.indexOf(t)>-1){i=!0;break}if(c.var.push(t),this.inModule&&c.flags&ge&&delete this.undefinedExports[t],c.flags&_e)break}i&&this.raiseRecoverable(s,"Identifier '"+t+"' has already been declared")};ee.checkLocalExport=function(t){this.scopeStack[0].lexical.indexOf(t.name)===-1&&this.scopeStack[0].var.indexOf(t.name)===-1&&(this.undefinedExports[t.name]=t)};ee.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};ee.currentVarScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(_e|Ee|ne))return e}};ee.currentThisScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(_e|Ee|ne)&&!(e.flags&je))return e}};var ke=function(e,s,i){this.type="",this.start=s,this.end=0,e.options.locations&&(this.loc=new we(e,i)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[s,0])},be=N.prototype;be.startNode=function(){return new ke(this,this.start,this.startLoc)};be.startNodeAt=function(t,e){return new ke(this,t,e)};function mt(t,e,s,i){return t.type=e,t.end=s,this.options.locations&&(t.loc.end=i),this.options.ranges&&(t.range[1]=s),t}be.finishNode=function(t,e){return mt.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)};be.finishNodeAt=function(t,e,s,i){return mt.call(this,t,e,s,i)};be.copyNode=function(t){var e=new ke(this,t.start,this.startLoc);for(var s in t)e[s]=t[s];return e};var ss="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",gt="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",xt=gt+" Extended_Pictographic",Et=xt,bt=Et+" EBase EComp EMod EPres ExtPict",Ct=bt,is=Ct,ns={9:gt,10:xt,11:Et,12:bt,13:Ct,14:is},rs="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",as={9:"",10:"",11:"",12:"",13:"",14:rs},Ye="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",yt="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",vt=yt+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",St=vt+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",At=St+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",wt=At+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",os=wt+" "+ss,cs={9:yt,10:vt,11:St,12:At,13:wt,14:os},Tt={};function us(t){var e=Tt[t]={binary:Y(ns[t]+" "+Ye),binaryOfStrings:Y(as[t]),nonBinary:{General_Category:Y(Ye),Script:Y(cs[t])}};e.nonBinary.Script_Extensions=e.nonBinary.Script,e.nonBinary.gc=e.nonBinary.General_Category,e.nonBinary.sc=e.nonBinary.Script,e.nonBinary.scx=e.nonBinary.Script_Extensions}for(var Oe=0,Je=[9,10,11,12,13,14];Oe<Je.length;Oe+=1){var ls=Je[Oe];us(ls)}var E=N.prototype,Ae=function(e,s){this.parent=e,this.base=s||this};Ae.prototype.separatedFrom=function(e){for(var s=this;s;s=s.parent)for(var i=e;i;i=i.parent)if(s.base===i.base&&s!==i)return!0;return!1};Ae.prototype.sibling=function(){return new Ae(this.parent,this.base)};var K=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=Tt[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};K.prototype.reset=function(e,s,i){var n=i.indexOf("v")!==-1,r=i.indexOf("u")!==-1;this.start=e|0,this.source=s+"",this.flags=i,n&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=r&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=r&&this.parser.options.ecmaVersion>=9)};K.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)};K.prototype.at=function(e,s){s===void 0&&(s=!1);var i=this.source,n=i.length;if(e>=n)return-1;var r=i.charCodeAt(e);if(!(s||this.switchU)||r<=55295||r>=57344||e+1>=n)return r;var a=i.charCodeAt(e+1);return a>=56320&&a<=57343?(r<<10)+a-56613888:r};K.prototype.nextIndex=function(e,s){s===void 0&&(s=!1);var i=this.source,n=i.length;if(e>=n)return n;var r=i.charCodeAt(e),a;return!(s||this.switchU)||r<=55295||r>=57344||e+1>=n||(a=i.charCodeAt(e+1))<56320||a>57343?e+1:e+2};K.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)};K.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)};K.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)};K.prototype.eat=function(e,s){return s===void 0&&(s=!1),this.current(s)===e?(this.advance(s),!0):!1};K.prototype.eatChars=function(e,s){s===void 0&&(s=!1);for(var i=this.pos,n=0,r=e;n<r.length;n+=1){var a=r[n],o=this.at(i,s);if(o===-1||o!==a)return!1;i=this.nextIndex(i,s)}return this.pos=i,!0};E.validateRegExpFlags=function(t){for(var e=t.validFlags,s=t.flags,i=!1,n=!1,r=0;r<s.length;r++){var a=s.charAt(r);e.indexOf(a)===-1&&this.raise(t.start,"Invalid regular expression flag"),s.indexOf(a,r+1)>-1&&this.raise(t.start,"Duplicate regular expression flag"),a==="u"&&(i=!0),a==="v"&&(n=!0)}this.options.ecmaVersion>=15&&i&&n&&this.raise(t.start,"Invalid regular expression flag")};function hs(t){for(var e in t)return!0;return!1}E.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&hs(t.groupNames)&&(t.switchN=!0,this.regexp_pattern(t))};E.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue="",t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames=Object.create(null),t.backReferenceNames.length=0,t.branchID=null,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise("Unmatched ')'"),(t.eat(93)||t.eat(125))&&t.raise("Lone quantifier brackets")),t.maxBackReference>t.numCapturingParens&&t.raise("Invalid escape");for(var e=0,s=t.backReferenceNames;e<s.length;e+=1){var i=s[e];t.groupNames[i]||t.raise("Invalid named capture referenced")}};E.regexp_disjunction=function(t){var e=this.options.ecmaVersion>=16;for(e&&(t.branchID=new Ae(t.branchID,null)),this.regexp_alternative(t);t.eat(124);)e&&(t.branchID=t.branchID.sibling()),this.regexp_alternative(t);e&&(t.branchID=t.branchID.parent),this.regexp_eatQuantifier(t,!0)&&t.raise("Nothing to repeat"),t.eat(123)&&t.raise("Lone quantifier brackets")};E.regexp_alternative=function(t){for(;t.pos<t.source.length&&this.regexp_eatTerm(t););};E.regexp_eatTerm=function(t){return this.regexp_eatAssertion(t)?(t.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(t)&&t.switchU&&t.raise("Invalid quantifier"),!0):(t.switchU?this.regexp_eatAtom(t):this.regexp_eatExtendedAtom(t))?(this.regexp_eatQuantifier(t),!0):!1};E.regexp_eatAssertion=function(t){var e=t.pos;if(t.lastAssertionIsQuantifiable=!1,t.eat(94)||t.eat(36))return!0;if(t.eat(92)){if(t.eat(66)||t.eat(98))return!0;t.pos=e}if(t.eat(40)&&t.eat(63)){var s=!1;if(this.options.ecmaVersion>=9&&(s=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise("Unterminated group"),t.lastAssertionIsQuantifiable=!s,!0}return t.pos=e,!1};E.regexp_eatQuantifier=function(t,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(t,e)?(t.eat(63),!0):!1};E.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)};E.regexp_eatBracedQuantifier=function(t,e){var s=t.pos;if(t.eat(123)){var i=0,n=-1;if(this.regexp_eatDecimalDigits(t)&&(i=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(n=t.lastIntValue),t.eat(125)))return n!==-1&&n<i&&!e&&t.raise("numbers out of order in {} quantifier"),!0;t.switchU&&!e&&t.raise("Incomplete quantifier"),t.pos=s}return!1};E.regexp_eatAtom=function(t){return this.regexp_eatPatternCharacters(t)||t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)};E.regexp_eatReverseSolidusAtomEscape=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatAtomEscape(t))return!0;t.pos=e}return!1};E.regexp_eatUncapturingGroup=function(t){var e=t.pos;if(t.eat(40)){if(t.eat(63)){if(this.options.ecmaVersion>=16){var s=this.regexp_eatModifiers(t),i=t.eat(45);if(s||i){for(var n=0;n<s.length;n++){var r=s.charAt(n);s.indexOf(r,n+1)>-1&&t.raise("Duplicate regular expression modifiers")}if(i){var a=this.regexp_eatModifiers(t);!s&&!a&&t.current()===58&&t.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var c=a.charAt(o);(a.indexOf(c,o+1)>-1||s.indexOf(c)>-1)&&t.raise("Duplicate regular expression modifiers")}}}}if(t.eat(58)){if(this.regexp_disjunction(t),t.eat(41))return!0;t.raise("Unterminated group")}}t.pos=e}return!1};E.regexp_eatCapturingGroup=function(t){if(t.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(t):t.current()===63&&t.raise("Invalid group"),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise("Unterminated group")}return!1};E.regexp_eatModifiers=function(t){for(var e="",s=0;(s=t.current())!==-1&&ps(s);)e+=G(s),t.advance();return e};function ps(t){return t===105||t===109||t===115}E.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)};E.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1};E.regexp_eatSyntaxCharacter=function(t){var e=t.current();return _t(e)?(t.lastIntValue=e,t.advance(),!0):!1};function _t(t){return t===36||t>=40&&t<=43||t===46||t===63||t>=91&&t<=94||t>=123&&t<=125}E.regexp_eatPatternCharacters=function(t){for(var e=t.pos,s=0;(s=t.current())!==-1&&!_t(s);)t.advance();return t.pos!==e};E.regexp_eatExtendedPatternCharacter=function(t){var e=t.current();return e!==-1&&e!==36&&!(e>=40&&e<=43)&&e!==46&&e!==63&&e!==91&&e!==94&&e!==124?(t.advance(),!0):!1};E.regexp_groupSpecifier=function(t){if(t.eat(63)){this.regexp_eatGroupName(t)||t.raise("Invalid group");var e=this.options.ecmaVersion>=16,s=t.groupNames[t.lastStringValue];if(s)if(e)for(var i=0,n=s;i<n.length;i+=1){var r=n[i];r.separatedFrom(t.branchID)||t.raise("Duplicate capture group name")}else t.raise("Duplicate capture group name");e?(s||(t.groupNames[t.lastStringValue]=[])).push(t.branchID):t.groupNames[t.lastStringValue]=!0}};E.regexp_eatGroupName=function(t){if(t.lastStringValue="",t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise("Invalid capture group name")}return!1};E.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=G(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=G(t.lastIntValue);return!0}return!1};E.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,s=this.options.ecmaVersion>=11,i=t.current(s);return t.advance(s),i===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,s)&&(i=t.lastIntValue),fs(i)?(t.lastIntValue=i,!0):(t.pos=e,!1)};function fs(t){return z(t,!0)||t===36||t===95}E.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,s=this.options.ecmaVersion>=11,i=t.current(s);return t.advance(s),i===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,s)&&(i=t.lastIntValue),ds(i)?(t.lastIntValue=i,!0):(t.pos=e,!1)};function ds(t){return J(t,!0)||t===36||t===95||t===8204||t===8205}E.regexp_eatAtomEscape=function(t){return this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t)?!0:(t.switchU&&(t.current()===99&&t.raise("Invalid unicode escape"),t.raise("Invalid escape")),!1)};E.regexp_eatBackReference=function(t){var e=t.pos;if(this.regexp_eatDecimalEscape(t)){var s=t.lastIntValue;if(t.switchU)return s>t.maxBackReference&&(t.maxBackReference=s),!0;if(s<=t.numCapturingParens)return!0;t.pos=e}return!1};E.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1};E.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t,!1)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)};E.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1};E.regexp_eatZero=function(t){return t.current()===48&&!Ie(t.lookahead())?(t.lastIntValue=0,t.advance(),!0):!1};E.regexp_eatControlEscape=function(t){var e=t.current();return e===116?(t.lastIntValue=9,t.advance(),!0):e===110?(t.lastIntValue=10,t.advance(),!0):e===118?(t.lastIntValue=11,t.advance(),!0):e===102?(t.lastIntValue=12,t.advance(),!0):e===114?(t.lastIntValue=13,t.advance(),!0):!1};E.regexp_eatControlLetter=function(t){var e=t.current();return Pt(e)?(t.lastIntValue=e%32,t.advance(),!0):!1};function Pt(t){return t>=65&&t<=90||t>=97&&t<=122}E.regexp_eatRegExpUnicodeEscapeSequence=function(t,e){e===void 0&&(e=!1);var s=t.pos,i=e||t.switchU;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var n=t.lastIntValue;if(i&&n>=55296&&n<=56319){var r=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var a=t.lastIntValue;if(a>=56320&&a<=57343)return t.lastIntValue=(n-55296)*1024+(a-56320)+65536,!0}t.pos=r,t.lastIntValue=n}return!0}if(i&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&ms(t.lastIntValue))return!0;i&&t.raise("Invalid unicode escape"),t.pos=s}return!1};function ms(t){return t>=0&&t<=1114111}E.regexp_eatIdentityEscape=function(t){if(t.switchU)return this.regexp_eatSyntaxCharacter(t)?!0:t.eat(47)?(t.lastIntValue=47,!0):!1;var e=t.current();return e!==99&&(!t.switchN||e!==107)?(t.lastIntValue=e,t.advance(),!0):!1};E.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(e>=49&&e<=57){do t.lastIntValue=10*t.lastIntValue+(e-48),t.advance();while((e=t.current())>=48&&e<=57);return!0}return!1};var kt=0,Q=1,B=2;E.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(gs(e))return t.lastIntValue=-1,t.advance(),Q;var s=!1;if(t.switchU&&this.options.ecmaVersion>=9&&((s=e===80)||e===112)){t.lastIntValue=-1,t.advance();var i;if(t.eat(123)&&(i=this.regexp_eatUnicodePropertyValueExpression(t))&&t.eat(125))return s&&i===B&&t.raise("Invalid property name"),i;t.raise("Invalid property name")}return kt};function gs(t){return t===100||t===68||t===115||t===83||t===119||t===87}E.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var s=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var i=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,s,i),Q}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var n=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,n)}return kt};E.regexp_validateUnicodePropertyNameAndValue=function(t,e,s){le(t.unicodeProperties.nonBinary,e)||t.raise("Invalid property name"),t.unicodeProperties.nonBinary[e].test(s)||t.raise("Invalid property value")};E.regexp_validateUnicodePropertyNameOrValue=function(t,e){if(t.unicodeProperties.binary.test(e))return Q;if(t.switchV&&t.unicodeProperties.binaryOfStrings.test(e))return B;t.raise("Invalid property name")};E.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";It(e=t.current());)t.lastStringValue+=G(e),t.advance();return t.lastStringValue!==""};function It(t){return Pt(t)||t===95}E.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";xs(e=t.current());)t.lastStringValue+=G(e),t.advance();return t.lastStringValue!==""};function xs(t){return It(t)||Ie(t)}E.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)};E.regexp_eatCharacterClass=function(t){if(t.eat(91)){var e=t.eat(94),s=this.regexp_classContents(t);return t.eat(93)||t.raise("Unterminated character class"),e&&s===B&&t.raise("Negated character class may contain strings"),!0}return!1};E.regexp_classContents=function(t){return t.current()===93?Q:t.switchV?this.regexp_classSetExpression(t):(this.regexp_nonEmptyClassRanges(t),Q)};E.regexp_nonEmptyClassRanges=function(t){for(;this.regexp_eatClassAtom(t);){var e=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassAtom(t)){var s=t.lastIntValue;t.switchU&&(e===-1||s===-1)&&t.raise("Invalid character class"),e!==-1&&s!==-1&&e>s&&t.raise("Range out of order in character class")}}};E.regexp_eatClassAtom=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var s=t.current();(s===99||Rt(s))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var i=t.current();return i!==93?(t.lastIntValue=i,t.advance(),!0):!1};E.regexp_eatClassEscape=function(t){var e=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=e}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)};E.regexp_classSetExpression=function(t){var e=Q,s;if(!this.regexp_eatClassSetRange(t))if(s=this.regexp_eatClassSetOperand(t)){s===B&&(e=B);for(var i=t.pos;t.eatChars([38,38]);){if(t.current()!==38&&(s=this.regexp_eatClassSetOperand(t))){s!==B&&(e=Q);continue}t.raise("Invalid character in character class")}if(i!==t.pos)return e;for(;t.eatChars([45,45]);)this.regexp_eatClassSetOperand(t)||t.raise("Invalid character in character class");if(i!==t.pos)return e}else t.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(t)){if(s=this.regexp_eatClassSetOperand(t),!s)return e;s===B&&(e=B)}};E.regexp_eatClassSetRange=function(t){var e=t.pos;if(this.regexp_eatClassSetCharacter(t)){var s=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassSetCharacter(t)){var i=t.lastIntValue;return s!==-1&&i!==-1&&s>i&&t.raise("Range out of order in character class"),!0}t.pos=e}return!1};E.regexp_eatClassSetOperand=function(t){return this.regexp_eatClassSetCharacter(t)?Q:this.regexp_eatClassStringDisjunction(t)||this.regexp_eatNestedClass(t)};E.regexp_eatNestedClass=function(t){var e=t.pos;if(t.eat(91)){var s=t.eat(94),i=this.regexp_classContents(t);if(t.eat(93))return s&&i===B&&t.raise("Negated character class may contain strings"),i;t.pos=e}if(t.eat(92)){var n=this.regexp_eatCharacterClassEscape(t);if(n)return n;t.pos=e}return null};E.regexp_eatClassStringDisjunction=function(t){var e=t.pos;if(t.eatChars([92,113])){if(t.eat(123)){var s=this.regexp_classStringDisjunctionContents(t);if(t.eat(125))return s}else t.raise("Invalid escape");t.pos=e}return null};E.regexp_classStringDisjunctionContents=function(t){for(var e=this.regexp_classString(t);t.eat(124);)this.regexp_classString(t)===B&&(e=B);return e};E.regexp_classString=function(t){for(var e=0;this.regexp_eatClassSetCharacter(t);)e++;return e===1?Q:B};E.regexp_eatClassSetCharacter=function(t){var e=t.pos;if(t.eat(92))return this.regexp_eatCharacterEscape(t)||this.regexp_eatClassSetReservedPunctuator(t)?!0:t.eat(98)?(t.lastIntValue=8,!0):(t.pos=e,!1);var s=t.current();return s<0||s===t.lookahead()&&Es(s)||bs(s)?!1:(t.advance(),t.lastIntValue=s,!0)};function Es(t){return t===33||t>=35&&t<=38||t>=42&&t<=44||t===46||t>=58&&t<=64||t===94||t===96||t===126}function bs(t){return t===40||t===41||t===45||t===47||t>=91&&t<=93||t>=123&&t<=125}E.regexp_eatClassSetReservedPunctuator=function(t){var e=t.current();return Cs(e)?(t.lastIntValue=e,t.advance(),!0):!1};function Cs(t){return t===33||t===35||t===37||t===38||t===44||t===45||t>=58&&t<=62||t===64||t===96||t===126}E.regexp_eatClassControlLetter=function(t){var e=t.current();return Ie(e)||e===95?(t.lastIntValue=e%32,t.advance(),!0):!1};E.regexp_eatHexEscapeSequence=function(t){var e=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise("Invalid escape"),t.pos=e}return!1};E.regexp_eatDecimalDigits=function(t){var e=t.pos,s=0;for(t.lastIntValue=0;Ie(s=t.current());)t.lastIntValue=10*t.lastIntValue+(s-48),t.advance();return t.pos!==e};function Ie(t){return t>=48&&t<=57}E.regexp_eatHexDigits=function(t){var e=t.pos,s=0;for(t.lastIntValue=0;Nt(s=t.current());)t.lastIntValue=16*t.lastIntValue+Mt(s),t.advance();return t.pos!==e};function Nt(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function Mt(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}E.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var e=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var s=t.lastIntValue;e<=3&&this.regexp_eatOctalDigit(t)?t.lastIntValue=e*64+s*8+t.lastIntValue:t.lastIntValue=e*8+s}else t.lastIntValue=e;return!0}return!1};E.regexp_eatOctalDigit=function(t){var e=t.current();return Rt(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)};function Rt(t){return t>=48&&t<=55}E.regexp_eatFixedHexDigits=function(t,e){var s=t.pos;t.lastIntValue=0;for(var i=0;i<e;++i){var n=t.current();if(!Nt(n))return t.pos=s,!1;t.lastIntValue=16*t.lastIntValue+Mt(n),t.advance()}return!0};var ze=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new we(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},w=N.prototype;w.next=function(t){!t&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new ze(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};w.getToken=function(){return this.next(),new ze(this)};typeof Symbol<"u"&&(w[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===u.eof,value:e}}}});w.nextToken=function(){var t=this.curContext();if((!t||!t.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(u.eof);if(t.override)return t.override(this);this.readToken(this.fullCharCodeAtPos())};w.readToken=function(t){return z(t,this.options.ecmaVersion>=6)||t===92?this.readWord():this.getTokenFromCode(t)};w.fullCharCodeAtPos=function(){var t=this.input.charCodeAt(this.pos);if(t<=55295||t>=56320)return t;var e=this.input.charCodeAt(this.pos+1);return e<=56319||e>=57344?t:(t<<10)+e-56613888};w.skipBlockComment=function(){var t=this.options.onComment&&this.curPosition(),e=this.pos,s=this.input.indexOf("*/",this.pos+=2);if(s===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=s+2,this.options.locations)for(var i=void 0,n=e;(i=it(this.input,n,this.pos))>-1;)++this.curLine,n=this.lineStart=i;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,s),e,this.pos,t,this.curPosition())};w.skipLineComment=function(t){for(var e=this.pos,s=this.options.onComment&&this.curPosition(),i=this.input.charCodeAt(this.pos+=t);this.pos<this.input.length&&!ue(i);)i=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(e+t,this.pos),e,this.pos,s,this.curPosition())};w.skipSpace=function(){e:for(;this.pos<this.input.length;){var t=this.input.charCodeAt(this.pos);switch(t){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 e}break;default:if(t>8&&t<14||t>=5760&&nt.test(String.fromCharCode(t)))++this.pos;else break e}}};w.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var s=this.type;this.type=t,this.value=e,this.updateContext(s)};w.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&t===46&&e===46?(this.pos+=3,this.finishToken(u.ellipsis)):(++this.pos,this.finishToken(u.dot))};w.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):t===61?this.finishOp(u.assign,2):this.finishOp(u.slash,1)};w.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),s=1,i=t===42?u.star:u.modulo;return this.options.ecmaVersion>=7&&t===42&&e===42&&(++s,i=u.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(u.assign,s+1):this.finishOp(i,s)};w.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);if(e===t){if(this.options.ecmaVersion>=12){var s=this.input.charCodeAt(this.pos+2);if(s===61)return this.finishOp(u.assign,3)}return this.finishOp(t===124?u.logicalOR:u.logicalAND,2)}return e===61?this.finishOp(u.assign,2):this.finishOp(t===124?u.bitwiseOR:u.bitwiseAND,1)};w.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(u.assign,2):this.finishOp(u.bitwiseXOR,1)};w.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?e===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||V.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(u.incDec,2):e===61?this.finishOp(u.assign,2):this.finishOp(u.plusMin,1)};w.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),s=1;return e===t?(s=t===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+s)===61?this.finishOp(u.assign,s+1):this.finishOp(u.bitShift,s)):e===33&&t===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(e===61&&(s=2),this.finishOp(u.relational,s))};w.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(u.equality,this.input.charCodeAt(this.pos+2)===61?3:2):t===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(u.arrow)):this.finishOp(t===61?u.eq:u.prefix,1)};w.readToken_question=function(){var t=this.options.ecmaVersion;if(t>=11){var e=this.input.charCodeAt(this.pos+1);if(e===46){var s=this.input.charCodeAt(this.pos+2);if(s<48||s>57)return this.finishOp(u.questionDot,2)}if(e===63){if(t>=12){var i=this.input.charCodeAt(this.pos+2);if(i===61)return this.finishOp(u.assign,3)}return this.finishOp(u.coalesce,2)}}return this.finishOp(u.question,1)};w.readToken_numberSign=function(){var t=this.options.ecmaVersion,e=35;if(t>=13&&(++this.pos,e=this.fullCharCodeAtPos(),z(e,!0)||e===92))return this.finishToken(u.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+G(e)+"'")};w.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(u.parenL);case 41:return++this.pos,this.finishToken(u.parenR);case 59:return++this.pos,this.finishToken(u.semi);case 44:return++this.pos,this.finishToken(u.comma);case 91:return++this.pos,this.finishToken(u.bracketL);case 93:return++this.pos,this.finishToken(u.bracketR);case 123:return++this.pos,this.finishToken(u.braceL);case 125:return++this.pos,this.finishToken(u.braceR);case 58:return++this.pos,this.finishToken(u.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(u.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(e===120||e===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(e===111||e===79)return this.readRadixNumber(8);if(e===98||e===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(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 63:return this.readToken_question();case 126:return this.finishOp(u.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+G(t)+"'")};w.finishOp=function(t,e){var s=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,s)};w.readRegexp=function(){for(var t,e,s=this.pos;;){this.pos>=this.input.length&&this.raise(s,"Unterminated regular expression");var i=this.input.charAt(this.pos);if(V.test(i)&&this.raise(s,"Unterminated regular expression"),t)t=!1;else{if(i==="[")e=!0;else if(i==="]"&&e)e=!1;else if(i==="/"&&!e)break;t=i==="\\"}++this.pos}var n=this.input.slice(s,this.pos);++this.pos;var r=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(r);var o=this.regexpState||(this.regexpState=new K(this));o.reset(s,n,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var c=null;try{c=new RegExp(n,a)}catch{}return this.finishToken(u.regexp,{pattern:n,flags:a,value:c})};w.readInt=function(t,e,s){for(var i=this.options.ecmaVersion>=12&&e===void 0,n=s&&this.input.charCodeAt(this.pos)===48,r=this.pos,a=0,o=0,c=0,l=e??1/0;c<l;++c,++this.pos){var h=this.input.charCodeAt(this.pos),p=void 0;if(i&&h===95){n&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===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"),o=h;continue}if(h>=97?p=h-97+10:h>=65?p=h-65+10:h>=48&&h<=57?p=h-48:p=1/0,p>=t)break;o=h,a=a*t+p}return i&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===r||e!=null&&this.pos-r!==e?null:a};function ys(t,e){return e?parseInt(t,8):parseFloat(t.replace(/_/g,""))}function Ot(t){return typeof BigInt!="function"?null:BigInt(t.replace(/_/g,""))}w.readRadixNumber=function(t){var e=this.pos;this.pos+=2;var s=this.readInt(t);return s==null&&this.raise(this.start+2,"Expected number in radix "+t),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(s=Ot(this.input.slice(e,this.pos)),++this.pos):z(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(u.num,s)};w.readNumber=function(t){var e=this.pos;!t&&this.readInt(10,void 0,!0)===null&&this.raise(e,"Invalid number");var s=this.pos-e>=2&&this.input.charCodeAt(e)===48;s&&this.strict&&this.raise(e,"Invalid number");var i=this.input.charCodeAt(this.pos);if(!s&&!t&&this.options.ecmaVersion>=11&&i===110){var n=Ot(this.input.slice(e,this.pos));return++this.pos,z(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(u.num,n)}s&&/[89]/.test(this.input.slice(e,this.pos))&&(s=!1),i===46&&!s&&(++this.pos,this.readInt(10),i=this.input.charCodeAt(this.pos)),(i===69||i===101)&&!s&&(i=this.input.charCodeAt(++this.pos),(i===43||i===45)&&++this.pos,this.readInt(10)===null&&this.raise(e,"Invalid number")),z(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var r=ys(this.input.slice(e,this.pos),s);return this.finishToken(u.num,r)};w.readCodePoint=function(){var t=this.input.charCodeAt(this.pos),e;if(t===123){this.options.ecmaVersion<6&&this.unexpected();var s=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(s,"Code point out of bounds")}else e=this.readHexChar(4);return e};w.readString=function(t){for(var e="",s=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var i=this.input.charCodeAt(this.pos);if(i===t)break;i===92?(e+=this.input.slice(s,this.pos),e+=this.readEscapedChar(!1),s=this.pos):i===8232||i===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(ue(i)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(s,this.pos++),this.finishToken(u.string,e)};var Lt={};w.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t===Lt)this.readInvalidTemplateToken();else throw t}this.inTemplateElement=!1};w.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Lt;this.raise(t,e)};w.readTmplToken=function(){for(var t="",e=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var s=this.input.charCodeAt(this.pos);if(s===96||s===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===u.template||this.type===u.invalidTemplate)?s===36?(this.pos+=2,this.finishToken(u.dollarBraceL)):(++this.pos,this.finishToken(u.backQuote)):(t+=this.input.slice(e,this.pos),this.finishToken(u.template,t));if(s===92)t+=this.input.slice(e,this.pos),t+=this.readEscapedChar(!0),e=this.pos;else if(ue(s)){switch(t+=this.input.slice(e,this.pos),++this.pos,s){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:t+=`
|
|
6
|
-
`;break;default:
|
|
1
|
+
var $t=[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,80,3,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,343,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,330,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,726,6,110,6,6,9,4759,9,787719,239],it=[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,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,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,328,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,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],jt="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",nt="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Oe={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"},Le="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",Wt={5:Le,"5module":Le+" export import",6:Le+" const class extends export import super"},Ut=/^in(stanceof)?$/,Ht=new RegExp("["+nt+"]"),qt=new RegExp("["+nt+jt+"]");function Ve(s,e){for(var t=65536,i=0;i<e.length;i+=2){if(t+=e[i],t>s)return!1;if(t+=e[i+1],t>=s)return!0}return!1}function K(s,e){return s<65?s===36:s<91?!0:s<97?s===95:s<123?!0:s<=65535?s>=170&&Ht.test(String.fromCharCode(s)):e===!1?!1:Ve(s,it)}function te(s,e){return s<48?s===36:s<58?!0:s<65?!1:s<91?!0:s<97?s===95:s<123?!0:s<=65535?s>=170&&qt.test(String.fromCharCode(s)):e===!1?!1:Ve(s,it)||Ve(s,$t)}var P=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 B(s,e){return new P(s,{beforeExpr:!0,binop:e})}var $={beforeExpr:!0},F={startsExpr:!0},We={};function w(s,e){return e===void 0&&(e={}),e.keyword=s,We[s]=new P(s,e)}var u={num:new P("num",F),regexp:new P("regexp",F),string:new P("string",F),name:new P("name",F),privateId:new P("privateId",F),eof:new P("eof"),bracketL:new P("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new P("]"),braceL:new P("{",{beforeExpr:!0,startsExpr:!0}),braceR:new P("}"),parenL:new P("(",{beforeExpr:!0,startsExpr:!0}),parenR:new P(")"),comma:new P(",",$),semi:new P(";",$),colon:new P(":",$),dot:new P("."),question:new P("?",$),questionDot:new P("?."),arrow:new P("=>",$),template:new P("template"),invalidTemplate:new P("invalidTemplate"),ellipsis:new P("...",$),backQuote:new P("`",F),dollarBraceL:new P("${",{beforeExpr:!0,startsExpr:!0}),eq:new P("=",{beforeExpr:!0,isAssign:!0}),assign:new P("_=",{beforeExpr:!0,isAssign:!0}),incDec:new P("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new P("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:B("||",1),logicalAND:B("&&",2),bitwiseOR:B("|",3),bitwiseXOR:B("^",4),bitwiseAND:B("&",5),equality:B("==/!=/===/!==",6),relational:B("</>/<=/>=",7),bitShift:B("<</>>/>>>",8),plusMin:new P("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:B("%",10),star:B("*",10),slash:B("/",10),starstar:new P("**",{beforeExpr:!0}),coalesce:B("??",1),_break:w("break"),_case:w("case",$),_catch:w("catch"),_continue:w("continue"),_debugger:w("debugger"),_default:w("default",$),_do:w("do",{isLoop:!0,beforeExpr:!0}),_else:w("else",$),_finally:w("finally"),_for:w("for",{isLoop:!0}),_function:w("function",F),_if:w("if"),_return:w("return",$),_switch:w("switch"),_throw:w("throw",$),_try:w("try"),_var:w("var"),_const:w("const"),_while:w("while",{isLoop:!0}),_with:w("with"),_new:w("new",{beforeExpr:!0,startsExpr:!0}),_this:w("this",F),_super:w("super",F),_class:w("class",F),_extends:w("extends",$),_export:w("export"),_import:w("import",F),_null:w("null",F),_true:w("true",F),_false:w("false",F),_in:w("in",{beforeExpr:!0,binop:7}),_instanceof:w("instanceof",{beforeExpr:!0,binop:7}),_typeof:w("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:w("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:w("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},D=/\r\n?|\n|\u2028|\u2029/,Xt=new RegExp(D.source,"g");function pe(s){return s===10||s===13||s===8232||s===8233}function rt(s,e,t){t===void 0&&(t=s.length);for(var i=e;i<t;i++){var n=s.charCodeAt(i);if(pe(n))return i<t-1&&n===13&&s.charCodeAt(i+1)===10?i+2:i+1}return-1}var at=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,R=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ot=Object.prototype,zt=ot.hasOwnProperty,Kt=ot.toString,he=Object.hasOwn||(function(s,e){return zt.call(s,e)}),Ze=Array.isArray||(function(s){return Kt.call(s)==="[object Array]"}),Ye=Object.create(null);function ee(s){return Ye[s]||(Ye[s]=new RegExp("^(?:"+s.replace(/ /g,"|")+")$"))}function Z(s){return s<=65535?String.fromCharCode(s):(s-=65536,String.fromCharCode((s>>10)+55296,(s&1023)+56320))}var Gt=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,ge=function(e,t){this.line=e,this.column=t};ge.prototype.offset=function(e){return new ge(this.line,this.column+e)};var we=function(e,t,i){this.start=t,this.end=i,e.sourceFile!==null&&(this.source=e.sourceFile)};function ct(s,e){for(var t=1,i=0;;){var n=rt(s,i,e);if(n<0)return new ge(t,e-i);++t,i=n}}var De={ecmaVersion:null,sourceType:"script",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},Je=!1;function Qt(s){var e={};for(var t in De)e[t]=s&&he(s,t)?s[t]:De[t];if(e.ecmaVersion==="latest"?e.ecmaVersion=1e8:e.ecmaVersion==null?(!Je&&typeof console=="object"&&console.warn&&(Je=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
2
|
+
Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=11):e.ecmaVersion>=2015&&(e.ecmaVersion-=2009),e.allowReserved==null&&(e.allowReserved=e.ecmaVersion<5),(!s||s.allowHashBang==null)&&(e.allowHashBang=e.ecmaVersion>=14),Ze(e.onToken)){var i=e.onToken;e.onToken=function(n){return i.push(n)}}return Ze(e.onComment)&&(e.onComment=Zt(e,e.onComment)),e}function Zt(s,e){return function(t,i,n,r,a,o){var c={type:t?"Block":"Line",value:i,start:n,end:r};s.locations&&(c.loc=new we(this,a,o)),s.ranges&&(c.range=[n,r]),e.push(c)}}var xe=1,fe=2,Ue=4,ut=8,He=16,lt=32,Pe=64,pt=128,ae=256,be=512,_e=xe|fe|ae;function qe(s,e){return fe|(s?Ue:0)|(e?ut:0)}var ve=0,Xe=1,J=2,ht=3,ft=4,dt=5,M=function(e,t,i){this.options=e=Qt(e),this.sourceFile=e.sourceFile,this.keywords=ee(Wt[e.ecmaVersion>=6?6:e.sourceType==="module"?"5module":5]);var n="";e.allowReserved!==!0&&(n=Oe[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType==="module"&&(n+=" await")),this.reservedWords=ee(n);var r=(n?n+" ":"")+Oe.strict;this.reservedWordsStrict=ee(r),this.reservedWordsStrictBind=ee(r+" "+Oe.strictBind),this.input=String(t),this.containsEsc=!1,i?(this.pos=i,this.lineStart=this.input.lastIndexOf(`
|
|
3
|
+
`,i-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(D).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=u.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||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(xe),this.regexpState=null,this.privateNameStack=[]},G={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};M.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};G.inFunction.get=function(){return(this.currentVarScope().flags&fe)>0};G.inGenerator.get=function(){return(this.currentVarScope().flags&ut)>0};G.inAsync.get=function(){return(this.currentVarScope().flags&Ue)>0};G.canAwait.get=function(){for(var s=this.scopeStack.length-1;s>=0;s--){var e=this.scopeStack[s],t=e.flags;if(t&(ae|be))return!1;if(t&fe)return(t&Ue)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};G.allowSuper.get=function(){var s=this.currentThisScope(),e=s.flags;return(e&Pe)>0||this.options.allowSuperOutsideMethod};G.allowDirectSuper.get=function(){return(this.currentThisScope().flags&pt)>0};G.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};G.allowNewDotTarget.get=function(){for(var s=this.scopeStack.length-1;s>=0;s--){var e=this.scopeStack[s],t=e.flags;if(t&(ae|be)||t&fe&&!(t&He))return!0}return!1};G.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&ae)>0};M.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var i=this,n=0;n<e.length;n++)i=e[n](i);return i};M.parse=function(e,t){return new this(t,e).parse()};M.parseExpressionAt=function(e,t,i){var n=new this(i,e,t);return n.nextToken(),n.parseExpression()};M.tokenizer=function(e,t){return new this(t,e)};Object.defineProperties(M.prototype,G);var O=M.prototype,Yt=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;O.strictDirective=function(s){if(this.options.ecmaVersion<5)return!1;for(;;){R.lastIndex=s,s+=R.exec(this.input)[0].length;var e=Yt.exec(this.input.slice(s));if(!e)return!1;if((e[1]||e[2])==="use strict"){R.lastIndex=s+e[0].length;var t=R.exec(this.input),i=t.index+t[0].length,n=this.input.charAt(i);return n===";"||n==="}"||D.test(t[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(n)||n==="!"&&this.input.charAt(i+1)==="=")}s+=e[0].length,R.lastIndex=s,s+=R.exec(this.input)[0].length,this.input[s]===";"&&s++}};O.eat=function(s){return this.type===s?(this.next(),!0):!1};O.isContextual=function(s){return this.type===u.name&&this.value===s&&!this.containsEsc};O.eatContextual=function(s){return this.isContextual(s)?(this.next(),!0):!1};O.expectContextual=function(s){this.eatContextual(s)||this.unexpected()};O.canInsertSemicolon=function(){return this.type===u.eof||this.type===u.braceR||D.test(this.input.slice(this.lastTokEnd,this.start))};O.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};O.semicolon=function(){!this.eat(u.semi)&&!this.insertSemicolon()&&this.unexpected()};O.afterTrailingComma=function(s,e){if(this.type===s)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};O.expect=function(s){this.eat(s)||this.unexpected()};O.unexpected=function(s){this.raise(s??this.start,"Unexpected token")};var Ne=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};O.checkPatternErrors=function(s,e){if(s){s.trailingComma>-1&&this.raiseRecoverable(s.trailingComma,"Comma is not permitted after the rest element");var t=e?s.parenthesizedAssign:s.parenthesizedBind;t>-1&&this.raiseRecoverable(t,e?"Assigning to rvalue":"Parenthesized pattern")}};O.checkExpressionErrors=function(s,e){if(!s)return!1;var t=s.shorthandAssign,i=s.doubleProto;if(!e)return t>=0||i>=0;t>=0&&this.raise(t,"Shorthand property assignments are valid only in destructuring patterns"),i>=0&&this.raiseRecoverable(i,"Redefinition of __proto__ property")};O.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")};O.isSimpleAssignTarget=function(s){return s.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(s.expression):s.type==="Identifier"||s.type==="MemberExpression"};var C=M.prototype;C.parseTopLevel=function(s){var e=Object.create(null);for(s.body||(s.body=[]);this.type!==u.eof;){var t=this.parseStatement(null,!0,e);s.body.push(t)}if(this.inModule)for(var i=0,n=Object.keys(this.undefinedExports);i<n.length;i+=1){var r=n[i];this.raiseRecoverable(this.undefinedExports[r].start,"Export '"+r+"' is not defined")}return this.adaptDirectivePrologue(s.body),this.next(),s.sourceType=this.options.sourceType,this.finishNode(s,"Program")};var ze={kind:"loop"},Jt={kind:"switch"};C.isLet=function(s){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;R.lastIndex=this.pos;var e=R.exec(this.input),t=this.pos+e[0].length,i=this.input.charCodeAt(t);if(i===91||i===92)return!0;if(s)return!1;if(i===123||i>55295&&i<56320)return!0;if(K(i,!0)){for(var n=t+1;te(i=this.input.charCodeAt(n),!0);)++n;if(i===92||i>55295&&i<56320)return!0;var r=this.input.slice(t,n);if(!Ut.test(r))return!0}return!1};C.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;R.lastIndex=this.pos;var s=R.exec(this.input),e=this.pos+s[0].length,t;return!D.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(te(t=this.input.charCodeAt(e+8))||t>55295&&t<56320))};C.isUsingKeyword=function(s,e){if(this.options.ecmaVersion<17||!this.isContextual(s?"await":"using"))return!1;R.lastIndex=this.pos;var t=R.exec(this.input),i=this.pos+t[0].length;if(D.test(this.input.slice(this.pos,i)))return!1;if(s){var n=i+5,r;if(this.input.slice(i,n)!=="using"||n===this.input.length||te(r=this.input.charCodeAt(n))||r>55295&&r<56320)return!1;R.lastIndex=n;var a=R.exec(this.input);if(a&&D.test(this.input.slice(n,n+a[0].length)))return!1}if(e){var o=i+2,c;if(this.input.slice(i,o)==="of"&&(o===this.input.length||!te(c=this.input.charCodeAt(o))&&!(c>55295&&c<56320)))return!1}var l=this.input.charCodeAt(i);return K(l,!0)||l===92};C.isAwaitUsing=function(s){return this.isUsingKeyword(!0,s)};C.isUsing=function(s){return this.isUsingKeyword(!1,s)};C.parseStatement=function(s,e,t){var i=this.type,n=this.startNode(),r;switch(this.isLet(s)&&(i=u._var,r="let"),i){case u._break:case u._continue:return this.parseBreakContinueStatement(n,i.keyword);case u._debugger:return this.parseDebuggerStatement(n);case u._do:return this.parseDoStatement(n);case u._for:return this.parseForStatement(n);case u._function:return s&&(this.strict||s!=="if"&&s!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1,!s);case u._class:return s&&this.unexpected(),this.parseClass(n,!0);case u._if:return this.parseIfStatement(n);case u._return:return this.parseReturnStatement(n);case u._switch:return this.parseSwitchStatement(n);case u._throw:return this.parseThrowStatement(n);case u._try:return this.parseTryStatement(n);case u._const:case u._var:return r=r||this.value,s&&r!=="var"&&this.unexpected(),this.parseVarStatement(n,r);case u._while:return this.parseWhileStatement(n);case u._with:return this.parseWithStatement(n);case u.braceL:return this.parseBlock(!0,n);case u.semi:return this.parseEmptyStatement(n);case u._export:case u._import:if(this.options.ecmaVersion>10&&i===u._import){R.lastIndex=this.pos;var a=R.exec(this.input),o=this.pos+a[0].length,c=this.input.charCodeAt(o);if(c===40||c===46)return this.parseExpressionStatement(n,this.parseExpression())}return this.options.allowImportExportEverywhere||(e||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'")),i===u._import?this.parseImport(n):this.parseExport(n,t);default:if(this.isAsyncFunction())return s&&this.unexpected(),this.next(),this.parseFunctionStatement(n,!0,!s);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return e&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),l==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(n,!1,l),this.semicolon(),this.finishNode(n,"VariableDeclaration");var p=this.value,h=this.parseExpression();return i===u.name&&h.type==="Identifier"&&this.eat(u.colon)?this.parseLabeledStatement(n,p,h,s):this.parseExpressionStatement(n,h)}};C.parseBreakContinueStatement=function(s,e){var t=e==="break";this.next(),this.eat(u.semi)||this.insertSemicolon()?s.label=null:this.type!==u.name?this.unexpected():(s.label=this.parseIdent(),this.semicolon());for(var i=0;i<this.labels.length;++i){var n=this.labels[i];if((s.label==null||n.name===s.label.name)&&(n.kind!=null&&(t||n.kind==="loop")||s.label&&t))break}return i===this.labels.length&&this.raise(s.start,"Unsyntactic "+e),this.finishNode(s,t?"BreakStatement":"ContinueStatement")};C.parseDebuggerStatement=function(s){return this.next(),this.semicolon(),this.finishNode(s,"DebuggerStatement")};C.parseDoStatement=function(s){return this.next(),this.labels.push(ze),s.body=this.parseStatement("do"),this.labels.pop(),this.expect(u._while),s.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(u.semi):this.semicolon(),this.finishNode(s,"DoWhileStatement")};C.parseForStatement=function(s){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(ze),this.enterScope(0),this.expect(u.parenL),this.type===u.semi)return e>-1&&this.unexpected(e),this.parseFor(s,null);var t=this.isLet();if(this.type===u._var||this.type===u._const||t){var i=this.startNode(),n=t?"let":this.value;return this.next(),this.parseVar(i,!0,n),this.finishNode(i,"VariableDeclaration"),this.parseForAfterInit(s,i,e)}var r=this.isContextual("let"),a=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var c=this.startNode();return this.next(),o==="await using"&&this.next(),this.parseVar(c,!0,o),this.finishNode(c,"VariableDeclaration"),this.parseForAfterInit(s,c,e)}var l=this.containsEsc,p=new Ne,h=this.start,f=e>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===u._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===u._in&&this.unexpected(e),s.await=!0):a&&this.options.ecmaVersion>=8&&(f.start===h&&!l&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(s.await=!1)),r&&a&&this.raise(f.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(f,!1,p),this.checkLValPattern(f),this.parseForIn(s,f)):(this.checkExpressionErrors(p,!0),e>-1&&this.unexpected(e),this.parseFor(s,f))};C.parseForAfterInit=function(s,e,t){return(this.type===u._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&e.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===u._in?t>-1&&this.unexpected(t):s.await=t>-1),this.parseForIn(s,e)):(t>-1&&this.unexpected(t),this.parseFor(s,e))};C.parseFunctionStatement=function(s,e,t){return this.next(),this.parseFunction(s,me|(t?0:Be),!1,e)};C.parseIfStatement=function(s){return this.next(),s.test=this.parseParenExpression(),s.consequent=this.parseStatement("if"),s.alternate=this.eat(u._else)?this.parseStatement("if"):null,this.finishNode(s,"IfStatement")};C.parseReturnStatement=function(s){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(u.semi)||this.insertSemicolon()?s.argument=null:(s.argument=this.parseExpression(),this.semicolon()),this.finishNode(s,"ReturnStatement")};C.parseSwitchStatement=function(s){this.next(),s.discriminant=this.parseParenExpression(),s.cases=[],this.expect(u.braceL),this.labels.push(Jt),this.enterScope(0);for(var e,t=!1;this.type!==u.braceR;)if(this.type===u._case||this.type===u._default){var i=this.type===u._case;e&&this.finishNode(e,"SwitchCase"),s.cases.push(e=this.startNode()),e.consequent=[],this.next(),i?e.test=this.parseExpression():(t&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),t=!0,e.test=null),this.expect(u.colon)}else e||this.unexpected(),e.consequent.push(this.parseStatement(null));return this.exitScope(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(s,"SwitchStatement")};C.parseThrowStatement=function(s){return this.next(),D.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),s.argument=this.parseExpression(),this.semicolon(),this.finishNode(s,"ThrowStatement")};var es=[];C.parseCatchClauseParam=function(){var s=this.parseBindingAtom(),e=s.type==="Identifier";return this.enterScope(e?lt:0),this.checkLValPattern(s,e?ft:J),this.expect(u.parenR),s};C.parseTryStatement=function(s){if(this.next(),s.block=this.parseBlock(),s.handler=null,this.type===u._catch){var e=this.startNode();this.next(),this.eat(u.parenL)?e.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterScope(0)),e.body=this.parseBlock(!1),this.exitScope(),s.handler=this.finishNode(e,"CatchClause")}return s.finalizer=this.eat(u._finally)?this.parseBlock():null,!s.handler&&!s.finalizer&&this.raise(s.start,"Missing catch or finally clause"),this.finishNode(s,"TryStatement")};C.parseVarStatement=function(s,e,t){return this.next(),this.parseVar(s,!1,e,t),this.semicolon(),this.finishNode(s,"VariableDeclaration")};C.parseWhileStatement=function(s){return this.next(),s.test=this.parseParenExpression(),this.labels.push(ze),s.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(s,"WhileStatement")};C.parseWithStatement=function(s){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),s.object=this.parseParenExpression(),s.body=this.parseStatement("with"),this.finishNode(s,"WithStatement")};C.parseEmptyStatement=function(s){return this.next(),this.finishNode(s,"EmptyStatement")};C.parseLabeledStatement=function(s,e,t,i){for(var n=0,r=this.labels;n<r.length;n+=1){var a=r[n];a.name===e&&this.raise(t.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===u._switch?"switch":null,c=this.labels.length-1;c>=0;c--){var l=this.labels[c];if(l.statementStart===s.start)l.statementStart=this.start,l.kind=o;else break}return this.labels.push({name:e,kind:o,statementStart:this.start}),s.body=this.parseStatement(i?i.indexOf("label")===-1?i+"label":i:"label"),this.labels.pop(),s.label=t,this.finishNode(s,"LabeledStatement")};C.parseExpressionStatement=function(s,e){return s.expression=e,this.semicolon(),this.finishNode(s,"ExpressionStatement")};C.parseBlock=function(s,e,t){for(s===void 0&&(s=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(u.braceL),s&&this.enterScope(0);this.type!==u.braceR;){var i=this.parseStatement(null);e.body.push(i)}return t&&(this.strict=!1),this.next(),s&&this.exitScope(),this.finishNode(e,"BlockStatement")};C.parseFor=function(s,e){return s.init=e,this.expect(u.semi),s.test=this.type===u.semi?null:this.parseExpression(),this.expect(u.semi),s.update=this.type===u.parenR?null:this.parseExpression(),this.expect(u.parenR),s.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(s,"ForStatement")};C.parseForIn=function(s,e){var t=this.type===u._in;return this.next(),e.type==="VariableDeclaration"&&e.declarations[0].init!=null&&(!t||this.options.ecmaVersion<8||this.strict||e.kind!=="var"||e.declarations[0].id.type!=="Identifier")&&this.raise(e.start,(t?"for-in":"for-of")+" loop variable declaration may not have an initializer"),s.left=e,s.right=t?this.parseExpression():this.parseMaybeAssign(),this.expect(u.parenR),s.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(s,t?"ForInStatement":"ForOfStatement")};C.parseVar=function(s,e,t,i){for(s.declarations=[],s.kind=t;;){var n=this.startNode();if(this.parseVarId(n,t),this.eat(u.eq)?n.init=this.parseMaybeAssign(e):!i&&t==="const"&&!(this.type===u._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!i&&(t==="using"||t==="await using")&&this.options.ecmaVersion>=17&&this.type!==u._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+t+" declaration"):!i&&n.id.type!=="Identifier"&&!(e&&(this.type===u._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):n.init=null,s.declarations.push(this.finishNode(n,"VariableDeclarator")),!this.eat(u.comma))break}return s};C.parseVarId=function(s,e){s.id=e==="using"||e==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(s.id,e==="var"?Xe:J,!1)};var me=1,Be=2,mt=4;C.parseFunction=function(s,e,t,i,n){this.initFunction(s),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!i)&&(this.type===u.star&&e&Be&&this.unexpected(),s.generator=this.eat(u.star)),this.options.ecmaVersion>=8&&(s.async=!!i),e&me&&(s.id=e&mt&&this.type!==u.name?null:this.parseIdent(),s.id&&!(e&Be)&&this.checkLValSimple(s.id,this.strict||s.generator||s.async?this.treatFunctionsAsVar?Xe:J:ht));var r=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(qe(s.async,s.generator)),e&me||(s.id=this.type===u.name?this.parseIdent():null),this.parseFunctionParams(s),this.parseFunctionBody(s,t,!1,n),this.yieldPos=r,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(s,e&me?"FunctionDeclaration":"FunctionExpression")};C.parseFunctionParams=function(s){this.expect(u.parenL),s.params=this.parseBindingList(u.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};C.parseClass=function(s,e){this.next();var t=this.strict;this.strict=!0,this.parseClassId(s,e),this.parseClassSuper(s);var i=this.enterClassBody(),n=this.startNode(),r=!1;for(n.body=[],this.expect(u.braceL);this.type!==u.braceR;){var a=this.parseClassElement(s.superClass!==null);a&&(n.body.push(a),a.type==="MethodDefinition"&&a.kind==="constructor"?(r&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),r=!0):a.key&&a.key.type==="PrivateIdentifier"&&ts(i,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=t,this.next(),s.body=this.finishNode(n,"ClassBody"),this.exitClassBody(),this.finishNode(s,e?"ClassDeclaration":"ClassExpression")};C.parseClassElement=function(s){if(this.eat(u.semi))return null;var e=this.options.ecmaVersion,t=this.startNode(),i="",n=!1,r=!1,a="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(u.braceL))return this.parseClassStaticBlock(t),t;this.isClassElementNameStart()||this.type===u.star?o=!0:i="static"}if(t.static=o,!i&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===u.star)&&!this.canInsertSemicolon()?r=!0:i="async"),!i&&(e>=9||!r)&&this.eat(u.star)&&(n=!0),!i&&!r&&!n){var c=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=c:i=c)}if(i?(t.computed=!1,t.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),t.key.name=i,this.finishNode(t.key,"Identifier")):this.parseClassElementName(t),e<13||this.type===u.parenL||a!=="method"||n||r){var l=!t.static&&Se(t,"constructor"),p=l&&s;l&&a!=="method"&&this.raise(t.key.start,"Constructor can't have get/set modifier"),t.kind=l?"constructor":a,this.parseClassMethod(t,n,r,p)}else this.parseClassField(t);return t};C.isClassElementNameStart=function(){return this.type===u.name||this.type===u.privateId||this.type===u.num||this.type===u.string||this.type===u.bracketL||this.type.keyword};C.parseClassElementName=function(s){this.type===u.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),s.computed=!1,s.key=this.parsePrivateIdent()):this.parsePropertyName(s)};C.parseClassMethod=function(s,e,t,i){var n=s.key;s.kind==="constructor"?(e&&this.raise(n.start,"Constructor can't be a generator"),t&&this.raise(n.start,"Constructor can't be an async method")):s.static&&Se(s,"prototype")&&this.raise(n.start,"Classes may not have a static property named prototype");var r=s.value=this.parseMethod(e,t,i);return s.kind==="get"&&r.params.length!==0&&this.raiseRecoverable(r.start,"getter should have no params"),s.kind==="set"&&r.params.length!==1&&this.raiseRecoverable(r.start,"setter should have exactly one param"),s.kind==="set"&&r.params[0].type==="RestElement"&&this.raiseRecoverable(r.params[0].start,"Setter cannot use rest params"),this.finishNode(s,"MethodDefinition")};C.parseClassField=function(s){return Se(s,"constructor")?this.raise(s.key.start,"Classes can't have a field named 'constructor'"):s.static&&Se(s,"prototype")&&this.raise(s.key.start,"Classes can't have a static field named 'prototype'"),this.eat(u.eq)?(this.enterScope(be|Pe),s.value=this.parseMaybeAssign(),this.exitScope()):s.value=null,this.semicolon(),this.finishNode(s,"PropertyDefinition")};C.parseClassStaticBlock=function(s){s.body=[];var e=this.labels;for(this.labels=[],this.enterScope(ae|Pe);this.type!==u.braceR;){var t=this.parseStatement(null);s.body.push(t)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(s,"StaticBlock")};C.parseClassId=function(s,e){this.type===u.name?(s.id=this.parseIdent(),e&&this.checkLValSimple(s.id,J,!1)):(e===!0&&this.unexpected(),s.id=null)};C.parseClassSuper=function(s){s.superClass=this.eat(u._extends)?this.parseExprSubscripts(null,!1):null};C.enterClassBody=function(){var s={declared:Object.create(null),used:[]};return this.privateNameStack.push(s),s.declared};C.exitClassBody=function(){var s=this.privateNameStack.pop(),e=s.declared,t=s.used;if(this.options.checkPrivateFields)for(var i=this.privateNameStack.length,n=i===0?null:this.privateNameStack[i-1],r=0;r<t.length;++r){var a=t[r];he(e,a.name)||(n?n.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}};function ts(s,e){var t=e.key.name,i=s[t],n="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(n=(e.static?"s":"i")+e.kind),i==="iget"&&n==="iset"||i==="iset"&&n==="iget"||i==="sget"&&n==="sset"||i==="sset"&&n==="sget"?(s[t]="true",!1):i?!0:(s[t]=n,!1)}function Se(s,e){var t=s.computed,i=s.key;return!t&&(i.type==="Identifier"&&i.name===e||i.type==="Literal"&&i.value===e)}C.parseExportAllDeclaration=function(s,e){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(s.exported=this.parseModuleExportName(),this.checkExport(e,s.exported,this.lastTokStart)):s.exported=null),this.expectContextual("from"),this.type!==u.string&&this.unexpected(),s.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(s,"ExportAllDeclaration")};C.parseExport=function(s,e){if(this.next(),this.eat(u.star))return this.parseExportAllDeclaration(s,e);if(this.eat(u._default))return this.checkExport(e,"default",this.lastTokStart),s.declaration=this.parseExportDefaultDeclaration(),this.finishNode(s,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())s.declaration=this.parseExportDeclaration(s),s.declaration.type==="VariableDeclaration"?this.checkVariableExport(e,s.declaration.declarations):this.checkExport(e,s.declaration.id,s.declaration.id.start),s.specifiers=[],s.source=null,this.options.ecmaVersion>=16&&(s.attributes=[]);else{if(s.declaration=null,s.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==u.string&&this.unexpected(),s.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause());else{for(var t=0,i=s.specifiers;t<i.length;t+=1){var n=i[t];this.checkUnreserved(n.local),this.checkLocalExport(n.local),n.local.type==="Literal"&&this.raise(n.local.start,"A string literal cannot be used as an exported binding without `from`.")}s.source=null,this.options.ecmaVersion>=16&&(s.attributes=[])}this.semicolon()}return this.finishNode(s,"ExportNamedDeclaration")};C.parseExportDeclaration=function(s){return this.parseStatement(null)};C.parseExportDefaultDeclaration=function(){var s;if(this.type===u._function||(s=this.isAsyncFunction())){var e=this.startNode();return this.next(),s&&this.next(),this.parseFunction(e,me|mt,!1,s)}else if(this.type===u._class){var t=this.startNode();return this.parseClass(t,"nullableID")}else{var i=this.parseMaybeAssign();return this.semicolon(),i}};C.checkExport=function(s,e,t){s&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),he(s,e)&&this.raiseRecoverable(t,"Duplicate export '"+e+"'"),s[e]=!0)};C.checkPatternExport=function(s,e){var t=e.type;if(t==="Identifier")this.checkExport(s,e,e.start);else if(t==="ObjectPattern")for(var i=0,n=e.properties;i<n.length;i+=1){var r=n[i];this.checkPatternExport(s,r)}else if(t==="ArrayPattern")for(var a=0,o=e.elements;a<o.length;a+=1){var c=o[a];c&&this.checkPatternExport(s,c)}else t==="Property"?this.checkPatternExport(s,e.value):t==="AssignmentPattern"?this.checkPatternExport(s,e.left):t==="RestElement"&&this.checkPatternExport(s,e.argument)};C.checkVariableExport=function(s,e){if(s)for(var t=0,i=e;t<i.length;t+=1){var n=i[t];this.checkPatternExport(s,n.id)}};C.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};C.parseExportSpecifier=function(s){var e=this.startNode();return e.local=this.parseModuleExportName(),e.exported=this.eatContextual("as")?this.parseModuleExportName():e.local,this.checkExport(s,e.exported,e.exported.start),this.finishNode(e,"ExportSpecifier")};C.parseExportSpecifiers=function(s){var e=[],t=!0;for(this.expect(u.braceL);!this.eat(u.braceR);){if(t)t=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;e.push(this.parseExportSpecifier(s))}return e};C.parseImport=function(s){return this.next(),this.type===u.string?(s.specifiers=es,s.source=this.parseExprAtom()):(s.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),s.source=this.type===u.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(s,"ImportDeclaration")};C.parseImportSpecifier=function(){var s=this.startNode();return s.imported=this.parseModuleExportName(),this.eatContextual("as")?s.local=this.parseIdent():(this.checkUnreserved(s.imported),s.local=s.imported),this.checkLValSimple(s.local,J),this.finishNode(s,"ImportSpecifier")};C.parseImportDefaultSpecifier=function(){var s=this.startNode();return s.local=this.parseIdent(),this.checkLValSimple(s.local,J),this.finishNode(s,"ImportDefaultSpecifier")};C.parseImportNamespaceSpecifier=function(){var s=this.startNode();return this.next(),this.expectContextual("as"),s.local=this.parseIdent(),this.checkLValSimple(s.local,J),this.finishNode(s,"ImportNamespaceSpecifier")};C.parseImportSpecifiers=function(){var s=[],e=!0;if(this.type===u.name&&(s.push(this.parseImportDefaultSpecifier()),!this.eat(u.comma)))return s;if(this.type===u.star)return s.push(this.parseImportNamespaceSpecifier()),s;for(this.expect(u.braceL);!this.eat(u.braceR);){if(e)e=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;s.push(this.parseImportSpecifier())}return s};C.parseWithClause=function(){var s=[];if(!this.eat(u._with))return s;this.expect(u.braceL);for(var e={},t=!0;!this.eat(u.braceR);){if(t)t=!1;else if(this.expect(u.comma),this.afterTrailingComma(u.braceR))break;var i=this.parseImportAttribute(),n=i.key.type==="Identifier"?i.key.name:i.key.value;he(e,n)&&this.raiseRecoverable(i.key.start,"Duplicate attribute key '"+n+"'"),e[n]=!0,s.push(i)}return s};C.parseImportAttribute=function(){var s=this.startNode();return s.key=this.type===u.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(u.colon),this.type!==u.string&&this.unexpected(),s.value=this.parseExprAtom(),this.finishNode(s,"ImportAttribute")};C.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===u.string){var s=this.parseLiteral(this.value);return Gt.test(s.value)&&this.raise(s.start,"An export name cannot include a lone surrogate."),s}return this.parseIdent(!0)};C.adaptDirectivePrologue=function(s){for(var e=0;e<s.length&&this.isDirectiveCandidate(s[e]);++e)s[e].directive=s[e].expression.raw.slice(1,-1)};C.isDirectiveCandidate=function(s){return this.options.ecmaVersion>=5&&s.type==="ExpressionStatement"&&s.expression.type==="Literal"&&typeof s.expression.value=="string"&&(this.input[s.start]==='"'||this.input[s.start]==="'")};var U=M.prototype;U.toAssignable=function(s,e,t){if(this.options.ecmaVersion>=6&&s)switch(s.type){case"Identifier":this.inAsync&&s.name==="await"&&this.raise(s.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":s.type="ObjectPattern",t&&this.checkPatternErrors(t,!0);for(var i=0,n=s.properties;i<n.length;i+=1){var r=n[i];this.toAssignable(r,e),r.type==="RestElement"&&(r.argument.type==="ArrayPattern"||r.argument.type==="ObjectPattern")&&this.raise(r.argument.start,"Unexpected token")}break;case"Property":s.kind!=="init"&&this.raise(s.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(s.value,e);break;case"ArrayExpression":s.type="ArrayPattern",t&&this.checkPatternErrors(t,!0),this.toAssignableList(s.elements,e);break;case"SpreadElement":s.type="RestElement",this.toAssignable(s.argument,e),s.argument.type==="AssignmentPattern"&&this.raise(s.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":s.operator!=="="&&this.raise(s.left.end,"Only '=' operator can be used for specifying default value."),s.type="AssignmentPattern",delete s.operator,this.toAssignable(s.left,e);break;case"ParenthesizedExpression":this.toAssignable(s.expression,e,t);break;case"ChainExpression":this.raiseRecoverable(s.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!e)break;default:this.raise(s.start,"Assigning to rvalue")}else t&&this.checkPatternErrors(t,!0);return s};U.toAssignableList=function(s,e){for(var t=s.length,i=0;i<t;i++){var n=s[i];n&&this.toAssignable(n,e)}if(t){var r=s[t-1];this.options.ecmaVersion===6&&e&&r&&r.type==="RestElement"&&r.argument.type!=="Identifier"&&this.unexpected(r.argument.start)}return s};U.parseSpread=function(s){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,s),this.finishNode(e,"SpreadElement")};U.parseRestBinding=function(){var s=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==u.name&&this.unexpected(),s.argument=this.parseBindingAtom(),this.finishNode(s,"RestElement")};U.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case u.bracketL:var s=this.startNode();return this.next(),s.elements=this.parseBindingList(u.bracketR,!0,!0),this.finishNode(s,"ArrayPattern");case u.braceL:return this.parseObj(!0)}return this.parseIdent()};U.parseBindingList=function(s,e,t,i){for(var n=[],r=!0;!this.eat(s);)if(r?r=!1:this.expect(u.comma),e&&this.type===u.comma)n.push(null);else{if(t&&this.afterTrailingComma(s))break;if(this.type===u.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),n.push(a),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(s);break}else n.push(this.parseAssignableListItem(i))}return n};U.parseAssignableListItem=function(s){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};U.parseBindingListItem=function(s){return s};U.parseMaybeDefault=function(s,e,t){if(t=t||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(u.eq))return t;var i=this.startNodeAt(s,e);return i.left=t,i.right=this.parseMaybeAssign(),this.finishNode(i,"AssignmentPattern")};U.checkLValSimple=function(s,e,t){e===void 0&&(e=ve);var i=e!==ve;switch(s.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(s.name)&&this.raiseRecoverable(s.start,(i?"Binding ":"Assigning to ")+s.name+" in strict mode"),i&&(e===J&&s.name==="let"&&this.raiseRecoverable(s.start,"let is disallowed as a lexically bound name"),t&&(he(t,s.name)&&this.raiseRecoverable(s.start,"Argument name clash"),t[s.name]=!0),e!==dt&&this.declareName(s.name,e,s.start));break;case"ChainExpression":this.raiseRecoverable(s.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":i&&this.raiseRecoverable(s.start,"Binding member expression");break;case"ParenthesizedExpression":return i&&this.raiseRecoverable(s.start,"Binding parenthesized expression"),this.checkLValSimple(s.expression,e,t);default:this.raise(s.start,(i?"Binding":"Assigning to")+" rvalue")}};U.checkLValPattern=function(s,e,t){switch(e===void 0&&(e=ve),s.type){case"ObjectPattern":for(var i=0,n=s.properties;i<n.length;i+=1){var r=n[i];this.checkLValInnerPattern(r,e,t)}break;case"ArrayPattern":for(var a=0,o=s.elements;a<o.length;a+=1){var c=o[a];c&&this.checkLValInnerPattern(c,e,t)}break;default:this.checkLValSimple(s,e,t)}};U.checkLValInnerPattern=function(s,e,t){switch(e===void 0&&(e=ve),s.type){case"Property":this.checkLValInnerPattern(s.value,e,t);break;case"AssignmentPattern":this.checkLValPattern(s.left,e,t);break;case"RestElement":this.checkLValPattern(s.argument,e,t);break;default:this.checkLValPattern(s,e,t)}};var X=function(e,t,i,n,r){this.token=e,this.isExpr=!!t,this.preserveSpace=!!i,this.override=n,this.generator=!!r},I={b_stat:new X("{",!1),b_expr:new X("{",!0),b_tmpl:new X("${",!1),p_stat:new X("(",!1),p_expr:new X("(",!0),q_tmpl:new X("`",!0,!0,function(s){return s.tryReadTemplateToken()}),f_stat:new X("function",!1),f_expr:new X("function",!0),f_expr_gen:new X("function",!0,!1,null,!0),f_gen:new X("function",!1,!1,null,!0)},de=M.prototype;de.initialContext=function(){return[I.b_stat]};de.curContext=function(){return this.context[this.context.length-1]};de.braceIsBlock=function(s){var e=this.curContext();return e===I.f_expr||e===I.f_stat?!0:s===u.colon&&(e===I.b_stat||e===I.b_expr)?!e.isExpr:s===u._return||s===u.name&&this.exprAllowed?D.test(this.input.slice(this.lastTokEnd,this.start)):s===u._else||s===u.semi||s===u.eof||s===u.parenR||s===u.arrow?!0:s===u.braceL?e===I.b_stat:s===u._var||s===u._const||s===u.name?!1:!this.exprAllowed};de.inGeneratorContext=function(){for(var s=this.context.length-1;s>=1;s--){var e=this.context[s];if(e.token==="function")return e.generator}return!1};de.updateContext=function(s){var e,t=this.type;t.keyword&&s===u.dot?this.exprAllowed=!1:(e=t.updateContext)?e.call(this,s):this.exprAllowed=t.beforeExpr};de.overrideContext=function(s){this.curContext()!==s&&(this.context[this.context.length-1]=s)};u.parenR.updateContext=u.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var s=this.context.pop();s===I.b_stat&&this.curContext().token==="function"&&(s=this.context.pop()),this.exprAllowed=!s.isExpr};u.braceL.updateContext=function(s){this.context.push(this.braceIsBlock(s)?I.b_stat:I.b_expr),this.exprAllowed=!0};u.dollarBraceL.updateContext=function(){this.context.push(I.b_tmpl),this.exprAllowed=!0};u.parenL.updateContext=function(s){var e=s===u._if||s===u._for||s===u._with||s===u._while;this.context.push(e?I.p_stat:I.p_expr),this.exprAllowed=!0};u.incDec.updateContext=function(){};u._function.updateContext=u._class.updateContext=function(s){s.beforeExpr&&s!==u._else&&!(s===u.semi&&this.curContext()!==I.p_stat)&&!(s===u._return&&D.test(this.input.slice(this.lastTokEnd,this.start)))&&!((s===u.colon||s===u.braceL)&&this.curContext()===I.b_stat)?this.context.push(I.f_expr):this.context.push(I.f_stat),this.exprAllowed=!1};u.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};u.backQuote.updateContext=function(){this.curContext()===I.q_tmpl?this.context.pop():this.context.push(I.q_tmpl),this.exprAllowed=!1};u.star.updateContext=function(s){if(s===u._function){var e=this.context.length-1;this.context[e]===I.f_expr?this.context[e]=I.f_expr_gen:this.context[e]=I.f_gen}this.exprAllowed=!0};u.name.updateContext=function(s){var e=!1;this.options.ecmaVersion>=6&&s!==u.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var T=M.prototype;T.checkPropClash=function(s,e,t){if(!(this.options.ecmaVersion>=9&&s.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(s.computed||s.method||s.shorthand))){var i=s.key,n;switch(i.type){case"Identifier":n=i.name;break;case"Literal":n=String(i.value);break;default:return}var r=s.kind;if(this.options.ecmaVersion>=6){n==="__proto__"&&r==="init"&&(e.proto&&(t?t.doubleProto<0&&(t.doubleProto=i.start):this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),e.proto=!0);return}n="$"+n;var a=e[n];if(a){var o;r==="init"?o=this.strict&&a.init||a.get||a.set:o=a.init||a[r],o&&this.raiseRecoverable(i.start,"Redefinition of property")}else a=e[n]={init:!1,get:!1,set:!1};a[r]=!0}};T.parseExpression=function(s,e){var t=this.start,i=this.startLoc,n=this.parseMaybeAssign(s,e);if(this.type===u.comma){var r=this.startNodeAt(t,i);for(r.expressions=[n];this.eat(u.comma);)r.expressions.push(this.parseMaybeAssign(s,e));return this.finishNode(r,"SequenceExpression")}return n};T.parseMaybeAssign=function(s,e,t){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(s);this.exprAllowed=!1}var i=!1,n=-1,r=-1,a=-1;e?(n=e.parenthesizedAssign,r=e.trailingComma,a=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new Ne,i=!0);var o=this.start,c=this.startLoc;(this.type===u.parenL||this.type===u.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=s==="await");var l=this.parseMaybeConditional(s,e);if(t&&(l=t.call(this,l,o,c)),this.type.isAssign){var p=this.startNodeAt(o,c);return p.operator=this.value,this.type===u.eq&&(l=this.toAssignable(l,!1,e)),i||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=l.start&&(e.shorthandAssign=-1),this.type===u.eq?this.checkLValPattern(l):this.checkLValSimple(l),p.left=l,this.next(),p.right=this.parseMaybeAssign(s),a>-1&&(e.doubleProto=a),this.finishNode(p,"AssignmentExpression")}else i&&this.checkExpressionErrors(e,!0);return n>-1&&(e.parenthesizedAssign=n),r>-1&&(e.trailingComma=r),l};T.parseMaybeConditional=function(s,e){var t=this.start,i=this.startLoc,n=this.parseExprOps(s,e);if(this.checkExpressionErrors(e))return n;if(this.eat(u.question)){var r=this.startNodeAt(t,i);return r.test=n,r.consequent=this.parseMaybeAssign(),this.expect(u.colon),r.alternate=this.parseMaybeAssign(s),this.finishNode(r,"ConditionalExpression")}return n};T.parseExprOps=function(s,e){var t=this.start,i=this.startLoc,n=this.parseMaybeUnary(e,!1,!1,s);return this.checkExpressionErrors(e)||n.start===t&&n.type==="ArrowFunctionExpression"?n:this.parseExprOp(n,t,i,-1,s)};T.parseExprOp=function(s,e,t,i,n){var r=this.type.binop;if(r!=null&&(!n||this.type!==u._in)&&r>i){var a=this.type===u.logicalOR||this.type===u.logicalAND,o=this.type===u.coalesce;o&&(r=u.logicalAND.binop);var c=this.value;this.next();var l=this.start,p=this.startLoc,h=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,n),l,p,r,n),f=this.buildBinary(e,t,s,h,c,a||o);return(a&&this.type===u.coalesce||o&&(this.type===u.logicalOR||this.type===u.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(f,e,t,i,n)}return s};T.buildBinary=function(s,e,t,i,n,r){i.type==="PrivateIdentifier"&&this.raise(i.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(s,e);return a.left=t,a.operator=n,a.right=i,this.finishNode(a,r?"LogicalExpression":"BinaryExpression")};T.parseMaybeUnary=function(s,e,t,i){var n=this.start,r=this.startLoc,a;if(this.isContextual("await")&&this.canAwait)a=this.parseAwait(i),e=!0;else if(this.type.prefix){var o=this.startNode(),c=this.type===u.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,c,i),this.checkExpressionErrors(s,!0),c?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&>(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&$e(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):e=!0,a=this.finishNode(o,c?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===u.privateId)(i||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),a=this.parsePrivateIdent(),this.type!==u._in&&this.unexpected();else{if(a=this.parseExprSubscripts(s,i),this.checkExpressionErrors(s))return a;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(n,r);l.operator=this.value,l.prefix=!1,l.argument=a,this.checkLValSimple(a),this.next(),a=this.finishNode(l,"UpdateExpression")}}if(!t&&this.eat(u.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(n,r,a,this.parseMaybeUnary(null,!1,!1,i),"**",!1);else return a};function gt(s){return s.type==="Identifier"||s.type==="ParenthesizedExpression"&>(s.expression)}function $e(s){return s.type==="MemberExpression"&&s.property.type==="PrivateIdentifier"||s.type==="ChainExpression"&&$e(s.expression)||s.type==="ParenthesizedExpression"&&$e(s.expression)}T.parseExprSubscripts=function(s,e){var t=this.start,i=this.startLoc,n=this.parseExprAtom(s,e);if(n.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return n;var r=this.parseSubscripts(n,t,i,!1,e);return s&&r.type==="MemberExpression"&&(s.parenthesizedAssign>=r.start&&(s.parenthesizedAssign=-1),s.parenthesizedBind>=r.start&&(s.parenthesizedBind=-1),s.trailingComma>=r.start&&(s.trailingComma=-1)),r};T.parseSubscripts=function(s,e,t,i,n){for(var r=this.options.ecmaVersion>=8&&s.type==="Identifier"&&s.name==="async"&&this.lastTokEnd===s.end&&!this.canInsertSemicolon()&&s.end-s.start===5&&this.potentialArrowAt===s.start,a=!1;;){var o=this.parseSubscript(s,e,t,i,r,a,n);if(o.optional&&(a=!0),o===s||o.type==="ArrowFunctionExpression"){if(a){var c=this.startNodeAt(e,t);c.expression=o,o=this.finishNode(c,"ChainExpression")}return o}s=o}};T.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(u.arrow)};T.parseSubscriptAsyncArrow=function(s,e,t,i){return this.parseArrowExpression(this.startNodeAt(s,e),t,!0,i)};T.parseSubscript=function(s,e,t,i,n,r,a){var o=this.options.ecmaVersion>=11,c=o&&this.eat(u.questionDot);i&&c&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(u.bracketL);if(l||c&&this.type!==u.parenL&&this.type!==u.backQuote||this.eat(u.dot)){var p=this.startNodeAt(e,t);p.object=s,l?(p.property=this.parseExpression(),this.expect(u.bracketR)):this.type===u.privateId&&s.type!=="Super"?p.property=this.parsePrivateIdent():p.property=this.parseIdent(this.options.allowReserved!=="never"),p.computed=!!l,o&&(p.optional=c),s=this.finishNode(p,"MemberExpression")}else if(!i&&this.eat(u.parenL)){var h=new Ne,f=this.yieldPos,g=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var E=this.parseExprList(u.parenR,this.options.ecmaVersion>=8,!1,h);if(n&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=f,this.awaitPos=g,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(e,t,E,a);this.checkExpressionErrors(h,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=g||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var y=this.startNodeAt(e,t);y.callee=s,y.arguments=E,o&&(y.optional=c),s=this.finishNode(y,"CallExpression")}else if(this.type===u.backQuote){(c||r)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var S=this.startNodeAt(e,t);S.tag=s,S.quasi=this.parseTemplate({isTagged:!0}),s=this.finishNode(S,"TaggedTemplateExpression")}return s};T.parseExprAtom=function(s,e,t){this.type===u.slash&&this.readRegexp();var i,n=this.potentialArrowAt===this.start;switch(this.type){case u._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),i=this.startNode(),this.next(),this.type===u.parenL&&!this.allowDirectSuper&&this.raise(i.start,"super() call outside constructor of a subclass"),this.type!==u.dot&&this.type!==u.bracketL&&this.type!==u.parenL&&this.unexpected(),this.finishNode(i,"Super");case u._this:return i=this.startNode(),this.next(),this.finishNode(i,"ThisExpression");case u.name:var r=this.start,a=this.startLoc,o=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&c.name==="async"&&!this.canInsertSemicolon()&&this.eat(u._function))return this.overrideContext(I.f_expr),this.parseFunction(this.startNodeAt(r,a),0,!1,!0,e);if(n&&!this.canInsertSemicolon()){if(this.eat(u.arrow))return this.parseArrowExpression(this.startNodeAt(r,a),[c],!1,e);if(this.options.ecmaVersion>=8&&c.name==="async"&&this.type===u.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(u.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,a),[c],!0,e)}return c;case u.regexp:var l=this.value;return i=this.parseLiteral(l.value),i.regex={pattern:l.pattern,flags:l.flags},i;case u.num:case u.string:return this.parseLiteral(this.value);case u._null:case u._true:case u._false:return i=this.startNode(),i.value=this.type===u._null?null:this.type===u._true,i.raw=this.type.keyword,this.next(),this.finishNode(i,"Literal");case u.parenL:var p=this.start,h=this.parseParenAndDistinguishExpression(n,e);return s&&(s.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(s.parenthesizedAssign=p),s.parenthesizedBind<0&&(s.parenthesizedBind=p)),h;case u.bracketL:return i=this.startNode(),this.next(),i.elements=this.parseExprList(u.bracketR,!0,!0,s),this.finishNode(i,"ArrayExpression");case u.braceL:return this.overrideContext(I.b_expr),this.parseObj(!1,s);case u._function:return i=this.startNode(),this.next(),this.parseFunction(i,0);case u._class:return this.parseClass(this.startNode(),!1);case u._new:return this.parseNew();case u.backQuote:return this.parseTemplate();case u._import:return this.options.ecmaVersion>=11?this.parseExprImport(t):this.unexpected();default:return this.parseExprAtomDefault()}};T.parseExprAtomDefault=function(){this.unexpected()};T.parseExprImport=function(s){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===u.parenL&&!s)return this.parseDynamicImport(e);if(this.type===u.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);return t.name="import",e.meta=this.finishNode(t,"Identifier"),this.parseImportMeta(e)}else this.unexpected()};T.parseDynamicImport=function(s){if(this.next(),s.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(u.parenR)?s.options=null:(this.expect(u.comma),this.afterTrailingComma(u.parenR)?s.options=null:(s.options=this.parseMaybeAssign(),this.eat(u.parenR)||(this.expect(u.comma),this.afterTrailingComma(u.parenR)||this.unexpected())));else if(!this.eat(u.parenR)){var e=this.start;this.eat(u.comma)&&this.eat(u.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(s,"ImportExpression")};T.parseImportMeta=function(s){this.next();var e=this.containsEsc;return s.property=this.parseIdent(!0),s.property.name!=="meta"&&this.raiseRecoverable(s.property.start,"The only valid meta property for import is 'import.meta'"),e&&this.raiseRecoverable(s.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(s.start,"Cannot use 'import.meta' outside a module"),this.finishNode(s,"MetaProperty")};T.parseLiteral=function(s){var e=this.startNode();return e.value=s,e.raw=this.input.slice(this.start,this.end),e.raw.charCodeAt(e.raw.length-1)===110&&(e.bigint=e.value!=null?e.value.toString():e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};T.parseParenExpression=function(){this.expect(u.parenL);var s=this.parseExpression();return this.expect(u.parenR),s};T.shouldParseArrow=function(s){return!this.canInsertSemicolon()};T.parseParenAndDistinguishExpression=function(s,e){var t=this.start,i=this.startLoc,n,r=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a=this.start,o=this.startLoc,c=[],l=!0,p=!1,h=new Ne,f=this.yieldPos,g=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==u.parenR;)if(l?l=!1:this.expect(u.comma),r&&this.afterTrailingComma(u.parenR,!0)){p=!0;break}else if(this.type===u.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else c.push(this.parseMaybeAssign(!1,h,this.parseParenItem));var E=this.lastTokEnd,y=this.lastTokEndLoc;if(this.expect(u.parenR),s&&this.shouldParseArrow(c)&&this.eat(u.arrow))return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=g,this.parseParenArrowList(t,i,c,e);(!c.length||p)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(h,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=g||this.awaitPos,c.length>1?(n=this.startNodeAt(a,o),n.expressions=c,this.finishNodeAt(n,"SequenceExpression",E,y)):n=c[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var S=this.startNodeAt(t,i);return S.expression=n,this.finishNode(S,"ParenthesizedExpression")}else return n};T.parseParenItem=function(s){return s};T.parseParenArrowList=function(s,e,t,i){return this.parseArrowExpression(this.startNodeAt(s,e),t,!1,i)};var ss=[];T.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var s=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===u.dot){var e=this.startNodeAt(s.start,s.loc&&s.loc.start);e.name="new",s.meta=this.finishNode(e,"Identifier"),this.next();var t=this.containsEsc;return s.property=this.parseIdent(!0),s.property.name!=="target"&&this.raiseRecoverable(s.property.start,"The only valid meta property for new is 'new.target'"),t&&this.raiseRecoverable(s.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(s.start,"'new.target' can only be used in functions and class static block"),this.finishNode(s,"MetaProperty")}var i=this.start,n=this.startLoc;return s.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),i,n,!0,!1),this.eat(u.parenL)?s.arguments=this.parseExprList(u.parenR,this.options.ecmaVersion>=8,!1):s.arguments=ss,this.finishNode(s,"NewExpression")};T.parseTemplateElement=function(s){var e=s.isTagged,t=this.startNode();return this.type===u.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),t.value={raw:this.value.replace(/\r\n?/g,`
|
|
4
|
+
`),cooked:null}):t.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
5
|
+
`),cooked:this.value},this.next(),t.tail=this.type===u.backQuote,this.finishNode(t,"TemplateElement")};T.parseTemplate=function(s){s===void 0&&(s={});var e=s.isTagged;e===void 0&&(e=!1);var t=this.startNode();this.next(),t.expressions=[];var i=this.parseTemplateElement({isTagged:e});for(t.quasis=[i];!i.tail;)this.type===u.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(u.dollarBraceL),t.expressions.push(this.parseExpression()),this.expect(u.braceR),t.quasis.push(i=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(t,"TemplateLiteral")};T.isAsyncProp=function(s){return!s.computed&&s.key.type==="Identifier"&&s.key.name==="async"&&(this.type===u.name||this.type===u.num||this.type===u.string||this.type===u.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===u.star)&&!D.test(this.input.slice(this.lastTokEnd,this.start))};T.parseObj=function(s,e){var t=this.startNode(),i=!0,n={};for(t.properties=[],this.next();!this.eat(u.braceR);){if(i)i=!1;else if(this.expect(u.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(u.braceR))break;var r=this.parseProperty(s,e);s||this.checkPropClash(r,n,e),t.properties.push(r)}return this.finishNode(t,s?"ObjectPattern":"ObjectExpression")};T.parseProperty=function(s,e){var t=this.startNode(),i,n,r,a;if(this.options.ecmaVersion>=9&&this.eat(u.ellipsis))return s?(t.argument=this.parseIdent(!1),this.type===u.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(t,"RestElement")):(t.argument=this.parseMaybeAssign(!1,e),this.type===u.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(t,"SpreadElement"));this.options.ecmaVersion>=6&&(t.method=!1,t.shorthand=!1,(s||e)&&(r=this.start,a=this.startLoc),s||(i=this.eat(u.star)));var o=this.containsEsc;return this.parsePropertyName(t),!s&&!o&&this.options.ecmaVersion>=8&&!i&&this.isAsyncProp(t)?(n=!0,i=this.options.ecmaVersion>=9&&this.eat(u.star),this.parsePropertyName(t)):n=!1,this.parsePropertyValue(t,s,i,n,r,a,e,o),this.finishNode(t,"Property")};T.parseGetterSetter=function(s){var e=s.key.name;this.parsePropertyName(s),s.value=this.parseMethod(!1),s.kind=e;var t=s.kind==="get"?0:1;if(s.value.params.length!==t){var i=s.value.start;s.kind==="get"?this.raiseRecoverable(i,"getter should have no params"):this.raiseRecoverable(i,"setter should have exactly one param")}else s.kind==="set"&&s.value.params[0].type==="RestElement"&&this.raiseRecoverable(s.value.params[0].start,"Setter cannot use rest params")};T.parsePropertyValue=function(s,e,t,i,n,r,a,o){(t||i)&&this.type===u.colon&&this.unexpected(),this.eat(u.colon)?(s.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),s.kind="init"):this.options.ecmaVersion>=6&&this.type===u.parenL?(e&&this.unexpected(),s.method=!0,s.value=this.parseMethod(t,i),s.kind="init"):!e&&!o&&this.options.ecmaVersion>=5&&!s.computed&&s.key.type==="Identifier"&&(s.key.name==="get"||s.key.name==="set")&&this.type!==u.comma&&this.type!==u.braceR&&this.type!==u.eq?((t||i)&&this.unexpected(),this.parseGetterSetter(s)):this.options.ecmaVersion>=6&&!s.computed&&s.key.type==="Identifier"?((t||i)&&this.unexpected(),this.checkUnreserved(s.key),s.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=n),e?s.value=this.parseMaybeDefault(n,r,this.copyNode(s.key)):this.type===u.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),s.value=this.parseMaybeDefault(n,r,this.copyNode(s.key))):s.value=this.copyNode(s.key),s.kind="init",s.shorthand=!0):this.unexpected()};T.parsePropertyName=function(s){if(this.options.ecmaVersion>=6){if(this.eat(u.bracketL))return s.computed=!0,s.key=this.parseMaybeAssign(),this.expect(u.bracketR),s.key;s.computed=!1}return s.key=this.type===u.num||this.type===u.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};T.initFunction=function(s){s.id=null,this.options.ecmaVersion>=6&&(s.generator=s.expression=!1),this.options.ecmaVersion>=8&&(s.async=!1)};T.parseMethod=function(s,e,t){var i=this.startNode(),n=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(i),this.options.ecmaVersion>=6&&(i.generator=s),this.options.ecmaVersion>=8&&(i.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(qe(e,i.generator)|Pe|(t?pt:0)),this.expect(u.parenL),i.params=this.parseBindingList(u.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(i,!1,!0,!1),this.yieldPos=n,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(i,"FunctionExpression")};T.parseArrowExpression=function(s,e,t,i){var n=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(qe(t,!1)|He),this.initFunction(s),this.options.ecmaVersion>=8&&(s.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,s.params=this.toAssignableList(e,!0),this.parseFunctionBody(s,!0,!1,i),this.yieldPos=n,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(s,"ArrowFunctionExpression")};T.parseFunctionBody=function(s,e,t,i){var n=e&&this.type!==u.braceL,r=this.strict,a=!1;if(n)s.body=this.parseMaybeAssign(i),s.expression=!0,this.checkParams(s,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(s.params);(!r||o)&&(a=this.strictDirective(this.end),a&&o&&this.raiseRecoverable(s.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var c=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(s,!r&&!a&&!e&&!t&&this.isSimpleParamList(s.params)),this.strict&&s.id&&this.checkLValSimple(s.id,dt),s.body=this.parseBlock(!1,void 0,a&&!r),s.expression=!1,this.adaptDirectivePrologue(s.body.body),this.labels=c}this.exitScope()};T.isSimpleParamList=function(s){for(var e=0,t=s;e<t.length;e+=1){var i=t[e];if(i.type!=="Identifier")return!1}return!0};T.checkParams=function(s,e){for(var t=Object.create(null),i=0,n=s.params;i<n.length;i+=1){var r=n[i];this.checkLValInnerPattern(r,Xe,e?null:t)}};T.parseExprList=function(s,e,t,i){for(var n=[],r=!0;!this.eat(s);){if(r)r=!1;else if(this.expect(u.comma),e&&this.afterTrailingComma(s))break;var a=void 0;t&&this.type===u.comma?a=null:this.type===u.ellipsis?(a=this.parseSpread(i),i&&this.type===u.comma&&i.trailingComma<0&&(i.trailingComma=this.start)):a=this.parseMaybeAssign(!1,i),n.push(a)}return n};T.checkUnreserved=function(s){var e=s.start,t=s.end,i=s.name;if(this.inGenerator&&i==="yield"&&this.raiseRecoverable(e,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&i==="await"&&this.raiseRecoverable(e,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&_e)&&i==="arguments"&&this.raiseRecoverable(e,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(i==="arguments"||i==="await")&&this.raise(e,"Cannot use "+i+" in class static initialization block"),this.keywords.test(i)&&this.raise(e,"Unexpected keyword '"+i+"'"),!(this.options.ecmaVersion<6&&this.input.slice(e,t).indexOf("\\")!==-1)){var n=this.strict?this.reservedWordsStrict:this.reservedWords;n.test(i)&&(!this.inAsync&&i==="await"&&this.raiseRecoverable(e,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(e,"The keyword '"+i+"' is reserved"))}};T.parseIdent=function(s){var e=this.parseIdentNode();return this.next(!!s),this.finishNode(e,"Identifier"),s||(this.checkUnreserved(e),e.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=e.start)),e};T.parseIdentNode=function(){var s=this.startNode();return this.type===u.name?s.name=this.value:this.type.keyword?(s.name=this.type.keyword,(s.name==="class"||s.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=u.name):this.unexpected(),s};T.parsePrivateIdent=function(){var s=this.startNode();return this.type===u.privateId?s.name=this.value:this.unexpected(),this.next(),this.finishNode(s,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(s.start,"Private field '#"+s.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(s)),s};T.parseYield=function(s){this.yieldPos||(this.yieldPos=this.start);var e=this.startNode();return this.next(),this.type===u.semi||this.canInsertSemicolon()||this.type!==u.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(u.star),e.argument=this.parseMaybeAssign(s)),this.finishNode(e,"YieldExpression")};T.parseAwait=function(s){this.awaitPos||(this.awaitPos=this.start);var e=this.startNode();return this.next(),e.argument=this.parseMaybeUnary(null,!0,!1,s),this.finishNode(e,"AwaitExpression")};var Te=M.prototype;Te.raise=function(s,e){var t=ct(this.input,s);e+=" ("+t.line+":"+t.column+")",this.sourceFile&&(e+=" in "+this.sourceFile);var i=new SyntaxError(e);throw i.pos=s,i.loc=t,i.raisedAt=this.pos,i};Te.raiseRecoverable=Te.raise;Te.curPosition=function(){if(this.options.locations)return new ge(this.curLine,this.pos-this.lineStart)};var se=M.prototype,is=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};se.enterScope=function(s){this.scopeStack.push(new is(s))};se.exitScope=function(){this.scopeStack.pop()};se.treatFunctionsAsVarInScope=function(s){return s.flags&fe||!this.inModule&&s.flags&xe};se.declareName=function(s,e,t){var i=!1;if(e===J){var n=this.currentScope();i=n.lexical.indexOf(s)>-1||n.functions.indexOf(s)>-1||n.var.indexOf(s)>-1,n.lexical.push(s),this.inModule&&n.flags&xe&&delete this.undefinedExports[s]}else if(e===ft){var r=this.currentScope();r.lexical.push(s)}else if(e===ht){var a=this.currentScope();this.treatFunctionsAsVar?i=a.lexical.indexOf(s)>-1:i=a.lexical.indexOf(s)>-1||a.var.indexOf(s)>-1,a.functions.push(s)}else for(var o=this.scopeStack.length-1;o>=0;--o){var c=this.scopeStack[o];if(c.lexical.indexOf(s)>-1&&!(c.flags<&&c.lexical[0]===s)||!this.treatFunctionsAsVarInScope(c)&&c.functions.indexOf(s)>-1){i=!0;break}if(c.var.push(s),this.inModule&&c.flags&xe&&delete this.undefinedExports[s],c.flags&_e)break}i&&this.raiseRecoverable(t,"Identifier '"+s+"' has already been declared")};se.checkLocalExport=function(s){this.scopeStack[0].lexical.indexOf(s.name)===-1&&this.scopeStack[0].var.indexOf(s.name)===-1&&(this.undefinedExports[s.name]=s)};se.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};se.currentVarScope=function(){for(var s=this.scopeStack.length-1;;s--){var e=this.scopeStack[s];if(e.flags&(_e|be|ae))return e}};se.currentThisScope=function(){for(var s=this.scopeStack.length-1;;s--){var e=this.scopeStack[s];if(e.flags&(_e|be|ae)&&!(e.flags&He))return e}};var ke=function(e,t,i){this.type="",this.start=t,this.end=0,e.options.locations&&(this.loc=new we(e,i)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Ce=M.prototype;Ce.startNode=function(){return new ke(this,this.start,this.startLoc)};Ce.startNodeAt=function(s,e){return new ke(this,s,e)};function xt(s,e,t,i){return s.type=e,s.end=t,this.options.locations&&(s.loc.end=i),this.options.ranges&&(s.range[1]=t),s}Ce.finishNode=function(s,e){return xt.call(this,s,e,this.lastTokEnd,this.lastTokEndLoc)};Ce.finishNodeAt=function(s,e,t,i){return xt.call(this,s,e,t,i)};Ce.copyNode=function(s){var e=new ke(this,s.start,this.startLoc);for(var t in s)e[t]=s[t];return e};var ns="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",Et="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",bt=Et+" Extended_Pictographic",Ct=bt,yt=Ct+" EBase EComp EMod EPres ExtPict",vt=yt,rs=vt,as={9:Et,10:bt,11:Ct,12:yt,13:vt,14:rs},os="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",cs={9:"",10:"",11:"",12:"",13:"",14:os},et="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",St="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",Tt=St+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",At=Tt+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",wt=At+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Pt=wt+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",us=Pt+" "+ns,ls={9:St,10:Tt,11:At,12:wt,13:Pt,14:us},_t={};function ps(s){var e=_t[s]={binary:ee(as[s]+" "+et),binaryOfStrings:ee(cs[s]),nonBinary:{General_Category:ee(et),Script:ee(ls[s])}};e.nonBinary.Script_Extensions=e.nonBinary.Script,e.nonBinary.gc=e.nonBinary.General_Category,e.nonBinary.sc=e.nonBinary.Script,e.nonBinary.scx=e.nonBinary.Script_Extensions}for(var Fe=0,tt=[9,10,11,12,13,14];Fe<tt.length;Fe+=1){var hs=tt[Fe];ps(hs)}var b=M.prototype,Ae=function(e,t){this.parent=e,this.base=t||this};Ae.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var i=e;i;i=i.parent)if(t.base===i.base&&t!==i)return!0;return!1};Ae.prototype.sibling=function(){return new Ae(this.parent,this.base)};var Q=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=_t[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};Q.prototype.reset=function(e,t,i){var n=i.indexOf("v")!==-1,r=i.indexOf("u")!==-1;this.start=e|0,this.source=t+"",this.flags=i,n&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=r&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=r&&this.parser.options.ecmaVersion>=9)};Q.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)};Q.prototype.at=function(e,t){t===void 0&&(t=!1);var i=this.source,n=i.length;if(e>=n)return-1;var r=i.charCodeAt(e);if(!(t||this.switchU)||r<=55295||r>=57344||e+1>=n)return r;var a=i.charCodeAt(e+1);return a>=56320&&a<=57343?(r<<10)+a-56613888:r};Q.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var i=this.source,n=i.length;if(e>=n)return n;var r=i.charCodeAt(e),a;return!(t||this.switchU)||r<=55295||r>=57344||e+1>=n||(a=i.charCodeAt(e+1))<56320||a>57343?e+1:e+2};Q.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)};Q.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)};Q.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)};Q.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1};Q.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var i=this.pos,n=0,r=e;n<r.length;n+=1){var a=r[n],o=this.at(i,t);if(o===-1||o!==a)return!1;i=this.nextIndex(i,t)}return this.pos=i,!0};b.validateRegExpFlags=function(s){for(var e=s.validFlags,t=s.flags,i=!1,n=!1,r=0;r<t.length;r++){var a=t.charAt(r);e.indexOf(a)===-1&&this.raise(s.start,"Invalid regular expression flag"),t.indexOf(a,r+1)>-1&&this.raise(s.start,"Duplicate regular expression flag"),a==="u"&&(i=!0),a==="v"&&(n=!0)}this.options.ecmaVersion>=15&&i&&n&&this.raise(s.start,"Invalid regular expression flag")};function fs(s){for(var e in s)return!0;return!1}b.validateRegExpPattern=function(s){this.regexp_pattern(s),!s.switchN&&this.options.ecmaVersion>=9&&fs(s.groupNames)&&(s.switchN=!0,this.regexp_pattern(s))};b.regexp_pattern=function(s){s.pos=0,s.lastIntValue=0,s.lastStringValue="",s.lastAssertionIsQuantifiable=!1,s.numCapturingParens=0,s.maxBackReference=0,s.groupNames=Object.create(null),s.backReferenceNames.length=0,s.branchID=null,this.regexp_disjunction(s),s.pos!==s.source.length&&(s.eat(41)&&s.raise("Unmatched ')'"),(s.eat(93)||s.eat(125))&&s.raise("Lone quantifier brackets")),s.maxBackReference>s.numCapturingParens&&s.raise("Invalid escape");for(var e=0,t=s.backReferenceNames;e<t.length;e+=1){var i=t[e];s.groupNames[i]||s.raise("Invalid named capture referenced")}};b.regexp_disjunction=function(s){var e=this.options.ecmaVersion>=16;for(e&&(s.branchID=new Ae(s.branchID,null)),this.regexp_alternative(s);s.eat(124);)e&&(s.branchID=s.branchID.sibling()),this.regexp_alternative(s);e&&(s.branchID=s.branchID.parent),this.regexp_eatQuantifier(s,!0)&&s.raise("Nothing to repeat"),s.eat(123)&&s.raise("Lone quantifier brackets")};b.regexp_alternative=function(s){for(;s.pos<s.source.length&&this.regexp_eatTerm(s););};b.regexp_eatTerm=function(s){return this.regexp_eatAssertion(s)?(s.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(s)&&s.switchU&&s.raise("Invalid quantifier"),!0):(s.switchU?this.regexp_eatAtom(s):this.regexp_eatExtendedAtom(s))?(this.regexp_eatQuantifier(s),!0):!1};b.regexp_eatAssertion=function(s){var e=s.pos;if(s.lastAssertionIsQuantifiable=!1,s.eat(94)||s.eat(36))return!0;if(s.eat(92)){if(s.eat(66)||s.eat(98))return!0;s.pos=e}if(s.eat(40)&&s.eat(63)){var t=!1;if(this.options.ecmaVersion>=9&&(t=s.eat(60)),s.eat(61)||s.eat(33))return this.regexp_disjunction(s),s.eat(41)||s.raise("Unterminated group"),s.lastAssertionIsQuantifiable=!t,!0}return s.pos=e,!1};b.regexp_eatQuantifier=function(s,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(s,e)?(s.eat(63),!0):!1};b.regexp_eatQuantifierPrefix=function(s,e){return s.eat(42)||s.eat(43)||s.eat(63)||this.regexp_eatBracedQuantifier(s,e)};b.regexp_eatBracedQuantifier=function(s,e){var t=s.pos;if(s.eat(123)){var i=0,n=-1;if(this.regexp_eatDecimalDigits(s)&&(i=s.lastIntValue,s.eat(44)&&this.regexp_eatDecimalDigits(s)&&(n=s.lastIntValue),s.eat(125)))return n!==-1&&n<i&&!e&&s.raise("numbers out of order in {} quantifier"),!0;s.switchU&&!e&&s.raise("Incomplete quantifier"),s.pos=t}return!1};b.regexp_eatAtom=function(s){return this.regexp_eatPatternCharacters(s)||s.eat(46)||this.regexp_eatReverseSolidusAtomEscape(s)||this.regexp_eatCharacterClass(s)||this.regexp_eatUncapturingGroup(s)||this.regexp_eatCapturingGroup(s)};b.regexp_eatReverseSolidusAtomEscape=function(s){var e=s.pos;if(s.eat(92)){if(this.regexp_eatAtomEscape(s))return!0;s.pos=e}return!1};b.regexp_eatUncapturingGroup=function(s){var e=s.pos;if(s.eat(40)){if(s.eat(63)){if(this.options.ecmaVersion>=16){var t=this.regexp_eatModifiers(s),i=s.eat(45);if(t||i){for(var n=0;n<t.length;n++){var r=t.charAt(n);t.indexOf(r,n+1)>-1&&s.raise("Duplicate regular expression modifiers")}if(i){var a=this.regexp_eatModifiers(s);!t&&!a&&s.current()===58&&s.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var c=a.charAt(o);(a.indexOf(c,o+1)>-1||t.indexOf(c)>-1)&&s.raise("Duplicate regular expression modifiers")}}}}if(s.eat(58)){if(this.regexp_disjunction(s),s.eat(41))return!0;s.raise("Unterminated group")}}s.pos=e}return!1};b.regexp_eatCapturingGroup=function(s){if(s.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(s):s.current()===63&&s.raise("Invalid group"),this.regexp_disjunction(s),s.eat(41))return s.numCapturingParens+=1,!0;s.raise("Unterminated group")}return!1};b.regexp_eatModifiers=function(s){for(var e="",t=0;(t=s.current())!==-1&&ds(t);)e+=Z(t),s.advance();return e};function ds(s){return s===105||s===109||s===115}b.regexp_eatExtendedAtom=function(s){return s.eat(46)||this.regexp_eatReverseSolidusAtomEscape(s)||this.regexp_eatCharacterClass(s)||this.regexp_eatUncapturingGroup(s)||this.regexp_eatCapturingGroup(s)||this.regexp_eatInvalidBracedQuantifier(s)||this.regexp_eatExtendedPatternCharacter(s)};b.regexp_eatInvalidBracedQuantifier=function(s){return this.regexp_eatBracedQuantifier(s,!0)&&s.raise("Nothing to repeat"),!1};b.regexp_eatSyntaxCharacter=function(s){var e=s.current();return Nt(e)?(s.lastIntValue=e,s.advance(),!0):!1};function Nt(s){return s===36||s>=40&&s<=43||s===46||s===63||s>=91&&s<=94||s>=123&&s<=125}b.regexp_eatPatternCharacters=function(s){for(var e=s.pos,t=0;(t=s.current())!==-1&&!Nt(t);)s.advance();return s.pos!==e};b.regexp_eatExtendedPatternCharacter=function(s){var e=s.current();return e!==-1&&e!==36&&!(e>=40&&e<=43)&&e!==46&&e!==63&&e!==91&&e!==94&&e!==124?(s.advance(),!0):!1};b.regexp_groupSpecifier=function(s){if(s.eat(63)){this.regexp_eatGroupName(s)||s.raise("Invalid group");var e=this.options.ecmaVersion>=16,t=s.groupNames[s.lastStringValue];if(t)if(e)for(var i=0,n=t;i<n.length;i+=1){var r=n[i];r.separatedFrom(s.branchID)||s.raise("Duplicate capture group name")}else s.raise("Duplicate capture group name");e?(t||(s.groupNames[s.lastStringValue]=[])).push(s.branchID):s.groupNames[s.lastStringValue]=!0}};b.regexp_eatGroupName=function(s){if(s.lastStringValue="",s.eat(60)){if(this.regexp_eatRegExpIdentifierName(s)&&s.eat(62))return!0;s.raise("Invalid capture group name")}return!1};b.regexp_eatRegExpIdentifierName=function(s){if(s.lastStringValue="",this.regexp_eatRegExpIdentifierStart(s)){for(s.lastStringValue+=Z(s.lastIntValue);this.regexp_eatRegExpIdentifierPart(s);)s.lastStringValue+=Z(s.lastIntValue);return!0}return!1};b.regexp_eatRegExpIdentifierStart=function(s){var e=s.pos,t=this.options.ecmaVersion>=11,i=s.current(t);return s.advance(t),i===92&&this.regexp_eatRegExpUnicodeEscapeSequence(s,t)&&(i=s.lastIntValue),ms(i)?(s.lastIntValue=i,!0):(s.pos=e,!1)};function ms(s){return K(s,!0)||s===36||s===95}b.regexp_eatRegExpIdentifierPart=function(s){var e=s.pos,t=this.options.ecmaVersion>=11,i=s.current(t);return s.advance(t),i===92&&this.regexp_eatRegExpUnicodeEscapeSequence(s,t)&&(i=s.lastIntValue),gs(i)?(s.lastIntValue=i,!0):(s.pos=e,!1)};function gs(s){return te(s,!0)||s===36||s===95||s===8204||s===8205}b.regexp_eatAtomEscape=function(s){return this.regexp_eatBackReference(s)||this.regexp_eatCharacterClassEscape(s)||this.regexp_eatCharacterEscape(s)||s.switchN&&this.regexp_eatKGroupName(s)?!0:(s.switchU&&(s.current()===99&&s.raise("Invalid unicode escape"),s.raise("Invalid escape")),!1)};b.regexp_eatBackReference=function(s){var e=s.pos;if(this.regexp_eatDecimalEscape(s)){var t=s.lastIntValue;if(s.switchU)return t>s.maxBackReference&&(s.maxBackReference=t),!0;if(t<=s.numCapturingParens)return!0;s.pos=e}return!1};b.regexp_eatKGroupName=function(s){if(s.eat(107)){if(this.regexp_eatGroupName(s))return s.backReferenceNames.push(s.lastStringValue),!0;s.raise("Invalid named reference")}return!1};b.regexp_eatCharacterEscape=function(s){return this.regexp_eatControlEscape(s)||this.regexp_eatCControlLetter(s)||this.regexp_eatZero(s)||this.regexp_eatHexEscapeSequence(s)||this.regexp_eatRegExpUnicodeEscapeSequence(s,!1)||!s.switchU&&this.regexp_eatLegacyOctalEscapeSequence(s)||this.regexp_eatIdentityEscape(s)};b.regexp_eatCControlLetter=function(s){var e=s.pos;if(s.eat(99)){if(this.regexp_eatControlLetter(s))return!0;s.pos=e}return!1};b.regexp_eatZero=function(s){return s.current()===48&&!Ie(s.lookahead())?(s.lastIntValue=0,s.advance(),!0):!1};b.regexp_eatControlEscape=function(s){var e=s.current();return e===116?(s.lastIntValue=9,s.advance(),!0):e===110?(s.lastIntValue=10,s.advance(),!0):e===118?(s.lastIntValue=11,s.advance(),!0):e===102?(s.lastIntValue=12,s.advance(),!0):e===114?(s.lastIntValue=13,s.advance(),!0):!1};b.regexp_eatControlLetter=function(s){var e=s.current();return kt(e)?(s.lastIntValue=e%32,s.advance(),!0):!1};function kt(s){return s>=65&&s<=90||s>=97&&s<=122}b.regexp_eatRegExpUnicodeEscapeSequence=function(s,e){e===void 0&&(e=!1);var t=s.pos,i=e||s.switchU;if(s.eat(117)){if(this.regexp_eatFixedHexDigits(s,4)){var n=s.lastIntValue;if(i&&n>=55296&&n<=56319){var r=s.pos;if(s.eat(92)&&s.eat(117)&&this.regexp_eatFixedHexDigits(s,4)){var a=s.lastIntValue;if(a>=56320&&a<=57343)return s.lastIntValue=(n-55296)*1024+(a-56320)+65536,!0}s.pos=r,s.lastIntValue=n}return!0}if(i&&s.eat(123)&&this.regexp_eatHexDigits(s)&&s.eat(125)&&xs(s.lastIntValue))return!0;i&&s.raise("Invalid unicode escape"),s.pos=t}return!1};function xs(s){return s>=0&&s<=1114111}b.regexp_eatIdentityEscape=function(s){if(s.switchU)return this.regexp_eatSyntaxCharacter(s)?!0:s.eat(47)?(s.lastIntValue=47,!0):!1;var e=s.current();return e!==99&&(!s.switchN||e!==107)?(s.lastIntValue=e,s.advance(),!0):!1};b.regexp_eatDecimalEscape=function(s){s.lastIntValue=0;var e=s.current();if(e>=49&&e<=57){do s.lastIntValue=10*s.lastIntValue+(e-48),s.advance();while((e=s.current())>=48&&e<=57);return!0}return!1};var It=0,Y=1,j=2;b.regexp_eatCharacterClassEscape=function(s){var e=s.current();if(Es(e))return s.lastIntValue=-1,s.advance(),Y;var t=!1;if(s.switchU&&this.options.ecmaVersion>=9&&((t=e===80)||e===112)){s.lastIntValue=-1,s.advance();var i;if(s.eat(123)&&(i=this.regexp_eatUnicodePropertyValueExpression(s))&&s.eat(125))return t&&i===j&&s.raise("Invalid property name"),i;s.raise("Invalid property name")}return It};function Es(s){return s===100||s===68||s===115||s===83||s===119||s===87}b.regexp_eatUnicodePropertyValueExpression=function(s){var e=s.pos;if(this.regexp_eatUnicodePropertyName(s)&&s.eat(61)){var t=s.lastStringValue;if(this.regexp_eatUnicodePropertyValue(s)){var i=s.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(s,t,i),Y}}if(s.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(s)){var n=s.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(s,n)}return It};b.regexp_validateUnicodePropertyNameAndValue=function(s,e,t){he(s.unicodeProperties.nonBinary,e)||s.raise("Invalid property name"),s.unicodeProperties.nonBinary[e].test(t)||s.raise("Invalid property value")};b.regexp_validateUnicodePropertyNameOrValue=function(s,e){if(s.unicodeProperties.binary.test(e))return Y;if(s.switchV&&s.unicodeProperties.binaryOfStrings.test(e))return j;s.raise("Invalid property name")};b.regexp_eatUnicodePropertyName=function(s){var e=0;for(s.lastStringValue="";Mt(e=s.current());)s.lastStringValue+=Z(e),s.advance();return s.lastStringValue!==""};function Mt(s){return kt(s)||s===95}b.regexp_eatUnicodePropertyValue=function(s){var e=0;for(s.lastStringValue="";bs(e=s.current());)s.lastStringValue+=Z(e),s.advance();return s.lastStringValue!==""};function bs(s){return Mt(s)||Ie(s)}b.regexp_eatLoneUnicodePropertyNameOrValue=function(s){return this.regexp_eatUnicodePropertyValue(s)};b.regexp_eatCharacterClass=function(s){if(s.eat(91)){var e=s.eat(94),t=this.regexp_classContents(s);return s.eat(93)||s.raise("Unterminated character class"),e&&t===j&&s.raise("Negated character class may contain strings"),!0}return!1};b.regexp_classContents=function(s){return s.current()===93?Y:s.switchV?this.regexp_classSetExpression(s):(this.regexp_nonEmptyClassRanges(s),Y)};b.regexp_nonEmptyClassRanges=function(s){for(;this.regexp_eatClassAtom(s);){var e=s.lastIntValue;if(s.eat(45)&&this.regexp_eatClassAtom(s)){var t=s.lastIntValue;s.switchU&&(e===-1||t===-1)&&s.raise("Invalid character class"),e!==-1&&t!==-1&&e>t&&s.raise("Range out of order in character class")}}};b.regexp_eatClassAtom=function(s){var e=s.pos;if(s.eat(92)){if(this.regexp_eatClassEscape(s))return!0;if(s.switchU){var t=s.current();(t===99||Lt(t))&&s.raise("Invalid class escape"),s.raise("Invalid escape")}s.pos=e}var i=s.current();return i!==93?(s.lastIntValue=i,s.advance(),!0):!1};b.regexp_eatClassEscape=function(s){var e=s.pos;if(s.eat(98))return s.lastIntValue=8,!0;if(s.switchU&&s.eat(45))return s.lastIntValue=45,!0;if(!s.switchU&&s.eat(99)){if(this.regexp_eatClassControlLetter(s))return!0;s.pos=e}return this.regexp_eatCharacterClassEscape(s)||this.regexp_eatCharacterEscape(s)};b.regexp_classSetExpression=function(s){var e=Y,t;if(!this.regexp_eatClassSetRange(s))if(t=this.regexp_eatClassSetOperand(s)){t===j&&(e=j);for(var i=s.pos;s.eatChars([38,38]);){if(s.current()!==38&&(t=this.regexp_eatClassSetOperand(s))){t!==j&&(e=Y);continue}s.raise("Invalid character in character class")}if(i!==s.pos)return e;for(;s.eatChars([45,45]);)this.regexp_eatClassSetOperand(s)||s.raise("Invalid character in character class");if(i!==s.pos)return e}else s.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(s)){if(t=this.regexp_eatClassSetOperand(s),!t)return e;t===j&&(e=j)}};b.regexp_eatClassSetRange=function(s){var e=s.pos;if(this.regexp_eatClassSetCharacter(s)){var t=s.lastIntValue;if(s.eat(45)&&this.regexp_eatClassSetCharacter(s)){var i=s.lastIntValue;return t!==-1&&i!==-1&&t>i&&s.raise("Range out of order in character class"),!0}s.pos=e}return!1};b.regexp_eatClassSetOperand=function(s){return this.regexp_eatClassSetCharacter(s)?Y:this.regexp_eatClassStringDisjunction(s)||this.regexp_eatNestedClass(s)};b.regexp_eatNestedClass=function(s){var e=s.pos;if(s.eat(91)){var t=s.eat(94),i=this.regexp_classContents(s);if(s.eat(93))return t&&i===j&&s.raise("Negated character class may contain strings"),i;s.pos=e}if(s.eat(92)){var n=this.regexp_eatCharacterClassEscape(s);if(n)return n;s.pos=e}return null};b.regexp_eatClassStringDisjunction=function(s){var e=s.pos;if(s.eatChars([92,113])){if(s.eat(123)){var t=this.regexp_classStringDisjunctionContents(s);if(s.eat(125))return t}else s.raise("Invalid escape");s.pos=e}return null};b.regexp_classStringDisjunctionContents=function(s){for(var e=this.regexp_classString(s);s.eat(124);)this.regexp_classString(s)===j&&(e=j);return e};b.regexp_classString=function(s){for(var e=0;this.regexp_eatClassSetCharacter(s);)e++;return e===1?Y:j};b.regexp_eatClassSetCharacter=function(s){var e=s.pos;if(s.eat(92))return this.regexp_eatCharacterEscape(s)||this.regexp_eatClassSetReservedPunctuator(s)?!0:s.eat(98)?(s.lastIntValue=8,!0):(s.pos=e,!1);var t=s.current();return t<0||t===s.lookahead()&&Cs(t)||ys(t)?!1:(s.advance(),s.lastIntValue=t,!0)};function Cs(s){return s===33||s>=35&&s<=38||s>=42&&s<=44||s===46||s>=58&&s<=64||s===94||s===96||s===126}function ys(s){return s===40||s===41||s===45||s===47||s>=91&&s<=93||s>=123&&s<=125}b.regexp_eatClassSetReservedPunctuator=function(s){var e=s.current();return vs(e)?(s.lastIntValue=e,s.advance(),!0):!1};function vs(s){return s===33||s===35||s===37||s===38||s===44||s===45||s>=58&&s<=62||s===64||s===96||s===126}b.regexp_eatClassControlLetter=function(s){var e=s.current();return Ie(e)||e===95?(s.lastIntValue=e%32,s.advance(),!0):!1};b.regexp_eatHexEscapeSequence=function(s){var e=s.pos;if(s.eat(120)){if(this.regexp_eatFixedHexDigits(s,2))return!0;s.switchU&&s.raise("Invalid escape"),s.pos=e}return!1};b.regexp_eatDecimalDigits=function(s){var e=s.pos,t=0;for(s.lastIntValue=0;Ie(t=s.current());)s.lastIntValue=10*s.lastIntValue+(t-48),s.advance();return s.pos!==e};function Ie(s){return s>=48&&s<=57}b.regexp_eatHexDigits=function(s){var e=s.pos,t=0;for(s.lastIntValue=0;Rt(t=s.current());)s.lastIntValue=16*s.lastIntValue+Ot(t),s.advance();return s.pos!==e};function Rt(s){return s>=48&&s<=57||s>=65&&s<=70||s>=97&&s<=102}function Ot(s){return s>=65&&s<=70?10+(s-65):s>=97&&s<=102?10+(s-97):s-48}b.regexp_eatLegacyOctalEscapeSequence=function(s){if(this.regexp_eatOctalDigit(s)){var e=s.lastIntValue;if(this.regexp_eatOctalDigit(s)){var t=s.lastIntValue;e<=3&&this.regexp_eatOctalDigit(s)?s.lastIntValue=e*64+t*8+s.lastIntValue:s.lastIntValue=e*8+t}else s.lastIntValue=e;return!0}return!1};b.regexp_eatOctalDigit=function(s){var e=s.current();return Lt(e)?(s.lastIntValue=e-48,s.advance(),!0):(s.lastIntValue=0,!1)};function Lt(s){return s>=48&&s<=55}b.regexp_eatFixedHexDigits=function(s,e){var t=s.pos;s.lastIntValue=0;for(var i=0;i<e;++i){var n=s.current();if(!Rt(n))return s.pos=t,!1;s.lastIntValue=16*s.lastIntValue+Ot(n),s.advance()}return!0};var Ke=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new we(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},A=M.prototype;A.next=function(s){!s&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Ke(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};A.getToken=function(){return this.next(),new Ke(this)};typeof Symbol<"u"&&(A[Symbol.iterator]=function(){var s=this;return{next:function(){var e=s.getToken();return{done:e.type===u.eof,value:e}}}});A.nextToken=function(){var s=this.curContext();if((!s||!s.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(u.eof);if(s.override)return s.override(this);this.readToken(this.fullCharCodeAtPos())};A.readToken=function(s){return K(s,this.options.ecmaVersion>=6)||s===92?this.readWord():this.getTokenFromCode(s)};A.fullCharCodeAtPos=function(){var s=this.input.charCodeAt(this.pos);if(s<=55295||s>=56320)return s;var e=this.input.charCodeAt(this.pos+1);return e<=56319||e>=57344?s:(s<<10)+e-56613888};A.skipBlockComment=function(){var s=this.options.onComment&&this.curPosition(),e=this.pos,t=this.input.indexOf("*/",this.pos+=2);if(t===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=t+2,this.options.locations)for(var i=void 0,n=e;(i=rt(this.input,n,this.pos))>-1;)++this.curLine,n=this.lineStart=i;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,t),e,this.pos,s,this.curPosition())};A.skipLineComment=function(s){for(var e=this.pos,t=this.options.onComment&&this.curPosition(),i=this.input.charCodeAt(this.pos+=s);this.pos<this.input.length&&!pe(i);)i=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(e+s,this.pos),e,this.pos,t,this.curPosition())};A.skipSpace=function(){e:for(;this.pos<this.input.length;){var s=this.input.charCodeAt(this.pos);switch(s){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 e}break;default:if(s>8&&s<14||s>=5760&&at.test(String.fromCharCode(s)))++this.pos;else break e}}};A.finishToken=function(s,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var t=this.type;this.type=s,this.value=e,this.updateContext(t)};A.readToken_dot=function(){var s=this.input.charCodeAt(this.pos+1);if(s>=48&&s<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&s===46&&e===46?(this.pos+=3,this.finishToken(u.ellipsis)):(++this.pos,this.finishToken(u.dot))};A.readToken_slash=function(){var s=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):s===61?this.finishOp(u.assign,2):this.finishOp(u.slash,1)};A.readToken_mult_modulo_exp=function(s){var e=this.input.charCodeAt(this.pos+1),t=1,i=s===42?u.star:u.modulo;return this.options.ecmaVersion>=7&&s===42&&e===42&&(++t,i=u.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(u.assign,t+1):this.finishOp(i,t)};A.readToken_pipe_amp=function(s){var e=this.input.charCodeAt(this.pos+1);if(e===s){if(this.options.ecmaVersion>=12){var t=this.input.charCodeAt(this.pos+2);if(t===61)return this.finishOp(u.assign,3)}return this.finishOp(s===124?u.logicalOR:u.logicalAND,2)}return e===61?this.finishOp(u.assign,2):this.finishOp(s===124?u.bitwiseOR:u.bitwiseAND,1)};A.readToken_caret=function(){var s=this.input.charCodeAt(this.pos+1);return s===61?this.finishOp(u.assign,2):this.finishOp(u.bitwiseXOR,1)};A.readToken_plus_min=function(s){var e=this.input.charCodeAt(this.pos+1);return e===s?e===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(u.incDec,2):e===61?this.finishOp(u.assign,2):this.finishOp(u.plusMin,1)};A.readToken_lt_gt=function(s){var e=this.input.charCodeAt(this.pos+1),t=1;return e===s?(t=s===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+t)===61?this.finishOp(u.assign,t+1):this.finishOp(u.bitShift,t)):e===33&&s===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(e===61&&(t=2),this.finishOp(u.relational,t))};A.readToken_eq_excl=function(s){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(u.equality,this.input.charCodeAt(this.pos+2)===61?3:2):s===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(u.arrow)):this.finishOp(s===61?u.eq:u.prefix,1)};A.readToken_question=function(){var s=this.options.ecmaVersion;if(s>=11){var e=this.input.charCodeAt(this.pos+1);if(e===46){var t=this.input.charCodeAt(this.pos+2);if(t<48||t>57)return this.finishOp(u.questionDot,2)}if(e===63){if(s>=12){var i=this.input.charCodeAt(this.pos+2);if(i===61)return this.finishOp(u.assign,3)}return this.finishOp(u.coalesce,2)}}return this.finishOp(u.question,1)};A.readToken_numberSign=function(){var s=this.options.ecmaVersion,e=35;if(s>=13&&(++this.pos,e=this.fullCharCodeAtPos(),K(e,!0)||e===92))return this.finishToken(u.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+Z(e)+"'")};A.getTokenFromCode=function(s){switch(s){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(u.parenL);case 41:return++this.pos,this.finishToken(u.parenR);case 59:return++this.pos,this.finishToken(u.semi);case 44:return++this.pos,this.finishToken(u.comma);case 91:return++this.pos,this.finishToken(u.bracketL);case 93:return++this.pos,this.finishToken(u.bracketR);case 123:return++this.pos,this.finishToken(u.braceL);case 125:return++this.pos,this.finishToken(u.braceR);case 58:return++this.pos,this.finishToken(u.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(u.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(e===120||e===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(e===111||e===79)return this.readRadixNumber(8);if(e===98||e===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(s);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(s);case 124:case 38:return this.readToken_pipe_amp(s);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(s);case 60:case 62:return this.readToken_lt_gt(s);case 61:case 33:return this.readToken_eq_excl(s);case 63:return this.readToken_question();case 126:return this.finishOp(u.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+Z(s)+"'")};A.finishOp=function(s,e){var t=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(s,t)};A.readRegexp=function(){for(var s,e,t=this.pos;;){this.pos>=this.input.length&&this.raise(t,"Unterminated regular expression");var i=this.input.charAt(this.pos);if(D.test(i)&&this.raise(t,"Unterminated regular expression"),s)s=!1;else{if(i==="[")e=!0;else if(i==="]"&&e)e=!1;else if(i==="/"&&!e)break;s=i==="\\"}++this.pos}var n=this.input.slice(t,this.pos);++this.pos;var r=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(r);var o=this.regexpState||(this.regexpState=new Q(this));o.reset(t,n,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var c=null;try{c=new RegExp(n,a)}catch{}return this.finishToken(u.regexp,{pattern:n,flags:a,value:c})};A.readInt=function(s,e,t){for(var i=this.options.ecmaVersion>=12&&e===void 0,n=t&&this.input.charCodeAt(this.pos)===48,r=this.pos,a=0,o=0,c=0,l=e??1/0;c<l;++c,++this.pos){var p=this.input.charCodeAt(this.pos),h=void 0;if(i&&p===95){n&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===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"),o=p;continue}if(p>=97?h=p-97+10:p>=65?h=p-65+10:p>=48&&p<=57?h=p-48:h=1/0,h>=s)break;o=p,a=a*s+h}return i&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===r||e!=null&&this.pos-r!==e?null:a};function Ss(s,e){return e?parseInt(s,8):parseFloat(s.replace(/_/g,""))}function Ft(s){return typeof BigInt!="function"?null:BigInt(s.replace(/_/g,""))}A.readRadixNumber=function(s){var e=this.pos;this.pos+=2;var t=this.readInt(s);return t==null&&this.raise(this.start+2,"Expected number in radix "+s),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(t=Ft(this.input.slice(e,this.pos)),++this.pos):K(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(u.num,t)};A.readNumber=function(s){var e=this.pos;!s&&this.readInt(10,void 0,!0)===null&&this.raise(e,"Invalid number");var t=this.pos-e>=2&&this.input.charCodeAt(e)===48;t&&this.strict&&this.raise(e,"Invalid number");var i=this.input.charCodeAt(this.pos);if(!t&&!s&&this.options.ecmaVersion>=11&&i===110){var n=Ft(this.input.slice(e,this.pos));return++this.pos,K(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(u.num,n)}t&&/[89]/.test(this.input.slice(e,this.pos))&&(t=!1),i===46&&!t&&(++this.pos,this.readInt(10),i=this.input.charCodeAt(this.pos)),(i===69||i===101)&&!t&&(i=this.input.charCodeAt(++this.pos),(i===43||i===45)&&++this.pos,this.readInt(10)===null&&this.raise(e,"Invalid number")),K(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var r=Ss(this.input.slice(e,this.pos),t);return this.finishToken(u.num,r)};A.readCodePoint=function(){var s=this.input.charCodeAt(this.pos),e;if(s===123){this.options.ecmaVersion<6&&this.unexpected();var t=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(t,"Code point out of bounds")}else e=this.readHexChar(4);return e};A.readString=function(s){for(var e="",t=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var i=this.input.charCodeAt(this.pos);if(i===s)break;i===92?(e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!1),t=this.pos):i===8232||i===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(pe(i)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(t,this.pos++),this.finishToken(u.string,e)};var Vt={};A.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(s){if(s===Vt)this.readInvalidTemplateToken();else throw s}this.inTemplateElement=!1};A.invalidStringToken=function(s,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Vt;this.raise(s,e)};A.readTmplToken=function(){for(var s="",e=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var t=this.input.charCodeAt(this.pos);if(t===96||t===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===u.template||this.type===u.invalidTemplate)?t===36?(this.pos+=2,this.finishToken(u.dollarBraceL)):(++this.pos,this.finishToken(u.backQuote)):(s+=this.input.slice(e,this.pos),this.finishToken(u.template,s));if(t===92)s+=this.input.slice(e,this.pos),s+=this.readEscapedChar(!0),e=this.pos;else if(pe(t)){switch(s+=this.input.slice(e,this.pos),++this.pos,t){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:s+=`
|
|
6
|
+
`;break;default:s+=String.fromCharCode(t);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}};A.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(u.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
7
7
|
`&&++this.pos;case`
|
|
8
|
-
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};
|
|
9
|
-
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return G(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"),t){var s=this.pos-1;this.invalidStringToken(s,"Invalid escape sequence in template string")}default:if(e>=48&&e<=55){var i=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],n=parseInt(i,8);return n>255&&(i=i.slice(0,-1),n=parseInt(i,8)),this.pos+=i.length-1,e=this.input.charCodeAt(this.pos),(i!=="0"||e===56||e===57)&&(this.strict||t)&&this.invalidStringToken(this.pos-1-i.length,t?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(n)}return ue(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}};w.readHexChar=function(t){var e=this.pos,s=this.readInt(16,t);return s===null&&this.invalidStringToken(e,"Bad character escape sequence"),s};w.readWord1=function(){this.containsEsc=!1;for(var t="",e=!0,s=this.pos,i=this.options.ecmaVersion>=6;this.pos<this.input.length;){var n=this.fullCharCodeAtPos();if(J(n,i))this.pos+=n<=65535?1:2;else if(n===92){this.containsEsc=!0,t+=this.input.slice(s,this.pos);var r=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(e?z:J)(a,i)||this.invalidStringToken(r,"Invalid Unicode escape"),t+=G(a),s=this.pos}else break;e=!1}return t+this.input.slice(s,this.pos)};w.readWord=function(){var t=this.readWord1(),e=u.name;return this.keywords.test(t)&&(e=$e[t]),this.finishToken(e,t)};var vs="8.15.0";N.acorn={Parser:N,version:vs,defaultOptions:Ve,Position:me,SourceLocation:we,getLineInfo:at,Node:ke,TokenType:_,tokTypes:u,keywordTypes:$e,TokContext:H,tokContexts:k,isIdentifierChar:J,isIdentifierStart:z,Token:ze,isNewLine:ue,lineBreak:V,lineBreakG:Ht,nonASCIIwhitespace:nt};function j(t,e){return N.parse(t,e)}function U(t,e,s,i,n){s||(s=g),(function r(a,o,c){var l=c||a.type;s[l](a,o,r),e[l]&&e[l](a,o)})(t,i,n)}function Ss(t,e,s,i,n){var r=[];s||(s=g),(function a(o,c,l){var h=l||o.type,p=o!==r[r.length-1];p&&r.push(o),s[h](o,c,a),e[h]&&e[h](o,c||r,r),p&&r.pop()})(t,i,n)}function Xe(t,e,s){s(t,e)}function re(t,e,s){}var g={};g.Program=g.BlockStatement=g.StaticBlock=function(t,e,s){for(var i=0,n=t.body;i<n.length;i+=1){var r=n[i];s(r,e,"Statement")}};g.Statement=Xe;g.EmptyStatement=re;g.ExpressionStatement=g.ParenthesizedExpression=g.ChainExpression=function(t,e,s){return s(t.expression,e,"Expression")};g.IfStatement=function(t,e,s){s(t.test,e,"Expression"),s(t.consequent,e,"Statement"),t.alternate&&s(t.alternate,e,"Statement")};g.LabeledStatement=function(t,e,s){return s(t.body,e,"Statement")};g.BreakStatement=g.ContinueStatement=re;g.WithStatement=function(t,e,s){s(t.object,e,"Expression"),s(t.body,e,"Statement")};g.SwitchStatement=function(t,e,s){s(t.discriminant,e,"Expression");for(var i=0,n=t.cases;i<n.length;i+=1){var r=n[i];s(r,e)}};g.SwitchCase=function(t,e,s){t.test&&s(t.test,e,"Expression");for(var i=0,n=t.consequent;i<n.length;i+=1){var r=n[i];s(r,e,"Statement")}};g.ReturnStatement=g.YieldExpression=g.AwaitExpression=function(t,e,s){t.argument&&s(t.argument,e,"Expression")};g.ThrowStatement=g.SpreadElement=function(t,e,s){return s(t.argument,e,"Expression")};g.TryStatement=function(t,e,s){s(t.block,e,"Statement"),t.handler&&s(t.handler,e),t.finalizer&&s(t.finalizer,e,"Statement")};g.CatchClause=function(t,e,s){t.param&&s(t.param,e,"Pattern"),s(t.body,e,"Statement")};g.WhileStatement=g.DoWhileStatement=function(t,e,s){s(t.test,e,"Expression"),s(t.body,e,"Statement")};g.ForStatement=function(t,e,s){t.init&&s(t.init,e,"ForInit"),t.test&&s(t.test,e,"Expression"),t.update&&s(t.update,e,"Expression"),s(t.body,e,"Statement")};g.ForInStatement=g.ForOfStatement=function(t,e,s){s(t.left,e,"ForInit"),s(t.right,e,"Expression"),s(t.body,e,"Statement")};g.ForInit=function(t,e,s){t.type==="VariableDeclaration"?s(t,e):s(t,e,"Expression")};g.DebuggerStatement=re;g.FunctionDeclaration=function(t,e,s){return s(t,e,"Function")};g.VariableDeclaration=function(t,e,s){for(var i=0,n=t.declarations;i<n.length;i+=1){var r=n[i];s(r,e)}};g.VariableDeclarator=function(t,e,s){s(t.id,e,"Pattern"),t.init&&s(t.init,e,"Expression")};g.Function=function(t,e,s){t.id&&s(t.id,e,"Pattern");for(var i=0,n=t.params;i<n.length;i+=1){var r=n[i];s(r,e,"Pattern")}s(t.body,e,t.expression?"Expression":"Statement")};g.Pattern=function(t,e,s){t.type==="Identifier"?s(t,e,"VariablePattern"):t.type==="MemberExpression"?s(t,e,"MemberPattern"):s(t,e)};g.VariablePattern=re;g.MemberPattern=Xe;g.RestElement=function(t,e,s){return s(t.argument,e,"Pattern")};g.ArrayPattern=function(t,e,s){for(var i=0,n=t.elements;i<n.length;i+=1){var r=n[i];r&&s(r,e,"Pattern")}};g.ObjectPattern=function(t,e,s){for(var i=0,n=t.properties;i<n.length;i+=1){var r=n[i];r.type==="Property"?(r.computed&&s(r.key,e,"Expression"),s(r.value,e,"Pattern")):r.type==="RestElement"&&s(r.argument,e,"Pattern")}};g.Expression=Xe;g.ThisExpression=g.Super=g.MetaProperty=re;g.ArrayExpression=function(t,e,s){for(var i=0,n=t.elements;i<n.length;i+=1){var r=n[i];r&&s(r,e,"Expression")}};g.ObjectExpression=function(t,e,s){for(var i=0,n=t.properties;i<n.length;i+=1){var r=n[i];s(r,e)}};g.FunctionExpression=g.ArrowFunctionExpression=g.FunctionDeclaration;g.SequenceExpression=function(t,e,s){for(var i=0,n=t.expressions;i<n.length;i+=1){var r=n[i];s(r,e,"Expression")}};g.TemplateLiteral=function(t,e,s){for(var i=0,n=t.quasis;i<n.length;i+=1){var r=n[i];s(r,e)}for(var a=0,o=t.expressions;a<o.length;a+=1){var c=o[a];s(c,e,"Expression")}};g.TemplateElement=re;g.UnaryExpression=g.UpdateExpression=function(t,e,s){s(t.argument,e,"Expression")};g.BinaryExpression=g.LogicalExpression=function(t,e,s){s(t.left,e,"Expression"),s(t.right,e,"Expression")};g.AssignmentExpression=g.AssignmentPattern=function(t,e,s){s(t.left,e,"Pattern"),s(t.right,e,"Expression")};g.ConditionalExpression=function(t,e,s){s(t.test,e,"Expression"),s(t.consequent,e,"Expression"),s(t.alternate,e,"Expression")};g.NewExpression=g.CallExpression=function(t,e,s){if(s(t.callee,e,"Expression"),t.arguments)for(var i=0,n=t.arguments;i<n.length;i+=1){var r=n[i];s(r,e,"Expression")}};g.MemberExpression=function(t,e,s){s(t.object,e,"Expression"),t.computed&&s(t.property,e,"Expression")};g.ExportNamedDeclaration=g.ExportDefaultDeclaration=function(t,e,s){t.declaration&&s(t.declaration,e,t.type==="ExportNamedDeclaration"||t.declaration.id?"Statement":"Expression"),t.source&&s(t.source,e,"Expression")};g.ExportAllDeclaration=function(t,e,s){t.exported&&s(t.exported,e),s(t.source,e,"Expression")};g.ImportDeclaration=function(t,e,s){for(var i=0,n=t.specifiers;i<n.length;i+=1){var r=n[i];s(r,e)}s(t.source,e,"Expression")};g.ImportExpression=function(t,e,s){s(t.source,e,"Expression")};g.ImportSpecifier=g.ImportDefaultSpecifier=g.ImportNamespaceSpecifier=g.Identifier=g.PrivateIdentifier=g.Literal=re;g.TaggedTemplateExpression=function(t,e,s){s(t.tag,e,"Expression"),s(t.quasi,e,"Expression")};g.ClassDeclaration=g.ClassExpression=function(t,e,s){return s(t,e,"Class")};g.Class=function(t,e,s){t.id&&s(t.id,e,"Pattern"),t.superClass&&s(t.superClass,e,"Expression"),s(t.body,e)};g.ClassBody=function(t,e,s){for(var i=0,n=t.body;i<n.length;i+=1){var r=n[i];s(r,e)}};g.MethodDefinition=g.PropertyDefinition=g.Property=function(t,e,s){t.computed&&s(t.key,e,"Expression"),t.value&&s(t.value,e,"Expression")};const d={ATTR_PREFIXES:{COMPONENT:"pp-component",CONTEXT:"pp-context",LOOP:"pp-for",SPREAD:"pp-spread",REF:"pp-ref"},SCRIPT_TYPE:"text/pp",MAX_CACHE_SIZE:2e3,DEBOUNCE_MS:16,POOL_SIZE:10,MUSTACHE_PATTERN:/\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}/,MUSTACHE_SINGLE_PATTERN:/^\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}$/},xe=new Set(["true","false","null","undefined","this","window","document","console","Math","Date","JSON","Object","Array","return","let","const","var","if","else","for","while","switch","case","break","continue","function","new","in","of","typeof","instanceof","void","delete","try","catch","finally","class","extends","super","thisElement","eventObject","arguments"]);function As(t,e){let s;return(...i)=>{clearTimeout(s),s=window.setTimeout(()=>t(...i),e)}}function Vt(t){return t.charAt(0).toUpperCase()+t.slice(1)}function ie(t){if(t==null||typeof t=="boolean"||typeof t=="function"||Array.isArray(t)&&t.length===0||typeof t=="object"&&Object.keys(t).length===0)return"";if(typeof t=="number")return String(t);if(typeof t=="string")return t;if(Array.isArray(t))return t.map(e=>ie(e)).filter(e=>e!=="").join("");if(typeof t=="object")try{return JSON.stringify(t)}catch{return"[object Object]"}return String(t)}class ws{static validate(e,s){const i=[],n=[],r=this.validateTernaryOperator(e);i.push(...r.errors),n.push(...r.warnings);const a=this.validateSyntax(e);return i.push(...a.errors),n.push(...a.warnings),{valid:i.length===0,errors:i,warnings:n}}static validateTernaryOperator(e){const s=[],i=[];if(!e.includes("?")||!e.includes(":"))return{errors:s,warnings:i};const n=e.match(/([^?]+)\?([^:]+):(.+)/);if(!n)return{errors:s,warnings:i};const[,,r,a]=n,o=r.trim(),c=this.validateBranch(o,"truthy");s.push(...c.errors),i.push(...c.warnings);const l=a.trim(),h=this.validateBranch(l,"falsy");return s.push(...h.errors),i.push(...h.warnings),{errors:s,warnings:i}}static validateBranch(e,s){const i=[],n=[],r=this.countQuotes(e);if(r.single%2!==0&&(i.push(`Unmatched single quotes in ternary ${s} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,"'"))){const a=this.suggestQuoteFix(e,"'");a&&i.push(` Did you mean: ${a}`)}if(r.double%2!==0&&(i.push(`Unmatched double quotes in ternary ${s} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,'"'))){const a=this.suggestQuoteFix(e,'"');a&&i.push(` Did you mean: ${a}`)}return r.single===0&&r.double===0&&this.looksLikeUnquotedLiteral(e)&&n.push(`Value "${e}" in ternary ${s} branch may need quotes. Did you mean '${e}' or "${e}"?`),{errors:i,warnings:n}}static hasTrailingOrLeadingQuote(e,s){const i=e.startsWith(s),n=e.endsWith(s);return i&&!n||!i&&n}static suggestQuoteFix(e,s){return e.endsWith(s)&&!e.startsWith(s)?`${s}${e}`:e.startsWith(s)&&!e.endsWith(s)?`${e}${s}`:null}static looksLikeUnquotedLiteral(e){const s=e.trim();return!s||this.isAlreadyQuoted(s)||xe.has(s)||s==="true"||s==="false"||s==="null"||s==="undefined"||!isNaN(Number(s))&&s!==""||/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(s)||s.includes(".")||/\[.*\]/.test(s)||/\(.*\)/.test(s)?!1:!!(s.includes("-")||/\s/.test(s)||/[^a-zA-Z0-9_$.]/.test(s))}static isAlreadyQuoted(e){return e.startsWith("'")&&e.endsWith("'")&&e.length>=2||e.startsWith('"')&&e.endsWith('"')&&e.length>=2}static countQuotes(e){let s=0,i=0,n=!1;for(let r=0;r<e.length;r++){if(n){n=!1;continue}if(e[r]==="\\"){n=!0;continue}e[r]==="'"&&s++,e[r]==='"'&&i++}return{single:s,double:i}}static validateSyntax(e){const s=[],i=[],n=this.checkBrackets(e);n.valid||s.push(n.error);const r=this.checkParentheses(e);return r.valid||s.push(r.error),{errors:s,warnings:i}}static checkBrackets(e){let s=0,i=!1,n="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!i&&(a==="'"||a==='"')?(i=!0,n=a):i&&a===n&&o!=="\\"&&(i=!1,n=""),!i&&(a==="{"&&s++,a==="}"&&s--,s<0))return{valid:!1,error:"Unexpected closing bracket '}'"}}return s!==0?{valid:!1,error:"Mismatched brackets - missing '}'"}:{valid:!0,error:""}}static checkParentheses(e){let s=0,i=!1,n="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!i&&(a==="'"||a==='"')?(i=!0,n=a):i&&a===n&&o!=="\\"&&(i=!1,n=""),!i&&(a==="("&&s++,a===")"&&s--,s<0))return{valid:!1,error:"Unexpected closing parenthesis ')'"}}return s!==0?{valid:!1,error:"Mismatched parentheses - missing ')'"}:{valid:!0,error:""}}}class ae{static instance;walkerPool=[];traversalCache=new WeakMap;lastCacheTime=new WeakMap;CACHE_TTL=250;trackedElements=new Set;static getInstance(){return ae.instance||(ae.instance=new ae),ae.instance}acquireWalker(e,s,i){return document.createTreeWalker(e,s,i)}releaseWalker(e){this.walkerPool.length<3&&this.walkerPool.push(e)}getCachedTraversal(e,s,i){const n=Date.now(),r=this.traversalCache.get(e),a=this.lastCacheTime.get(e);if(r&&a&&n-a<this.CACHE_TTL){const c=r.get(s);if(c)return c}const o=i();return this.traversalCache.has(e)||(this.traversalCache.set(e,new Map),this.trackedElements.add(e)),this.traversalCache.get(e).set(s,o),this.lastCacheTime.set(e,n),o}traverseElementsAndText(e,s,i){const n=this.acquireWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),r=[],a=[];let o;for(;o=n.nextNode();)if(o.nodeType===Node.ELEMENT_NODE){const c=o;(!s||s(c))&&r.push(c)}else if(o.nodeType===Node.TEXT_NODE){const c=o;(!i||i(c))&&a.push(c)}return this.releaseWalker(n),{elements:r,textNodes:a}}cleanupCache(){const e=[];for(const s of this.trackedElements)document.contains(s)||e.push(s);e.forEach(s=>{this.traversalCache.delete(s),this.lastCacheTime.delete(s),this.trackedElements.delete(s)})}}class L{static instance;componentElementsCache=new $(100);scriptElementsCache=new $(50);templateElementsCache=new $(50);selectorCache=new $(200);elementComponentCache=new WeakMap;parentComponentCache=new WeakMap;contextComponentCache=new WeakMap;elementDepthCache=new WeakMap;elementChildrenCache=new WeakMap;cacheHits=0;cacheMisses=0;static CACHE_KEYS={COMPONENT_ELEMENTS:e=>`comp:${e}`,SCRIPTS:(e,s)=>`scripts:${e}:${s}`,TEMPLATES:(e,s)=>`templates:${e}:${s}`,SELECTOR:e=>`sel:${e}`};static getInstance(){return L.instance||(L.instance=new L),L.instance}queryComponentElements(e){const s=L.CACHE_KEYS.COMPONENT_ELEMENTS(e);if(this.componentElementsCache.has(s))return this.cacheHits++,this.componentElementsCache.get(s);this.cacheMisses++;const i=Array.from(document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e}"]`));return i.forEach(n=>{this.elementComponentCache.set(n,e)}),this.componentElementsCache.set(s,i),i}querySelectorAll(e){const s=L.CACHE_KEYS.SELECTOR(e);if(this.selectorCache.has(s))return this.cacheHits++,this.selectorCache.get(s);this.cacheMisses++;const i=Array.from(document.querySelectorAll(e));return this.selectorCache.set(s,i),i}getElementComponent(e){if(this.elementComponentCache.has(e))return this.cacheHits++,this.elementComponentCache.get(e);this.cacheMisses++;const s=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(s)return this.elementComponentCache.set(e,s),s;let i=e.parentElement;for(;i;){const n=i.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(n)return this.elementComponentCache.set(e,n),n;i=i.parentElement}return this.elementComponentCache.set(e,"app"),"app"}getContextComponent(e){if(this.contextComponentCache.has(e))return this.cacheHits++,this.contextComponentCache.get(e);this.cacheMisses++;const s=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let i;if(s)if(s==="parent"){const n=this.getElementComponent(e);i=this.getParentOfComponent(n,e)}else s==="app"?i="app":i=s;else i=this.getElementComponent(e);return this.contextComponentCache.set(e,i),i}getParentOfComponent(e,s){if(this.parentComponentCache.has(s))return this.cacheHits++,this.parentComponentCache.get(s);if(this.cacheMisses++,e==="app")return this.parentComponentCache.set(s,"app"),"app";let i=s;for(;i&&i.getAttribute(d.ATTR_PREFIXES.COMPONENT)!==e;)i=i.parentElement;if(!i)return this.parentComponentCache.set(s,"app"),"app";let n=i.parentElement;for(;n;){const r=n.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(r)return this.parentComponentCache.set(s,r),r;n=n.parentElement}return this.parentComponentCache.set(s,"app"),"app"}getElementDepthCached(e){if(this.elementDepthCache.has(e))return this.cacheHits++,this.elementDepthCache.get(e);this.cacheMisses++;let s=0,i=e.parentElement;for(;i&&i!==document.body;)s++,i=i.parentElement;return this.elementDepthCache.set(e,s),s}getFirstComponentElement(e){const s=this.queryComponentElements(e);return s.length>0?s[0]:null}getComponentScripts(e,s){const i=L.CACHE_KEYS.SCRIPTS(e,s?.tagName||"global");if(this.scriptElementsCache.has(i))return this.cacheHits++,this.scriptElementsCache.get(i);this.cacheMisses++;let n=[];if(s){const r=s.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`);for(const a of r)a instanceof HTMLScriptElement&&n.push(a)}else{const r=document.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`);for(const a of r)if(a instanceof HTMLScriptElement){const o=a.getAttribute(d.ATTR_PREFIXES.COMPONENT);(o===e||!o&&!a.closest(`[${d.ATTR_PREFIXES.COMPONENT}]`))&&n.push(a)}}return this.scriptElementsCache.set(i,n),n}getComponentTemplates(e,s){const i=L.CACHE_KEYS.TEMPLATES(e,s?.tagName||"global");if(this.templateElementsCache.has(i))return this.cacheHits++,this.templateElementsCache.get(i);this.cacheMisses++;let n=[];if(s){const r=s.querySelectorAll("template[pp-for]");for(const a of r)a instanceof HTMLTemplateElement&&this.getElementComponent(a)===e&&n.push(a)}else{const r=document.querySelectorAll("template[pp-for]");for(const a of r)a instanceof HTMLTemplateElement&&this.getElementComponent(a)===e&&n.push(a)}return this.templateElementsCache.set(i,n),n}querySelector(e){const s=this.querySelectorAll(e);return s.length>0?s[0]:null}findElementForComponent(e,s){if(s==="app")return document.body;const i=this.queryComponentElements(s);return i.length>0?i[0]:null}invalidateCache(e){switch(e){case"components":this.componentElementsCache.clear();break;case"selectors":this.selectorCache.clear();break;case"scripts":this.scriptElementsCache.clear();break;case"templates":this.templateElementsCache.clear();break;default:this.clearAllCaches()}}invalidateByComponent(e){const s=L.CACHE_KEYS.COMPONENT_ELEMENTS(e);this.componentElementsCache.delete(s);const i=L.CACHE_KEYS.SCRIPTS(e,"global");this.scriptElementsCache.delete(i);const n=L.CACHE_KEYS.TEMPLATES(e,"global");this.templateElementsCache.delete(n),this.selectorCache.clear()}invalidateByPrefix(e){this.invalidateByComponent(e)}invalidateElement(e){this.elementComponentCache.delete(e),this.contextComponentCache.delete(e),this.parentComponentCache.delete(e),this.elementDepthCache.delete(e),this.elementChildrenCache.delete(e)}clearAllCaches(){this.componentElementsCache.clear(),this.scriptElementsCache.clear(),this.templateElementsCache.clear(),this.selectorCache.clear(),this.elementComponentCache=new WeakMap,this.parentComponentCache=new WeakMap,this.contextComponentCache=new WeakMap,this.elementDepthCache=new WeakMap,this.elementChildrenCache=new WeakMap}getCacheStats(){const e=this.cacheHits+this.cacheMisses;return{componentElements:this.componentElementsCache.getStats(),scriptElements:this.scriptElementsCache.getStats(),templateElements:this.templateElementsCache.getStats(),selectors:this.selectorCache.getStats(),global:{size:0,maxSize:-1,hitRate:e>0?this.cacheHits/e*100:0,hits:this.cacheHits,misses:this.cacheMisses}}}resetStats(){this.cacheHits=0,this.cacheMisses=0}}class Ts{subscriptions=new Map;elementSubscriptions=new WeakMap;keyIndex=new Map;cleanupQueue=new Set;cleanupScheduled=!1;addSubscription(e){this.subscriptions.set(e.id,e),e.element&&(this.elementSubscriptions.has(e.element)||this.elementSubscriptions.set(e.element,new Set),this.elementSubscriptions.get(e.element).add(e.id));for(const s of e.dependencies)this.keyIndex.has(s)||this.keyIndex.set(s,new Set),this.keyIndex.get(s).add(e.id)}removeSubscription(e){const s=this.subscriptions.get(e);if(s){if(this.subscriptions.delete(e),s.element){const i=this.elementSubscriptions.get(s.element);i&&(i.delete(e),i.size===0&&this.elementSubscriptions.delete(s.element))}for(const i of s.dependencies){const n=this.keyIndex.get(i);n&&(n.delete(e),n.size===0&&this.keyIndex.delete(i))}}}cleanupElement(e){const s=this.elementSubscriptions.get(e);s&&(s.forEach(i=>this.cleanupQueue.add(i)),this.scheduleCleanup())}scheduleCleanup(){this.cleanupScheduled||(this.cleanupScheduled=!0,queueMicrotask(()=>{this.processCleanupQueue(),this.cleanupScheduled=!1}))}processCleanupQueue(){for(const e of this.cleanupQueue)this.removeSubscription(e);this.cleanupQueue.clear()}getSubscription(e){return this.subscriptions.get(e)}getSubscriptionsForKey(e){return this.keyIndex.get(e)}getAllSubscriptions(){return new Map(this.subscriptions)}cleanupStaleSubscriptions(){const e=[];for(const[s,i]of this.subscriptions)i.element&&!document.contains(i.element)&&e.push(s);e.forEach(s=>this.removeSubscription(s))}getStats(){return{totalSubscriptions:this.subscriptions.size,elementSubscriptions:this.elementSubscriptions instanceof WeakMap?-1:0,keyIndexes:this.keyIndex.size}}}class q{static instance;stateVariables=new Set;static FUNCTIONS_NEEDING_VALUE_TRANSFORM=new Set(["console.log","console.warn","console.error","console.info","console.debug","console.dir","console.table","console.trace","console.assert","JSON.stringify","JSON.parse","Object.keys","Object.values","Object.entries","Array.from","Array.isArray","Math.max","Math.min","Math.abs","Math.floor","Math.ceil","Math.round","alert","confirm","prompt","parseInt","parseFloat","Number","String","Boolean"]);transformRefDeclarations(e){try{const s=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const n=[];return U(s,{VariableDeclarator:r=>{if(this.isRefDeclaration(r)){const a=r.id.name,o=this.findStatementEnd(e,r.end);n.push({start:o,end:o,replacement:`; this.${a} = ${a}`})}}}),n.sort((r,a)=>a.start-r.start).forEach(r=>{i=i.slice(0,r.start)+r.replacement+i.slice(r.end)}),i}catch(s){return console.error("Ref transformation error:",s),e}}isRefDeclaration(e){return e.id?.type==="Identifier"&&e.init?.type==="CallExpression"&&e.init.callee?.type==="MemberExpression"&&e.init.callee.object?.type==="Identifier"&&e.init.callee.object.name==="pp"&&e.init.callee.property?.type==="Identifier"&&e.init.callee.property.name==="ref"}findStatementEnd(e,s){let i=s;for(;i<e.length&&e[i]!==";"&&e[i]!==`
|
|
10
|
-
`;)i++;return i}static getInstance(){return q.instance||(q.instance=new q),q.instance}extractFunctionNames(e){const s=[];try{const i=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});U(i,{FunctionDeclaration:n=>{n.id?.type==="Identifier"&&s.push(n.id.name)},VariableDeclarator:n=>{n.id?.type==="Identifier"&&(n.init?.type==="ArrowFunctionExpression"||n.init?.type==="FunctionExpression")&&s.push(n.id.name)},AssignmentExpression:n=>{n.left?.type==="Identifier"&&(n.right?.type==="ArrowFunctionExpression"||n.right?.type==="FunctionExpression")&&s.push(n.left.name)}})}catch(i){console.error("AST function extraction error:",i)}return Array.from(new Set(s))}transformEffectDeclarations(e){try{const s=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const n=[];return U(s,{CallExpression:r=>{const a=this.transformEffectCall(r,e);a&&n.push(a)}}),n.sort((r,a)=>a.start-r.start).forEach(r=>{i=i.slice(0,r.start)+r.replacement+i.slice(r.end)}),i}catch(s){return console.error("Effect transformation error:",s),e}}transformEffectCall(e,s){if(!this.isPPEffectCall(e))return null;const i=e.arguments;if(i.length<2)return null;const n=i[1];if(n.type!=="ArrayExpression"||!n.elements.some(p=>p?p.type==="Identifier"||p.type==="MemberExpression":!1))return null;const a=n.elements.map(p=>p?p.type==="Identifier"?`"${p.name}"`:p.type==="MemberExpression"?`"${this.extractMemberExpression(p,s)}"`:s.slice(p.start,p.end):"null"),o=s.slice(i[0].start,i[0].end),c=i.slice(2).map(p=>s.slice(p.start,p.end)).join(", "),l=`[${a.join(", ")}]`,h=c?`pp.effect(${o}, ${l}, ${c})`:`pp.effect(${o}, ${l})`;return{start:e.start,end:e.end,replacement:h}}extractMemberExpression(e,s){if(e.type!=="MemberExpression")return e.type==="Identifier"?e.name:s.slice(e.start,e.end);const i=this.extractMemberExpression(e.object,s);if(e.computed){const n=s.slice(e.property.start,e.property.end);return`${i}[${n}]`}else{const n=e.property.name||s.slice(e.property.start,e.property.end);return`${i}.${n}`}}isPPEffectCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&e.callee.property.name==="effect"}transformStateDeclarations(e){this.stateVariables.clear();let s=this.transformStateDeclarationsOnly(e);return s=this.transformEffectDeclarations(s),s=this.transformRefDeclarations(s),s=this.transformUnsupportedStateUsages(s),s}transformStateDeclarationsOnlyOriginal(e){try{const s=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const n=[];return U(s,{VariableDeclarator:r=>{const a=this.transformStateDeclarator(r,e);a&&n.push(a)}}),n.sort((r,a)=>a.start-r.start).forEach(r=>{i=i.slice(0,r.start)+r.replacement+i.slice(r.end)}),i}catch(s){return console.error("AST transformation error:",s),e}}transformStateDeclarationsOnly(e){let s=this.transformStateDeclarationsOnlyOriginal(e);return s=this.transformDestructuringAssignments(s),s}transformUnsupportedStateUsages(e){try{const s=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});this.collectStateVariables(s);let i=this.transformShorthandProperties(e);const n=j(i,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),r=[];return U(n,{SpreadElement:a=>{const o=this.transformSpreadElement(a,i);o&&r.push(o)},UnaryExpression:a=>{const o=this.transformUnaryExpression(a,i);o&&r.push(o)},BinaryExpression:a=>{const o=this.transformBinaryExpression(a,i);o&&r.push(o)},LogicalExpression:a=>{const o=this.transformLogicalExpression(a,i);o&&r.push(o)},ConditionalExpression:a=>{const o=this.transformConditionalExpression(a,i);o&&r.push(o)},IfStatement:a=>{const o=this.transformIfStatement(a,i);o&&r.push(o)},WhileStatement:a=>{const o=this.transformWhileStatement(a,i);o&&r.push(o)},ForStatement:a=>{const o=this.transformForStatement(a,i);o&&r.push(o)},ReturnStatement:a=>{const o=this.transformReturnStatement(a,i);o&&r.push(o)},VariableDeclarator:a=>{const o=this.transformVariableDeclarator(a,i);o&&r.push(o)},AssignmentExpression:a=>{const o=this.transformAssignmentExpression(a,i);o&&r.push(o)},CallExpression:a=>{const o=this.transformGeneralCallExpression(a,i);o&&r.push(o)}}),Ss(n,{Identifier:(a,o)=>{r.some(l=>a.start>=l.start&&a.end<=l.end)||this.stateVariables.has(a.name)&&(this.alreadyHasValue(a,i)||this.isPartOfStateDeclaration(a,o)||this.isPropertyName(a,o)||this.isMethodCallObject(a,o)||this.isPartOfPPCall(a,o)||this.isPartOfDestructuring(a,o)||r.push({start:a.start,end:a.end,replacement:`${a.name}.value`}))}}),r.sort((a,o)=>o.start-a.start).forEach(a=>{i=i.slice(0,a.start)+a.replacement+i.slice(a.end)}),i=this.transformMultipleCallArguments(i),i}catch(s){return console.error("State usage transformation error:",s),e}}transformShorthandProperties(e){try{const s=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const n=[];return U(s,{Property:r=>{if(r.shorthand&&r.key?.type==="Identifier"&&this.stateVariables.has(r.key.name)){const a=r.key.name,o=`${a}: ${a}.value`;n.push({start:r.start,end:r.end,replacement:o})}}}),n.sort((r,a)=>a.start-r.start).forEach(r=>{i=i.slice(0,r.start)+r.replacement+i.slice(r.end)}),i}catch(s){return console.error("Shorthand property transformation error:",s),e}}transformLogicalExpression(e,s){return e.left?.type==="Identifier"&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,s)?{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`}:e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,s)?{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}:null}transformConditionalExpression(e,s){return e.test?.type==="Identifier"&&this.stateVariables.has(e.test.name)&&!this.alreadyHasValue(e.test,s)?{start:e.test.start,end:e.test.end,replacement:`${e.test.name}.value`}:e.consequent?.type==="Identifier"&&this.stateVariables.has(e.consequent.name)&&!this.alreadyHasValue(e.consequent,s)?{start:e.consequent.start,end:e.consequent.end,replacement:`${e.consequent.name}.value`}:e.alternate?.type==="Identifier"&&this.stateVariables.has(e.alternate.name)&&!this.alreadyHasValue(e.alternate,s)?{start:e.alternate.start,end:e.alternate.end,replacement:`${e.alternate.name}.value`}:null}transformIfStatement(e,s){return this.transformExpressionNode(e.test,s)}transformWhileStatement(e,s){return this.transformExpressionNode(e.test,s)}transformForStatement(e,s){return e.test?this.transformExpressionNode(e.test,s):null}transformReturnStatement(e,s){return e.argument?this.transformExpressionNode(e.argument,s):null}transformVariableDeclarator(e,s){return this.isStateDeclaration(e)||e.id?.type==="ArrayPattern"||e.id?.type==="ObjectPattern"?null:e.init?.type==="Identifier"&&this.stateVariables.has(e.init.name)&&!this.alreadyHasValue(e.init,s)?{start:e.init.start,end:e.init.end,replacement:`${e.init.name}.value`}:null}transformAssignmentExpression(e,s){return e.left?.type==="ArrayPattern"||e.left?.type==="ObjectPattern"?null:e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,s)?{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}:null}transformGeneralCallExpression(e,s){const i=s.slice(e.callee.start,e.callee.end);if(e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&this.stateVariables.has(e.callee.object.name)||this.isPPCall(e))return null;if(!q.isFunctionNeedingValueTransform(i)&&e.arguments.length>0){for(const r of e.arguments)if(r.type==="Identifier"&&this.stateVariables.has(r.name)&&!this.alreadyHasValue(r,s))return{start:r.start,end:r.end,replacement:`${r.name}.value`}}return null}static isFunctionNeedingValueTransform(e){if(this.FUNCTIONS_NEEDING_VALUE_TRANSFORM.has(e))return!0;const s=e.lastIndexOf(".");if(s>-1){const i=e.slice(s+1);if(this.FUNCTIONS_NEEDING_VALUE_TRANSFORM.has(i))return!0}return!1}transformExpressionNode(e,s){return e?.type==="Identifier"&&this.stateVariables.has(e.name)&&!this.alreadyHasValue(e,s)?{start:e.start,end:e.end,replacement:`${e.name}.value`}:null}isPPCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&(e.callee.property.name==="state"||e.callee.property.name==="effect")}isPartOfStateDeclaration(e,s){if(!s||!Array.isArray(s))return!1;for(const i of s)if(i.type==="VariableDeclarator"&&i.id?.type==="ArrayPattern"&&i.init?.type==="CallExpression"&&this.isPPStateCall(i.init))return!0;return!1}isPropertyName(e,s){if(!s||s.length===0)return!1;const i=s[s.length-1];return!!(i?.type==="Property"&&i.key===e||i?.type==="Property"&&i.shorthand&&i.value===e||i?.type==="MemberExpression"&&i.property===e&&!i.computed)}isMethodCallObject(e,s){if(!s||s.length===0)return!1;const i=s[s.length-1];if(i?.type==="MemberExpression"&&i.object===e&&s.length>=2){const n=s[s.length-2];if(n?.type==="CallExpression"&&n.callee===i)return!0}return!1}isPartOfPPCall(e,s){if(!s||!Array.isArray(s))return!1;for(const i of s)if(i.type==="CallExpression"&&i.callee?.type==="MemberExpression"&&i.callee.object?.type==="Identifier"&&i.callee.object.name==="pp"&&i.callee.property?.type==="Identifier"&&(i.callee.property.name==="state"||i.callee.property.name==="effect"))return!0;return!1}isPartOfDestructuring(e,s){if(!s||!Array.isArray(s))return!1;for(let i=0;i<s.length;i++){const n=s[i];if(n.type==="ArrayPattern"||n.type==="ObjectPattern"){if(i+1<s.length){const r=s[i+1];if(r?.type==="VariableDeclarator"&&r.id===n&&r.init===e)return!1}return!0}}return!1}collectStateVariables(e){U(e,{VariableDeclarator:s=>{if(this.isStateDeclaration(s)){const i=s.id.elements[0];i?.type==="Identifier"&&this.stateVariables.add(i.name)}}})}isStateDeclaration(e){return e.id?.type==="ArrayPattern"&&e.init?.type==="CallExpression"&&this.isPPStateCall(e.init)}transformSpreadElement(e,s){return e.argument?.type==="Identifier"&&this.stateVariables.has(e.argument.name)?this.alreadyHasValue(e.argument,s)?null:{start:e.argument.start,end:e.argument.end,replacement:`${e.argument.name}.value`}:null}transformUnaryExpression(e,s){return e.argument?.type==="Identifier"&&this.stateVariables.has(e.argument.name)&&["typeof","!","+","-","~","void","delete"].includes(e.operator)&&!this.alreadyHasValue(e.argument,s)?{start:e.argument.start,end:e.argument.end,replacement:`${e.argument.name}.value`}:null}transformBinaryExpression(e,s){if(["===","!==","==","!=",">","<",">=","<=","+","-","*","/","%","**","&","|","^","<<",">>",">>>","in","instanceof"].includes(e.operator)){if(e.left?.type==="Identifier"&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,s))return{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`};if(e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,s))return{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}}return null}transformMultipleCallArguments(e){try{const s=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const n=[];return U(s,{CallExpression:r=>{const a=i.slice(r.callee.start,r.callee.end);if(q.isFunctionNeedingValueTransform(a)&&r.arguments.length>0)for(const c of r.arguments)c.type==="Identifier"&&this.stateVariables.has(c.name)&&(this.alreadyHasValue(c,i)||n.push({start:c.start,end:c.end,replacement:`${c.name}.value`}))}}),n.sort((r,a)=>a.start-r.start).forEach(r=>{i=i.slice(0,r.start)+r.replacement+i.slice(r.end)}),i}catch(s){return console.error("Multiple call arguments transformation error:",s),e}}transformDestructuringAssignments(e){try{const s=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const n=[];return U(s,{VariableDeclarator:r=>{this.isStateDeclaration(r)||(r.id?.type==="ArrayPattern"||r.id?.type==="ObjectPattern")&&r.init?.type==="Identifier"&&this.stateVariables.has(r.init.name)&&(this.alreadyHasValue(r.init,e)||n.push({start:r.init.start,end:r.init.end,replacement:`${r.init.name}.value`}))},AssignmentExpression:r=>{(r.left?.type==="ArrayPattern"||r.left?.type==="ObjectPattern")&&r.right?.type==="Identifier"&&this.stateVariables.has(r.right.name)&&(this.alreadyHasValue(r.right,e)||n.push({start:r.right.start,end:r.right.end,replacement:`${r.right.name}.value`}))}}),n.sort((r,a)=>a.start-r.start).forEach(r=>{i=i.slice(0,r.start)+r.replacement+i.slice(r.end)}),i}catch(s){return console.error("Destructuring transformation error:",s),e}}alreadyHasValue(e,s){const i=e.end;return s.slice(i,i+6).startsWith(".value")}transformStateDeclarator(e,s){if(e.id?.type!=="ArrayPattern"||e.init?.type!=="CallExpression")return null;const i=e.init;if(!this.isPPStateCall(i))return null;const n=e.id.elements[0];if(!n||n.type!=="Identifier")return null;const r=n.name,a=`set${this.capitalize(r)}`,o=e.id.elements[1];return o?.type==="Identifier"&&o.name!==a&&console.warn(`Setter name mismatch: expected ${a}, got ${o.name}`),this.createTransformation(i,r,s)}isPPStateCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&e.callee.property.name==="state"}createTransformation(e,s,i){const n=e.arguments;if(n.length===0){const c=`pp.state("${s}")`;return{start:e.start,end:e.end,replacement:c}}const r=n[0];if(r.type==="Literal"&&typeof r.value=="string"&&r.value===s)return null;if(n.length===1){const c=i.slice(r.start,r.end),l=`pp.state("${s}", ${c})`;return{start:e.start,end:e.end,replacement:l}}const a=i.slice(e.arguments[0].start,e.arguments[e.arguments.length-1].end),o=`pp.state("${s}", ${a})`;return{start:e.start,end:e.end,replacement:o}}looksLikeVariableName(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&e.length<=50&&!e.includes(" ")}extractStateDeclarations(e){const s=[];try{const i=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0});U(i,{VariableDeclarator:n=>{const r=this.extractStateFromDeclarator(n,e);r&&s.push(r)}})}catch(i){console.error("State extraction error:",i)}return s}extractStateFromDeclarator(e,s){if(e.id?.type!=="ArrayPattern"||e.init?.type!=="CallExpression"||!this.isPPStateCall(e.init))return null;const i=e.id.elements[0],n=e.id.elements[1];if(i?.type!=="Identifier"||n?.type!=="Identifier")return null;const r=e.init.arguments;let a=i.name,o;return r.length>=1&&(r[0].type==="Literal"&&typeof r[0].value=="string"?this.looksLikeVariableName(r[0].value)?(a=r[0].value,r.length>=2&&(o=this.extractLiteralValue(r[1]))):(a=i.name,o=this.extractLiteralValue(r[0])):o=this.extractLiteralValue(r[0])),{variableName:i.name,setterName:n.name,stateKey:a,initialValue:o,line:e.loc?.start.line||0,column:e.loc?.start.column||0}}extractFunctionDeclarations(e){const s=[];try{const i=j(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0});U(i,{FunctionDeclaration:n=>{n.id?.type==="Identifier"&&s.push({name:n.id.name,type:"function",params:n.params.map(r=>r.type==="Identifier"?r.name:""),line:n.loc?.start.line||0})},VariableDeclarator:n=>{if(n.id?.type==="Identifier"&&(n.init?.type==="ArrowFunctionExpression"||n.init?.type==="FunctionExpression")){const r=n.init;s.push({name:n.id.name,type:r.type==="ArrowFunctionExpression"?"arrow":"function",params:r.params.map(a=>a.type==="Identifier"?a.name:""),line:n.loc?.start.line||0})}}})}catch(i){console.error("Function extraction error:",i)}return s}extractLiteralValue(e){if(e.type==="Literal")return e.value;e.type==="Identifier"&&e.name}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}}class Ke{constructor(e){this.evaluator=e}render(e,s,i){const n=P.isSingleExpression(e);if(n)return this.evaluator.evaluateExpression(n,s,i);let r="";for(const a of P.parse(e))if(a.type==="static")r+=a.content;else if(a.expression)try{r+=ie(this.evaluator.evaluateExpression(a.expression,s,i))}catch{}return r}dependencies(e,s,i){const n=P.extractExpressions(e),r=new Set;for(const a of n)for(const o of this.evaluator.extractDependencies(a,s,i))r.add(o);return[...r]}}class _s{static containsMustacheExpression(e){if(d.MUSTACHE_PATTERN.test(e))return!0;const i=P.decodeEntities(e);return d.MUSTACHE_PATTERN.test(i)}}class y{static FRAMEWORK_ATTRIBUTES=new Set(["pp-component","pp-context","pp-for","pp-spread","pp-ref","key"]);static domCache;static getDOMCache(){return this.domCache||(this.domCache=L.getInstance()),this.domCache}static isFrameworkAttribute(e){return y.FRAMEWORK_ATTRIBUTES.has(e)}static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}static shouldBeDirectBinding(e,s){const i=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),n=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);return!i||!n||i===n?!1:y.isDOMProperty(e,s)}static isDOMProperty(e,s){const i=e.tagName.toLowerCase(),n=document.createElement(i);return y.attributeToPropertyName(s)in n}static attributeToPropertyName(e){const s={class:"className",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",tabindex:"tabIndex",contenteditable:"contentEditable",formnovalidate:"formNoValidate",novalidate:"noValidate",allowfullscreen:"allowFullscreen",itemscope:"itemScope"};return s[e]?s[e]:e.replace(/-([a-z])/g,(i,n)=>n.toUpperCase())}static isBooleanAttribute(e){return["checked","disabled","hidden","readonly","required","multiple","selected","autofocus","autoplay","controls","defer","loop","muted","open","reversed","async","default","formnovalidate","novalidate","allowfullscreen","capture","itemscope"].includes(e)}static getContextComponent(e){return this.getDOMCache().getContextComponent(e)}static getParentOfComponent(e,s){return this.getDOMCache().getParentOfComponent(e,s)}static findElementForComponent(e,s){return this.getDOMCache().findElementForComponent(e,s)}static getElementDepth(e){return this.getDOMCache().getElementDepthCached(e)}static getParentComponentForElement(e){let s=e.parentElement;for(;s;){const i=s.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i)return i;s=s.parentElement}return"app"}static isTextNodeInsideScript(e){let s=e.parentElement;for(;s&&s!==document.body;){const i=s.tagName.toLowerCase();if(i==="script"||i==="style")return!0;s=s.parentElement}return!1}static getComponentForNode(e){let s=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return s?this.getDOMCache().getElementComponent(s):"app"}static getElementComponent(e){return this.getDOMCache().getElementComponent(e)}}class oe{static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}}class Be{static findExistingStateKey(e,s,i){return[`${s}.${e}`,`app.${e}`,e].find(r=>r in i)||null}}class et{pendingUpdates=new Map;batchTimeout=null;componentManager;domBindingManager;setManagers(e,s){this.componentManager=e,this.domBindingManager=s}scheduleUpdate(e,s){this.pendingUpdates.has(e)||this.pendingUpdates.set(e,new Set),this.pendingUpdates.get(e).add(s),this.batchTimeout===null&&(this.batchTimeout=requestAnimationFrame(()=>{this.processBatchedUpdates(),this.batchTimeout=null}))}processBatchedUpdates(){const e=new Map(this.pendingUpdates);this.pendingUpdates.clear(),this.batchTimeout=null;const s=this.sortUpdatesByDependency(e);for(const[i,n]of s)this.processComponentUpdate(i,n)}sortUpdatesByDependency(e){const s=new WeakMap,i=n=>{let r=s.get(n);return r==null&&(r=y.getElementDepth(n),s.set(n,r)),r};return Array.from(e.entries()).sort(([,n],[,r])=>{const a=Math.min(...Array.from(n,i)),o=Math.min(...Array.from(r,i));return a-o})}processComponentUpdate(e,s){if(!this.componentManager||!this.domBindingManager)return;this.componentManager.invalidateComponent(e);const i=[],n=[],r=[];for(const a of s){if(!document.contains(a))continue;const o=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null);let c;for(;c=o.nextNode();)i.push(c);const l=this.domBindingManager.loopManager;if(l){const h=l.getAllLoops();for(const[p,f]of h)f.component===e&&a.contains(p)&&n.push([p,f])}r.push(a)}this.updateTextNodesBatch(i,e),this.updateLoopsBatch(n),this.updateElementsBatch(r,e)}updateTextNodesBatch(e,s){const i=this.domBindingManager.textNodeManager;i&&e.forEach(n=>{document.contains(n)&&y.getComponentForNode(n)===s&&i.updateTextNode(n)})}updateLoopsBatch(e){const s=this.domBindingManager.loopManager;if(!s)return;const i=new Map;e.forEach(([r,a])=>{const o=y.getElementDepth(r);i.has(o)||i.set(o,[]),i.get(o).push([r,a])});const n=Array.from(i.keys()).sort((r,a)=>r-a);for(const r of n)i.get(r).forEach(([o,c])=>{document.contains(o)&&s.renderLoop(c,c.iterableExpr)})}updateElementsBatch(e,s){e.forEach(i=>{document.contains(i)&&this.domBindingManager.processElementBindings(i,!0)})}}class Ft{loopBindings=new Map;stateManager;expressionEvaluator;componentManager;domBindingManager;cleanupObserver;loopCounter=0;pendingTemplates=[];loopItemElements=new WeakSet;loopItemContexts=new WeakMap;templateRenderer;constructor(e,s){this.stateManager=e,this.expressionEvaluator=s,this.cleanupObserver=new MutationObserver(i=>{this.cleanupDetachedTemplates(i)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateRenderer=new Ke(s)}getLoopContextForElement(e){if(!this.domBindingManager)return null;const s=this.domBindingManager.loopManager;if(!s)return null;let i=e.parentElement;for(;i;){if(s.isLoopItem&&s.isLoopItem(i))return s.getLoopItemContext(i);i=i.parentElement}const n=s.getAllLoops();for(const[r,a]of n)for(const o of a.renderedItems)if(o.element.contains(e))return o.context;return null}setDependencies(e,s){this.componentManager=e,this.domBindingManager=s}queueTemplate(e,s){this.loopBindings.has(e)||this.pendingTemplates.push({template:e,component:s})}processPendingTemplates(){const e=[...this.pendingTemplates];this.pendingTemplates=[];for(const{template:s,component:i}of e)document.contains(s)&&this.processTemplate(s,i)}processTemplate(e,s){const i=e.getAttribute("pp-for");if(!i||this.loopBindings.has(e))return;const n=this.parseLoopExpression(i);if(!n){console.error(`Invalid pp-for syntax: "${i}"`);return}const r=e.parentElement,a=document.createComment(`pp-for: ${i}`);r.insertBefore(a,e);const o={template:e,expression:i,itemVar:n.itemVar,indexVar:n.indexVar,component:s,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:r,placeholder:a,iterableExpr:n.iterableExpr};this.loopBindings.set(e,o),this.setupLoopReactivity(o,n.iterableExpr),this.renderLoop(o,n.iterableExpr)}parseLoopExpression(e){const s=e.match(/^\s*([a-zA-Z_$][\w$]*)\s+in\s+(.+)$/);if(s)return{itemVar:s[1],iterableExpr:s[2].trim()};const i=e.match(/^\s*\(\s*([a-zA-Z_$][\w$]*)\s*,\s*([a-zA-Z_$][\w$]*)\s*\)\s+in\s+(.+)$/);return i?{itemVar:i[1],indexVar:i[2],iterableExpr:i[3].trim()}:null}setupLoopReactivity(e,s){const i=`loop_${Date.now()}_${++this.loopCounter}`,n=this.expressionEvaluator.extractDependencies(s,e.component,this.stateManager),r=this.findComponentElementForLoop(e);if(r&&this.componentManager){const o=this.componentManager.getComponentPropDependencies(r,e.component);n.push(...o)}const a={id:i,selector:"",dependencies:new Set(n),callback:()=>{this.renderLoop(e,e.iterableExpr)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(a),e.subscriptionIds.push(i)}renderLoop(e,s){if(!(!this.componentManager||!this.domBindingManager))try{const i=this.findComponentElementForLoop(e);let n;const r=this.findParentLoopContext(e.template);r?n={...this.componentManager.buildComponentContextWithProps(e.component,i),...r}:n=this.componentManager.buildComponentContextWithProps(e.component,i);const a=this.expressionEvaluator.evaluateExpression(s,n,e.component);if(!Array.isArray(a)){console.warn(`Loop expression "${s}" did not return an array:`,a,`Available context keys: [${Object.keys(n).join(", ")}]`,"Parent loop context:",r),this.clearRenderedItems(e);return}this.updateRenderedItems(e,a)}catch(i){console.error(`Error evaluating loop expression "${s}":`,i),this.clearRenderedItems(e)}}findParentLoopContext(e){const s=[];let i=e.parentElement;for(;i&&i!==document.body;){if(this.loopItemElements.has(i)){const n=this.loopItemContexts.get(i);n&&s.unshift(n)}for(const[n,r]of this.loopBindings)if(r.template!==e){for(const a of r.renderedItems)if(a.element===i||a.element.contains(e)){s.unshift(a.context);break}}i=i.parentElement}return s.length>0?s.reduce((n,r)=>({...n,...r}),{}):null}findComponentElementForLoop(e){let s=e.parentElement;for(;s;){if(s.getAttribute(d.ATTR_PREFIXES.COMPONENT)===e.component)return s;s=s.parentElement}return document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e.component}"]`)[0]||void 0}updateRenderedItems(e,s){const i=e.renderedItems,n=[],r=new Set,a=new Map;i.forEach(o=>{a.set(o.key,o)}),s.forEach((o,c)=>{const l=this.generateItemKey(e,o,c),h=a.get(l);if(h&&!r.has(h.element))r.add(h.element),this.updateItemContext(e,h,o,c),n.push(h);else{const p=this.createLoopItem(e,o,c,l);p&&(n.push(p),this.processNestedLoopsInItem(p,e.component))}}),i.forEach(o=>{r.has(o.element)||this.cleanupLoopItem(o)}),this.updateDOMOrder(e,n),e.renderedItems=n}processNestedLoopsInItem(e,s){e.element.querySelectorAll("template[pp-for]").forEach(n=>{const r=n;this.loopBindings.has(r)||this.processNestedTemplate(r,s,e.context)})}generateItemKey(e,s,i){const r=e.template.content.firstElementChild;if(r&&r.hasAttribute("key")){const a=r.getAttribute("key");try{const o=this.createItemContextWithParentContext(e,s,i),c=P.isSingleExpression(a);if(c){const l=this.expressionEvaluator.evaluateExpression(c,o,e.component);return String(l)}else{const l=P.parse(a);let h="";for(const p of l)if(p.type==="static")h+=p.content;else if(p.expression){const f=this.expressionEvaluator.evaluateExpression(p.expression,o,e.component);h+=ie(f)}return h}}catch(o){console.warn(`Error evaluating key expression "${a}":`,o,"Available context keys:",Object.keys(this.createItemContextWithParentContext(e,s,i)))}}return s&&typeof s=="object"&&"id"in s?String(s.id):`${e.expression}_${i}`}createItemContextWithParentContext(e,s,i){if(!this.componentManager)return{};const n=this.componentManager.buildComponentContext(e.component),r=this.getAllParentLoopContexts(e.template),a={...n,...r,[e.itemVar]:s};return e.indexVar&&(a[e.indexVar]=i),a}getAllParentLoopContexts(e){const s=[];let i=e.parentElement;for(;i&&i!==document.body;){if(this.loopItemElements.has(i)){const n=this.loopItemContexts.get(i);n&&s.unshift(n)}for(const[n,r]of this.loopBindings)if(n!==e){for(const a of r.renderedItems)if(a.element===i||a.element.contains(e)){s.unshift(a.context);break}}i=i.parentElement}return s.reduce((n,r)=>({...n,...r}),{})}createItemContext(e,s,i){if(!this.componentManager)return{};const n=this.componentManager.buildComponentContext(e.component),r=this.findAllParentLoopContexts(e.template),a={...n,...r,[e.itemVar]:s};return e.indexVar&&(a[e.indexVar]=i),a}findAllParentLoopContexts(e){const s={};let i=e.parentElement;for(;i&&i!==document.body;){if(this.loopItemElements.has(i)){const n=this.loopItemContexts.get(i);if(n)for(const[r,a]of Object.entries(n))r in s||(s[r]=a)}for(const[n,r]of this.loopBindings)if(n!==e){for(const a of r.renderedItems)if(a.element===i){for(const[o,c]of Object.entries(a.context))o in s||(s[o]=c);break}}i=i.parentElement}return s}createLoopItem(e,s,i,n){if(!this.domBindingManager)return null;try{const r=this.createItemContextWithParentContext(e,s,i),a=document.importNode(e.template.content,!0),o=document.createElement("div");o.appendChild(a);const c=o.firstElementChild;if(!c)return console.warn("Template content must contain exactly one root element"),null;o.removeChild(c),this.loopItemElements.add(c),this.loopItemContexts.set(c,r),c.getAttribute("key")&&c.removeAttribute("key");const h={key:n,element:c,context:r,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map};return this.executeComponentScriptsInLoopItem(c),this.processRefsInLoopItem(c,r,e.component),this.processElementWithContext(c,r,e.component,h),this.cleanupRawMustacheAttributes(c),h}catch(r){return console.error("Error creating loop item:",r),null}}processRefsInLoopItem(e,s,i){if(e.hasAttribute("pp-ref")){const o=e.getAttribute("pp-ref");this.processRefAttribute(e,o,s,i)}const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>o.hasAttribute("pp-ref")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let r;const a=[];for(;r=n.nextNode();)a.push(r);a.forEach(o=>{const c=o.getAttribute("pp-ref");this.processRefAttribute(o,c,s,i)})}processRefAttribute(e,s,i,n){try{const r=P.decodeEntities(s),a=P.isSingleExpression(r)||r,o=this.expressionEvaluator.evaluateExpression(a,i,n);typeof o=="function"?o(e):o&&typeof o=="object"&&"current"in o?o.current=e:console.warn("⚠️ Invalid ref result:",o),e.removeAttribute("pp-ref")}catch(r){console.error("❌ Failed to process ref:",r)}}executeComponentScriptsInLoopItem(e){if(!this.componentManager)return;const s=[e],i=e.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}]`);s.push(...Array.from(i)),s.forEach(n=>{if(n.hasAttribute(d.ATTR_PREFIXES.COMPONENT)){const r=n.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(r){const a=this.getLoopItemContextForElement(n),o=this.generateInstanceId(a),c=`${r}_${o}`;n.setAttribute(d.ATTR_PREFIXES.COMPONENT,c),n.__originalComponentName=r,n.__uniqueComponentName=c,this.componentManager.pushComponent(c),this.getComponentScripts(n).forEach(h=>{this.componentManager.executeScript(h)}),this.componentManager.popComponent()}}})}getLoopItemContextForElement(e){let s=e;for(;s;){if(this.loopItemElements.has(s)){const i=this.loopItemContexts.get(s);if(i)return i}s=s.parentElement}for(const[i,n]of this.loopBindings)for(const r of n.renderedItems)if(r.element===e||r.element.contains(e))return r.context;return console.warn("⚠️ No loop item context found, using empty context"),{}}generateInstanceId(e){const s={};for(const[a,o]of Object.entries(e))typeof o=="function"||a.startsWith("set")||a.endsWith("Getter")||a==="getContext"||a==="withContext"||a==="__getProp"||(o&&typeof o=="object"&&"id"in o||typeof o!="object"||Array.isArray(o))&&(s[a]=o);return Object.keys(s).length===0?`${Date.now()}_${Math.random().toString(36).substring(2,7)}`:Object.keys(s).sort().map(a=>{const o=s[a];return o&&typeof o=="object"&&"id"in o?`${a}_${o.id}`:typeof o=="string"||typeof o=="number"?`${a}_${o}`:`${a}_${JSON.stringify(o)}`}).join("_").replace(/[^a-zA-Z0-9_]/g,"").substring(0,20)||`fallback_${Date.now()}`}getComponentScripts(e){const s=[];return e.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`).forEach(n=>{const r=n;let a=r.parentElement,o=!1;for(;a&&a!==e.parentElement;){if(a===e){o=!0;break}if(a.hasAttribute(d.ATTR_PREFIXES.COMPONENT)&&a!==e)break;a=a.parentElement}o&&s.push(r)}),s}cleanupRawMustacheAttributes(e){this.cleanupElementMustacheAttributes(e);const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let i;for(;i=s.nextNode();)this.cleanupElementMustacheAttributes(i)}cleanupElementMustacheAttributes(e){const s=Array.from(e.attributes);for(const i of s)i.value&&d.MUSTACHE_PATTERN.test(i.value)&&(y.isBooleanAttribute(i.name),e.removeAttribute(i.name))}processElementWithContext(e,s,i,n){if(!this.domBindingManager||!this.componentManager)return;const r=(o,c)=>{const l=this.componentManager.buildComponentContext(c),h=o.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(h&&h!==c){const f=this.componentManager.buildComponentContext(h);return{...s,...l,...f}}return{...s,...l}},a=this.componentManager.buildComponentContextWithProps.bind(this.componentManager);this.componentManager.buildComponentContextWithProps=(o,c)=>c&&(c===e||e.contains(c))?r(c,o):a(o,c);try{if(e.hasAttribute("pp-ref")){const m=e.getAttribute("pp-ref");this.processRefInLoopContext(e,m,s,i)}const o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:m=>m===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}),c=[];let l;for(;l=o.nextNode();){const m=l;if(m.hasAttribute("pp-ref")){const x=m.getAttribute("pp-ref");c.push({element:m,expression:x})}}c.forEach(({element:m,expression:x})=>{this.processRefInLoopContext(m,x,s,i)}),this.bindLoopItemElement(e,s,i,n),this.setupEventBindingsForLoopItem(e,i);const h=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:m=>{if(m===e)return NodeFilter.FILTER_SKIP;if(m.nodeType===Node.TEXT_NODE){const x=m;if(y.isTextNodeInsideScript(x))return NodeFilter.FILTER_REJECT;if(x.textContent&&d.MUSTACHE_PATTERN.test(x.textContent))return NodeFilter.FILTER_ACCEPT}else if(m.nodeType===Node.ELEMENT_NODE)return m.tagName.toLowerCase()==="script"?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT;return NodeFilter.FILTER_SKIP}});let p;for(;p=h.nextNode();)if(p.nodeType===Node.TEXT_NODE){const m=p;if(m.textContent&&d.MUSTACHE_PATTERN.test(m.textContent)){const x=this.getComponentForTextNode(m),C=r(m.parentElement,x);this.processTextNodeWithLoopContext(m,C,x,n)}}else if(p.nodeType===Node.ELEMENT_NODE){const m=p,x=y.getElementComponent(m),C=r(m,x);this.bindLoopItemElement(m,C,x,n),this.setupEventBindingsForLoopItem(m,x)}e.querySelectorAll("template[pp-for]").forEach(m=>{this.processNestedTemplate(m,i,s)})}finally{this.componentManager.buildComponentContextWithProps=a}}processRefInLoopContext(e,s,i,n){try{const r=P.decodeEntities(s),a=P.isSingleExpression(r)||r,o=this.expressionEvaluator.evaluateExpression(a,i,n);typeof o=="function"?o(e):o&&typeof o=="object"&&"current"in o?o.current=e:console.warn("⚠️ Invalid ref result:",o),e.removeAttribute("pp-ref")}catch(r){console.error("❌ processRefInLoopContext error:",r)}}getComponentForTextNode(e){let s=e.parentElement;for(;s;){const i=s.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i)return i;s=s.parentElement}return"app"}processNestedTemplate(e,s,i){const n=e.getAttribute("pp-for");if(!n||this.loopBindings.has(e))return;const r=this.parseLoopExpression(n);if(!r){console.error(`Invalid pp-for syntax: "${n}"`);return}const a=e.parentElement,o=document.createComment(`pp-for: ${n}`);a.insertBefore(o,e);const c=this.findComponentElementForTemplate(e);let l={...i};const h=this.findParentLoopContextForNestedTemplate(e);if(h&&(l={...l,...h}),c&&this.componentManager){const f=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(f){const m=y.getParentComponentForElement(c);this.componentManager.hasStoredProps(c)||this.componentManager.setupProps(c,m);const x=this.evaluateComponentPropsWithContext(c,l);l={...this.componentManager.buildComponentContext(f),...x,...l}}}const p={template:e,expression:n,itemVar:r.itemVar,indexVar:r.indexVar,iterableExpr:r.iterableExpr,component:s,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:a,placeholder:o};this.loopBindings.set(e,p),this.setupNestedLoopReactivity(p,r.iterableExpr,l),this.renderNestedLoop(p,r.iterableExpr,l)}findParentLoopContextForNestedTemplate(e){let s=e.parentElement;const i={};let n=0;for(;s&&s!==document.body&&n<10;){if(n++,this.loopItemElements.has(s)){const r=this.loopItemContexts.get(s);if(r)for(const[a,o]of Object.entries(r))a in i||(i[a]=o)}for(const[r,a]of this.loopBindings)for(const o of a.renderedItems)(o.element.contains(e)||o.element===s)&&(a.itemVar in i||(i[a.itemVar]=o.context[a.itemVar]),a.indexVar&&!(a.indexVar in i)&&(i[a.indexVar]=o.context[a.indexVar]));s=s.parentElement}return Object.keys(i).length>0?i:null}evaluateComponentPropsWithContext(e,s){const i={};if(!this.componentManager||!this.expressionEvaluator)return i;const n=this.componentManager.extractProps(e,"app");for(const[r,a]of n)try{const o=this.templateRenderer.render(a.expression,s,a.component);i[r]=o}catch(o){console.error(`Failed to evaluate prop "${r}":`,o),i[r]=void 0}return i}findComponentElementForTemplate(e){let s=e.parentElement;for(;s;){if(s.hasAttribute(d.ATTR_PREFIXES.COMPONENT))return s;s=s.parentElement}return null}setupNestedLoopReactivity(e,s,i){const n=`nested_loop_${Date.now()}_${++this.loopCounter}`;let r=this.expressionEvaluator.extractDependencies(s,e.component,this.stateManager);const a={id:n,selector:"",dependencies:new Set(r),callback:()=>{const o=e.template,c=this.findComponentElementForTemplate(o);let l=i;if(o.parentElement){const p=this.getParentLoopContextForElement(o);p&&(l={...l,...p})}if(c&&this.componentManager){const p=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(p){const f=this.extractParentLoopContextFromBinding(e,i),m=this.evaluateComponentPropsWithContext(c,f),x=this.componentManager.buildComponentContext(p);l={...f,...x,...m}}}this.renderNestedLoop(e,s,l)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(a),e.subscriptionIds.push(n)}getParentLoopContextForElement(e){let s=e.parentElement;for(;s;){if(this.loopItemElements.has(s)){const i=this.loopItemContexts.get(s);if(i)return i}s=s.parentElement}return null}extractParentLoopContextFromBinding(e,s){const i=new Set;for(const[r,a]of this.loopBindings)if(a!==e){for(const o of a.renderedItems)if(o.element.contains(e.template)){i.add(a.itemVar),a.indexVar&&i.add(a.indexVar);break}}const n={};for(const[r,a]of Object.entries(s))(i.has(r)||r.startsWith("users")||r.startsWith("set")||r.includes("Getter")||typeof a=="function")&&(n[r]=a);return n}renderNestedLoop(e,s,i){if(!(!this.componentManager||!this.domBindingManager))try{const n=this.expressionEvaluator.evaluateExpression(s,i,e.component);if(!Array.isArray(n)){console.warn(`Nested loop expression "${s}" did not return an array:`,n,`Available context keys: [${Object.keys(i).join(", ")}]`),this.clearRenderedItems(e);return}this.updateNestedRenderedItems(e,n,i)}catch(n){console.error(`Error evaluating nested loop expression "${s}":`,n,`Available context keys: [${Object.keys(i).join(", ")}]`),this.clearRenderedItems(e)}}updateNestedRenderedItems(e,s,i){const n=e.renderedItems,r=[],a=new Set,o=new Map;n.forEach(c=>{o.set(c.key,c)}),s.forEach((c,l)=>{const h=this.generateNestedItemKey(e,c,l,i),p=o.get(h);if(p&&!a.has(p.element))a.add(p.element),this.updateNestedItemContext(e,p,c,l,i),r.push(p);else{const f=this.createNestedLoopItem(e,c,l,h,i);f&&r.push(f)}}),n.forEach(c=>{a.has(c.element)||this.cleanupLoopItem(c)}),this.updateDOMOrder(e,r),e.renderedItems=r}generateNestedItemKey(e,s,i,n){return s&&typeof s=="object"&&"id"in s?String(s.id):`${e.expression}_${i}_${JSON.stringify(n[e.itemVar]||{})}`}createNestedLoopItem(e,s,i,n,r){if(!this.domBindingManager)return null;try{const a={...r,[e.itemVar]:s};e.indexVar&&(a[e.indexVar]=i);const o=document.importNode(e.template.content,!0),c=document.createElement("div");c.appendChild(o);const l=c.firstElementChild;if(!l)return console.warn("Template content must contain exactly one root element"),null;c.removeChild(l),this.loopItemElements.add(l),this.loopItemContexts.set(l,a),l.getAttribute("key")&&l.removeAttribute("key");const p={key:n,element:l,context:a,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map};return this.processElementWithContext(l,a,e.component,p),this.cleanupRawMustacheAttributes(l),p}catch(a){return console.error("Error creating nested loop item:",a),null}}updateNestedItemContext(e,s,i,n,r){const a={...r};a[e.itemVar]=i,e.indexVar&&(a[e.indexVar]=n);const o=this.gatherAllComponentContextsInLoopItem(s.element),c={...a,...o};if(s.context=c,this.loopItemContexts.set(s.element,c),s.textNodeTemplates)for(const[l,h]of s.textNodeTemplates)document.contains(l)&&this.updateTextNodeWithContext(l,h,c,this.getTextNodeComponent(l));if(s.attributeTemplates)for(const[l,h]of s.attributeTemplates)document.contains(l)&&h.forEach((p,f)=>{try{const m=y.getElementComponent(l),x=this.buildElementSpecificContext(l,c),C=this.templateRenderer.render(p,x,m);this.domBindingManager?.updateElementProperty(l,f,C)}catch(m){console.error(`Nested binding update error for "${p}":`,m)}})}bindLoopItemElement(e,s,i,n){const r=this.extractMustacheBindings(e);n&&r.size>0&&(n.attributeTemplates||(n.attributeTemplates=new Map),n.attributeTemplates.set(e,new Map(r))),r.forEach((a,o)=>{this.createLoopItemBinding(e,o,a,s,i,n)})}setupEventBindingsForLoopItem(e,s){const i=this.domBindingManager.eventDelegation;if(!i){console.warn("No event delegation manager available");return}const n=Array.from(e.attributes);for(const r of n)if(oe.isEventAttribute(r.name)){const a=r.name.substring(2);i.registerEventHandler(e,a,r.value,s),e.removeAttribute(r.name)}}processTextNodeWithLoopContext(e,s,i,n){if(y.isTextNodeInsideScript(e))return;const r=e.textContent||"";if(!P.parse(r).some(x=>x.type==="expression"))return;n&&(n.textNodeTemplates||(n.textNodeTemplates=new Map),n.textNodeTemplates.set(e,r));const c=this.findActualComponentForTextNode(e);this.updateTextNodeWithContext(e,r,s,c);const l=`loop_text_${Date.now()}_${Math.random()}`,h=this.templateRenderer.dependencies(r,c,this.stateManager),p=new Set(h),m={id:l,selector:"",dependencies:p,callback:()=>{if(!document.contains(e)){this.stateManager.removeSubscription(l);return}let x={};if(this.componentManager&&(x=this.componentManager.buildComponentContext(c)),n){const C={};let v=null;for(const[A,I]of this.loopBindings)if(I.renderedItems.includes(n)){v=I;break}if(v){C[v.itemVar]=n.context[v.itemVar],v.indexVar&&(C[v.indexVar]=n.context[v.indexVar]);const A=this.findParentLoopContext(v.template);A&&Object.assign(C,A)}x={...x,...C}}this.updateTextNodeWithContext(e,r,x,c)},component:c};this.stateManager.addSubscription(m),n&&n.subscriptionIds.push(l)}findActualComponentForTextNode(e){let s=e.parentElement;for(;s;){const i=s.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i){const n=s.__uniqueComponentName;return n||i}s=s.parentElement}return"app"}updateTextNodeWithContext(e,s,i,n){const r=P.parse(s);let a="";for(const o of r)if(o.type==="static")a+=o.content;else if(o.expression)try{const c=this.expressionEvaluator.evaluateExpression(o.expression,i,n);a+=ie(c)}catch(c){console.warn(`Loop text evaluation error for "${o.expression}":`,c,"Available context keys:",Object.keys(i)),a+=""}e.textContent!==a&&(e.textContent=a)}extractMustacheBindings(e){const s=new Map,i=e.attributes;for(let n=0;n<i.length;n++){const r=i[n];if(!(r.name===d.ATTR_PREFIXES.COMPONENT||r.name==="key"||r.name.startsWith("on"))&&r.value){const a=d.MUSTACHE_PATTERN.test(r.value),o=P.decodeEntities(r.value),c=d.MUSTACHE_PATTERN.test(o);(a||c)&&s.set(r.name,o)}}return s}createLoopItemBinding(e,s,i,n,r,a){const o=`loop_item_${Date.now()}_${Math.random()}`,c=this.templateRenderer.dependencies(i,r,this.stateManager),l=new Set(c);let h=!1,p=0;const f=5,m=()=>{if(h)return;if(!document.contains(e)){if(p++,p<f){const A=10*Math.pow(2,p-1);setTimeout(()=>{h||m()},A)}else h=!0,this.stateManager.removeSubscription(o);return}p=0;try{const A=this.componentManager.buildComponentContext(r);let I;if(a){I={...A};let te=null;for(const[Ne,Ce]of this.loopBindings)if(Ce.renderedItems.includes(a)){te=Ce;break}te&&(I[te.itemVar]=a.context[te.itemVar],te.indexVar&&(I[te.indexVar]=a.context[te.indexVar]));for(const[Ne,Ce]of Object.entries(a.context))Ne in I||(I[Ne]=Ce)}else I=n;const fe=this.templateRenderer.render(i,I,r);this.domBindingManager?.updateElementProperty(e,s,fe)}catch(A){console.error(`Loop item binding evaluation error for "${i}":`,A),console.error("Available context keys:",Object.keys(n))}},x={id:o,selector:"",dependencies:l,callback:()=>{h||m()},element:e,component:r};if(this.stateManager.addSubscription(x),a){a.subscriptionIds.push(o);const v=this.cleanupLoopItem.bind(this);this.cleanupLoopItem=A=>{A===a&&(h=!0),v(A)}}(()=>{document.contains(e)?m():Promise.resolve().then(()=>{if(!h&&document.contains(e))m();else if(!h&&p<f){p++;const v=10*Math.pow(2,p-1);setTimeout(()=>{h||m()},v)}else!h&&p>=f&&(h=!0,this.stateManager.removeSubscription(o))})})()}updateItemContext(e,s,i,n){const r=this.createItemContext(e,i,n),a=this.gatherAllComponentContextsInLoopItem(s.element),o={...r,...a};if(s.context=o,this.loopItemContexts.set(s.element,o),s.textNodeTemplates)for(const[c,l]of s.textNodeTemplates)document.contains(c)&&this.updateTextNodeWithContext(c,l,o,this.getTextNodeComponent(c));if(s.attributeTemplates)for(const[c,l]of s.attributeTemplates)document.contains(c)&&l.forEach((h,p)=>{try{const f=y.getElementComponent(c),m=this.buildElementSpecificContext(c,o),x=this.templateRenderer.render(h,m,f);this.domBindingManager?.updateElementProperty(c,p,x)}catch(f){console.error(`Attribute binding update error for "${h}":`,f)}})}gatherAllComponentContextsInLoopItem(e){if(!this.componentManager)return{};const s={};if(e.hasAttribute(d.ATTR_PREFIXES.COMPONENT)){const n=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),r=this.componentManager.buildComponentContext(n);Object.assign(s,r)}return e.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}]`).forEach(n=>{const r=n.getAttribute(d.ATTR_PREFIXES.COMPONENT),a=this.componentManager?.buildComponentContext(r);Object.assign(s,a)}),s}buildElementSpecificContext(e,s){if(!this.componentManager)return s;const i=y.getElementComponent(e),n=this.componentManager.buildComponentContext(i);return{...s,...n}}getTextNodeComponent(e){let s=e.parentElement;for(;s;){const i=s.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i)return i;s=s.parentElement}return"app"}updateDOMOrder(e,s){let i=e.placeholder;s.forEach(n=>{(n.element.parentElement!==e.parentElement||n.element!==i.nextSibling)&&e.parentElement.insertBefore(n.element,i.nextSibling),i=n.element})}clearRenderedItems(e){e.renderedItems.forEach(s=>{this.cleanupLoopItem(s)}),e.renderedItems=[]}cleanupLoopItem(e){this.loopItemElements.delete(e.element),this.loopItemContexts.delete(e.element),e.element.parentElement&&e.element.parentElement.removeChild(e.element),e.subscriptionIds.forEach(s=>{this.stateManager.removeSubscription(s)})}isLoopItem(e){return this.loopItemElements.has(e)}getLoopItemContext(e){return this.loopItemContexts.get(e)}cleanupDetachedTemplates(e){for(const s of e)s.type==="childList"&&s.removedNodes.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const n=i;n.tagName==="TEMPLATE"&&n.hasAttribute("pp-for")&&this.cleanupTemplate(n),n.querySelectorAll("template[pp-for]").forEach(a=>{this.cleanupTemplate(a)})}})}cleanupTemplate(e){const s=this.loopBindings.get(e);s&&(this.clearRenderedItems(s),s.subscriptionIds.forEach(i=>{this.stateManager.removeSubscription(i)}),s.placeholder.parentElement&&s.placeholder.parentElement.removeChild(s.placeholder),this.loopBindings.delete(e))}getAllLoops(){return new Map(this.loopBindings)}destroy(){this.cleanupObserver.disconnect(),Array.from(this.loopBindings.keys()).forEach(e=>{this.cleanupTemplate(e)}),this.loopItemContexts=new WeakMap}}class ${cache=new Map;maxSize;hits=0;misses=0;constructor(e){this.maxSize=e}keys(){return Array.from(this.cache.keys())}deleteByPrefix(e){let s=0;const i=[];return this.cache.forEach((n,r)=>{typeof r=="string"&&r.startsWith(e)&&i.push(r)}),i.forEach(n=>{this.cache.delete(n)&&s++}),s}getKeysByPrefix(e){const s=[];return this.cache.forEach((i,n)=>{typeof n=="string"&&n.startsWith(e)&&s.push(n)}),s}get(e){const s=this.cache.get(e);if(s!==void 0)return this.hits++,this.cache.delete(e),this.cache.set(e,s),s;this.misses++}set(e,s){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){const i=this.cache.keys().next().value;i!==void 0&&this.cache.delete(i)}this.cache.set(e,s)}size(){return this.cache.size}has(e){return this.cache.has(e)}delete(e){return this.cache.delete(e)}clear(){this.cache.clear(),this.hits=0,this.misses=0}getStats(){const e=this.hits+this.misses;return{size:this.cache.size,maxSize:this.maxSize,hitRate:e>0?this.hits/e*100:0,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}}class P{static EXPRESSION_CACHE=new $(1e3);static parseSpreadDirective(e){const s=e.replace(/^\s*\{\s*|\s*\}\s*$/g,""),i=this.parseSpreadParts(s),n=[],r=[];for(const a of i){const o=a.trim();if(o.startsWith("..."))n.push(o.substring(3).trim());else if(o.startsWith("{")&&o.endsWith("}")){const c=o.slice(1,-1).trim();if(c){const l=this.parseObjectProperties(c);r.push(l)}}else console.warn(`Invalid spread directive part: "${o}". Expected ...spread or {object}`)}return{spreads:n,objects:r}}static parseSpreadParts(e){const s=[];let i="",n=0,r=!1,a="",o=0;for(;o<e.length;){const c=e[o],l=o>0?e[o-1]:"";if(!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&l!=="\\"&&(r=!1,a=""),!r){if(c==="{")n++;else if(c==="}")n--;else if(c===","&&n===0){s.push(i.trim()),i="",o++;continue}}i+=c,o++}return i.trim()&&s.push(i.trim()),s}static parseObjectProperties(e){const s=[],i=this.parseObjectParts(e);for(const n of i){const r=n.trim(),a=this.findPropertySeparator(r);if(a!==-1){const o=r.substring(0,a).trim().replace(/['"]/g,""),c=r.substring(a+1).trim();s.push({key:o,value:c})}else console.warn(`Invalid object property: "${r}". Expected key: value format.`)}return s}static parseObjectParts(e){const s=[];let i="",n=0,r=!1,a="";for(let o=0;o<e.length;o++){const c=e[o],l=o>0?e[o-1]:"";if(!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&l!=="\\"&&(r=!1,a=""),!r){if(c==="{"||c==="["||c==="(")n++;else if(c==="}"||c==="]"||c===")")n--;else if(c===","&&n===0){s.push(i.trim()),i="";continue}}i+=c}return i.trim()&&s.push(i.trim()),s}static findPropertySeparator(e){let s=0,i=!1,n="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!i&&(a==='"'||a==="'")?(i=!0,n=a):i&&a===n&&o!=="\\"&&(i=!1,n=""),!i){if(a==="{"||a==="["||a==="(")s++;else if(a==="}"||a==="]"||a===")")s--;else if(a===":"&&s===0)return r}}return-1}static decodeEntities=e=>{const s=document.createElement("textarea");s.innerHTML=e;let i=s.value;for(;i.includes("&");){s.innerHTML=i;const n=s.value;if(n===i)break;i=n}return i};static parse(e){const s=P.decodeEntities(e);if(P.EXPRESSION_CACHE.has(s))return P.EXPRESSION_CACHE.get(s);const i=P.parseContentWithNesting(s);return P.EXPRESSION_CACHE.set(s,i),i}static parseContentWithNesting(e){const s=[],i=e.length;let n=0,r=0;for(;n<i;)if(e[n]==="{"){n>r&&s.push({type:"static",content:e.substring(r,n),expression:null});const o=this.extractNestedExpression(e,n);o.endIndex!==-1?(s.push({type:"expression",content:e.substring(n,o.endIndex+1),expression:o.expression.trim()}),n=o.endIndex+1,r=n):n++}else n++;return r<i&&s.push({type:"static",content:e.substring(r),expression:null}),s}static extractNestedExpression(e,s){let i=1,n=s+1,r=!1,a="",o=!1;for(;n<e.length&&i>0;){const c=e[n],l=n>0?e[n-1]:"";!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&l!=="\\"&&(r=!1,a=""),!r&&c==="`"&&l!=="\\"&&(o=!o),!r&&!o&&(c==="{"?i++:c==="}"&&i--),n++}if(i===0){const c=e.slice(s+1,n-1);if(c.trim()){const l=this.checkForMismatchedQuotes(c);l.hasIssue&&(console.error(`
|
|
8
|
+
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};A.readEscapedChar=function(s){var e=this.input.charCodeAt(++this.pos);switch(++this.pos,e){case 110:return`
|
|
9
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return Z(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"),s){var t=this.pos-1;this.invalidStringToken(t,"Invalid escape sequence in template string")}default:if(e>=48&&e<=55){var i=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],n=parseInt(i,8);return n>255&&(i=i.slice(0,-1),n=parseInt(i,8)),this.pos+=i.length-1,e=this.input.charCodeAt(this.pos),(i!=="0"||e===56||e===57)&&(this.strict||s)&&this.invalidStringToken(this.pos-1-i.length,s?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(n)}return pe(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}};A.readHexChar=function(s){var e=this.pos,t=this.readInt(16,s);return t===null&&this.invalidStringToken(e,"Bad character escape sequence"),t};A.readWord1=function(){this.containsEsc=!1;for(var s="",e=!0,t=this.pos,i=this.options.ecmaVersion>=6;this.pos<this.input.length;){var n=this.fullCharCodeAtPos();if(te(n,i))this.pos+=n<=65535?1:2;else if(n===92){this.containsEsc=!0,s+=this.input.slice(t,this.pos);var r=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(e?K:te)(a,i)||this.invalidStringToken(r,"Invalid Unicode escape"),s+=Z(a),t=this.pos}else break;e=!1}return s+this.input.slice(t,this.pos)};A.readWord=function(){var s=this.readWord1(),e=u.name;return this.keywords.test(s)&&(e=We[s]),this.finishToken(e,s)};var Ts="8.15.0";M.acorn={Parser:M,version:Ts,defaultOptions:De,Position:ge,SourceLocation:we,getLineInfo:ct,Node:ke,TokenType:P,tokTypes:u,keywordTypes:We,TokContext:X,tokContexts:I,isIdentifierChar:te,isIdentifierStart:K,Token:Ke,isNewLine:pe,lineBreak:D,lineBreakG:Xt,nonASCIIwhitespace:at};function H(s,e){return M.parse(s,e)}function q(s,e,t,i,n){t||(t=x),(function r(a,o,c){var l=c||a.type;t[l](a,o,r),e[l]&&e[l](a,o)})(s,i,n)}function As(s,e,t,i,n){var r=[];t||(t=x),(function a(o,c,l){var p=l||o.type,h=o!==r[r.length-1];h&&r.push(o),t[p](o,c,a),e[p]&&e[p](o,c||r,r),h&&r.pop()})(s,i,n)}function Ge(s,e,t){t(s,e)}function oe(s,e,t){}var x={};x.Program=x.BlockStatement=x.StaticBlock=function(s,e,t){for(var i=0,n=s.body;i<n.length;i+=1){var r=n[i];t(r,e,"Statement")}};x.Statement=Ge;x.EmptyStatement=oe;x.ExpressionStatement=x.ParenthesizedExpression=x.ChainExpression=function(s,e,t){return t(s.expression,e,"Expression")};x.IfStatement=function(s,e,t){t(s.test,e,"Expression"),t(s.consequent,e,"Statement"),s.alternate&&t(s.alternate,e,"Statement")};x.LabeledStatement=function(s,e,t){return t(s.body,e,"Statement")};x.BreakStatement=x.ContinueStatement=oe;x.WithStatement=function(s,e,t){t(s.object,e,"Expression"),t(s.body,e,"Statement")};x.SwitchStatement=function(s,e,t){t(s.discriminant,e,"Expression");for(var i=0,n=s.cases;i<n.length;i+=1){var r=n[i];t(r,e)}};x.SwitchCase=function(s,e,t){s.test&&t(s.test,e,"Expression");for(var i=0,n=s.consequent;i<n.length;i+=1){var r=n[i];t(r,e,"Statement")}};x.ReturnStatement=x.YieldExpression=x.AwaitExpression=function(s,e,t){s.argument&&t(s.argument,e,"Expression")};x.ThrowStatement=x.SpreadElement=function(s,e,t){return t(s.argument,e,"Expression")};x.TryStatement=function(s,e,t){t(s.block,e,"Statement"),s.handler&&t(s.handler,e),s.finalizer&&t(s.finalizer,e,"Statement")};x.CatchClause=function(s,e,t){s.param&&t(s.param,e,"Pattern"),t(s.body,e,"Statement")};x.WhileStatement=x.DoWhileStatement=function(s,e,t){t(s.test,e,"Expression"),t(s.body,e,"Statement")};x.ForStatement=function(s,e,t){s.init&&t(s.init,e,"ForInit"),s.test&&t(s.test,e,"Expression"),s.update&&t(s.update,e,"Expression"),t(s.body,e,"Statement")};x.ForInStatement=x.ForOfStatement=function(s,e,t){t(s.left,e,"ForInit"),t(s.right,e,"Expression"),t(s.body,e,"Statement")};x.ForInit=function(s,e,t){s.type==="VariableDeclaration"?t(s,e):t(s,e,"Expression")};x.DebuggerStatement=oe;x.FunctionDeclaration=function(s,e,t){return t(s,e,"Function")};x.VariableDeclaration=function(s,e,t){for(var i=0,n=s.declarations;i<n.length;i+=1){var r=n[i];t(r,e)}};x.VariableDeclarator=function(s,e,t){t(s.id,e,"Pattern"),s.init&&t(s.init,e,"Expression")};x.Function=function(s,e,t){s.id&&t(s.id,e,"Pattern");for(var i=0,n=s.params;i<n.length;i+=1){var r=n[i];t(r,e,"Pattern")}t(s.body,e,s.expression?"Expression":"Statement")};x.Pattern=function(s,e,t){s.type==="Identifier"?t(s,e,"VariablePattern"):s.type==="MemberExpression"?t(s,e,"MemberPattern"):t(s,e)};x.VariablePattern=oe;x.MemberPattern=Ge;x.RestElement=function(s,e,t){return t(s.argument,e,"Pattern")};x.ArrayPattern=function(s,e,t){for(var i=0,n=s.elements;i<n.length;i+=1){var r=n[i];r&&t(r,e,"Pattern")}};x.ObjectPattern=function(s,e,t){for(var i=0,n=s.properties;i<n.length;i+=1){var r=n[i];r.type==="Property"?(r.computed&&t(r.key,e,"Expression"),t(r.value,e,"Pattern")):r.type==="RestElement"&&t(r.argument,e,"Pattern")}};x.Expression=Ge;x.ThisExpression=x.Super=x.MetaProperty=oe;x.ArrayExpression=function(s,e,t){for(var i=0,n=s.elements;i<n.length;i+=1){var r=n[i];r&&t(r,e,"Expression")}};x.ObjectExpression=function(s,e,t){for(var i=0,n=s.properties;i<n.length;i+=1){var r=n[i];t(r,e)}};x.FunctionExpression=x.ArrowFunctionExpression=x.FunctionDeclaration;x.SequenceExpression=function(s,e,t){for(var i=0,n=s.expressions;i<n.length;i+=1){var r=n[i];t(r,e,"Expression")}};x.TemplateLiteral=function(s,e,t){for(var i=0,n=s.quasis;i<n.length;i+=1){var r=n[i];t(r,e)}for(var a=0,o=s.expressions;a<o.length;a+=1){var c=o[a];t(c,e,"Expression")}};x.TemplateElement=oe;x.UnaryExpression=x.UpdateExpression=function(s,e,t){t(s.argument,e,"Expression")};x.BinaryExpression=x.LogicalExpression=function(s,e,t){t(s.left,e,"Expression"),t(s.right,e,"Expression")};x.AssignmentExpression=x.AssignmentPattern=function(s,e,t){t(s.left,e,"Pattern"),t(s.right,e,"Expression")};x.ConditionalExpression=function(s,e,t){t(s.test,e,"Expression"),t(s.consequent,e,"Expression"),t(s.alternate,e,"Expression")};x.NewExpression=x.CallExpression=function(s,e,t){if(t(s.callee,e,"Expression"),s.arguments)for(var i=0,n=s.arguments;i<n.length;i+=1){var r=n[i];t(r,e,"Expression")}};x.MemberExpression=function(s,e,t){t(s.object,e,"Expression"),s.computed&&t(s.property,e,"Expression")};x.ExportNamedDeclaration=x.ExportDefaultDeclaration=function(s,e,t){s.declaration&&t(s.declaration,e,s.type==="ExportNamedDeclaration"||s.declaration.id?"Statement":"Expression"),s.source&&t(s.source,e,"Expression")};x.ExportAllDeclaration=function(s,e,t){s.exported&&t(s.exported,e),t(s.source,e,"Expression")};x.ImportDeclaration=function(s,e,t){for(var i=0,n=s.specifiers;i<n.length;i+=1){var r=n[i];t(r,e)}t(s.source,e,"Expression")};x.ImportExpression=function(s,e,t){t(s.source,e,"Expression")};x.ImportSpecifier=x.ImportDefaultSpecifier=x.ImportNamespaceSpecifier=x.Identifier=x.PrivateIdentifier=x.Literal=oe;x.TaggedTemplateExpression=function(s,e,t){t(s.tag,e,"Expression"),t(s.quasi,e,"Expression")};x.ClassDeclaration=x.ClassExpression=function(s,e,t){return t(s,e,"Class")};x.Class=function(s,e,t){s.id&&t(s.id,e,"Pattern"),s.superClass&&t(s.superClass,e,"Expression"),t(s.body,e)};x.ClassBody=function(s,e,t){for(var i=0,n=s.body;i<n.length;i+=1){var r=n[i];t(r,e)}};x.MethodDefinition=x.PropertyDefinition=x.Property=function(s,e,t){s.computed&&t(s.key,e,"Expression"),s.value&&t(s.value,e,"Expression")};const d={ATTR_PREFIXES:{COMPONENT:"pp-component",CONTEXT:"pp-context",LOOP:"pp-for",SPREAD:"pp-spread",REF:"pp-ref"},SCRIPT_TYPE:"text/pp",MAX_CACHE_SIZE:2e3,DEBOUNCE_MS:16,POOL_SIZE:10,MUSTACHE_PATTERN:/\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}/,MUSTACHE_SINGLE_PATTERN:/^\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}$/},Ee=new Set(["true","false","null","undefined","this","window","document","console","Math","Date","JSON","Object","Array","return","let","const","var","if","else","for","while","switch","case","break","continue","function","new","in","of","typeof","instanceof","void","delete","try","catch","finally","class","extends","super","thisElement","eventObject","arguments"]);function ws(s,e){let t;return(...i)=>{clearTimeout(t),t=window.setTimeout(()=>s(...i),e)}}function Dt(s){return s.charAt(0).toUpperCase()+s.slice(1)}function re(s){if(s==null||typeof s=="boolean"||typeof s=="function"||Array.isArray(s)&&s.length===0||typeof s=="object"&&Object.keys(s).length===0)return"";if(typeof s=="number")return String(s);if(typeof s=="string")return s;if(Array.isArray(s))return s.map(e=>re(e)).filter(e=>e!=="").join("");if(typeof s=="object")try{return JSON.stringify(s)}catch{return"[object Object]"}return String(s)}class Ps{static validate(e,t){const i=[],n=[],r=this.validateTernaryOperator(e);i.push(...r.errors),n.push(...r.warnings);const a=this.validateSyntax(e);return i.push(...a.errors),n.push(...a.warnings),{valid:i.length===0,errors:i,warnings:n}}static validateTernaryOperator(e){const t=[],i=[];if(!e.includes("?")||!e.includes(":"))return{errors:t,warnings:i};const n=e.match(/([^?]+)\?([^:]+):(.+)/);if(!n)return{errors:t,warnings:i};const[,,r,a]=n,o=r.trim(),c=this.validateBranch(o,"truthy");t.push(...c.errors),i.push(...c.warnings);const l=a.trim(),p=this.validateBranch(l,"falsy");return t.push(...p.errors),i.push(...p.warnings),{errors:t,warnings:i}}static validateBranch(e,t){const i=[],n=[],r=this.countQuotes(e);if(r.single%2!==0&&(i.push(`Unmatched single quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,"'"))){const a=this.suggestQuoteFix(e,"'");a&&i.push(` Did you mean: ${a}`)}if(r.double%2!==0&&(i.push(`Unmatched double quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,'"'))){const a=this.suggestQuoteFix(e,'"');a&&i.push(` Did you mean: ${a}`)}return r.single===0&&r.double===0&&this.looksLikeUnquotedLiteral(e)&&n.push(`Value "${e}" in ternary ${t} branch may need quotes. Did you mean '${e}' or "${e}"?`),{errors:i,warnings:n}}static hasTrailingOrLeadingQuote(e,t){const i=e.startsWith(t),n=e.endsWith(t);return i&&!n||!i&&n}static suggestQuoteFix(e,t){return e.endsWith(t)&&!e.startsWith(t)?`${t}${e}`:e.startsWith(t)&&!e.endsWith(t)?`${e}${t}`:null}static looksLikeUnquotedLiteral(e){const t=e.trim();return!t||this.isAlreadyQuoted(t)||Ee.has(t)||t==="true"||t==="false"||t==="null"||t==="undefined"||!isNaN(Number(t))&&t!==""||/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)||t.includes(".")||/\[.*\]/.test(t)||/\(.*\)/.test(t)?!1:!!(t.includes("-")||/\s/.test(t)||/[^a-zA-Z0-9_$.]/.test(t))}static isAlreadyQuoted(e){return e.startsWith("'")&&e.endsWith("'")&&e.length>=2||e.startsWith('"')&&e.endsWith('"')&&e.length>=2}static countQuotes(e){let t=0,i=0,n=!1;for(let r=0;r<e.length;r++){if(n){n=!1;continue}if(e[r]==="\\"){n=!0;continue}e[r]==="'"&&t++,e[r]==='"'&&i++}return{single:t,double:i}}static validateSyntax(e){const t=[],i=[],n=this.checkBrackets(e);n.valid||t.push(n.error);const r=this.checkParentheses(e);return r.valid||t.push(r.error),{errors:t,warnings:i}}static checkBrackets(e){let t=0,i=!1,n="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!i&&(a==="'"||a==='"')?(i=!0,n=a):i&&a===n&&o!=="\\"&&(i=!1,n=""),!i&&(a==="{"&&t++,a==="}"&&t--,t<0))return{valid:!1,error:"Unexpected closing bracket '}'"}}return t!==0?{valid:!1,error:"Mismatched brackets - missing '}'"}:{valid:!0,error:""}}static checkParentheses(e){let t=0,i=!1,n="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!i&&(a==="'"||a==='"')?(i=!0,n=a):i&&a===n&&o!=="\\"&&(i=!1,n=""),!i&&(a==="("&&t++,a===")"&&t--,t<0))return{valid:!1,error:"Unexpected closing parenthesis ')'"}}return t!==0?{valid:!1,error:"Mismatched parentheses - missing ')'"}:{valid:!0,error:""}}}class ce{static instance;walkerPool=[];traversalCache=new WeakMap;lastCacheTime=new WeakMap;CACHE_TTL=250;trackedElements=new Set;static getInstance(){return ce.instance||(ce.instance=new ce),ce.instance}acquireWalker(e,t,i){return document.createTreeWalker(e,t,i)}releaseWalker(e){this.walkerPool.length<3&&this.walkerPool.push(e)}getCachedTraversal(e,t,i){const n=Date.now(),r=this.traversalCache.get(e),a=this.lastCacheTime.get(e);if(r&&a&&n-a<this.CACHE_TTL){const c=r.get(t);if(c)return c}const o=i();return this.traversalCache.has(e)||(this.traversalCache.set(e,new Map),this.trackedElements.add(e)),this.traversalCache.get(e).set(t,o),this.lastCacheTime.set(e,n),o}traverseElementsAndText(e,t,i){const n=this.acquireWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),r=[],a=[];let o;for(;o=n.nextNode();)if(o.nodeType===Node.ELEMENT_NODE){const c=o;(!t||t(c))&&r.push(c)}else if(o.nodeType===Node.TEXT_NODE){const c=o;(!i||i(c))&&a.push(c)}return this.releaseWalker(n),{elements:r,textNodes:a}}cleanupCache(){const e=[];for(const t of this.trackedElements)document.contains(t)||e.push(t);e.forEach(t=>{this.traversalCache.delete(t),this.lastCacheTime.delete(t),this.trackedElements.delete(t)})}}class V{static instance;componentElementsCache=new W(100);scriptElementsCache=new W(50);templateElementsCache=new W(50);selectorCache=new W(200);elementComponentCache=new WeakMap;parentComponentCache=new WeakMap;contextComponentCache=new WeakMap;elementDepthCache=new WeakMap;elementChildrenCache=new WeakMap;cacheHits=0;cacheMisses=0;static CACHE_KEYS={COMPONENT_ELEMENTS:e=>`comp:${e}`,SCRIPTS:(e,t)=>`scripts:${e}:${t}`,TEMPLATES:(e,t)=>`templates:${e}:${t}`,SELECTOR:e=>`sel:${e}`};static getInstance(){return V.instance||(V.instance=new V),V.instance}queryComponentElements(e){const t=V.CACHE_KEYS.COMPONENT_ELEMENTS(e);if(this.componentElementsCache.has(t))return this.cacheHits++,this.componentElementsCache.get(t);this.cacheMisses++;const i=Array.from(document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e}"]`));return i.forEach(n=>{this.elementComponentCache.set(n,e)}),this.componentElementsCache.set(t,i),i}querySelectorAll(e){const t=V.CACHE_KEYS.SELECTOR(e);if(this.selectorCache.has(t))return this.cacheHits++,this.selectorCache.get(t);this.cacheMisses++;const i=Array.from(document.querySelectorAll(e));return this.selectorCache.set(t,i),i}getElementComponent(e){if(this.elementComponentCache.has(e))return this.cacheHits++,this.elementComponentCache.get(e);this.cacheMisses++;const t=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(t)return this.elementComponentCache.set(e,t),t;let i=e.parentElement;for(;i;){const n=i.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(n)return this.elementComponentCache.set(e,n),n;i=i.parentElement}return this.elementComponentCache.set(e,"app"),"app"}getContextComponent(e){if(this.contextComponentCache.has(e))return this.cacheHits++,this.contextComponentCache.get(e);this.cacheMisses++;const t=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let i;if(t)if(t==="parent"){const n=this.getElementComponent(e);i=this.getParentOfComponent(n,e)}else t==="app"?i="app":i=t;else i=this.getElementComponent(e);return this.contextComponentCache.set(e,i),i}getParentOfComponent(e,t){if(this.parentComponentCache.has(t))return this.cacheHits++,this.parentComponentCache.get(t);if(this.cacheMisses++,e==="app")return this.parentComponentCache.set(t,"app"),"app";let i=t;for(;i&&i.getAttribute(d.ATTR_PREFIXES.COMPONENT)!==e;)i=i.parentElement;if(!i)return this.parentComponentCache.set(t,"app"),"app";let n=i.parentElement;for(;n;){const r=n.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(r)return this.parentComponentCache.set(t,r),r;n=n.parentElement}return this.parentComponentCache.set(t,"app"),"app"}getElementDepthCached(e){if(this.elementDepthCache.has(e))return this.cacheHits++,this.elementDepthCache.get(e);this.cacheMisses++;let t=0,i=e.parentElement;for(;i&&i!==document.body;)t++,i=i.parentElement;return this.elementDepthCache.set(e,t),t}getFirstComponentElement(e){const t=this.queryComponentElements(e);return t.length>0?t[0]:null}getComponentScripts(e,t){const i=V.CACHE_KEYS.SCRIPTS(e,t?.tagName||"global");if(this.scriptElementsCache.has(i))return this.cacheHits++,this.scriptElementsCache.get(i);this.cacheMisses++;let n=[];if(t){const r=t.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`);for(const a of r)a instanceof HTMLScriptElement&&n.push(a)}else{const r=document.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`);for(const a of r)if(a instanceof HTMLScriptElement){const o=a.getAttribute(d.ATTR_PREFIXES.COMPONENT);(o===e||!o&&!a.closest(`[${d.ATTR_PREFIXES.COMPONENT}]`))&&n.push(a)}}return this.scriptElementsCache.set(i,n),n}getComponentTemplates(e,t){const i=V.CACHE_KEYS.TEMPLATES(e,t?.tagName||"global");if(this.templateElementsCache.has(i))return this.cacheHits++,this.templateElementsCache.get(i);this.cacheMisses++;let n=[];if(t){const r=t.querySelectorAll("template[pp-for]");for(const a of r)a instanceof HTMLTemplateElement&&this.getElementComponent(a)===e&&n.push(a)}else{const r=document.querySelectorAll("template[pp-for]");for(const a of r)a instanceof HTMLTemplateElement&&this.getElementComponent(a)===e&&n.push(a)}return this.templateElementsCache.set(i,n),n}querySelector(e){const t=this.querySelectorAll(e);return t.length>0?t[0]:null}findElementForComponent(e,t){if(t==="app")return document.body;const i=this.queryComponentElements(t);return i.length>0?i[0]:null}invalidateCache(e){switch(e){case"components":this.componentElementsCache.clear();break;case"selectors":this.selectorCache.clear();break;case"scripts":this.scriptElementsCache.clear();break;case"templates":this.templateElementsCache.clear();break;default:this.clearAllCaches()}}invalidateByComponent(e){const t=V.CACHE_KEYS.COMPONENT_ELEMENTS(e);this.componentElementsCache.delete(t);const i=V.CACHE_KEYS.SCRIPTS(e,"global");this.scriptElementsCache.delete(i);const n=V.CACHE_KEYS.TEMPLATES(e,"global");this.templateElementsCache.delete(n),this.selectorCache.clear()}invalidateByPrefix(e){this.invalidateByComponent(e)}invalidateElement(e){this.elementComponentCache.delete(e),this.contextComponentCache.delete(e),this.parentComponentCache.delete(e),this.elementDepthCache.delete(e),this.elementChildrenCache.delete(e)}clearAllCaches(){this.componentElementsCache.clear(),this.scriptElementsCache.clear(),this.templateElementsCache.clear(),this.selectorCache.clear(),this.elementComponentCache=new WeakMap,this.parentComponentCache=new WeakMap,this.contextComponentCache=new WeakMap,this.elementDepthCache=new WeakMap,this.elementChildrenCache=new WeakMap}getCacheStats(){const e=this.cacheHits+this.cacheMisses;return{componentElements:this.componentElementsCache.getStats(),scriptElements:this.scriptElementsCache.getStats(),templateElements:this.templateElementsCache.getStats(),selectors:this.selectorCache.getStats(),global:{size:0,maxSize:-1,hitRate:e>0?this.cacheHits/e*100:0,hits:this.cacheHits,misses:this.cacheMisses}}}resetStats(){this.cacheHits=0,this.cacheMisses=0}}class _s{subscriptions=new Map;elementSubscriptions=new WeakMap;keyIndex=new Map;cleanupQueue=new Set;cleanupScheduled=!1;addSubscription(e){this.subscriptions.set(e.id,e),e.element&&(this.elementSubscriptions.has(e.element)||this.elementSubscriptions.set(e.element,new Set),this.elementSubscriptions.get(e.element).add(e.id));for(const t of e.dependencies)this.keyIndex.has(t)||this.keyIndex.set(t,new Set),this.keyIndex.get(t).add(e.id)}removeSubscription(e){const t=this.subscriptions.get(e);if(t){if(this.subscriptions.delete(e),t.element){const i=this.elementSubscriptions.get(t.element);i&&(i.delete(e),i.size===0&&this.elementSubscriptions.delete(t.element))}for(const i of t.dependencies){const n=this.keyIndex.get(i);n&&(n.delete(e),n.size===0&&this.keyIndex.delete(i))}}}cleanupElement(e){const t=this.elementSubscriptions.get(e);t&&(t.forEach(i=>this.cleanupQueue.add(i)),this.scheduleCleanup())}scheduleCleanup(){this.cleanupScheduled||(this.cleanupScheduled=!0,queueMicrotask(()=>{this.processCleanupQueue(),this.cleanupScheduled=!1}))}processCleanupQueue(){for(const e of this.cleanupQueue)this.removeSubscription(e);this.cleanupQueue.clear()}getSubscription(e){return this.subscriptions.get(e)}getSubscriptionsForKey(e){return this.keyIndex.get(e)}getAllSubscriptions(){return new Map(this.subscriptions)}cleanupStaleSubscriptions(){const e=[];for(const[t,i]of this.subscriptions)i.element&&!document.contains(i.element)&&e.push(t);e.forEach(t=>this.removeSubscription(t))}getStats(){return{totalSubscriptions:this.subscriptions.size,elementSubscriptions:this.elementSubscriptions instanceof WeakMap?-1:0,keyIndexes:this.keyIndex.size}}}class z{static instance;stateVariables=new Set;static FUNCTIONS_NEEDING_VALUE_TRANSFORM=new Set(["console.log","console.warn","console.error","console.info","console.debug","console.dir","console.table","console.trace","console.assert","JSON.stringify","JSON.parse","Object.keys","Object.values","Object.entries","Array.from","Array.isArray","Math.max","Math.min","Math.abs","Math.floor","Math.ceil","Math.round","alert","confirm","prompt","parseInt","parseFloat","Number","String","Boolean"]);transformRefDeclarations(e){try{const t=H(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const n=[];return q(t,{VariableDeclarator:r=>{if(this.isRefDeclaration(r)){const a=r.id.name,o=this.findStatementEnd(e,r.end);n.push({start:o,end:o,replacement:`; this.${a} = ${a}`})}}}),n.sort((r,a)=>a.start-r.start).forEach(r=>{i=i.slice(0,r.start)+r.replacement+i.slice(r.end)}),i}catch(t){return console.error("Ref transformation error:",t),e}}isRefDeclaration(e){return e.id?.type==="Identifier"&&e.init?.type==="CallExpression"&&e.init.callee?.type==="MemberExpression"&&e.init.callee.object?.type==="Identifier"&&e.init.callee.object.name==="pp"&&e.init.callee.property?.type==="Identifier"&&e.init.callee.property.name==="ref"}findStatementEnd(e,t){let i=t;for(;i<e.length&&e[i]!==";"&&e[i]!==`
|
|
10
|
+
`;)i++;return i}static getInstance(){return z.instance||(z.instance=new z),z.instance}extractFunctionNames(e){const t=[];try{const i=H(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});q(i,{FunctionDeclaration:n=>{n.id?.type==="Identifier"&&t.push(n.id.name)},VariableDeclarator:n=>{n.id?.type==="Identifier"&&(n.init?.type==="ArrowFunctionExpression"||n.init?.type==="FunctionExpression")&&t.push(n.id.name)},AssignmentExpression:n=>{n.left?.type==="Identifier"&&(n.right?.type==="ArrowFunctionExpression"||n.right?.type==="FunctionExpression")&&t.push(n.left.name)}})}catch(i){console.error("AST function extraction error:",i)}return Array.from(new Set(t))}transformEffectDeclarations(e){try{const t=H(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const n=[];return q(t,{CallExpression:r=>{const a=this.transformEffectCall(r,e);a&&n.push(a)}}),n.sort((r,a)=>a.start-r.start).forEach(r=>{i=i.slice(0,r.start)+r.replacement+i.slice(r.end)}),i}catch(t){return console.error("Effect transformation error:",t),e}}transformEffectCall(e,t){if(!this.isPPEffectCall(e))return null;const i=e.arguments;if(i.length<2)return null;const n=i[1];if(n.type!=="ArrayExpression"||!n.elements.some(h=>h?h.type==="Identifier"||h.type==="MemberExpression":!1))return null;const a=n.elements.map(h=>h?h.type==="Identifier"?`"${h.name}"`:h.type==="MemberExpression"?`"${this.extractMemberExpression(h,t)}"`:t.slice(h.start,h.end):"null"),o=t.slice(i[0].start,i[0].end),c=i.slice(2).map(h=>t.slice(h.start,h.end)).join(", "),l=`[${a.join(", ")}]`,p=c?`pp.effect(${o}, ${l}, ${c})`:`pp.effect(${o}, ${l})`;return{start:e.start,end:e.end,replacement:p}}extractMemberExpression(e,t){if(e.type!=="MemberExpression")return e.type==="Identifier"?e.name:t.slice(e.start,e.end);const i=this.extractMemberExpression(e.object,t);if(e.computed){const n=t.slice(e.property.start,e.property.end);return`${i}[${n}]`}else{const n=e.property.name||t.slice(e.property.start,e.property.end);return`${i}.${n}`}}isPPEffectCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&e.callee.property.name==="effect"}transformStateDeclarations(e){this.stateVariables.clear();let t=this.transformStateDeclarationsOnly(e);return t=this.transformEffectDeclarations(t),t=this.transformRefDeclarations(t),t=this.transformUnsupportedStateUsages(t),t}transformStateDeclarationsOnlyOriginal(e){try{const t=H(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const n=[];return q(t,{VariableDeclarator:r=>{const a=this.transformStateDeclarator(r,e);a&&n.push(a)}}),n.sort((r,a)=>a.start-r.start).forEach(r=>{i=i.slice(0,r.start)+r.replacement+i.slice(r.end)}),i}catch(t){return console.error("AST transformation error:",t),e}}transformStateDeclarationsOnly(e){let t=this.transformStateDeclarationsOnlyOriginal(e);return t=this.transformDestructuringAssignments(t),t}transformUnsupportedStateUsages(e){try{const t=H(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});this.collectStateVariables(t);let i=this.transformShorthandProperties(e);const n=H(i,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),r=[];return q(n,{SpreadElement:a=>{const o=this.transformSpreadElement(a,i);o&&r.push(o)},UnaryExpression:a=>{const o=this.transformUnaryExpression(a,i);o&&r.push(o)},BinaryExpression:a=>{const o=this.transformBinaryExpression(a,i);o&&r.push(o)},LogicalExpression:a=>{const o=this.transformLogicalExpression(a,i);o&&r.push(o)},ConditionalExpression:a=>{const o=this.transformConditionalExpression(a,i);o&&r.push(o)},IfStatement:a=>{const o=this.transformIfStatement(a,i);o&&r.push(o)},WhileStatement:a=>{const o=this.transformWhileStatement(a,i);o&&r.push(o)},ForStatement:a=>{const o=this.transformForStatement(a,i);o&&r.push(o)},ReturnStatement:a=>{const o=this.transformReturnStatement(a,i);o&&r.push(o)},VariableDeclarator:a=>{const o=this.transformVariableDeclarator(a,i);o&&r.push(o)},AssignmentExpression:a=>{const o=this.transformAssignmentExpression(a,i);o&&r.push(o)},CallExpression:a=>{const o=this.transformGeneralCallExpression(a,i);o&&r.push(o)}}),As(n,{Identifier:(a,o)=>{r.some(l=>a.start>=l.start&&a.end<=l.end)||this.stateVariables.has(a.name)&&(this.alreadyHasValue(a,i)||this.isPartOfStateDeclaration(a,o)||this.isPropertyName(a,o)||this.isMethodCallObject(a,o)||this.isPartOfPPCall(a,o)||this.isPartOfDestructuring(a,o)||r.push({start:a.start,end:a.end,replacement:`${a.name}.value`}))}}),r.sort((a,o)=>o.start-a.start).forEach(a=>{i=i.slice(0,a.start)+a.replacement+i.slice(a.end)}),i=this.transformMultipleCallArguments(i),i}catch(t){return console.error("State usage transformation error:",t),e}}transformShorthandProperties(e){try{const t=H(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const n=[];return q(t,{Property:r=>{if(r.shorthand&&r.key?.type==="Identifier"&&this.stateVariables.has(r.key.name)){const a=r.key.name,o=`${a}: ${a}.value`;n.push({start:r.start,end:r.end,replacement:o})}}}),n.sort((r,a)=>a.start-r.start).forEach(r=>{i=i.slice(0,r.start)+r.replacement+i.slice(r.end)}),i}catch(t){return console.error("Shorthand property transformation error:",t),e}}transformLogicalExpression(e,t){return e.left?.type==="Identifier"&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,t)?{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`}:e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,t)?{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}:null}transformConditionalExpression(e,t){return e.test?.type==="Identifier"&&this.stateVariables.has(e.test.name)&&!this.alreadyHasValue(e.test,t)?{start:e.test.start,end:e.test.end,replacement:`${e.test.name}.value`}:e.consequent?.type==="Identifier"&&this.stateVariables.has(e.consequent.name)&&!this.alreadyHasValue(e.consequent,t)?{start:e.consequent.start,end:e.consequent.end,replacement:`${e.consequent.name}.value`}:e.alternate?.type==="Identifier"&&this.stateVariables.has(e.alternate.name)&&!this.alreadyHasValue(e.alternate,t)?{start:e.alternate.start,end:e.alternate.end,replacement:`${e.alternate.name}.value`}:null}transformIfStatement(e,t){return this.transformExpressionNode(e.test,t)}transformWhileStatement(e,t){return this.transformExpressionNode(e.test,t)}transformForStatement(e,t){return e.test?this.transformExpressionNode(e.test,t):null}transformReturnStatement(e,t){return e.argument?this.transformExpressionNode(e.argument,t):null}transformVariableDeclarator(e,t){return this.isStateDeclaration(e)||e.id?.type==="ArrayPattern"||e.id?.type==="ObjectPattern"?null:e.init?.type==="Identifier"&&this.stateVariables.has(e.init.name)&&!this.alreadyHasValue(e.init,t)?{start:e.init.start,end:e.init.end,replacement:`${e.init.name}.value`}:null}transformAssignmentExpression(e,t){return e.left?.type==="ArrayPattern"||e.left?.type==="ObjectPattern"?null:e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,t)?{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}:null}transformGeneralCallExpression(e,t){const i=t.slice(e.callee.start,e.callee.end);if(e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&this.stateVariables.has(e.callee.object.name)||this.isPPCall(e))return null;if(!z.isFunctionNeedingValueTransform(i)&&e.arguments.length>0){for(const r of e.arguments)if(r.type==="Identifier"&&this.stateVariables.has(r.name)&&!this.alreadyHasValue(r,t))return{start:r.start,end:r.end,replacement:`${r.name}.value`}}return null}static isFunctionNeedingValueTransform(e){if(this.FUNCTIONS_NEEDING_VALUE_TRANSFORM.has(e))return!0;const t=e.lastIndexOf(".");if(t>-1){const i=e.slice(t+1);if(this.FUNCTIONS_NEEDING_VALUE_TRANSFORM.has(i))return!0}return!1}transformExpressionNode(e,t){return e?.type==="Identifier"&&this.stateVariables.has(e.name)&&!this.alreadyHasValue(e,t)?{start:e.start,end:e.end,replacement:`${e.name}.value`}:null}isPPCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&(e.callee.property.name==="state"||e.callee.property.name==="effect")}isPartOfStateDeclaration(e,t){if(!t||!Array.isArray(t))return!1;for(const i of t)if(i.type==="VariableDeclarator"&&i.id?.type==="ArrayPattern"&&i.init?.type==="CallExpression"&&this.isPPStateCall(i.init))return!0;return!1}isPropertyName(e,t){if(!t||t.length===0)return!1;const i=t[t.length-1];return!!(i?.type==="Property"&&i.key===e||i?.type==="Property"&&i.shorthand&&i.value===e||i?.type==="MemberExpression"&&i.property===e&&!i.computed)}isMethodCallObject(e,t){if(!t||t.length===0)return!1;const i=t[t.length-1];if(i?.type==="MemberExpression"&&i.object===e&&t.length>=2){const n=t[t.length-2];if(n?.type==="CallExpression"&&n.callee===i)return!0}return!1}isPartOfPPCall(e,t){if(!t||!Array.isArray(t))return!1;for(const i of t)if(i.type==="CallExpression"&&i.callee?.type==="MemberExpression"&&i.callee.object?.type==="Identifier"&&i.callee.object.name==="pp"&&i.callee.property?.type==="Identifier"&&(i.callee.property.name==="state"||i.callee.property.name==="effect"))return!0;return!1}isPartOfDestructuring(e,t){if(!t||!Array.isArray(t))return!1;for(let i=0;i<t.length;i++){const n=t[i];if(n.type==="ArrayPattern"||n.type==="ObjectPattern"){if(i+1<t.length){const r=t[i+1];if(r?.type==="VariableDeclarator"&&r.id===n&&r.init===e)return!1}return!0}}return!1}collectStateVariables(e){q(e,{VariableDeclarator:t=>{if(this.isStateDeclaration(t)){const i=t.id.elements[0];i?.type==="Identifier"&&this.stateVariables.add(i.name)}}})}isStateDeclaration(e){return e.id?.type==="ArrayPattern"&&e.init?.type==="CallExpression"&&this.isPPStateCall(e.init)}transformSpreadElement(e,t){return e.argument?.type==="Identifier"&&this.stateVariables.has(e.argument.name)?this.alreadyHasValue(e.argument,t)?null:{start:e.argument.start,end:e.argument.end,replacement:`${e.argument.name}.value`}:null}transformUnaryExpression(e,t){return e.argument?.type==="Identifier"&&this.stateVariables.has(e.argument.name)&&["typeof","!","+","-","~","void","delete"].includes(e.operator)&&!this.alreadyHasValue(e.argument,t)?{start:e.argument.start,end:e.argument.end,replacement:`${e.argument.name}.value`}:null}transformBinaryExpression(e,t){if(["===","!==","==","!=",">","<",">=","<=","+","-","*","/","%","**","&","|","^","<<",">>",">>>","in","instanceof"].includes(e.operator)){if(e.left?.type==="Identifier"&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,t))return{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`};if(e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,t))return{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}}return null}transformMultipleCallArguments(e){try{const t=H(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const n=[];return q(t,{CallExpression:r=>{const a=i.slice(r.callee.start,r.callee.end);if(z.isFunctionNeedingValueTransform(a)&&r.arguments.length>0)for(const c of r.arguments)c.type==="Identifier"&&this.stateVariables.has(c.name)&&(this.alreadyHasValue(c,i)||n.push({start:c.start,end:c.end,replacement:`${c.name}.value`}))}}),n.sort((r,a)=>a.start-r.start).forEach(r=>{i=i.slice(0,r.start)+r.replacement+i.slice(r.end)}),i}catch(t){return console.error("Multiple call arguments transformation error:",t),e}}transformDestructuringAssignments(e){try{const t=H(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const n=[];return q(t,{VariableDeclarator:r=>{this.isStateDeclaration(r)||(r.id?.type==="ArrayPattern"||r.id?.type==="ObjectPattern")&&r.init?.type==="Identifier"&&this.stateVariables.has(r.init.name)&&(this.alreadyHasValue(r.init,e)||n.push({start:r.init.start,end:r.init.end,replacement:`${r.init.name}.value`}))},AssignmentExpression:r=>{(r.left?.type==="ArrayPattern"||r.left?.type==="ObjectPattern")&&r.right?.type==="Identifier"&&this.stateVariables.has(r.right.name)&&(this.alreadyHasValue(r.right,e)||n.push({start:r.right.start,end:r.right.end,replacement:`${r.right.name}.value`}))}}),n.sort((r,a)=>a.start-r.start).forEach(r=>{i=i.slice(0,r.start)+r.replacement+i.slice(r.end)}),i}catch(t){return console.error("Destructuring transformation error:",t),e}}alreadyHasValue(e,t){const i=e.end;return t.slice(i,i+6).startsWith(".value")}transformStateDeclarator(e,t){if(e.id?.type!=="ArrayPattern"||e.init?.type!=="CallExpression")return null;const i=e.init;if(!this.isPPStateCall(i))return null;const n=e.id.elements[0];if(!n||n.type!=="Identifier")return null;const r=n.name,a=`set${this.capitalize(r)}`,o=e.id.elements[1];return o?.type==="Identifier"&&o.name!==a&&console.warn(`Setter name mismatch: expected ${a}, got ${o.name}`),this.createTransformation(i,r,t)}isPPStateCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&e.callee.property.name==="state"}createTransformation(e,t,i){const n=e.arguments;if(n.length===0){const c=`pp.state("${t}")`;return{start:e.start,end:e.end,replacement:c}}const r=n[0];if(r.type==="Literal"&&typeof r.value=="string"&&r.value===t)return null;if(n.length===1){const c=i.slice(r.start,r.end),l=`pp.state("${t}", ${c})`;return{start:e.start,end:e.end,replacement:l}}const a=i.slice(e.arguments[0].start,e.arguments[e.arguments.length-1].end),o=`pp.state("${t}", ${a})`;return{start:e.start,end:e.end,replacement:o}}looksLikeVariableName(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&e.length<=50&&!e.includes(" ")}extractStateDeclarations(e){const t=[];try{const i=H(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0});q(i,{VariableDeclarator:n=>{const r=this.extractStateFromDeclarator(n,e);r&&t.push(r)}})}catch(i){console.error("State extraction error:",i)}return t}extractStateFromDeclarator(e,t){if(e.id?.type!=="ArrayPattern"||e.init?.type!=="CallExpression"||!this.isPPStateCall(e.init))return null;const i=e.id.elements[0],n=e.id.elements[1];if(i?.type!=="Identifier"||n?.type!=="Identifier")return null;const r=e.init.arguments;let a=i.name,o;return r.length>=1&&(r[0].type==="Literal"&&typeof r[0].value=="string"?this.looksLikeVariableName(r[0].value)?(a=r[0].value,r.length>=2&&(o=this.extractLiteralValue(r[1]))):(a=i.name,o=this.extractLiteralValue(r[0])):o=this.extractLiteralValue(r[0])),{variableName:i.name,setterName:n.name,stateKey:a,initialValue:o,line:e.loc?.start.line||0,column:e.loc?.start.column||0}}extractFunctionDeclarations(e){const t=[];try{const i=H(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0});q(i,{FunctionDeclaration:n=>{n.id?.type==="Identifier"&&t.push({name:n.id.name,type:"function",params:n.params.map(r=>r.type==="Identifier"?r.name:""),line:n.loc?.start.line||0})},VariableDeclarator:n=>{if(n.id?.type==="Identifier"&&(n.init?.type==="ArrowFunctionExpression"||n.init?.type==="FunctionExpression")){const r=n.init;t.push({name:n.id.name,type:r.type==="ArrowFunctionExpression"?"arrow":"function",params:r.params.map(a=>a.type==="Identifier"?a.name:""),line:n.loc?.start.line||0})}}})}catch(i){console.error("Function extraction error:",i)}return t}extractLiteralValue(e){if(e.type==="Literal")return e.value;e.type==="Identifier"&&e.name}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}}class Qe{constructor(e){this.evaluator=e}render(e,t,i){const n=_.isSingleExpression(e);if(n)return this.evaluator.evaluateExpression(n,t,i);let r="";for(const a of _.parse(e))if(a.type==="static")r+=a.content;else if(a.expression)try{r+=re(this.evaluator.evaluateExpression(a.expression,t,i))}catch{}return r}dependencies(e,t,i){const n=_.extractExpressions(e),r=new Set;for(const a of n)for(const o of this.evaluator.extractDependencies(a,t,i))r.add(o);return[...r]}}class Ns{static containsMustacheExpression(e){if(d.MUSTACHE_PATTERN.test(e))return!0;const i=_.decodeEntities(e);return d.MUSTACHE_PATTERN.test(i)}}class v{static FRAMEWORK_ATTRIBUTES=new Set(["pp-component","pp-context","pp-for","pp-spread","pp-ref","key"]);static domCache;static getDOMCache(){return this.domCache||(this.domCache=V.getInstance()),this.domCache}static isFrameworkAttribute(e){return v.FRAMEWORK_ATTRIBUTES.has(e)}static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}static shouldBeDirectBinding(e,t){const i=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),n=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);return!i||!n||i===n?!1:v.isDOMProperty(e,t)}static isDOMProperty(e,t){const i=e.tagName.toLowerCase(),n=document.createElement(i);return v.attributeToPropertyName(t)in n}static attributeToPropertyName(e){const t={class:"className",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",minlength:"minLength",tabindex:"tabIndex",contenteditable:"contentEditable",formnovalidate:"formNoValidate",novalidate:"noValidate",allowfullscreen:"allowFullscreen",itemscope:"itemScope"};return t[e]?t[e]:e.replace(/-([a-z])/g,(i,n)=>n.toUpperCase())}static isBooleanAttribute(e){return["checked","disabled","hidden","readonly","required","multiple","selected","autofocus","autoplay","controls","defer","loop","muted","open","reversed","async","default","formnovalidate","novalidate","allowfullscreen","capture","itemscope"].includes(e)}static getContextComponent(e){return this.getDOMCache().getContextComponent(e)}static getParentOfComponent(e,t){return this.getDOMCache().getParentOfComponent(e,t)}static findElementForComponent(e,t){return this.getDOMCache().findElementForComponent(e,t)}static getElementDepth(e){return this.getDOMCache().getElementDepthCached(e)}static getParentComponentForElement(e){let t=e.parentElement;for(;t;){const i=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i)return i;t=t.parentElement}return"app"}static isTextNodeInsideScript(e){let t=e.parentElement;for(;t&&t!==document.body;){const i=t.tagName.toLowerCase();if(i==="script"||i==="style")return!0;t=t.parentElement}return!1}static getComponentForNode(e){let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return t?this.getDOMCache().getElementComponent(t):"app"}static getElementComponent(e){return this.getDOMCache().getElementComponent(e)}}class ue{static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}}class je{static findExistingStateKey(e,t,i){return[`${t}.${e}`,`app.${e}`,e].find(r=>r in i)||null}}class st{pendingUpdates=new Map;batchTimeout=null;componentManager;domBindingManager;setManagers(e,t){this.componentManager=e,this.domBindingManager=t}scheduleUpdate(e,t){this.pendingUpdates.has(e)||this.pendingUpdates.set(e,new Set),this.pendingUpdates.get(e).add(t),this.batchTimeout===null&&(this.batchTimeout=requestAnimationFrame(()=>{this.processBatchedUpdates(),this.batchTimeout=null}))}processBatchedUpdates(){const e=new Map(this.pendingUpdates);this.pendingUpdates.clear(),this.batchTimeout=null;const t=this.sortUpdatesByDependency(e);for(const[i,n]of t)this.processComponentUpdate(i,n)}sortUpdatesByDependency(e){const t=new WeakMap,i=n=>{let r=t.get(n);return r==null&&(r=v.getElementDepth(n),t.set(n,r)),r};return Array.from(e.entries()).sort(([,n],[,r])=>{const a=Math.min(...Array.from(n,i)),o=Math.min(...Array.from(r,i));return a-o})}processComponentUpdate(e,t){if(!this.componentManager||!this.domBindingManager)return;this.componentManager.invalidateComponent(e);const i=[],n=[],r=[];for(const a of t){if(!document.contains(a))continue;const o=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null);let c;for(;c=o.nextNode();)i.push(c);const l=this.domBindingManager.loopManager;if(l){const p=l.getAllLoops();for(const[h,f]of p)f.component===e&&a.contains(h)&&n.push([h,f])}r.push(a)}this.updateTextNodesBatch(i,e),this.updateLoopsBatch(n),this.updateElementsBatch(r,e)}updateTextNodesBatch(e,t){const i=this.domBindingManager.textNodeManager;i&&e.forEach(n=>{document.contains(n)&&v.getComponentForNode(n)===t&&i.updateTextNode(n)})}updateLoopsBatch(e){const t=this.domBindingManager.loopManager;if(!t)return;const i=new Map;e.forEach(([r,a])=>{const o=v.getElementDepth(r);i.has(o)||i.set(o,[]),i.get(o).push([r,a])});const n=Array.from(i.keys()).sort((r,a)=>r-a);for(const r of n)i.get(r).forEach(([o,c])=>{document.contains(o)&&t.renderLoop(c,c.iterableExpr)})}updateElementsBatch(e,t){e.forEach(i=>{document.contains(i)&&this.domBindingManager.processElementBindings(i,!0)})}}class Bt{loopBindings=new Map;stateManager;expressionEvaluator;componentManager;domBindingManager;cleanupObserver;loopCounter=0;pendingTemplates=[];loopItemElements=new WeakSet;loopItemContexts=new WeakMap;templateRenderer;templateMoveObserver;portalTemplates=new WeakSet;constructor(e,t){this.stateManager=e,this.expressionEvaluator=t,this.cleanupObserver=new MutationObserver(i=>{this.cleanupDetachedTemplates(i)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateMoveObserver=new MutationObserver(i=>{this.handleTemplateMoves(i)}),this.templateMoveObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateRenderer=new Qe(t),this.schedulePortalScan()}schedulePortalScan(){this.scanForPortalTemplates(),setTimeout(()=>{this.scanForPortalTemplates()},50),setTimeout(()=>{this.scanForPortalTemplates()},200)}scanForPortalTemplates(){document.querySelectorAll('[data-slot="portal"], #pp-portal-root > *').forEach(t=>{t.querySelectorAll("template[pp-for]").forEach(n=>{if(this.loopBindings.has(n))return;this.portalTemplates.add(n);const r=n.getAttribute(d.ATTR_PREFIXES.CONTEXT);let a;r?r==="app"?a="app":r==="parent"?a=t.getAttribute(d.ATTR_PREFIXES.COMPONENT)||"app":a=r:a=n.getAttribute(d.ATTR_PREFIXES.COMPONENT)||v.getElementComponent(n),this.processTemplate(n,a)})})}handleTemplateMoves(e){const t=new Set;for(const i of e)i.type==="childList"&&i.addedNodes.forEach(n=>{if(n.nodeType!==Node.ELEMENT_NODE)return;const r=n;if(r.querySelectorAll("template[pp-for]").forEach(o=>{const c=o;this.loopBindings.has(c)&&t.add(c)}),r.tagName==="TEMPLATE"&&r.hasAttribute("pp-for")){const o=r;this.loopBindings.has(o)&&t.add(o)}});t.size>0&&setTimeout(()=>{t.forEach(i=>{document.contains(i)&&this.updateMovedTemplate(i)})},0)}updateMovedTemplate(e){const t=this.loopBindings.get(e);if(!t)return;const i=e.parentElement;if(!i||i===t.parentElement&&t.placeholder.parentElement===i&&t.placeholder.nextSibling===e)return;const n=[...t.renderedItems];t.placeholder.parentElement&&t.placeholder.parentElement!==i&&t.placeholder.parentElement.removeChild(t.placeholder);const r=document.createComment(`pp-for: ${t.expression}`);i.insertBefore(r,e),t.parentElement=i,t.placeholder=r,n.length>0&&(n.forEach(a=>{a.element.parentElement!==i&&i.insertBefore(a.element,e)}),this.updateDOMOrder(t,n)),setTimeout(()=>{document.contains(e)&&this.renderLoop(t,t.iterableExpr)},0)}getLoopContextForElement(e){if(!this.domBindingManager)return null;const t=this.domBindingManager.loopManager;if(!t)return null;let i=e.parentElement;for(;i;){if(t.isLoopItem&&t.isLoopItem(i))return t.getLoopItemContext(i);i=i.parentElement}const n=t.getAllLoops();for(const[r,a]of n)for(const o of a.renderedItems)if(o.element.contains(e))return o.context;return null}setDependencies(e,t){this.componentManager=e,this.domBindingManager=t}queueTemplate(e,t){this.loopBindings.has(e)||this.pendingTemplates.push({template:e,component:t})}processPendingTemplates(){const e=[...this.pendingTemplates];this.pendingTemplates=[];for(const{template:t,component:i}of e)document.contains(t)&&this.processTemplate(t,i);this.scanForPortalTemplates()}processTemplate(e,t){const i=e.getAttribute("pp-for");if(!i||this.loopBindings.has(e))return;if(!e.parentElement){console.warn("⚠️ Template has no parent, queueing for later:",i),this.queueTemplate(e,t);return}const n=this.parseLoopExpression(i);if(!n){console.error(`Invalid pp-for syntax: "${i}"`);return}const r=e.parentElement,a=document.createComment(`pp-for: ${i}`);r.insertBefore(a,e);const o={template:e,expression:i,itemVar:n.itemVar,indexVar:n.indexVar,component:t,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:r,placeholder:a,iterableExpr:n.iterableExpr};this.loopBindings.set(e,o),this.setupLoopReactivity(o,n.iterableExpr),this.renderLoop(o,n.iterableExpr)}parseLoopExpression(e){const t=e.match(/^\s*([a-zA-Z_$][\w$]*)\s+in\s+(.+)$/);if(t)return{itemVar:t[1],iterableExpr:t[2].trim()};const i=e.match(/^\s*\(\s*([a-zA-Z_$][\w$]*)\s*,\s*([a-zA-Z_$][\w$]*)\s*\)\s+in\s+(.+)$/);return i?{itemVar:i[1],indexVar:i[2],iterableExpr:i[3].trim()}:null}setupLoopReactivity(e,t){const i=`loop_${Date.now()}_${++this.loopCounter}`,n=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager),r=this.findComponentElementForLoop(e);if(r&&this.componentManager){const o=this.componentManager.getComponentPropDependencies(r,e.component);n.push(...o)}const a={id:i,selector:"",dependencies:new Set(n),callback:()=>{this.renderLoop(e,e.iterableExpr)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(a),e.subscriptionIds.push(i)}renderLoop(e,t){if(!(!this.componentManager||!this.domBindingManager))try{const i=this.findComponentElementForLoop(e);let n;const r=this.findParentLoopContext(e.template);r?n={...i?this.componentManager.buildComponentContextWithProps(e.component,i):this.componentManager.buildComponentContext(e.component),...r}:n=i?this.componentManager.buildComponentContextWithProps(e.component,i):this.componentManager.buildComponentContext(e.component);const a=this.expressionEvaluator.evaluateExpression(t,n,e.component);if(!Array.isArray(a)){console.warn(`Loop expression "${t}" did not return an array:`,a,`Available context keys: [${Object.keys(n).join(", ")}]`,"Parent loop context:",r),this.clearRenderedItems(e);return}this.updateRenderedItems(e,a)}catch(i){console.error(`Error evaluating loop expression "${t}":`,i),this.clearRenderedItems(e)}}findParentLoopContext(e){const t=[];let i=e.parentElement;for(;i&&i!==document.body;){if(this.loopItemElements.has(i)){const n=this.loopItemContexts.get(i);n&&t.unshift(n)}for(const[n,r]of this.loopBindings)if(r.template!==e){for(const a of r.renderedItems)if(a.element===i||a.element.contains(e)){t.unshift(a.context);break}}i=i.parentElement}return t.length>0?t.reduce((n,r)=>({...n,...r}),{}):null}findComponentElementForLoop(e){if(this.portalTemplates.has(e.template)){const r=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e.component}"]`);for(const a of r)if(this.componentManager&&this.componentManager.hasStoredProps(a))return a;return r[0]||void 0}let i=e.parentElement;for(;i;){if(i.getAttribute(d.ATTR_PREFIXES.COMPONENT)===e.component)return i;i=i.parentElement}return document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e.component}"]`)[0]||void 0}updateRenderedItems(e,t){const i=e.renderedItems,n=[],r=new Set,a=new Map;i.forEach(o=>{a.set(o.key,o)}),t.forEach((o,c)=>{const l=this.generateItemKey(e,o,c),p=a.get(l);if(p&&!r.has(p.element))r.add(p.element),this.updateItemContext(e,p,o,c),n.push(p);else{const h=this.createLoopItem(e,o,c,l);h&&(n.push(h),this.processNestedLoopsInItem(h,e.component))}}),i.forEach(o=>{r.has(o.element)||this.cleanupLoopItem(o)}),this.updateDOMOrder(e,n),e.renderedItems=n}processNestedLoopsInItem(e,t){e.element.querySelectorAll("template[pp-for]").forEach(n=>{const r=n;this.loopBindings.has(r)||this.processNestedTemplate(r,t,e.context)})}generateItemKey(e,t,i){const r=e.template.content.firstElementChild;if(r&&r.hasAttribute("key")){const a=r.getAttribute("key");try{const o=this.createItemContextWithParentContext(e,t,i),c=_.isSingleExpression(a);if(c){const l=this.expressionEvaluator.evaluateExpression(c,o,e.component);return String(l)}else{const l=_.parse(a);let p="";for(const h of l)if(h.type==="static")p+=h.content;else if(h.expression){const f=this.expressionEvaluator.evaluateExpression(h.expression,o,e.component);p+=re(f)}return p}}catch(o){console.warn(`Error evaluating key expression "${a}":`,o,"Available context keys:",Object.keys(this.createItemContextWithParentContext(e,t,i)))}}return t&&typeof t=="object"&&"id"in t?String(t.id):`${e.expression}_${i}`}createItemContextWithParentContext(e,t,i){if(!this.componentManager)return{};const n=this.componentManager.buildComponentContext(e.component),r=this.getAllParentLoopContexts(e.template),a=t&&typeof t=="object"?Object.keys(t):[],o={};for(const[l,p]of Object.entries(n))a.includes(l)&&!l.startsWith("set")&&!l.endsWith("Getter")||(o[l]=p);const c={...o,...r,[e.itemVar]:t};return e.indexVar&&(c[e.indexVar]=i),c}getAllParentLoopContexts(e){const t=[];let i=e.parentElement;for(;i&&i!==document.body;){if(this.loopItemElements.has(i)){const n=this.loopItemContexts.get(i);n&&t.unshift(n)}for(const[n,r]of this.loopBindings)if(n!==e){for(const a of r.renderedItems)if(a.element===i||a.element.contains(e)){t.unshift(a.context);break}}i=i.parentElement}return t.reduce((n,r)=>({...n,...r}),{})}createItemContext(e,t,i){if(!this.componentManager)return{};const n=this.componentManager.buildComponentContext(e.component),r={},a=t&&typeof t=="object"?Object.keys(t):[];for(const[l,p]of Object.entries(n)){if(typeof p=="function"&&!p.__pphp_key){r[l]=p;continue}if(l.startsWith("set")||l.endsWith("Getter")){r[l]=p;continue}if(["getContext","withContext","__getProp"].includes(l)){r[l]=p;continue}a.includes(l)||(r[l]=p)}const o=this.findAllParentLoopContexts(e.template),c={...r,...o,[e.itemVar]:t};return e.indexVar&&(c[e.indexVar]=i),c}findAllParentLoopContexts(e){const t={};let i=e.parentElement;for(;i&&i!==document.body;){if(this.loopItemElements.has(i)){const n=this.loopItemContexts.get(i);if(n)for(const[r,a]of Object.entries(n))r in t||(t[r]=a)}for(const[n,r]of this.loopBindings)if(n!==e){for(const a of r.renderedItems)if(a.element===i){for(const[o,c]of Object.entries(a.context))o in t||(t[o]=c);break}}i=i.parentElement}return t}createLoopItem(e,t,i,n){if(!this.domBindingManager)return null;try{const r=this.createItemContextWithParentContext(e,t,i),a=document.importNode(e.template.content,!0),o=document.createElement("div");o.appendChild(a);const c=o.firstElementChild;if(!c)return console.warn("Template content must contain exactly one root element"),null;o.removeChild(c),this.loopItemElements.add(c),this.loopItemContexts.set(c,r),c.getAttribute("key")&&c.removeAttribute("key");const p={key:n,element:c,context:r,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map};return this.executeComponentScriptsInLoopItem(c),this.processRefsInLoopItem(c,r,e.component),this.processElementWithContext(c,r,e.component,p),this.cleanupRawMustacheAttributes(c),p}catch(r){return console.error("Error creating loop item:",r),null}}processRefsInLoopItem(e,t,i){if(e.hasAttribute("pp-ref")){const o=e.getAttribute("pp-ref");this.processRefAttribute(e,o,t,i)}const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>o.hasAttribute("pp-ref")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let r;const a=[];for(;r=n.nextNode();)a.push(r);a.forEach(o=>{const c=o.getAttribute("pp-ref");this.processRefAttribute(o,c,t,i)})}processRefAttribute(e,t,i,n){try{const r=_.decodeEntities(t),a=_.isSingleExpression(r)||r,o=this.expressionEvaluator.evaluateExpression(a,i,n);typeof o=="function"?o(e):o&&typeof o=="object"&&"current"in o?o.current=e:console.warn("⚠️ Invalid ref result:",o),e.removeAttribute("pp-ref")}catch(r){console.error("❌ Failed to process ref:",r)}}executeComponentScriptsInLoopItem(e){if(!this.componentManager)return;const t=[e],i=e.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}]`);t.push(...Array.from(i)),t.forEach(n=>{if(n.hasAttribute(d.ATTR_PREFIXES.COMPONENT)){const r=n.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(r){const a=this.getLoopItemContextForElement(n),o=this.generateInstanceId(a),c=`${r}_${o}`;n.setAttribute(d.ATTR_PREFIXES.COMPONENT,c),n.__originalComponentName=r,n.__uniqueComponentName=c,this.componentManager.pushComponent(c),window[c]||(window[c]={}),window[r]&&Object.assign(window[c],window[r]),this.getComponentScripts(n).forEach(p=>{this.componentManager.executeScript(p)}),this.componentManager.popComponent()}}})}getLoopItemContextForElement(e){let t=e;for(;t;){if(this.loopItemElements.has(t)){const i=this.loopItemContexts.get(t);if(i)return i}t=t.parentElement}for(const[i,n]of this.loopBindings)for(const r of n.renderedItems)if(r.element===e||r.element.contains(e))return r.context;return console.warn("⚠️ No loop item context found, using empty context"),{}}generateInstanceId(e){const t={};for(const[a,o]of Object.entries(e))typeof o=="function"||a.startsWith("set")||a.endsWith("Getter")||a==="getContext"||a==="withContext"||a==="__getProp"||o&&typeof o=="function"&&"__pphp_key"in o||typeof o=="boolean"||typeof o=="number"||typeof o=="string"||o&&typeof o=="object"&&!Array.isArray(o)&&"id"in o&&(t[a]=o);return Object.keys(t).length===0?`${Date.now()}_${Math.random().toString(36).substring(2,7)}`:Object.keys(t).sort().map(a=>{const o=t[a];return o&&typeof o=="object"&&"id"in o?`${a}_${o.id}`:`${a}_${JSON.stringify(o)}`}).join("_").replace(/[^a-zA-Z0-9_]/g,"").substring(0,20)||`fallback_${Date.now()}`}getComponentScripts(e){const t=[];return e.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`).forEach(n=>{const r=n;let a=r.parentElement,o=!1;for(;a&&a!==e.parentElement;){if(a===e){o=!0;break}if(a.hasAttribute(d.ATTR_PREFIXES.COMPONENT)&&a!==e)break;a=a.parentElement}o&&t.push(r)}),t}cleanupRawMustacheAttributes(e){this.cleanupElementMustacheAttributes(e);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let i;for(;i=t.nextNode();)this.cleanupElementMustacheAttributes(i)}cleanupElementMustacheAttributes(e){const t=Array.from(e.attributes);for(const i of t)i.value&&d.MUSTACHE_PATTERN.test(i.value)&&(v.isBooleanAttribute(i.name),e.removeAttribute(i.name))}processElementWithContext(e,t,i,n){if(!this.domBindingManager||!this.componentManager)return;const r=(o,c)=>{const l=this.componentManager.buildComponentContext(c),p=o.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(p&&p!==c){const f=this.componentManager.buildComponentContext(p);return{...t,...l,...f}}return{...t,...l}},a=this.componentManager.buildComponentContextWithProps.bind(this.componentManager);this.componentManager.buildComponentContextWithProps=(o,c)=>c&&(c===e||e.contains(c))?r(c,o):a(o,c);try{if(e.hasAttribute("pp-ref")){const f=e.getAttribute("pp-ref");this.processRefInLoopContext(e,f,t,i),e.removeAttribute("pp-ref")}const o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:f=>f===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}),c=[];let l;for(;l=o.nextNode();){const f=l;if(f.hasAttribute("pp-ref")){const g=f.getAttribute("pp-ref");c.push({element:f,expression:g})}}c.forEach(({element:f,expression:g})=>{this.processRefInLoopContext(f,g,t,i)});const p=this.bindLoopItemElement(e,t,i,n);this.setupEventBindingsForLoopItem(e,i);for(let f=0;f<e.childNodes.length;f++){const g=e.childNodes[f];if(g.nodeType===Node.TEXT_NODE){const m=g;if(m.textContent&&d.MUSTACHE_PATTERN.test(m.textContent)&&!v.isTextNodeInsideScript(m)){const E=this.getComponentForTextNode(m);this.processTextNodeWithLoopContext(m,p,E,n)}}else if(g.nodeType===Node.ELEMENT_NODE){const m=g;if(m.tagName.toLowerCase()==="script")continue;const y=m.getAttribute(d.ATTR_PREFIXES.COMPONENT)||i,S=this.bindLoopItemElement(m,p,y,n);this.setupEventBindingsForLoopItem(m,y),this.processChildrenRecursively(m,S,y,n)}}e.querySelectorAll("template[pp-for]").forEach(f=>{(f.parentElement===e||e.contains(f))&&this.processNestedTemplate(f,i,p)})}finally{this.componentManager.buildComponentContextWithProps=a}}processChildrenRecursively(e,t,i,n){const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{if(o===e)return NodeFilter.FILTER_SKIP;if(o.nodeType===Node.TEXT_NODE){const c=o;if(v.isTextNodeInsideScript(c))return NodeFilter.FILTER_REJECT;if(c.textContent&&d.MUSTACHE_PATTERN.test(c.textContent))return NodeFilter.FILTER_ACCEPT}else if(o.nodeType===Node.ELEMENT_NODE){const c=o;if(c.tagName.toLowerCase()==="script")return NodeFilter.FILTER_REJECT;const l=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);return l&&l!==i&&!n?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let a;for(;a=r.nextNode();)if(a.nodeType===Node.TEXT_NODE){const o=a,c=this.getComponentForTextNode(o);this.processTextNodeWithLoopContext(o,t,c,n)}else if(a.nodeType===Node.ELEMENT_NODE){const o=a,c=v.getElementComponent(o),l=this.bindLoopItemElement(o,t,c,n);this.setupEventBindingsForLoopItem(o,c),this.processChildrenRecursively(o,l,c,n)}}processChildElementsWithContext(e,t,i,n){const r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:l=>{if(l===e)return NodeFilter.FILTER_SKIP;if(l.nodeType===Node.TEXT_NODE){const p=l;if(v.isTextNodeInsideScript(p))return NodeFilter.FILTER_REJECT;if(p.textContent&&d.MUSTACHE_PATTERN.test(p.textContent))return NodeFilter.FILTER_ACCEPT}else if(l.nodeType===Node.ELEMENT_NODE){const p=l;if(p.tagName.toLowerCase()==="script")return NodeFilter.FILTER_REJECT;const h=p.getAttribute(d.ATTR_PREFIXES.COMPONENT);return h&&h!==i?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let a;const o=[],c=[];for(;a=r.nextNode();)a.nodeType===Node.ELEMENT_NODE?o.push(a):a.nodeType===Node.TEXT_NODE&&c.push(a);c.forEach(l=>{const p=this.getComponentForTextNode(l);this.processTextNodeWithLoopContext(l,t,p,n)}),o.forEach(l=>{const p=v.getElementComponent(l),h=this.bindLoopItemElement(l,t,p,n);this.setupEventBindingsForLoopItem(l,p),this.processChildElementsWithContext(l,h,p,n)})}processRefInLoopContext(e,t,i,n){try{const r=_.decodeEntities(t),a=_.isSingleExpression(r)||r,o=this.expressionEvaluator.evaluateExpression(a,i,n);typeof o=="function"?o(e):o&&typeof o=="object"&&"current"in o?o.current=e:console.warn("⚠️ Invalid ref result:",o),e.removeAttribute("pp-ref")}catch(r){console.error("❌ processRefInLoopContext error:",r)}}getComponentForTextNode(e){let t=e.parentElement;for(;t;){const i=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i)return i;t=t.parentElement}return"app"}processNestedTemplate(e,t,i){const n=e.getAttribute("pp-for");if(!n||this.loopBindings.has(e))return;const r=this.parseLoopExpression(n);if(!r){console.error(`Invalid pp-for syntax: "${n}"`);return}const a=e.parentElement,o=document.createComment(`pp-for: ${n}`);a.insertBefore(o,e);const c=this.findComponentElementForTemplate(e);let l={...i};const p=this.findParentLoopContextForNestedTemplate(e);if(p&&(l={...l,...p}),c&&this.componentManager){const f=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(f){const g=v.getParentComponentForElement(c);this.componentManager.hasStoredProps(c)||this.componentManager.setupProps(c,g);const m=this.evaluateComponentPropsWithContext(c,l);l={...this.componentManager.buildComponentContext(f),...m,...l}}}const h={template:e,expression:n,itemVar:r.itemVar,indexVar:r.indexVar,iterableExpr:r.iterableExpr,component:t,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:a,placeholder:o};this.loopBindings.set(e,h),this.setupNestedLoopReactivity(h,r.iterableExpr,l),this.renderNestedLoop(h,r.iterableExpr,l)}findParentLoopContextForNestedTemplate(e){let t=e.parentElement;const i={};let n=0;for(;t&&t!==document.body&&n<10;){if(n++,this.loopItemElements.has(t)){const r=this.loopItemContexts.get(t);if(r)for(const[a,o]of Object.entries(r))a in i||(i[a]=o)}for(const[r,a]of this.loopBindings)for(const o of a.renderedItems)(o.element.contains(e)||o.element===t)&&(a.itemVar in i||(i[a.itemVar]=o.context[a.itemVar]),a.indexVar&&!(a.indexVar in i)&&(i[a.indexVar]=o.context[a.indexVar]));t=t.parentElement}return Object.keys(i).length>0?i:null}evaluateComponentPropsWithContext(e,t){const i={};if(!this.componentManager||!this.expressionEvaluator)return i;const n=this.componentManager.extractProps(e,"app");for(const[r,a]of n)try{const o=this.templateRenderer.render(a.expression,t,a.component);i[r]=o}catch(o){console.error(`Failed to evaluate prop "${r}":`,o),i[r]=void 0}return i}findComponentElementForTemplate(e){let t=e.parentElement;for(;t;){if(t.hasAttribute(d.ATTR_PREFIXES.COMPONENT))return t;t=t.parentElement}return null}setupNestedLoopReactivity(e,t,i){const n=`nested_loop_${Date.now()}_${++this.loopCounter}`;let r=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager);const a={id:n,selector:"",dependencies:new Set(r),callback:()=>{const o=e.template,c=this.findComponentElementForTemplate(o);let l=i;if(o.parentElement){const h=this.getParentLoopContextForElement(o);h&&(l={...l,...h})}if(c&&this.componentManager){const h=c.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(h){const f=this.extractParentLoopContextFromBinding(e,i),g=this.evaluateComponentPropsWithContext(c,f),m=this.componentManager.buildComponentContext(h);l={...f,...m,...g}}}this.renderNestedLoop(e,t,l)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(a),e.subscriptionIds.push(n)}getParentLoopContextForElement(e){let t=e.parentElement;for(;t;){if(this.loopItemElements.has(t)){const i=this.loopItemContexts.get(t);if(i)return i}t=t.parentElement}return null}extractParentLoopContextFromBinding(e,t){const i=new Set;for(const[r,a]of this.loopBindings)if(a!==e){for(const o of a.renderedItems)if(o.element.contains(e.template)){i.add(a.itemVar),a.indexVar&&i.add(a.indexVar);break}}const n={};for(const[r,a]of Object.entries(t))(i.has(r)||r.startsWith("users")||r.startsWith("set")||r.includes("Getter")||typeof a=="function")&&(n[r]=a);return n}renderNestedLoop(e,t,i){if(!(!this.componentManager||!this.domBindingManager))try{const n=this.expressionEvaluator.evaluateExpression(t,i,e.component);if(!Array.isArray(n)){console.warn(`Nested loop expression "${t}" did not return an array:`,n,`Available context keys: [${Object.keys(i).join(", ")}]`),this.clearRenderedItems(e);return}this.updateNestedRenderedItems(e,n,i)}catch(n){console.error(`Error evaluating nested loop expression "${t}":`,n,`Available context keys: [${Object.keys(i).join(", ")}]`),this.clearRenderedItems(e)}}updateNestedRenderedItems(e,t,i){const n=e.renderedItems,r=[],a=new Set,o=new Map;n.forEach(c=>{o.set(c.key,c)}),t.forEach((c,l)=>{const p=this.generateNestedItemKey(e,c,l,i),h=o.get(p);if(h&&!a.has(h.element))a.add(h.element),this.updateNestedItemContext(e,h,c,l,i),r.push(h);else{const f=this.createNestedLoopItem(e,c,l,p,i);f&&r.push(f)}}),n.forEach(c=>{a.has(c.element)||this.cleanupLoopItem(c)}),this.updateDOMOrder(e,r),e.renderedItems=r}generateNestedItemKey(e,t,i,n){return t&&typeof t=="object"&&"id"in t?String(t.id):`${e.expression}_${i}_${JSON.stringify(n[e.itemVar]||{})}`}createNestedLoopItem(e,t,i,n,r){if(!this.domBindingManager)return null;try{const a={...r,[e.itemVar]:t};e.indexVar&&(a[e.indexVar]=i);const o=document.importNode(e.template.content,!0),c=document.createElement("div");c.appendChild(o);const l=c.firstElementChild;if(!l)return console.warn("Template content must contain exactly one root element"),null;c.removeChild(l),this.loopItemElements.add(l),this.loopItemContexts.set(l,a),l.getAttribute("key")&&l.removeAttribute("key");const h={key:n,element:l,context:a,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map};return this.processElementWithContext(l,a,e.component,h),this.cleanupRawMustacheAttributes(l),h}catch(a){return console.error("Error creating nested loop item:",a),null}}updateNestedItemContext(e,t,i,n,r){const a={...r};a[e.itemVar]=i,e.indexVar&&(a[e.indexVar]=n);const o=this.gatherAllComponentContextsInLoopItem(t.element),c={...a,...o};if(t.context=c,this.loopItemContexts.set(t.element,c),t.textNodeTemplates)for(const[l,p]of t.textNodeTemplates)document.contains(l)&&this.updateTextNodeWithContext(l,p,c,this.getTextNodeComponent(l));if(t.attributeTemplates)for(const[l,p]of t.attributeTemplates)document.contains(l)&&p.forEach((h,f)=>{try{const g=v.getElementComponent(l),m=this.buildElementSpecificContext(l,c),E=this.templateRenderer.render(h,m,g);this.domBindingManager?.updateElementProperty(l,f,E)}catch(g){console.error(`Nested binding update error for "${h}":`,g)}})}bindLoopItemElement(e,t,i,n){const r=this.extractMustacheBindings(e),a=this.findOriginalComponentName(i),o=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let c=a;o?o==="app"?c="app":o==="parent"?c=this.findLoopParentComponent(e,a):c=o:c=this.findLoopParentComponent(e,a);let l=this.componentManager.buildComponentContext(c);l={...l,...t};const h=!!e.getAttribute(d.ATTR_PREFIXES.COMPONENT),f=new Map,g=new Map;r.forEach((S,N)=>{h&&N!=="class"&&N!=="style"?f.set(N,S):g.set(N,S)});const m={},E=this.sortPropsByDependency(f);for(const[S,N]of E)try{const k=this.templateRenderer.render(N,l,c);m[S]=k,l[S]=k}catch(k){console.error(`❌ Failed to evaluate prop "${S}":`,k),m[S]=void 0,l[S]=void 0}h&&Object.keys(m).length>0&&(window[i]||(window[i]={}),Object.assign(window[i],m));const y=l;return n&&Object.keys(m).length>0&&Object.assign(n.context,m),n&&r.size>0&&(n.attributeTemplates||(n.attributeTemplates=new Map),n.attributeTemplates.set(e,new Map(r))),r.forEach((S,N)=>{this.createLoopItemBinding(e,N,S,y,c,n)}),y}sortPropsByDependency(e){const t=Array.from(e.keys()),i=Array.from(e.entries()),n=[],r=[];for(const[a,o]of i)t.some(l=>l!==a&&o.includes(l))?r.push([a,o]):n.push([a,o]);return[...n,...r]}setupEventBindingsForLoopItem(e,t){const i=this.domBindingManager.eventDelegation;if(!i){console.warn("No event delegation manager available");return}const n=Array.from(e.attributes);for(const r of n)if(ue.isEventAttribute(r.name)){const a=r.name.substring(2);i.registerEventHandler(e,a,r.value,t),e.removeAttribute(r.name)}}processTextNodeWithLoopContext(e,t,i,n){if(v.isTextNodeInsideScript(e))return;const r=e.textContent||"";if(!_.parse(r).some(E=>E.type==="expression"))return;n&&(n.textNodeTemplates||(n.textNodeTemplates=new Map),n.textNodeTemplates.set(e,r));const c=this.findActualComponentForTextNode(e);let l=t;c!==i&&n&&this.componentManager&&(l={...this.componentManager.buildComponentContext(c),...n.context}),this.updateTextNodeWithContext(e,r,l,c);const p=`loop_text_${Date.now()}_${Math.random()}`,h=this.templateRenderer.dependencies(r,c,this.stateManager),f=new Set(h),m={id:p,selector:"",dependencies:f,callback:()=>{if(!document.contains(e)){this.stateManager.removeSubscription(p);return}let E={};if(this.componentManager&&(c!==i&&n?E={...this.componentManager.buildComponentContext(c),...n.context}:E=this.componentManager.buildComponentContext(c)),n){const y={};let S=null;for(const[N,k]of this.loopBindings)if(k.renderedItems.includes(n)){S=k;break}if(S){y[S.itemVar]=n.context[S.itemVar],S.indexVar&&(y[S.indexVar]=n.context[S.indexVar]);const N=this.findParentLoopContext(S.template);N&&Object.assign(y,N)}E={...E,...y}}this.updateTextNodeWithContext(e,r,E,c)},component:c};this.stateManager.addSubscription(m),n&&n.subscriptionIds.push(p)}findActualComponentForTextNode(e){let t=e.parentElement;for(;t;){const i=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i){const n=t.__uniqueComponentName;return n||i}t=t.parentElement}return"app"}updateTextNodeWithContext(e,t,i,n){const r=_.parse(t);let a="";for(const o of r)if(o.type==="static")a+=o.content;else if(o.expression)try{const c=this.expressionEvaluator.evaluateExpression(o.expression,i,n);a+=re(c)}catch(c){console.warn(`Loop text evaluation error for "${o.expression}":`,c,"Available context keys:",Object.keys(i)),a+=""}e.textContent!==a&&(e.textContent=a)}extractMustacheBindings(e){const t=new Map,i=e.attributes;for(let n=0;n<i.length;n++){const r=i[n];if(!(r.name===d.ATTR_PREFIXES.COMPONENT||r.name==="key"||r.name.startsWith("on"))&&r.value){const a=d.MUSTACHE_PATTERN.test(r.value),o=_.decodeEntities(r.value),c=d.MUSTACHE_PATTERN.test(o);(a||c)&&t.set(r.name,o)}}return t}createLoopItemBinding(e,t,i,n,r,a){const o=`loop_item_${Date.now()}_${Math.random()}`,c=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let l;if(c)if(c==="app")l="app";else if(c==="parent"){const N=e.getAttribute(d.ATTR_PREFIXES.COMPONENT)||r,k=this.findOriginalComponentName(N);l=this.findParentComponentForLoop(e,k)}else l=c;else l=this.findLoopParentComponent(e,r);const p=this.templateRenderer.dependencies(i,l,this.stateManager),h=new Set([...p,"*"]);let f=!1,g=0;const m=5,E=()=>{if(f)return;if(!document.contains(e)){if(g++,g<m){const k=10*Math.pow(2,g-1);setTimeout(()=>{f||E()},k)}else f=!0,this.stateManager.removeSubscription(o);return}g=0;try{const k=this.componentManager.buildComponentContext(l);let L;if(a){L={...k};let ie=null;for(const[Re,ye]of this.loopBindings)if(ye.renderedItems.includes(a)){ie=ye;break}ie&&(L[ie.itemVar]=a.context[ie.itemVar],ie.indexVar&&(L[ie.indexVar]=a.context[ie.indexVar]));for(const[Re,ye]of Object.entries(a.context))Re in L||(L[Re]=ye)}else L=n;const Me=this.templateRenderer.render(i,L,l);this.domBindingManager?.updateElementProperty(e,t,Me)}catch(k){console.error(`❌ Loop item binding evaluation error for "${i}":`,k),console.error("Available context keys:",Object.keys(n))}},y={id:o,selector:"",dependencies:h,callback:()=>{f||E()},element:e,component:l};if(this.stateManager.addSubscription(y),a){a.subscriptionIds.push(o);const N=this.cleanupLoopItem.bind(this);this.cleanupLoopItem=k=>{k===a&&(f=!0),N(k)}}(()=>{document.contains(e)?E():Promise.resolve().then(()=>{if(!f&&document.contains(e))E();else if(!f&&g<m){g++;const N=10*Math.pow(2,g-1);setTimeout(()=>{f||E()},N)}else!f&&g>=m&&(f=!0,this.stateManager.removeSubscription(o))})})()}findLoopParentComponent(e,t){for(const[i,n]of this.loopBindings)for(const r of n.renderedItems)if(r.element===e||r.element.contains(e))return n.component;return this.findOriginalComponentName(t)}findParentComponentForLoop(e,t){for(const[i,n]of this.loopBindings)for(const r of n.renderedItems)if(r.element===e||r.element.contains(e))return this.findParentComponent(n.component,i);return v.getParentComponentForElement(e)}findParentComponent(e,t){if(e==="app")return"app";let i=t.parentElement;for(;i;){if(i.getAttribute(d.ATTR_PREFIXES.COMPONENT)===e){let r=i.parentElement;for(;r;){const a=r.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(a)return a;r=r.parentElement}return"app"}i=i.parentElement}return"app"}findOriginalComponentName(e){return e.includes("_")&&/\d{13}/.test(e)?e.split("_")[0]:e}updateItemContext(e,t,i,n){const r=this.createItemContext(e,i,n),a=this.gatherAllComponentContextsInLoopItem(t.element),o={...r,...a};if(t.context=o,this.loopItemContexts.set(t.element,o),t.textNodeTemplates)for(const[c,l]of t.textNodeTemplates)document.contains(c)&&this.updateTextNodeWithContext(c,l,o,this.getTextNodeComponent(c));if(t.attributeTemplates)for(const[c,l]of t.attributeTemplates)document.contains(c)&&l.forEach((p,h)=>{try{const f=v.getElementComponent(c),g=this.buildElementSpecificContext(c,o),m=this.templateRenderer.render(p,g,f);this.domBindingManager?.updateElementProperty(c,h,m)}catch(f){console.error(`Attribute binding update error for "${p}":`,f)}})}gatherAllComponentContextsInLoopItem(e){if(!this.componentManager)return{};const t={};if(e.hasAttribute(d.ATTR_PREFIXES.COMPONENT)){const n=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),r=this.componentManager.buildComponentContext(n);Object.assign(t,r)}return e.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}]`).forEach(n=>{const r=n.getAttribute(d.ATTR_PREFIXES.COMPONENT),a=this.componentManager?.buildComponentContext(r);Object.assign(t,a)}),t}buildElementSpecificContext(e,t){if(!this.componentManager)return t;const i=v.getElementComponent(e),n=this.componentManager.buildComponentContext(i);return{...t,...n}}getTextNodeComponent(e){let t=e.parentElement;for(;t;){const i=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i)return i;t=t.parentElement}return"app"}updateDOMOrder(e,t){let i=e.placeholder;t.forEach(n=>{(n.element.parentElement!==e.parentElement||n.element!==i.nextSibling)&&e.parentElement.insertBefore(n.element,i.nextSibling),i=n.element})}clearRenderedItems(e){e.renderedItems.forEach(t=>{this.cleanupLoopItem(t)}),e.renderedItems=[]}cleanupLoopItem(e){this.loopItemElements.delete(e.element),this.loopItemContexts.delete(e.element),e.element.parentElement&&e.element.parentElement.removeChild(e.element),e.subscriptionIds.forEach(t=>{this.stateManager.removeSubscription(t)})}isLoopItem(e){return this.loopItemElements.has(e)}getLoopItemContext(e){return this.loopItemContexts.get(e)}cleanupDetachedTemplates(e){for(const t of e)t.type==="childList"&&t.removedNodes.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const n=i;n.tagName==="TEMPLATE"&&n.hasAttribute("pp-for")&&this.cleanupTemplate(n),n.querySelectorAll("template[pp-for]").forEach(a=>{this.cleanupTemplate(a)})}})}cleanupTemplate(e){const t=this.loopBindings.get(e);t&&(this.clearRenderedItems(t),t.subscriptionIds.forEach(i=>{this.stateManager.removeSubscription(i)}),t.placeholder.parentElement&&t.placeholder.parentElement.removeChild(t.placeholder),this.loopBindings.delete(e))}getAllLoops(){return new Map(this.loopBindings)}destroy(){this.cleanupObserver.disconnect(),this.templateMoveObserver.disconnect(),Array.from(this.loopBindings.keys()).forEach(e=>{this.cleanupTemplate(e)}),this.loopItemContexts=new WeakMap}}class W{cache=new Map;maxSize;hits=0;misses=0;constructor(e){this.maxSize=e}keys(){return Array.from(this.cache.keys())}deleteByPrefix(e){let t=0;const i=[];return this.cache.forEach((n,r)=>{typeof r=="string"&&r.startsWith(e)&&i.push(r)}),i.forEach(n=>{this.cache.delete(n)&&t++}),t}getKeysByPrefix(e){const t=[];return this.cache.forEach((i,n)=>{typeof n=="string"&&n.startsWith(e)&&t.push(n)}),t}get(e){const t=this.cache.get(e);if(t!==void 0)return this.hits++,this.cache.delete(e),this.cache.set(e,t),t;this.misses++}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){const i=this.cache.keys().next().value;i!==void 0&&this.cache.delete(i)}this.cache.set(e,t)}size(){return this.cache.size}has(e){return this.cache.has(e)}delete(e){return this.cache.delete(e)}clear(){this.cache.clear(),this.hits=0,this.misses=0}getStats(){const e=this.hits+this.misses;return{size:this.cache.size,maxSize:this.maxSize,hitRate:e>0?this.hits/e*100:0,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}}class _{static EXPRESSION_CACHE=new W(1e3);static parseSpreadDirective(e){const t=e.replace(/^\s*\{\s*|\s*\}\s*$/g,""),i=this.parseSpreadParts(t),n=[],r=[];for(const a of i){const o=a.trim();if(o.startsWith("..."))n.push(o.substring(3).trim());else if(o.startsWith("{")&&o.endsWith("}")){const c=o.slice(1,-1).trim();if(c){const l=this.parseObjectProperties(c);r.push(l)}}else console.warn(`Invalid spread directive part: "${o}". Expected ...spread or {object}`)}return{spreads:n,objects:r}}static parseSpreadParts(e){const t=[];let i="",n=0,r=!1,a="",o=0;for(;o<e.length;){const c=e[o],l=o>0?e[o-1]:"";if(!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&l!=="\\"&&(r=!1,a=""),!r){if(c==="{")n++;else if(c==="}")n--;else if(c===","&&n===0){t.push(i.trim()),i="",o++;continue}}i+=c,o++}return i.trim()&&t.push(i.trim()),t}static parseObjectProperties(e){const t=[],i=this.parseObjectParts(e);for(const n of i){const r=n.trim(),a=this.findPropertySeparator(r);if(a!==-1){const o=r.substring(0,a).trim().replace(/['"]/g,""),c=r.substring(a+1).trim();t.push({key:o,value:c})}else console.warn(`Invalid object property: "${r}". Expected key: value format.`)}return t}static parseObjectParts(e){const t=[];let i="",n=0,r=!1,a="";for(let o=0;o<e.length;o++){const c=e[o],l=o>0?e[o-1]:"";if(!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&l!=="\\"&&(r=!1,a=""),!r){if(c==="{"||c==="["||c==="(")n++;else if(c==="}"||c==="]"||c===")")n--;else if(c===","&&n===0){t.push(i.trim()),i="";continue}}i+=c}return i.trim()&&t.push(i.trim()),t}static findPropertySeparator(e){let t=0,i=!1,n="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!i&&(a==='"'||a==="'")?(i=!0,n=a):i&&a===n&&o!=="\\"&&(i=!1,n=""),!i){if(a==="{"||a==="["||a==="(")t++;else if(a==="}"||a==="]"||a===")")t--;else if(a===":"&&t===0)return r}}return-1}static decodeEntities=e=>{const t=document.createElement("textarea");t.innerHTML=e;let i=t.value;for(;i.includes("&");){t.innerHTML=i;const n=t.value;if(n===i)break;i=n}return i};static parse(e){const t=_.decodeEntities(e);if(_.EXPRESSION_CACHE.has(t))return _.EXPRESSION_CACHE.get(t);const i=_.parseContentWithNesting(t);return _.EXPRESSION_CACHE.set(t,i),i}static parseContentWithNesting(e){const t=[],i=e.length;let n=0,r=0;for(;n<i;)if(e[n]==="{"){n>r&&t.push({type:"static",content:e.substring(r,n),expression:null});const o=this.extractNestedExpression(e,n);o.endIndex!==-1?(t.push({type:"expression",content:e.substring(n,o.endIndex+1),expression:o.expression.trim()}),n=o.endIndex+1,r=n):n++}else n++;return r<i&&t.push({type:"static",content:e.substring(r),expression:null}),t}static extractNestedExpression(e,t){let i=1,n=t+1,r=!1,a="",o=!1;for(;n<e.length&&i>0;){const c=e[n],l=n>0?e[n-1]:"";!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&l!=="\\"&&(r=!1,a=""),!r&&c==="`"&&l!=="\\"&&(o=!o),!r&&!o&&(c==="{"?i++:c==="}"&&i--),n++}if(i===0){const c=e.slice(t+1,n-1);if(c.trim()){const l=this.checkForMismatchedQuotes(c);l.hasIssue&&(console.error(`
|
|
11
11
|
❌ Malformed expression detected during parsing:`),console.error(` Expression: ${c}`),console.error(` Issue: ${l.message}`),console.error(` Full content: ${e}`),console.error(` 💡 Hint: Check your quotes - strings must be properly quoted
|
|
12
12
|
`))}return{endIndex:n-1,expression:c}}return console.warn(`
|
|
13
|
-
⚠️ Failed to extract mustache expression - unclosed braces`),console.warn(` Content: ${e}`),console.warn(` Starting at position: ${
|
|
14
|
-
`),{endIndex:-1,expression:""}}static checkForMismatchedQuotes(e){let
|
|
13
|
+
⚠️ Failed to extract mustache expression - unclosed braces`),console.warn(` Content: ${e}`),console.warn(` Starting at position: ${t}
|
|
14
|
+
`),{endIndex:-1,expression:""}}static checkForMismatchedQuotes(e){let t=0,i=0,n=!1;for(let r=0;r<e.length;r++){if(n){n=!1;continue}if(e[r]==="\\"){n=!0;continue}e[r]==="'"&&t++,e[r]==='"'&&i++}return t%2!==0?{hasIssue:!0,message:`Unmatched single quotes (found ${t})`}:i%2!==0?{hasIssue:!0,message:`Unmatched double quotes (found ${i})`}:{hasIssue:!1,message:""}}static isSingleExpression(e){const t=_.decodeEntities(e),i=_.parseContentWithNesting(t);return i.length===1&&i[0].type==="expression"?i[0].expression:null}static extractExpressions(e){const t=_.decodeEntities(e),i=_.parseContentWithNesting(t),n=i.filter(r=>r.type==="expression").map(r=>r.expression).filter(r=>r);return i.some(r=>r.type==="expression")&&n.length===0&&(console.error(`
|
|
15
15
|
❌ Failed to extract expressions from content:`),console.error(` Content: ${e}`),console.error(` Parsed ${i.length} parts, but extracted 0 expressions`),console.error(` This usually means malformed mustache syntax
|
|
16
|
-
`)),n}}class Ps{textNodeBindings=new Map;expressionEvaluator;stateManager;componentManager;cleanupObserver;bindingCount=0;constructor(e,s){this.expressionEvaluator=e,this.stateManager=s,this.cleanupObserver=new MutationObserver(i=>{this.cleanupDetachedNodes(i)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}cleanupDetachedNodes(e){const s=[];for(const i of e)i.type==="childList"&&i.removedNodes.forEach(n=>{if(n.nodeType===Node.TEXT_NODE)s.push(n);else if(n.nodeType===Node.ELEMENT_NODE){const r=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null);let a;for(;a=r.nextNode();)s.push(a)}});Promise.resolve().then(()=>{s.forEach(i=>{document.contains(i)||this.cleanupTextNode(i)})})}processTextNode(e,s){if(this.textNodeBindings.has(e)||y.isTextNodeInsideScript(e)||this.isInsideLoopItem(e))return;const i=e.parentElement,n=i?y.getContextComponent(i):s,r=e.textContent||"",a=P.parse(r);if(!a.some(l=>l.type==="expression"))return;const c={originalContent:r,expressions:a,subscriptionIds:[]};a.filter(l=>l.type==="expression").forEach(l=>{if(!l.expression)return;const h=`text_${Date.now()}_${Math.random()}`,p=this.expressionEvaluator.extractDependencies(l.expression,n,this.stateManager),f={id:h,selector:"",dependencies:new Set(p),callback:()=>{this.updateTextNode(e)},element:e.parentElement??void 0,component:n};this.stateManager.addSubscription(f),c.subscriptionIds.push(h)}),this.textNodeBindings.set(e,c),this.bindingCount++,this.updateTextNode(e)}isInsideLoopItem(e){let s=e.parentElement;for(;s&&s!==document.body;){const i=s.previousSibling;if(i&&i.nodeType===Node.COMMENT_NODE&&i.textContent?.startsWith("pp-for:"))return!0;let n=s.parentElement?.firstChild||null;for(;n;){if(n.nodeType===Node.COMMENT_NODE&&n.textContent?.startsWith("pp-for:")&&n!==s)return!0;n=n.nextSibling}s=s.parentElement}return!1}updateTextNode(e){const s=this.textNodeBindings.get(e);if(!s||!e.parentElement)return;const i=e.parentElement,n=y.getContextComponent(i),r=this.resolveComponentRootForElement(e,n),a=this.getContextForComponent(n,r);let o="";for(const c of s.expressions)if(c.type==="static")o+=c.content;else if(c.expression)try{const l=this.expressionEvaluator.evaluateExpression(c.expression,a,n);o+=ie(l)}catch(l){const h=typeof l=="object"&&l!==null&&"message"in l?l.message:String(l);console.warn(`Text binding evaluation warning for "${c.expression}": ${h}`),o+=""}e.textContent!==o&&(e.textContent=o)}resolveComponentRootForElement(e,s){let i=e.parentElement;for(;i&&i.nodeType===Node.ELEMENT_NODE;){const n=i;if(n.getAttribute(d.ATTR_PREFIXES.COMPONENT)===s)return n;i=i.parentElement}}getContextForComponent(e,s){return this.componentManager?this.componentManager.buildComponentContextWithProps(e,s):{}}cleanupTextNode(e){const s=this.textNodeBindings.get(e);s&&(s.subscriptionIds.forEach(i=>{this.stateManager.removeSubscription(i)}),this.textNodeBindings.delete(e),this.bindingCount=Math.max(0,this.bindingCount-1))}getBindingCount(){return this.textNodeBindings.size}getAllBindings(){return new Map(this.textNodeBindings)}clearAllBindings(){for(const[e]of this.textNodeBindings)this.cleanupTextNode(e)}destroy(){this.cleanupObserver.disconnect(),this.clearAllBindings()}}class ks{listeners=new Map;on(e,s){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(s),()=>this.off(e,s)}off(e,s){this.listeners.get(e)?.delete(s)}emit(e,...s){const i=this.listeners.get(e);i&&i.forEach(n=>{try{n(...s)}catch(r){console.error(`Event listener error for ${e}:`,r)}})}}class Is{stateStore={};subscriptions=new Map;updateQueue=new Set;isUpdating=!1;eventBus=new ks;contextCache=new Map;previousValues=new Map;_subscriptionManager=new Ts;originalStateStore={};domUpdateCallbacks=[];domUpdateScheduled=!1;constructor(){this.setupGlobalStateProxy(),setInterval(()=>{this.subscriptionManager.cleanupStaleSubscriptions()},3e4)}clearSubscriptions(){const e=this._subscriptionManager.getAllSubscriptions();for(const[s]of e)this._subscriptionManager.removeSubscription(s);this.updateQueue.clear()}clearComponentSubscriptions(e){const s=this._subscriptionManager.getAllSubscriptions();for(const[i,n]of s)n.component===e&&this._subscriptionManager.removeSubscription(i)}clearState(){Object.keys(this.stateStore).forEach(e=>{delete this.stateStore[e],delete this.originalStateStore[e]}),this.previousValues.clear(),this.updateQueue.clear(),this.contextCache.clear()}clearComponentState(e){Object.keys(this.stateStore).filter(i=>i.startsWith(`${e}.`)).forEach(i=>{delete this.stateStore[i],delete this.originalStateStore[i],this.previousValues.delete(i)})}onDOMUpdateComplete(e){this.domUpdateCallbacks.push(e),this.domUpdateScheduled||(this.domUpdateScheduled=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{const s=[...this.domUpdateCallbacks];this.domUpdateCallbacks=[],this.domUpdateScheduled=!1,s.forEach(i=>{try{i()}catch(n){console.error("DOM update callback error:",n)}})})}))}setInitialState(e,s){if(this.previousValues.set(e,void 0),this.originalStateStore[e]=s,this.previousValues.size>100){const i=this.previousValues.keys().next().value;typeof i=="string"&&this.previousValues.delete(i)}}get subscriptionManager(){return this._subscriptionManager}batchStateUpdates(e){const s=this.isUpdating;this.isUpdating=!0;try{return e()}finally{this.isUpdating=s,!this.isUpdating&&this.updateQueue.size>0&&this.scheduleFlush()}}invalidateContextCache(){this.contextCache.clear()}setupGlobalStateProxy(){this.originalStateStore=this.stateStore,this.stateStore=new Proxy(this.stateStore,{set:(e,s,i,n)=>{const r=e[s],a=Reflect.set(e,s,i,n);return r!==i&&this.notifySubscribers(s),a},get:(e,s)=>Reflect.get(e,s)})}notifySubscribers(e){if(this.eventBus.emit("stateChanged",e),this.updateQueue.add(e),e.includes(".")){const s=e.split(".")[0];this.updateQueue.add(s)}this.notifyPathBasedSubscribers(e),this.isUpdating||this.scheduleFlush()}notifyPathBasedSubscribers(e){const s=this.stateStore[e],i=this.previousValues?.get(e);for(const[n,r]of this.subscriptions)for(const a of r.dependencies)if(this.isPathDependency(a)&&a.startsWith(e+".")){const o=a.substring(e.length+1),c=this.getPathValue(i,o),l=this.getPathValue(s,o);this.deepEqual(c,l)||this.updateQueue.add(a)}}isPathDependency(e){return e.includes(".")&&e.split(".").length>1}getPathValue(e,s){if(!e||typeof e!="object")return;const i=s.split(".");let n=e;for(const r of i){if(n==null)return;if(Array.isArray(n))return r==="length"?n.length:n.map(a=>a?.[r]).filter(a=>a!==void 0);n=n[r]}return n}deepEqual(e,s){if(e===s)return!0;if(e==null||s==null)return!1;if(Array.isArray(e)&&Array.isArray(s))return e.length!==s.length?!1:e.every((i,n)=>this.deepEqual(i,s[n]));if(typeof e=="object"&&typeof s=="object"){const i=Object.keys(e),n=Object.keys(s);return i.length!==n.length?!1:i.every(r=>this.deepEqual(e[r],s[r]))}return!1}scheduleFlush=As(()=>{this.flushUpdates()},d.DEBOUNCE_MS);flushUpdates(){if(!this.isUpdating){this.isUpdating=!0;try{const e=new Set,s=this.subscriptionManager.getSubscriptionsForKey("*");if(s&&s.size>0&&this.updateQueue.size>0)for(const i of s){const n=this.subscriptionManager.getSubscription(i);if(!n)continue;if(n.element&&!document.contains(n.element)){this.subscriptionManager.removeSubscription(i);continue}const r=n.element??document.body;try{const a=Array.from(this.updateQueue)[0];n.callback(r,{key:a})}catch(a){console.error("Wildcard subscription callback failed:",a)}}for(const i of this.updateQueue){if(e.has(i))continue;e.add(i);const n=this.subscriptionManager.getSubscriptionsForKey(i);if(n)for(const r of n){const a=this.subscriptionManager.getSubscription(r);if(!a)continue;if(a.element&&!document.contains(a.element)){this.subscriptionManager.removeSubscription(r);continue}const o=a.element??document.body;try{a.callback(o,{key:i})}catch(c){console.error("Subscription callback failed:",c)}}}}finally{this.updateQueue.clear(),this.isUpdating=!1}}}getState(){return this.stateStore}setState(e,s){if(this.previousValues.set(e,this.stateStore[e]),this.stateStore[e]=s,this.previousValues.size>100){const i=this.previousValues.keys().next().value;typeof i=="string"&&this.previousValues.delete(i)}}hasState(e){return e in this.originalStateStore}addSubscription(e){this._subscriptionManager.addSubscription(e)}removeSubscription(e){this._subscriptionManager.removeSubscription(e)}onStateChange(e){return this.eventBus.on("stateChanged",e)}batch(e){const s=this.isUpdating;this.isUpdating=!0;try{return e()}finally{this.isUpdating=s,!this.isUpdating&&this.updateQueue.size&&this.flushUpdates()}}getSubscriptions(){return this.subscriptionManager.getAllSubscriptions()}getKeyIndex(){const e=new Map,s=this.subscriptionManager.getAllSubscriptions();for(const[i,n]of s)for(const r of n.dependencies)e.has(r)||e.set(r,new Set),e.get(r).add(i);return e}}class ce{expressionCache=new $(d.MAX_CACHE_SIZE);dependencyCache=new $(d.MAX_CACHE_SIZE);commonExpressionsCache=new $(100);dependencyParser=new Ns;static CACHE_KEYS={EXPRESSION:(e,s)=>`expr:${e}:${s}`,DEPENDENCY:(e,s)=>`deps:${e}:${s}`,COMMON:e=>`common:${e}`};constructor(){this.precompileCommonExpressions()}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}precompileCommonExpressions(){["true","false","null","undefined"].forEach(s=>{const i={fn:new Function("return "+s),contextMap:new Map,dependencies:[s],timestamp:Date.now(),hitCount:0},n=ce.CACHE_KEYS.COMMON(s);this.commonExpressionsCache.set(n,i)})}extractDependencies(e,s,i){const n=this.normalizeExpression(e),r=ce.CACHE_KEYS.DEPENDENCY(s,n);let a=this.dependencyCache.get(r);return a||(a=this.dependencyParser.extract(n,s,i),this.dependencyCache.set(r,a),a)}evaluateExpression(e,s,i){const n=this.normalizeExpression(e),r=ce.CACHE_KEYS.COMMON(n);let a=this.commonExpressionsCache.get(r);if(a){a.hitCount++;try{return a.fn()}catch(c){console.error(`Common expression evaluation failed: "${n}"`,c);return}}const o=ce.CACHE_KEYS.EXPRESSION(i,n);a=this.expressionCache.get(o),(!a||this.isStale(a))&&(a=this.compileExpression(n,s,i),this.expressionCache.set(o,a)),a.hitCount++;try{const c=this.buildArguments(a.contextMap,s);return a.fn(...c)}catch(c){console.error(`Expression evaluation failed: "${n}"`,c),console.error("Available context:",Object.keys(s));return}}compileExpression(e,s,i){const n=this.prepareSafeContext(s),r=new Map,a=[];Object.keys(n).forEach((c,l)=>{r.set(c,l),a.push(c)});const o=this.dependencyParser.extract(e,i);return{fn:new Function(...a,`return (${e})`),contextMap:r,dependencies:o,timestamp:Date.now(),hitCount:0}}buildArguments(e,s){const i=new Array(e.size);for(const[n,r]of e)i[r]=s[n];return i}isStale(e){return Date.now()-e.timestamp>3e5}prepareSafeContext(e){const s={};for(const[i,n]of Object.entries(e))xe.has(i)||!this.isValidJavaScriptIdentifier(i)||(s[i]=n);return s}isValidJavaScriptIdentifier(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!xe.has(e)}invalidateCache(e){switch(e){case"expressions":this.expressionCache.clear();break;case"dependencies":this.dependencyCache.clear();break;case"common":this.commonExpressionsCache.clear(),this.precompileCommonExpressions();break;case"parser":this.dependencyParser.clearCache();break;default:this.clearAllCaches()}}invalidateByComponent(e){this.expressionCache.deleteByPrefix(`expr:${e}:`),this.dependencyCache.deleteByPrefix(`deps:${e}:`)}clearAllCaches(){this.expressionCache.clear(),this.dependencyCache.clear(),this.commonExpressionsCache.clear(),this.dependencyParser.clearCache(),this.precompileCommonExpressions()}getCacheStats(){return{expressions:this.expressionCache.getStats(),dependencies:this.dependencyCache.getStats(),commonExpressions:this.commonExpressionsCache.getStats(),dependencyParser:this.getDependencyParserStats()}}getDependencyParserStats(){return this.dependencyParser.getCacheSize?{size:this.dependencyParser.getCacheSize(),maxSize:500,hitRate:0,hits:0,misses:0}:{size:0,maxSize:0,hitRate:0,hits:0,misses:0}}cleanupStaleExpressions(){let e=0;return this.expressionCache.keys().forEach(i=>{const n=this.expressionCache.get(i);n&&this.isStale(n)&&(this.expressionCache.delete(i),e++)}),e}}class Ns{parseCache=new $(500);extract(e,s,i){const n=this.normalizeExpression(e),r=`${s}:${n}`;if(this.parseCache.has(r))return this.parseCache.get(r);const a=this.parseExpression(n,s,i);return this.parseCache.set(r,a),a}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}parseExpression(e,s,i){const n=this.extractIdentifiers(e),r=[],a=i?.getState()||{};for(const c of n){if(xe.has(c))continue;const l=c.indexOf("."),h=l===-1?c:c.substring(0,l),p=Be.findExistingStateKey(h,s,a);if(p)r.push(p);else{const f=s==="app"?[`app.${h}`]:[`${s}.${h}`,`app.${h}`];r.push(...f)}if(l!==-1){const f=s==="app"?[`app.${h}`]:[`${s}.${h}`,`app.${h}`];r.push(...f)}}return Array.from(new Set(r))}extractIdentifiers(e){const s=[];let i=0;for(;i<e.length;){const n=e[i];if(n==="'"){i=this.skipString(e,i,"'");continue}if(n==='"'){i=this.skipString(e,i,'"');continue}if(n==="`"){i=this.skipTemplateLiteral(e,i,s);continue}if(this.isIdentifierStart(n)){const r=this.extractIdentifier(e,i);s.push(r.value),i=r.endIndex;continue}i++}return s}skipString(e,s,i){let n=s+1;for(;n<e.length&&e[n]!==i;)e[n]==="\\"&&n++,n++;return n+1}skipTemplateLiteral(e,s,i){let n=s+1;for(;n<e.length&&e[n]!=="`";){if(e[n]==="$"&&n+1<e.length&&e[n+1]==="{"){n+=2;let r=1;for(;n<e.length&&r>0;){const a=e[n];if(a==='"'||a==="'"){n=this.skipString(e,n,a);continue}if(a==="{"?r++:a==="}"&&r--,r>0&&this.isIdentifierStart(a)){const o=this.extractIdentifier(e,n);i.push(o.value),n=o.endIndex-1}n++}continue}e[n]==="\\"&&n++,n++}return n+1}extractIdentifier(e,s){let i=s;for(;i<e.length&&(this.isIdentifierPart(e[i])||e[i]===".");)i++;return{value:e.substring(s,i),endIndex:i}}isIdentifierStart(e){return/[a-zA-Z_$]/.test(e)}isIdentifierPart(e){return/[a-zA-Z0-9_$]/.test(e)}clearCache(){this.parseCache.clear()}getCacheSize(){return this.parseCache.cache.size}}class Ms{componentStack=["app"];elementProps=new WeakMap;contextCache=new $(100);contextIndex=new Map;contextInvalidated=new Set;stateManager;processedScripts=new WeakSet;componentFunctions=new Map;expressionEvaluator;domBindingManager;loopManager;templateRenderer;updateTimeouts;updateBatcher=new et;propDependencyCache=new Map;constructor(e){this.stateManager=e,this.updateBatcher=new et,this.stateManager.onStateChange(s=>this.invalidateContextCache(s))}getPropDependencies(e,s){const i=this.findElementWithProps(s);if(!i)return[];const n=this.elementProps.get(i);if(!n||!n.has(e))return[];const r=n.get(e);return this.templateRenderer?.dependencies(r.expression,r.component,this.stateManager)||[]}buildRestrictedComponentContext(e,s=!1){const i={};window[e]&&Object.assign(i,window[e]);const n=this.componentFunctions.get(e);if(n)for(const[a,o]of n)i[a]=o;const r=this.stateManager.getState();for(const a of Object.keys(r))if(a.startsWith(e+".")){const o=a.substring(e.length+1);o in i||(i[o]=r[a])}if(s){if(window.app)for(const[o,c]of Object.entries(window.app))o in i||(i[o]=c);const a=this.componentFunctions.get("app");if(a)for(const[o,c]of a)o in i||(i[o]=c);for(const o of Object.keys(r))if(o.startsWith("app.")){const c=o.substring(4);c in i||(i[c]=r[o])}}return i}getComponentPropDependencies(e,s){if(this.propDependencyCache.has(e))return this.propDependencyCache.get(e);const i=[],n=this.elementProps.get(e);n&&this.templateRenderer&&n.forEach(a=>{const o=this.templateRenderer?.dependencies(a.expression,a.component,this.stateManager);i.push(...o??[])});const r=Array.from(new Set(i));return this.propDependencyCache.set(e,r),r}setDOMBindingManager(e){this.domBindingManager=e,this.updateBatcher.setManagers(this,e)}hasStoredProps(e){return this.elementProps.has(e)&&this.elementProps.get(e).size>0}setExpressionEvaluator(e){this.expressionEvaluator=e,this.templateRenderer=new Ke(e),this.loopManager=new Ft(this.stateManager,e)}extractProps(e,s){const i=new Map,n=e.attributes,r=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);let o=s;r&&(r==="app"?o="app":r==="parent"?o=y.getParentOfComponent(a||"app",e):o=r);for(let c=0;c<n.length;c++){const l=n[c];if(!(l.name===d.ATTR_PREFIXES.COMPONENT||l.name===d.ATTR_PREFIXES.CONTEXT||l.name===d.ATTR_PREFIXES.SPREAD||l.name===d.ATTR_PREFIXES.LOOP)&&!oe.isEventAttribute(l.name)&&l.value&&_s.containsMustacheExpression(l.value)){if(a&&this.mightReferenceSelfProps(l.value,e))continue;const h=this.attributeToPropName(l.name),p={name:h,expression:l.value,component:o,subscriptionIds:[]};i.set(h,p)}}return i}mightReferenceSelfProps(e,s){const i=this.elementProps.get(s);return i?Array.from(i.keys()).some(r=>e.includes(r)&&r!=="dataState"):!1}attributeToPropName(e){return e.replace(/-([a-z])/g,(s,i)=>i.toUpperCase())}setupProps(e,s){const i=this.extractProps(e,s);i.size!==0&&(this.elementProps.set(e,i),this.expressionEvaluator&&i.forEach((n,r)=>{this.setupPropBinding(e,n)}))}setupPropBinding(e,s){if(!this.expressionEvaluator)return;const i=`prop_${Date.now()}_${Math.random()}`,n=this.templateRenderer?.dependencies(s.expression,s.component,this.stateManager)||[],r={id:i,selector:"",dependencies:new Set(n),callback:()=>{const a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);a&&(this.updateBatcher.scheduleUpdate(a,e),this.refreshComponentBindings(e,a))},element:e,component:s.component};this.stateManager.addSubscription(r),s.subscriptionIds.push(i)}refreshComponentBindings(e,s){this.contextInvalidated.add(s),this.contextCache.delete(s),this.domBindingManager&&this.domBindingManager.refreshComponentElement(e,s)}evaluateProps(e){const s={},i=this.elementProps.get(e);if(!i||!this.expressionEvaluator)return s;const n=i.values().next().value;if(!n)return s;const r=this.buildComponentContext(n.component);return i.forEach((a,o)=>{try{const c=this.templateRenderer?.render(a.expression,r,a.component);typeof c=="function"?s[o]=(...l)=>c.apply(this,l):s[o]=c}catch(c){console.error(`❌ Failed to evaluate prop "${o}":`,c),s[o]=void 0}}),s}cleanupProps(e){const s=this.elementProps.get(e);s&&(s.forEach(i=>{i.subscriptionIds.forEach(n=>{this.stateManager.removeSubscription(n)})}),this.elementProps.delete(e))}buildComponentContextWithProps(e,s){const i=this.buildComponentContext(e);let n=this.findElementWithProps(e);if(s&&this.elementProps.has(s)&&(n=s),n)try{const r=this.evaluatePropsWithContext(n,e,s);Object.keys(r).length>0&&Object.keys(r).forEach(a=>{i[a]=r[a]})}catch(r){console.error(`❌ Error evaluating props for ${e}:`,r)}return i}evaluatePropsWithContext(e,s,i){const n={},r=this.elementProps.get(e);if(!r||!this.expressionEvaluator)return n;const a=r.values().next().value;if(!a)return n;let o;const c=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),l=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(c)if(c==="app")o=this.buildComponentContext("app");else if(c==="parent"){const C=y.getParentOfComponent(l||"app",e);o=this.buildComponentContext(C)}else o=this.buildComponentContext(c);else o=this.buildComponentContext(a.component);const h=this.loopManager?.getLoopContextForElement(e);h&&(o={...o,...h});const p=new Map,f=new Map,m=Array.from(r.keys());r.forEach((C,v)=>{m.some(I=>I!==v&&C.expression.includes(I))?f.set(v,C):p.set(v,C)}),p.forEach((C,v)=>{try{const A=this.templateRenderer?.render(C.expression,o,c||C.component);typeof A=="function"?this.isFunctionExplicitlyPassed(C.expression)?n[v]=(...fe)=>A.apply(this,fe):(console.warn(`⚠️ Function "${v}" not passed - not from shared namespace or explicitly passed`),n[v]=void 0):n[v]=A}catch(A){console.error(`❌ Failed to evaluate simple prop "${v}":`,A),console.error("Expression:",C.expression),console.error("Available context keys:",Object.keys(o)),n[v]=void 0}});const x={...o,...n};return f.forEach((C,v)=>{try{const A=this.templateRenderer?.render(C.expression,x,c||C.component);typeof A=="function"?this.isFunctionExplicitlyPassed(C.expression)?n[v]=(...fe)=>A.apply(this,fe):(console.warn(`⚠️ Function "${v}" not passed - not from shared namespace or explicitly passed`),n[v]=void 0):n[v]=A}catch(A){console.error(`❌ Failed to evaluate complex prop "${v}":`,A),console.error("Expression:",C.expression),console.error("Available context keys:",Object.keys(x)),n[v]=void 0}}),n}isFunctionExplicitlyPassed(e){const s=P.isSingleExpression(e);return s?/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(s.trim()):!1}findElementWithProps(e){const s=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e}"]`);for(const i of s){const n=this.elementProps.get(i);if(n&&n.size>0)return i}return null}pushComponent(e){this.componentStack.push(e)}popComponent(){return this.componentStack.pop()}getCurrentComponent(){return this.componentStack[this.componentStack.length-1]}buildComponentContext(e){if(!this.contextInvalidated.has(e)&&this.contextCache.has(e))return this.contextCache.get(e);const s=this.computeComponentContext(e);return this.contextCache.set(e,s),this.contextInvalidated.delete(e),s}computeComponentContext(e){const s={};e!=="app"&&window[e]&&Object.assign(s,window[e]),e==="app"&&window.app&&Object.assign(s,window.app);const i=this.componentFunctions.get(e);if(i)for(const[r,a]of i)s[r]=a;if(e!=="app"){const r=this.componentFunctions.get("app");if(r)for(const[a,o]of r)a in s||(s[a]=o);if(window.app)for(const[a,o]of Object.entries(window.app))a in s||(s[a]=o)}const n=this.stateManager.getState();for(const r of Object.keys(n))if(r.startsWith(e+".")){const a=r.substring(e.length+1);a in s||(s[a]=n[r])}if(e!=="app"){for(const r of Object.keys(n))if(r.startsWith("app.")){const a=r.substring(4);a in s||(s[a]=n[r])}}return s}invalidateContextCache(e){if(e.startsWith("app.")){this.contextCache.clear();for(const i of this.contextInvalidated.keys())this.contextInvalidated.add(i);return}const s=e.indexOf(".");if(s!==-1){const i=e.slice(0,s);this.invalidateComponent(i)}}invalidateComponent(e){this.contextInvalidated.add(e),this.contextIndex.delete(e)}executePhpScripts(e){const s=this.componentStack.length,i=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),n=e===document.body;if(i||n){if(i){this.pushComponent(i);const a=this.getParentComponent(e);this.setupProps(e,a)}this.getRelevantScripts(e,n).forEach(a=>{const o=a.getAttribute(d.ATTR_PREFIXES.COMPONENT);o&&o!==i?(this.pushComponent(o),this.executeScript(a),this.popComponent()):this.executeScript(a)})}for(Array.from(e.children).forEach(r=>this.executePhpScripts(r));this.componentStack.length>s;)this.popComponent()}getParentComponent(e){let s=e.parentElement;for(;s;){const i=s.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i)return i;s=s.parentElement}return"app"}getRelevantScripts(e,s){return Array.from(e.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`)).filter(i=>{if(this.processedScripts.has(i))return!1;if(s)return i.hasAttribute(d.ATTR_PREFIXES.COMPONENT)?!0:!i.closest(`[${d.ATTR_PREFIXES.COMPONENT}]`);let n=i.parentElement;for(;n&&n!==e;){if(n.hasAttribute(d.ATTR_PREFIXES.COMPONENT))return!1;n=n.parentElement}return n===e||e.contains(i)})}executeScript(e){if(this.processedScripts.has(e))return;this.processedScripts.add(e);const s=this.getCurrentComponent(),i=e.textContent||"",n=P.decodeEntities(i);try{const r=this.findComponentElementForScript(e,s);if(r===e){const o=this.getParentComponent(e);this.setupProps(e,o)}const a=this.buildComponentContextWithProps(s,r);window[s]||(window[s]={}),this.executeScriptFunctions(n,s,a)}catch(r){console.error(`Script execution failed in component ${s}:`,r),console.error("Script content:",n)}}findComponentElementForScript(e,s){if(e.getAttribute(d.ATTR_PREFIXES.COMPONENT)===s)return e;let i=e.parentElement;for(;i;){if(i.getAttribute(d.ATTR_PREFIXES.COMPONENT)===s)return i;i=i.parentElement}const n=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${s}"]`);for(const r of n)if(this.elementProps.has(r))return r;return n[0]||void 0}executeScriptFunctions(e,s,i){const n=this.extractFunctionNames(e),r=this.findElementWithProps(s),a=this.extractVariableDeclarations(e);let o={...i};if(a.forEach(x=>{delete o[x];const C=`set${Vt(x)}`,v=`${x}Getter`;delete o[C],delete o[v]}),r){const x=this.evaluateProps(r);Object.assign(o,x)}o.getContext=()=>this.buildComponentContextWithProps(s),o.withContext=x=>{const C=this.buildComponentContextWithProps(s);return x.call(C,C)},o.__getProp=x=>{if(r)return this.evaluateProps(r)[x]};let l=q.getInstance().transformStateDeclarations(e);l=this.modifyScriptForReactiveProps(l,s,r||void 0);const h=`
|
|
16
|
+
`)),n}}class ks{textNodeBindings=new Map;expressionEvaluator;stateManager;componentManager;cleanupObserver;bindingCount=0;constructor(e,t){this.expressionEvaluator=e,this.stateManager=t,this.cleanupObserver=new MutationObserver(i=>{this.cleanupDetachedNodes(i)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}cleanupDetachedNodes(e){const t=[];for(const i of e)i.type==="childList"&&i.removedNodes.forEach(n=>{if(n.nodeType===Node.TEXT_NODE)t.push(n);else if(n.nodeType===Node.ELEMENT_NODE){const r=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null);let a;for(;a=r.nextNode();)t.push(a)}});Promise.resolve().then(()=>{t.forEach(i=>{document.contains(i)||this.cleanupTextNode(i)})})}processTextNode(e,t){if(this.textNodeBindings.has(e)||v.isTextNodeInsideScript(e)||this.isInsideLoopItem(e))return;const i=e.parentElement,n=i?v.getContextComponent(i):t,r=e.textContent||"",a=_.parse(r);if(!a.some(l=>l.type==="expression"))return;const c={originalContent:r,expressions:a,subscriptionIds:[]};a.filter(l=>l.type==="expression").forEach(l=>{if(!l.expression)return;const p=`text_${Date.now()}_${Math.random()}`,h=this.expressionEvaluator.extractDependencies(l.expression,n,this.stateManager),f={id:p,selector:"",dependencies:new Set(h),callback:()=>{this.updateTextNode(e)},element:e.parentElement??void 0,component:n};this.stateManager.addSubscription(f),c.subscriptionIds.push(p)}),this.textNodeBindings.set(e,c),this.bindingCount++,this.updateTextNode(e)}isInsideLoopItem(e){let t=e.parentElement;for(;t&&t!==document.body;){const i=t.previousSibling;if(i&&i.nodeType===Node.COMMENT_NODE&&i.textContent?.startsWith("pp-for:"))return!0;let n=t.parentElement?.firstChild||null;for(;n;){if(n.nodeType===Node.COMMENT_NODE&&n.textContent?.startsWith("pp-for:")&&n!==t)return!0;n=n.nextSibling}t=t.parentElement}return!1}updateTextNode(e){const t=this.textNodeBindings.get(e);if(!t||!e.parentElement)return;const i=e.parentElement,n=v.getContextComponent(i),r=this.resolveComponentRootForElement(e,n),a=this.getContextForComponent(n,r);let o="";for(const c of t.expressions)if(c.type==="static")o+=c.content;else if(c.expression)try{const l=this.expressionEvaluator.evaluateExpression(c.expression,a,n);o+=re(l)}catch(l){const p=typeof l=="object"&&l!==null&&"message"in l?l.message:String(l);console.warn(`Text binding evaluation warning for "${c.expression}": ${p}`),o+=""}e.textContent!==o&&(e.textContent=o)}resolveComponentRootForElement(e,t){let i=e.parentElement;for(;i&&i.nodeType===Node.ELEMENT_NODE;){const n=i;if(n.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return n;i=i.parentElement}}getContextForComponent(e,t){return this.componentManager?this.componentManager.buildComponentContextWithProps(e,t):{}}cleanupTextNode(e){const t=this.textNodeBindings.get(e);t&&(t.subscriptionIds.forEach(i=>{this.stateManager.removeSubscription(i)}),this.textNodeBindings.delete(e),this.bindingCount=Math.max(0,this.bindingCount-1))}getBindingCount(){return this.textNodeBindings.size}getAllBindings(){return new Map(this.textNodeBindings)}clearAllBindings(){for(const[e]of this.textNodeBindings)this.cleanupTextNode(e)}destroy(){this.cleanupObserver.disconnect(),this.clearAllBindings()}}class Is{listeners=new Map;on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>this.off(e,t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,...t){const i=this.listeners.get(e);i&&i.forEach(n=>{try{n(...t)}catch(r){console.error(`Event listener error for ${e}:`,r)}})}}class Ms{stateStore={};subscriptions=new Map;updateQueue=new Set;isUpdating=!1;eventBus=new Is;contextCache=new Map;previousValues=new Map;_subscriptionManager=new _s;originalStateStore={};domUpdateCallbacks=[];domUpdateScheduled=!1;constructor(){this.setupGlobalStateProxy(),setInterval(()=>{this.subscriptionManager.cleanupStaleSubscriptions()},3e4)}clearSubscriptions(){const e=this._subscriptionManager.getAllSubscriptions();for(const[t]of e)this._subscriptionManager.removeSubscription(t);this.updateQueue.clear()}clearComponentSubscriptions(e){const t=this._subscriptionManager.getAllSubscriptions();for(const[i,n]of t)n.component===e&&this._subscriptionManager.removeSubscription(i)}clearState(){Object.keys(this.stateStore).forEach(e=>{delete this.stateStore[e],delete this.originalStateStore[e]}),this.previousValues.clear(),this.updateQueue.clear(),this.contextCache.clear()}clearComponentState(e){Object.keys(this.stateStore).filter(i=>i.startsWith(`${e}.`)).forEach(i=>{delete this.stateStore[i],delete this.originalStateStore[i],this.previousValues.delete(i)})}onDOMUpdateComplete(e){this.domUpdateCallbacks.push(e),this.domUpdateScheduled||(this.domUpdateScheduled=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=[...this.domUpdateCallbacks];this.domUpdateCallbacks=[],this.domUpdateScheduled=!1,t.forEach(i=>{try{i()}catch(n){console.error("DOM update callback error:",n)}})})}))}setInitialState(e,t){if(this.previousValues.set(e,void 0),this.originalStateStore[e]=t,this.previousValues.size>100){const i=this.previousValues.keys().next().value;typeof i=="string"&&this.previousValues.delete(i)}}get subscriptionManager(){return this._subscriptionManager}batchStateUpdates(e){const t=this.isUpdating;this.isUpdating=!0;try{return e()}finally{this.isUpdating=t,!this.isUpdating&&this.updateQueue.size>0&&this.scheduleFlush()}}invalidateContextCache(){this.contextCache.clear()}setupGlobalStateProxy(){this.originalStateStore=this.stateStore,this.stateStore=new Proxy(this.stateStore,{set:(e,t,i,n)=>{const r=e[t],a=Reflect.set(e,t,i,n);return r!==i&&this.notifySubscribers(t),a},get:(e,t)=>Reflect.get(e,t)})}notifySubscribers(e){if(this.eventBus.emit("stateChanged",e),this.updateQueue.add(e),e.includes(".")){const t=e.split(".")[0];this.updateQueue.add(t)}this.notifyPathBasedSubscribers(e),this.isUpdating||this.scheduleFlush()}notifyPathBasedSubscribers(e){const t=this.stateStore[e],i=this.previousValues?.get(e);for(const[n,r]of this.subscriptions)for(const a of r.dependencies)if(this.isPathDependency(a)&&a.startsWith(e+".")){const o=a.substring(e.length+1),c=this.getPathValue(i,o),l=this.getPathValue(t,o);this.deepEqual(c,l)||this.updateQueue.add(a)}}isPathDependency(e){return e.includes(".")&&e.split(".").length>1}getPathValue(e,t){if(!e||typeof e!="object")return;const i=t.split(".");let n=e;for(const r of i){if(n==null)return;if(Array.isArray(n))return r==="length"?n.length:n.map(a=>a?.[r]).filter(a=>a!==void 0);n=n[r]}return n}deepEqual(e,t){if(e===t)return!0;if(e==null||t==null)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((i,n)=>this.deepEqual(i,t[n]));if(typeof e=="object"&&typeof t=="object"){const i=Object.keys(e),n=Object.keys(t);return i.length!==n.length?!1:i.every(r=>this.deepEqual(e[r],t[r]))}return!1}scheduleFlush=ws(()=>{this.flushUpdates()},d.DEBOUNCE_MS);flushUpdates(){if(!this.isUpdating){this.isUpdating=!0;try{const e=new Set,t=this.subscriptionManager.getSubscriptionsForKey("*");if(t&&t.size>0&&this.updateQueue.size>0)for(const i of t){const n=this.subscriptionManager.getSubscription(i);if(!n)continue;if(n.element&&!document.contains(n.element)){this.subscriptionManager.removeSubscription(i);continue}const r=n.element??document.body;try{const a=Array.from(this.updateQueue)[0];n.callback(r,{key:a})}catch(a){console.error("Wildcard subscription callback failed:",a)}}for(const i of this.updateQueue){if(e.has(i))continue;e.add(i);const n=this.subscriptionManager.getSubscriptionsForKey(i);if(n)for(const r of n){const a=this.subscriptionManager.getSubscription(r);if(!a)continue;if(a.element&&!document.contains(a.element)){this.subscriptionManager.removeSubscription(r);continue}const o=a.element??document.body;try{a.callback(o,{key:i})}catch(c){console.error("Subscription callback failed:",c)}}}}finally{this.updateQueue.clear(),this.isUpdating=!1}}}getState(){return this.stateStore}setState(e,t){if(this.previousValues.set(e,this.stateStore[e]),this.stateStore[e]=t,this.previousValues.size>100){const i=this.previousValues.keys().next().value;typeof i=="string"&&this.previousValues.delete(i)}}hasState(e){return e in this.originalStateStore}addSubscription(e){this._subscriptionManager.addSubscription(e)}removeSubscription(e){this._subscriptionManager.removeSubscription(e)}onStateChange(e){return this.eventBus.on("stateChanged",e)}batch(e){const t=this.isUpdating;this.isUpdating=!0;try{return e()}finally{this.isUpdating=t,!this.isUpdating&&this.updateQueue.size&&this.flushUpdates()}}getSubscriptions(){return this.subscriptionManager.getAllSubscriptions()}getKeyIndex(){const e=new Map,t=this.subscriptionManager.getAllSubscriptions();for(const[i,n]of t)for(const r of n.dependencies)e.has(r)||e.set(r,new Set),e.get(r).add(i);return e}}class le{expressionCache=new W(d.MAX_CACHE_SIZE);dependencyCache=new W(d.MAX_CACHE_SIZE);commonExpressionsCache=new W(100);dependencyParser=new Rs;static CACHE_KEYS={EXPRESSION:(e,t)=>`expr:${e}:${t}`,DEPENDENCY:(e,t)=>`deps:${e}:${t}`,COMMON:e=>`common:${e}`};constructor(){this.precompileCommonExpressions()}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}precompileCommonExpressions(){["true","false","null","undefined"].forEach(t=>{const i={fn:new Function("return "+t),contextMap:new Map,dependencies:[t],timestamp:Date.now(),hitCount:0},n=le.CACHE_KEYS.COMMON(t);this.commonExpressionsCache.set(n,i)})}extractDependencies(e,t,i){const n=this.normalizeExpression(e),r=le.CACHE_KEYS.DEPENDENCY(t,n);let a=this.dependencyCache.get(r);return a||(a=this.dependencyParser.extract(n,t,i),this.dependencyCache.set(r,a),a)}evaluateExpression(e,t,i){const n=this.normalizeExpression(e),r=le.CACHE_KEYS.COMMON(n);let a=this.commonExpressionsCache.get(r);if(a){a.hitCount++;try{return a.fn()}catch(c){console.error(`Common expression evaluation failed: "${n}"`,c);return}}const o=le.CACHE_KEYS.EXPRESSION(i,n);a=this.expressionCache.get(o),(!a||this.isStale(a))&&(a=this.compileExpression(n,t,i),this.expressionCache.set(o,a)),a.hitCount++;try{const c=this.buildArguments(a.contextMap,t);return a.fn(...c)}catch(c){console.error(`Expression evaluation failed: "${n}"`,c),console.error("Available context:",Object.keys(t));return}}compileExpression(e,t,i){const n=this.prepareSafeContext(t),r=new Map,a=[];Object.keys(n).forEach((c,l)=>{r.set(c,l),a.push(c)});const o=this.dependencyParser.extract(e,i);return{fn:new Function(...a,`return (${e})`),contextMap:r,dependencies:o,timestamp:Date.now(),hitCount:0}}buildArguments(e,t){const i=new Array(e.size);for(const[n,r]of e)i[r]=t[n];return i}isStale(e){return Date.now()-e.timestamp>3e5}prepareSafeContext(e){const t={};for(const[i,n]of Object.entries(e))Ee.has(i)||!this.isValidJavaScriptIdentifier(i)||(t[i]=n);return t}isValidJavaScriptIdentifier(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!Ee.has(e)}invalidateCache(e){switch(e){case"expressions":this.expressionCache.clear();break;case"dependencies":this.dependencyCache.clear();break;case"common":this.commonExpressionsCache.clear(),this.precompileCommonExpressions();break;case"parser":this.dependencyParser.clearCache();break;default:this.clearAllCaches()}}invalidateByComponent(e){this.expressionCache.deleteByPrefix(`expr:${e}:`),this.dependencyCache.deleteByPrefix(`deps:${e}:`)}clearAllCaches(){this.expressionCache.clear(),this.dependencyCache.clear(),this.commonExpressionsCache.clear(),this.dependencyParser.clearCache(),this.precompileCommonExpressions()}getCacheStats(){return{expressions:this.expressionCache.getStats(),dependencies:this.dependencyCache.getStats(),commonExpressions:this.commonExpressionsCache.getStats(),dependencyParser:this.getDependencyParserStats()}}getDependencyParserStats(){return this.dependencyParser.getCacheSize?{size:this.dependencyParser.getCacheSize(),maxSize:500,hitRate:0,hits:0,misses:0}:{size:0,maxSize:0,hitRate:0,hits:0,misses:0}}cleanupStaleExpressions(){let e=0;return this.expressionCache.keys().forEach(i=>{const n=this.expressionCache.get(i);n&&this.isStale(n)&&(this.expressionCache.delete(i),e++)}),e}}class Rs{parseCache=new W(500);extract(e,t,i){const n=this.normalizeExpression(e),r=`${t}:${n}`;if(this.parseCache.has(r))return this.parseCache.get(r);const a=this.parseExpression(n,t,i);return this.parseCache.set(r,a),a}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}parseExpression(e,t,i){const n=this.extractIdentifiers(e),r=[],a=i?.getState()||{};for(const c of n){if(Ee.has(c))continue;const l=c.indexOf("."),p=l===-1?c:c.substring(0,l),h=je.findExistingStateKey(p,t,a);if(h)r.push(h);else{const f=t==="app"?[`app.${p}`]:[`${t}.${p}`,`app.${p}`];r.push(...f)}if(l!==-1){const f=t==="app"?[`app.${p}`]:[`${t}.${p}`,`app.${p}`];r.push(...f)}}return Array.from(new Set(r))}extractIdentifiers(e){const t=[];let i=0;for(;i<e.length;){const n=e[i];if(n==="'"){i=this.skipString(e,i,"'");continue}if(n==='"'){i=this.skipString(e,i,'"');continue}if(n==="`"){i=this.skipTemplateLiteral(e,i,t);continue}if(this.isIdentifierStart(n)){const r=this.extractIdentifier(e,i);t.push(r.value),i=r.endIndex;continue}i++}return t}skipString(e,t,i){let n=t+1;for(;n<e.length&&e[n]!==i;)e[n]==="\\"&&n++,n++;return n+1}skipTemplateLiteral(e,t,i){let n=t+1;for(;n<e.length&&e[n]!=="`";){if(e[n]==="$"&&n+1<e.length&&e[n+1]==="{"){n+=2;let r=1;for(;n<e.length&&r>0;){const a=e[n];if(a==='"'||a==="'"){n=this.skipString(e,n,a);continue}if(a==="{"?r++:a==="}"&&r--,r>0&&this.isIdentifierStart(a)){const o=this.extractIdentifier(e,n);i.push(o.value),n=o.endIndex-1}n++}continue}e[n]==="\\"&&n++,n++}return n+1}extractIdentifier(e,t){let i=t;for(;i<e.length&&(this.isIdentifierPart(e[i])||e[i]===".");)i++;return{value:e.substring(t,i),endIndex:i}}isIdentifierStart(e){return/[a-zA-Z_$]/.test(e)}isIdentifierPart(e){return/[a-zA-Z0-9_$]/.test(e)}clearCache(){this.parseCache.clear()}getCacheSize(){return this.parseCache.cache.size}}class Os{componentStack=["app"];elementProps=new WeakMap;contextCache=new W(100);contextIndex=new Map;contextInvalidated=new Set;stateManager;processedScripts=new WeakSet;componentFunctions=new Map;expressionEvaluator;domBindingManager;loopManager;templateRenderer;updateTimeouts;updateBatcher=new st;propDependencyCache=new Map;constructor(e){this.stateManager=e,this.updateBatcher=new st,this.stateManager.onStateChange(t=>this.invalidateContextCache(t))}getPropDependencies(e,t){const i=this.findElementWithProps(t);if(!i)return[];const n=this.elementProps.get(i);if(!n||!n.has(e))return[];const r=n.get(e);return this.templateRenderer?.dependencies(r.expression,r.component,this.stateManager)||[]}buildRestrictedComponentContext(e,t=!1){const i={};window[e]&&Object.assign(i,window[e]);const n=this.componentFunctions.get(e);if(n)for(const[a,o]of n)i[a]=o;const r=this.stateManager.getState();for(const a of Object.keys(r))if(a.startsWith(e+".")){const o=a.substring(e.length+1);o in i||(i[o]=r[a])}if(t){if(window.app)for(const[o,c]of Object.entries(window.app))o in i||(i[o]=c);const a=this.componentFunctions.get("app");if(a)for(const[o,c]of a)o in i||(i[o]=c);for(const o of Object.keys(r))if(o.startsWith("app.")){const c=o.substring(4);c in i||(i[c]=r[o])}}return i}getComponentPropDependencies(e,t){if(this.propDependencyCache.has(e))return this.propDependencyCache.get(e);const i=[],n=this.elementProps.get(e);n&&this.templateRenderer&&n.forEach(a=>{const o=this.templateRenderer?.dependencies(a.expression,a.component,this.stateManager);i.push(...o??[])});const r=Array.from(new Set(i));return this.propDependencyCache.set(e,r),r}setDOMBindingManager(e){this.domBindingManager=e,this.updateBatcher.setManagers(this,e)}hasStoredProps(e){return this.elementProps.has(e)&&this.elementProps.get(e).size>0}setExpressionEvaluator(e){this.expressionEvaluator=e,this.templateRenderer=new Qe(e),this.loopManager=new Bt(this.stateManager,e)}extractProps(e,t){const i=new Map,n=e.attributes,r=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);let o=t;r&&(r==="app"?o="app":r==="parent"?o=v.getParentOfComponent(a||"app",e):o=r);for(let c=0;c<n.length;c++){const l=n[c];if(!(l.name===d.ATTR_PREFIXES.COMPONENT||l.name===d.ATTR_PREFIXES.CONTEXT||l.name===d.ATTR_PREFIXES.SPREAD||l.name===d.ATTR_PREFIXES.LOOP)&&!ue.isEventAttribute(l.name)&&l.value&&Ns.containsMustacheExpression(l.value)){if(a&&this.mightReferenceSelfProps(l.value,e))continue;const p=this.attributeToPropName(l.name),h={name:p,expression:l.value,component:o,subscriptionIds:[]};i.set(p,h)}}return i}mightReferenceSelfProps(e,t){const i=this.elementProps.get(t);return i?Array.from(i.keys()).some(r=>e.includes(r)&&r!=="dataState"):!1}attributeToPropName(e){return e.replace(/-([a-z])/g,(t,i)=>i.toUpperCase())}setupProps(e,t){const i=this.extractProps(e,t);i.size!==0&&(this.elementProps.set(e,i),this.expressionEvaluator&&i.forEach((n,r)=>{this.setupPropBinding(e,n)}))}setupPropBinding(e,t){if(!this.expressionEvaluator)return;const i=`prop_${Date.now()}_${Math.random()}`,n=this.templateRenderer?.dependencies(t.expression,t.component,this.stateManager)||[],r={id:i,selector:"",dependencies:new Set(n),callback:()=>{const a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);a&&(this.updateBatcher.scheduleUpdate(a,e),this.refreshComponentBindings(e,a))},element:e,component:t.component};this.stateManager.addSubscription(r),t.subscriptionIds.push(i)}refreshComponentBindings(e,t){this.contextInvalidated.add(t),this.contextCache.delete(t),this.domBindingManager&&this.domBindingManager.refreshComponentElement(e,t)}evaluateProps(e){const t={},i=this.elementProps.get(e);if(!i||!this.expressionEvaluator)return t;const n=i.values().next().value;if(!n)return t;const r=this.buildComponentContext(n.component);return i.forEach((a,o)=>{try{const c=this.templateRenderer?.render(a.expression,r,a.component);typeof c=="function"?t[o]=(...l)=>c.apply(this,l):t[o]=c}catch(c){console.error(`❌ Failed to evaluate prop "${o}":`,c),t[o]=void 0}}),t}cleanupProps(e){const t=this.elementProps.get(e);t&&(t.forEach(i=>{i.subscriptionIds.forEach(n=>{this.stateManager.removeSubscription(n)})}),this.elementProps.delete(e))}buildComponentContextWithProps(e,t){const i=this.buildComponentContext(e);let n=this.findElementWithProps(e);if(t&&this.elementProps.has(t)&&(n=t),n)try{const r=this.evaluatePropsWithContext(n,e,t);Object.keys(r).length>0&&Object.keys(r).forEach(a=>{i[a]=r[a]})}catch(r){console.error(`❌ Error evaluating props for ${e}:`,r)}return i}evaluatePropsWithContext(e,t,i){const n={},r=this.elementProps.get(e);if(!r||!this.expressionEvaluator)return n;const a=r.values().next().value;if(!a)return n;let o;const c=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),l=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(c)if(c==="app")o=this.buildComponentContext("app");else if(c==="parent"){const E=v.getParentOfComponent(l||"app",e);o=this.buildComponentContext(E)}else o=this.buildComponentContext(c);else o=this.buildComponentContext(a.component);const p=this.loopManager?.getLoopContextForElement(e);p&&(o={...o,...p});const h=new Map,f=new Map,g=Array.from(r.keys());r.forEach((E,y)=>{g.some(N=>N!==y&&E.expression.includes(N))?f.set(y,E):h.set(y,E)}),h.forEach((E,y)=>{try{const S=this.templateRenderer?.render(E.expression,o,c||E.component);typeof S=="function"?this.isFunctionExplicitlyPassed(E.expression)?n[y]=(...k)=>S.apply(this,k):(console.warn(`⚠️ Function "${y}" not passed - not from shared namespace or explicitly passed`),n[y]=void 0):n[y]=S}catch(S){console.error(`❌ Failed to evaluate simple prop "${y}":`,S),console.error("Expression:",E.expression),console.error("Available context keys:",Object.keys(o)),n[y]=void 0}});const m={...o,...n};return f.forEach((E,y)=>{try{const S=this.templateRenderer?.render(E.expression,m,c||E.component);typeof S=="function"?this.isFunctionExplicitlyPassed(E.expression)?n[y]=(...k)=>S.apply(this,k):(console.warn(`⚠️ Function "${y}" not passed - not from shared namespace or explicitly passed`),n[y]=void 0):n[y]=S}catch(S){console.error(`❌ Failed to evaluate complex prop "${y}":`,S),console.error("Expression:",E.expression),console.error("Available context keys:",Object.keys(m)),n[y]=void 0}}),n}isFunctionExplicitlyPassed(e){const t=_.isSingleExpression(e);return t?/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t.trim()):!1}findElementWithProps(e){const t=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${e}"]`);for(const i of t){const n=this.elementProps.get(i);if(n&&n.size>0)return i}return null}pushComponent(e){this.componentStack.push(e)}popComponent(){return this.componentStack.pop()}getCurrentComponent(){return this.componentStack[this.componentStack.length-1]}buildComponentContext(e){if(!this.contextInvalidated.has(e)&&this.contextCache.has(e))return this.contextCache.get(e);const t=this.computeComponentContext(e);return this.contextCache.set(e,t),this.contextInvalidated.delete(e),t}computeComponentContext(e){const t={};if(e.includes("_loop_")||e.match(/_[a-zA-Z0-9]{8}$/)){const r=e.split("_");r.pop();const a=r.join("_");window[a]&&Object.assign(t,window[a])}e!=="app"&&window[e]&&Object.assign(t,window[e]),e==="app"&&window.app&&Object.assign(t,window.app);const i=this.componentFunctions.get(e);if(i)for(const[r,a]of i)t[r]=a;if(e!=="app"){const r=this.componentFunctions.get("app");if(r)for(const[a,o]of r)a in t||(t[a]=o);if(window.app)for(const[a,o]of Object.entries(window.app))a in t||(t[a]=o)}const n=this.stateManager.getState();for(const r of Object.keys(n))if(r.startsWith(e+".")){const a=r.substring(e.length+1);a in t||(t[a]=n[r])}if(e!=="app"){for(const r of Object.keys(n))if(r.startsWith("app.")){const a=r.substring(4);a in t||(t[a]=n[r])}}return t}invalidateContextCache(e){if(e.startsWith("app.")){this.contextCache.clear();for(const i of this.contextInvalidated.keys())this.contextInvalidated.add(i);return}const t=e.indexOf(".");if(t!==-1){const i=e.slice(0,t);this.invalidateComponent(i)}}invalidateComponent(e){this.contextInvalidated.add(e),this.contextIndex.delete(e)}executePhpScripts(e){const t=this.componentStack.length,i=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),n=e===document.body;if(i||n){if(i){this.pushComponent(i);const a=this.getParentComponent(e);this.setupProps(e,a)}this.getRelevantScripts(e,n).forEach(a=>{const o=a.getAttribute(d.ATTR_PREFIXES.COMPONENT);o&&o!==i?(this.pushComponent(o),this.executeScript(a),this.popComponent()):this.executeScript(a)})}for(Array.from(e.children).forEach(r=>this.executePhpScripts(r));this.componentStack.length>t;)this.popComponent()}getParentComponent(e){let t=e.parentElement;for(;t;){const i=t.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(i)return i;t=t.parentElement}return"app"}getRelevantScripts(e,t){return Array.from(e.querySelectorAll(`script[type="${d.SCRIPT_TYPE}"]`)).filter(i=>{if(this.processedScripts.has(i))return!1;if(t)return i.hasAttribute(d.ATTR_PREFIXES.COMPONENT)?!0:!i.closest(`[${d.ATTR_PREFIXES.COMPONENT}]`);let n=i.parentElement;for(;n&&n!==e;){if(n.hasAttribute(d.ATTR_PREFIXES.COMPONENT))return!1;n=n.parentElement}return n===e||e.contains(i)})}executeScript(e){if(this.processedScripts.has(e))return;this.processedScripts.add(e);const t=this.getCurrentComponent(),i=e.textContent||"",n=_.decodeEntities(i);try{const r=this.findComponentElementForScript(e,t);if(r===e){const o=this.getParentComponent(e);this.setupProps(e,o)}const a=this.buildComponentContextWithProps(t,r);window[t]||(window[t]={}),this.executeScriptFunctions(n,t,a)}catch(r){console.error(`Script execution failed in component ${t}:`,r),console.error("Script content:",n)}}findComponentElementForScript(e,t){if(e.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return e;let i=e.parentElement;for(;i;){if(i.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return i;i=i.parentElement}const n=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const r of n)if(this.elementProps.has(r))return r;return n[0]||void 0}executeScriptFunctions(e,t,i){const n=this.extractFunctionNames(e),r=this.findElementWithProps(t),a=this.extractVariableDeclarations(e);let o={...i};if(a.forEach(m=>{delete o[m];const E=`set${Dt(m)}`,y=`${m}Getter`;delete o[E],delete o[y]}),r){const m=this.evaluateProps(r);Object.assign(o,m)}o.getContext=()=>this.buildComponentContextWithProps(t),o.withContext=m=>{const E=this.buildComponentContextWithProps(t);return m.call(E,E)},o.__getProp=m=>{if(r)return this.evaluateProps(r)[m]};let l=z.getInstance().transformStateDeclarations(e);l=this.modifyScriptForReactiveProps(l,t,r||void 0);const p=`
|
|
17
17
|
${l}
|
|
18
18
|
|
|
19
|
-
${n.map(
|
|
20
|
-
if (typeof ${
|
|
21
|
-
this['${
|
|
19
|
+
${n.map(m=>`
|
|
20
|
+
if (typeof ${m} === 'function') {
|
|
21
|
+
this['${m}'] = ${m};
|
|
22
22
|
}
|
|
23
23
|
`).join(`
|
|
24
24
|
`)}
|
|
25
|
-
`,
|
|
26
|
-
`,n),c=o===-1?r:o;i+=e.slice(n,c),n=c;continue}else if(e[n+1]==="*"){const o=e.indexOf("*/",n+2),c=o===-1?r:o+2;i+=e.slice(n,c),n=c;continue}}this.matchesPropName(e,n,s)?(i+=`__getProp('${s}')`,n+=s.length):(i+=a,n++)}return i}findStringEnd(e,s,i){let n=s+1;for(;n<e.length;){if(e[n]===i&&e[n-1]!=="\\")return n;e[n]==="\\"&&n++,n++}return e.length-1}findTemplateEnd(e,s){let i=s+1,n=0;for(;i<e.length;){const r=e[i];if(r==="`"&&n===0)return i;r==="$"&&i+1<e.length&&e[i+1]==="{"?(n++,i++):r==="}"&&n>0?n--:r==="\\"&&i++,i++}return e.length-1}matchesPropName(e,s,i){if(s+i.length>e.length||e.substr(s,i.length)!==i)return!1;const r=s>0?e[s-1]:"",a=s+i.length<e.length?e[s+i.length]:"",o=s===0||!/[a-zA-Z0-9_$]/.test(r),c=s+i.length===e.length||!/[a-zA-Z0-9_$]/.test(a);if(!o||!c||r==="."||a===".")return!1;const l=e.slice(s+i.length);if(/^\s*[=:]/.test(l))return!1;const h=e.slice(Math.max(0,s-20),s);return!/[a-zA-Z0-9_$]\s*\.\s*$/.test(h)}extractFunctionNames(e){return q.getInstance().extractFunctionNames(e)}storeFunctionForComponent(e,s,i){this.componentFunctions.has(e)||this.componentFunctions.set(e,new Map),this.componentFunctions.get(e).set(s,i),window[e]||(window[e]={}),window[e][s]=i}getComponentFunctions(e){return this.componentFunctions.get(e)}destroy(){if(this.updateTimeouts){for(const e of this.updateTimeouts.values())clearTimeout(e);this.updateTimeouts.clear()}}}class Rs{stateManager;componentManager;expressionEvaluator;textNodeManager;observer;listeners=new WeakMap;pendingBindings=[];pendingTextNodes=[];applyingUpdates=!1;elementCache=new WeakMap;batchedUpdates=new Set;processingRAF=null;updateQueue=new Map;eventDelegation=new se;processedElements=new WeakSet;loopManager;templateRenderer;BOOL_REFLECTED={checked:"checked",disabled:"disabled",hidden:"hidden",readonly:"readOnly",required:"required",multiple:"multiple",selected:"selected",autofocus:"autofocus",autoplay:"autoplay",controls:"controls",defer:"defer",loop:"loop",muted:"muted",open:"open",reversed:"reversed",async:"async",default:"default",formnovalidate:"formNoValidate",novalidate:"noValidate",allowfullscreen:"allowFullscreen",capture:"capture",itemscope:"itemScope"};lastValueCache=new WeakMap;stringValueCache=new $(500);refBindings=new WeakMap;constructor(e,s,i){this.stateManager=e,this.componentManager=s,this.expressionEvaluator=i,this.textNodeManager=new Ps(i,e),this.textNodeManager.componentManager=this.componentManager,this.componentManager.setDOMBindingManager(this),this.setupMutationObserver(),this.eventDelegation.setupEventDelegation(),this.loopManager=new Ft(e,i),this.loopManager.setDependencies(s,this),this.loopManager.eventDelegation=this.eventDelegation,this.eventDelegation.setDependencies(this.componentManager,this.expressionEvaluator,this.loopManager),this.templateRenderer=new Ke(i)}refreshComponentElement(e,s){this.elementCache.delete(e),this.processedElements.delete(e);const i=[...this.componentManager.componentStack];this.componentManager.componentStack=["app"],s!=="app"&&this.componentManager.componentStack.push(s);try{const n=this.componentManager.buildComponentContextWithProps(s,e);this.processElementInContext(e,n,s,!0),this.walkComponentChildren(e,s),this.refreshComponentTextNodes(e,s)}finally{this.componentManager.componentStack=i}}refreshComponentTextNodes(e,s){const i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:a=>{const o=a;return!o.textContent||!d.MUSTACHE_PATTERN.test(o.textContent)||y.isTextNodeInsideScript(o)||this.isTextNodeInsideLoopItem(o)||y.getComponentForNode(o)!==s?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let n;const r=[];for(;n=i.nextNode();)r.push(n);r.forEach(a=>{this.textNodeManager.cleanupTextNode(a),this.textNodeManager.cleanupTextNode(a),this.textNodeManager.processTextNode(a,s)})}walkComponentChildren(e,s){const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const o=a;return y.getElementComponent(o)!==s?NodeFilter.FILTER_REJECT:o===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}});let n;const r=[];for(;n=i.nextNode();){const a=n;r.push(a)}r.forEach(a=>{this.elementCache.delete(a),this.processedElements.delete(a);const o=this.componentManager.buildComponentContextWithProps(s,e);this.processElementInContext(a,o,s,!0)})}createSpreadDirectiveBinding(e,s,i){const n=`spread_${Date.now()}_${Math.random()}`,r=P.parseSpreadDirective(s);if(r.spreads.length===0&&r.objects.length===0){console.warn(`Invalid pp-spread directive: ${s}`);return}const a=new Set,o=()=>{if(!document.contains(e)){this.stateManager.removeSubscription(n);return}try{const h=this.componentManager.buildComponentContextWithProps(i,e);this.clearSpreadAttributes(e,a);for(const p of r.spreads){const f=this.expressionEvaluator.evaluateExpression(p,h,i);f&&typeof f=="object"&&this.applySpreadObject(e,f,a)}for(const p of r.objects)this.applyObjectProperties(e,p,h,i,a)}catch(h){console.error(`Spread directive evaluation error for "${s}":`,h)}},c=new Set;for(const h of r.spreads)this.templateRenderer.dependencies(h,i,this.stateManager).forEach(f=>c.add(f));for(const h of r.objects)for(const p of h)this.templateRenderer.dependencies(p.value,i,this.stateManager).forEach(m=>c.add(m));const l={id:n,selector:"",dependencies:c,callback:o,element:e,component:i};this.stateManager.addSubscription(l),this.storeSpreadSubscription(e,n),o()}applyObjectProperties(e,s,i,n,r){for(const a of s)try{const o=this.expressionEvaluator.evaluateExpression(a.value,i,n);if(this.isEventProperty(a.key)){this.handleSpreadEventProperty(e,a.key,o);continue}const c=this.normalizeAttributeName(a.key);this.updateElementProperty(e,c,o),r.add(c)}catch(o){console.error(`Error evaluating object property "${a.key}: ${a.value}":`,o)}}applySpreadObject(e,s,i){for(const[n,r]of Object.entries(s))if(r!=null){if(this.isEventProperty(n)){this.handleSpreadEventProperty(e,n,r);continue}const a=this.normalizeAttributeName(n);(!e.hasAttribute(a)||i.has(a))&&(this.updateElementProperty(e,a,r),i.add(a))}}isEventProperty(e){return e.startsWith("on")&&e.length>2}handleSpreadEventProperty(e,s,i){const n=s.substring(2).toLowerCase();if(typeof i=="function"){const r=a=>{try{const o=y.getContextComponent(e),c=this.componentManager?.buildComponentContextWithProps(o,e)||{};i.call(c,a)}catch(o){console.error("Spread event handler error:",o)}};e.addEventListener(n,r),this.storeDirectEventListener(e,n,r);return}if(typeof i=="string"){const r=y.getContextComponent(e);this.eventDelegation.registerEventHandler(e,n,i,r)}}storeDirectEventListener(e,s,i){e.__directEventListeners||(e.__directEventListeners=[]),e.__directEventListeners.push({eventType:s,listener:i})}clearSpreadAttributes(e,s){for(const i of s)e.hasAttribute(i)&&e.removeAttribute(i);s.clear()}normalizeAttributeName(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}storeSpreadSubscription(e,s){e.__spreadSubscriptions||(e.__spreadSubscriptions=[]),e.__spreadSubscriptions.push(s)}setupMutationObserver(){this.observer=new MutationObserver(e=>{const s=e.filter(this.isRelevantMutation);if(s.length===0)return;const i=L.getInstance();for(const n of s)if(n.type==="childList"&&(n.removedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const a=r;this.cleanupRefBinding(a),a.querySelectorAll("[pp-ref]").forEach(l=>{this.cleanupRefBinding(l)}),i.invalidateElement(a);const c=a.getAttribute(d.ATTR_PREFIXES.COMPONENT);c&&i.invalidateByComponent(c)}}),n.addedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const o=r.getAttribute(d.ATTR_PREFIXES.COMPONENT);o&&i.invalidateByComponent(o)}})),n.type==="attributes"&&n.target){const r=n.target;i.invalidateElement(r);const a=r.getAttribute(d.ATTR_PREFIXES.COMPONENT);a&&i.invalidateByComponent(a)}this.processMutationsBatch(s)}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0,attributeFilter:[d.ATTR_PREFIXES.COMPONENT]})}isRelevantMutation=e=>{if(this.applyingUpdates&&e.type==="attributes")return!1;if(e.type==="childList"||e.type==="characterData")return!0;if(e.type==="attributes"){const s=e.attributeName;return s===d.ATTR_PREFIXES.COMPONENT||s!==null&&oe.isEventAttribute(s)}return!1};processElement(e,s=!0){if(e===document.body){const n=Array.from(document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}]`)).sort((r,a)=>{const o=y.getElementDepth(r),c=y.getElementDepth(a);return o-c});this.processElementsBatch([e],s),n.forEach(r=>{this.processElementsBatch([r],s)}),s&&this.loopManager.processPendingTemplates()}else this.processElementsBatch([e],s)}processElementsBatch(e,s=!0){for(const i of e)this.processSingleElement(i,s);s&&(e.forEach(i=>{this.componentManager.executePhpScripts(i)}),this.processPendingBindings())}processSingleElement(e,s){const i=y.getElementComponent(e),n=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let r;n?n==="app"?r="app":n==="parent"?r=y.getParentOfComponent(i,e):r=n:r=y.getParentComponentForElement(e);const a=this.componentManager.componentStack.length;i!=="app"&&this.componentManager.pushComponent(i),this.componentManager.setupProps(e,r),s&&this.componentManager.executePhpScripts(e),this.processLoopTemplates(e,i);const o=s?this.componentManager.buildComponentContextWithProps(i,e):{};for(this.processElementInContext(e,o,i,s),this.walkDOM(e,o,i,s);this.componentManager.componentStack.length>a;)this.componentManager.popComponent()}processLoopTemplates(e,s){this.getDirectComponentTemplates(e,s).forEach(n=>{this.loopManager.queueTemplate(n,s)})}getDirectComponentTemplates(e,s){const i=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const o=a;return o!==e&&o.hasAttribute(d.ATTR_PREFIXES.COMPONENT)?NodeFilter.FILTER_REJECT:o.tagName==="TEMPLATE"&&o.hasAttribute("pp-for")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let r;for(;r=n.nextNode();)i.push(r);return i}walkDOM(e,s,i,n){const r=ae.getInstance(),a=`walkDOM_${i}_${n}`,o=r.getCachedTraversal(e,a,()=>{const h=r.traverseElementsAndText(e,p=>{if(p===e||p.tagName.toLowerCase()==="script"||this.loopManager.isLoopItem(p))return!1;let f=p.parentElement;for(;f&&f!==e;){if(this.loopManager.isLoopItem(f))return!1;f=f.parentElement}return!(y.getElementComponent(p)!==i||this.processedElements.has(p))},p=>{if(!p.textContent||!d.MUSTACHE_PATTERN.test(p.textContent)||y.isTextNodeInsideScript(p)||this.isTextNodeInsideLoopItem(p))return!1;const f=p.parentElement;if(f){const m=y.getContextComponent(f),x=y.getComponentForNode(p);if(m!==i&&x!==i)return!1}else if(y.getComponentForNode(p)!==i)return!1;return!0});return[...h.textNodes,...h.elements]}),c=[],l=[];o.forEach(h=>{if(h.nodeType===Node.TEXT_NODE)c.push(h);else if(h.nodeType===Node.ELEMENT_NODE){const p=h;if(p.hasAttribute("pp-ref")&&n){const f=p.getAttribute("pp-ref");this.createRefBinding(p,f,i),p.removeAttribute("pp-ref")}l.push(p),this.processedElements.add(p)}}),c.forEach(h=>{const p=h.parentElement,f=p?y.getContextComponent(p):i;n?this.textNodeManager.processTextNode(h,f):this.pendingTextNodes.push({textNode:h,component:f})}),l.forEach(h=>{this.processElementInContext(h,s,i,n)})}isTextNodeInsideLoopItem(e){let s=e.parentElement;for(;s&&s!==document.body;){if(this.loopManager.isLoopItem(s))return!0;s=s.parentElement}return!1}processElementInContext(e,s,i,n){if(e.hasAttribute("pp-ref")){const l=e.getAttribute("pp-ref");n&&this.createRefBinding(e,l,i),e.removeAttribute("pp-ref")}if(e.hasAttribute(d.ATTR_PREFIXES.SPREAD)){const l=e.getAttribute(d.ATTR_PREFIXES.SPREAD);n&&this.createSpreadDirectiveBinding(e,l,i),e.removeAttribute(d.ATTR_PREFIXES.SPREAD)}if(this.loopManager.isLoopItem(e)||this.isElementInLoopItem(e))return;const r=this.extractDomMustacheBindings(e),a=this.elementCache.get(e),o=this.getElementHash(e);if(a&&a.hash===o&&this.isCacheValid(a)&&n){this.applyBindingsFromCache(e,a,s);return}const c={bindings:r,component:i,listeners:[],lastProcessed:Date.now(),hash:o};n?this.applyBindings(e,r,s,i):r.forEach((l,h)=>{this.pendingBindings.push({element:e,property:h,expression:l,component:i})}),this.setupEventBindings(e,i),this.elementCache.set(e,c)}createRefBinding(e,s,i){try{const n=P.decodeEntities(s),r=P.isSingleExpression(n)||n,a=y.getContextComponent(e),o=this.componentManager.buildComponentContextWithProps(a,e);try{const c=this.expressionEvaluator.evaluateExpression(r,o,a);if(typeof c=="function"){const l=c;this.refBindings.set(e,{element:e,callback:l,component:a}),l(e)}else if(c&&typeof c=="object"&&"current"in c){const l=c;this.refBindings.set(e,{element:e,refObject:l,component:a}),l.current=e}else console.warn(`⚠️ pp-ref expression did not return a ref object or callback: ${r}`,c)}catch(c){console.error(`❌ Failed to evaluate ref "${r}":`,c)}}catch(n){console.error(`❌ Failed to create ref binding for "${s}":`,n)}}isElementInLoopItem(e){let s=e;for(;s;){if(this.loopManager.isLoopItem(s))return!0;s=s.parentElement}return!1}extractDomMustacheBindings(e){const s=new Map,i=e.attributes,n=this.elementCache.get(e),r=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),o=a&&this.componentManager?.hasStoredProps(e),c=r&&a&&r!==a;for(let l=0;l<i.length;l++){const h=i[l];if(!(h.name===d.ATTR_PREFIXES.COMPONENT||h.name===d.ATTR_PREFIXES.CONTEXT||h.name==="key"||oe.isEventAttribute(h.name))&&!(n&&n.bindings.has(h.name))&&h.value){const p=d.MUSTACHE_PATTERN.test(h.value),f=P.decodeEntities(h.value),m=d.MUSTACHE_PATTERN.test(f);if(p||m){if(this.looksLikeSerializedObject(f))continue;const x=P.extractExpressions(f),C=y.getContextComponent(e);if(x.length===0&&(p||m)){console.error(`
|
|
27
|
-
❌ Malformed mustache expression in attribute "${
|
|
28
|
-
`),o||c&&
|
|
29
|
-
❌ Invalid expression in attribute "${
|
|
30
|
-
`)),
|
|
31
|
-
⚠️ Expression warnings in attribute "${h.name}":`),console.warn(` Expression: ${v}`),console.warn(" Element:",e),A.warnings.forEach(I=>{console.warn(` • ${I}`)}))}o||c&&y.shouldBeDirectBinding(e,h.name)?s.set(h.name,f):c||s.set(h.name,f)}}}return s}applyBindings(e,s,i,n){s.forEach((r,a)=>{this.createMustacheBinding(e,a,r)}),this.setupEventBindings(e,n)}applyBindingsFromCache(e,s,i){s.bindings.forEach((n,r)=>{try{const a=this.componentManager.buildComponentContextWithProps(s.component,e),o=this.templateRenderer.render(n,a,s.component);this.updateElementProperty(e,r,o)}catch(a){console.error(`Cached binding evaluation error for "${n}":`,a)}})}createMustacheBinding(e,s,i){const n=`mustache_${Date.now()}_${Math.random()}`;let r;const a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(a&&this.componentManager?.hasStoredProps(e)){const f=this.componentManager.elementProps.get(e);(f?Array.from(f.keys()):[]).some(C=>i.includes(C))?r=a:r=y.getContextComponent(e)}else r=y.getContextComponent(e);e.removeAttribute(s);const o=new Set;this.templateRenderer.dependencies(i,r,this.stateManager).forEach(f=>o.add(f));const l=this.findComponentElementForMustacheBinding(e,r);l&&this.componentManager&&this.componentManager.getComponentPropDependencies(l,r).forEach(m=>o.add(m));const h=()=>{if(!document.contains(e)){this.stateManager.removeSubscription(n);return}try{const f=r===a?e:l||void 0,m=this.componentManager.buildComponentContextWithProps(r,f),x=this.templateRenderer.render(i,m,r);this.scheduleElementUpdate(e,s,x)}catch(f){console.error(`Mustache binding evaluation error for "${i}":`,f)}},p={id:n,selector:"",dependencies:o,callback:h,element:e,component:r};this.stateManager.addSubscription(p),h()}findComponentElementForMustacheBinding(e,s){if(e.getAttribute(d.ATTR_PREFIXES.COMPONENT)===s)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(d.ATTR_PREFIXES.COMPONENT)===s)return n;n=n.parentElement}const r=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${s}"]`);for(const a of r)if(this.componentManager&&this.componentManager.hasStoredProps(a))return a;return r[0]||null}setupEventBindings(e,s){for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i];if(oe.isEventAttribute(n.name)){const r=n.name.substring(2),a=y.getContextComponent(e);this.eventDelegation.registerEventHandler(e,r,n.value,a),e.removeAttribute(n.name)}}}scheduleElementUpdate(e,s,i){if(this.isCriticalProperty(s)){this.updateElementProperty(e,s,i);return}this.updateQueue.has(e)||(this.updateQueue.set(e,new Set),this.batchedUpdates.add(e)),this.updateQueue.get(e).add(s),this.processingRAF||(this.processingRAF=requestAnimationFrame(()=>{this.processBatchedElementUpdates()})),e[`__pending_${s}`]=i}isCriticalProperty(e){return["textContent","innerHTML","value","checked","selected","disabled","class","className","style","hidden","display"].includes(e)}processBatchedElementUpdates(){this.applyingUpdates=!0;try{for(const e of this.batchedUpdates){const s=this.updateQueue.get(e);if(s)for(const i of s){const n=e[`__pending_${i}`];this.updateElementProperty(e,i,n),delete e[`__pending_${i}`]}}}finally{this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF=null,this.applyingUpdates=!1}}updateElementProperty(e,s,i){const n=this.lastValueCache.get(e);if(n&&this.isSameValue(n.get(s),i))return;const r=this.applyingUpdates;this.applyingUpdates=!0;try{switch(s){case"textContent":const a=this.cachedValueToString(i);e.textContent!==a&&(e.textContent=a);break;case"innerHTML":const o=this.cachedValueToString(i);e.innerHTML!==o&&(e.innerHTML=o);break;case"value":const c=this.cachedValueToString(i);e instanceof HTMLOptionElement?e.value!==c&&(e.value=c,e.setAttribute("value",c)):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.value!==c&&(e.value=c);break;case"selectedIndex":if(e instanceof HTMLSelectElement){const h=Number(i);e.selectedIndex!==h&&(e.selectedIndex=h)}break;case"checked":case"disabled":case"hidden":case"readonly":case"required":case"multiple":case"selected":case"autofocus":case"autoplay":case"controls":case"defer":case"loop":case"muted":case"open":case"reversed":case"async":case"default":case"formnovalidate":case"novalidate":case"allowfullscreen":case"capture":case"itemscope":this.setBooleanProperty(e,s,i);break;case"indeterminate":if(e instanceof HTMLInputElement&&e.type==="checkbox"){const h=!!i;e.indeterminate!==h&&(e.indeterminate=h)}break;case"class":case"className":const l=this.cachedValueToString(i);e instanceof SVGElement?e.getAttribute("class")!==l&&e.setAttribute("class",l):e.className!==l&&(e.className=l);break;case"htmlFor":case"for":if(e instanceof HTMLLabelElement){const h=this.cachedValueToString(i);e.htmlFor!==h&&(e.htmlFor=h)}break;case"style":if(e instanceof HTMLElement)if(typeof i=="object"&&i&&!Array.isArray(i))this.updateStyleObject(e,i);else{const h=this.cachedValueToString(i);e.style.cssText!==h&&(e.style.cssText=h)}break;case"tabIndex":if(e instanceof HTMLElement){const h=i==null?-1:Number(i);e.tabIndex!==h&&(e.tabIndex=h)}break;case"contentEditable":if(e instanceof HTMLElement){const h=i===!0?"true":i===!1?"false":String(i);e.contentEditable!==h&&(e.contentEditable=h)}break;case"draggable":if(e instanceof HTMLElement){const h=i===!0,p=h?"true":"false";e.draggable!==h&&(e.draggable=h,e.setAttribute("draggable",p))}break;case"spellcheck":if(e instanceof HTMLElement){const h=!!i,p=h?"true":"false";e.spellcheck!==h&&(e.spellcheck=h,e.setAttribute("spellcheck",p))}break;case"src":case"href":case"action":case"alt":case"title":case"placeholder":case"id":case"name":case"type":case"method":case"target":case"rel":case"pattern":case"accept":case"autocomplete":case"enctype":case"wrap":case"download":case"ping":case"referrerpolicy":case"crossorigin":case"integrity":case"loading":case"decoding":case"srcset":case"sizes":case"dir":case"lang":case"translate":case"role":this.setStringAttribute(e,s,i);break;case"min":case"max":case"step":case"maxLength":case"minLength":case"size":case"rows":case"cols":case"rowSpan":case"colSpan":this.setNumericAttribute(e,s,i);break;default:s.startsWith("aria-")?this.setAriaAttribute(e,s,i):s.startsWith("data-")?this.setDataAttribute(e,s,i):this.setGenericAttribute(e,s,i);break}this.updateValueCache(e,s,i)}catch(a){console.error(`Failed to update property "${s}" on element:`,e,a)}finally{this.applyingUpdates=r}}looksLikeSerializedObject(e){if(!e.startsWith("{")||!e.endsWith("}"))return!1;try{const s=JSON.parse(e);return typeof s=="object"&&s!==null&&!Array.isArray(s)&&Object.keys(s).length>0}catch{return!1}}cachedValueToString(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(e==null)return"";if(typeof e=="boolean")return e?"true":"false";if(this.stringValueCache.has(e))return this.stringValueCache.get(e);const s=ie(e);return this.stringValueCache.set(e,s),s}isSameValue(e,s){if(e===s)return!0;if(typeof e=="object"&&typeof s=="object"){if(e===null||s===null)return e===s;if(Array.isArray(e)&&Array.isArray(s))return e.length===s.length&&e.every((i,n)=>i===s[n]);if(this.isStyleObject(e)&&this.isStyleObject(s)){const i=Object.keys(e),n=Object.keys(s);return i.length===n.length&&i.every(r=>e[r]===s[r])}}return!1}isStyleObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}setBooleanProperty(e,s,i){const n=!!i;this.setBooleanProp(e,s,i)||(n&&!e.hasAttribute(s)?e.setAttribute(s,""):!n&&e.hasAttribute(s)&&e.removeAttribute(s))}updateStyleObject(e,s){const i=this.lastValueCache.get(e)?.get("style"),n=i&&typeof i=="object"?i:{};for(const[r,a]of Object.entries(s))n[r]!==a&&(e.style[r]=a)}setStringAttribute(e,s,i){const n=this.cachedValueToString(i);e.getAttribute(s)!==n&&(i==null?e.removeAttribute(s):e.setAttribute(s,n))}setNumericAttribute(e,s,i){const n=String(i);e.getAttribute(s)!==n&&(i==null?e.removeAttribute(s):e.setAttribute(s,n))}setAriaAttribute(e,s,i){const n=this.cachedValueToString(i);e.getAttribute(s)!==n&&(i==null||i===!1?e.removeAttribute(s):e.setAttribute(s,n))}setDataAttribute(e,s,i){const n=this.cachedValueToString(i);e.getAttribute(s)!==n&&(i==null?e.removeAttribute(s):e.setAttribute(s,n))}setGenericAttribute(e,s,i){const n=this.cachedValueToString(i);e.getAttribute(s)!==n&&(i==null||i===!1?e.removeAttribute(s):e.setAttribute(s,n))}updateValueCache(e,s,i){this.lastValueCache.has(e)||this.lastValueCache.set(e,new Map),this.lastValueCache.get(e).set(s,i)}setBooleanProp(e,s,i){const n=this.BOOL_REFLECTED[s];if(!n)return!1;const r=!!i;return e instanceof HTMLElement&&n in e?(e[n]!==r&&(e[n]=r),!0):(r?e.hasAttribute(s)||e.setAttribute(s,""):e.hasAttribute(s)&&e.removeAttribute(s),!0)}processPendingBindings(){const e=[...this.pendingBindings];this.pendingBindings=[];const s=new Map;for(const i of e)s.has(i.component)||s.set(i.component,[]),s.get(i.component).push(i);for(const[i,n]of s){const r=[...this.componentManager.componentStack];i!=="app"?this.componentManager.componentStack=["app",i]:this.componentManager.componentStack=["app"];for(const a of n)try{if(!document.contains(a.element))continue;this.createMustacheBinding(a.element,a.property,a.expression)}catch(o){console.error(`❌ Failed to create binding for ${i}:`,o)}this.componentManager.componentStack=r}this.processTextNodesPending()}processTextNodesPending(){const e=new Map;for(const s of this.pendingTextNodes)e.has(s.component)||e.set(s.component,[]),e.get(s.component).push(s);this.pendingTextNodes=[];for(const[s,i]of e){const n=[...this.componentManager.componentStack];s!=="app"?this.componentManager.componentStack=["app",s]:this.componentManager.componentStack=["app"];for(const{textNode:r,component:a}of i)if(document.contains(r))try{this.textNodeManager.processTextNode(r,a)}catch(o){console.error(`❌ Failed to process text node for ${a}:`,o)}this.componentManager.componentStack=n}}processMutationsBatch(e){const s=new Set,i=new Set,n=new Set,r=new Set,a=new Set;for(const o of e)if(o.type==="childList"&&(o.addedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE)s.add(c);else if(c.nodeType===Node.TEXT_NODE){const l=c;l.textContent&&d.MUSTACHE_PATTERN.test(l.textContent)&&a.add(l)}}),o.removedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE)i.add(c);else if(c.nodeType===Node.TEXT_NODE){const l=c;l.textContent&&d.MUSTACHE_PATTERN.test(l.textContent)&&(document.contains(l)||this.textNodeManager.cleanupTextNode(l))}})),o.type==="attributes"&&o.target&&r.add(o.target),o.type==="characterData"&&o.target){const c=o.target;c.textContent&&d.MUSTACHE_PATTERN.test(c.textContent)&&a.add(c)}for(const o of i)(s.has(o)||document.contains(o))&&(n.add(o),i.delete(o),s.has(o)&&s.delete(o));i.size>0&&this.cleanupElementsBatch(Array.from(i)),s.size>0&&this.processElementsBatch(Array.from(s)),a.size>0&&this.processTextNodesBatch(Array.from(a)),r.size>0&&this.rebindChangedElements(Array.from(r))}processTextNodesBatch(e){const s=new Map;for(const i of e){const n=y.getComponentForNode(i);s.has(n)||s.set(n,[]),s.get(n).push(i)}for(const[i,n]of s)n.forEach(r=>{this.textNodeManager.processTextNode(r,i)})}rebindChangedElements(e){e.forEach(s=>{this.processElementBindings(s,!0)})}processElementBindings(e,s=!0){const i=this.extractDomMustacheBindings(e),n=y.getElementComponent(e);i.forEach((r,a)=>{s?this.createMustacheBinding(e,a,r):this.pendingBindings.push({element:e,property:a,expression:r,component:n})}),s&&this.setupEventBindings(e,n)}cleanupElementsBatch(e){e.forEach(s=>this.cleanupElement(s))}cleanupElement(e){this.cleanupRefBinding(e),this.stateManager.subscriptionManager?.cleanupElement(e);const s=this.listeners.get(e)||[];for(const{type:l,fn:h}of s)e.removeEventListener(l,h);this.listeners.delete(e),this.elementCache.delete(e),this.processedElements.delete(e),this.componentManager.cleanupProps(e);const i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let n;for(;n=i.nextNode();)this.textNodeManager.cleanupTextNode(n);e.tagName==="TEMPLATE"&&e.hasAttribute("pp-for")&&this.loopManager.cleanupTemplate(e),e.querySelectorAll("template[pp-for]").forEach(l=>{this.loopManager.cleanupTemplate(l)});const a=e.__directEventListeners;a&&(a.forEach(({eventType:l,listener:h})=>{e.removeEventListener(l,h)}),delete e.__directEventListeners);const o=e.__spreadEventHandlers;o&&(o.forEach(l=>{window.__spreadHandlers&&window.__spreadHandlers.delete(l)}),delete e.__spreadEventHandlers);const c=e.__spreadSubscriptions;c&&(c.forEach(l=>{this.stateManager.removeSubscription(l)}),delete e.__spreadSubscriptions),this.lastValueCache.delete(e),this.stringValueCache.size()>1500&&this.stringValueCache.clear()}cleanupRefBinding(e){const s=this.refBindings.get(e);if(s){try{s.callback?s.callback(null):s.refObject&&(s.refObject.current=null)}catch(i){console.error("Failed to cleanup ref:",i)}this.refBindings.delete(e)}}getElementHash(e){const s=[];for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i];(n.name===d.ATTR_PREFIXES.COMPONENT||oe.isEventAttribute(n.name)||n.value&&d.MUSTACHE_PATTERN.test(n.value))&&s.push(`${n.name}=${n.value}`)}return s.sort().join("|")}isCacheValid(e){return Date.now()-e.lastProcessed<3e4}refreshAllBindings(){this.elementCache=new WeakMap,this.processedElements=new WeakSet,this.processElement(document.body,!0)}destroy(){this.observer&&this.observer.disconnect(),document.querySelectorAll("[pp-ref]").forEach(s=>{this.cleanupRefBinding(s)}),this.eventDelegation.cleanup(),this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF&&cancelAnimationFrame(this.processingRAF),this.elementCache=new WeakMap,this.listeners=new WeakMap,this.processedElements=new WeakSet,this.loopManager.destroy()}}class se{static eventCache=null;delegatedEvents=new Map;elementHandlers=new WeakMap;handlerCache=new $(200);componentManager;expressionEvaluator;loopManager;setupEvents=new Set;static getAllAvailableEvents(){if(se.eventCache)return se.eventCache;const e=new Set,s=["click","input","change","submit","focus","blur","keydown","keyup","mousedown","mouseup","mouseover","mouseout"];try{Object.getOwnPropertyNames(HTMLElement.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(n){console.warn("Could not get HTMLElement events:",n),s.forEach(r=>e.add(r))}try{Object.getOwnPropertyNames(Document.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(n){console.warn("Could not get Document events:",n)}try{Object.getOwnPropertyNames(Window.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(n){console.warn("Could not get Window events:",n)}try{Object.getOwnPropertyNames(Element.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(n){console.warn("Could not get Element events:",n)}return new Set(["beforeunload","unload","pagehide","pageshow","popstate","hashchange","storage","message","messageerror","offline","online","languagechange","rejectionhandled","unhandledrejection","afterprint","beforeprint","devicemotion","deviceorientation","deviceorientationabsolute"]).forEach(n=>e.delete(n)),se.eventCache=e,e}setupEventDelegation(){const e=["click","input","change","submit","focus","blur"];for(const s of e)this.ensureEventSetup(s)}getEventOptions(e){const s={capture:!0,passive:!1};return["wheel","touchstart","touchmove","touchend","scroll","mousewheel"].includes(e)&&(s.passive=!0),(e==="focusin"||e==="focusout")&&(s.capture=!1),s}isEventSupported(e){return se.getAllAvailableEvents().has(e.toLowerCase())}getAllSupportedEvents(){return Array.from(se.getAllAvailableEvents()).sort()}getDelegatedEvents(){return Array.from(this.delegatedEvents.keys()).sort()}setDependencies(e,s,i){this.componentManager=e,this.expressionEvaluator=s,this.loopManager=i}createDelegatedListener(e){return s=>{const i=s.target;if(!i)return;const n=this.findHandler(i,e);n&&this.executeHandler(n.handler,n.element,s)}}registerEventHandler(e,s,i,n){const r=s.toLowerCase();if(this.ensureEventSetup(r),!this.isEventSupported(r)){console.warn(`⚠️ Event type "${s}" is not supported`);return}const a=y.getContextComponent(e);this.elementHandlers.has(e)||this.elementHandlers.set(e,new Map);const o=this.elementHandlers.get(e),c={code:i,component:a};o.set(r,c);const l=this.delegatedEvents.get(r);l?l.elements.add(e):(console.warn(`⚠️ No delegated listener for ${r}, attaching directly`),this.attachDirectListener(e,r,c))}ensureEventSetup(e){if(!this.setupEvents.has(e)){if(!this.isEventSupported(e)){console.warn(`⚠️ Attempting to setup unsupported event: ${e}`);return}try{const s=this.createDelegatedListener(e),i=this.getEventOptions(e);document.addEventListener(e,s,i),this.setupEvents.add(e),this.delegatedEvents.set(e,{listener:s,elements:new WeakSet})}catch(s){console.error(`Failed to setup event delegation for ${e}:`,s),this.setupEvents.delete(e)}}}findHandler(e,s){let i=e;for(;i;){const n=this.elementHandlers.get(i);if(n?.has(s))return{handler:n.get(s),element:i};i=i.parentElement}return null}compileHandler(e,s){const i=`${s}:${e}`;if(this.handlerCache.has(i))return this.handlerCache.get(i);let n=e;e.includes("this")&&(n=n.replace(/\bthis\b/g,"thisElement")),e.includes("event")&&(n=n.replace(/\bevent\b/g,"eventObject"));const r=new Function("eventObject","thisElement","context",`
|
|
25
|
+
`,h=Object.keys(o),f=h.map(m=>o[m]);if(this.checkIfInLoopItem()){const m=this.extractLoopItemContext();this.domBindingManager.stateManager.currentLoopContext=m}try{new Function(...h,p).call(window[t],...f),window[t].getContext=o.getContext,window[t].withContext=o.withContext,window[t].__getProp=o.__getProp;for(const E of n){const y=window[t][E];typeof y=="function"&&this.storeFunctionForComponent(t,E,y)}this.invalidateComponent(t)}catch(m){console.error("Script execution failed:",m),console.error("Component:",t),console.error("Original script:",e),console.error("Processed script:",l),console.error("Execution context keys:",Object.keys(o))}finally{this.domBindingManager.stateManager.currentLoopContext=null}}checkIfInLoopItem(){return!1}extractLoopItemContext(){return{}}extractVariableDeclarations(e){const n=z.getInstance().extractStateDeclarations(e).map(l=>l.variableName),r=[],a=/(?:const|let|var)\s*\[\s*([^,\]]+)(?:\s*,\s*([^,\]]+))?\s*\]/g;let o;for(;(o=a.exec(e))!==null;)o[1]&&!n.includes(o[1].trim())&&r.push(o[1].trim()),o[2]&&!n.includes(o[2].trim())&&r.push(o[2].trim());const c=/(?:const|let|var)\s+([a-zA-Z_$][\w$]*)/g;for(;(o=c.exec(e))!==null;)n.includes(o[1])||r.push(o[1]);return[...n,...r]}modifyScriptForReactiveProps(e,t,i){if(!i||!this.elementProps.has(i))return e;const n=this.elementProps.get(i),r=Array.from(n.keys());let a=e;return r.forEach(o=>{a=this.replacePropOutsideStrings(a,o)}),a}replacePropOutsideStrings(e,t){let i="",n=0;const r=e.length;for(;n<r;){const a=e[n];if(a==="'"){const o=this.findStringEnd(e,n,"'");i+=e.slice(n,o+1),n=o+1;continue}if(a==='"'){const o=this.findStringEnd(e,n,'"');i+=e.slice(n,o+1),n=o+1;continue}if(a==="`"){const o=this.findTemplateEnd(e,n);i+=e.slice(n,o+1),n=o+1;continue}if(a==="/"&&n+1<r){if(e[n+1]==="/"){const o=e.indexOf(`
|
|
26
|
+
`,n),c=o===-1?r:o;i+=e.slice(n,c),n=c;continue}else if(e[n+1]==="*"){const o=e.indexOf("*/",n+2),c=o===-1?r:o+2;i+=e.slice(n,c),n=c;continue}}this.matchesPropName(e,n,t)?(i+=`__getProp('${t}')`,n+=t.length):(i+=a,n++)}return i}findStringEnd(e,t,i){let n=t+1;for(;n<e.length;){if(e[n]===i&&e[n-1]!=="\\")return n;e[n]==="\\"&&n++,n++}return e.length-1}findTemplateEnd(e,t){let i=t+1,n=0;for(;i<e.length;){const r=e[i];if(r==="`"&&n===0)return i;r==="$"&&i+1<e.length&&e[i+1]==="{"?(n++,i++):r==="}"&&n>0?n--:r==="\\"&&i++,i++}return e.length-1}matchesPropName(e,t,i){if(t+i.length>e.length||e.substr(t,i.length)!==i)return!1;const r=t>0?e[t-1]:"",a=t+i.length<e.length?e[t+i.length]:"",o=t===0||!/[a-zA-Z0-9_$]/.test(r),c=t+i.length===e.length||!/[a-zA-Z0-9_$]/.test(a);if(!o||!c||r==="."||a===".")return!1;const l=e.slice(t+i.length);if(/^\s*[=:]/.test(l))return!1;const p=e.slice(Math.max(0,t-20),t);return!/[a-zA-Z0-9_$]\s*\.\s*$/.test(p)}extractFunctionNames(e){return z.getInstance().extractFunctionNames(e)}storeFunctionForComponent(e,t,i){this.componentFunctions.has(e)||this.componentFunctions.set(e,new Map),this.componentFunctions.get(e).set(t,i),window[e]||(window[e]={}),window[e][t]=i}getComponentFunctions(e){return this.componentFunctions.get(e)}destroy(){if(this.updateTimeouts){for(const e of this.updateTimeouts.values())clearTimeout(e);this.updateTimeouts.clear()}}}class Ls{stateManager;componentManager;expressionEvaluator;textNodeManager;observer;listeners=new WeakMap;pendingBindings=[];pendingTextNodes=[];applyingUpdates=!1;elementCache=new WeakMap;batchedUpdates=new Set;processingRAF=null;updateQueue=new Map;eventDelegation=new ne;processedElements=new WeakSet;loopManager;templateRenderer;BOOL_REFLECTED={checked:"checked",disabled:"disabled",hidden:"hidden",readonly:"readOnly",required:"required",multiple:"multiple",selected:"selected",autofocus:"autofocus",autoplay:"autoplay",controls:"controls",defer:"defer",loop:"loop",muted:"muted",open:"open",reversed:"reversed",async:"async",default:"default",formnovalidate:"formNoValidate",novalidate:"noValidate",allowfullscreen:"allowFullscreen",capture:"capture",itemscope:"itemScope"};lastValueCache=new WeakMap;stringValueCache=new W(500);refBindings=new WeakMap;constructor(e,t,i){this.stateManager=e,this.componentManager=t,this.expressionEvaluator=i,this.textNodeManager=new ks(i,e),this.textNodeManager.componentManager=this.componentManager,this.componentManager.setDOMBindingManager(this),this.setupMutationObserver(),this.eventDelegation.setupEventDelegation(),this.loopManager=new Bt(e,i),this.loopManager.setDependencies(t,this),this.loopManager.eventDelegation=this.eventDelegation,this.eventDelegation.setDependencies(this.componentManager,this.expressionEvaluator,this.loopManager),this.templateRenderer=new Qe(i)}refreshComponentElement(e,t){this.elementCache.delete(e),this.processedElements.delete(e);const i=[...this.componentManager.componentStack];this.componentManager.componentStack=["app"],t!=="app"&&this.componentManager.componentStack.push(t);try{const n=this.componentManager.buildComponentContextWithProps(t,e);this.processElementInContext(e,n,t,!0),this.walkComponentChildren(e,t),this.refreshComponentTextNodes(e,t)}finally{this.componentManager.componentStack=i}}refreshComponentTextNodes(e,t){const i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:a=>{const o=a;return!o.textContent||!d.MUSTACHE_PATTERN.test(o.textContent)||v.isTextNodeInsideScript(o)||this.isTextNodeInsideLoopItem(o)||v.getComponentForNode(o)!==t?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let n;const r=[];for(;n=i.nextNode();)r.push(n);r.forEach(a=>{this.textNodeManager.cleanupTextNode(a),this.textNodeManager.cleanupTextNode(a),this.textNodeManager.processTextNode(a,t)})}walkComponentChildren(e,t){const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const o=a;return v.getElementComponent(o)!==t?NodeFilter.FILTER_REJECT:o===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}});let n;const r=[];for(;n=i.nextNode();){const a=n;r.push(a)}r.forEach(a=>{this.elementCache.delete(a),this.processedElements.delete(a);const o=this.componentManager.buildComponentContextWithProps(t,e);this.processElementInContext(a,o,t,!0)})}createSpreadDirectiveBinding(e,t,i){const n=`spread_${Date.now()}_${Math.random()}`,r=_.parseSpreadDirective(t);if(r.spreads.length===0&&r.objects.length===0){console.warn(`Invalid pp-spread directive: ${t}`);return}const a=new Set,o=()=>{if(!document.contains(e)){this.stateManager.removeSubscription(n);return}try{const p=this.componentManager.buildComponentContextWithProps(i,e);this.clearSpreadAttributes(e,a);for(const h of r.spreads){const f=this.expressionEvaluator.evaluateExpression(h,p,i);f&&typeof f=="object"&&this.applySpreadObject(e,f,a)}for(const h of r.objects)this.applyObjectProperties(e,h,p,i,a)}catch(p){console.error(`Spread directive evaluation error for "${t}":`,p)}},c=new Set;for(const p of r.spreads)this.templateRenderer.dependencies(p,i,this.stateManager).forEach(f=>c.add(f));for(const p of r.objects)for(const h of p)this.templateRenderer.dependencies(h.value,i,this.stateManager).forEach(g=>c.add(g));const l={id:n,selector:"",dependencies:c,callback:o,element:e,component:i};this.stateManager.addSubscription(l),this.storeSpreadSubscription(e,n),o()}applyObjectProperties(e,t,i,n,r){for(const a of t)try{const o=this.expressionEvaluator.evaluateExpression(a.value,i,n);if(this.isEventProperty(a.key)){this.handleSpreadEventProperty(e,a.key,o);continue}const c=this.normalizeAttributeName(a.key);this.updateElementProperty(e,c,o),r.add(c)}catch(o){console.error(`Error evaluating object property "${a.key}: ${a.value}":`,o)}}applySpreadObject(e,t,i){for(const[n,r]of Object.entries(t))if(r!=null){if(this.isEventProperty(n)){this.handleSpreadEventProperty(e,n,r);continue}const a=this.normalizeAttributeName(n);(!e.hasAttribute(a)||i.has(a))&&(this.updateElementProperty(e,a,r),i.add(a))}}isEventProperty(e){return e.startsWith("on")&&e.length>2}handleSpreadEventProperty(e,t,i){const n=t.substring(2).toLowerCase();if(typeof i=="function"){const r=a=>{try{const o=v.getContextComponent(e),c=this.componentManager?.buildComponentContextWithProps(o,e)||{};i.call(c,a)}catch(o){console.error("Spread event handler error:",o)}};e.addEventListener(n,r),this.storeDirectEventListener(e,n,r);return}if(typeof i=="string"){const r=v.getContextComponent(e);this.eventDelegation.registerEventHandler(e,n,i,r)}}storeDirectEventListener(e,t,i){e.__directEventListeners||(e.__directEventListeners=[]),e.__directEventListeners.push({eventType:t,listener:i})}clearSpreadAttributes(e,t){for(const i of t)e.hasAttribute(i)&&e.removeAttribute(i);t.clear()}normalizeAttributeName(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}storeSpreadSubscription(e,t){e.__spreadSubscriptions||(e.__spreadSubscriptions=[]),e.__spreadSubscriptions.push(t)}setupMutationObserver(){this.observer=new MutationObserver(e=>{const t=e.filter(this.isRelevantMutation);if(t.length===0)return;const i=V.getInstance();for(const n of t)if(n.type==="childList"&&(n.removedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const a=r;this.cleanupRefBinding(a),a.querySelectorAll("[pp-ref]").forEach(l=>{this.cleanupRefBinding(l)}),i.invalidateElement(a);const c=a.getAttribute(d.ATTR_PREFIXES.COMPONENT);c&&i.invalidateByComponent(c)}}),n.addedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const o=r.getAttribute(d.ATTR_PREFIXES.COMPONENT);o&&i.invalidateByComponent(o)}})),n.type==="attributes"&&n.target){const r=n.target;i.invalidateElement(r);const a=r.getAttribute(d.ATTR_PREFIXES.COMPONENT);a&&i.invalidateByComponent(a)}this.processMutationsBatch(t)}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0,attributeFilter:[d.ATTR_PREFIXES.COMPONENT]})}isRelevantMutation=e=>{if(this.applyingUpdates&&e.type==="attributes")return!1;if(e.type==="childList"||e.type==="characterData")return!0;if(e.type==="attributes"){const t=e.attributeName;return t===d.ATTR_PREFIXES.COMPONENT||t!==null&&ue.isEventAttribute(t)}return!1};processElement(e,t=!0){if(e===document.body){const n=Array.from(document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}]`)).sort((r,a)=>{const o=v.getElementDepth(r),c=v.getElementDepth(a);return o-c});this.processElementsBatch([e],t),n.forEach(r=>{this.processElementsBatch([r],t)}),t&&this.loopManager.processPendingTemplates()}else this.processElementsBatch([e],t)}processElementsBatch(e,t=!0){for(const i of e)this.processSingleElement(i,t);t&&(e.forEach(i=>{this.componentManager.executePhpScripts(i)}),this.processPendingBindings())}processSingleElement(e,t){const i=v.getElementComponent(e),n=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let r;n?n==="app"?r="app":n==="parent"?r=v.getParentOfComponent(i,e):r=n:r=v.getParentComponentForElement(e);const a=this.componentManager.componentStack.length;i!=="app"&&this.componentManager.pushComponent(i),this.componentManager.setupProps(e,r),t&&this.componentManager.executePhpScripts(e),this.processLoopTemplates(e,i);const o=t?this.componentManager.buildComponentContextWithProps(i,e):{};for(this.processElementInContext(e,o,i,t),this.walkDOM(e,o,i,t);this.componentManager.componentStack.length>a;)this.componentManager.popComponent()}processLoopTemplates(e,t){this.getDirectComponentTemplates(e,t).forEach(n=>{this.loopManager.queueTemplate(n,t)})}getDirectComponentTemplates(e,t){const i=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const o=a;return o!==e&&o.hasAttribute(d.ATTR_PREFIXES.COMPONENT)?NodeFilter.FILTER_REJECT:o.tagName==="TEMPLATE"&&o.hasAttribute("pp-for")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let r;for(;r=n.nextNode();)i.push(r);return i}walkDOM(e,t,i,n){const r=ce.getInstance(),a=`walkDOM_${i}_${n}`,o=r.getCachedTraversal(e,a,()=>{const p=r.traverseElementsAndText(e,h=>{if(h===e||h.tagName.toLowerCase()==="script"||this.loopManager.isLoopItem(h))return!1;let f=h.parentElement;for(;f&&f!==e;){if(this.loopManager.isLoopItem(f))return!1;f=f.parentElement}return!(v.getElementComponent(h)!==i||this.processedElements.has(h))},h=>{if(!h.textContent||!d.MUSTACHE_PATTERN.test(h.textContent)||v.isTextNodeInsideScript(h)||this.isTextNodeInsideLoopItem(h))return!1;const f=h.parentElement;if(f){const g=v.getContextComponent(f),m=v.getComponentForNode(h);if(g!==i&&m!==i)return!1}else if(v.getComponentForNode(h)!==i)return!1;return!0});return[...p.textNodes,...p.elements]}),c=[],l=[];o.forEach(p=>{if(p.nodeType===Node.TEXT_NODE)c.push(p);else if(p.nodeType===Node.ELEMENT_NODE){const h=p;if(h.hasAttribute("pp-ref")&&n){const f=h.getAttribute("pp-ref");this.createRefBinding(h,f,i),h.removeAttribute("pp-ref")}l.push(h),this.processedElements.add(h)}}),c.forEach(p=>{const h=p.parentElement,f=h?v.getContextComponent(h):i;n?this.textNodeManager.processTextNode(p,f):this.pendingTextNodes.push({textNode:p,component:f})}),l.forEach(p=>{this.processElementInContext(p,t,i,n)})}isTextNodeInsideLoopItem(e){let t=e.parentElement;for(;t&&t!==document.body;){if(this.loopManager.isLoopItem(t))return!0;t=t.parentElement}return!1}processElementInContext(e,t,i,n){if(e.hasAttribute("pp-ref")){const l=e.getAttribute("pp-ref");n&&this.createRefBinding(e,l,i),e.removeAttribute("pp-ref")}if(e.hasAttribute(d.ATTR_PREFIXES.SPREAD)){const l=e.getAttribute(d.ATTR_PREFIXES.SPREAD);n&&this.createSpreadDirectiveBinding(e,l,i),e.removeAttribute(d.ATTR_PREFIXES.SPREAD)}if(this.loopManager.isLoopItem(e)||this.isElementInLoopItem(e))return;const r=this.extractDomMustacheBindings(e),a=this.elementCache.get(e),o=this.getElementHash(e);if(a&&a.hash===o&&this.isCacheValid(a)&&n){this.applyBindingsFromCache(e,a,t);return}const c={bindings:r,component:i,listeners:[],lastProcessed:Date.now(),hash:o};n?this.applyBindings(e,r,t,i):r.forEach((l,p)=>{this.pendingBindings.push({element:e,property:p,expression:l,component:i})}),this.setupEventBindings(e,i),this.elementCache.set(e,c)}createRefBinding(e,t,i){try{const n=_.decodeEntities(t),r=_.isSingleExpression(n)||n,a=v.getContextComponent(e),o=this.componentManager.buildComponentContextWithProps(a,e);try{const c=this.expressionEvaluator.evaluateExpression(r,o,a);if(typeof c=="function"){const l=c;this.refBindings.set(e,{element:e,callback:l,component:a}),l(e)}else if(c&&typeof c=="object"&&"current"in c){const l=c;this.refBindings.set(e,{element:e,refObject:l,component:a}),l.current=e}else console.warn(`⚠️ pp-ref expression did not return a ref object or callback: ${r}`,c)}catch(c){console.error(`❌ Failed to evaluate ref "${r}":`,c)}}catch(n){console.error(`❌ Failed to create ref binding for "${t}":`,n)}}isElementInLoopItem(e){let t=e;for(;t;){if(this.loopManager.isLoopItem(t))return!0;t=t.parentElement}return!1}extractDomMustacheBindings(e){const t=new Map,i=e.attributes,n=this.elementCache.get(e),r=e.getAttribute(d.ATTR_PREFIXES.CONTEXT),a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT),o=a&&this.componentManager?.hasStoredProps(e),c=r&&a&&r!==a;for(let l=0;l<i.length;l++){const p=i[l];if(!(p.name===d.ATTR_PREFIXES.COMPONENT||p.name===d.ATTR_PREFIXES.CONTEXT||p.name==="key"||ue.isEventAttribute(p.name))&&!(n&&n.bindings.has(p.name))&&p.value){const h=d.MUSTACHE_PATTERN.test(p.value),f=_.decodeEntities(p.value),g=d.MUSTACHE_PATTERN.test(f);if(h||g){if(this.looksLikeSerializedObject(f))continue;const m=_.extractExpressions(f),E=v.getContextComponent(e);if(m.length===0&&(h||g)){console.error(`
|
|
27
|
+
❌ Malformed mustache expression in attribute "${p.name}":`),console.error(` Value: ${f}`),console.error(" Element:",e),console.error(` Component: ${E}`),console.error(" 💡 The expression has mustache syntax {} but couldn't be parsed"),console.error(` 💡 Common causes: unmatched quotes, unclosed braces, invalid syntax
|
|
28
|
+
`),o||c&&v.shouldBeDirectBinding(e,p.name)?t.set(p.name,f):c||t.set(p.name,f);continue}for(const y of m){const S=Ps.validate(y,E);S.valid||(console.error(`
|
|
29
|
+
❌ Invalid expression in attribute "${p.name}":`),console.error(` Expression: ${y}`),console.error(` Original HTML: ${p.value}`),console.error(` Decoded: ${f}`),console.error(" Element:",e),console.error(` Component: ${E}`),S.errors.forEach(N=>{console.error(` ⚠️ ${N}`)}),console.error(" 💡 Hint: Check your quotes and syntax in conditional expressions"),console.error(` 💡 Example: class="{isActive ? 'text-blue-500' : 'text-gray-500'}"
|
|
30
|
+
`)),S.warnings.length>0&&(console.warn(`
|
|
31
|
+
⚠️ Expression warnings in attribute "${p.name}":`),console.warn(` Expression: ${y}`),console.warn(" Element:",e),S.warnings.forEach(N=>{console.warn(` • ${N}`)}))}o||c&&v.shouldBeDirectBinding(e,p.name)?t.set(p.name,f):c||t.set(p.name,f)}}}return t}applyBindings(e,t,i,n){t.forEach((r,a)=>{this.createMustacheBinding(e,a,r)}),this.setupEventBindings(e,n)}applyBindingsFromCache(e,t,i){t.bindings.forEach((n,r)=>{try{const a=this.componentManager.buildComponentContextWithProps(t.component,e),o=this.templateRenderer.render(n,a,t.component);this.updateElementProperty(e,r,o)}catch(a){console.error(`Cached binding evaluation error for "${n}":`,a)}})}createMustacheBinding(e,t,i){const n=`mustache_${Date.now()}_${Math.random()}`;let r;const a=e.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(a&&this.componentManager?.hasStoredProps(e)){const f=this.componentManager.elementProps.get(e);(f?Array.from(f.keys()):[]).some(E=>i.includes(E))?r=a:r=v.getContextComponent(e)}else r=v.getContextComponent(e);e.removeAttribute(t);const o=new Set;this.templateRenderer.dependencies(i,r,this.stateManager).forEach(f=>o.add(f));const l=this.findComponentElementForMustacheBinding(e,r);l&&this.componentManager&&this.componentManager.getComponentPropDependencies(l,r).forEach(g=>o.add(g));const p=()=>{if(!document.contains(e)){this.stateManager.removeSubscription(n);return}try{const f=r===a?e:l||void 0,g=this.componentManager.buildComponentContextWithProps(r,f),m=this.templateRenderer.render(i,g,r);this.scheduleElementUpdate(e,t,m)}catch(f){console.error(`Mustache binding evaluation error for "${i}":`,f)}},h={id:n,selector:"",dependencies:o,callback:p,element:e,component:r};this.stateManager.addSubscription(h),p()}findComponentElementForMustacheBinding(e,t){if(e.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(d.ATTR_PREFIXES.COMPONENT)===t)return n;n=n.parentElement}const r=document.querySelectorAll(`[${d.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const a of r)if(this.componentManager&&this.componentManager.hasStoredProps(a))return a;return r[0]||null}setupEventBindings(e,t){for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i];if(ue.isEventAttribute(n.name)){const r=n.name.substring(2),a=v.getContextComponent(e);this.eventDelegation.registerEventHandler(e,r,n.value,a),e.removeAttribute(n.name)}}}scheduleElementUpdate(e,t,i){if(this.isCriticalProperty(t)){this.updateElementProperty(e,t,i);return}this.updateQueue.has(e)||(this.updateQueue.set(e,new Set),this.batchedUpdates.add(e)),this.updateQueue.get(e).add(t),this.processingRAF||(this.processingRAF=requestAnimationFrame(()=>{this.processBatchedElementUpdates()})),e[`__pending_${t}`]=i}isCriticalProperty(e){return["textContent","innerHTML","value","checked","selected","disabled","class","className","style","hidden","display"].includes(e)}processBatchedElementUpdates(){this.applyingUpdates=!0;try{for(const e of this.batchedUpdates){const t=this.updateQueue.get(e);if(t)for(const i of t){const n=e[`__pending_${i}`];this.updateElementProperty(e,i,n),delete e[`__pending_${i}`]}}}finally{this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF=null,this.applyingUpdates=!1}}updateElementProperty(e,t,i){const n=this.lastValueCache.get(e);if(n&&this.isSameValue(n.get(t),i))return;const r=this.applyingUpdates;this.applyingUpdates=!0;try{switch(t){case"textContent":const a=this.cachedValueToString(i);e.textContent!==a&&(e.textContent=a);break;case"innerHTML":const o=this.cachedValueToString(i);e.innerHTML!==o&&(e.innerHTML=o);break;case"value":const c=this.cachedValueToString(i);e instanceof HTMLOptionElement?e.value!==c&&(e.value=c,e.setAttribute("value",c)):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.value!==c&&(e.value=c);break;case"selectedIndex":if(e instanceof HTMLSelectElement){const p=Number(i);e.selectedIndex!==p&&(e.selectedIndex=p)}break;case"checked":case"disabled":case"hidden":case"readonly":case"required":case"multiple":case"selected":case"autofocus":case"autoplay":case"controls":case"defer":case"loop":case"muted":case"open":case"reversed":case"async":case"default":case"formnovalidate":case"novalidate":case"allowfullscreen":case"capture":case"itemscope":this.setBooleanProperty(e,t,i);break;case"indeterminate":if(e instanceof HTMLInputElement&&e.type==="checkbox"){const p=!!i;e.indeterminate!==p&&(e.indeterminate=p)}break;case"class":case"className":const l=this.cachedValueToString(i);e instanceof SVGElement?e.getAttribute("class")!==l&&e.setAttribute("class",l):e.className!==l&&(e.className=l);break;case"htmlFor":case"for":if(e instanceof HTMLLabelElement){const p=this.cachedValueToString(i);e.htmlFor!==p&&(e.htmlFor=p)}break;case"style":if(e instanceof HTMLElement)if(typeof i=="object"&&i&&!Array.isArray(i))this.updateStyleObject(e,i);else{const p=this.cachedValueToString(i);e.style.cssText!==p&&(e.style.cssText=p)}break;case"tabIndex":if(e instanceof HTMLElement){const p=i==null?-1:Number(i);e.tabIndex!==p&&(e.tabIndex=p)}break;case"contentEditable":if(e instanceof HTMLElement){const p=i===!0?"true":i===!1?"false":String(i);e.contentEditable!==p&&(e.contentEditable=p)}break;case"draggable":if(e instanceof HTMLElement){const p=i===!0,h=p?"true":"false";e.draggable!==p&&(e.draggable=p,e.setAttribute("draggable",h))}break;case"spellcheck":if(e instanceof HTMLElement){const p=!!i,h=p?"true":"false";e.spellcheck!==p&&(e.spellcheck=p,e.setAttribute("spellcheck",h))}break;case"src":case"href":case"action":case"alt":case"title":case"placeholder":case"id":case"name":case"type":case"method":case"target":case"rel":case"pattern":case"accept":case"autocomplete":case"enctype":case"wrap":case"download":case"ping":case"referrerpolicy":case"crossorigin":case"integrity":case"loading":case"decoding":case"srcset":case"sizes":case"dir":case"lang":case"translate":case"role":this.setStringAttribute(e,t,i);break;case"min":case"max":case"step":case"maxLength":case"minLength":case"size":case"rows":case"cols":case"rowSpan":case"colSpan":this.setNumericAttribute(e,t,i);break;default:t.startsWith("aria-")?this.setAriaAttribute(e,t,i):t.startsWith("data-")?this.setDataAttribute(e,t,i):this.setGenericAttribute(e,t,i);break}this.updateValueCache(e,t,i)}catch(a){console.error(`Failed to update property "${t}" on element:`,e,a)}finally{this.applyingUpdates=r}}looksLikeSerializedObject(e){if(!e.startsWith("{")||!e.endsWith("}"))return!1;try{const t=JSON.parse(e);return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length>0}catch{return!1}}cachedValueToString(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(e==null)return"";if(typeof e=="boolean")return e?"true":"false";if(this.stringValueCache.has(e))return this.stringValueCache.get(e);const t=re(e);return this.stringValueCache.set(e,t),t}isSameValue(e,t){if(e===t)return!0;if(typeof e=="object"&&typeof t=="object"){if(e===null||t===null)return e===t;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((i,n)=>i===t[n]);if(this.isStyleObject(e)&&this.isStyleObject(t)){const i=Object.keys(e),n=Object.keys(t);return i.length===n.length&&i.every(r=>e[r]===t[r])}}return!1}isStyleObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}setBooleanProperty(e,t,i){const n=!!i;this.setBooleanProp(e,t,i)||(n&&!e.hasAttribute(t)?e.setAttribute(t,""):!n&&e.hasAttribute(t)&&e.removeAttribute(t))}updateStyleObject(e,t){const i=this.lastValueCache.get(e)?.get("style"),n=i&&typeof i=="object"?i:{};for(const[r,a]of Object.entries(t))n[r]!==a&&(e.style[r]=a)}setStringAttribute(e,t,i){const n=this.cachedValueToString(i);e.getAttribute(t)!==n&&(i==null?e.removeAttribute(t):e.setAttribute(t,n))}setNumericAttribute(e,t,i){const n=String(i);e.getAttribute(t)!==n&&(i==null?e.removeAttribute(t):e.setAttribute(t,n))}setAriaAttribute(e,t,i){const n=this.cachedValueToString(i);e.getAttribute(t)!==n&&(i==null||i===!1?e.removeAttribute(t):e.setAttribute(t,n))}setDataAttribute(e,t,i){const n=this.cachedValueToString(i);e.getAttribute(t)!==n&&(i==null?e.removeAttribute(t):e.setAttribute(t,n))}setGenericAttribute(e,t,i){const n=this.cachedValueToString(i);e.getAttribute(t)!==n&&(i==null||i===!1?e.removeAttribute(t):e.setAttribute(t,n))}updateValueCache(e,t,i){this.lastValueCache.has(e)||this.lastValueCache.set(e,new Map),this.lastValueCache.get(e).set(t,i)}setBooleanProp(e,t,i){const n=this.BOOL_REFLECTED[t];if(!n)return!1;const r=!!i;return e instanceof HTMLElement&&n in e?(e[n]!==r&&(e[n]=r),!0):(r?e.hasAttribute(t)||e.setAttribute(t,""):e.hasAttribute(t)&&e.removeAttribute(t),!0)}processPendingBindings(){const e=[...this.pendingBindings];this.pendingBindings=[];const t=new Map;for(const i of e)t.has(i.component)||t.set(i.component,[]),t.get(i.component).push(i);for(const[i,n]of t){const r=[...this.componentManager.componentStack];i!=="app"?this.componentManager.componentStack=["app",i]:this.componentManager.componentStack=["app"];for(const a of n)try{if(!document.contains(a.element))continue;this.createMustacheBinding(a.element,a.property,a.expression)}catch(o){console.error(`❌ Failed to create binding for ${i}:`,o)}this.componentManager.componentStack=r}this.processTextNodesPending()}processTextNodesPending(){const e=new Map;for(const t of this.pendingTextNodes)e.has(t.component)||e.set(t.component,[]),e.get(t.component).push(t);this.pendingTextNodes=[];for(const[t,i]of e){const n=[...this.componentManager.componentStack];t!=="app"?this.componentManager.componentStack=["app",t]:this.componentManager.componentStack=["app"];for(const{textNode:r,component:a}of i)if(document.contains(r))try{this.textNodeManager.processTextNode(r,a)}catch(o){console.error(`❌ Failed to process text node for ${a}:`,o)}this.componentManager.componentStack=n}}processMutationsBatch(e){const t=new Set,i=new Set,n=new Set,r=new Set,a=new Set;for(const o of e)if(o.type==="childList"&&(o.addedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE)t.add(c);else if(c.nodeType===Node.TEXT_NODE){const l=c;l.textContent&&d.MUSTACHE_PATTERN.test(l.textContent)&&a.add(l)}}),o.removedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE)i.add(c);else if(c.nodeType===Node.TEXT_NODE){const l=c;l.textContent&&d.MUSTACHE_PATTERN.test(l.textContent)&&(document.contains(l)||this.textNodeManager.cleanupTextNode(l))}})),o.type==="attributes"&&o.target&&r.add(o.target),o.type==="characterData"&&o.target){const c=o.target;c.textContent&&d.MUSTACHE_PATTERN.test(c.textContent)&&a.add(c)}for(const o of i)(t.has(o)||document.contains(o))&&(n.add(o),i.delete(o),t.has(o)&&t.delete(o));i.size>0&&this.cleanupElementsBatch(Array.from(i)),t.size>0&&this.processElementsBatch(Array.from(t)),a.size>0&&this.processTextNodesBatch(Array.from(a)),r.size>0&&this.rebindChangedElements(Array.from(r))}processTextNodesBatch(e){const t=new Map;for(const i of e){const n=v.getComponentForNode(i);t.has(n)||t.set(n,[]),t.get(n).push(i)}for(const[i,n]of t)n.forEach(r=>{this.textNodeManager.processTextNode(r,i)})}rebindChangedElements(e){e.forEach(t=>{this.processElementBindings(t,!0)})}processElementBindings(e,t=!0){const i=this.extractDomMustacheBindings(e),n=v.getElementComponent(e);i.forEach((r,a)=>{t?this.createMustacheBinding(e,a,r):this.pendingBindings.push({element:e,property:a,expression:r,component:n})}),t&&this.setupEventBindings(e,n)}cleanupElementsBatch(e){e.forEach(t=>this.cleanupElement(t))}cleanupElement(e){this.cleanupRefBinding(e),this.stateManager.subscriptionManager?.cleanupElement(e);const t=this.listeners.get(e)||[];for(const{type:l,fn:p}of t)e.removeEventListener(l,p);this.listeners.delete(e),this.elementCache.delete(e),this.processedElements.delete(e),this.componentManager.cleanupProps(e);const i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let n;for(;n=i.nextNode();)this.textNodeManager.cleanupTextNode(n);e.tagName==="TEMPLATE"&&e.hasAttribute("pp-for")&&this.loopManager.cleanupTemplate(e),e.querySelectorAll("template[pp-for]").forEach(l=>{this.loopManager.cleanupTemplate(l)});const a=e.__directEventListeners;a&&(a.forEach(({eventType:l,listener:p})=>{e.removeEventListener(l,p)}),delete e.__directEventListeners);const o=e.__spreadEventHandlers;o&&(o.forEach(l=>{window.__spreadHandlers&&window.__spreadHandlers.delete(l)}),delete e.__spreadEventHandlers);const c=e.__spreadSubscriptions;c&&(c.forEach(l=>{this.stateManager.removeSubscription(l)}),delete e.__spreadSubscriptions),this.lastValueCache.delete(e),this.stringValueCache.size()>1500&&this.stringValueCache.clear()}cleanupRefBinding(e){const t=this.refBindings.get(e);if(t){try{t.callback?t.callback(null):t.refObject&&(t.refObject.current=null)}catch(i){console.error("Failed to cleanup ref:",i)}this.refBindings.delete(e)}}getElementHash(e){const t=[];for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i];(n.name===d.ATTR_PREFIXES.COMPONENT||ue.isEventAttribute(n.name)||n.value&&d.MUSTACHE_PATTERN.test(n.value))&&t.push(`${n.name}=${n.value}`)}return t.sort().join("|")}isCacheValid(e){return Date.now()-e.lastProcessed<3e4}refreshAllBindings(){this.elementCache=new WeakMap,this.processedElements=new WeakSet,this.processElement(document.body,!0)}destroy(){this.observer&&this.observer.disconnect(),document.querySelectorAll("[pp-ref]").forEach(t=>{this.cleanupRefBinding(t)}),this.eventDelegation.cleanup(),this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF&&cancelAnimationFrame(this.processingRAF),this.elementCache=new WeakMap,this.listeners=new WeakMap,this.processedElements=new WeakSet,this.loopManager.destroy()}}class ne{static eventCache=null;delegatedEvents=new Map;elementHandlers=new WeakMap;handlerCache=new W(200);componentManager;expressionEvaluator;loopManager;setupEvents=new Set;static getAllAvailableEvents(){if(ne.eventCache)return ne.eventCache;const e=new Set,t=["click","input","change","submit","focus","blur","keydown","keyup","mousedown","mouseup","mouseover","mouseout"];try{Object.getOwnPropertyNames(HTMLElement.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(n){console.warn("Could not get HTMLElement events:",n),t.forEach(r=>e.add(r))}try{Object.getOwnPropertyNames(Document.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(n){console.warn("Could not get Document events:",n)}try{Object.getOwnPropertyNames(Window.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(n){console.warn("Could not get Window events:",n)}try{Object.getOwnPropertyNames(Element.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(n){console.warn("Could not get Element events:",n)}return new Set(["beforeunload","unload","pagehide","pageshow","popstate","hashchange","storage","message","messageerror","offline","online","languagechange","rejectionhandled","unhandledrejection","afterprint","beforeprint","devicemotion","deviceorientation","deviceorientationabsolute"]).forEach(n=>e.delete(n)),ne.eventCache=e,e}setupEventDelegation(){const e=["click","input","change","submit","focus","blur"];for(const t of e)this.ensureEventSetup(t)}getEventOptions(e){const t={capture:!0,passive:!1};return["wheel","touchstart","touchmove","touchend","scroll","mousewheel"].includes(e)&&(t.passive=!0),(e==="focusin"||e==="focusout")&&(t.capture=!1),t}isEventSupported(e){return ne.getAllAvailableEvents().has(e.toLowerCase())}getAllSupportedEvents(){return Array.from(ne.getAllAvailableEvents()).sort()}getDelegatedEvents(){return Array.from(this.delegatedEvents.keys()).sort()}setDependencies(e,t,i){this.componentManager=e,this.expressionEvaluator=t,this.loopManager=i}createDelegatedListener(e){return t=>{const i=t.target;if(!i)return;const n=this.findHandler(i,e);n&&this.executeHandler(n.handler,n.element,t)}}registerEventHandler(e,t,i,n){const r=t.toLowerCase();if(this.ensureEventSetup(r),!this.isEventSupported(r)){console.warn(`⚠️ Event type "${t}" is not supported`);return}const a=e.getAttribute(d.ATTR_PREFIXES.CONTEXT);let o=n;if(a)if(a==="app")o="app";else if(a==="parent"){const h=v.getElementComponent(e);o=v.getParentOfComponent(h,e)}else o=a;this.elementHandlers.has(e)||this.elementHandlers.set(e,new Map);const c=this.elementHandlers.get(e),l={code:i,component:o};c.set(r,l);const p=this.delegatedEvents.get(r);p?p.elements.add(e):(console.warn(`⚠️ No delegated listener for ${r}, attaching directly`),this.attachDirectListener(e,r,l))}ensureEventSetup(e){if(!this.setupEvents.has(e)){if(!this.isEventSupported(e)){console.warn(`⚠️ Attempting to setup unsupported event: ${e}`);return}try{const t=this.createDelegatedListener(e),i=this.getEventOptions(e);document.addEventListener(e,t,i),this.setupEvents.add(e),this.delegatedEvents.set(e,{listener:t,elements:new WeakSet})}catch(t){console.error(`Failed to setup event delegation for ${e}:`,t),this.setupEvents.delete(e)}}}findHandler(e,t){let i=e;for(;i;){const n=this.elementHandlers.get(i);if(n?.has(t))return{handler:n.get(t),element:i};i=i.parentElement}return null}compileHandler(e,t){const i=`${t}:${e}`;if(this.handlerCache.has(i))return this.handlerCache.get(i);let n=e;e.includes("this")&&(n=n.replace(/\bthis\b/g,"thisElement")),e.includes("event")&&(n=n.replace(/\bevent\b/g,"eventObject"));const r=new Function("eventObject","thisElement","context",`
|
|
32
32
|
try {
|
|
33
33
|
with(context) {
|
|
34
34
|
${n}
|
|
@@ -36,7 +36,7 @@ Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=1
|
|
|
36
36
|
} catch(error) {
|
|
37
37
|
console.error('Event handler execution error:', error);
|
|
38
38
|
console.error('Handler code:', ${JSON.stringify(e)});
|
|
39
|
-
console.error('Component:', '${
|
|
39
|
+
console.error('Component:', '${t}');
|
|
40
40
|
console.error('Available context keys:', Object.keys(context));
|
|
41
41
|
}
|
|
42
|
-
`);return this.handlerCache.set(i,r),r}executeHandler(e,
|
|
42
|
+
`);return this.handlerCache.set(i,r),r}executeHandler(e,t,i){if(!this.componentManager||!this.expressionEvaluator){console.warn("EventDelegationManager dependencies not set");return}try{const n=t.getAttribute(d.ATTR_PREFIXES.CONTEXT);let r=e.component,a=e.component;if(n)if(n==="app")r="app",a="app";else if(n==="parent"){const g=v.getElementComponent(t);r=v.getParentOfComponent(g,t),a=r}else r=n,a=n;else{let g=t,m=null;for(;g&&g!==document.body;){const E=g.getAttribute(d.ATTR_PREFIXES.COMPONENT);if(E){const y=g.__originalComponentName;if(E===e.component||y===e.component){m=g;break}}g=g.parentElement}if(m){const E=m.getAttribute(d.ATTR_PREFIXES.CONTEXT);if(E)if(E==="app")r="app",a="app";else if(E==="parent"){const y=v.getElementComponent(m);r=v.getParentOfComponent(y,m),a=r}else r=E,a=E}for(g=t;g&&g!==document.body;){const E=g.__uniqueComponentName,y=g.__originalComponentName;if(E){r=E,(!m||!m.__originalComponentName)&&(a=y||e.component);break}g=g.parentElement}}const o=n==="app"||n==="parent"||r==="app"||a==="app",c=r==="app"||a==="app",l=v.findElementForComponent(t,a);let p;if(o||c)p=this.componentManager.buildComponentContextWithProps(a,l||void 0);else if(p=this.componentManager.buildRestrictedComponentContext(a,!1),l){const g=this.componentManager.evaluateProps(l);Object.assign(p,g)}if(r!==a&&window[r]){const g=window[r];for(const[m,E]of Object.entries(g))typeof E!="function"&&!(m in p)&&(p[m]=E)}const h={...p};for(const[g,m]of Object.entries(p))typeof m=="function"&&"__pphp_key"in m&&(h[g]=m.value);const f=this.loopManager?.getLoopContextForElement(t);if(f){const g={};for(const[m,E]of Object.entries(f)){if(typeof E=="function")continue;const y=`set${m.charAt(0).toUpperCase()}${m.slice(1)}`,S=`${m}Getter`,N=y in f&&typeof f[y]=="function",k=S in f&&typeof f[S]=="function";if(N||k)if(k){const L=f[S],Me=typeof L.value<"u"?L.value:L();g[m]=Me}else{const L=h[m];L!==void 0?g[m]=L:g[m]=E}else g[m]=E}p={...h,...g}}else p=h;e.compiledFn||(e.compiledFn=this.compileHandler(e.code,a)),e.compiledFn&&e.compiledFn(i,t,p)}catch(n){console.error("💥 Event handler execution failed:",n),console.error("Handler code:",e.code),console.error("Handler component:",e.component)}}attachDirectListener(e,t,i){const n=r=>{this.executeHandler(i,e,r)};e.addEventListener(t,n),e[`__${t}_listener`]=n}removeEventHandler(e,t){const i=this.elementHandlers.get(e);i&&(i.delete(t),i.size===0&&this.elementHandlers.delete(e));const n=this.delegatedEvents.get(t);n&&n.elements.delete?.(e);const r=e[`__${t}_listener`];r&&(e.removeEventListener(t,r),delete e[`__${t}_listener`])}cleanup(){for(const[e,t]of this.delegatedEvents)document.removeEventListener(e,t.listener,!0);this.delegatedEvents.clear(),this.handlerCache.clear(),this.setupEvents.clear()}}class Fs{stateManager=new Ms;expressionEvaluator=new le;componentManager=new Os(this.stateManager);domBindingManager=new Ls(this.stateManager,this.componentManager,this.expressionEvaluator);initialized=!1;hydrationDone=!1;hydrationResolve;hydrationPromise;hydrationCallbacks=new Set;constructor(){document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.initialize()):setTimeout(()=>this.initialize(),0),this.hydrationPromise=new Promise(e=>this.hydrationResolve=e)}initialize(){this.initialized||(this.initialized=!0,this.markHydrationStart(),this.componentManager.setExpressionEvaluator(this.expressionEvaluator),this.componentManager.executePhpScripts(document.body),this.domBindingManager.processElement(document.body,!0),this.domBindingManager.processPendingBindings(),Promise.resolve().then(()=>{requestAnimationFrame(()=>{this.markHydrated()})}))}reinitialize(){this.componentManager.setExpressionEvaluator(this.expressionEvaluator),this.componentManager.executePhpScripts(document.body),this.domBindingManager.processElement(document.body,!0),this.domBindingManager.processPendingBindings()}cleanup(e){e?(this.stateManager.clearComponentState(e),this.stateManager.clearComponentSubscriptions(e),window[e]&&delete window[e]):(this.stateManager.clearState(),this.stateManager.clearSubscriptions(),this.hydrationCallbacks.clear()),this.stateManager.invalidateContextCache()}ref(e=null){return{current:e}}hydrated(){return this.hydrationPromise}onHydrated(e){this.hydrationDone?queueMicrotask(e):this.hydrationCallbacks.add(e)}get isHydrated(){return this.hydrationDone}markHydrationStart(){document.dispatchEvent(new CustomEvent("pp:hydrationstart"))}markHydrated(){if(!this.hydrationDone){this.hydrationDone=!0,this.hydrationResolve();for(const e of this.hydrationCallbacks)try{e()}catch{}this.hydrationCallbacks.clear(),document.dispatchEvent(new CustomEvent("pp:hydrated",{detail:{at:performance.now()}}))}}state(e,t){const i=this.componentManager.getCurrentComponent();let n,r;typeof e=="string"&&arguments.length===2?(n=e,r=t):typeof e=="string"&&arguments.length===1?this.looksLikeVariableName(e)?(n=e,r=void 0):(console.warn("pp.state() called with string that doesn't look like variable name:",e),n="unknownState",r=e):(console.warn("pp.state() called without explicit key - this should be handled by AST transformation"),n="unknownState",r=e),r&&typeof r=="function"&&"__pphp_key"in r&&(r=r.value);let a;const o=this.getLoopExecutionContext();if(o){const h=this.generateLoopInstanceId(o);a=`${i}.${h}.${n}`}else a=`${i}.${n}`;this.stateManager.hasState(a)||this.stateManager.setInitialState(a,r);const c=(()=>this.stateManager.getState()[a]),l=new Proxy(c,{get(h,f,g){if(f==="__pphp_key"||f==="__pphp_fullKey"||f==="__pphp_component"||f==="value"||f==="valueOf"||f==="toString")return Reflect.get(h,f,g);const m=h();if(m!=null){if(f in Object(m)){const E=m[f];return typeof E=="function"?E.bind(m):E}return Reflect.get(h,f,g)}},has(h,f){if(f==="__pphp_key"||f==="__pphp_fullKey"||f==="__pphp_component"||f==="value"||f==="valueOf"||f==="toString")return Reflect.has(h,f);const g=h();return g!=null&&f in Object(g)?!0:Reflect.has(h,f)},apply(h,f,g){return Reflect.apply(h,f,g)}});Object.defineProperty(l,"__pphp_key",{value:n,enumerable:!1,writable:!1}),Object.defineProperty(l,"__pphp_fullKey",{value:a,enumerable:!1,writable:!1}),Object.defineProperty(l,"__pphp_component",{value:i,enumerable:!1,writable:!1}),Object.defineProperty(l,"value",{get:()=>this.stateManager.getState()[a],enumerable:!0,configurable:!0}),c.valueOf=()=>this.stateManager.getState()[a],c.toString=()=>re(this.stateManager.getState()[a]);const p=h=>{const f=this.stateManager.getState()[a],g=typeof h=="function"?h(f):h;this.stateManager.setState(a,g)};return this.createComponentScopedGlobals(i,n,l,p),[l,p]}currentLoopContext=null;getLoopExecutionContext(){return this.currentLoopContext}generateLoopInstanceId(e){const i=Object.keys(e).sort().map(r=>{const a=e[r];return a&&typeof a=="object"&&"id"in a?`${r}:${a.id}`:`${r}:${JSON.stringify(a)}`});return`loop_${btoa(i.join("|")).replace(/[^a-zA-Z0-9]/g,"").substring(0,8)}`}looksLikeVariableName(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&e.length<=50&&!e.includes(" ")&&!Ee.has(e)}effect(e,t){const i=`effect_${Date.now()}_${Math.random()}`,n=this.componentManager.getCurrentComponent();let r,a=!1,o,c;if(arguments.length===1)o="always",c={immediate:!0,detectDeps:!0};else if(Array.isArray(t)){const p=this.extractDependencyNames(t,n);p.length===0?(o="once",c={deps:p,immediate:!0}):(o="deps",c={deps:p,immediate:!0})}else{const p={immediate:!0,...t||{}};if(!p.deps||p.deps.length===0)o="always",c={immediate:p.immediate,detectDeps:!0};else{const h=this.extractDependencyNames(p.deps,n);o="deps",c={deps:h,immediate:p.immediate,detectDeps:p.detectDeps}}}const l=()=>{a||this.stateManager.onDOMUpdateComplete(()=>{if(!a){if(r&&typeof r=="function")try{r()}catch(p){console.error("Effect cleanup error:",p)}try{r=e()}catch(p){console.error("Effect callback error:",p)}}})};switch(o){case"always":const p=["*"],h={id:i,selector:"",dependencies:new Set(p),callback:l,component:n};this.stateManager.addSubscription(h);break;case"once":break;case"deps":const f=this.resolveDependencies(c.deps,n);if(f.length){const g={id:i,selector:"",dependencies:new Set(f),callback:l,component:n};this.stateManager.addSubscription(g)}break}return c.immediate!==!1&&l(),()=>{if(a=!0,r&&typeof r=="function")try{r()}catch(p){console.error("Effect cleanup error:",p)}this.stateManager.removeSubscription(i)}}extractDependencyNames(e,t){const i=[];for(const n of e)typeof n=="string"?i.push(n):typeof n=="function"&&n.__pphp_key?i.push(n.__pphp_key):console.warn("Invalid dependency in effect:",n);return i.filter(Boolean)}resolveDependencies(e,t){const i=[],n=this.stateManager.getState();for(const r of e)if(r.includes(".")){const a=r.split("."),o=a[0],c=a.slice(1).join("."),l=this.componentManager.getPropDependencies(o,t);if(l.length>0)i.push(...l);else{const p=je.findExistingStateKey(o,t,n);p?i.push(`${p}.${c}`):i.push(`${t}.${r}`)}}else{const a=this.componentManager.getPropDependencies(r,t);if(a.length>0)i.push(...a);else{const o=je.findExistingStateKey(r,t,n);o?i.push(o):i.push(`${t}.${r}`)}}return Array.from(new Set(i))}createComponentScopedGlobals(e,t,i,n){window[e]||(window[e]={});const r=`set${Dt(t)}`;Object.defineProperty(window[e],t,{get:()=>i.valueOf(),configurable:!0,enumerable:!0}),window[e][r]=n,window[e][`${t}Getter`]=i}}export{Fs as P};
|