create-prisma-php-app 4.2.13-beta → 4.2.14-beta
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 +1 @@
|
|
|
1
|
-
var ls=Object.defineProperty,us=(e,t,n)=>t in e?ls(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t,n)=>us(e,"symbol"!=typeof t?t+"":t,n),ps=[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],Tt=[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],hs="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",wt="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Ye={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"},Je="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",fs={5:Je,"5module":Je+" export import",6:Je+" const class extends export import super"},ds=/^in(stanceof)?$/,ms=new RegExp("["+wt+"]"),gs=new RegExp("["+wt+hs+"]");function et(e,t){for(var n=65536,s=0;s<t.length;s+=2){if((n+=t[s])>e)return!1;if((n+=t[s+1])>=e)return!0}return!1}function te(e,t){return e<65?36===e:e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&ms.test(String.fromCharCode(e)):!1!==t&&et(e,Tt)))}function pe(e,t){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&gs.test(String.fromCharCode(e)):!1!==t&&(et(e,Tt)||et(e,ps)))))}var N=function(e,t){void 0===t&&(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 z(e,t){return new N(e,{beforeExpr:!0,binop:t})}var X={beforeExpr:!0},j={startsExpr:!0},ct={};function _(e,t){return void 0===t&&(t={}),t.keyword=e,ct[e]=new N(e,t)}var h={num:new N("num",j),regexp:new N("regexp",j),string:new N("string",j),name:new N("name",j),privateId:new N("privateId",j),eof:new N("eof"),bracketL:new N("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new N("]"),braceL:new N("{",{beforeExpr:!0,startsExpr:!0}),braceR:new N("}"),parenL:new N("(",{beforeExpr:!0,startsExpr:!0}),parenR:new N(")"),comma:new N(",",X),semi:new N(";",X),colon:new N(":",X),dot:new N("."),question:new N("?",X),questionDot:new N("?."),arrow:new N("=>",X),template:new N("template"),invalidTemplate:new N("invalidTemplate"),ellipsis:new N("...",X),backQuote:new N("`",j),dollarBraceL:new N("${",{beforeExpr:!0,startsExpr:!0}),eq:new N("=",{beforeExpr:!0,isAssign:!0}),assign:new N("_=",{beforeExpr:!0,isAssign:!0}),incDec:new N("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new N("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:z("||",1),logicalAND:z("&&",2),bitwiseOR:z("|",3),bitwiseXOR:z("^",4),bitwiseAND:z("&",5),equality:z("==/!=/===/!==",6),relational:z("</>/<=/>=",7),bitShift:z("<</>>/>>>",8),plusMin:new N("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:z("%",10),star:z("*",10),slash:z("/",10),starstar:new N("**",{beforeExpr:!0}),coalesce:z("??",1),_break:_("break"),_case:_("case",X),_catch:_("catch"),_continue:_("continue"),_debugger:_("debugger"),_default:_("default",X),_do:_("do",{isLoop:!0,beforeExpr:!0}),_else:_("else",X),_finally:_("finally"),_for:_("for",{isLoop:!0}),_function:_("function",j),_if:_("if"),_return:_("return",X),_switch:_("switch"),_throw:_("throw",X),_try:_("try"),_var:_("var"),_const:_("const"),_while:_("while",{isLoop:!0}),_with:_("with"),_new:_("new",{beforeExpr:!0,startsExpr:!0}),_this:_("this",j),_super:_("super",j),_class:_("class",j),_extends:_("extends",X),_export:_("export"),_import:_("import",j),_null:_("null",j),_true:_("true",j),_false:_("false",j),_in:_("in",{beforeExpr:!0,binop:7}),_instanceof:_("instanceof",{beforeExpr:!0,binop:7}),_typeof:_("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:_("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:_("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},H=/\r\n?|\n|\u2028|\u2029/,xs=new RegExp(H.source,"g");function Te(e){return 10===e||13===e||8232===e||8233===e}function At(e,t,n){void 0===n&&(n=e.length);for(var s=t;s<n;s++){var i=e.charCodeAt(s);if(Te(i))return s<n-1&&13===i&&10===e.charCodeAt(s+1)?s+2:s+1}return-1}var Pt=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,B=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,_t=Object.prototype,Es=_t.hasOwnProperty,Cs=_t.toString,we=Object.hasOwn||function(e,t){return Es.call(e,t)},xt=Array.isArray||function(e){return"[object Array]"===Cs.call(e)},Et=Object.create(null);function ue(e){return Et[e]||(Et[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function re(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}var bs=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,ke=function(e,t){this.line=e,this.column=t};ke.prototype.offset=function(e){return new ke(this.line,this.column+e)};var qe=function(e,t,n){this.start=t,this.end=n,null!==e.sourceFile&&(this.source=e.sourceFile)};function Nt(e,t){for(var n=1,s=0;;){var i=At(e,s,t);if(i<0)return new ke(n,t-s);++n,s=i}}var tt={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},Ct=!1;function ys(e){var t={};for(var n in tt)t[n]=e&&we(e,n)?e[n]:tt[n];if("latest"===t.ecmaVersion?t.ecmaVersion=1e8:null==t.ecmaVersion?(!Ct&&"object"==typeof console&&console.warn&&(Ct=!0,console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.")),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),null==t.allowReserved&&(t.allowReserved=t.ecmaVersion<5),(!e||null==e.allowHashBang)&&(t.allowHashBang=t.ecmaVersion>=14),xt(t.onToken)){var s=t.onToken;t.onToken=function(e){return s.push(e)}}return xt(t.onComment)&&(t.onComment=vs(t,t.onComment)),t}function vs(e,t){return function(n,s,i,r,a,o){var c={type:n?"Block":"Line",value:s,start:i,end:r};e.locations&&(c.loc=new qe(this,a,o)),e.ranges&&(c.range=[i,r]),t.push(c)}}var Ie=1,Ae=2,lt=4,kt=8,ut=16,It=32,ze=64,Mt=128,be=256,Me=512,Xe=Ie|Ae|be;function pt(e,t){return Ae|(e?lt:0)|(t?kt:0)}var Ve=0,ht=1,oe=2,Rt=3,Ot=4,Lt=5,F=function(e,t,n){this.options=e=ys(e),this.sourceFile=e.sourceFile,this.keywords=ue(fs[e.ecmaVersion>=6?6:"module"===e.sourceType?"5module":5]);var s="";!0!==e.allowReserved&&(s=Ye[e.ecmaVersion>=6?6:5===e.ecmaVersion?5:3],"module"===e.sourceType&&(s+=" await")),this.reservedWords=ue(s);var i=(s?s+" ":"")+Ye.strict;this.reservedWordsStrict=ue(i),this.reservedWordsStrictBind=ue(i+" "+Ye.strictBind),this.input=String(t),this.containsEsc=!1,n?(this.pos=n,this.lineStart=this.input.lastIndexOf("\n",n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(H).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=h.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="module"===e.sourceType,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),0===this.pos&&e.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(Ie),this.regexpState=null,this.privateNameStack=[]},se={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}};F.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)},se.inFunction.get=function(){return(this.currentVarScope().flags&Ae)>0},se.inGenerator.get=function(){return(this.currentVarScope().flags&kt)>0},se.inAsync.get=function(){return(this.currentVarScope().flags<)>0},se.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(be|Me))return!1;if(t&Ae)return(t<)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},se.allowSuper.get=function(){return(this.currentThisScope().flags&ze)>0||this.options.allowSuperOutsideMethod},se.allowDirectSuper.get=function(){return(this.currentThisScope().flags&Mt)>0},se.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},se.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(be|Me)||t&Ae&&!(t&ut))return!0}return!1},se.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&be)>0},F.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,s=0;s<e.length;s++)n=e[s](n);return n},F.parse=function(e,t){return new this(t,e).parse()},F.parseExpressionAt=function(e,t,n){var s=new this(n,e,t);return s.nextToken(),s.parseExpression()},F.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(F.prototype,se);var W=F.prototype,Ss=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;W.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){B.lastIndex=e,e+=B.exec(this.input)[0].length;var t=Ss.exec(this.input.slice(e));if(!t)return!1;if("use strict"===(t[1]||t[2])){B.lastIndex=e+t[0].length;var n=B.exec(this.input),s=n.index+n[0].length,i=this.input.charAt(s);return";"===i||"}"===i||H.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||"!"===i&&"="===this.input.charAt(s+1))}e+=t[0].length,B.lastIndex=e,e+=B.exec(this.input)[0].length,";"===this.input[e]&&e++}},W.eat=function(e){return this.type===e&&(this.next(),!0)},W.isContextual=function(e){return this.type===h.name&&this.value===e&&!this.containsEsc},W.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},W.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},W.canInsertSemicolon=function(){return this.type===h.eof||this.type===h.braceR||H.test(this.input.slice(this.lastTokEnd,this.start))},W.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},W.semicolon=function(){!this.eat(h.semi)&&!this.insertSemicolon()&&this.unexpected()},W.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},W.expect=function(e){this.eat(e)||this.unexpected()},W.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var Ke=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};W.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?"Assigning to rvalue":"Parenthesized pattern")}},W.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,s=e.doubleProto;if(!t)return n>=0||s>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),s>=0&&this.raiseRecoverable(s,"Redefinition of __proto__ property")},W.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")},W.isSimpleAssignTarget=function(e){return"ParenthesizedExpression"===e.type?this.isSimpleAssignTarget(e.expression):"Identifier"===e.type||"MemberExpression"===e.type};var T=F.prototype;T.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==h.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var s=0,i=Object.keys(this.undefinedExports);s<i.length;s+=1){var r=i[s];this.raiseRecoverable(this.undefinedExports[r].start,"Export '"+r+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var ft={kind:"loop"},Ts={kind:"switch"};T.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;B.lastIndex=this.pos;var t=B.exec(this.input),n=this.pos+t[0].length,s=this.input.charCodeAt(n);if(91===s||92===s)return!0;if(e)return!1;if(123===s||s>55295&&s<56320)return!0;if(te(s,!0)){for(var i=n+1;pe(s=this.input.charCodeAt(i),!0);)++i;if(92===s||s>55295&&s<56320)return!0;var r=this.input.slice(n,i);if(!ds.test(r))return!0}return!1},T.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;B.lastIndex=this.pos;var e,t=B.exec(this.input),n=this.pos+t[0].length;return!(H.test(this.input.slice(this.pos,n))||"function"!==this.input.slice(n,n+8)||n+8!==this.input.length&&(pe(e=this.input.charCodeAt(n+8))||e>55295&&e<56320))},T.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;B.lastIndex=this.pos;var n=B.exec(this.input),s=this.pos+n[0].length;if(H.test(this.input.slice(this.pos,s)))return!1;if(e){var i,r=s+5;if("using"!==this.input.slice(s,r)||r===this.input.length||pe(i=this.input.charCodeAt(r))||i>55295&&i<56320)return!1;B.lastIndex=r;var a=B.exec(this.input);if(a&&H.test(this.input.slice(r,r+a[0].length)))return!1}if(t){var o,c=s+2;if(!("of"!==this.input.slice(s,c)||c!==this.input.length&&(pe(o=this.input.charCodeAt(c))||o>55295&&o<56320)))return!1}var h=this.input.charCodeAt(s);return te(h,!0)||92===h},T.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},T.isUsing=function(e){return this.isUsingKeyword(!1,e)},T.parseStatement=function(e,t,n){var s,i=this.type,r=this.startNode();switch(this.isLet(e)&&(i=h._var,s="let"),i){case h._break:case h._continue:return this.parseBreakContinueStatement(r,i.keyword);case h._debugger:return this.parseDebuggerStatement(r);case h._do:return this.parseDoStatement(r);case h._for:return this.parseForStatement(r);case h._function:return e&&(this.strict||"if"!==e&&"label"!==e)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(r,!1,!e);case h._class:return e&&this.unexpected(),this.parseClass(r,!0);case h._if:return this.parseIfStatement(r);case h._return:return this.parseReturnStatement(r);case h._switch:return this.parseSwitchStatement(r);case h._throw:return this.parseThrowStatement(r);case h._try:return this.parseTryStatement(r);case h._const:case h._var:return s=s||this.value,e&&"var"!==s&&this.unexpected(),this.parseVarStatement(r,s);case h._while:return this.parseWhileStatement(r);case h._with:return this.parseWithStatement(r);case h.braceL:return this.parseBlock(!0,r);case h.semi:return this.parseEmptyStatement(r);case h._export:case h._import:if(this.options.ecmaVersion>10&&i===h._import){B.lastIndex=this.pos;var a=B.exec(this.input),o=this.pos+a[0].length,c=this.input.charCodeAt(o);if(40===c||46===c)return this.parseExpressionStatement(r,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),i===h._import?this.parseImport(r):this.parseExport(r,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(r,!0,!e);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return t&&"script"===this.options.sourceType&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),"await using"===l&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(r,!1,l),this.semicolon(),this.finishNode(r,"VariableDeclaration");var p=this.value,u=this.parseExpression();return i===h.name&&"Identifier"===u.type&&this.eat(h.colon)?this.parseLabeledStatement(r,p,u,e):this.parseExpressionStatement(r,u)}},T.parseBreakContinueStatement=function(e,t){var n="break"===t;this.next(),this.eat(h.semi)||this.insertSemicolon()?e.label=null:this.type!==h.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var s=0;s<this.labels.length;++s){var i=this.labels[s];if((null==e.label||i.name===e.label.name)&&(null!=i.kind&&(n||"loop"===i.kind)||e.label&&n))break}return s===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,n?"BreakStatement":"ContinueStatement")},T.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")},T.parseDoStatement=function(e){return this.next(),this.labels.push(ft),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(h._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(h.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},T.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(ft),this.enterScope(0),this.expect(h.parenL),this.type===h.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===h._var||this.type===h._const||n){var s=this.startNode(),i=n?"let":this.value;return this.next(),this.parseVar(s,!0,i),this.finishNode(s,"VariableDeclaration"),this.parseForAfterInit(e,s,t)}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(),"await using"===o&&this.next(),this.parseVar(c,!0,o),this.finishNode(c,"VariableDeclaration"),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,p=new Ke,u=this.start,d=t>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===h._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===h._in&&this.unexpected(t),e.await=!0):a&&this.options.ecmaVersion>=8&&(d.start!==u||l||"Identifier"!==d.type||"async"!==d.name?this.options.ecmaVersion>=9&&(e.await=!1):this.unexpected()),r&&a&&this.raise(d.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(d,!1,p),this.checkLValPattern(d),this.parseForIn(e,d)):(this.checkExpressionErrors(p,!0),t>-1&&this.unexpected(t),this.parseFor(e,d))},T.parseForAfterInit=function(e,t,n){return(this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&1===t.declarations.length?(this.options.ecmaVersion>=9&&(this.type===h._in?n>-1&&this.unexpected(n):e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},T.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,_e|(n?0:st),!1,t)},T.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(h._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")},T.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(h.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},T.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(h.braceL),this.labels.push(Ts),this.enterScope(0);for(var t,n=!1;this.type!==h.braceR;)if(this.type===h._case||this.type===h._default){var s=this.type===h._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),s?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,t.test=null),this.expect(h.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")},T.parseThrowStatement=function(e){return this.next(),H.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var ws=[];T.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t="Identifier"===e.type;return this.enterScope(t?It:0),this.checkLValPattern(e,t?Ot:oe),this.expect(h.parenR),e},T.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===h._catch){var t=this.startNode();this.next(),this.eat(h.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(h._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},T.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")},T.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(ft),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")},T.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")},T.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},T.parseLabeledStatement=function(e,t,n,s){for(var i=0,r=this.labels;i<r.length;i+=1){r[i].name===t&&this.raise(n.start,"Label '"+t+"' is already declared")}for(var a=this.type.isLoop?"loop":this.type===h._switch?"switch":null,o=this.labels.length-1;o>=0;o--){var c=this.labels[o];if(c.statementStart!==e.start)break;c.statementStart=this.start,c.kind=a}return this.labels.push({name:t,kind:a,statementStart:this.start}),e.body=this.parseStatement(s?-1===s.indexOf("label")?s+"label":s:"label"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")},T.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},T.parseBlock=function(e,t,n){for(void 0===e&&(e=!0),void 0===t&&(t=this.startNode()),t.body=[],this.expect(h.braceL),e&&this.enterScope(0);this.type!==h.braceR;){var s=this.parseStatement(null);t.body.push(s)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")},T.parseFor=function(e,t){return e.init=t,this.expect(h.semi),e.test=this.type===h.semi?null:this.parseExpression(),this.expect(h.semi),e.update=this.type===h.parenR?null:this.parseExpression(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")},T.parseForIn=function(e,t){var n=this.type===h._in;return this.next(),"VariableDeclaration"===t.type&&null!=t.declarations[0].init&&(!n||this.options.ecmaVersion<8||this.strict||"var"!==t.kind||"Identifier"!==t.declarations[0].id.type)&&this.raise(t.start,(n?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,n?"ForInStatement":"ForOfStatement")},T.parseVar=function(e,t,n,s){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(h.eq)?i.init=this.parseMaybeAssign(t):s||"const"!==n||this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of")?s||"using"!==n&&"await using"!==n||!(this.options.ecmaVersion>=17)||this.type===h._in||this.isContextual("of")?s||"Identifier"===i.id.type||t&&(this.type===h._in||this.isContextual("of"))?i.init=null:this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):this.raise(this.lastTokEnd,"Missing initializer in "+n+" declaration"):this.unexpected(),e.declarations.push(this.finishNode(i,"VariableDeclarator")),!this.eat(h.comma))break}return e},T.parseVarId=function(e,t){e.id="using"===t||"await using"===t?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,"var"===t?ht:oe,!1)};var _e=1,st=2,Ft=4;function As(e,t){var n=t.key.name,s=e[n],i="true";return"MethodDefinition"===t.type&&("get"===t.kind||"set"===t.kind)&&(i=(t.static?"s":"i")+t.kind),"iget"===s&&"iset"===i||"iset"===s&&"iget"===i||"sget"===s&&"sset"===i||"sset"===s&&"sget"===i?(e[n]="true",!1):!!s||(e[n]=i,!1)}function De(e,t){var n=e.computed,s=e.key;return!n&&("Identifier"===s.type&&s.name===t||"Literal"===s.type&&s.value===t)}T.parseFunction=function(e,t,n,s,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!s)&&(this.type===h.star&&t&st&&this.unexpected(),e.generator=this.eat(h.star)),this.options.ecmaVersion>=8&&(e.async=!!s),t&_e&&(e.id=t&Ft&&this.type!==h.name?null:this.parseIdent(),e.id&&!(t&st)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?ht:oe:Rt));var r=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(pt(e.async,e.generator)),t&_e||(e.id=this.type===h.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=r,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,t&_e?"FunctionDeclaration":"FunctionExpression")},T.parseFunctionParams=function(e){this.expect(h.parenL),e.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},T.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var s=this.enterClassBody(),i=this.startNode(),r=!1;for(i.body=[],this.expect(h.braceL);this.type!==h.braceR;){var a=this.parseClassElement(null!==e.superClass);a&&(i.body.push(a),"MethodDefinition"===a.type&&"constructor"===a.kind?(r&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),r=!0):a.key&&"PrivateIdentifier"===a.key.type&&As(s,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=n,this.next(),e.body=this.finishNode(i,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},T.parseClassElement=function(e){if(this.eat(h.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),s="",i=!1,r=!1,a="method",o=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(h.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===h.star?o=!0:s="static"}if(n.static=o,!s&&t>=8&&this.eatContextual("async")&&(!this.isClassElementNameStart()&&this.type!==h.star||this.canInsertSemicolon()?s="async":r=!0),!s&&(t>=9||!r)&&this.eat(h.star)&&(i=!0),!s&&!r&&!i){var c=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=c:s=c)}if(s?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=s,this.finishNode(n.key,"Identifier")):this.parseClassElementName(n),t<13||this.type===h.parenL||"method"!==a||i||r){var l=!n.static&&De(n,"constructor"),p=l&&e;l&&"method"!==a&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=l?"constructor":a,this.parseClassMethod(n,i,r,p)}else this.parseClassField(n);return n},T.isClassElementNameStart=function(){return this.type===h.name||this.type===h.privateId||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword},T.parseClassElementName=function(e){this.type===h.privateId?("constructor"===this.value&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},T.parseClassMethod=function(e,t,n,s){var i=e.key;"constructor"===e.kind?(t&&this.raise(i.start,"Constructor can't be a generator"),n&&this.raise(i.start,"Constructor can't be an async method")):e.static&&De(e,"prototype")&&this.raise(i.start,"Classes may not have a static property named prototype");var r=e.value=this.parseMethod(t,n,s);return"get"===e.kind&&0!==r.params.length&&this.raiseRecoverable(r.start,"getter should have no params"),"set"===e.kind&&1!==r.params.length&&this.raiseRecoverable(r.start,"setter should have exactly one param"),"set"===e.kind&&"RestElement"===r.params[0].type&&this.raiseRecoverable(r.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")},T.parseClassField=function(e){return De(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&De(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(h.eq)?(this.enterScope(Me|ze),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")},T.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(be|ze);this.type!==h.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")},T.parseClassId=function(e,t){this.type===h.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,oe,!1)):(!0===t&&this.unexpected(),e.id=null)},T.parseClassSuper=function(e){e.superClass=this.eat(h._extends)?this.parseExprSubscripts(null,!1):null},T.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},T.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var s=this.privateNameStack.length,i=0===s?null:this.privateNameStack[s-1],r=0;r<n.length;++r){var a=n[r];we(t,a.name)||(i?i.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}},T.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")},T.parseExport=function(e,t){if(this.next(),this.eat(h.star))return this.parseExportAllDeclaration(e,t);if(this.eat(h._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),"VariableDeclaration"===e.declaration.type?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,s=e.specifiers;n<s.length;n+=1){var i=s[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),"Literal"===i.local.type&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")},T.parseExportDeclaration=function(e){return this.parseStatement(null)},T.parseExportDefaultDeclaration=function(){var e;if(this.type===h._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,_e|Ft,!1,e)}if(this.type===h._class){var n=this.startNode();return this.parseClass(n,"nullableID")}var s=this.parseMaybeAssign();return this.semicolon(),s},T.checkExport=function(e,t,n){e&&("string"!=typeof t&&(t="Identifier"===t.type?t.name:t.value),we(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)},T.checkPatternExport=function(e,t){var n=t.type;if("Identifier"===n)this.checkExport(e,t,t.start);else if("ObjectPattern"===n)for(var s=0,i=t.properties;s<i.length;s+=1){var r=i[s];this.checkPatternExport(e,r)}else if("ArrayPattern"===n)for(var a=0,o=t.elements;a<o.length;a+=1){var c=o[a];c&&this.checkPatternExport(e,c)}else"Property"===n?this.checkPatternExport(e,t.value):"AssignmentPattern"===n?this.checkPatternExport(e,t.left):"RestElement"===n&&this.checkPatternExport(e,t.argument)},T.checkVariableExport=function(e,t){if(e)for(var n=0,s=t;n<s.length;n+=1){var i=s[n];this.checkPatternExport(e,i.id)}},T.shouldParseExportStatement=function(){return"var"===this.type.keyword||"const"===this.type.keyword||"class"===this.type.keyword||"function"===this.type.keyword||this.isLet()||this.isAsyncFunction()},T.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")},T.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(h.braceL);!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;t.push(this.parseExportSpecifier(e))}return t},T.parseImport=function(e){return this.next(),this.type===h.string?(e.specifiers=ws,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===h.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")},T.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,oe),this.finishNode(e,"ImportSpecifier")},T.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,oe),this.finishNode(e,"ImportDefaultSpecifier")},T.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,oe),this.finishNode(e,"ImportNamespaceSpecifier")},T.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===h.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(h.comma)))return e;if(this.type===h.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(h.braceL);!this.eat(h.braceR);){if(t)t=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;e.push(this.parseImportSpecifier())}return e},T.parseWithClause=function(){var e=[];if(!this.eat(h._with))return e;this.expect(h.braceL);for(var t={},n=!0;!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;var s=this.parseImportAttribute(),i="Identifier"===s.key.type?s.key.name:s.key.value;we(t,i)&&this.raiseRecoverable(s.key.start,"Duplicate attribute key '"+i+"'"),t[i]=!0,e.push(s)}return e},T.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===h.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved),this.expect(h.colon),this.type!==h.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")},T.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===h.string){var e=this.parseLiteral(this.value);return bs.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)},T.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},T.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&"ExpressionStatement"===e.type&&"Literal"===e.expression.type&&"string"==typeof e.expression.value&&('"'===this.input[e.start]||"'"===this.input[e.start])};var Q=F.prototype;Q.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&"await"===e.name&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var s=0,i=e.properties;s<i.length;s+=1){var r=i[s];this.toAssignable(r,t),"RestElement"===r.type&&("ArrayPattern"===r.argument.type||"ObjectPattern"===r.argument.type)&&this.raise(r.argument.start,"Unexpected token")}break;case"Property":"init"!==e.kind&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),"AssignmentPattern"===e.argument.type&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":"="!==e.operator&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,n);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else n&&this.checkPatternErrors(n,!0);return e},Q.toAssignableList=function(e,t){for(var n=e.length,s=0;s<n;s++){var i=e[s];i&&this.toAssignable(i,t)}if(n){var r=e[n-1];6===this.options.ecmaVersion&&t&&r&&"RestElement"===r.type&&"Identifier"!==r.argument.type&&this.unexpected(r.argument.start)}return e},Q.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")},Q.parseRestBinding=function(){var e=this.startNode();return this.next(),6===this.options.ecmaVersion&&this.type!==h.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")},Q.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case h.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(h.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case h.braceL:return this.parseObj(!0)}return this.parseIdent()},Q.parseBindingList=function(e,t,n,s){for(var i=[],r=!0;!this.eat(e);)if(r?r=!1:this.expect(h.comma),t&&this.type===h.comma)i.push(null);else{if(n&&this.afterTrailingComma(e))break;if(this.type===h.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),i.push(a),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}i.push(this.parseAssignableListItem(s))}return i},Q.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},Q.parseBindingListItem=function(e){return e},Q.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(h.eq))return n;var s=this.startNodeAt(e,t);return s.left=n,s.right=this.parseMaybeAssign(),this.finishNode(s,"AssignmentPattern")},Q.checkLValSimple=function(e,t,n){void 0===t&&(t=Ve);var s=t!==Ve;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(s?"Binding ":"Assigning to ")+e.name+" in strict mode"),s&&(t===oe&&"let"===e.name&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),n&&(we(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==Lt&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":s&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return s&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(s?"Binding":"Assigning to")+" rvalue")}},Q.checkLValPattern=function(e,t,n){switch(void 0===t&&(t=Ve),e.type){case"ObjectPattern":for(var s=0,i=e.properties;s<i.length;s+=1){var r=i[s];this.checkLValInnerPattern(r,t,n)}break;case"ArrayPattern":for(var a=0,o=e.elements;a<o.length;a+=1){var c=o[a];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},Q.checkLValInnerPattern=function(e,t,n){switch(void 0===t&&(t=Ve),e.type){case"Property":this.checkLValInnerPattern(e.value,t,n);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,n);break;case"RestElement":this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var J=function(e,t,n,s,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=s,this.generator=!!i},O={b_stat:new J("{",!1),b_expr:new J("{",!0),b_tmpl:new J("${",!1),p_stat:new J("(",!1),p_expr:new J("(",!0),q_tmpl:new J("`",!0,!0,(function(e){return e.tryReadTemplateToken()})),f_stat:new J("function",!1),f_expr:new J("function",!0),f_expr_gen:new J("function",!0,!1,null,!0),f_gen:new J("function",!1,!1,null,!0)},Pe=F.prototype;Pe.initialContext=function(){return[O.b_stat]},Pe.curContext=function(){return this.context[this.context.length-1]},Pe.braceIsBlock=function(e){var t=this.curContext();return t===O.f_expr||t===O.f_stat||(e!==h.colon||t!==O.b_stat&&t!==O.b_expr?e===h._return||e===h.name&&this.exprAllowed?H.test(this.input.slice(this.lastTokEnd,this.start)):e===h._else||e===h.semi||e===h.eof||e===h.parenR||e===h.arrow||(e===h.braceL?t===O.b_stat:e!==h._var&&e!==h._const&&e!==h.name&&!this.exprAllowed):!t.isExpr)},Pe.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if("function"===t.token)return t.generator}return!1},Pe.updateContext=function(e){var t,n=this.type;n.keyword&&e===h.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Pe.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},h.parenR.updateContext=h.braceR.updateContext=function(){if(1!==this.context.length){var e=this.context.pop();e===O.b_stat&&"function"===this.curContext().token&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}else this.exprAllowed=!0},h.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?O.b_stat:O.b_expr),this.exprAllowed=!0},h.dollarBraceL.updateContext=function(){this.context.push(O.b_tmpl),this.exprAllowed=!0},h.parenL.updateContext=function(e){var t=e===h._if||e===h._for||e===h._with||e===h._while;this.context.push(t?O.p_stat:O.p_expr),this.exprAllowed=!0},h.incDec.updateContext=function(){},h._function.updateContext=h._class.updateContext=function(e){!e.beforeExpr||e===h._else||e===h.semi&&this.curContext()!==O.p_stat||e===h._return&&H.test(this.input.slice(this.lastTokEnd,this.start))||(e===h.colon||e===h.braceL)&&this.curContext()===O.b_stat?this.context.push(O.f_stat):this.context.push(O.f_expr),this.exprAllowed=!1},h.colon.updateContext=function(){"function"===this.curContext().token&&this.context.pop(),this.exprAllowed=!0},h.backQuote.updateContext=function(){this.curContext()===O.q_tmpl?this.context.pop():this.context.push(O.q_tmpl),this.exprAllowed=!1},h.star.updateContext=function(e){if(e===h._function){var t=this.context.length-1;this.context[t]===O.f_expr?this.context[t]=O.f_expr_gen:this.context[t]=O.f_gen}this.exprAllowed=!0},h.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==h.dot&&("of"===this.value&&!this.exprAllowed||"yield"===this.value&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var w=F.prototype;function Vt(e){return"Identifier"===e.type||"ParenthesizedExpression"===e.type&&Vt(e.expression)}function nt(e){return"MemberExpression"===e.type&&"PrivateIdentifier"===e.property.type||"ChainExpression"===e.type&&nt(e.expression)||"ParenthesizedExpression"===e.type&&nt(e.expression)}w.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&"SpreadElement"===e.type||this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var s,i=e.key;switch(i.type){case"Identifier":s=i.name;break;case"Literal":s=String(i.value);break;default:return}var r=e.kind;if(this.options.ecmaVersion>=6)return void("__proto__"===s&&"init"===r&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=i.start):this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),t.proto=!0));var a=t[s="$"+s];if(a)("init"===r?this.strict&&a.init||a.get||a.set:a.init||a[r])&&this.raiseRecoverable(i.start,"Redefinition of property");else a=t[s]={init:!1,get:!1,set:!1};a[r]=!0}},w.parseExpression=function(e,t){var n=this.start,s=this.startLoc,i=this.parseMaybeAssign(e,t);if(this.type===h.comma){var r=this.startNodeAt(n,s);for(r.expressions=[i];this.eat(h.comma);)r.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(r,"SequenceExpression")}return i},w.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var s=!1,i=-1,r=-1,a=-1;t?(i=t.parenthesizedAssign,r=t.trailingComma,a=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Ke,s=!0);var o=this.start,c=this.startLoc;(this.type===h.parenL||this.type===h.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait="await"===e);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,o,c)),this.type.isAssign){var p=this.startNodeAt(o,c);return p.operator=this.value,this.type===h.eq&&(l=this.toAssignable(l,!1,t)),s||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===h.eq?this.checkLValPattern(l):this.checkLValSimple(l),p.left=l,this.next(),p.right=this.parseMaybeAssign(e),a>-1&&(t.doubleProto=a),this.finishNode(p,"AssignmentExpression")}return s&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),r>-1&&(t.trailingComma=r),l},w.parseMaybeConditional=function(e,t){var n=this.start,s=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(this.eat(h.question)){var r=this.startNodeAt(n,s);return r.test=i,r.consequent=this.parseMaybeAssign(),this.expect(h.colon),r.alternate=this.parseMaybeAssign(e),this.finishNode(r,"ConditionalExpression")}return i},w.parseExprOps=function(e,t){var n=this.start,s=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&"ArrowFunctionExpression"===i.type?i:this.parseExprOp(i,n,s,-1,e)},w.parseExprOp=function(e,t,n,s,i){var r=this.type.binop;if(null!=r&&(!i||this.type!==h._in)&&r>s){var a=this.type===h.logicalOR||this.type===h.logicalAND,o=this.type===h.coalesce;o&&(r=h.logicalAND.binop);var c=this.value;this.next();var l=this.start,p=this.startLoc,u=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,p,r,i),d=this.buildBinary(t,n,e,u,c,a||o);return(a&&this.type===h.coalesce||o&&(this.type===h.logicalOR||this.type===h.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(d,t,n,s,i)}return e},w.buildBinary=function(e,t,n,s,i,r){"PrivateIdentifier"===s.type&&this.raise(s.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(e,t);return a.left=n,a.operator=i,a.right=s,this.finishNode(a,r?"LogicalExpression":"BinaryExpression")},w.parseMaybeUnary=function(e,t,n,s){var i,r=this.start,a=this.startLoc;if(this.isContextual("await")&&this.canAwait)i=this.parseAwait(s),t=!0;else if(this.type.prefix){var o=this.startNode(),c=this.type===h.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,c,s),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(o.argument):this.strict&&"delete"===o.operator&&Vt(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):"delete"===o.operator&&nt(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,i=this.finishNode(o,c?"UpdateExpression":"UnaryExpression")}else if(t||this.type!==h.privateId){if(i=this.parseExprSubscripts(e,s),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(r,a);l.operator=this.value,l.prefix=!1,l.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(l,"UpdateExpression")}}else(s||0===this.privateNameStack.length)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==h._in&&this.unexpected();return n||!this.eat(h.starstar)?i:t?void this.unexpected(this.lastTokStart):this.buildBinary(r,a,i,this.parseMaybeUnary(null,!1,!1,s),"**",!1)},w.parseExprSubscripts=function(e,t){var n=this.start,s=this.startLoc,i=this.parseExprAtom(e,t);if("ArrowFunctionExpression"===i.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd))return i;var r=this.parseSubscripts(i,n,s,!1,t);return e&&"MemberExpression"===r.type&&(e.parenthesizedAssign>=r.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=r.start&&(e.parenthesizedBind=-1),e.trailingComma>=r.start&&(e.trailingComma=-1)),r},w.parseSubscripts=function(e,t,n,s,i){for(var r=this.options.ecmaVersion>=8&&"Identifier"===e.type&&"async"===e.name&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start==5&&this.potentialArrowAt===e.start,a=!1;;){var o=this.parseSubscript(e,t,n,s,r,a,i);if(o.optional&&(a=!0),o===e||"ArrowFunctionExpression"===o.type){if(a){var c=this.startNodeAt(t,n);c.expression=o,o=this.finishNode(c,"ChainExpression")}return o}e=o}},w.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(h.arrow)},w.parseSubscriptAsyncArrow=function(e,t,n,s){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,s)},w.parseSubscript=function(e,t,n,s,i,r,a){var o=this.options.ecmaVersion>=11,c=o&&this.eat(h.questionDot);s&&c&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(h.bracketL);if(l||c&&this.type!==h.parenL&&this.type!==h.backQuote||this.eat(h.dot)){var p=this.startNodeAt(t,n);p.object=e,l?(p.property=this.parseExpression(),this.expect(h.bracketR)):this.type===h.privateId&&"Super"!==e.type?p.property=this.parsePrivateIdent():p.property=this.parseIdent("never"!==this.options.allowReserved),p.computed=!!l,o&&(p.optional=c),e=this.finishNode(p,"MemberExpression")}else if(!s&&this.eat(h.parenL)){var u=new Ke,d=this.yieldPos,m=this.awaitPos,f=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var g=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1,u);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(u,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=d,this.awaitPos=m,this.awaitIdentPos=f,this.parseSubscriptAsyncArrow(t,n,g,a);this.checkExpressionErrors(u,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=f||this.awaitIdentPos;var E=this.startNodeAt(t,n);E.callee=e,E.arguments=g,o&&(E.optional=c),e=this.finishNode(E,"CallExpression")}else if(this.type===h.backQuote){(c||r)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var x=this.startNodeAt(t,n);x.tag=e,x.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(x,"TaggedTemplateExpression")}return e},w.parseExprAtom=function(e,t,n){this.type===h.slash&&this.readRegexp();var s,i=this.potentialArrowAt===this.start;switch(this.type){case h._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),s=this.startNode(),this.next(),this.type===h.parenL&&!this.allowDirectSuper&&this.raise(s.start,"super() call outside constructor of a subclass"),this.type!==h.dot&&this.type!==h.bracketL&&this.type!==h.parenL&&this.unexpected(),this.finishNode(s,"Super");case h._this:return s=this.startNode(),this.next(),this.finishNode(s,"ThisExpression");case h.name:var r=this.start,a=this.startLoc,o=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&"async"===c.name&&!this.canInsertSemicolon()&&this.eat(h._function))return this.overrideContext(O.f_expr),this.parseFunction(this.startNodeAt(r,a),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(h.arrow))return this.parseArrowExpression(this.startNodeAt(r,a),[c],!1,t);if(this.options.ecmaVersion>=8&&"async"===c.name&&this.type===h.name&&!o&&(!this.potentialArrowInForAwait||"of"!==this.value||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(h.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,a),[c],!0,t)}return c;case h.regexp:var l=this.value;return(s=this.parseLiteral(l.value)).regex={pattern:l.pattern,flags:l.flags},s;case h.num:case h.string:return this.parseLiteral(this.value);case h._null:case h._true:case h._false:return(s=this.startNode()).value=this.type===h._null?null:this.type===h._true,s.raw=this.type.keyword,this.next(),this.finishNode(s,"Literal");case h.parenL:var p=this.start,u=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(u)&&(e.parenthesizedAssign=p),e.parenthesizedBind<0&&(e.parenthesizedBind=p)),u;case h.bracketL:return s=this.startNode(),this.next(),s.elements=this.parseExprList(h.bracketR,!0,!0,e),this.finishNode(s,"ArrayExpression");case h.braceL:return this.overrideContext(O.b_expr),this.parseObj(!1,e);case h._function:return s=this.startNode(),this.next(),this.parseFunction(s,0);case h._class:return this.parseClass(this.startNode(),!1);case h._new:return this.parseNew();case h.backQuote:return this.parseTemplate();case h._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},w.parseExprAtomDefault=function(){this.unexpected()},w.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===h.parenL&&!e)return this.parseDynamicImport(t);if(this.type===h.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name="import",t.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(t)}this.unexpected()},w.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(h.parenR)?e.options=null:(this.expect(h.comma),this.afterTrailingComma(h.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(h.parenR)||(this.expect(h.comma),this.afterTrailingComma(h.parenR)||this.unexpected())));else if(!this.eat(h.parenR)){var t=this.start;this.eat(h.comma)&&this.eat(h.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")},w.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),"meta"!==e.property.name&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),"module"!==this.options.sourceType&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")},w.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),110===t.raw.charCodeAt(t.raw.length-1)&&(t.bigint=null!=t.value?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")},w.parseParenExpression=function(){this.expect(h.parenL);var e=this.parseExpression();return this.expect(h.parenR),e},w.shouldParseArrow=function(e){return!this.canInsertSemicolon()},w.parseParenAndDistinguishExpression=function(e,t){var n,s=this.start,i=this.startLoc,r=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,c=this.startLoc,l=[],p=!0,u=!1,d=new Ke,m=this.yieldPos,f=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==h.parenR;){if(p?p=!1:this.expect(h.comma),r&&this.afterTrailingComma(h.parenR,!0)){u=!0;break}if(this.type===h.ellipsis){a=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}l.push(this.parseMaybeAssign(!1,d,this.parseParenItem))}var g=this.lastTokEnd,E=this.lastTokEndLoc;if(this.expect(h.parenR),e&&this.shouldParseArrow(l)&&this.eat(h.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=m,this.awaitPos=f,this.parseParenArrowList(s,i,l,t);(!l.length||u)&&this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(d,!0),this.yieldPos=m||this.yieldPos,this.awaitPos=f||this.awaitPos,l.length>1?((n=this.startNodeAt(o,c)).expressions=l,this.finishNodeAt(n,"SequenceExpression",g,E)):n=l[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var x=this.startNodeAt(s,i);return x.expression=n,this.finishNode(x,"ParenthesizedExpression")}return n},w.parseParenItem=function(e){return e},w.parseParenArrowList=function(e,t,n,s){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,s)};var Ps=[];w.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===h.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),"target"!==e.property.name&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var s=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),s,i,!0,!1),this.eat(h.parenL)?e.arguments=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Ps,this.finishNode(e,"NewExpression")},w.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===h.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value.replace(/\r\n?/g,"\n"),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),n.tail=this.type===h.backQuote,this.finishNode(n,"TemplateElement")},w.parseTemplate=function(e){void 0===e&&(e={});var t=e.isTagged;void 0===t&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var s=this.parseTemplateElement({isTagged:t});for(n.quasis=[s];!s.tail;)this.type===h.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(h.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(h.braceR),n.quasis.push(s=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,"TemplateLiteral")},w.isAsyncProp=function(e){return!e.computed&&"Identifier"===e.key.type&&"async"===e.key.name&&(this.type===h.name||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===h.star)&&!H.test(this.input.slice(this.lastTokEnd,this.start))},w.parseObj=function(e,t){var n=this.startNode(),s=!0,i={};for(n.properties=[],this.next();!this.eat(h.braceR);){if(s)s=!1;else if(this.expect(h.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(h.braceR))break;var r=this.parseProperty(e,t);e||this.checkPropClash(r,i,t),n.properties.push(r)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")},w.parseProperty=function(e,t){var n,s,i,r,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(h.ellipsis))return e?(a.argument=this.parseIdent(!1),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(a.argument=this.parseMaybeAssign(!1,t),this.type===h.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(e||t)&&(i=this.start,r=this.startLoc),e||(n=this.eat(h.star)));var o=this.containsEsc;return this.parsePropertyName(a),!e&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(a)?(s=!0,n=this.options.ecmaVersion>=9&&this.eat(h.star),this.parsePropertyName(a)):s=!1,this.parsePropertyValue(a,e,n,s,i,r,t,o),this.finishNode(a,"Property")},w.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n="get"===e.kind?0:1;if(e.value.params.length!==n){var s=e.value.start;"get"===e.kind?this.raiseRecoverable(s,"getter should have no params"):this.raiseRecoverable(s,"setter should have exactly one param")}else"set"===e.kind&&"RestElement"===e.value.params[0].type&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")},w.parsePropertyValue=function(e,t,n,s,i,r,a,o){(n||s)&&this.type===h.colon&&this.unexpected(),this.eat(h.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),e.kind="init"):this.options.ecmaVersion>=6&&this.type===h.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,s),e.kind="init"):t||o||!(this.options.ecmaVersion>=5)||e.computed||"Identifier"!==e.key.type||"get"!==e.key.name&&"set"!==e.key.name||this.type===h.comma||this.type===h.braceR||this.type===h.eq?this.options.ecmaVersion>=6&&!e.computed&&"Identifier"===e.key.type?((n||s)&&this.unexpected(),this.checkUnreserved(e.key),"await"===e.key.name&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,r,this.copyNode(e.key)):this.type===h.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,r,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected():((n||s)&&this.unexpected(),this.parseGetterSetter(e))},w.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(h.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(h.bracketR),e.key;e.computed=!1}return e.key=this.type===h.num||this.type===h.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved)},w.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},w.parseMethod=function(e,t,n){var s=this.startNode(),i=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(s),this.options.ecmaVersion>=6&&(s.generator=e),this.options.ecmaVersion>=8&&(s.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(pt(t,s.generator)|ze|(n?Mt:0)),this.expect(h.parenL),s.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(s,!1,!0,!1),this.yieldPos=i,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(s,"FunctionExpression")},w.parseArrowExpression=function(e,t,n,s){var i=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(pt(n,!1)|ut),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,s),this.yieldPos=i,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(e,"ArrowFunctionExpression")},w.parseFunctionBody=function(e,t,n,s){var i=t&&this.type!==h.braceL,r=this.strict,a=!1;if(i)e.body=this.parseMaybeAssign(s),e.expression=!0,this.checkParams(e,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!r||o)&&((a=this.strictDirective(this.end))&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var c=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(e,!r&&!a&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Lt),e.body=this.parseBlock(!1,void 0,a&&!r),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},w.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1){if("Identifier"!==n[t].type)return!1}return!0},w.checkParams=function(e,t){for(var n=Object.create(null),s=0,i=e.params;s<i.length;s+=1){var r=i[s];this.checkLValInnerPattern(r,ht,t?null:n)}},w.parseExprList=function(e,t,n,s){for(var i=[],r=!0;!this.eat(e);){if(r)r=!1;else if(this.expect(h.comma),t&&this.afterTrailingComma(e))break;var a=void 0;n&&this.type===h.comma?a=null:this.type===h.ellipsis?(a=this.parseSpread(s),s&&this.type===h.comma&&s.trailingComma<0&&(s.trailingComma=this.start)):a=this.parseMaybeAssign(!1,s),i.push(a)}return i},w.checkUnreserved=function(e){var t=e.start,n=e.end,s=e.name;(this.inGenerator&&"yield"===s&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&"await"===s&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&Xe)&&"arguments"===s&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&("arguments"===s||"await"===s)&&this.raise(t,"Cannot use "+s+" in class static initialization block"),this.keywords.test(s)&&this.raise(t,"Unexpected keyword '"+s+"'"),this.options.ecmaVersion<6&&-1!==this.input.slice(t,n).indexOf("\\"))||(this.strict?this.reservedWordsStrict:this.reservedWords).test(s)&&(!this.inAsync&&"await"===s&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+s+"' is reserved"))},w.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),"await"===t.name&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},w.parseIdentNode=function(){var e=this.startNode();return this.type===h.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,("class"===e.name||"function"===e.name)&&(this.lastTokEnd!==this.lastTokStart+1||46!==this.input.charCodeAt(this.lastTokStart))&&this.context.pop(),this.type=h.name):this.unexpected(),e},w.parsePrivateIdent=function(){var e=this.startNode();return this.type===h.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(0===this.privateNameStack.length?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},w.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===h.semi||this.canInsertSemicolon()||this.type!==h.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(h.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")},w.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var Be=F.prototype;Be.raise=function(e,t){var n=Nt(this.input,e);t+=" ("+n.line+":"+n.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var s=new SyntaxError(t);throw s.pos=e,s.loc=n,s.raisedAt=this.pos,s},Be.raiseRecoverable=Be.raise,Be.curPosition=function(){if(this.options.locations)return new ke(this.curLine,this.pos-this.lineStart)};var he=F.prototype,_s=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};he.enterScope=function(e){this.scopeStack.push(new _s(e))},he.exitScope=function(){this.scopeStack.pop()},he.treatFunctionsAsVarInScope=function(e){return e.flags&Ae||!this.inModule&&e.flags&Ie},he.declareName=function(e,t,n){var s=!1;if(t===oe){var i=this.currentScope();s=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&Ie&&delete this.undefinedExports[e]}else if(t===Ot){this.currentScope().lexical.push(e)}else if(t===Rt){var r=this.currentScope();s=this.treatFunctionsAsVar?r.lexical.indexOf(e)>-1:r.lexical.indexOf(e)>-1||r.var.indexOf(e)>-1,r.functions.push(e)}else for(var a=this.scopeStack.length-1;a>=0;--a){var o=this.scopeStack[a];if(o.lexical.indexOf(e)>-1&&!(o.flags&It&&o.lexical[0]===e)||!this.treatFunctionsAsVarInScope(o)&&o.functions.indexOf(e)>-1){s=!0;break}if(o.var.push(e),this.inModule&&o.flags&Ie&&delete this.undefinedExports[e],o.flags&Xe)break}s&&this.raiseRecoverable(n,"Identifier '"+e+"' has already been declared")},he.checkLocalExport=function(e){-1===this.scopeStack[0].lexical.indexOf(e.name)&&-1===this.scopeStack[0].var.indexOf(e.name)&&(this.undefinedExports[e.name]=e)},he.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},he.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Xe|Me|be))return t}},he.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Xe|Me|be)&&!(t.flags&ut))return t}};var Ge=function(e,t,n){this.type="",this.start=t,this.end=0,e.options.locations&&(this.loc=new qe(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Re=F.prototype;function Dt(e,t,n,s){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=s),this.options.ranges&&(e.range[1]=n),e}Re.startNode=function(){return new Ge(this,this.start,this.startLoc)},Re.startNodeAt=function(e,t){return new Ge(this,e,t)},Re.finishNode=function(e,t){return Dt.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},Re.finishNodeAt=function(e,t,n,s){return Dt.call(this,e,t,n,s)},Re.copyNode=function(e){var t=new Ge(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};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",Bt="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",$t=Bt+" Extended_Pictographic",Wt=$t,jt=$t+" EBase EComp EMod EPres ExtPict",Ht=jt,ks=jt,Is={9:Bt,10:$t,11:$t,12:jt,13:jt,14:ks},Ms="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Rs={9:"",10:"",11:"",12:"",13:"",14:Ms},bt="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",Ut="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",qt=Ut+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",zt=qt+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Xt=zt+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Kt=Xt+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Os=Kt+" "+Ns,Ls={9:Ut,10:qt,11:zt,12:Xt,13:Kt,14:Os},Gt={};function Fs(e){var t=Gt[e]={binary:ue(Is[e]+" "+bt),binaryOfStrings:ue(Rs[e]),nonBinary:{General_Category:ue(bt),Script:ue(Ls[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var Ze=0,yt=[9,10,11,12,13,14];Ze<yt.length;Ze+=1){var Vs=yt[Ze];Fs(Vs)}var S=F.prototype,$e=function(e,t){this.parent=e,this.base=t||this};$e.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1},$e.prototype.sibling=function(){return new $e(this.parent,this.base)};var ne=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=Gt[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};function Ds(e){for(var t in e)return!0;return!1}function Bs(e){return 105===e||109===e||115===e}function Qt(e){return 36===e||e>=40&&e<=43||46===e||63===e||e>=91&&e<=94||e>=123&&e<=125}function $s(e){return te(e,!0)||36===e||95===e}function Ws(e){return pe(e,!0)||36===e||95===e||8204===e||8205===e}function Yt(e){return e>=65&&e<=90||e>=97&&e<=122}function js(e){return e>=0&&e<=1114111}ne.prototype.reset=function(e,t,n){var s=-1!==n.indexOf("v"),i=-1!==n.indexOf("u");this.start=0|e,this.source=t+"",this.flags=n,s&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},ne.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)},ne.prototype.at=function(e,t){void 0===t&&(t=!1);var n=this.source,s=n.length;if(e>=s)return-1;var i=n.charCodeAt(e);if(!t&&!this.switchU||i<=55295||i>=57344||e+1>=s)return i;var r=n.charCodeAt(e+1);return r>=56320&&r<=57343?(i<<10)+r-56613888:i},ne.prototype.nextIndex=function(e,t){void 0===t&&(t=!1);var n=this.source,s=n.length;if(e>=s)return s;var i,r=n.charCodeAt(e);return!t&&!this.switchU||r<=55295||r>=57344||e+1>=s||(i=n.charCodeAt(e+1))<56320||i>57343?e+1:e+2},ne.prototype.current=function(e){return void 0===e&&(e=!1),this.at(this.pos,e)},ne.prototype.lookahead=function(e){return void 0===e&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},ne.prototype.advance=function(e){void 0===e&&(e=!1),this.pos=this.nextIndex(this.pos,e)},ne.prototype.eat=function(e,t){return void 0===t&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},ne.prototype.eatChars=function(e,t){void 0===t&&(t=!1);for(var n=this.pos,s=0,i=e;s<i.length;s+=1){var r=i[s],a=this.at(n,t);if(-1===a||a!==r)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},S.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,s=!1,i=!1,r=0;r<n.length;r++){var a=n.charAt(r);-1===t.indexOf(a)&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(a,r+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),"u"===a&&(s=!0),"v"===a&&(i=!0)}this.options.ecmaVersion>=15&&s&&i&&this.raise(e.start,"Invalid regular expression flag")},S.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Ds(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},S.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var s=n[t];e.groupNames[s]||e.raise("Invalid named capture referenced")}},S.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new $e(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")},S.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},S.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):!!(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))&&(this.regexp_eatQuantifier(e),!0)},S.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},S.regexp_eatQuantifier=function(e,t){return void 0===t&&(t=!1),!!this.regexp_eatQuantifierPrefix(e,t)&&(e.eat(63),!0)},S.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},S.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var s=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return-1!==i&&i<s&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=n}return!1},S.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},S.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},S.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),s=e.eat(45);if(n||s){for(var i=0;i<n.length;i++){var r=n.charAt(i);n.indexOf(r,i+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(s){var a=this.regexp_eatModifiers(e);!n&&!a&&58===e.current()&&e.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var c=a.charAt(o);(a.indexOf(c,o+1)>-1||n.indexOf(c)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1},S.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):63===e.current()&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1},S.regexp_eatModifiers=function(e){for(var t="",n=0;-1!==(n=e.current())&&Bs(n);)t+=re(n),e.advance();return t},S.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},S.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},S.regexp_eatSyntaxCharacter=function(e){var t=e.current();return!!Qt(t)&&(e.lastIntValue=t,e.advance(),!0)},S.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;-1!==(n=e.current())&&!Qt(n);)e.advance();return e.pos!==t},S.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return!(-1===t||36===t||t>=40&&t<=43||46===t||63===t||91===t||94===t||124===t)&&(e.advance(),!0)},S.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var s=0,i=n;s<i.length;s+=1){i[s].separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},S.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1},S.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=re(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=re(e.lastIntValue);return!0}return!1},S.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,s=e.current(n);return e.advance(n),92===s&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(s=e.lastIntValue),$s(s)?(e.lastIntValue=s,!0):(e.pos=t,!1)},S.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,s=e.current(n);return e.advance(n),92===s&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(s=e.lastIntValue),Ws(s)?(e.lastIntValue=s,!0):(e.pos=t,!1)},S.regexp_eatAtomEscape=function(e){return!!(this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e))||(e.switchU&&(99===e.current()&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)},S.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},S.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1},S.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},S.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},S.regexp_eatZero=function(e){return 48===e.current()&&!Qe(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},S.regexp_eatControlEscape=function(e){var t=e.current();return 116===t?(e.lastIntValue=9,e.advance(),!0):110===t?(e.lastIntValue=10,e.advance(),!0):118===t?(e.lastIntValue=11,e.advance(),!0):102===t?(e.lastIntValue=12,e.advance(),!0):114===t&&(e.lastIntValue=13,e.advance(),!0)},S.regexp_eatControlLetter=function(e){var t=e.current();return!!Yt(t)&&(e.lastIntValue=t%32,e.advance(),!0)},S.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){void 0===t&&(t=!1);var n=e.pos,s=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(s&&i>=55296&&i<=56319){var r=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var a=e.lastIntValue;if(a>=56320&&a<=57343)return e.lastIntValue=1024*(i-55296)+(a-56320)+65536,!0}e.pos=r,e.lastIntValue=i}return!0}if(s&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&js(e.lastIntValue))return!0;s&&e.raise("Invalid unicode escape"),e.pos=n}return!1},S.regexp_eatIdentityEscape=function(e){if(e.switchU)return!!this.regexp_eatSyntaxCharacter(e)||!!e.eat(47)&&(e.lastIntValue=47,!0);var t=e.current();return!(99===t||e.switchN&&107===t)&&(e.lastIntValue=t,e.advance(),!0)},S.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do{e.lastIntValue=10*e.lastIntValue+(t-48),e.advance()}while((t=e.current())>=48&&t<=57);return!0}return!1};var Jt=0,ae=1,K=2;function Hs(e){return 100===e||68===e||115===e||83===e||119===e||87===e}function Zt(e){return Yt(e)||95===e}function Us(e){return Zt(e)||Qe(e)}function qs(e){return 33===e||e>=35&&e<=38||e>=42&&e<=44||46===e||e>=58&&e<=64||94===e||96===e||126===e}function zs(e){return 40===e||41===e||45===e||47===e||e>=91&&e<=93||e>=123&&e<=125}function Xs(e){return 33===e||35===e||37===e||38===e||44===e||45===e||e>=58&&e<=62||64===e||96===e||126===e}function Qe(e){return e>=48&&e<=57}function es(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function ts(e){return e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e-48}function ss(e){return e>=48&&e<=55}S.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Hs(t))return e.lastIntValue=-1,e.advance(),ae;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=80===t)||112===t)){var s;if(e.lastIntValue=-1,e.advance(),e.eat(123)&&(s=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&s===K&&e.raise("Invalid property name"),s;e.raise("Invalid property name")}return Jt},S.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,s),ae}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Jt},S.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){we(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")},S.regexp_validateUnicodePropertyNameOrValue=function(e,t){return e.unicodeProperties.binary.test(t)?ae:e.switchV&&e.unicodeProperties.binaryOfStrings.test(t)?K:void e.raise("Invalid property name")},S.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Zt(t=e.current());)e.lastStringValue+=re(t),e.advance();return""!==e.lastStringValue},S.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";Us(t=e.current());)e.lastStringValue+=re(t),e.advance();return""!==e.lastStringValue},S.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},S.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&n===K&&e.raise("Negated character class may contain strings"),!0}return!1},S.regexp_classContents=function(e){return 93===e.current()?ae:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),ae)},S.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(-1===t||-1===n)&&e.raise("Invalid character class"),-1!==t&&-1!==n&&t>n&&e.raise("Range out of order in character class")}}},S.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(99===n||ss(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var s=e.current();return 93!==s&&(e.lastIntValue=s,e.advance(),!0)},S.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},S.regexp_classSetExpression=function(e){var t,n=ae;if(!this.regexp_eatClassSetRange(e))if(t=this.regexp_eatClassSetOperand(e)){t===K&&(n=K);for(var s=e.pos;e.eatChars([38,38]);)38!==e.current()&&(t=this.regexp_eatClassSetOperand(e))?t!==K&&(n=ae):e.raise("Invalid character in character class");if(s!==e.pos)return n;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(s!==e.pos)return n}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(!(t=this.regexp_eatClassSetOperand(e)))return n;t===K&&(n=K)}},S.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var s=e.lastIntValue;return-1!==n&&-1!==s&&n>s&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1},S.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?ae:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},S.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),s=this.regexp_classContents(e);if(e.eat(93))return n&&s===K&&e.raise("Negated character class may contain strings"),s;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},S.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise("Invalid escape");e.pos=t}return null},S.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===K&&(t=K);return t},S.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return 1===t?ae:K},S.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return!(!this.regexp_eatCharacterEscape(e)&&!this.regexp_eatClassSetReservedPunctuator(e))||(e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1));var n=e.current();return!(n<0||n===e.lookahead()&&qs(n)||zs(n))&&(e.advance(),e.lastIntValue=n,!0)},S.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return!!Xs(t)&&(e.lastIntValue=t,e.advance(),!0)},S.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!Qe(t)&&95!==t)&&(e.lastIntValue=t%32,e.advance(),!0)},S.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1},S.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Qe(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t},S.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;es(n=e.current());)e.lastIntValue=16*e.lastIntValue+ts(n),e.advance();return e.pos!==t},S.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=64*t+8*n+e.lastIntValue:e.lastIntValue=8*t+n}else e.lastIntValue=t;return!0}return!1},S.regexp_eatOctalDigit=function(e){var t=e.current();return ss(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)},S.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var s=0;s<t;++s){var i=e.current();if(!es(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+ts(i),e.advance()}return!0};var dt=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new qe(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},P=F.prototype;function Ks(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function ns(e){return"function"!=typeof BigInt?null:BigInt(e.replace(/_/g,""))}P.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new dt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},P.getToken=function(){return this.next(),new dt(this)},typeof Symbol<"u"&&(P[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===h.eof,value:t}}}}),P.nextToken=function(){var e=this.curContext();return(!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length?this.finishToken(h.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},P.readToken=function(e){return te(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},P.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888},P.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(-1===n&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var s=void 0,i=t;(s=At(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=s;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},P.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),s=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!Te(s);)s=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},P.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:10===this.input.charCodeAt(this.pos+1)&&++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(!(e>8&&e<14||e>=5760&&Pt.test(String.fromCharCode(e))))break e;++this.pos}}},P.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},P.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===e&&46===t?(this.pos+=3,this.finishToken(h.ellipsis)):(++this.pos,this.finishToken(h.dot))},P.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===e?this.finishOp(h.assign,2):this.finishOp(h.slash,1)},P.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,s=42===e?h.star:h.modulo;return this.options.ecmaVersion>=7&&42===e&&42===t&&(++n,s=h.starstar,t=this.input.charCodeAt(this.pos+2)),61===t?this.finishOp(h.assign,n+1):this.finishOp(s,n)},P.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12)if(61===this.input.charCodeAt(this.pos+2))return this.finishOp(h.assign,3);return this.finishOp(124===e?h.logicalOR:h.logicalAND,2)}return 61===t?this.finishOp(h.assign,2):this.finishOp(124===e?h.bitwiseOR:h.bitwiseAND,1)},P.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(h.assign,2):this.finishOp(h.bitwiseXOR,1)},P.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?45!==t||this.inModule||62!==this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!H.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(h.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===t?this.finishOp(h.assign,2):this.finishOp(h.plusMin,1)},P.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=62===e&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+n)?this.finishOp(h.assign,n+1):this.finishOp(h.bitShift,n)):33!==t||60!==e||this.inModule||45!==this.input.charCodeAt(this.pos+2)||45!==this.input.charCodeAt(this.pos+3)?(61===t&&(n=2),this.finishOp(h.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},P.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(h.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===e&&62===t&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(h.arrow)):this.finishOp(61===e?h.eq:h.prefix,1)},P.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(46===t){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(h.questionDot,2)}if(63===t){if(e>=12)if(61===this.input.charCodeAt(this.pos+2))return this.finishOp(h.assign,3);return this.finishOp(h.coalesce,2)}}return this.finishOp(h.question,1)},P.readToken_numberSign=function(){var e=35;if(this.options.ecmaVersion>=13&&(++this.pos,te(e=this.fullCharCodeAtPos(),!0)||92===e))return this.finishToken(h.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+re(e)+"'")},P.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(h.parenL);case 41:return++this.pos,this.finishToken(h.parenR);case 59:return++this.pos,this.finishToken(h.semi);case 44:return++this.pos,this.finishToken(h.comma);case 91:return++this.pos,this.finishToken(h.bracketL);case 93:return++this.pos,this.finishToken(h.bracketR);case 123:return++this.pos,this.finishToken(h.braceL);case 125:return++this.pos,this.finishToken(h.braceR);case 58:return++this.pos,this.finishToken(h.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(h.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(120===t||88===t)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===t||79===t)return this.readRadixNumber(8);if(98===t||66===t)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(h.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+re(e)+"'")},P.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},P.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var s=this.input.charAt(this.pos);if(H.test(s)&&this.raise(n,"Unterminated regular expression"),e)e=!1;else{if("["===s)t=!0;else if("]"===s&&t)t=!1;else if("/"===s&&!t)break;e="\\"===s}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var r=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(r);var o=this.regexpState||(this.regexpState=new ne(this));o.reset(n,i,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var c=null;try{c=new RegExp(i,a)}catch{}return this.finishToken(h.regexp,{pattern:i,flags:a,value:c})},P.readInt=function(e,t,n){for(var s=this.options.ecmaVersion>=12&&void 0===t,i=n&&48===this.input.charCodeAt(this.pos),r=this.pos,a=0,o=0,c=0,h=t??1/0;c<h;++c,++this.pos){var l=this.input.charCodeAt(this.pos),p=void 0;if(s&&95===l)i&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),95===o&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),0===c&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=l;else{if((p=l>=97?l-97+10:l>=65?l-65+10:l>=48&&l<=57?l-48:1/0)>=e)break;o=l,a=a*e+p}}return s&&95===o&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===r||null!=t&&this.pos-r!==t?null:a},P.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return null==n&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&110===this.input.charCodeAt(this.pos)?(n=ns(this.input.slice(t,this.pos)),++this.pos):te(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,n)},P.readNumber=function(e){var t=this.pos;!e&&null===this.readInt(10,void 0,!0)&&this.raise(t,"Invalid number");var n=this.pos-t>=2&&48===this.input.charCodeAt(t);n&&this.strict&&this.raise(t,"Invalid number");var s=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&110===s){var i=ns(this.input.slice(t,this.pos));return++this.pos,te(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),46===s&&!n&&(++this.pos,this.readInt(10),s=this.input.charCodeAt(this.pos)),(69===s||101===s)&&!n&&((43===(s=this.input.charCodeAt(++this.pos))||45===s)&&++this.pos,null===this.readInt(10)&&this.raise(t,"Invalid number")),te(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var r=Ks(this.input.slice(t,this.pos),n);return this.finishToken(h.num,r)},P.readCodePoint=function(){var e;if(123===this.input.charCodeAt(this.pos)){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},P.readString=function(e){for(var t="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var s=this.input.charCodeAt(this.pos);if(s===e)break;92===s?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):8232===s||8233===s?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Te(s)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(h.string,t)};var is={};P.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==is)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},P.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw is;this.raise(e,t)},P.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(96===n||36===n&&123===this.input.charCodeAt(this.pos+1))return this.pos!==this.start||this.type!==h.template&&this.type!==h.invalidTemplate?(e+=this.input.slice(t,this.pos),this.finishToken(h.template,e)):36===n?(this.pos+=2,this.finishToken(h.dollarBraceL)):(++this.pos,this.finishToken(h.backQuote));if(92===n)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Te(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(n)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},P.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(h.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":"\n"===this.input[this.pos+1]&&++this.pos;case"\n":case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1}this.raise(this.start,"Unterminated template")},P.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return"\n";case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return re(this.readCodePoint());case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var s=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(s,8);return i>255&&(s=s.slice(0,-1),i=parseInt(s,8)),this.pos+=s.length-1,t=this.input.charCodeAt(this.pos),("0"!==s||56===t||57===t)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-s.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(i)}return Te(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},P.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return null===n&&this.invalidStringToken(t,"Bad character escape sequence"),n},P.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,s=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(pe(i,s))this.pos+=i<=65535?1:2;else{if(92!==i)break;this.containsEsc=!0,e+=this.input.slice(n,this.pos);var r=this.pos;117!==this.input.charCodeAt(++this.pos)&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(t?te:pe)(a,s)||this.invalidStringToken(r,"Invalid Unicode escape"),e+=re(a),n=this.pos}t=!1}return e+this.input.slice(n,this.pos)},P.readWord=function(){var e=this.readWord1(),t=h.name;return this.keywords.test(e)&&(t=ct[e]),this.finishToken(t,e)};var Gs="8.15.0";function D(e,t){return F.parse(e,t)}function U(e,t,n,s,i){n||(n=b),function e(s,i,r){var a=r||s.type;n[a](s,i,e),t[a]&&t[a](s,i)}(e,s,i)}function vt(e,t,n,s,i){var r=[];n||(n=b),function e(s,i,a){var o=a||s.type,c=s!==r[r.length-1];c&&r.push(s),n[o](s,i,e),t[o]&&t[o](s,i||r,r),c&&r.pop()}(e,s,i)}function mt(e,t,n){n(e,t)}function ye(e,t,n){}F.acorn={Parser:F,version:Gs,defaultOptions:tt,Position:ke,SourceLocation:qe,getLineInfo:Nt,Node:Ge,TokenType:N,tokTypes:h,keywordTypes:ct,TokContext:J,tokContexts:O,isIdentifierChar:pe,isIdentifierStart:te,Token:dt,isNewLine:Te,lineBreak:H,lineBreakG:xs,nonASCIIwhitespace:Pt};var b={};b.Program=b.BlockStatement=b.StaticBlock=function(e,t,n){for(var s=0,i=e.body;s<i.length;s+=1){n(i[s],t,"Statement")}},b.Statement=mt,b.EmptyStatement=ye,b.ExpressionStatement=b.ParenthesizedExpression=b.ChainExpression=function(e,t,n){return n(e.expression,t,"Expression")},b.IfStatement=function(e,t,n){n(e.test,t,"Expression"),n(e.consequent,t,"Statement"),e.alternate&&n(e.alternate,t,"Statement")},b.LabeledStatement=function(e,t,n){return n(e.body,t,"Statement")},b.BreakStatement=b.ContinueStatement=ye,b.WithStatement=function(e,t,n){n(e.object,t,"Expression"),n(e.body,t,"Statement")},b.SwitchStatement=function(e,t,n){n(e.discriminant,t,"Expression");for(var s=0,i=e.cases;s<i.length;s+=1){n(i[s],t)}},b.SwitchCase=function(e,t,n){e.test&&n(e.test,t,"Expression");for(var s=0,i=e.consequent;s<i.length;s+=1){n(i[s],t,"Statement")}},b.ReturnStatement=b.YieldExpression=b.AwaitExpression=function(e,t,n){e.argument&&n(e.argument,t,"Expression")},b.ThrowStatement=b.SpreadElement=function(e,t,n){return n(e.argument,t,"Expression")},b.TryStatement=function(e,t,n){n(e.block,t,"Statement"),e.handler&&n(e.handler,t),e.finalizer&&n(e.finalizer,t,"Statement")},b.CatchClause=function(e,t,n){e.param&&n(e.param,t,"Pattern"),n(e.body,t,"Statement")},b.WhileStatement=b.DoWhileStatement=function(e,t,n){n(e.test,t,"Expression"),n(e.body,t,"Statement")},b.ForStatement=function(e,t,n){e.init&&n(e.init,t,"ForInit"),e.test&&n(e.test,t,"Expression"),e.update&&n(e.update,t,"Expression"),n(e.body,t,"Statement")},b.ForInStatement=b.ForOfStatement=function(e,t,n){n(e.left,t,"ForInit"),n(e.right,t,"Expression"),n(e.body,t,"Statement")},b.ForInit=function(e,t,n){"VariableDeclaration"===e.type?n(e,t):n(e,t,"Expression")},b.DebuggerStatement=ye,b.FunctionDeclaration=function(e,t,n){return n(e,t,"Function")},b.VariableDeclaration=function(e,t,n){for(var s=0,i=e.declarations;s<i.length;s+=1){n(i[s],t)}},b.VariableDeclarator=function(e,t,n){n(e.id,t,"Pattern"),e.init&&n(e.init,t,"Expression")},b.Function=function(e,t,n){e.id&&n(e.id,t,"Pattern");for(var s=0,i=e.params;s<i.length;s+=1){n(i[s],t,"Pattern")}n(e.body,t,e.expression?"Expression":"Statement")},b.Pattern=function(e,t,n){"Identifier"===e.type?n(e,t,"VariablePattern"):"MemberExpression"===e.type?n(e,t,"MemberPattern"):n(e,t)},b.VariablePattern=ye,b.MemberPattern=mt,b.RestElement=function(e,t,n){return n(e.argument,t,"Pattern")},b.ArrayPattern=function(e,t,n){for(var s=0,i=e.elements;s<i.length;s+=1){var r=i[s];r&&n(r,t,"Pattern")}},b.ObjectPattern=function(e,t,n){for(var s=0,i=e.properties;s<i.length;s+=1){var r=i[s];"Property"===r.type?(r.computed&&n(r.key,t,"Expression"),n(r.value,t,"Pattern")):"RestElement"===r.type&&n(r.argument,t,"Pattern")}},b.Expression=mt,b.ThisExpression=b.Super=b.MetaProperty=ye,b.ArrayExpression=function(e,t,n){for(var s=0,i=e.elements;s<i.length;s+=1){var r=i[s];r&&n(r,t,"Expression")}},b.ObjectExpression=function(e,t,n){for(var s=0,i=e.properties;s<i.length;s+=1){n(i[s],t)}},b.FunctionExpression=b.ArrowFunctionExpression=b.FunctionDeclaration,b.SequenceExpression=function(e,t,n){for(var s=0,i=e.expressions;s<i.length;s+=1){n(i[s],t,"Expression")}},b.TemplateLiteral=function(e,t,n){for(var s=0,i=e.quasis;s<i.length;s+=1){n(i[s],t)}for(var r=0,a=e.expressions;r<a.length;r+=1){n(a[r],t,"Expression")}},b.TemplateElement=ye,b.UnaryExpression=b.UpdateExpression=function(e,t,n){n(e.argument,t,"Expression")},b.BinaryExpression=b.LogicalExpression=function(e,t,n){n(e.left,t,"Expression"),n(e.right,t,"Expression")},b.AssignmentExpression=b.AssignmentPattern=function(e,t,n){n(e.left,t,"Pattern"),n(e.right,t,"Expression")},b.ConditionalExpression=function(e,t,n){n(e.test,t,"Expression"),n(e.consequent,t,"Expression"),n(e.alternate,t,"Expression")},b.NewExpression=b.CallExpression=function(e,t,n){if(n(e.callee,t,"Expression"),e.arguments)for(var s=0,i=e.arguments;s<i.length;s+=1){n(i[s],t,"Expression")}},b.MemberExpression=function(e,t,n){n(e.object,t,"Expression"),e.computed&&n(e.property,t,"Expression")},b.ExportNamedDeclaration=b.ExportDefaultDeclaration=function(e,t,n){e.declaration&&n(e.declaration,t,"ExportNamedDeclaration"===e.type||e.declaration.id?"Statement":"Expression"),e.source&&n(e.source,t,"Expression")},b.ExportAllDeclaration=function(e,t,n){e.exported&&n(e.exported,t),n(e.source,t,"Expression")},b.ImportDeclaration=function(e,t,n){for(var s=0,i=e.specifiers;s<i.length;s+=1){n(i[s],t)}n(e.source,t,"Expression")},b.ImportExpression=function(e,t,n){n(e.source,t,"Expression")},b.ImportSpecifier=b.ImportDefaultSpecifier=b.ImportNamespaceSpecifier=b.Identifier=b.PrivateIdentifier=b.Literal=ye,b.TaggedTemplateExpression=function(e,t,n){n(e.tag,t,"Expression"),n(e.quasi,t,"Expression")},b.ClassDeclaration=b.ClassExpression=function(e,t,n){return n(e,t,"Class")},b.Class=function(e,t,n){e.id&&n(e.id,t,"Pattern"),e.superClass&&n(e.superClass,t,"Expression"),n(e.body,t)},b.ClassBody=function(e,t,n){for(var s=0,i=e.body;s<i.length;s+=1){n(i[s],t)}},b.MethodDefinition=b.PropertyDefinition=b.Property=function(e,t,n){e.computed&&n(e.key,t,"Expression"),e.value&&n(e.value,t,"Expression")};class Qs{constructor(){d(this,"portals",new Map),d(this,"portalCounter",0),d(this,"componentManager"),d(this,"domBindingManager"),d(this,"cleanupObserver"),d(this,"stateManager"),d(this,"pphpInstance"),this.cleanupObserver=new MutationObserver((e=>{this.handleMutations(e)})),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}setDependencies(e,t,n,s){this.componentManager=e,this.domBindingManager=t,this.stateManager=n,this.pphpInstance=s}createPortal(e,t,n){var s;const i="string"==typeof t?document.querySelector(t):t;if(!i)throw new Error(`Portal container not found: ${t}`);const r=(null==(s=this.componentManager)?void 0:s.getCurrentComponent())||"app",a=(null==n?void 0:n.key)||`portal_${++this.portalCounter}_${Date.now()}`;this.portals.has(a)&&this.removePortal(a);const o={id:a,content:e,container:i,component:r};return this.portals.set(a,o),this.renderPortalWithHydration(o,n,a),a}async renderPortalWithHydration(e,t,n){if(this.componentManager&&this.domBindingManager)try{await this.renderPortal(e,t),await new Promise((e=>requestAnimationFrame(e))),this.domBindingManager.processPendingBindings(),await new Promise((e=>{var t;null==(t=this.stateManager)||t.onDOMUpdateComplete((()=>{e(void 0)}))})),this.pphpInstance&&this.pphpInstance.markPortalHydrated&&this.pphpInstance.markPortalHydrated(n),null!=t&&t.onMount&&t.onMount(e.container)}catch(e){console.error("Portal hydration error:",e),this.pphpInstance&&this.pphpInstance.markPortalHydrated&&this.pphpInstance.markPortalHydrated(n)}else console.warn("PortalManager dependencies not set")}renderPortal(e,t){return new Promise(((t,n)=>{if(!this.componentManager||!this.domBindingManager)return console.warn("PortalManager dependencies not set"),void n(new Error("Dependencies not set"));try{let n;if(e.renderedContent&&e.renderedContent.parentElement&&e.renderedContent.parentElement.removeChild(e.renderedContent),"string"==typeof e.content){const t=document.createElement("template");if(t.innerHTML=e.content.trim(),n=t.content.firstElementChild,!n)throw new Error("Invalid HTML string for portal content")}else if(e.content instanceof DocumentFragment){const t=document.createElement("div");if(t.appendChild(e.content.cloneNode(!0)),n=t.firstElementChild,!n)throw new Error("DocumentFragment must contain at least one element")}else n=e.content;n.setAttribute("data-portal-id",e.id),n.setAttribute("data-portal-component",e.component),e.container.appendChild(n),e.renderedContent=n;const s=[...this.componentManager.componentStack];try{this.componentManager.executePhpScripts(n),this.domBindingManager.processElement(n,!0);const s=n.querySelectorAll("template[pp-for]"),i=this.domBindingManager.loopManager;i&&(s.forEach((t=>{var n,s;const r=t;if(null!=(n=i.loopBindings)&&n.has(r))if("function"==typeof i.updateTemplateParent)i.updateTemplateParent(r);else{const t=i.loopBindings.get(r);t&&(null==(s=t.subscriptionIds)||s.forEach((e=>{var t;null==(t=this.stateManager)||t.removeSubscription(e)})),i.loopBindings.delete(r)),i.processTemplate(r,e.component)}else i.queueTemplate(r,e.component)})),i.processPendingTemplates()),this.domBindingManager.processPendingBindings(),t()}finally{this.componentManager.componentStack=s}}catch(t){console.error("Portal rendering error:",t),this.portals.delete(e.id),n(t)}}))}removePortal(e){const t=this.portals.get(e);if(!t)return!1;try{return t.cleanup&&t.cleanup(),t.renderedContent&&this.cleanupPortalElement(t.renderedContent),t.renderedContent&&t.renderedContent.parentElement&&t.renderedContent.parentElement.removeChild(t.renderedContent),this.portals.delete(e),!0}catch(e){return console.error("Portal cleanup error:",e),!1}}cleanupPortalElement(e){var t;if(this.stateManager){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let s=e;do{s.nodeType===Node.ELEMENT_NODE&&(null==(t=this.stateManager.subscriptionManager)||t.cleanupElement(s))}while(s=n.nextNode())}}updatePortal(e,t,n){const s=this.portals.get(e);return!!s&&(s.content=t,this.renderPortal(s,n),!0)}getPortal(e){return this.portals.get(e)}hasPortal(e){return this.portals.has(e)}getAllPortals(){return Array.from(this.portals.values())}handleMutations(e){for(const t of e)"childList"===t.type&&t.removedNodes.forEach((e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;for(const[e,n]of this.portals)(n.container===t||t.contains(n.container))&&this.removePortal(e)}}))}destroy(){for(const e of Array.from(this.portals.keys()))this.removePortal(e);this.cleanupObserver.disconnect(),this.portals.clear()}}const Z=class e{constructor(){d(this,"stateVariables",new Set)}transformRefDeclarations(e){try{const t=D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{VariableDeclarator:t=>{if(this.isRefDeclaration(t)){const n=t.id.name,i=this.findStatementEnd(e,t.end);s.push({start:i,end:i,replacement:`; this.${n} = ${n}`})}}}),s.sort(((e,t)=>t.start-e.start)).forEach((e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)})),n}catch(t){return console.error("Ref transformation error:",t),e}}isRefDeclaration(e){var t,n,s,i,r;return"Identifier"===(null==(t=e.id)?void 0:t.type)&&"CallExpression"===(null==(n=e.init)?void 0:n.type)&&"MemberExpression"===(null==(s=e.init.callee)?void 0:s.type)&&"Identifier"===(null==(i=e.init.callee.object)?void 0:i.type)&&"pp"===e.init.callee.object.name&&"Identifier"===(null==(r=e.init.callee.property)?void 0:r.type)&&"ref"===e.init.callee.property.name}findStatementEnd(e,t){let n=t;for(;n<e.length&&";"!==e[n]&&"\n"!==e[n];)n++;return n}static getInstance(){return e.instance||(e.instance=new e),e.instance}extractFunctionNames(e){const t=[];try{U(D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),{FunctionDeclaration:e=>{var n;"Identifier"===(null==(n=e.id)?void 0:n.type)&&t.push(e.id.name)},VariableDeclarator:e=>{var n,s,i;"Identifier"===(null==(n=e.id)?void 0:n.type)&&("ArrowFunctionExpression"===(null==(s=e.init)?void 0:s.type)||"FunctionExpression"===(null==(i=e.init)?void 0:i.type))&&t.push(e.id.name)},AssignmentExpression:e=>{var n,s,i;"Identifier"===(null==(n=e.left)?void 0:n.type)&&("ArrowFunctionExpression"===(null==(s=e.right)?void 0:s.type)||"FunctionExpression"===(null==(i=e.right)?void 0:i.type))&&t.push(e.left.name)}})}catch(e){console.error("AST function extraction error:",e)}return Array.from(new Set(t))}transformEffectDeclarations(e){try{const t=D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{CallExpression:t=>{const n=this.transformEffectCall(t,e);n&&s.push(n)}}),s.sort(((e,t)=>t.start-e.start)).forEach((e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)})),n}catch(t){return console.error("Effect transformation error:",t),e}}transformEffectCall(e,t){if(!this.isPPEffectCall(e))return null;const n=e.arguments;if(n.length<2)return null;const s=n[1];if("ArrayExpression"!==s.type||!s.elements.some((e=>!!e&&("Identifier"===e.type||"MemberExpression"===e.type))))return null;const i=s.elements.map((e=>e?"Identifier"===e.type?`"${e.name}"`:"MemberExpression"===e.type?`"${this.extractMemberExpression(e,t)}"`:t.slice(e.start,e.end):"null")),r=t.slice(n[0].start,n[0].end),a=n.slice(2).map((e=>t.slice(e.start,e.end))).join(", "),o=`[${i.join(", ")}]`,c=a?`pp.effect(${r}, ${o}, ${a})`:`pp.effect(${r}, ${o})`;return{start:e.start,end:e.end,replacement:c}}extractMemberExpression(e,t){if("MemberExpression"!==e.type)return"Identifier"===e.type?e.name:t.slice(e.start,e.end);const n=this.extractMemberExpression(e.object,t);if(e.computed){return`${n}[${t.slice(e.property.start,e.property.end)}]`}return`${n}.${e.property.name||t.slice(e.property.start,e.property.end)}`}isPPEffectCall(e){var t,n,s;return"MemberExpression"===(null==(t=e.callee)?void 0:t.type)&&"Identifier"===(null==(n=e.callee.object)?void 0:n.type)&&"pp"===e.callee.object.name&&"Identifier"===(null==(s=e.callee.property)?void 0:s.type)&&"effect"===e.callee.property.name}transformStateDeclarations(e,t){this.stateVariables.clear(),t&&t.forEach((e=>this.stateVariables.add(e)));let n=this.transformStateDeclarationsOnly(e);return n=this.transformEffectDeclarations(n),n=this.transformRefDeclarations(n),n=this.transformUnsupportedStateUsages(n),n}transformStateDeclarationsOnlyOriginal(e){try{const t=D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{VariableDeclarator:t=>{const n=this.transformStateDeclarator(t,e);n&&s.push(n)}}),s.sort(((e,t)=>t.start-e.start)).forEach((e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)})),n}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=D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});this.collectStateVariables(t);let n=this.transformShorthandProperties(e);const s=D(n,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),i=[],r=new Set,a=new Map;vt(s,{VariableDeclarator:(e,t)=>{var n;if(this.isStateDeclaration(e))return;let s=null;for(let e=t.length-1;e>=0;e--){const n=t[e];if("FunctionExpression"===n.type||"ArrowFunctionExpression"===n.type||"FunctionDeclaration"===n.type||"BlockStatement"===n.type){s=n;break}}s&&"Identifier"===(null==(n=e.id)?void 0:n.type)&&(a.has(s)||a.set(s,new Set),a.get(s).add(e.id.name),r.add(e.id.name))}});const o=(e,t)=>{for(let n=t.length-1;n>=0;n--){const s=t[n],i=a.get(s);if(i&&i.has(e))return!0}return!1},c=(e,t)=>!(e&&"Identifier"===e.type&&this.stateVariables.has(e.name)&&!r.has(e.name)&&!this.alreadyHasValue(e,t));return U(s,{MemberExpression:e=>{var t;"Identifier"===(null==(t=e.object)?void 0:t.type)&&this.stateVariables.has(e.object.name)&&!r.has(e.object.name)&&!this.alreadyHasValue(e.object,n)&&i.push({start:e.object.start,end:e.object.end,replacement:`${e.object.name}.value`})},SpreadElement:e=>{if(!c(e.argument,n)){const t=this.transformSpreadElement(e,n);t&&i.push(t)}},UnaryExpression:e=>{if(!c(e.argument,n)){const t=this.transformUnaryExpression(e,n);t&&i.push(t)}},BinaryExpression:e=>{const t=c(e.left,n),s=c(e.right,n);if(!t||!s){const t=this.transformBinaryExpression(e,n);t&&i.push(t)}},LogicalExpression:e=>{const t=c(e.left,n),s=c(e.right,n);if(!t||!s){const t=this.transformLogicalExpression(e,n);t&&i.push(t)}},ConditionalExpression:e=>{const t=this.transformConditionalExpression(e,n);t&&i.push(t)},IfStatement:e=>{if(!c(e.test,n)){const t=this.transformIfStatement(e,n);t&&i.push(t)}},WhileStatement:e=>{if(!c(e.test,n)){const t=this.transformWhileStatement(e,n);t&&i.push(t)}},ForStatement:e=>{const t=this.transformForStatement(e,n);t&&i.push(t)},ReturnStatement:e=>{const t=this.transformReturnStatement(e,n);t&&i.push(t)},VariableDeclarator:e=>{const t=this.transformVariableDeclarator(e,n);t&&i.push(t)},AssignmentExpression:e=>{const t=this.transformAssignmentExpression(e,n);t&&i.push(t)},CallExpression:e=>{const t=this.transformGeneralCallExpression(e,n);t&&t.length>0&&i.push(...t)}}),vt(s,{Identifier:(e,t)=>{!this.stateVariables.has(e.name)||i.some((t=>e.start>=t.start&&e.end<=t.end))||o(e.name,t)||this.alreadyHasValue(e,n)||this.isPartOfStateDeclaration(e,t)||this.isPropertyName(e,t)||this.isMethodCallObject(e,t)||this.isPartOfPPCall(e,t)||this.isPartOfDestructuring(e,t)||i.push({start:e.start,end:e.end,replacement:`${e.name}.value`})}}),i.sort(((e,t)=>t.start-e.start)).forEach((e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)})),n=this.transformMultipleCallArguments(n,r),n}catch(t){return console.error("State usage transformation error:",t),e}}transformShorthandProperties(e){try{const t=D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{Property:e=>{var t;if(e.shorthand&&"Identifier"===(null==(t=e.key)?void 0:t.type)&&this.stateVariables.has(e.key.name)){const t=e.key.name,n=`${t}: ${t}.value`;s.push({start:e.start,end:e.end,replacement:n})}}}),s.sort(((e,t)=>t.start-e.start)).forEach((e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)})),n}catch(t){return console.error("Shorthand property transformation error:",t),e}}transformLogicalExpression(e,t){var n,s;return"Identifier"===(null==(n=e.left)?void 0:n.type)&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,t)?{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`}:"Identifier"===(null==(s=e.right)?void 0:s.type)&&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){var n,s,i;return"Identifier"===(null==(n=e.test)?void 0:n.type)&&this.stateVariables.has(e.test.name)&&!this.alreadyHasValue(e.test,t)?{start:e.test.start,end:e.test.end,replacement:`${e.test.name}.value`}:"Identifier"===(null==(s=e.consequent)?void 0:s.type)&&this.stateVariables.has(e.consequent.name)&&!this.alreadyHasValue(e.consequent,t)?{start:e.consequent.start,end:e.consequent.end,replacement:`${e.consequent.name}.value`}:"Identifier"===(null==(i=e.alternate)?void 0:i.type)&&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){var n,s,i;return this.isStateDeclaration(e)||"ArrayPattern"===(null==(n=e.id)?void 0:n.type)||"ObjectPattern"===(null==(s=e.id)?void 0:s.type)?null:"Identifier"===(null==(i=e.init)?void 0:i.type)&&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){var n,s,i;return"ArrayPattern"===(null==(n=e.left)?void 0:n.type)||"ObjectPattern"===(null==(s=e.left)?void 0:s.type)?null:"Identifier"===(null==(i=e.right)?void 0:i.type)&&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(t,n){var s,i;const r=n.slice(t.callee.start,t.callee.end);if("MemberExpression"===(null==(s=t.callee)?void 0:s.type)&&"Identifier"===(null==(i=t.callee.object)?void 0:i.type)&&this.stateVariables.has(t.callee.object.name))return[];if(this.isPPCall(t))return[];if(!e.isFunctionNeedingValueTransform(r)&&t.arguments.length>0){const e=[];for(const s of t.arguments)"Identifier"===s.type&&this.stateVariables.has(s.name)&&(this.alreadyHasValue(s,n)||e.push({start:s.start,end:s.end,replacement:`${s.name}.value`}));return e}return[]}static isFunctionNeedingValueTransform(e){if(this.FUNCTIONS_NEEDING_VALUE_TRANSFORM.has(e))return!0;const t=e.lastIndexOf(".");if(t>-1){const n=e.slice(t+1);if(this.FUNCTIONS_NEEDING_VALUE_TRANSFORM.has(n))return!0}return!1}transformExpressionNode(e,t){return"Identifier"===(null==e?void 0:e.type)&&this.stateVariables.has(e.name)&&!this.alreadyHasValue(e,t)?{start:e.start,end:e.end,replacement:`${e.name}.value`}:null}isPPCall(e){var t,n,s;return"MemberExpression"===(null==(t=e.callee)?void 0:t.type)&&"Identifier"===(null==(n=e.callee.object)?void 0:n.type)&&"pp"===e.callee.object.name&&"Identifier"===(null==(s=e.callee.property)?void 0:s.type)&&("state"===e.callee.property.name||"effect"===e.callee.property.name)}isPartOfStateDeclaration(e,t){var n,s;if(!t||!Array.isArray(t))return!1;for(const e of t)if("VariableDeclarator"===e.type&&"ArrayPattern"===(null==(n=e.id)?void 0:n.type)&&"CallExpression"===(null==(s=e.init)?void 0:s.type)&&this.isPPStateCall(e.init))return!0;return!1}isPropertyName(e,t){if(!t||0===t.length)return!1;const n=t[t.length-1];return!!("Property"===(null==n?void 0:n.type)&&n.key===e||"Property"===(null==n?void 0:n.type)&&n.shorthand&&n.value===e||"MemberExpression"===(null==n?void 0:n.type)&&n.property===e&&!n.computed)}isMethodCallObject(e,t){if(!t||0===t.length)return!1;const n=t[t.length-1];if("MemberExpression"===(null==n?void 0:n.type)&&n.object===e&&t.length>=2){const e=t[t.length-2];if("CallExpression"===(null==e?void 0:e.type)&&e.callee===n)return!0}return!1}isPartOfPPCall(e,t){var n,s,i;if(!t||!Array.isArray(t))return!1;for(const e of t)if("CallExpression"===e.type&&"MemberExpression"===(null==(n=e.callee)?void 0:n.type)&&"Identifier"===(null==(s=e.callee.object)?void 0:s.type)&&"pp"===e.callee.object.name&&"Identifier"===(null==(i=e.callee.property)?void 0:i.type)&&("state"===e.callee.property.name||"effect"===e.callee.property.name))return!0;return!1}isPartOfDestructuring(e,t){if(!t||!Array.isArray(t))return!1;for(let n=0;n<t.length;n++){const s=t[n];if("ArrayPattern"===s.type||"ObjectPattern"===s.type){if(n+1<t.length){const i=t[n+1];if("VariableDeclarator"===(null==i?void 0:i.type)&&i.id===s&&i.init===e)return!1}return!0}}return!1}collectStateVariables(e){U(e,{VariableDeclarator:e=>{if(this.isStateDeclaration(e)){const t=e.id.elements[0];"Identifier"===(null==t?void 0:t.type)&&this.stateVariables.add(t.name)}}})}isStateDeclaration(e){var t,n;return"ArrayPattern"===(null==(t=e.id)?void 0:t.type)&&"CallExpression"===(null==(n=e.init)?void 0:n.type)&&this.isPPStateCall(e.init)}transformSpreadElement(e,t){var n;return"Identifier"===(null==(n=e.argument)?void 0:n.type)&&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){var n;return"Identifier"===(null==(n=e.argument)?void 0:n.type)&&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){var n,s;if(["===","!==","==","!=",">","<",">=","<=","+","-","*","/","%","**","&","|","^","<<",">>",">>>","in","instanceof"].includes(e.operator)){if("Identifier"===(null==(n=e.left)?void 0:n.type)&&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("Identifier"===(null==(s=e.right)?void 0:s.type)&&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(t,n){try{const s=D(t,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=t;const r=[];return U(s,{CallExpression:t=>{const s=i.slice(t.callee.start,t.callee.end);if(e.isFunctionNeedingValueTransform(s)&&t.arguments.length>0)for(const e of t.arguments)if("Identifier"===e.type&&this.stateVariables.has(e.name)){if(n&&n.has(e.name))continue;this.alreadyHasValue(e,i)||r.push({start:e.start,end:e.end,replacement:`${e.name}.value`})}}}),r.sort(((e,t)=>t.start-e.start)).forEach((e=>{i=i.slice(0,e.start)+e.replacement+i.slice(e.end)})),i}catch(e){return console.error("Multiple call arguments transformation error:",e),t}}transformDestructuringAssignments(e){try{const t=D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{VariableDeclarator:t=>{var n,i,r;this.isStateDeclaration(t)||("ArrayPattern"===(null==(n=t.id)?void 0:n.type)||"ObjectPattern"===(null==(i=t.id)?void 0:i.type))&&"Identifier"===(null==(r=t.init)?void 0:r.type)&&this.stateVariables.has(t.init.name)&&(this.alreadyHasValue(t.init,e)||s.push({start:t.init.start,end:t.init.end,replacement:`${t.init.name}.value`}))},AssignmentExpression:t=>{var n,i,r;("ArrayPattern"===(null==(n=t.left)?void 0:n.type)||"ObjectPattern"===(null==(i=t.left)?void 0:i.type))&&"Identifier"===(null==(r=t.right)?void 0:r.type)&&this.stateVariables.has(t.right.name)&&(this.alreadyHasValue(t.right,e)||s.push({start:t.right.start,end:t.right.end,replacement:`${t.right.name}.value`}))}}),s.sort(((e,t)=>t.start-e.start)).forEach((e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)})),n}catch(t){return console.error("Destructuring transformation error:",t),e}}alreadyHasValue(e,t){const n=e.end;return t.slice(n,n+6).startsWith(".value")}transformStateDeclarator(e,t){var n,s;if("ArrayPattern"!==(null==(n=e.id)?void 0:n.type)||"CallExpression"!==(null==(s=e.init)?void 0:s.type))return null;const i=e.init;if(!this.isPPStateCall(i))return null;const r=e.id.elements[0];if(!r||"Identifier"!==r.type)return null;const a=r.name,o=`set${this.capitalize(a)}`,c=e.id.elements[1];return"Identifier"===(null==c?void 0:c.type)&&c.name!==o&&console.warn(`Setter name mismatch: expected ${o}, got ${c.name}`),this.createTransformation(i,a,t)}isPPStateCall(e){var t,n,s;return"MemberExpression"===(null==(t=e.callee)?void 0:t.type)&&"Identifier"===(null==(n=e.callee.object)?void 0:n.type)&&"pp"===e.callee.object.name&&"Identifier"===(null==(s=e.callee.property)?void 0:s.type)&&"state"===e.callee.property.name}createTransformation(e,t,n){const s=e.arguments;if(0===s.length){const n=`pp.state("${t}")`;return{start:e.start,end:e.end,replacement:n}}const i=s[0];if("Literal"===i.type&&"string"==typeof i.value&&i.value===t)return null;if(1===s.length){const s=`pp.state("${t}", ${n.slice(i.start,i.end)})`;return{start:e.start,end:e.end,replacement:s}}const r=`pp.state("${t}", ${n.slice(e.arguments[0].start,e.arguments[e.arguments.length-1].end)})`;return{start:e.start,end:e.end,replacement:r}}looksLikeVariableName(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&e.length<=50&&!e.includes(" ")}extractStateDeclarations(e){const t=[];try{U(D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0}),{VariableDeclarator:n=>{const s=this.extractStateFromDeclarator(n,e);s&&t.push(s)}})}catch(e){console.error("State extraction error:",e)}return t}extractStateFromDeclarator(e,t){var n,s,i,r;if("ArrayPattern"!==(null==(n=e.id)?void 0:n.type)||"CallExpression"!==(null==(s=e.init)?void 0:s.type)||!this.isPPStateCall(e.init))return null;const a=e.id.elements[0],o=e.id.elements[1];if("Identifier"!==(null==a?void 0:a.type)||"Identifier"!==(null==o?void 0:o.type))return null;const c=e.init.arguments;let h,l=a.name;return c.length>=1&&("Literal"===c[0].type&&"string"==typeof c[0].value?this.looksLikeVariableName(c[0].value)?(l=c[0].value,c.length>=2&&(h=this.extractLiteralValue(c[1]))):(l=a.name,h=this.extractLiteralValue(c[0])):h=this.extractLiteralValue(c[0])),{variableName:a.name,setterName:o.name,stateKey:l,initialValue:h,line:(null==(i=e.loc)?void 0:i.start.line)||0,column:(null==(r=e.loc)?void 0:r.start.column)||0}}extractFunctionDeclarations(e){const t=[];try{U(D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0}),{FunctionDeclaration:e=>{var n,s;"Identifier"===(null==(n=e.id)?void 0:n.type)&&t.push({name:e.id.name,type:"function",params:e.params.map((e=>"Identifier"===e.type?e.name:"")),line:(null==(s=e.loc)?void 0:s.start.line)||0})},VariableDeclarator:e=>{var n,s,i,r;if("Identifier"===(null==(n=e.id)?void 0:n.type)&&("ArrowFunctionExpression"===(null==(s=e.init)?void 0:s.type)||"FunctionExpression"===(null==(i=e.init)?void 0:i.type))){const n=e.init;t.push({name:e.id.name,type:"ArrowFunctionExpression"===n.type?"arrow":"function",params:n.params.map((e=>"Identifier"===e.type?e.name:"")),line:(null==(r=e.loc)?void 0:r.start.line)||0})}}})}catch(e){console.error("Function extraction error:",e)}return t}extractLiteralValue(e){if("Literal"===e.type)return e.value;"Identifier"===e.type&&e.name}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}};d(Z,"instance"),d(Z,"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"]));let Ne=Z;class Ys{constructor(e,t){d(this,"textNodeBindings",new Map),d(this,"expressionEvaluator"),d(this,"stateManager"),d(this,"componentManager"),d(this,"cleanupObserver"),d(this,"bindingCount",0),this.expressionEvaluator=e,this.stateManager=t,this.cleanupObserver=new MutationObserver((e=>{this.cleanupDetachedNodes(e)})),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}cleanupDetachedNodes(e){const t=[];for(const n of e)"childList"===n.type&&n.removedNodes.forEach((e=>{if(e.nodeType===Node.TEXT_NODE)t.push(e);else if(e.nodeType===Node.ELEMENT_NODE){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let s;for(;s=n.nextNode();)t.push(s)}}));Promise.resolve().then((()=>{t.forEach((e=>{document.contains(e)||this.cleanupTextNode(e)}))}))}processTextNode(e,t){if(this.shouldSkipTextNode(e))return;const n=k.findScope(e);let s;if(n)s="app"===n?"app":n;else{const n=e.parentElement;s=n?A.getContextComponent(n):t}const i=e.textContent||"",r=L.parse(i);if(!this.hasValidExpressions(r))return;const a=this.resolveComponentRootForElement(e,s),o=this.createTextNodeBinding(i,r,s,a);this.setupExpressionSubscriptions(e,r,s,a,o),this.textNodeBindings.set(e,o),this.bindingCount++,this.updateTextNode(e)}shouldSkipTextNode(e){return this.textNodeBindings.has(e)||A.isTextNodeInsideScript(e)||this.isInsideLoopItem(e)}hasValidExpressions(e){return e.some((e=>"expression"===e.type))}createTextNodeBinding(e,t,n,s){return{originalContent:e,expressions:t,subscriptionIds:[],component:n,componentElement:s}}setupExpressionSubscriptions(e,t,n,s,i){t.filter((e=>"expression"===e.type)).forEach((t=>{if(!t.expression)return;const r=`text_${Date.now()}_${Math.random()}`,a=this.expressionEvaluator.extractDependencies(t.expression,n,this.stateManager);if(s&&this.componentManager){const e=this.componentManager.getComponentPropDependencies(s,n);a.push(...e)}const o={id:r,selector:"",dependencies:new Set(a),callback:()=>{this.updateTextNode(e)},element:e.parentElement??void 0,component:n};this.stateManager.addSubscription(o),i.subscriptionIds.push(r)}))}updateTextNode(e){const t=this.textNodeBindings.get(e);if(!t||!e.parentElement)return;const n=this.resolveBindingComponentElement(e,t),s=this.buildEvaluationContext(e,t,n),i=this.evaluateExpressionsToText(t.expressions,s,t.component);this.applyTextUpdate(e,i)}resolveBindingComponentElement(e,t){let{componentElement:n}=t;return(!n||!document.contains(n))&&(n=this.resolveComponentRootForElement(e,t.component),t.componentElement=n),n}buildEvaluationContext(e,t,n){let s=this.componentManager.buildComponentContext(t.component);const i=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t.component}"]`);let r=!1;for(const e of i)if(this.componentManager.hasStoredProps(e)){const t=this.componentManager.evaluateProps(e);s={...s,...t},r=!0;break}if(!r){let t=e.parentElement;for(;t&&t!==document.body;){if(t.hasAttribute(g.ATTR_PREFIXES.COMPONENT)&&this.componentManager.hasStoredProps(t)){const e=this.componentManager.evaluateProps(t);s={...s,...e};break}t=t.parentElement}}return os(s)}evaluateExpressionsToText(e,t,n){let s="";for(const i of e)if("static"===i.type)s+=i.content;else if(i.expression)try{s+=Ce(this.expressionEvaluator.evaluateExpression(i.expression,t,n))}catch(e){console.error(`❌ Text binding evaluation error for "${i.expression}":`,e),console.error(`Component: ${n}`),console.error(`Available variables: [${Object.keys(t).join(", ")}]`),s+=""}return s}applyTextUpdate(e,t){e.textContent!==t&&(e.textContent=t)}isInsideLoopItem(e){var t,n,s;let i=e.parentElement;for(;i&&i!==document.body;){const e=i.previousSibling;if(e&&e.nodeType===Node.COMMENT_NODE&&null!=(t=e.textContent)&&t.startsWith("pp-for:"))return!0;let r=(null==(n=i.parentElement)?void 0:n.firstChild)||null;for(;r;){if(r.nodeType===Node.COMMENT_NODE&&null!=(s=r.textContent)&&s.startsWith("pp-for:")&&r!==i)return!0;r=r.nextSibling}i=i.parentElement}return!1}resolveComponentRootForElement(e,t){const n=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`);if(this.componentManager)for(const e of n)if(this.componentManager.hasStoredProps(e))return e;return n[0]||void 0}cleanupTextNode(e){const t=this.textNodeBindings.get(e);t&&(t.subscriptionIds.forEach((e=>{this.stateManager.removeSubscription(e)})),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()}}const le=class e{constructor(){d(this,"delegatedEvents",new Map),d(this,"elementHandlers",new WeakMap),d(this,"handlerCache",new G(200)),d(this,"componentManager"),d(this,"expressionEvaluator"),d(this,"loopManager"),d(this,"setupEvents",new Set)}static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}static getAllAvailableEvents(){if(e.eventCache)return e.eventCache;const t=new Set,n=["click","input","change","submit","focus","blur","keydown","keyup","mousedown","mouseup","mouseover","mouseout"];try{Object.getOwnPropertyNames(HTMLElement.prototype).filter((e=>e.startsWith("on")&&e.length>2)).map((e=>e.substring(2).toLowerCase())).forEach((e=>t.add(e)))}catch(e){console.warn("Could not get HTMLElement events:",e),n.forEach((e=>t.add(e)))}try{Object.getOwnPropertyNames(Document.prototype).filter((e=>e.startsWith("on")&&e.length>2)).map((e=>e.substring(2).toLowerCase())).forEach((e=>t.add(e)))}catch(e){console.warn("Could not get Document events:",e)}try{Object.getOwnPropertyNames(Window.prototype).filter((e=>e.startsWith("on")&&e.length>2)).map((e=>e.substring(2).toLowerCase())).forEach((e=>t.add(e)))}catch(e){console.warn("Could not get Window events:",e)}try{Object.getOwnPropertyNames(Element.prototype).filter((e=>e.startsWith("on")&&e.length>2)).map((e=>e.substring(2).toLowerCase())).forEach((e=>t.add(e)))}catch(e){console.warn("Could not get Element events:",e)}return new Set(["beforeunload","unload","pagehide","pageshow","popstate","hashchange","storage","message","messageerror","offline","online","languagechange","rejectionhandled","unhandledrejection","afterprint","beforeprint","devicemotion","deviceorientation","deviceorientationabsolute"]).forEach((e=>t.delete(e))),e.eventCache=t,t}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),("focusin"===e||"focusout"===e)&&(t.capture=!1),t}isEventSupported(t){return e.getAllAvailableEvents().has(t.toLowerCase())}getAllSupportedEvents(){return Array.from(e.getAllAvailableEvents()).sort()}getDelegatedEvents(){return Array.from(this.delegatedEvents.keys()).sort()}setDependencies(e,t,n,s){this.componentManager=e,this.expressionEvaluator=t,this.loopManager=s}createDelegatedListener(e){return t=>{const n=t.target;if(!n)return;const s=this.findHandler(n,e);s&&this.executeHandler(s.handler,s.element,t)}}registerEventHandler(e,t,n,s){const i=t.toLowerCase();if(this.ensureEventSetup(i),!this.isEventSupported(i))return;const r=s;this.elementHandlers.has(e)||this.elementHandlers.set(e,new Map);const a={code:n,component:r};this.elementHandlers.get(e).set(i,a);const o=this.delegatedEvents.get(i);o?o.elements.add(e):(console.warn(`⚠️ No delegated listener for ${i}, attaching directly`),this.attachDirectListener(e,i,a))}ensureEventSetup(e){if(!this.setupEvents.has(e)){if(!this.isEventSupported(e))return void console.warn(`⚠️ Attempting to setup unsupported event: ${e}`);try{const t=this.createDelegatedListener(e),n=this.getEventOptions(e);document.addEventListener(e,t,n),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 n=e;for(;n;){const e=this.elementHandlers.get(n);if(null!=e&&e.has(t))return{handler:e.get(t),element:n};n=n.parentElement}return null}compileHandler(e,t){const n=`${t}:${e}`;if(this.handlerCache.has(n))return this.handlerCache.get(n);let s=e;e.includes("this")&&(s=s.replace(/\bthis\b/g,"thisElement")),e.includes("event")&&(s=s.replace(/\bevent\b/g,"eventObject"));const i=new Function("eventObject","thisElement","context",`\n try {\n with(context) {\n ${s}\n }\n } catch(error) {\n console.error('Event handler execution error:', error);\n console.error('Handler code:', ${JSON.stringify(e)});\n console.error('Component:', '${t}');\n console.error('Available context keys:', Object.keys(context));\n }\n `);return this.handlerCache.set(n,i),i}executeHandler(e,t,n){var s;if(this.componentManager&&this.expressionEvaluator)try{const{effectiveComponent:i,useStrictScope:r,scopedComponent:a,actualElementComponent:o}=this.resolveEffectiveComponent(t,e),c=this.locateComponentElement(t,i,o),h=this.findNearestComponentWithProps(t);let l=r?this.buildContextStrict(a,i,c,t):this.buildContextNonStrict(i,c,h);l=os(l),l=this.mergeLoopContext(t,l),this.ensureCompiled(e),null==(s=e.compiledFn)||s.call(e,n,t,l)}catch(t){console.error("💥 Event handler execution failed:",t),console.error("Handler code:",e.code),console.error("Handler component:",e.component)}else console.warn("EventDelegationManager dependencies not set")}resolveEffectiveComponent(e,t){const n=k.findScope(e),s=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);return n?{effectiveComponent:"app"===n?"app":n,useStrictScope:!0,scopedComponent:n,actualElementComponent:s}:t.component?{effectiveComponent:t.component,useStrictScope:!1,scopedComponent:null,actualElementComponent:s}:s?{effectiveComponent:s,useStrictScope:!1,scopedComponent:null,actualElementComponent:s}:{effectiveComponent:"app",useStrictScope:!1,scopedComponent:null,actualElementComponent:null}}locateComponentElement(e,t,n){if(n&&n===t)return e;let s=e.parentElement;for(;s&&s!==document.body;){if(s.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return s;s=s.parentElement}for(s=e.parentElement;s&&s!==document.body;){if(s.getAttribute(g.ATTR_PREFIXES.COMPONENT))return s;s=s.parentElement}const i=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const e of i)if(this.componentManager.hasStoredProps(e))return e;return i.length>0?i[0]:null}findNearestComponentWithProps(e){let t=e.parentElement;for(;t&&t!==document.body;){if(t.hasAttribute(g.ATTR_PREFIXES.COMPONENT)&&this.componentManager.hasStoredProps(t))return t;t=t.parentElement}return null}buildContextStrict(e,t,n,s){if(t&&t!==e){let s=this.componentManager.buildComponentContext(t);if(n&&this.componentManager.hasStoredProps(n)){const e=this.componentManager.evaluateProps(n);s={...s,...e}}if(e&&e!==t)if("app"===e){const e=this.componentManager.buildComponentContext("app");for(const[t,n]of Object.entries(e))t in s||(s[t]=n)}else{const t=this.componentManager.buildComponentContext(e);for(const[e,n]of Object.entries(t))e in s||(s[e]=n)}return s}if("app"===e){let e=this.componentManager.buildComponentContext("app");if(n&&n!==document.body&&this.componentManager.hasStoredProps(n)){const t=this.componentManager.evaluateProps(n);e={...e,...t}}return e}let i=this.componentManager.buildComponentContext(t);if(n&&this.componentManager.hasStoredProps(n)){const e=this.componentManager.evaluateProps(n);i={...i,...e}}return i}buildContextNonStrict(e,t,n){if(n){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===e)return this.componentManager.buildComponentContextWithProps(e,n);if("app"===k.findScope(n)){let e={};e.getContext=()=>this.componentManager.buildComponentContext("app"),e.withContext=e=>{const t=this.componentManager.buildComponentContext("app");return e.call(t,t)},e.__getProp=e=>this.componentManager.evaluateProps(n)[e];const t=this.componentManager.evaluateProps(n);e={...e,...t};const s=n.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(s){const t=this.componentManager.getComponentFunctions(s);if(t)for(const[n,s]of t)e[n]=s}return e}const t=this.componentManager.buildRestrictedComponentContext(e,!1),s=this.componentManager.evaluateProps(n);return Object.assign(t,s),t}if(t&&t.getAttribute(g.ATTR_PREFIXES.COMPONENT)===e)return this.componentManager.buildComponentContextWithProps(e,t);const s=this.componentManager.buildRestrictedComponentContext(e,!1),i=t||n;if(i&&this.componentManager.hasStoredProps(i)){const e=this.componentManager.evaluateProps(i);Object.assign(s,e)}return s}mergeLoopContext(e,t){var n;const s=null==(n=this.loopManager)?void 0:n.getLoopContextForElement(e);if(!s)return t;const i={};for(const[e,t]of Object.entries(s))i[e]="function"==typeof t&&"__pphp_key"in t?t.value:t;return{...t,...i}}ensureCompiled(e){e.compiledFn||(e.compiledFn=this.compileHandler(e.code,e.component))}attachDirectListener(e,t,n){const s=t=>{this.executeHandler(n,e,t)};e.addEventListener(t,s),e[`__${t}_listener`]=s}removeEventHandler(e,t){var n,s;const i=this.elementHandlers.get(e);i&&(i.delete(t),0===i.size&&this.elementHandlers.delete(e));const r=this.delegatedEvents.get(t);r&&(null==(s=(n=r.elements).delete)||s.call(n,e));const a=e[`__${t}_listener`];a&&(e.removeEventListener(t,a),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()}};d(le,"eventCache",null);let ie=le;class Js{constructor(e,t,n){d(this,"stateManager"),d(this,"componentManager"),d(this,"expressionEvaluator"),d(this,"textNodeManager"),d(this,"observer"),d(this,"listeners",new WeakMap),d(this,"pendingBindings",[]),d(this,"pendingTextNodes",[]),d(this,"applyingUpdates",!1),d(this,"elementCache",new WeakMap),d(this,"batchedUpdates",new Set),d(this,"processingRAF",null),d(this,"updateQueue",new Map),d(this,"eventDelegation",new ie),d(this,"processedElements",new WeakSet),d(this,"loopManager"),d(this,"templateRenderer"),d(this,"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"}),d(this,"lastValueCache",new WeakMap),d(this,"stringValueCache",new G(500)),d(this,"refBindings",new WeakMap),d(this,"isRelevantMutation",(e=>{if(this.applyingUpdates&&"attributes"===e.type)return!1;if("childList"===e.type||"characterData"===e.type)return!0;if("attributes"===e.type){const t=e.attributeName;return t===g.ATTR_PREFIXES.COMPONENT||null!==t&&ie.isEventAttribute(t)}return!1})),this.stateManager=e,this.componentManager=t,this.expressionEvaluator=n,this.textNodeManager=new Ys(n,e),this.textNodeManager.componentManager=this.componentManager,this.componentManager.setDOMBindingManager(this),this.setupMutationObserver(),this.eventDelegation.setupEventDelegation(),this.loopManager=new Zs(e,n),this.loopManager.setDependencies(t,this),this.loopManager.eventDelegation=this.eventDelegation,this.eventDelegation.setDependencies(this.componentManager,this.expressionEvaluator,this.stateManager,this.loopManager),this.templateRenderer=new ve(n)}refreshComponentElement(e,t){this.elementCache.delete(e),this.processedElements.delete(e);const n=[...this.componentManager.componentStack];this.componentManager.componentStack=["app"],"app"!==t&&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=n}}refreshComponentTextNodes(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>{const n=e;return!n.textContent||!g.MUSTACHE_PATTERN.test(n.textContent)||A.isTextNodeInsideScript(n)||this.isTextNodeInsideLoopItem(n)||A.getComponentForNode(n)!==t?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let s;const i=[];for(;s=n.nextNode();)i.push(s);i.forEach((e=>{this.textNodeManager.cleanupTextNode(e),this.textNodeManager.cleanupTextNode(e),this.textNodeManager.processTextNode(e,t)}))}walkComponentChildren(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const s=n;return A.getElementComponent(s)!==t?NodeFilter.FILTER_REJECT:s===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}});let s;const i=[];for(;s=n.nextNode();){const e=s;i.push(e)}i.forEach((n=>{this.elementCache.delete(n),this.processedElements.delete(n);const s=this.componentManager.buildComponentContextWithProps(t,e);this.processElementInContext(n,s,t,!0)}))}createSpreadDirectiveBinding(e,t,n){const s=`spread_${Date.now()}_${Math.random()}`,i=L.parseSpreadDirective(t);if(0===i.spreads.length&&0===i.objects.length)return void console.warn(`Invalid pp-spread directive: ${t}`);const r=new Set,a=()=>{if(document.contains(e))try{const t=this.componentManager.buildComponentContextWithProps(n,e);this.clearSpreadAttributes(e,r);for(const s of i.spreads){const i=this.expressionEvaluator.evaluateExpression(s,t,n);i&&"object"==typeof i&&this.applySpreadObject(e,i,r)}for(const s of i.objects)this.applyObjectProperties(e,s,t,n,r)}catch(e){console.error(`Spread directive evaluation error for "${t}":`,e)}else this.stateManager.removeSubscription(s)},o=new Set;for(const e of i.spreads)this.templateRenderer.dependencies(e,n,this.stateManager).forEach((e=>o.add(e)));for(const e of i.objects)for(const t of e)this.templateRenderer.dependencies(t.value,n,this.stateManager).forEach((e=>o.add(e)));const c={id:s,selector:"",dependencies:o,callback:a,element:e,component:n};this.stateManager.addSubscription(c),this.storeSpreadSubscription(e,s),a()}applyObjectProperties(e,t,n,s,i){for(const r of t)try{const t=this.expressionEvaluator.evaluateExpression(r.value,n,s);if(this.isEventProperty(r.key)){this.handleSpreadEventProperty(e,r.key,t);continue}const a=this.normalizeAttributeName(r.key);this.updateElementProperty(e,a,t),i.add(a)}catch(e){console.error(`Error evaluating object property "${r.key}: ${r.value}":`,e)}}applySpreadObject(e,t,n){for(const[s,i]of Object.entries(t))if(null!=i){if(this.isEventProperty(s)){this.handleSpreadEventProperty(e,s,i);continue}const t=this.normalizeAttributeName(s);(!e.hasAttribute(t)||n.has(t))&&(this.updateElementProperty(e,t,i),n.add(t))}}isEventProperty(e){return e.startsWith("on")&&e.length>2}handleSpreadEventProperty(e,t,n){const s=t.substring(2).toLowerCase();if("function"==typeof n){const t=t=>{var s;try{const i=A.getContextComponent(e),r=(null==(s=this.componentManager)?void 0:s.buildComponentContextWithProps(i,e))||{};n.call(r,t)}catch(e){console.error("Spread event handler error:",e)}};return e.addEventListener(s,t),void this.storeDirectEventListener(e,s,t)}if("string"==typeof n){const t=A.getContextComponent(e);this.eventDelegation.registerEventHandler(e,s,n,t)}}storeDirectEventListener(e,t,n){e.__directEventListeners||(e.__directEventListeners=[]),e.__directEventListeners.push({eventType:t,listener:n})}clearSpreadAttributes(e,t){for(const n of t)e.hasAttribute(n)&&e.removeAttribute(n);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(0===t.length)return;const n=je.getInstance(),s=new Set;for(const e of t)if("childList"===e.type&&(e.removedNodes.forEach((t=>{if(t.nodeType===Node.ELEMENT_NODE){const e=t;this.cleanupRefBinding(e),e.querySelectorAll(`[${g.ATTR_PREFIXES.REF}]`).forEach((e=>{this.cleanupRefBinding(e)})),n.invalidateElement(e),k.invalidateTree(e);const s=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);s&&n.invalidateByComponent(s)}else if(t.nodeType===Node.COMMENT_NODE){const t=e.target;t&&s.add(t)}})),e.addedNodes.forEach((t=>{if(t.nodeType===Node.ELEMENT_NODE){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);e&&n.invalidateByComponent(e)}else if(t.nodeType===Node.COMMENT_NODE){const t=e.target;t&&s.add(t)}}))),"attributes"===e.type&&e.target){const t=e.target;n.invalidateElement(t);const s=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);s&&n.invalidateByComponent(s)}s.forEach((e=>{k.invalidateTree(e)})),this.processMutationsBatch(t)})),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0,characterDataOldValue:!1,attributeFilter:[g.ATTR_PREFIXES.COMPONENT]})}processElement(e,t=!0){if(e===document.body){const n=Array.from(document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}]`)).sort(((e,t)=>A.getElementDepth(e)-A.getElementDepth(t)));this.processElementsBatch([e],t),n.forEach((e=>{this.processElementsBatch([e],t)})),t&&this.loopManager.processPendingTemplates()}else this.processElementsBatch([e],t)}processElementsBatch(e,t=!0){for(const n of e)this.processSingleElement(n,t);t&&(e.forEach((e=>{this.componentManager.executePhpScripts(e)})),this.processPendingBindings())}processSingleElement(e,t){const n=A.getElementComponent(e),s=k.findScope(e);let i;i=s?"app"===s?"app":s:A.getParentComponentForElement(e);const r=this.componentManager.componentStack.length;"app"!==n&&this.componentManager.pushComponent(n),this.componentManager.setupProps(e,i),t&&this.componentManager.executePhpScripts(e),this.processLoopTemplates(e,n);const a=t?this.componentManager.buildComponentContextWithProps(n,e):{};for(this.processElementInContext(e,a,n,t),this.walkDOM(e,a,n,t);this.componentManager.componentStack.length>r;)this.componentManager.popComponent()}processLoopTemplates(e,t){this.getDirectComponentTemplates(e,t).forEach((e=>{this.loopManager.queueTemplate(e,t)}))}getDirectComponentTemplates(e,t){const n=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:t=>{const n=t;return n!==e&&n.hasAttribute(g.ATTR_PREFIXES.COMPONENT)?NodeFilter.FILTER_REJECT:"TEMPLATE"===n.tagName&&n.hasAttribute("pp-for")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let i;for(;i=s.nextNode();)n.push(i);return n}walkDOM(e,t,n,s){const i=it.getInstance(),r=`walkDOM_${n}_${s}`,a=i.getCachedTraversal(e,r,(()=>{const t=i.traverseElementsAndText(e,(t=>{if(t===e||"script"===t.tagName.toLowerCase()||this.loopManager.isLoopItem(t))return!1;let s=t.parentElement;for(;s&&s!==e;){if(this.loopManager.isLoopItem(s))return!1;s=s.parentElement}return!(A.getElementComponent(t)!==n||this.processedElements.has(t))}),(e=>{if(!e.textContent||!g.MUSTACHE_PATTERN.test(e.textContent)||A.isTextNodeInsideScript(e)||this.isTextNodeInsideLoopItem(e))return!1;const t=e.parentElement;if(t){const s=A.getContextComponent(t),i=A.getComponentForNode(e);if(s!==n&&i!==n)return!1}else if(A.getComponentForNode(e)!==n)return!1;return!0}));return[...t.textNodes,...t.elements]})),o=[],c=[];a.forEach((e=>{if(e.nodeType===Node.TEXT_NODE)o.push(e);else if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.hasAttribute(`${g.ATTR_PREFIXES.REF}`)&&s){const e=t.getAttribute(`${g.ATTR_PREFIXES.REF}`);this.createRefBinding(t,e,n),t.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}c.push(t),this.processedElements.add(t)}})),o.forEach((e=>{const t=e.parentElement,i=t?A.getContextComponent(t):n;s?this.textNodeManager.processTextNode(e,i):this.pendingTextNodes.push({textNode:e,component:i})})),c.forEach((e=>{this.processElementInContext(e,t,n,s)}))}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,n,s){if(e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)){const t=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);s&&this.createRefBinding(e,t,n),e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}if(e.hasAttribute(`${g.ATTR_PREFIXES.SPREAD}`)){const t=e.getAttribute(`${g.ATTR_PREFIXES.SPREAD}`);s&&this.createSpreadDirectiveBinding(e,t,n),e.removeAttribute(g.ATTR_PREFIXES.SPREAD)}if(this.loopManager.isLoopItem(e)||this.isElementInLoopItem(e))return;const i=this.extractDomMustacheBindings(e),r=this.elementCache.get(e),a=this.getElementHash(e);if(r&&r.hash===a&&this.isCacheValid(r)&&s)return void this.applyBindingsFromCache(e,r,t);const o={bindings:i,component:n,listeners:[],lastProcessed:Date.now(),hash:a};s?this.applyBindings(e,i,t,n):i.forEach(((t,s)=>{this.pendingBindings.push({element:e,property:s,expression:t,component:n})})),this.setupEventBindings(e,n),this.elementCache.set(e,o)}createRefBinding(e,t,n){try{const n=L.decodeEntities(t),s=L.isSingleExpression(n)||n,i=A.getContextComponent(e),r=this.componentManager.buildComponentContextWithProps(i,e);try{const t=this.expressionEvaluator.evaluateExpression(s,r,i);if("function"==typeof t){const n=t;this.refBindings.set(e,{element:e,callback:n,component:i}),n(e)}else if(t&&"object"==typeof t&&"current"in t){const n=t;this.refBindings.set(e,{element:e,refObject:n,component:i}),n.current=e}else console.warn(`⚠️ ${g.ATTR_PREFIXES.REF} expression did not return a ref object or callback: ${s}`,t)}catch(e){console.error(`❌ Failed to evaluate ref "${s}":`,e)}}catch(e){console.error(`❌ Failed to create ref binding for "${t}":`,e)}}isElementInLoopItem(e){let t=e;for(;t;){if(this.loopManager.isLoopItem(t))return!0;t=t.parentElement}return!1}extractDomMustacheBindings(e){var t;const n=new Map,s=e.attributes,i=this.elementCache.get(e),r=k.findScope(e),a=e.getAttribute(g.ATTR_PREFIXES.COMPONENT),o=a&&(null==(t=this.componentManager)?void 0:t.hasStoredProps(e)),c=r&&a&&r!==a;for(let t=0;t<s.length;t++){const r=s[t];if(r.name!==g.ATTR_PREFIXES.COMPONENT&&"key"!==r.name&&!ie.isEventAttribute(r.name)&&(!i||!i.bindings.has(r.name))&&r.value){const t=g.MUSTACHE_PATTERN.test(r.value),s=L.decodeEntities(r.value),i=g.MUSTACHE_PATTERN.test(s);if(t||i){if(this.looksLikeSerializedObject(s))continue;const a=L.extractExpressions(s),h=A.getContextComponent(e);if(0===a.length&&(t||i)){console.error(`\n❌ Malformed mustache expression in attribute "${r.name}":`),console.error(` Value: ${s}`),console.error(" Element:",e),console.error(` Component: ${h}`),console.error(" 💡 The expression has mustache syntax {} but couldn't be parsed"),console.error(" 💡 Common causes: unmatched quotes, unclosed braces, invalid syntax\n"),o||c&&A.shouldBeDirectBinding(e,r.name)?n.set(r.name,s):c||n.set(r.name,s);continue}for(const t of a){const n=nn.validate(t,h);n.valid||(console.error(`\n❌ Invalid expression in attribute "${r.name}":`),console.error(` Expression: ${t}`),console.error(` Original HTML: ${r.value}`),console.error(` Decoded: ${s}`),console.error(" Element:",e),console.error(` Component: ${h}`),n.errors.forEach((e=>{console.error(` ⚠️ ${e}`)})),console.error(" 💡 Hint: Check your quotes and syntax in conditional expressions"),console.error(" 💡 Example: class=\"{isActive ? 'text-blue-500' : 'text-gray-500'}\"\n")),n.warnings.length>0&&(console.warn(`\n⚠️ Expression warnings in attribute "${r.name}":`),console.warn(` Expression: ${t}`),console.warn(" Element:",e),n.warnings.forEach((e=>{console.warn(` • ${e}`)})))}o||c&&A.shouldBeDirectBinding(e,r.name)?n.set(r.name,s):c||n.set(r.name,s)}}}return n}applyBindings(e,t,n,s){t.forEach(((t,n)=>{this.createMustacheBinding(e,n,t)})),this.setupEventBindings(e,s)}applyBindingsFromCache(e,t,n){t.bindings.forEach(((n,s)=>{try{const i=this.componentManager.buildComponentContextWithProps(t.component,e),r=this.templateRenderer.render(n,i,t.component);this.updateElementProperty(e,s,r)}catch(e){console.error(`Cached binding evaluation error for "${n}":`,e)}}))}createMustacheBinding(e,t,n){const s=`mustache_${Date.now()}_${Math.random()}`,i=k.findScope(e),r=null!==e.getAttribute(g.ATTR_PREFIXES.COMPONENT);let a,o=!1,c=!1;i?(a="app"===i?"app":i,c=!0,o=!1):r?(a=A.getParentComponentForElement(e),o=!0,c=!1):(a=A.getContextComponent(e),o=!1,c=!1),e.removeAttribute(t);let h=null,l=e.parentElement;for(;l&&l!==document.body;){if(l.hasAttribute(g.ATTR_PREFIXES.COMPONENT)){h=l;break}l=l.parentElement}const p=this.templateRenderer.dependencies(n,a,this.stateManager),u=new Set(p),d=this.findComponentElementForMustacheBinding(e,a);if(d&&this.componentManager){const e=this.componentManager.elementProps.get(d);if(e)for(const t of p){const n=t.split("."),s=n[n.length-1];if(e.has(s)){const t=e.get(s);this.templateRenderer.dependencies(t.expression,t.component,this.stateManager).forEach((e=>u.add(e)))}}}if(h&&h!==d&&this.componentManager&&this.componentManager.hasStoredProps(h)){const e=this.componentManager.elementProps.get(h);if(e)for(const t of p){const n=t.split("."),s=n[n.length-1];if(e.has(s)){const t=e.get(s);this.templateRenderer.dependencies(t.expression,t.component,this.stateManager).forEach((e=>u.add(e)))}}}const m=()=>{if(document.contains(e))try{let s;if(c){if(s=this.componentManager.buildComponentContextWithProps(a,d||void 0),e!==d&&r&&this.componentManager.elementProps.get(e)){const t=this.componentManager.evaluateProps(e);s={...s,...t}}}else if(o){let t=null,n=e.parentElement;for(;n&&n!==document.body;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===a){t=n;break}n=n.parentElement}if(s=this.componentManager.buildComponentContextWithProps(a,t||void 0),e!==t&&this.componentManager.hasStoredProps(e)){const t=this.componentManager.evaluatePropsWithContext(e,a,e);s={...s,...t}}}else{const t=this.findComponentElementForMustacheBinding(e,a);if(t){if(s=this.componentManager.buildRestrictedComponentContextWithProps(a,t),e!==t&&this.componentManager.hasStoredProps(e)){const t=this.componentManager.evaluatePropsWithContext(e,a,e);s={...s,...t}}}else{if(s=this.componentManager.buildRestrictedComponentContext(a,!1),t&&this.componentManager.hasStoredProps(t)){const e=this.componentManager.evaluateProps(t);Object.assign(s,e)}if(e!==t&&this.componentManager.hasStoredProps(e)){const t=this.componentManager.evaluatePropsWithContext(e,a,e);Object.assign(s,t)}}}if(h&&this.componentManager&&this.componentManager.hasStoredProps(h)){const e=this.componentManager.evaluateProps(h);s={...s,...e}}const i=this.templateRenderer.render(n,s,a);this.scheduleElementUpdate(e,t,i)}catch(e){console.error(`Mustache binding evaluation error for "${n}":`,e),console.error(`Context component: ${a}`),console.error(`Use strict scope: ${c}`)}else this.stateManager.removeSubscription(s)},f={id:s,selector:"",dependencies:u,callback:m,element:e,component:a};this.stateManager.addSubscription(f),m()}findComponentElementForMustacheBinding(e,t){if(e.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return n;n=n.parentElement}const s=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const e of s)if(this.componentManager&&this.componentManager.hasStoredProps(e))return e;return s[0]||null}setupEventBindings(e,t){const n=k.findScope(e),s=n?"app"===n?"app":n:t;for(let t=0;t<e.attributes.length;t++){const n=e.attributes[t];if(ie.isEventAttribute(n.name)){const t=n.name.substring(2);this.eventDelegation.registerEventHandler(e,t,n.value,s),e.removeAttribute(n.name)}}}scheduleElementUpdate(e,t,n){this.isCriticalProperty(t)?this.updateElementProperty(e,t,n):(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}`]=n)}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 n of t){const t=e[`__pending_${n}`];this.updateElementProperty(e,n,t),delete e[`__pending_${n}`]}}}finally{this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF=null,this.applyingUpdates=!1}}updateElementProperty(e,t,n){const s=We(n),i=this.lastValueCache.get(e);if(i&&this.isSameValue(i.get(t),s))return;const r=this.applyingUpdates;this.applyingUpdates=!0;try{switch(t){case"textContent":const n=this.cachedValueToString(s);e.textContent!==n&&(e.textContent=n);break;case"innerHTML":const i=this.cachedValueToString(s);e.innerHTML!==i&&(e.innerHTML=i);break;case"value":const r=this.cachedValueToString(s);e instanceof HTMLOptionElement?e.value!==r&&(e.value=r,e.setAttribute("value",r)):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.value!==r&&(e.value=r);break;case"selectedIndex":if(e instanceof HTMLSelectElement){const t=Number(s);e.selectedIndex!==t&&(e.selectedIndex=t)}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,s);break;case"indeterminate":if(e instanceof HTMLInputElement&&"checkbox"===e.type){const t=!!s;e.indeterminate!==t&&(e.indeterminate=t)}break;case"class":case"className":const a=this.cachedValueToString(s);e instanceof SVGElement?e.getAttribute("class")!==a&&e.setAttribute("class",a):e.className!==a&&(e.className=a);break;case"htmlFor":case"for":if(e instanceof HTMLLabelElement){const t=this.cachedValueToString(s);e.htmlFor!==t&&(e.htmlFor=t)}break;case"style":if(e instanceof HTMLElement)if("object"==typeof s&&s&&!Array.isArray(s))this.updateStyleObject(e,s);else{const t=this.cachedValueToString(s);e.style.cssText!==t&&(e.style.cssText=t)}break;case"tabIndex":if(e instanceof HTMLElement){const t=null==s?-1:Number(s);e.tabIndex!==t&&(e.tabIndex=t)}break;case"contentEditable":if(e instanceof HTMLElement){const t=!0===s?"true":!1===s?"false":String(s);e.contentEditable!==t&&(e.contentEditable=t)}break;case"draggable":if(e instanceof HTMLElement){const t=!0===s,n=t?"true":"false";e.draggable!==t&&(e.draggable=t,e.setAttribute("draggable",n))}break;case"spellcheck":if(e instanceof HTMLElement){const t=!!s,n=t?"true":"false";e.spellcheck!==t&&(e.spellcheck=t,e.setAttribute("spellcheck",n))}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,s);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,s);break;default:t.startsWith("aria-")?this.setAriaAttribute(e,t,s):t.startsWith("data-")?this.setDataAttribute(e,t,s):this.setGenericAttribute(e,t,s)}this.updateValueCache(e,t,s)}catch(n){console.error(`Failed to update property "${t}" on element:`,e,n)}finally{this.applyingUpdates=r}}looksLikeSerializedObject(e){const t=e.startsWith("{")&&e.endsWith("}"),n=e.startsWith("[")&&e.endsWith("]");if(!t&&!n)return!1;try{const t=JSON.parse(e);return"object"==typeof t&&null!==t&&(Array.isArray(t)||Object.keys(t).length>0)}catch{return!1}}cachedValueToString(e){if("string"==typeof e)return e;if("number"==typeof e)return String(e);if(null==e)return"";if("boolean"==typeof e)return e?"true":"false";if(this.stringValueCache.has(e))return this.stringValueCache.get(e);const t=Ce(e);return this.stringValueCache.set(e,t),t}isSameValue(e,t){if(e===t)return!0;if("object"==typeof e&&"object"==typeof t){if(null===e||null===t)return e===t;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((e,n)=>e===t[n]));if(this.isStyleObject(e)&&this.isStyleObject(t)){const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every((n=>e[n]===t[n]))}}return!1}isStyleObject(e){return e&&"object"==typeof e&&!Array.isArray(e)}setBooleanProperty(e,t,n){const s=!!n;this.setBooleanProp(e,t,n)||(s&&!e.hasAttribute(t)?e.setAttribute(t,""):!s&&e.hasAttribute(t)&&e.removeAttribute(t))}updateStyleObject(e,t){var n;const s=null==(n=this.lastValueCache.get(e))?void 0:n.get("style"),i=s&&"object"==typeof s?s:{};for(const[n,s]of Object.entries(t))i[n]!==s&&(e.style[n]=s)}setStringAttribute(e,t,n){const s=this.cachedValueToString(n);e.getAttribute(t)!==s&&(null==n?e.removeAttribute(t):e.setAttribute(t,s))}setNumericAttribute(e,t,n){const s=String(n);e.getAttribute(t)!==s&&(null==n?e.removeAttribute(t):e.setAttribute(t,s))}setAriaAttribute(e,t,n){const s=this.cachedValueToString(n);e.getAttribute(t)!==s&&(null==n||!1===n?e.removeAttribute(t):e.setAttribute(t,s))}setDataAttribute(e,t,n){const s=this.cachedValueToString(n);e.getAttribute(t)!==s&&(null==n?e.removeAttribute(t):e.setAttribute(t,s))}setGenericAttribute(e,t,n){const s=this.cachedValueToString(n);e.getAttribute(t)!==s&&(null==n||!1===n?e.removeAttribute(t):e.setAttribute(t,s))}updateValueCache(e,t,n){this.lastValueCache.has(e)||this.lastValueCache.set(e,new Map),this.lastValueCache.get(e).set(t,n)}setBooleanProp(e,t,n){const s=this.BOOL_REFLECTED[t];if(!s)return!1;const i=!!n;return e instanceof HTMLElement&&s in e?(e[s]!==i&&(e[s]=i),!0):(i?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 n of e)t.has(n.component)||t.set(n.component,[]),t.get(n.component).push(n);for(const[e,n]of t){const t=[...this.componentManager.componentStack];this.componentManager.componentStack="app"!==e?["app",e]:["app"];for(const t of n)try{if(!document.contains(t.element))continue;this.createMustacheBinding(t.element,t.property,t.expression)}catch(t){console.error(`❌ Failed to create binding for ${e}:`,t)}this.componentManager.componentStack=t}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,n]of e){const e=[...this.componentManager.componentStack];this.componentManager.componentStack="app"!==t?["app",t]:["app"];for(const{textNode:e,component:t}of n)if(document.contains(e))try{this.textNodeManager.processTextNode(e,t)}catch(e){console.error(`❌ Failed to process text node for ${t}:`,e)}this.componentManager.componentStack=e}}processMutationsBatch(e){const t=new Set,n=new Set,s=new Set,i=new Set,r=new Set;for(const s of e)if("childList"===s.type&&(s.addedNodes.forEach((e=>{if(e.nodeType===Node.ELEMENT_NODE)t.add(e);else if(e.nodeType===Node.TEXT_NODE){const t=e;t.textContent&&g.MUSTACHE_PATTERN.test(t.textContent)&&r.add(t)}})),s.removedNodes.forEach((e=>{if(e.nodeType===Node.ELEMENT_NODE)n.add(e);else if(e.nodeType===Node.TEXT_NODE){const t=e;t.textContent&&g.MUSTACHE_PATTERN.test(t.textContent)&&(document.contains(t)||this.textNodeManager.cleanupTextNode(t))}}))),"attributes"===s.type&&s.target&&i.add(s.target),"characterData"===s.type&&s.target){const e=s.target;e.textContent&&g.MUSTACHE_PATTERN.test(e.textContent)&&r.add(e)}for(const e of n)(t.has(e)||document.contains(e))&&(s.add(e),n.delete(e),t.has(e)&&t.delete(e));n.size>0&&this.cleanupElementsBatch(Array.from(n)),t.size>0&&this.processElementsBatch(Array.from(t)),r.size>0&&this.processTextNodesBatch(Array.from(r)),i.size>0&&this.rebindChangedElements(Array.from(i))}processTextNodesBatch(e){const t=new Map;for(const n of e){const e=A.getComponentForNode(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}for(const[e,n]of t)n.forEach((t=>{this.textNodeManager.processTextNode(t,e)}))}rebindChangedElements(e){e.forEach((e=>{this.processElementBindings(e,!0)}))}processElementBindings(e,t=!0){const n=this.extractDomMustacheBindings(e),s=A.getElementComponent(e);n.forEach(((n,i)=>{t?this.createMustacheBinding(e,i,n):this.pendingBindings.push({element:e,property:i,expression:n,component:s})})),t&&this.setupEventBindings(e,s)}cleanupElementsBatch(e){e.forEach((e=>this.cleanupElement(e)))}cleanupElement(e){var t;this.cleanupRefBinding(e),null==(t=this.stateManager.subscriptionManager)||t.cleanupElement(e);const n=this.listeners.get(e)||[];for(const{type:t,fn:s}of n)e.removeEventListener(t,s);this.listeners.delete(e),this.elementCache.delete(e),this.processedElements.delete(e),this.componentManager.cleanupProps(e);const s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let i;for(;i=s.nextNode();)this.textNodeManager.cleanupTextNode(i);"TEMPLATE"===e.tagName&&e.hasAttribute("pp-for")&&this.loopManager.cleanupTemplate(e),e.querySelectorAll("template[pp-for]").forEach((e=>{this.loopManager.cleanupTemplate(e)}));const r=e.__directEventListeners;r&&(r.forEach((({eventType:t,listener:n})=>{e.removeEventListener(t,n)})),delete e.__directEventListeners);const a=e.__spreadEventHandlers;a&&(a.forEach((e=>{window.__spreadHandlers&&window.__spreadHandlers.delete(e)})),delete e.__spreadEventHandlers);const o=e.__spreadSubscriptions;o&&(o.forEach((e=>{this.stateManager.removeSubscription(e)})),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(e){console.error("Failed to cleanup ref:",e)}this.refBindings.delete(e)}}getElementHash(e){const t=[];for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n];(s.name===g.ATTR_PREFIXES.COMPONENT||ie.isEventAttribute(s.name)||s.value&&g.MUSTACHE_PATTERN.test(s.value))&&t.push(`${s.name}=${s.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(`[${g.ATTR_PREFIXES.REF}]`).forEach((e=>{this.cleanupRefBinding(e)})),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()}}const de=class e{constructor(){d(this,"walkerPool",[]),d(this,"traversalCache",new WeakMap),d(this,"lastCacheTime",new WeakMap),d(this,"CACHE_TTL",250),d(this,"trackedElements",new Set)}static getInstance(){return e.instance||(e.instance=new e),e.instance}acquireWalker(e,t,n){return document.createTreeWalker(e,t,n)}releaseWalker(e){this.walkerPool.length<3&&this.walkerPool.push(e)}getCachedTraversal(e,t,n){const s=Date.now(),i=this.traversalCache.get(e),r=this.lastCacheTime.get(e);if(i&&r&&s-r<this.CACHE_TTL){const e=i.get(t);if(e)return e}const a=n();return this.traversalCache.has(e)||(this.traversalCache.set(e,new Map),this.trackedElements.add(e)),this.traversalCache.get(e).set(t,a),this.lastCacheTime.set(e,s),a}traverseElementsAndText(e,t,n){const s=this.acquireWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),i=[],r=[];let a;for(;a=s.nextNode();)if(a.nodeType===Node.ELEMENT_NODE){const e=a;(!t||t(e))&&i.push(e)}else if(a.nodeType===Node.TEXT_NODE){const e=a;(!n||n(e))&&r.push(e)}return this.releaseWalker(s),{elements:i,textNodes:r}}cleanupCache(){const e=[];for(const t of this.trackedElements)document.contains(t)||e.push(t);e.forEach((e=>{this.traversalCache.delete(e),this.lastCacheTime.delete(e),this.trackedElements.delete(e)}))}};d(de,"instance");let it=de;const me=class e{static getDOMCache(){return this.domCache||(this.domCache=je.getInstance()),this.domCache}static isFrameworkAttribute(t){return e.FRAMEWORK_ATTRIBUTES.has(t)}static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}static shouldBeDirectBinding(t,n){const s=k.findScope(t),i=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);return!(!s||!i||s===i)&&e.isDOMProperty(t,n)}static isDOMProperty(t,n){const s=t.tagName.toLowerCase(),i=document.createElement(s);return e.attributeToPropertyName(n)in i}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,((e,t)=>t.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 e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}static isTextNodeInsideScript(e){let t=e.parentElement;for(;t&&t!==document.body;){const e=t.tagName.toLowerCase();if("script"===e||"style"===e)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)}};d(me,"FRAMEWORK_ATTRIBUTES",new Set(["pp-component","pp-for","pp-spread","pp-ref","key"])),d(me,"domCache");let A=me;class Zs{constructor(e,t){d(this,"eventDelegation"),d(this,"loopBindings",new Map),d(this,"stateManager"),d(this,"expressionEvaluator"),d(this,"componentManager"),d(this,"domBindingManager"),d(this,"cleanupObserver"),d(this,"loopCounter",0),d(this,"pendingTemplates",[]),d(this,"loopItemElements",new WeakSet),d(this,"loopItemContexts",new WeakMap),d(this,"templateRenderer"),d(this,"templateMoveObserver"),this.stateManager=e,this.expressionEvaluator=t,this.cleanupObserver=new MutationObserver((e=>{this.cleanupDetachedTemplates(e)})),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateMoveObserver=new MutationObserver((e=>{this.handleTemplateMoves(e)})),this.templateMoveObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateRenderer=new ve(t)}handleTemplateMoves(e){const t=new Set;for(const n of e)"childList"===n.type&&n.addedNodes.forEach((e=>{if(e.nodeType!==Node.ELEMENT_NODE)return;const n=e;if(n.querySelectorAll("template[pp-for]").forEach((e=>{const n=e;this.loopBindings.has(n)&&t.add(n)})),"TEMPLATE"===n.tagName&&n.hasAttribute("pp-for")){const e=n;this.loopBindings.has(e)&&t.add(e)}}));t.size>0&&setTimeout((()=>{t.forEach((e=>{document.contains(e)&&this.updateMovedTemplate(e)}))}),0)}updateMovedTemplate(e){const t=this.loopBindings.get(e);if(!t)return;const n=e.parentElement;if(!n||n===t.parentElement&&t.placeholder.parentElement===n&&t.placeholder.nextSibling===e)return;const s=[...t.renderedItems];t.placeholder.parentElement&&t.placeholder.parentElement!==n&&t.placeholder.parentElement.removeChild(t.placeholder);const i=document.createComment(`pp-for: ${t.expression}`);n.insertBefore(i,e),t.parentElement=n,t.placeholder=i,s.length>0&&(s.forEach((t=>{t.element.parentElement!==n&&n.insertBefore(t.element,e)})),this.updateDOMOrder(t,s)),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 n=e.parentElement;for(;n;){if(t.isLoopItem&&t.isLoopItem(n))return t.getLoopItemContext(n);n=n.parentElement}const s=t.getAllLoops();for(const[t,n]of s)for(const t of n.renderedItems)if(t.element.contains(e))return t.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:n}of e)document.contains(t)&&this.processTemplate(t,n)}processTemplate(e,t){const n=e.getAttribute("pp-for");if(!n||this.loopBindings.has(e))return;if(!e.parentElement)return console.warn("⚠️ Template has no parent, queueing for later:",n),void this.queueTemplate(e,t);const s=this.parseLoopExpression(n);if(!s)return void console.error(`Invalid pp-for syntax: "${n}"`);const i=e.getAttribute("pp-ssr")??void 0,r=void 0!==i;let a;r&&(a=this.findListContainer(e,i),a||console.warn(`⚠️ No pp-list="${i}" container found for SSR template`));const o=k.findScope(e);let c=t;if(o)if(o.includes(":children")){const e=o.replace(/:children$/,"");c="app"===e?"app":e}else c="app"===o?"app":o;const h=e.parentElement,l=document.createComment(`pp-for: ${n}`);h.insertBefore(l,e);const p={template:e,expression:n,itemVar:s.itemVar,indexVar:s.indexVar,component:c,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:h,placeholder:l,iterableExpr:s.iterableExpr,isSSR:r,ssrIdentifier:i,listContainer:a};this.loopBindings.set(e,p),r&&a&&this.hydrateSSRItems(p),this.setupLoopReactivity(p,s.iterableExpr),this.renderLoop(p,s.iterableExpr)}findListContainer(e,t){var n;let s=e.parentElement;for(;s&&s!==document.body;){if(s.getAttribute("pp-list")===t)return s;s=s.parentElement}const i=null==(n=e.parentElement)?void 0:n.children;if(i)for(const e of Array.from(i))if(e.getAttribute("pp-list")===t)return e}hydrateSSRItems(e){if(!e.listContainer)return;const t=[];if(Array.from(e.listContainer.children).forEach((n=>{if(n===e.template||n.nodeType!==Node.ELEMENT_NODE)return;const s=n;s.hasAttribute("key")&&t.push(s)})),0===t.length)return console.warn("⚠️ [Hydrate] No SSR items found, falling back to client render"),void(e.isSSR=!1);t.forEach(((t,n)=>{const s={key:t.getAttribute("key"),element:t,context:{},subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map,parentTemplate:e.template};this.loopItemElements.add(t),e.renderedItems.push(s),t.removeAttribute("key")}))}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 n=e.match(/^\s*\(\s*([a-zA-Z_$][\w$]*)\s*,\s*([a-zA-Z_$][\w$]*)\s*\)\s+in\s+(.+)$/);return n?{itemVar:n[1],indexVar:n[2],iterableExpr:n[3].trim()}:null}setupLoopReactivity(e,t){const n=`loop_${Date.now()}_${++this.loopCounter}`,s=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager),i=this.findComponentElementForLoop(e);if(i&&this.componentManager){const t=this.componentManager.getComponentPropDependencies(i,e.component);s.push(...t)}const r={id:n,selector:"",dependencies:new Set(s),callback:()=>{this.renderLoop(e,e.iterableExpr)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(r),e.subscriptionIds.push(n)}renderLoop(e,t){if(this.componentManager&&this.domBindingManager)try{const n=e.template,s=k.findScope(n);let i,r;if((null==s?void 0:s.includes(":children"))||!1){const e=s.replace(/:children$/,"");if(r=this.findComponentElementForScope(e),i=this.componentManager.buildComponentContext(e),r&&this.componentManager.hasStoredProps(r)){const e=this.componentManager.evaluateProps(r);i={...i,...e}}}else{r=this.findComponentElementForLoop(e);const t=this.findParentLoopContext(e.template);if(null!==s){const n=this.componentManager.buildComponentContext(e.component);if(r){const e=this.componentManager.evaluateProps(r);i={...n,...e}}else i=n;t&&(i={...i,...t})}else{if(i=this.componentManager.buildRestrictedComponentContext(e.component,!1),r&&this.componentManager.hasStoredProps(r)){const e=this.componentManager.evaluateProps(r);Object.assign(i,e)}t&&(i={...i,...t})}}const a=We(this.expressionEvaluator.evaluateExpression(t,i,e.component));if(!Array.isArray(a))return console.warn(`Loop expression "${t}" did not return an array:`,a,`Available context keys: [${Object.keys(i).join(", ")}]`,"Parent loop context:"),void this.clearRenderedItems(e);e.isSSR&&e.renderedItems.length>0?this.reconcileSSRItems(e,a):this.updateRenderedItems(e,a)}catch(n){console.error(`❌ Error evaluating loop expression "${t}":`,n),this.clearRenderedItems(e)}}reconcileSSRItems(e,t){const n=e.renderedItems,s=[],i=new Set,r=new Map,a=[];n.forEach((e=>{r.set(e.key,e),a.push(e)})),t.forEach(((t,n)=>{const o=this.generateItemKey(e,t,n),c=r.get(o);if(c&&!i.has(c.element))i.add(c.element),this.updateItemContext(e,c,t,n),this.processElementWithContext(c.element,c.context,e.component,c),this.refreshLoopItemContent(c),c.element.querySelectorAll("template[pp-for]").forEach((e=>{const t=e,n=this.loopBindings.get(t);n&&this.renderLoop(n,n.iterableExpr)})),s.push(c);else{const r=a.find((e=>!i.has(e.element)));if(r)i.add(r.element),r.key=o,this.updateItemContext(e,r,t,n),this.refreshLoopItemContent(r),s.push(r);else{const i=this.createLoopItem(e,t,n,o);i&&(s.push(i),this.processNestedLoopsInItem(i,e.component))}}})),n.forEach((e=>{i.has(e.element)||this.cleanupLoopItem(e)})),this.updateDOMOrder(e,s),e.renderedItems=s,e.isSSR=!1}refreshLoopItemContent(e){if(e.textNodeTemplates)for(const[t,n]of e.textNodeTemplates)document.contains(t)&&this.updateTextNodeWithContext(t,n,e.context,this.getTextNodeComponent(t));if(e.attributeTemplates)for(const[t,n]of e.attributeTemplates)document.contains(t)&&n.forEach(((n,s)=>{var i;try{const r=A.getElementComponent(t),a=this.templateRenderer.render(n,e.context,r);null==(i=this.domBindingManager)||i.updateElementProperty(t,s,a)}catch(e){console.error(`Error refreshing attribute "${s}":`,e)}}))}findComponentElementForScope(e){const t=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${e}"]`);for(const e of t)if(this.componentManager.hasStoredProps(e))return e;return t[0]||void 0}findParentLoopContext(e){const t=[];let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const e=this.loopItemContexts.get(n);e&&t.unshift(e)}for(const[s,i]of this.loopBindings)if(i.template!==e)for(const s of i.renderedItems)if(s.element===n||s.element.contains(e)){t.unshift(s.context);break}n=n.parentElement}return t.length>0?t.reduce(((e,t)=>({...e,...t})),{}):null}findComponentElementForLoop(e){var t;let n=e.parentElement;for(;n;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===e.component)return n;n=n.parentElement}if("app"===e.component)for(n=e.parentElement;n&&n!==document.body;){if(n.hasAttribute(g.ATTR_PREFIXES.COMPONENT)&&null!=(t=this.componentManager)&&t.hasStoredProps(n))return n;n=n.parentElement}return document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${e.component}"]`)[0]||void 0}updateRenderedItems(e,t){const n=e.renderedItems,s=[],i=new Set,r=new Map,a=[];n.forEach((e=>{r.set(e.key,e),a.push(e)})),t.forEach(((t,n)=>{const o=this.generateItemKey(e,t,n),c=r.get(o);if(c&&!i.has(c.element))i.add(c.element),this.updateItemContext(e,c,t,n),this.refreshLoopItemContent(c),c.element.querySelectorAll("template[pp-for]").forEach((e=>{const t=e,n=this.loopBindings.get(t);n&&this.renderLoop(n,n.iterableExpr)})),s.push(c);else{const r=a.find((e=>!i.has(e.element)));if(r)i.add(r.element),r.key=o,this.updateItemContext(e,r,t,n),this.refreshLoopItemContent(r),s.push(r);else{const i=this.createLoopItem(e,t,n,o);i&&(s.push(i),this.processNestedLoopsInItem(i,e.component))}}})),n.forEach((e=>{i.has(e.element)||this.cleanupLoopItem(e)})),this.updateDOMOrder(e,s),e.renderedItems=s}processNestedLoopsInItem(e,t){e.element.querySelectorAll("template[pp-for]").forEach((n=>{const s=n;this.loopBindings.has(s)||this.processNestedTemplate(s,t,e.context)}))}generateItemKey(e,t,n){const s=e.template.content.firstElementChild;if(s&&s.hasAttribute("key")){const i=s.getAttribute("key");try{const s=this.createItemContextWithParentContext(e,t,n),r=L.isSingleExpression(i);if(r){const t=this.expressionEvaluator.evaluateExpression(r,s,e.component);return String(t)}{const t=L.parse(i);let n="";for(const i of t)if("static"===i.type)n+=i.content;else if(i.expression){n+=Ce(this.expressionEvaluator.evaluateExpression(i.expression,s,e.component))}return n}}catch(s){console.warn(`Error evaluating key expression "${i}":`,s,"Available context keys:",Object.keys(this.createItemContextWithParentContext(e,t,n)))}}return t&&"object"==typeof t&&"id"in t?String(t.id):`${e.expression}_${n}`}createItemContextWithParentContext(e,t,n){if(!this.componentManager)return{};const s=e.template,i=k.findScope(s);let r;if((null==i?void 0:i.includes(":children"))||!1){const e=i.replace(/:children$/,"");r=this.componentManager.buildComponentContext(e);const t=this.findComponentElementForScope(e);if(t&&this.componentManager.hasStoredProps(t)){const e=this.componentManager.evaluateProps(t);r={...r,...e}}}else{const t=null!==i,n=this.findComponentElementForLoop(e),s=n&&this.componentManager.hasStoredProps(n);if(t&&"app"===i&&s&&n){r={},r.getContext=()=>this.componentManager.buildComponentContext("app"),r.withContext=e=>{const t=this.componentManager.buildComponentContext("app");return e.call(t,t)},r.__getProp=e=>{if(n)return this.componentManager.evaluateProps(n)[e]};const e=this.componentManager.evaluateProps(n);r={...r,...e}}else r=this.componentManager.buildComponentContext(e.component)}const a=this.getAllParentLoopContexts(e.template),o=t&&"object"==typeof t?Object.keys(t):[],c={};for(const[e,t]of Object.entries(r))o.includes(e)&&!e.startsWith("set")&&!e.endsWith("Getter")||(c[e]=t);const h={...c,...a,[e.itemVar]:t};return e.indexVar&&(h[e.indexVar]=n),h}getAllParentLoopContexts(e){const t=[];let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const e=this.loopItemContexts.get(n);e&&t.unshift(e)}for(const[s,i]of this.loopBindings)for(const s of i.renderedItems)if(s.element.contains(e)||s.element===n){t.unshift(s.context);break}n=n.parentElement}const s={};for(const e of t)for(const[t,n]of Object.entries(e))if(!(t in s)){if("function"==typeof n&&!("__pphp_key"in n)){["getContext","withContext","__getProp"].includes(t)&&(s[t]=n);continue}s[t]=n}return s}createItemContext(e,t,n){if(!this.componentManager)return{};const s=e.template,i=k.findScope(s),r=null!==i,a=this.findComponentElementForLoop(e),o=a&&this.componentManager.hasStoredProps(a);let c,h=!1,l=s.parentElement;for(;l&&l!==document.body;){if(this.loopItemElements.has(l)){const e=this.loopItemContexts.get(l);if(e&&!Object.keys(e).some((t=>{const n=e[t];return"function"==typeof n&&!("__pphp_key"in n)&&!["getContext","withContext","__getProp"].includes(t)}))){h=!0;break}}l=l.parentElement}if(r&&"app"===i&&o&&a||h&&o&&a){c={},c.getContext=()=>this.componentManager.buildComponentContext("app"),c.withContext=e=>{const t=this.componentManager.buildComponentContext("app");return e.call(t,t)},c.__getProp=e=>{if(a)return this.componentManager.evaluateProps(a)[e]};const e=this.componentManager.evaluateProps(a);c={...c,...e}}else c=r||o?this.componentManager.buildComponentContext(e.component):this.componentManager.buildRestrictedComponentContext(e.component,!1);const p={},u=t&&"object"==typeof t?Object.keys(t):[];for(const[e,t]of Object.entries(c))"function"!=typeof t||t.__pphp_key?e.startsWith("set")||e.endsWith("Getter")||["getContext","withContext","__getProp"].includes(e)?p[e]=t:u.includes(e)||(p[e]=t):p[e]=t;const d=this.findAllParentLoopContexts(e.template),m={...p,...d,[e.itemVar]:t};return e.indexVar&&(m[e.indexVar]=n),m}findAllParentLoopContexts(e){const t={};let n=e.parentElement,s=0;for(;n&&n!==document.body&&s<10;){if(s++,this.loopItemElements.has(n)){const e=this.loopItemContexts.get(n);if(e)for(const[n,s]of Object.entries(e))if(!(n in t)){const e="function"==typeof s,i=e&&"__pphp_key"in s,r=["getContext","withContext","__getProp"].includes(n);if(e&&!i){r&&(t[n]=s);continue}t[n]=s}}for(const[s,i]of this.loopBindings)if(s!==e)for(const e of i.renderedItems)if(e.element===n){for(const[n,s]of Object.entries(e.context))if(!(n in t)){const e="function"==typeof s,i=e&&"__pphp_key"in s,r=["getContext","withContext","__getProp"].includes(n);if(e&&!i){r&&(t[n]=s);continue}t[n]=s}break}n=n.parentElement}return t}createLoopItem(e,t,n,s){if(!this.domBindingManager)return null;try{const i=this.createItemContextWithParentContext(e,t,n);this.preCloneSanitizeTemplate(e.template);const r=document.importNode(e.template.content,!0),a=document.createElement("div");a.appendChild(r);const o=a.firstElementChild;if(!o)return console.error("❌ [LoopItem] No element found in template"),null;a.removeChild(o),this.sanitizeInputValidationAttributes(o),this.loopItemElements.add(o),this.loopItemContexts.set(o,i),o.getAttribute("key")&&o.removeAttribute("key");const c={key:s,element:o,context:i,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map,parentTemplate:e.template};return o instanceof HTMLElement&&(o.classList.add("pp-entering"),requestAnimationFrame((()=>{requestAnimationFrame((()=>{o.classList.remove("pp-entering")}))}))),this.executeComponentScriptsInLoopItem(o),this.processRefsInLoopItem(o,i,e.component,c),this.processElementWithContext(o,i,e.component,c),this.cleanupRawMustacheAttributes(o),c}catch(e){return console.error("❌ [LoopItem] Error creating loop item:",e),console.error(" Stack:",e.stack),null}}preCloneSanitizeTemplate(e){const t=e.content.querySelectorAll("input");for(const e of Array.from(t)){const t=(e.getAttribute("type")||"text").toLowerCase();if(!["number","date","time","datetime-local","month","week","email","url","tel","range"].includes(t))continue;const n=["value","min","max","step","pattern"];for(const t of n){const n=e.getAttribute(t);if(n&&g.MUSTACHE_PATTERN.test(n)){const s=`data-pp-${t}`;e.setAttribute(s,n),e.removeAttribute(t)}}"number"===t&&!e.hasAttribute("value")&&e.setAttribute("value","0")}}sanitizeInputValidationAttributes(e){const t=[];"input"===e.tagName.toLowerCase()&&t.push(e),t.push(...Array.from(e.querySelectorAll("input")));for(const e of t){const t=(e.getAttribute("type")||"text").toLowerCase();if(!["number","date","time","datetime-local","month","week","email","url","tel","range"].includes(t))continue;const n=["value","min","max","step","pattern"];for(const t of n){const n=`data-pp-${t}`,s=e.getAttribute(n);s&&(e.setAttribute(t,s),e.removeAttribute(n))}"0"===e.getAttribute("value")&&!e.hasAttribute("data-pp-value")&&"number"===t&&e.removeAttribute("value")}}processRefsInLoopItem(e,t,n,s){if(e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)){const i=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);s&&(s.refTemplates||(s.refTemplates=new Map),s.refTemplates.set(e,i)),this.processRefAttribute(e,i,t,n),ve.containsMustacheExpression(i)||e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let r;const a=[];for(;r=i.nextNode();)a.push(r);a.forEach((e=>{const i=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);s&&(s.refTemplates||(s.refTemplates=new Map),s.refTemplates.set(e,i)),this.processRefAttribute(e,i,t,n),ve.containsMustacheExpression(i)||e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}))}processRefAttribute(e,t,n,s){try{const i=L.decodeEntities(t),r=L.isSingleExpression(i)||i,a=this.expressionEvaluator.evaluateExpression(r,n,s);"function"==typeof a?a(e):a&&"object"==typeof a&&"current"in a?a.current=e:console.warn("⚠️ Invalid ref result:",a),e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}catch(e){console.error("❌ Failed to process ref:",e)}}executeComponentScriptsInLoopItem(e){if(!this.componentManager)return;const t=[e],n=e.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}]`);t.push(...Array.from(n)),t.forEach((e=>{if(e.hasAttribute(g.ATTR_PREFIXES.COMPONENT)){const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(t){const n=this.getLoopItemContextForElement(e),s=`${t}_${this.generateInstanceId(n)}`;e.setAttribute(g.ATTR_PREFIXES.COMPONENT,s),e.__originalComponentName=t,e.__uniqueComponentName=s,this.componentManager.pushComponent(s),window[s]||(window[s]={}),window[t]&&Object.assign(window[s],window[t]),this.getComponentScripts(e).forEach((e=>{this.componentManager.executeScript(e)})),this.componentManager.popComponent()}}}))}getLoopItemContextForElement(e){let t=e;for(;t;){if(this.loopItemElements.has(t)){const e=this.loopItemContexts.get(t);if(e)return e}t=t.parentElement}for(const[t,n]of this.loopBindings)for(const t of n.renderedItems)if(t.element===e||t.element.contains(e))return t.context;return console.warn("⚠️ No loop item context found, using empty context"),{}}generateInstanceId(e){const t={};for(const[n,s]of Object.entries(e))"function"==typeof s||n.startsWith("set")||n.endsWith("Getter")||"getContext"===n||"withContext"===n||"__getProp"===n||s&&"function"==typeof s&&"__pphp_key"in s||"boolean"==typeof s||"number"==typeof s||"string"==typeof s||s&&"object"==typeof s&&!Array.isArray(s)&&"id"in s&&(t[n]=s);return 0===Object.keys(t).length?`${Date.now()}_${Math.random().toString(36).substring(2,7)}`:Object.keys(t).sort().map((e=>{const n=t[e];return n&&"object"==typeof n&&"id"in n?`${e}_${n.id}`:`${e}_${JSON.stringify(n)}`})).join("_").replace(/[^a-zA-Z0-9_]/g,"").substring(0,20)||`fallback_${Date.now()}`}getComponentScripts(e){const t=[];return e.querySelectorAll(`script[type="${g.SCRIPT_TYPE}"]`).forEach((n=>{const s=n;let i=s.parentElement,r=!1;for(;i&&i!==e.parentElement;){if(i===e){r=!0;break}if(i.hasAttribute(g.ATTR_PREFIXES.COMPONENT)&&i!==e)break;i=i.parentElement}r&&t.push(s)})),t}cleanupRawMustacheAttributes(e){this.cleanupElementMustacheAttributes(e);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let n;for(;n=t.nextNode();)this.cleanupElementMustacheAttributes(n)}cleanupElementMustacheAttributes(e){const t=Array.from(e.attributes);for(const n of t)n.value&&g.MUSTACHE_PATTERN.test(n.value)&&(A.isBooleanAttribute(n.name),e.removeAttribute(n.name))}processElementWithContext(e,t,n,s){if(!this.domBindingManager||!this.componentManager)return;const i=(e,n)=>{const s=this.componentManager.buildComponentContext(n),i=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(i&&i!==n){const e=this.componentManager.buildComponentContext(i);return{...t,...s,...e}}return{...t,...s}},r=this.componentManager.buildComponentContextWithProps.bind(this.componentManager);this.componentManager.buildComponentContextWithProps=(t,n)=>n&&(n===e||e.contains(n))?i(n,t):r(t,n);try{if(e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)){const s=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);this.processRefInLoopContext(e,s,t,n),e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:t=>t===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}),r=[];let a;for(;a=i.nextNode();){const e=a;if(e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)){const t=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);r.push({element:e,expression:t})}}r.forEach((({element:e,expression:s})=>{this.processRefInLoopContext(e,s,t,n)}));const o=this.bindLoopItemElement(e,t,n,s);this.setupEventBindingsForLoopItem(e,n);for(let t=0;t<e.childNodes.length;t++){const i=e.childNodes[t];if(i.nodeType===Node.TEXT_NODE){const e=i;if(e.textContent&&g.MUSTACHE_PATTERN.test(e.textContent)&&!A.isTextNodeInsideScript(e)){const t=this.getComponentForTextNode(e);this.processTextNodeWithLoopContext(e,o,t,s)}}else if(i.nodeType===Node.ELEMENT_NODE){const e=i;if("script"===e.tagName.toLowerCase())continue;const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT)||n,r=this.bindLoopItemElement(e,o,t,s);this.setupEventBindingsForLoopItem(e,t),this.processChildrenRecursively(e,r,t,s)}}e.querySelectorAll("template[pp-for]").forEach((t=>{(t.parentElement===e||e.contains(t))&&this.processNestedTemplate(t,n,o)}))}finally{this.componentManager.buildComponentContextWithProps=r}}processChildrenRecursively(e,t,n,s){const i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:t=>{if(t===e)return NodeFilter.FILTER_SKIP;if(t.nodeType===Node.TEXT_NODE){const e=t;if(A.isTextNodeInsideScript(e))return NodeFilter.FILTER_REJECT;if(e.textContent&&g.MUSTACHE_PATTERN.test(e.textContent))return NodeFilter.FILTER_ACCEPT}else if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("script"===e.tagName.toLowerCase())return NodeFilter.FILTER_REJECT;const i=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);return i&&i!==n&&!s?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let r;for(;r=i.nextNode();)if(r.nodeType===Node.TEXT_NODE){const e=r,n=this.getComponentForTextNode(e);this.processTextNodeWithLoopContext(e,t,n,s)}else if(r.nodeType===Node.ELEMENT_NODE){const e=r,n=A.getElementComponent(e),i=this.bindLoopItemElement(e,t,n,s);this.setupEventBindingsForLoopItem(e,n),this.processChildrenRecursively(e,i,n,s)}}processChildElementsWithContext(e,t,n,s){const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:t=>{if(t===e)return NodeFilter.FILTER_SKIP;if(t.nodeType===Node.TEXT_NODE){const e=t;if(A.isTextNodeInsideScript(e))return NodeFilter.FILTER_REJECT;if(e.textContent&&g.MUSTACHE_PATTERN.test(e.textContent))return NodeFilter.FILTER_ACCEPT}else if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("script"===e.tagName.toLowerCase())return NodeFilter.FILTER_REJECT;const s=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);return s&&s!==n?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let r;const a=[],o=[];for(;r=i.nextNode();)r.nodeType===Node.ELEMENT_NODE?a.push(r):r.nodeType===Node.TEXT_NODE&&o.push(r);o.forEach((e=>{const n=this.getComponentForTextNode(e);this.processTextNodeWithLoopContext(e,t,n,s)})),a.forEach((e=>{const n=A.getElementComponent(e),i=this.bindLoopItemElement(e,t,n,s);this.setupEventBindingsForLoopItem(e,n),this.processChildElementsWithContext(e,i,n,s)}))}processRefInLoopContext(e,t,n,s){try{const i=L.decodeEntities(t),r=L.isSingleExpression(i)||i,a=this.expressionEvaluator.evaluateExpression(r,n,s);"function"==typeof a?a(e):a&&"object"==typeof a&&"current"in a?a.current=e:console.warn("⚠️ Invalid ref result:",a),e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}catch(e){console.error("❌ processRefInLoopContext error:",e)}}getComponentForTextNode(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}processNestedTemplate(e,t,n){const s=e.getAttribute("pp-for");if(!s||this.loopBindings.has(e))return;const i=this.parseLoopExpression(s);if(!i)return void console.error(`Invalid pp-for syntax: "${s}"`);const r=e.parentElement,a=document.createComment(`pp-for: ${s}`);r.insertBefore(a,e);const o=this.findComponentElementForTemplate(e);let c={...n};const h=this.findParentLoopContextForNestedTemplate(e);if(h&&(c={...c,...h}),o&&this.componentManager){const e=o.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e){const t=A.getParentComponentForElement(o);this.componentManager.hasStoredProps(o)||this.componentManager.setupProps(o,t);const n=this.evaluateComponentPropsWithContext(o,c);c={...this.componentManager.buildComponentContext(e),...n,...c}}}const l={template:e,expression:s,itemVar:i.itemVar,indexVar:i.indexVar,iterableExpr:i.iterableExpr,component:t,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:r,placeholder:a};this.loopBindings.set(e,l),this.setupNestedLoopReactivity(l,i.iterableExpr,c),this.renderNestedLoop(l,i.iterableExpr,c)}findParentLoopContextForNestedTemplate(e){let t=e.parentElement;const n={};let s=0;for(;t&&t!==document.body&&s<10;){if(s++,this.loopItemElements.has(t)){const e=this.loopItemContexts.get(t);if(e)for(const[t,s]of Object.entries(e))t in n||(n[t]=s)}for(const[s,i]of this.loopBindings)for(const s of i.renderedItems)(s.element.contains(e)||s.element===t)&&(i.itemVar in n||(n[i.itemVar]=s.context[i.itemVar]),i.indexVar&&!(i.indexVar in n)&&(n[i.indexVar]=s.context[i.indexVar]));t=t.parentElement}return Object.keys(n).length>0?n:null}evaluateComponentPropsWithContext(e,t){const n={};if(!this.componentManager||!this.expressionEvaluator)return n;const s=this.componentManager.extractProps(e,"app");for(const[e,i]of s)try{const s=this.templateRenderer.render(i.expression,t,i.component);n[e]=s}catch(t){console.error(`Failed to evaluate prop "${e}":`,t),n[e]=void 0}return n}findComponentElementForTemplate(e){let t=e.parentElement;for(;t;){if(t.hasAttribute(g.ATTR_PREFIXES.COMPONENT))return t;t=t.parentElement}return null}setupNestedLoopReactivity(e,t,n){const s=`nested_loop_${Date.now()}_${++this.loopCounter}`;let i=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager);const r={id:s,selector:"",dependencies:new Set(i),callback:()=>{const s=e.template,i=this.findComponentElementForTemplate(s);let r=n;if(s.parentElement){const e=this.getParentLoopContextForElement(s);e&&(r={...r,...e})}if(i&&this.componentManager){const t=i.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(t){const s=this.extractParentLoopContextFromBinding(e,n),a=this.evaluateComponentPropsWithContext(i,s),o=this.componentManager.buildComponentContext(t);r={...s,...o,...a}}}this.renderNestedLoop(e,t,r)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(r),e.subscriptionIds.push(s)}getParentLoopContextForElement(e){let t=e.parentElement;for(;t;){if(this.loopItemElements.has(t)){const e=this.loopItemContexts.get(t);if(e)return e}t=t.parentElement}return null}extractParentLoopContextFromBinding(e,t){const n=new Set;for(const[t,s]of this.loopBindings)if(s!==e)for(const t of s.renderedItems)if(t.element.contains(e.template)){n.add(s.itemVar),s.indexVar&&n.add(s.indexVar);break}const s={};for(const[e,i]of Object.entries(t))(n.has(e)||e.startsWith("users")||e.startsWith("set")||e.includes("Getter")||"function"==typeof i)&&(s[e]=i);return s}renderNestedLoop(e,t,n){if(this.componentManager&&this.domBindingManager)try{const s=e.template,i=null!==k.findScope(s),r=this.findComponentElementForLoop(e),a=r&&this.componentManager.hasStoredProps(r);let o;if(i||a)o=n;else{const t=this.componentManager.buildRestrictedComponentContext(e.component,!1),s=this.extractLoopVariablesOnly(n);o={...t,...s}}const c=We(this.expressionEvaluator.evaluateExpression(t,o,e.component));if(!Array.isArray(c))return console.warn(`Nested loop expression "${t}" did not return an array:`,c,`Available context keys: [${Object.keys(o).join(", ")}]`),void this.clearRenderedItems(e);this.updateNestedRenderedItems(e,c,o)}catch(s){console.error(`Error evaluating nested loop expression "${t}":`,s,`Available context keys: [${Object.keys(n).join(", ")}]`),this.clearRenderedItems(e)}}extractLoopVariablesOnly(e){const t={};for(const[n,s]of Object.entries(e))"function"==typeof s&&!("__pphp_key"in s)||n.startsWith("set")&&"function"==typeof s||n.endsWith("Getter")||["getContext","withContext","__getProp"].includes(n)||(t[n]=s);return t}updateNestedRenderedItems(e,t,n){const s=e.renderedItems,i=[],r=new Set,a=new Map;s.forEach((e=>{a.set(e.key,e)})),t.forEach(((t,s)=>{const o=this.generateNestedItemKey(e,t,s,n),c=a.get(o);if(c&&!r.has(c.element))r.add(c.element),this.updateNestedItemContext(e,c,t,s,n),i.push(c);else{const r=this.createNestedLoopItem(e,t,s,o,n);r&&i.push(r)}})),s.forEach((e=>{r.has(e.element)||this.cleanupLoopItem(e)})),this.updateDOMOrder(e,i),e.renderedItems=i}generateNestedItemKey(e,t,n,s){return t&&"object"==typeof t&&"id"in t?String(t.id):`${e.expression}_${n}_${JSON.stringify(s[e.itemVar]||{})}`}createNestedLoopItem(e,t,n,s,i){if(!this.domBindingManager)return null;try{const r={...i,[e.itemVar]:t};e.indexVar&&(r[e.indexVar]=n);const 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:s,element:c,context:r,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map};return this.processElementWithContext(c,r,e.component,h),this.cleanupRawMustacheAttributes(c),h}catch(e){return console.error("Error creating nested loop item:",e),null}}updateNestedItemContext(e,t,n,s,i){const r={...i};r[e.itemVar]=n,e.indexVar&&(r[e.indexVar]=s);const a=this.gatherAllComponentContextsInLoopItem(t.element),o={...r,...a};if(t.context=o,this.loopItemContexts.set(t.element,o),t.textNodeTemplates)for(const[e,n]of t.textNodeTemplates)document.contains(e)&&this.updateTextNodeWithContext(e,n,o,this.getTextNodeComponent(e));if(t.attributeTemplates)for(const[e,n]of t.attributeTemplates)document.contains(e)&&n.forEach(((t,n)=>{var s;try{const i=A.getElementComponent(e),r=this.buildElementSpecificContext(e,o),a=this.templateRenderer.render(t,r,i);null==(s=this.domBindingManager)||s.updateElementProperty(e,n,a)}catch(e){console.error(`Nested binding update error for "${t}":`,e)}}))}bindLoopItemElement(e,t,n,s){const i=this.extractMustacheBindings(e),r=this.findOriginalComponentName(n),a=k.findScope(e);let o=r;o=a?"app"===a?"app":a:this.findLoopParentComponent(e,r);let c=this.componentManager.buildComponentContext(o);c={...c,...t};const h=!!e.getAttribute(g.ATTR_PREFIXES.COMPONENT),l=new Map,p=new Map;i.forEach(((e,t)=>{h&&"class"!==t&&"style"!==t?l.set(t,e):p.set(t,e)}));const u={},d=this.sortPropsByDependency(l);for(const[e,t]of d)try{const n=this.templateRenderer.render(t,c,o);u[e]=n,c[e]=n}catch(t){console.error(`❌ Failed to evaluate prop "${e}":`,t),u[e]=void 0,c[e]=void 0}h&&Object.keys(u).length>0&&(window[n]||(window[n]={}),Object.assign(window[n],u));const m=c;return s&&Object.keys(u).length>0&&Object.assign(s.context,u),s&&i.size>0&&(s.attributeTemplates||(s.attributeTemplates=new Map),s.attributeTemplates.set(e,new Map(i))),i.forEach(((t,n)=>{this.createLoopItemBinding(e,n,t,m,o,s)})),m}sortPropsByDependency(e){const t=Array.from(e.keys()),n=Array.from(e.entries()),s=[],i=[];for(const[e,r]of n)t.some((t=>t!==e&&r.includes(t)))?i.push([e,r]):s.push([e,r]);return[...s,...i]}setupEventBindingsForLoopItem(e,t){if(!this.eventDelegation)return void console.warn("No event delegation manager available");const n=Array.from(e.attributes);for(const s of n)if(ie.isEventAttribute(s.name)){const n=s.name.substring(2);this.eventDelegation.registerEventHandler(e,n,s.value,t),e.removeAttribute(s.name)}}processTextNodeWithLoopContext(e,t,n,s){if(A.isTextNodeInsideScript(e))return;const i=e.textContent||"";if(!L.parse(i).some((e=>"expression"===e.type)))return;s&&(s.textNodeTemplates||(s.textNodeTemplates=new Map),s.textNodeTemplates.set(e,i));const r=this.findActualComponentForTextNode(e);let a=t;r!==n&&s&&this.componentManager&&(a={...this.componentManager.buildComponentContext(r),...s.context}),this.updateTextNodeWithContext(e,i,a,r);const o=`loop_text_${Date.now()}_${Math.random()}`,c=this.templateRenderer.dependencies(i,r,this.stateManager),h=new Set(c),l={id:o,selector:"",dependencies:h,callback:()=>{if(!document.contains(e))return void this.stateManager.removeSubscription(o);let t={};if(this.componentManager&&(t=r!==n&&s?{...this.componentManager.buildComponentContext(r),...s.context}:this.componentManager.buildComponentContext(r)),s){const e={};let n=null;for(const[e,t]of this.loopBindings)if(t.renderedItems.includes(s)){n=t;break}if(n){e[n.itemVar]=s.context[n.itemVar],n.indexVar&&(e[n.indexVar]=s.context[n.indexVar]);const t=this.findParentLoopContext(n.template);t&&Object.assign(e,t)}t={...t,...e}}this.updateTextNodeWithContext(e,i,t,r)},component:r};this.stateManager.addSubscription(l),s&&s.subscriptionIds.push(o)}findActualComponentForTextNode(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e){return t.__uniqueComponentName||e}t=t.parentElement}return"app"}updateTextNodeWithContext(e,t,n,s){const i=L.parse(t),r={};for(const[e,t]of Object.entries(n))r[e]="function"==typeof t&&"__pphp_key"in t?t.value:t;let a="";for(const e of i)if("static"===e.type)a+=e.content;else if(e.expression)try{a+=Ce(this.expressionEvaluator.evaluateExpression(e.expression,r,s))}catch(t){console.warn(`Loop text evaluation error for "${e.expression}":`,t,"Available context keys:",Object.keys(r)),a+=""}e.textContent!==a&&(e.textContent=a)}extractMustacheBindings(e){const t=new Map,n=e.attributes;for(let e=0;e<n.length;e++){const s=n[e];if(s.name!==g.ATTR_PREFIXES.COMPONENT&&"key"!==s.name&&!s.name.startsWith("on")&&s.value){const e=g.MUSTACHE_PATTERN.test(s.value),n=L.decodeEntities(s.value),i=g.MUSTACHE_PATTERN.test(n);(e||i)&&t.set(s.name,n)}}return t}createLoopItemBinding(e,t,n,s,i,r){const a=`loop_item_${Date.now()}_${Math.random()}`,o=k.findScope(e);let c;c=o?"app"===o?"app":o:this.findLoopParentComponent(e,i);const h=this.templateRenderer.dependencies(n,c,this.stateManager);let l=null;const p=[];if(null!=r&&r.parentTemplate&&(l=this.findParentComponentWithPropsFromTemplate(r.parentTemplate),l&&this.componentManager)){const e=l.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e){const t=this.componentManager.getComponentPropDependencies(l,e);p.push(...t);const s=this.componentManager.elementProps.get(l);if(s){const e=Array.from(s.keys());for(const t of e)if(n.includes(t)){const e=s.get(t);if(e){const t=this.templateRenderer.dependencies(e.expression,e.component,this.stateManager);p.push(...t)}}}}}const u=new Set([...h,...p,"*"]);let d=!1,m=0;const f=()=>{var i;if(!d)if(document.contains(e)){m=0;try{const a=this.componentManager.buildComponentContext(c);let o;if(r){o={...a};let e=null;for(const[t,n]of this.loopBindings)if(n.renderedItems.includes(r)){e=n;break}e&&(o[e.itemVar]=r.context[e.itemVar],e.indexVar&&(o[e.indexVar]=r.context[e.indexVar]));for(const[e,t]of Object.entries(r.context))e in o||(o[e]=t);if(l&&this.componentManager){const e=this.componentManager.evaluateProps(l);Object.assign(o,e)}}else o=s;const h=this.templateRenderer.render(n,o,c);null==(i=this.domBindingManager)||i.updateElementProperty(e,t,h)}catch(e){console.error(`❌ Loop item binding evaluation error for "${n}":`,e),console.error("Available context keys:",Object.keys(s))}}else if(m++,m<5){const e=10*Math.pow(2,m-1);setTimeout((()=>{d||f()}),e)}else d=!0,this.stateManager.removeSubscription(a)},E={id:a,selector:"",dependencies:u,callback:()=>{d||f()},element:e,component:c};if(this.stateManager.addSubscription(E),r){r.subscriptionIds.push(a);const e=this.cleanupLoopItem.bind(this);this.cleanupLoopItem=t=>{t===r&&(d=!0),e(t)}}(()=>{document.contains(e)?f():Promise.resolve().then((()=>{if(!d&&document.contains(e))f();else if(!d&&m<5){m++;const e=10*Math.pow(2,m-1);setTimeout((()=>{d||f()}),e)}else!d&&m>=5&&(d=!0,this.stateManager.removeSubscription(a))}))})()}findParentComponentWithPropsFromTemplate(e){var t;let n=e.parentElement;for(;n&&n!==document.body;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)&&null!=(t=this.componentManager)&&t.hasStoredProps(n))return n;n=n.parentElement}return null}findLoopParentComponent(e,t){for(const[t,n]of this.loopBindings)for(const t of n.renderedItems)if(t.element===e||t.element.contains(e))return n.component;return this.findOriginalComponentName(t)}findOriginalComponentName(e){return e.includes("_")&&/\d{13}/.test(e)?e.split("_")[0]:e}updateItemContext(e,t,n,s){const i={...this.createItemContext(e,n,s),...this.gatherAllComponentContextsInLoopItem(t.element)};if(t.context=i,this.loopItemContexts.set(t.element,i),t.refTemplates)for(const[n,s]of t.refTemplates)if(document.contains(n))try{this.processRefAttribute(n,s,i,e.component)}catch(e){console.error(`Ref template update error for "${s}":`,e)}if(t.textNodeTemplates)for(const[e,n]of t.textNodeTemplates)document.contains(e)&&this.updateTextNodeWithContext(e,n,i,this.getTextNodeComponent(e));if(t.attributeTemplates)for(const[e,n]of t.attributeTemplates)document.contains(e)&&n.forEach(((t,n)=>{var s;try{const r=A.getElementComponent(e),a=this.buildElementSpecificContext(e,i),o=this.templateRenderer.render(t,a,r);null==(s=this.domBindingManager)||s.updateElementProperty(e,n,o)}catch(e){console.error(`Attribute binding update error for "${t}":`,e)}}))}gatherAllComponentContextsInLoopItem(e){if(!this.componentManager)return{};const t={};if(e.hasAttribute(g.ATTR_PREFIXES.COMPONENT)){const n=e.getAttribute(g.ATTR_PREFIXES.COMPONENT),s=this.componentManager.buildComponentContext(n);Object.assign(t,s)}return e.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}]`).forEach((e=>{var n;const s=e.getAttribute(g.ATTR_PREFIXES.COMPONENT),i=null==(n=this.componentManager)?void 0:n.buildComponentContext(s);Object.assign(t,i)})),t}buildElementSpecificContext(e,t){if(!this.componentManager)return t;const n=A.getElementComponent(e),s=this.componentManager.buildComponentContext(n);return{...t,...s}}getTextNodeComponent(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}updateDOMOrder(e,t){let n=e.isSSR&&e.listContainer?e.template:e.placeholder;t.forEach((t=>{(t.element.parentElement!==e.parentElement||t.element!==n.nextSibling)&&e.parentElement.insertBefore(t.element,n.nextSibling),n=t.element}))}clearRenderedItems(e){e.renderedItems.forEach((e=>{this.cleanupLoopItem(e)})),e.renderedItems=[]}cleanupLoopItem(e){if(e.element instanceof HTMLElement){const t=e.element;if(t.style.transition||"none"!==getComputedStyle(t).transition){t.style.opacity="0";const n=this.getTransitionDuration(t);return void setTimeout((()=>{this.performCleanup(e)}),n)}}this.performCleanup(e)}performCleanup(e){this.loopItemElements.delete(e.element),this.loopItemContexts.delete(e.element),e.element.parentElement&&e.element.parentElement.removeChild(e.element),e.subscriptionIds.forEach((e=>{this.stateManager.removeSubscription(e)}))}getTransitionDuration(e){const t=(getComputedStyle(e).transitionDuration||"0s").match(/^([\d.]+)(m?s)$/);if(!t)return 0;const n=parseFloat(t[1]);return"ms"===t[2]?n:1e3*n}isLoopItem(e){return this.loopItemElements.has(e)}getLoopItemContext(e){return this.loopItemContexts.get(e)}cleanupDetachedTemplates(e){for(const t of e)"childList"===t.type&&t.removedNodes.forEach((e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(document.contains(t))return;if("TEMPLATE"===t.tagName&&t.hasAttribute("pp-for")){const e=t;document.contains(e)||this.cleanupTemplate(e)}t.querySelectorAll("template[pp-for]").forEach((e=>{const t=e;document.contains(t)||this.cleanupTemplate(t)}))}}))}cleanupTemplate(e){const t=this.loopBindings.get(e);t&&(this.clearRenderedItems(t),t.subscriptionIds.forEach((e=>{this.stateManager.removeSubscription(e)})),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 ve{constructor(e){this.evaluator=e}static containsMustacheExpression(e){if(g.MUSTACHE_PATTERN.test(e))return!0;const t=L.decodeEntities(e);return g.MUSTACHE_PATTERN.test(t)}render(e,t,n){const s=L.isSingleExpression(e);if(s)return this.evaluator.evaluateExpression(s,t,n);let i="";for(const s of L.parse(e))if("static"===s.type)i+=s.content;else if(s.expression)try{i+=Ce(this.evaluator.evaluateExpression(s.expression,t,n))}catch{}return i}dependencies(e,t,n){const s=L.extractExpressions(e),i=new Set;for(const e of s)for(const s of this.evaluator.extractDependencies(e,t,n))i.add(s);return[...i]}}class en{constructor(e){d(this,"componentStack",["app"]),d(this,"elementProps",new WeakMap),d(this,"contextCache",new G(100)),d(this,"contextIndex",new Map),d(this,"contextInvalidated",new Set),d(this,"stateManager"),d(this,"processedScripts",new WeakSet),d(this,"componentFunctions",new Map),d(this,"expressionEvaluator"),d(this,"domBindingManager"),d(this,"templateRenderer"),d(this,"updateTimeouts"),d(this,"updateBatcher",new St),d(this,"propDependencyCache",new Map),this.stateManager=e,this.updateBatcher=new St,this.stateManager.onStateChange((e=>this.invalidateContextCache(e)))}getPropDependencies(e,t){var n;const s=this.findElementWithProps(t);if(!s)return[];const i=this.elementProps.get(s);if(!i||!i.has(e))return[];const r=i.get(e),a=(null==(n=this.templateRenderer)?void 0:n.dependencies(r.expression,r.component,this.stateManager))||[],o=new Set(a);for(const e of a){const t=e.split("."),n=t[t.length-1];this.getPropDependencies(n,r.component).forEach((e=>o.add(e)))}return Array.from(o)}buildRestrictedComponentContext(e,t=!1){const n={};window[e]&&Object.assign(n,window[e]);const s=this.componentFunctions.get(e);if(s)for(const[e,t]of s)n[e]=t;const i=this.stateManager.getState(),r=Object.keys(i).filter((t=>t.startsWith(e+".")));for(const t of r){const s=t.substring(e.length+1);s in n||(n[s]=i[t])}if(t&&"app"!==e){const e=this.componentFunctions.get("app");if(e)for(const[t,s]of e)t in n||(n[t]=s);if(window.app)for(const[e,t]of Object.entries(window.app))"function"==typeof t&&!("__pphp_key"in t)&&(e in n||(n[e]=t))}return n}getComponentPropDependencies(e,t){if(this.propDependencyCache.has(e))return this.propDependencyCache.get(e);const n=new Set,s=this.elementProps.get(e);s&&this.templateRenderer&&s.forEach((t=>{var s;const i=null==(s=this.templateRenderer)?void 0:s.dependencies(t.expression,t.component,this.stateManager);null==i||i.forEach((e=>n.add(e)));const r=this.findElementWithProps(t.component);r&&r!==e&&this.getComponentPropDependencies(r,t.component).forEach((e=>n.add(e)))}));const i=Array.from(n);return this.propDependencyCache.set(e,i),i}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 ve(e)}extractProps(e,t){const n=new Map,s=e.attributes,i=k.findScope(e),r=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);let a=t;i&&(a="app"===i?"app":i);for(let t=0;t<s.length;t++){const i=s[t];if(i.name!==g.ATTR_PREFIXES.COMPONENT&&i.name!==g.ATTR_PREFIXES.SPREAD&&i.name!==g.ATTR_PREFIXES.LOOP&&!ie.isEventAttribute(i.name)&&i.value&&ve.containsMustacheExpression(i.value)){if(r&&this.mightReferenceSelfProps(i.value,e))continue;const t=this.attributeToPropName(i.name),s={name:t,expression:i.value,component:a,subscriptionIds:[]};n.set(t,s)}}return n}mightReferenceSelfProps(e,t){const n=this.elementProps.get(t);if(!n)return!1;const s=Array.from(n.keys()),i=L.extractExpressions(e);if(0===i.length)return!1;for(const e of i)try{const t=D(e,{ecmaVersion:2022,sourceType:"script"}),n=new Set,i=new Set;U(t,{Identifier:(e,t)=>{const s=null==t?void 0:t[t.length-1];"MemberExpression"===(null==s?void 0:s.type)&&s.property===e&&!s.computed||("FunctionExpression"===(null==s?void 0:s.type)||"ArrowFunctionExpression"===(null==s?void 0:s.type))&&(s.params||[]).includes(e)||("MemberExpression"===(null==s?void 0:s.type)&&s.object===e?i.add(e.name):n.add(e.name))}});for(const e of s){if("dataState"===e)continue;const t=n.has(e),s=i.has(e)&&!n.has(e);if(t&&!s)return!0}}catch(t){console.error(`❌ Failed to parse mustache expression "${e}":`,t);continue}return!1}attributeToPropName(e){return e.replace(/-([a-z])/g,((e,t)=>t.toUpperCase()))}setupProps(e,t){const n=this.extractProps(e,t);0!==n.size&&(this.elementProps.set(e,n),this.expressionEvaluator&&n.forEach(((t,n)=>{this.setupPropBinding(e,t)})))}setupPropBinding(e,t){var n;if(!this.expressionEvaluator)return;const s=`prop_${Date.now()}_${Math.random()}`,i=(null==(n=this.templateRenderer)?void 0:n.dependencies(t.expression,t.component,this.stateManager))||[],r={id:s,selector:"",dependencies:new Set(i),callback:()=>{const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);t&&(this.updateBatcher.scheduleUpdate(t,e),this.refreshComponentBindings(e,t))},element:e,component:t.component};this.stateManager.addSubscription(r),t.subscriptionIds.push(s)}refreshComponentBindings(e,t){this.contextInvalidated.add(t),this.contextCache.delete(t),this.domBindingManager&&this.domBindingManager.refreshComponentElement(e,t)}evaluateProps(e){const t={},n=this.elementProps.get(e);if(!n||!this.expressionEvaluator)return t;const s=n.values().next().value;if(!s)return t;const i=this.buildComponentContextWithProps(s.component);return n.forEach(((e,n)=>{var s;try{const r=null==(s=this.templateRenderer)?void 0:s.render(e.expression,i,e.component);t[n]="function"==typeof r?"__pphp_key"in r?r:(...e)=>r.apply(this,e):r}catch(e){console.error(`❌ Failed to evaluate prop "${n}":`,e),t[n]=void 0}})),t}cleanupProps(e){const t=this.elementProps.get(e);t&&(t.forEach((e=>{e.subscriptionIds.forEach((e=>{this.stateManager.removeSubscription(e)}))})),this.elementProps.delete(e))}buildComponentContextWithProps(e,t){const n=this.buildComponentContext(e);let s=this.findElementWithProps(e);if(t&&this.elementProps.has(t)&&(s=t),s)try{const i=this.evaluatePropsWithContext(s,e,t);Object.keys(i).length>0&&Object.keys(i).forEach((e=>{n[e]=i[e]}))}catch(t){console.error(`❌ Error evaluating props for ${e}:`,t)}return n}buildRestrictedComponentContextWithProps(e,t){const n=this.buildRestrictedComponentContext(e,!1);if(this.elementProps.has(t)){const e=this.evaluateProps(t);Object.assign(n,e)}return n}evaluatePropsWithContext(e,t,n){const s={},i=this.elementProps.get(e);if(!i||!this.expressionEvaluator)return s;const r=i.values().next().value;if(!r)return s;const a=r.component;let o=this.buildComponentContextWithProps(a);const c=new Map,h=new Map,l=Array.from(i.keys());i.forEach(((e,t)=>{l.some((n=>n!==t&&e.expression.includes(n)))?h.set(t,e):c.set(t,e)})),c.forEach(((e,t)=>{var n;try{const i=null==(n=this.templateRenderer)?void 0:n.render(e.expression,o,e.component);s[t]=i}catch(e){console.error(`❌ Failed to evaluate prop "${t}":`,e),s[t]=void 0}}));const p={...o,...s};return h.forEach(((e,t)=>{var n;try{const i=null==(n=this.templateRenderer)?void 0:n.render(e.expression,p,e.component);s[t]=i}catch(e){console.error(`❌ Failed to evaluate prop "${t}":`,e),s[t]=void 0}})),s}findElementWithProps(e){const t=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${e}"]`);for(const e of t){const t=this.elementProps.get(e);if(t&&t.size>0)return e}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 n=e.split("_");n.pop();const s=n.join("_");window[s]&&Object.assign(t,window[s])}"app"!==e&&window[e]&&Object.assign(t,window[e]),"app"===e&&window.app&&Object.assign(t,window.app);const n=this.componentFunctions.get(e);if(n)for(const[e,s]of n)t[e]=s;const s=this.stateManager.getState();for(const n of Object.keys(s))if(n.startsWith(e+".")){const i=n.substring(e.length+1);i in t||(t[i]=s[n])}return t}invalidateContextCache(e){if(e.startsWith("app.")){this.contextCache.clear();for(const e of this.contextInvalidated.keys())this.contextInvalidated.add(e);return}const t=e.indexOf(".");if(-1!==t){const n=e.slice(0,t);this.invalidateComponent(n)}}invalidateComponent(e){this.contextInvalidated.add(e),this.contextIndex.delete(e)}executePhpScripts(e){const t=this.componentStack.length,n=e.getAttribute(g.ATTR_PREFIXES.COMPONENT),s=e===document.body;if(n||s){if(n){this.pushComponent(n);const t=this.getParentComponent(e);this.setupProps(e,t)}this.getRelevantScripts(e,s).forEach((e=>{const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);t&&t!==n?(this.pushComponent(t),this.executeScript(e),this.popComponent()):this.executeScript(e)}))}for(Array.from(e.children).forEach((e=>this.executePhpScripts(e)));this.componentStack.length>t;)this.popComponent()}getParentComponent(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}getRelevantScripts(e,t){return Array.from(e.querySelectorAll(`script[type="${g.SCRIPT_TYPE}"]`)).filter((n=>{if(this.processedScripts.has(n))return!1;if(t)return!!n.hasAttribute(g.ATTR_PREFIXES.COMPONENT)||!n.closest(`[${g.ATTR_PREFIXES.COMPONENT}]`);let s=n.parentElement;for(;s&&s!==e;){if(s.hasAttribute(g.ATTR_PREFIXES.COMPONENT))return!1;s=s.parentElement}return s===e||e.contains(n)}))}executeScript(e){if(this.processedScripts.has(e))return;this.processedScripts.add(e);const t=this.getCurrentComponent(),n=e.textContent||"",s=L.decodeEntities(n);try{const n=this.findComponentElementForScript(e,t);if(n===e){const t=this.getParentComponent(e);this.setupProps(e,t)}let i;if(this.hasExplicitContext(n||e,t))i=this.buildComponentContextWithProps(t,n);else if(i=this.buildRestrictedComponentContext(t,!1),n&&this.hasStoredProps(n)){const e=this.evaluateProps(n);Object.assign(i,e)}window[t]||(window[t]={}),this.executeScriptFunctions(s,t,i)}catch(e){console.error(`Script execution failed in component ${t}:`,e),console.error("Script content:",s)}}hasExplicitContext(e,t){return null!==k.findScope(e)}findComponentElementForScript(e,t){if(e.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return n;n=n.parentElement}const s=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const e of s)if(this.elementProps.has(e))return e;return s[0]||void 0}executeScriptFunctions(e,t,n){const s=this.extractFunctionNames(e),i=this.findElementWithProps(t),r=this.extractVariableDeclarations(e);let a={...n};r.forEach((e=>{delete a[e];const t=`set${rs(e)}`,n=`${e}Getter`;delete a[t],delete a[n]}));const o=i&&this.hasStoredProps(i);if(o){a=this.buildRestrictedComponentContext(t,!1);const e=this.evaluateProps(i);a={...a,...e}}else if(i){const e=this.evaluateProps(i);Object.assign(a,e)}a.getContext=()=>{if(o){return{...this.buildRestrictedComponentContext(t,!1),...i?this.evaluateProps(i):{}}}return this.buildComponentContextWithProps(t)},a.withContext=e=>{const t=a.getContext();return e.call(t,t)},a.__getProp=e=>{if(i)return this.evaluateProps(i)[e]};const c=Ne.getInstance(),h=new Set;if(i){const e=this.evaluateProps(i);for(const[t,n]of Object.entries(e))"function"==typeof n&&"__pphp_key"in n&&(h.add(t),/^set[A-Z]/.test(t)&&h.add(t))}let l=c.transformStateDeclarations(e,h);l=this.modifyScriptForReactiveProps(l,t,i||void 0);const p=`\n ${l}\n\n ${s.map((e=>`\n if (typeof ${e} === 'function') {\n this['${e}'] = ${e};\n }\n `)).join("\n")}\n `,u={};for(const[e,t]of Object.entries(a))this.isValidJavaScriptIdentifier(e)&&(u[e]=t);const d=Object.keys(u),m=d.map((e=>u[e]));if(this.checkIfInLoopItem()){const e=this.extractLoopItemContext();this.domBindingManager.stateManager.currentLoopContext=e}try{new Function(...d,p).call(window[t],...m),window[t].getContext=a.getContext,window[t].withContext=a.withContext,window[t].__getProp=a.__getProp;for(const e of s){const n=window[t][e];"function"==typeof n&&this.storeFunctionForComponent(t,e,n)}this.invalidateComponent(t)}catch(n){console.error("Script execution failed:",n),console.error("Component:",t),console.error("Original script:",e),console.error("Available context keys:",Object.keys(u)),console.error("Should isolate:",o)}finally{this.domBindingManager.stateManager.currentLoopContext=null}}isValidJavaScriptIdentifier(e){return!Se.has(e)&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}checkIfInLoopItem(){return!1}extractLoopItemContext(){return{}}extractVariableDeclarations(e){const t=Ne.getInstance().extractStateDeclarations(e).map((e=>e.variableName)),n=[],s=/(?:const|let|var)\s*\[\s*([^,\]]+)(?:\s*,\s*([^,\]]+))?\s*\]/g;let i;for(;null!==(i=s.exec(e));)i[1]&&!t.includes(i[1].trim())&&n.push(i[1].trim()),i[2]&&!t.includes(i[2].trim())&&n.push(i[2].trim());const r=/(?:const|let|var)\s+([a-zA-Z_$][\w$]*)/g;for(;null!==(i=r.exec(e));)t.includes(i[1])||n.push(i[1]);return[...t,...n]}modifyScriptForReactiveProps(e,t,n){if(!n||!this.elementProps.has(n))return e;const s=this.elementProps.get(n),i=Array.from(s.keys());let r=e;return i.forEach((e=>{r=this.replacePropOutsideStrings(r,e)})),r}replacePropOutsideStrings(e,t){let n="",s=0;const i=e.length;for(;s<i;){const r=e[s];if("'"!==r)if('"'!==r)if("`"!==r){if("/"===r&&s+1<i){if("/"===e[s+1]){const t=e.indexOf("\n",s),r=-1===t?i:t;n+=e.slice(s,r),s=r;continue}if("*"===e[s+1]){const t=e.indexOf("*/",s+2),r=-1===t?i:t+2;n+=e.slice(s,r),s=r;continue}}this.matchesPropName(e,s,t)?(n+=`__getProp('${t}')`,s+=t.length):(n+=r,s++)}else{const t=this.findTemplateEnd(e,s);n+=e.slice(s,t+1),s=t+1}else{const t=this.findStringEnd(e,s,'"');n+=e.slice(s,t+1),s=t+1}else{const t=this.findStringEnd(e,s,"'");n+=e.slice(s,t+1),s=t+1}}return n}findStringEnd(e,t,n){let s=t+1;for(;s<e.length;){if(e[s]===n&&"\\"!==e[s-1])return s;"\\"===e[s]&&s++,s++}return e.length-1}findTemplateEnd(e,t){let n=t+1,s=0;for(;n<e.length;){const t=e[n];if("`"===t&&0===s)return n;"$"===t&&n+1<e.length&&"{"===e[n+1]?(s++,n++):"}"===t&&s>0?s--:"\\"===t&&n++,n++}return e.length-1}matchesPropName(e,t,n){if(t+n.length>e.length||e.substr(t,n.length)!==n)return!1;const s=t>0?e[t-1]:"",i=t+n.length<e.length?e[t+n.length]:"",r=0===t||!/[a-zA-Z0-9_$]/.test(s),a=t+n.length===e.length||!/[a-zA-Z0-9_$]/.test(i);if(!r||!a||"."===s||"."===i)return!1;const o=e.slice(t+n.length);if(/^\s*[=:]/.test(o))return!1;const c=e.slice(Math.max(0,t-20),t);return!/[a-zA-Z0-9_$]\s*\.\s*$/.test(c)}extractFunctionNames(e){return Ne.getInstance().extractFunctionNames(e)}storeFunctionForComponent(e,t,n){this.componentFunctions.has(e)||this.componentFunctions.set(e,new Map),this.componentFunctions.get(e).set(t,n),window[e]||(window[e]={}),window[e][t]=n}getComponentFunctions(e){return this.componentFunctions.get(e)}destroy(){if(this.updateTimeouts){for(const e of this.updateTimeouts.values())clearTimeout(e);this.updateTimeouts.clear()}this.componentFunctions.clear(),this.elementProps=new WeakMap,this.contextCache.clear(),this.propDependencyCache.clear()}}class St{constructor(){d(this,"pendingUpdates",new Map),d(this,"batchTimeout",null),d(this,"componentManager"),d(this,"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),null===this.batchTimeout&&(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[e,n]of t)this.processComponentUpdate(e,n)}sortUpdatesByDependency(e){const t=new WeakMap,n=e=>{let n=t.get(e);return null==n&&(n=A.getElementDepth(e),t.set(e,n)),n};return Array.from(e.entries()).sort((([,e],[,t])=>Math.min(...Array.from(e,n))-Math.min(...Array.from(t,n))))}processComponentUpdate(e,t){if(!this.componentManager||!this.domBindingManager)return;this.componentManager.invalidateComponent(e);const n=[],s=[],i=[];for(const r of t){if(!document.contains(r))continue;const t=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,null);let a;for(;a=t.nextNode();)n.push(a);const o=this.domBindingManager.loopManager;if(o){const t=o.getAllLoops();for(const[n,i]of t)i.component===e&&r.contains(n)&&s.push([n,i])}i.push(r)}this.updateTextNodesBatch(n,e),this.updateLoopsBatch(s),this.updateElementsBatch(i,e)}updateTextNodesBatch(e,t){const n=this.domBindingManager.textNodeManager;n&&e.forEach((e=>{document.contains(e)&&A.getComponentForNode(e)===t&&n.updateTextNode(e)}))}updateLoopsBatch(e){const t=this.domBindingManager.loopManager;if(!t)return;const n=new Map;e.forEach((([e,t])=>{const s=A.getElementDepth(e);n.has(s)||n.set(s,[]),n.get(s).push([e,t])}));const s=Array.from(n.keys()).sort(((e,t)=>e-t));for(const e of s)n.get(e).forEach((([e,n])=>{document.contains(e)&&t.renderLoop(n,n.iterableExpr)}))}updateElementsBatch(e,t){e.forEach((e=>{document.contains(e)&&this.domBindingManager.processElementBindings(e,!0)}))}}const g={ATTR_PREFIXES:{COMPONENT:"pp-component",LOOP:"pp-for",SPREAD:"pp-spread",REF:"pp-ref"},SCRIPT_TYPE:"text/pp",MAX_CACHE_SIZE:2e3,DEBOUNCE_MS:16,MUSTACHE_PATTERN:/\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}/},Se=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 tn(e,t){let n;return(...s)=>{clearTimeout(n),n=window.setTimeout((()=>e(...s)),t)}}function rs(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ce(e){if(null==e||"boolean"==typeof e||"function"==typeof e||Array.isArray(e)&&0===e.length||"object"==typeof e&&0===Object.keys(e).length)return"";if("number"==typeof e)return String(e);if("string"==typeof e)return e;if(Array.isArray(e)){if(e.some((e=>null!==e&&("object"==typeof e||Array.isArray(e)))))try{return JSON.stringify(e)}catch{return"[Array]"}return e.map((e=>Ce(e))).filter((e=>""!==e)).join("")}if("object"==typeof e)try{return JSON.stringify(e)}catch{return"[object Object]"}return String(e)}function Oe(e){return"function"==typeof e&&"__pphp_key"in e}function We(e){return Oe(e)?e.value:e}function as(e,t={}){if(!Oe(e))return e;const n=e.value;return t.forComparison||t.forLogical||t.forceExtract||null==n||"boolean"==typeof n||"string"==typeof n||"number"==typeof n?n:e}function os(e,t=!1){const n={};for(const[s,i]of Object.entries(e))Oe(i)?n[s]=t?as(i):i.value:n[s]=i;return n}function sn(e){return e.includes("?")||e.includes("&&")||e.includes("||")||e.includes("===")||e.includes("!==")||e.includes("==")||e.includes("!=")||e.includes(">=")||e.includes("<=")||e.includes(">")||e.includes("<")||/^!/.test(e.trim())}class k{static findScope(e){const t=e instanceof Text?e.parentElement:e;if(!t)return null;if(this.scopeCache.has(t))return this.scopeCache.get(t);const n=this.findScopeUncached(t);return this.scopeCache.set(t,n),this.trackElement(t),n}static findScopeUncached(e){const t=this.findScopeInSiblings(e);if(null!==t)return t;let n=e.parentElement;for(;n&&n!==document.body;){if(n instanceof Element&&n.hasAttribute(g.ATTR_PREFIXES.COMPONENT))return null;const e=this.findScopeInSiblings(n);if(null!==e)return e;n=n.parentElement}return null}static findScopeInSiblings(e){let t=e.previousSibling,n=0;for(;t;){if(t.nodeType===Node.COMMENT_NODE){const e=t,s=this.parseCommentNode(e,n);if(null!==s)if("end"===s.type)n++;else if("start"===s.type){if(0===n)return s.name;n--}}t=t.previousSibling}return null}static parseCommentNode(e,t){if(this.commentCache.has(e)){const t=this.commentCache.get(e);if(""===t)return null;if("/pp-scope"===t)return{type:"end",name:""};if(t.startsWith("pp-scope:"))return{type:"start",name:t.substring(9)}}const n=(e.textContent||"").trim();if("/pp-scope"===n)return this.commentCache.set(e,n),{type:"end",name:""};if(n.startsWith("pp-scope:")){const t=n.substring(9).trim();return this.isValidScopeName(t)?(this.commentCache.set(e,n),{type:"start",name:t}):(console.warn(`⚠️ Invalid scope name in comment: "${t}". Scope names must be valid identifiers or "app".`),this.commentCache.set(e,""),null)}return this.commentCache.set(e,""),null}static isValidScopeName(e){return"app"===e||/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}static removeScopeComments(){const e=document.createTreeWalker(document.body,NodeFilter.SHOW_COMMENT,{acceptNode:e=>{const t=(e.textContent||"").trim();return"/pp-scope"===t||t.startsWith("pp-scope:")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),t=[];let n;for(;n=e.nextNode();)t.push(n);if(0===t.length)return void console.debug("No scope comments found to remove");console.debug(`Found ${t.length} scope comments to remove`);let s=0;for(const e of t)try{e.parentNode&&(e.parentNode.removeChild(e),s++)}catch(e){console.error("Failed to remove scope comment:",e)}console.debug(`✅ Successfully removed ${s} scope comments from DOM`)}static preCacheAllScopes(){const e=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,null),t=[];let n;for(;n=e.nextNode();)t.push(n);for(const e of t)this.findScope(e);console.debug(`Pre-cached scopes for ${t.length} elements`)}static trackElement(e){this.trackedElements.add(e),this.trackedElements.size>=this.MAX_TRACKED_ELEMENTS&&this.scheduleCleanup(),Date.now()-this.lastCleanup>this.CLEANUP_INTERVAL&&this.scheduleCleanup()}static scheduleCleanup(){this.cleanupScheduled||(this.cleanupScheduled=!0,requestIdleCallback((()=>{this.performCleanup(),this.cleanupScheduled=!1}),{timeout:1e3}))}static performCleanup(){const e=[];let t=0;for(const n of this.trackedElements){if(t++,t%100==0&&!this.cleanupScheduled)break;document.contains(n)||e.push(n)}e.forEach((e=>{this.scopeCache.delete(e),this.trackedElements.delete(e)})),this.lastCleanup=Date.now(),e.length>0&&console.debug(`ScopeResolver cleanup: removed ${e.length} detached elements, ${this.trackedElements.size} elements remaining`)}static clearCache(){this.scopeCache=new WeakMap,this.commentCache=new WeakMap,this.trackedElements.clear(),this.cleanupScheduled=!1,this.lastCleanup=0}static invalidateElement(e){this.scopeCache.delete(e),this.trackedElements.delete(e)}static invalidateTree(e){this.invalidateElement(e);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let n;for(;n=t.nextNode();)this.invalidateElement(n)}static getCacheStats(){return{trackedElements:this.trackedElements.size,lastCleanup:this.lastCleanup,cleanupScheduled:this.cleanupScheduled}}static forceCleanup(){this.cleanupScheduled=!0,this.performCleanup(),this.cleanupScheduled=!1}}d(k,"scopeCache",new WeakMap),d(k,"commentCache",new WeakMap),d(k,"trackedElements",new Set),d(k,"cleanupScheduled",!1),d(k,"CLEANUP_INTERVAL",5e3),d(k,"MAX_TRACKED_ELEMENTS",1e3),d(k,"lastCleanup",0);class nn{static validate(e,t){const n=[],s=[];try{const t=D(e,{ecmaVersion:2022,sourceType:"script"}),i=this.validateAST(t,e);n.push(...i.errors),s.push(...i.warnings);const r=this.validateSyntax(e);n.push(...r.errors),s.push(...r.warnings)}catch(e){n.push(`Invalid JavaScript syntax: ${e instanceof Error?e.message:String(e)}`)}return{valid:0===n.length,errors:n,warnings:s}}static validateAST(e,t){const n=[],s=[];return U(e,{ConditionalExpression:e=>{const i=t.slice(e.consequent.start,e.consequent.end),r=this.validateBranch(i,"truthy");n.push(...r.errors),s.push(...r.warnings);const a=t.slice(e.alternate.start,e.alternate.end),o=this.validateBranch(a,"falsy");n.push(...o.errors),s.push(...o.warnings)}}),{errors:n,warnings:s}}static validateBranch(e,t){const n=[],s=[];try{return D(e,{ecmaVersion:2022,sourceType:"script"}),{errors:n,warnings:s}}catch{const i=this.countQuotes(e);if(i.single%2!=0&&(n.push(`Unmatched single quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,"'"))){const t=this.suggestQuoteFix(e,"'");t&&n.push(` Did you mean: ${t}`)}if(i.double%2!=0&&(n.push(`Unmatched double quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,'"'))){const t=this.suggestQuoteFix(e,'"');t&&n.push(` Did you mean: ${t}`)}i.single%2==0&&i.double%2==0&&this.looksLikeUnquotedLiteral(e)&&s.push(`Value "${e}" in ternary ${t} branch may need quotes. Did you mean '${e}' or "${e}"?`)}return{errors:n,warnings:s}}static hasTrailingOrLeadingQuote(e,t){const n=e.startsWith(t),s=e.endsWith(t);return n&&!s||!n&&s}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();if(!t||this.isAlreadyQuoted(t))return!1;try{return D(t,{ecmaVersion:2022,sourceType:"script"}),!1}catch{}return!(Se.has(t)||"true"===t||"false"===t||"null"===t||"undefined"===t||!isNaN(Number(t))&&""!==t||/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)||t.includes(".")||/\[.*\]/.test(t)||/\(.*\)/.test(t))&&!!(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,n=0,s=!1;for(let i=0;i<e.length;i++)s?s=!1:"\\"!==e[i]?("'"===e[i]&&t++,'"'===e[i]&&n++):s=!0;return{single:t,double:n}}static validateSyntax(e){const t=[],n=this.checkBrackets(e);n.valid||t.push(n.error);const s=this.checkParentheses(e);return s.valid||t.push(s.error),{errors:t,warnings:[]}}static checkBrackets(e){let t=0,n=!1,s="";for(let i=0;i<e.length;i++){const r=e[i],a=i>0?e[i-1]:"";if(n||"'"!==r&&'"'!==r?n&&r===s&&"\\"!==a&&(n=!1,s=""):(n=!0,s=r),!n&&("{"===r&&t++,"}"===r&&t--,t<0))return{valid:!1,error:"Unexpected closing bracket '}'"}}return 0!==t?{valid:!1,error:"Mismatched brackets - missing '}'"}:{valid:!0,error:""}}static checkParentheses(e){let t=0,n=!1,s="";for(let i=0;i<e.length;i++){const r=e[i],a=i>0?e[i-1]:"";if(n||"'"!==r&&'"'!==r?n&&r===s&&"\\"!==a&&(n=!1,s=""):(n=!0,s=r),!n&&("("===r&&t++,")"===r&&t--,t<0))return{valid:!1,error:"Unexpected closing parenthesis ')'"}}return 0!==t?{valid:!1,error:"Mismatched parentheses - missing ')'"}:{valid:!0,error:""}}}const $=class e{constructor(){d(this,"componentElementsCache",new G(100)),d(this,"scriptElementsCache",new G(50)),d(this,"templateElementsCache",new G(50)),d(this,"selectorCache",new G(200)),d(this,"elementComponentCache",new WeakMap),d(this,"parentComponentCache",new WeakMap),d(this,"contextComponentCache",new WeakMap),d(this,"elementDepthCache",new WeakMap),d(this,"elementChildrenCache",new WeakMap),d(this,"cacheHits",0),d(this,"cacheMisses",0)}static getInstance(){return e.instance||(e.instance=new e),e.instance}queryComponentElements(t){const n=e.CACHE_KEYS.COMPONENT_ELEMENTS(t);if(this.componentElementsCache.has(n))return this.cacheHits++,this.componentElementsCache.get(n);this.cacheMisses++;const s=Array.from(document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`));return s.forEach((e=>{this.elementComponentCache.set(e,t)})),this.componentElementsCache.set(n,s),s}querySelectorAll(t){const n=e.CACHE_KEYS.SELECTOR(t);if(this.selectorCache.has(n))return this.cacheHits++,this.selectorCache.get(n);this.cacheMisses++;const s=Array.from(document.querySelectorAll(t));return this.selectorCache.set(n,s),s}getElementComponent(e){if(this.elementComponentCache.has(e))return this.cacheHits++,this.elementComponentCache.get(e);this.cacheMisses++;const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(t)return this.elementComponentCache.set(e,t),t;let n=e.parentElement;for(;n;){const t=n.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(t)return this.elementComponentCache.set(e,t),t;n=n.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=k.findScope(e);let n;return n=t?"app"===t?"app":t:this.getElementComponent(e),this.contextComponentCache.set(e,n),n}getParentOfComponent(e,t){if(this.parentComponentCache.has(t))return this.cacheHits++,this.parentComponentCache.get(t);if(this.cacheMisses++,"app"===e)return this.parentComponentCache.set(t,"app"),"app";let n=t;for(;n&&n.getAttribute(g.ATTR_PREFIXES.COMPONENT)!==e;)n=n.parentElement;if(!n)return this.parentComponentCache.set(t,"app"),"app";let s=n.parentElement;for(;s;){const e=s.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return this.parentComponentCache.set(t,e),e;s=s.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,n=e.parentElement;for(;n&&n!==document.body;)t++,n=n.parentElement;return this.elementDepthCache.set(e,t),t}getFirstComponentElement(e){const t=this.queryComponentElements(e);return t.length>0?t[0]:null}getComponentScripts(t,n){const s=e.CACHE_KEYS.SCRIPTS(t,(null==n?void 0:n.tagName)||"global");if(this.scriptElementsCache.has(s))return this.cacheHits++,this.scriptElementsCache.get(s);this.cacheMisses++;let i=[];if(n){const e=n.querySelectorAll(`script[type="${g.SCRIPT_TYPE}"]`);for(const t of e)t instanceof HTMLScriptElement&&i.push(t)}else{const e=document.querySelectorAll(`script[type="${g.SCRIPT_TYPE}"]`);for(const n of e)if(n instanceof HTMLScriptElement){const e=n.getAttribute(g.ATTR_PREFIXES.COMPONENT);(e===t||!e&&!n.closest(`[${g.ATTR_PREFIXES.COMPONENT}]`))&&i.push(n)}}return this.scriptElementsCache.set(s,i),i}getComponentTemplates(t,n){const s=e.CACHE_KEYS.TEMPLATES(t,(null==n?void 0:n.tagName)||"global");if(this.templateElementsCache.has(s))return this.cacheHits++,this.templateElementsCache.get(s);this.cacheMisses++;let i=[];if(n){const e=n.querySelectorAll("template[pp-for]");for(const n of e)n instanceof HTMLTemplateElement&&this.getElementComponent(n)===t&&i.push(n)}else{const e=document.querySelectorAll("template[pp-for]");for(const n of e)n instanceof HTMLTemplateElement&&this.getElementComponent(n)===t&&i.push(n)}return this.templateElementsCache.set(s,i),i}querySelector(e){const t=this.querySelectorAll(e);return t.length>0?t[0]:null}findElementForComponent(e,t){if("app"===t)return document.body;const n=this.queryComponentElements(t);return n.length>0?n[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(t){const n=e.CACHE_KEYS.COMPONENT_ELEMENTS(t);this.componentElementsCache.delete(n);const s=e.CACHE_KEYS.SCRIPTS(t,"global");this.scriptElementsCache.delete(s);const i=e.CACHE_KEYS.TEMPLATES(t,"global");this.templateElementsCache.delete(i),this.selectorCache.clear(),this.queryComponentElements(t).forEach((e=>k.invalidateElement(e)))}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),k.invalidateElement(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,k.clearCache()}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}};d($,"instance"),d($,"CACHE_KEYS",{COMPONENT_ELEMENTS:e=>`comp:${e}`,SCRIPTS:(e,t)=>`scripts:${e}:${t}`,TEMPLATES:(e,t)=>`templates:${e}:${t}`,SELECTOR:e=>`sel:${e}`});let je=$;class rn{constructor(){d(this,"subscriptions",new Map),d(this,"elementSubscriptions",new WeakMap),d(this,"keyIndex",new Map),d(this,"cleanupQueue",new Set),d(this,"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 n=this.elementSubscriptions.get(t.element);n&&(n.delete(e),0===n.size&&this.elementSubscriptions.delete(t.element))}for(const n of t.dependencies){const t=this.keyIndex.get(n);t&&(t.delete(e),0===t.size&&this.keyIndex.delete(n))}}}cleanupElement(e){const t=this.elementSubscriptions.get(e);t&&(t.forEach((e=>this.cleanupQueue.add(e))),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,n]of this.subscriptions)n.element&&!document.contains(n.element)&&e.push(t);e.forEach((e=>this.removeSubscription(e)))}getStats(){return{totalSubscriptions:this.subscriptions.size,elementSubscriptions:this.elementSubscriptions instanceof WeakMap?-1:0,keyIndexes:this.keyIndex.size}}}class G{constructor(e){d(this,"cache",new Map),d(this,"maxSize"),d(this,"hits",0),d(this,"misses",0),this.maxSize=e}keys(){return Array.from(this.cache.keys())}deleteByPrefix(e){let t=0;const n=[];return this.cache.forEach(((t,s)=>{"string"==typeof s&&s.startsWith(e)&&n.push(s)})),n.forEach((e=>{this.cache.delete(e)&&t++})),t}getKeysByPrefix(e){const t=[];return this.cache.forEach(((n,s)=>{"string"==typeof s&&s.startsWith(e)&&t.push(s)})),t}get(e){const t=this.cache.get(e);if(void 0!==t)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 e=this.cache.keys().next().value;void 0!==e&&this.cache.delete(e)}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}}const ee=class e{static parseSpreadDirective(e){const t=e.replace(/^\s*\{\s*|\s*\}\s*$/g,""),n=this.parseSpreadParts(t),s=[],i=[];for(const e of n){const t=e.trim();if(t.startsWith("..."))s.push(t.substring(3).trim());else if(t.startsWith("{")&&t.endsWith("}")){const e=t.slice(1,-1).trim();if(e){const t=this.parseObjectProperties(e);i.push(t)}}else console.warn(`Invalid spread directive part: "${t}". Expected ...spread or {object}`)}return{spreads:s,objects:i}}static parseSpreadParts(e){const t=[];let n="",s=0,i=!1,r="",a=0;for(;a<e.length;){const o=e[a],c=a>0?e[a-1]:"";if(i||'"'!==o&&"'"!==o?i&&o===r&&"\\"!==c&&(i=!1,r=""):(i=!0,r=o),!i)if("{"===o)s++;else if("}"===o)s--;else if(","===o&&0===s){t.push(n.trim()),n="",a++;continue}n+=o,a++}return n.trim()&&t.push(n.trim()),t}static parseObjectProperties(e){const t=[],n=this.parseObjectParts(e);for(const e of n){const n=e.trim(),s=this.findPropertySeparator(n);if(-1!==s){const e=n.substring(0,s).trim().replace(/['"]/g,""),i=n.substring(s+1).trim();t.push({key:e,value:i})}else console.warn(`Invalid object property: "${n}". Expected key: value format.`)}return t}static parseObjectParts(e){const t=[];let n="",s=0,i=!1,r="";for(let a=0;a<e.length;a++){const o=e[a],c=a>0?e[a-1]:"";if(i||'"'!==o&&"'"!==o?i&&o===r&&"\\"!==c&&(i=!1,r=""):(i=!0,r=o),!i)if("{"===o||"["===o||"("===o)s++;else if("}"===o||"]"===o||")"===o)s--;else if(","===o&&0===s){t.push(n.trim()),n="";continue}n+=o}return n.trim()&&t.push(n.trim()),t}static findPropertySeparator(e){let t=0,n=!1,s="";for(let i=0;i<e.length;i++){const r=e[i],a=i>0?e[i-1]:"";if(n||'"'!==r&&"'"!==r?n&&r===s&&"\\"!==a&&(n=!1,s=""):(n=!0,s=r),!n)if("{"===r||"["===r||"("===r)t++;else if("}"===r||"]"===r||")"===r)t--;else if(":"===r&&0===t)return i}return-1}static parse(t){if(e.EXPRESSION_CACHE.has(t))return e.EXPRESSION_CACHE.get(t);const n=e.parseContentWithNesting(t);return e.EXPRESSION_CACHE.set(t,n),n}static parseContentWithNesting(e){const t=[],n=e.length;let s=0,i=0;for(;s<n;)if("{"===e[s]){s>i&&t.push({type:"static",content:e.substring(i,s),expression:null});const n=this.extractNestedExpression(e,s);-1!==n.endIndex&&n.expression&&this.isValidExpression(n.expression)?(t.push({type:"expression",content:e.substring(s,n.endIndex+1),expression:n.expression.trim()}),s=n.endIndex+1,i=s):s++}else s++;return i<n&&t.push({type:"static",content:e.substring(i),expression:null}),t}static isValidExpression(e){const t=e.trim();if(!t)return!1;try{const e=D(t,{ecmaVersion:2022,sourceType:"script"});if("Program"!==e.type)return!1;const n=e.body;if(!n||0===n.length)return!1;const s=n[0];if("ExpressionStatement"!==s.type)return!1;const i=s.expression;return!("ObjectExpression"===i.type||"SequenceExpression"===i.type)}catch{try{const e=D(`(${t})`,{ecmaVersion:2022,sourceType:"script"}).body;if(e&&e.length>0&&"ExpressionStatement"===e[0].type)return!0}catch{return!1}return!1}}static extractNestedExpression(e,t){let n=1,s=t+1,i=!1,r="",a=!1;for(;s<e.length&&n>0;){const t=e[s],o=s>0?e[s-1]:"";i||'"'!==t&&"'"!==t?i&&t===r&&"\\"!==o&&(i=!1,r=""):(i=!0,r=t),!i&&"`"===t&&"\\"!==o&&(a=!a),!i&&!a&&("{"===t?n++:"}"===t&&n--),s++}if(0===n){const n=e.slice(t+1,s-1);if(n.trim()){const t=this.checkForMismatchedQuotes(n);t.hasIssue&&(console.error("\n❌ Malformed expression detected during parsing:"),console.error(` Expression: ${n}`),console.error(` Issue: ${t.message}`),console.error(` Full content: ${e}`),console.error(" 💡 Hint: Check your quotes - strings must be properly quoted\n"))}return{endIndex:s-1,expression:n}}return console.warn("\n⚠️ Failed to extract mustache expression - unclosed braces"),console.warn(` Content: ${e}`),console.warn(` Starting at position: ${t}\n`),{endIndex:-1,expression:""}}static checkForMismatchedQuotes(e){let t=0,n=0,s=!1;for(let i=0;i<e.length;i++)s?s=!1:"\\"!==e[i]?("'"===e[i]&&t++,'"'===e[i]&&n++):s=!0;return t%2!=0?{hasIssue:!0,message:`Unmatched single quotes (found ${t})`}:n%2!=0?{hasIssue:!0,message:`Unmatched double quotes (found ${n})`}:{hasIssue:!1,message:""}}static isSingleExpression(t){const n=e.parseContentWithNesting(t);return 1===n.length&&"expression"===n[0].type?n[0].expression:null}static extractExpressions(t){const n=e.parseContentWithNesting(t),s=n.filter((e=>"expression"===e.type)).map((e=>e.expression)).filter((e=>e));return n.some((e=>"expression"===e.type))&&0===s.length&&(console.error("\n❌ Failed to extract expressions from content:"),console.error(` Content: ${t}`),console.error(` Parsed ${n.length} parts, but extracted 0 expressions`),console.error(" This usually means malformed mustache syntax\n")),s}};d(ee,"EXPRESSION_CACHE",new G(1e3)),d(ee,"decodeEntities",(e=>{const t=document.createElement("textarea");t.innerHTML=e;let n=t.value;for(;n.includes("&");){t.innerHTML=n;const e=t.value;if(e===n)break;n=e}return n}));let L=ee;class an{constructor(){d(this,"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){var n;null==(n=this.listeners.get(e))||n.delete(t)}emit(e,...t){const n=this.listeners.get(e);n&&n.forEach((n=>{try{n(...t)}catch(t){console.error(`Event listener error for ${e}:`,t)}}))}}class Fe{constructor(){d(this,"subscriptionManager",new rn),d(this,"stateStore",{}),d(this,"updateQueue",new Set),d(this,"isUpdating",!1),d(this,"eventBus",new an),d(this,"contextCache",new Map),d(this,"previousValues",new Map),d(this,"originalStateStore",{}),d(this,"domUpdateCallbacks",[]),d(this,"domUpdateScheduled",!1),d(this,"scheduleFlush",tn((()=>{this.flushUpdates()}),g.DEBOUNCE_MS)),this.setupGlobalStateProxy(),setInterval((()=>{this.subscriptionManager.cleanupStaleSubscriptions()}),3e4)}static findExistingStateKey(e,t,n){return[`${t}.${e}`,`app.${e}`,e].find((e=>e in n))||null}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[n,s]of t)s.component===e&&this.subscriptionManager.removeSubscription(n)}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((t=>t.startsWith(`${e}.`))).forEach((e=>{delete this.stateStore[e],delete this.originalStateStore[e],this.previousValues.delete(e)}))}onDOMUpdateComplete(e){this.domUpdateCallbacks.push(e),this.domUpdateScheduled||(this.domUpdateScheduled=!0,requestAnimationFrame((()=>{requestAnimationFrame((()=>{const e=[...this.domUpdateCallbacks];this.domUpdateCallbacks=[],this.domUpdateScheduled=!1,e.forEach((e=>{try{e()}catch(e){console.error("DOM update callback error:",e)}}))}))})))}setInitialState(e,t){if(this.previousValues.set(e,void 0),this.originalStateStore[e]=t,this.previousValues.size>100){const e=this.previousValues.keys().next().value;"string"==typeof e&&this.previousValues.delete(e)}}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,n,s)=>{const i=e[t],r=Reflect.set(e,t,n,s);return i!==n&&this.notifySubscribers(t),r},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){var t;const n=this.stateStore[e],s=null==(t=this.previousValues)?void 0:t.get(e),i=this.subscriptionManager.getAllSubscriptions();for(const[t,r]of i)for(const t of r.dependencies)if(this.isPathDependency(t)&&t.startsWith(e+".")){const i=t.substring(e.length+1),r=this.getPathValue(s,i),a=this.getPathValue(n,i);this.deepEqual(r,a)||this.updateQueue.add(t)}}isPathDependency(e){return e.includes(".")&&e.split(".").length>1}getPathValue(e,t){if(!e||"object"!=typeof e)return;const n=t.split(".");let s=e;for(const e of n){if(null==s)return;if(Array.isArray(s))return"length"===e?s.length:s.map((t=>null==t?void 0:t[e])).filter((e=>void 0!==e));s=s[e]}return s}deepEqual(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((e,n)=>this.deepEqual(e,t[n])));if("object"==typeof e&&"object"==typeof t){const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every((n=>this.deepEqual(e[n],t[n])))}return!1}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 e of t){const t=this.subscriptionManager.getSubscription(e);if(!t)continue;if(t.element&&!document.contains(t.element)){this.subscriptionManager.removeSubscription(e);continue}const n=t.element??document.body;try{const e=Array.from(this.updateQueue)[0];t.callback(n,{key:e})}catch(e){console.error("Wildcard subscription callback failed:",e)}}for(const t of this.updateQueue){if(e.has(t))continue;e.add(t);const n=this.subscriptionManager.getSubscriptionsForKey(t);if(n)for(const e of n){const n=this.subscriptionManager.getSubscription(e);if(!n)continue;const s=n.element??document.body;try{n.callback(s,{key:t})}catch(e){console.error("Subscription callback failed:",e)}}}}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 e=this.previousValues.keys().next().value;"string"==typeof e&&this.previousValues.delete(e)}}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[n,s]of t)for(const t of s.dependencies)e.has(t)||e.set(t,new Set),e.get(t).add(n);return e}destroy(){this.clearState(),this.clearSubscriptions(),this.contextCache.clear(),this.previousValues.clear(),this.domUpdateCallbacks=[]}}const ge=class e{constructor(){d(this,"expressionCache",new G(g.MAX_CACHE_SIZE)),d(this,"dependencyCache",new G(g.MAX_CACHE_SIZE)),d(this,"commonExpressionsCache",new G(100)),d(this,"dependencyParser",new on),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 n={fn:new Function("return "+t),contextMap:new Map,dependencies:[t],timestamp:Date.now(),hitCount:0},s=e.CACHE_KEYS.COMMON(t);this.commonExpressionsCache.set(s,n)}))}extractDependencies(t,n,s){const i=this.normalizeExpression(t),r=e.CACHE_KEYS.DEPENDENCY(n,i);let a=this.dependencyCache.get(r);return a||(a=this.dependencyParser.extract(i,n,s),this.dependencyCache.set(r,a),a)}evaluateExpression(t,n,s){const i=this.normalizeExpression(t),r=e.CACHE_KEYS.COMMON(i);let a=this.commonExpressionsCache.get(r);if(a){a.hitCount++;try{return a.fn()}catch(e){return void console.error(`Common expression evaluation failed: "${i}"`,e)}}const o=e.CACHE_KEYS.EXPRESSION(s,i);a=this.expressionCache.get(o);const c=this.transformContextForEvaluation(n,i);(!a||this.isStale(a))&&(a=this.compileExpression(i,c,s),this.expressionCache.set(o,a)),a.hitCount++;try{const e=this.buildArguments(a.contextMap,c);return a.fn(...e)}catch(e){return console.error(`Expression evaluation failed: "${i}"`,e),void console.error("Available context:",Object.keys(c))}}transformContextForEvaluation(e,t){const n=!!t&&sn(t),s={};for(const[t,i]of Object.entries(e))Oe(i)?s[t]=as(i,{forComparison:n}):s[t]=i;return s}compileExpression(e,t,n){const s=this.prepareSafeContext(t),i=new Map,r=[];Object.keys(s).forEach(((e,t)=>{i.set(e,t),r.push(e)}));const a=this.dependencyParser.extract(e,n);return{fn:new Function(...r,`return (${e})`),contextMap:i,dependencies:a,timestamp:Date.now(),hitCount:0}}buildArguments(e,t){const n=new Array(e.size);for(const[s,i]of e)n[i]=t[s];return n}isStale(e){return Date.now()-e.timestamp>3e5}prepareSafeContext(e){const t={};for(const[n,s]of Object.entries(e))Se.has(n)||!this.isValidJavaScriptIdentifier(n)||(t[n]=s);return t}isValidJavaScriptIdentifier(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!Se.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((t=>{const n=this.expressionCache.get(t);n&&this.isStale(n)&&(this.expressionCache.delete(t),e++)})),e}};d(ge,"CACHE_KEYS",{EXPRESSION:(e,t)=>`expr:${e}:${t}`,DEPENDENCY:(e,t)=>`deps:${e}:${t}`,COMMON:e=>`common:${e}`});let rt=ge;class on{constructor(){d(this,"parseCache",new G(500))}extract(e,t,n){const s=this.normalizeExpression(e),i=`${t}:${s}`;if(this.parseCache.has(i))return this.parseCache.get(i);const r=this.parseExpression(s,t,n);return this.parseCache.set(i,r),r}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}parseExpression(e,t,n){const s=this.extractIdentifiers(e),i=[],r=(null==n?void 0:n.getState())||{};for(const e of s){if(Se.has(e))continue;const n=e.indexOf("."),s=-1===n?e:e.substring(0,n),a=Fe.findExistingStateKey(s,t,r);if(a)i.push(a);else{const e="app"===t?[`app.${s}`]:[`${t}.${s}`,`app.${s}`];i.push(...e)}if(-1!==n){const e="app"===t?[`app.${s}`]:[`${t}.${s}`,`app.${s}`];i.push(...e)}}return Array.from(new Set(i))}extractIdentifiers(e){const t=[];let n=0;for(;n<e.length;){const s=e[n];if("'"!==s)if('"'!==s)if("`"!==s)if(this.isIdentifierStart(s)){const s=this.extractIdentifier(e,n);t.push(s.value),n=s.endIndex}else n++;else n=this.skipTemplateLiteral(e,n,t);else n=this.skipString(e,n,'"');else n=this.skipString(e,n,"'")}return t}skipString(e,t,n){let s=t+1;for(;s<e.length&&e[s]!==n;)"\\"===e[s]&&s++,s++;return s+1}skipTemplateLiteral(e,t,n){let s=t+1;for(;s<e.length&&"`"!==e[s];)if("$"===e[s]&&s+1<e.length&&"{"===e[s+1]){s+=2;let t=1;for(;s<e.length&&t>0;){const i=e[s];if('"'!==i&&"'"!==i){if("{"===i?t++:"}"===i&&t--,t>0&&this.isIdentifierStart(i)){const t=this.extractIdentifier(e,s);n.push(t.value),s=t.endIndex-1}s++}else s=this.skipString(e,s,i)}}else"\\"===e[s]&&s++,s++;return s+1}extractIdentifier(e,t){let n=t;for(;n<e.length&&(this.isIdentifierPart(e[n])||"."===e[n]);)n++;return{value:e.substring(t,n),endIndex:n}}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 cs{constructor(){d(this,"hydrationStarted",!1),d(this,"hydrationDone",!1),d(this,"initialized",!1),d(this,"stateManager",new Fe),d(this,"expressionEvaluator",new rt),d(this,"componentManager",new en(this.stateManager)),d(this,"domBindingManager",new Js(this.stateManager,this.componentManager,this.expressionEvaluator)),d(this,"hydrationCallbacks",new Set),d(this,"portalManager",new Qs),d(this,"hydrationResolve"),d(this,"hydrationPromise"),d(this,"portalHydrationPromises",new Set),d(this,"portalHydrationResolvers",new Map),d(this,"pendingLoopRenders",0),d(this,"currentLoopContext",null),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>this.initialize())):setTimeout((()=>this.initialize()),0),this.hydrationPromise=new Promise((e=>this.hydrationResolve=e))}async initialize(){this.initialized||(this.initialized=!0,this.markHydrationStart(),this.componentManager.setExpressionEvaluator(this.expressionEvaluator),this.portalManager.setDependencies(this.componentManager,this.domBindingManager,this.stateManager,this),k.preCacheAllScopes(),this.componentManager.executePhpScripts(document.body),this.domBindingManager.processElement(document.body,!0),this.domBindingManager.processPendingBindings(),await this.waitForLoopRenders(),await this.waitForDOMUpdates(),this.markHydrated(),this.scheduleCommentCleanup())}async waitForLoopRenders(){const e=Date.now();for(;this.pendingLoopRenders>0;){const t=Date.now()-e;if(t>5e3){console.warn(`⚠️ [PPHP] Loop render timeout - ${this.pendingLoopRenders} loops may not have completed after ${t}ms`);break}t%500==0&&console.log(` Still waiting: ${this.pendingLoopRenders} loops pending (${t}ms elapsed)`),await new Promise((e=>setTimeout(e,10)))}0===this.pendingLoopRenders&&(console.log("✅ [PPHP] All loops rendered, waiting 50ms for stability..."),await new Promise((e=>setTimeout(e,50))))}waitForDOMUpdates(){return new Promise((e=>{Promise.resolve().then((()=>{requestAnimationFrame((()=>{requestAnimationFrame((()=>{e()}))}))}))}))}scheduleCommentCleanup(){const e=()=>{try{k.removeScopeComments(),console.debug("✅ Scope comments cleaned up")}catch(e){console.error("Failed to remove scope comments:",e)}};"requestIdleCallback"in window?requestIdleCallback(e,{timeout:5e3}):setTimeout(e,100)}createPortal(e,t,n){const s=this.portalManager.createPortal(e,t,n),i=new Promise((e=>{this.portalHydrationResolvers.set(s,e)}));return this.portalHydrationPromises.add(i),i.finally((()=>{this.portalHydrationPromises.delete(i),this.portalHydrationResolvers.delete(s)})),s}removePortal(e){return this.markPortalHydrated(e),this.portalManager.removePortal(e)}markPortalHydrated(e){const t=this.portalHydrationResolvers.get(e);t&&t()}updatePortal(e,t,n){return this.portalManager.updatePortal(e,t,n)}cleanup(){this.portalManager.destroy(),this.domBindingManager.destroy(),this.componentManager.destroy(),this.stateManager.clearState(),this.stateManager.clearSubscriptions(),this.expressionEvaluator.clearAllCaches(),this.hydrationCallbacks.clear(),this.deleteAllComponentObjects(),k.clearCache()}ref(e=null){return{current:e}}async hydrated(){await Promise.all([this.hydrationPromise,...Array.from(this.portalHydrationPromises)])}onHydrated(e){this.hydrationDone?queueMicrotask(e):this.hydrationCallbacks.add(e)}markHydrationStart(){this.hydrationStarted=!0,this.hydrationDone=!1,document.dispatchEvent(new CustomEvent("pp:hydrationstart"))}get isHydrated(){return this.hydrationDone}get isHydrating(){return this.hydrationStarted&&!this.hydrationDone}markHydrated(){if(!this.hydrationDone){this.hydrationStarted=!1,this.hydrationDone=!0,this.hydrationResolve();for(const e of this.hydrationCallbacks)try{e()}catch(e){console.error("❌ [PPHP] Hydration callback error:",e)}this.hydrationCallbacks.clear(),document.dispatchEvent(new CustomEvent("pp:hydrated",{detail:{at:performance.now()}}))}}state(e,t){const n=this.componentManager.getCurrentComponent();let s,i,r;"string"==typeof e&&2===arguments.length?(s=e,i=t):"string"==typeof e&&1===arguments.length?this.looksLikeVariableName(e)?(s=e,i=void 0):(console.warn("pp.state() called with string that doesn't look like variable name:",e),s="unknownState",i=e):(console.warn("pp.state() called without explicit key - this should be handled by AST transformation"),s="unknownState",i=e),Oe(i)&&(i=We(i));const a=this.getLoopExecutionContext();if(a){const e=this.generateLoopInstanceId(a);r=`${n}.${e}.${s}`}else r=`${n}.${s}`;this.stateManager.hasState(r)||this.stateManager.setInitialState(r,i);const o=()=>this.stateManager.getState()[r],c=new Proxy(o,{get(e,t,n){if("__pphp_key"===t||"__pphp_fullKey"===t||"__pphp_component"===t||"value"===t||"valueOf"===t||"toString"===t)return Reflect.get(e,t,n);const s=e();if(null!=s){if(t in Object(s)){const e=s[t];return"function"==typeof e?e.bind(s):e}return Reflect.get(e,t,n)}},has(e,t){if("__pphp_key"===t||"__pphp_fullKey"===t||"__pphp_component"===t||"value"===t||"valueOf"===t||"toString"===t)return Reflect.has(e,t);const n=e();return null!=n&&t in Object(n)||Reflect.has(e,t)},apply:(e,t,n)=>Reflect.apply(e,t,n)});Object.defineProperty(c,"__pphp_key",{value:s,enumerable:!1,writable:!1}),Object.defineProperty(c,"__pphp_fullKey",{value:r,enumerable:!1,writable:!1}),Object.defineProperty(c,"__pphp_component",{value:n,enumerable:!1,writable:!1}),Object.defineProperty(c,"value",{get:()=>this.stateManager.getState()[r],enumerable:!0,configurable:!0}),o.valueOf=()=>this.stateManager.getState()[r],o.toString=()=>Ce(this.stateManager.getState()[r]);const h=e=>{const t=this.stateManager.getState()[r],n="function"==typeof e?e(t):e;this.stateManager.setState(r,n)};return this.createComponentScopedGlobals(n,s,c,h),[c,h]}getLoopExecutionContext(){return this.currentLoopContext}generateLoopInstanceId(e){const t=Object.keys(e).sort().map((t=>{const n=e[t];return n&&"object"==typeof n&&"id"in n?`${t}:${n.id}`:`${t}:${JSON.stringify(n)}`}));return`loop_${btoa(t.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(" ")&&!Se.has(e)}effect(e,t){const n=`effect_${Date.now()}_${Math.random()}`,s=this.componentManager.getCurrentComponent();let i,r,a,o=!1;if(1===arguments.length)r="always",a={immediate:!0,detectDeps:!0};else if(Array.isArray(t)){const e=this.extractDependencyNames(t,s);0===e.length?(r="once",a={deps:e,immediate:!0}):(r="deps",a={deps:e,immediate:!0})}else{const e={immediate:!0,...t||{}};if(e.deps&&0!==e.deps.length){r="deps",a={deps:this.extractDependencyNames(e.deps,s),immediate:e.immediate,detectDeps:e.detectDeps}}else r="always",a={immediate:e.immediate,detectDeps:!0}}const c=()=>{o||this.stateManager.onDOMUpdateComplete((()=>{if(!o){if(i&&"function"==typeof i)try{i()}catch(e){console.error("Effect cleanup error:",e)}try{i=e()}catch(e){console.error("Effect callback error:",e)}}}))};switch(r){case"always":const e={id:n,selector:"",dependencies:new Set(["*"]),callback:c,component:s};this.stateManager.addSubscription(e);break;case"once":break;case"deps":const t=this.resolveDependencies(a.deps,s);if(t.length){const e={id:n,selector:"",dependencies:new Set(t),callback:c,component:s};this.stateManager.addSubscription(e)}}return!1!==a.immediate&&c(),()=>{if(o=!0,i&&"function"==typeof i)try{i()}catch(e){console.error("Effect cleanup error:",e)}this.stateManager.removeSubscription(n)}}extractDependencyNames(e,t){const n=[];for(const t of e)"string"==typeof t?n.push(t):"function"==typeof t&&t.__pphp_key?n.push(t.__pphp_key):console.warn("Invalid dependency in effect:",t);return n.filter(Boolean)}resolveDependencies(e,t){const n=[],s=this.stateManager.getState();for(const i of e)if(i.includes(".")){const e=i.split("."),r=e[0],a=e.slice(1).join("."),o=this.componentManager.getPropDependencies(r,t);if(o.length>0)n.push(...o);else{const e=Fe.findExistingStateKey(r,t,s);e?n.push(`${e}.${a}`):n.push(`${t}.${i}`)}}else{const e=this.componentManager.getPropDependencies(i,t);if(e.length>0)n.push(...e);else{const e=Fe.findExistingStateKey(i,t,s);e?n.push(e):n.push(`${t}.${i}`)}}return Array.from(new Set(n))}createComponentScopedGlobals(e,t,n,s){window[e]||(window[e]={});const i=`set${rs(t)}`;window[e][t]=n,window[e][i]=s,window[e][`${t}Getter`]=n}deleteAllComponentObjects(){const e=Object.keys(window),t=new Set(["window","self","document","location","customElements","history","navigation","locationbar","menubar","personalbar","scrollbars","statusbar","toolbar","frames","top","parent","navigator","external","screen","visualViewport","crypto","performance","localStorage","sessionStorage","indexedDB","fetch","XMLHttpRequest","WebSocket","Worker","SharedWorker","MessageChannel","MessagePort","Notification","Push","BroadcastChannel","Cache","CacheStorage","requestAnimationFrame","cancelAnimationFrame","requestIdleCallback","cancelIdleCallback","setInterval","clearInterval","setTimeout","clearTimeout","queueMicrotask","atob","btoa","alert","confirm","prompt","open","close","focus","blur","print","stop","getComputedStyle","getSelection","matchMedia","scroll","scrollBy","scrollTo","resizeBy","resizeTo","moveBy","moveTo"]);for(const n of e){if(t.has(n))continue;const e=window[n];(/^s[a-z0-9]+$/i.test(n)||"app"===n)&&e&&"object"==typeof e&&delete window[n]}}static resetInstance(){this.instance&&(this.instance.destroy(),this.instance=null)}destroy(){this.cleanup(),this.initialized=!1,this.hydrationDone=!1}}d(cs,"instance",null);const Ue=class e extends cs{constructor(){super(),d(this,"cryptoKey",null),d(this,"activeAbortController",null),d(this,"navigationEnabled",!1),d(this,"boundHandleLinkClick",null),d(this,"boundHandlePopState",null),d(this,"isNavigating",!1),this.hydrated().then((()=>{document.body.hidden=!1,this.enableSPANavigation()})).catch((e=>{console.error("PPHPUtilities hydration error:",e),document.body.hidden=!1}))}static resetInstance(){this.instance&&(this.instance.navigationEnabled&&this.instance.disableSPANavigation(),this.instance.activeAbortController&&(this.instance.activeAbortController.abort(),this.instance.activeAbortController=null),this.instance.destroy(),this.instance=null)}static getInstance(){return this.instance||(this.instance=new e),this.instance}enableSPANavigation(){this.navigationEnabled||"true"!==document.body.getAttribute("pp-spa")||(this.navigationEnabled=!0,this.boundHandleLinkClick=this.handleLinkClick.bind(this),this.boundHandlePopState=this.handlePopState.bind(this),document.addEventListener("click",this.boundHandleLinkClick),window.addEventListener("popstate",this.boundHandlePopState))}disableSPANavigation(){this.navigationEnabled=!1,this.boundHandleLinkClick&&(document.removeEventListener("click",this.boundHandleLinkClick),this.boundHandleLinkClick=null),this.boundHandlePopState&&(window.removeEventListener("popstate",this.boundHandlePopState),this.boundHandlePopState=null)}handleLinkClick(e){if(!this.navigationEnabled)return;const t=e.target.closest("a");if(t&&t.href)try{const n=new URL(t.href),s=n.origin!==window.location.origin,i=n.pathname===window.location.pathname&&n.search===window.location.search,r="false"===t.getAttribute("pp-spa");if(s||"_blank"===t.target||t.hasAttribute("download")||r||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;if(e.preventDefault(),i){const e=n.hash;if(e){const t=document.querySelector(e);t&&t.scrollIntoView({behavior:"smooth"})}else window.scrollTo({top:0,behavior:"smooth"});return}this.navigateTo(n.pathname+n.search+n.hash)}catch(e){console.error("Link click navigation error:",e)}}async handlePopState(){const e=window.location.pathname+window.location.search+window.location.hash;await this.navigateTo(e,!1)}async navigateTo(e,t=!0){this.isNavigating=!0;try{this.dispatchNavigationEvent("start",e),await this.showLoadingTransition();const n=await this.fetchPageContent(e);this.updateBrowserHistory(e,t);const s=document.getElementById("loading-file-1B87E"),i="startViewTransition"in document;this.performCleanup(),!s&&i?await this.updatePageContentWithViewTransition(n):this.updatePageContent(n),this.initialized=!1,await this.initialize(),await this.hydrated(),await this.handleNavigationCompletion(e),this.dispatchNavigationEvent("complete",e)}catch(t){this.handleNavigationError(e,t)}finally{this.isNavigating=!1}}async updatePageContentWithViewTransition(e){if(this.isNavigating)return void this.updatePageContent(e);const t=document.startViewTransition((()=>{this.updatePageContent(e)}));try{await t.finished}catch(e){console.warn("View transition failed, continuing anyway:",e)}}dispatchNavigationEvent(e,t,n){const s=`pp:navigation:${e}`,i=n?{url:t,error:n}:{url:t};document.dispatchEvent(new CustomEvent(s,{detail:i}))}async showLoadingTransition(){const e=document.getElementById("loading-file-1B87E");if(e){const t=this.findLoadingElement(e,window.location.pathname);if(t)return void await this.updateContentWithTransition(t)}const t=document.querySelector("[pp-loading-content='true']")||document.body;t&&!("startViewTransition"in document)&&await this.fadeOut(t,250)}async fetchPageContent(e){var t;const n=await fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest","X-PP-Navigation":"true",Accept:"text/html"}});if(!n.ok)throw new Error(`Navigation failed: ${n.status} ${n.statusText}`);let s=await n.text();const i=document.createElement("iframe");i.style.display="none",document.body.appendChild(i);const r=i.contentDocument||(null==(t=i.contentWindow)?void 0:t.document);if(!r)throw document.body.removeChild(i),new Error("Failed to create iframe document");r.documentElement.innerHTML=s;const a=document.implementation.createHTMLDocument();return a.head.innerHTML=r.head.innerHTML,a.body.innerHTML=r.body.innerHTML,Array.from(r.body.attributes).forEach((e=>{a.body.setAttribute(e.name,e.value)})),a.title=r.title,document.body.removeChild(i),a}performCleanup(){this.cleanup()}updateBrowserHistory(e,t){t&&history.pushState(null,"",e)}updatePageContent(e){e.title&&(document.title=e.title),this.reconcileHead(e);const t=e.body;document.body.innerHTML=t.innerHTML}async handleNavigationCompletion(e){const t=new URL(e,window.location.origin).hash;if(t){const e=document.querySelector(t);e&&e.scrollIntoView({behavior:"smooth"})}else window.scrollTo({top:0,behavior:"instant"});const n=document.querySelector("[pp-loading-content='true']")||document.body;n?requestAnimationFrame((()=>{document.body.hidden=!1,this.fadeIn(n,150)})):document.body.hidden=!1}handleNavigationError(e,t){console.error("Navigation error:",t),document.body.hidden=!1,this.dispatchNavigationEvent("error",e,t),window.location.href=e}findLoadingElement(e,t){let n=t;for(;;){const t=e.querySelector(`div[pp-loading-url='${n}']`);if(t)return t;if("/"===n)break;const s=n.lastIndexOf("/");n=s<=0?"/":n.substring(0,s)}return e.querySelector("div[pp-loading-url='/' ]")}async updateContentWithTransition(e){const t=document.querySelector("[pp-loading-content='true']")||document.body;if(!t)return;const{fadeIn:n,fadeOut:s}=this.parseTransition(e);await this.fadeOut(t,s),t.innerHTML=e.innerHTML,this.fadeIn(t,n)}parseTransition(e){let t=250,n=250;const s=e.querySelector("[pp-loading-transition]"),i=null==s?void 0:s.getAttribute("pp-loading-transition");if(i){let e=JSON.parse(i);e&&"object"==typeof e?(t=this.parseTime(e.fadeIn??t),n=this.parseTime(e.fadeOut??n)):console.warn("pp-loading-transition is not valid JSON → default values (250 ms) will be used. String:",i)}return{fadeIn:t,fadeOut:n}}fadeOut(e,t){return new Promise((n=>{e.style.transition=`opacity ${t}ms ease-out`,setTimeout((()=>{e.style.transition="",n()}),t)}))}fadeIn(e,t){e.style.transition=`opacity ${t}ms ease-in`,setTimeout((()=>{e.style.transition=""}),t)}parseTime(e){if("number"==typeof e)return e;const t=e.match(/^(\d+)(ms|s|m)?$/);if(t){const e=parseInt(t[1],10);switch(t[2]||"ms"){case"ms":default:return e;case"s":return 1e3*e;case"m":return 60*e*1e3}}return 0}reconcileHead(e){const t="pp-dynamic-script",n="pp-dynamic-link";document.head.querySelectorAll("[pp-dynamic-meta]").forEach((e=>e.remove())),document.head.querySelectorAll(`[${n}]`).forEach((e=>e.remove())),document.head.querySelectorAll(`[${t}]`).forEach((e=>e.remove())),Array.from(e.head.children).forEach((e=>{var s;switch(e.tagName){case"SCRIPT":if(e.hasAttribute(t)){const t=document.createElement("script");Array.from(e.attributes).forEach((e=>t.setAttribute(e.name,e.value))),t.textContent=e.textContent,document.head.appendChild(t)}break;case"META":{const t=e;if(t.getAttribute("charset")||"viewport"===t.name)break;const n=t.name?`meta[name="${t.name}"]`:`meta[property="${t.getAttribute("property")}"]`,i=t.cloneNode(!0),r=document.head.querySelector(n);r?document.head.replaceChild(i,r):document.head.insertBefore(i,(null==(s=document.head.querySelector("title"))?void 0:s.nextSibling)||null);break}case"TITLE":{const t=e.cloneNode(!0),n=document.head.querySelector("title");n?document.head.replaceChild(t,n):document.head.appendChild(t);break}case"LINK":{const t=e;if("icon"===t.rel){const e=t.cloneNode(!0),n=document.head.querySelector('link[rel="icon"]');n?document.head.replaceChild(e,n):document.head.appendChild(e)}else t.hasAttribute(n)&&document.head.appendChild(t.cloneNode(!0));break}}}))}async redirect(e){if(e)try{const t=new URL(e,window.location.origin);t.origin!==window.location.origin?window.location.href=e:this.navigationEnabled?await this.navigateTo(t.pathname+t.search+t.hash):window.location.href=e}catch(e){console.error("Redirect error:",e)}}async initCryptoKey(){var e;const t=null==(e=document.cookie.split("; ").find((e=>e.startsWith("pp_function_call_jwt="))))?void 0:e.split("=",2)[1];if(!t)throw new Error("Missing function-call token");const[,n]=t.split("."),s=atob(n.replace(/-/g,"+").replace(/_/g,"/")),{k:i,exp:r}=JSON.parse(s);if(Date.now()/1e3>r)throw new Error("Function-call token expired");const a=Uint8Array.from(atob(i),(e=>e.charCodeAt(0)));this.cryptoKey=await crypto.subtle.importKey("raw",a,{name:"AES-CBC"},!1,["encrypt","decrypt"])}async encryptCallbackName(e){await this.initCryptoKey();const t=crypto.getRandomValues(new Uint8Array(16)),n=(new TextEncoder).encode(e),s=await crypto.subtle.encrypt({name:"AES-CBC",iv:t},this.cryptoKey,n);return`${btoa(String.fromCharCode(...t))}:${btoa(String.fromCharCode(...new Uint8Array(s)))}`}createFetchOptions(e){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PP_WIRE_REQUEST:"true"},body:JSON.stringify(e)}}async fetchFunction(e,t={},n=!1){let s=null;try{n&&this.activeAbortController&&(this.activeAbortController.abort(),this.activeAbortController=null),s=new AbortController,n&&(this.activeAbortController=s);const i={callback:await this.encryptCallbackName(e),...t},r=window.location.href;let a;if(Object.keys(i).some((e=>{const t=i[e];return t instanceof File||t instanceof FileList&&t.length>0}))){const e=new FormData;Object.keys(i).forEach((t=>{const n=i[t];n instanceof File?e.append(t,n):n instanceof FileList?Array.from(n).forEach((n=>e.append(t,n))):e.append(t,n)})),a={method:"POST",headers:{HTTP_PP_WIRE_REQUEST:"true"},body:e,signal:s.signal}}else a={signal:s.signal,...this.createFetchOptions(i)};const o=await fetch(r,a);if(!o.ok)throw new Error(`Fetch failed with status: ${o.status} ${o.statusText}`);const c=await o.text();s&&this.activeAbortController===s&&(this.activeAbortController=null);try{return JSON.parse(c)}catch{return c}}catch(e){if(s&&this.activeAbortController===s&&(this.activeAbortController=null),e instanceof Error&&"AbortError"===e.name)return console.log("Request was cancelled"),{cancelled:!0};throw console.error("Error in fetchFunction:",e),new Error("Failed to fetch data.")}}};d(Ue,"instance",null);let He=Ue;const xe=class e{constructor(e={}){d(this,"state"),d(this,"listeners"),d(this,"pp"),d(this,"STORAGE_KEY"),d(this,"lastSyncedState",null),this.state=e,this.listeners=[],this.pp=He.getInstance(),this.STORAGE_KEY=this.getCookie("pp_local_store_key")||"pp_local_store_59e13",this.lastSyncedState=localStorage.getItem(this.STORAGE_KEY),this.loadState()}static getInstance(t={}){return e.instance||(e.instance=new e(t)),e.instance}getCookie(e){var t;return(null==(t=document.cookie.split("; ").find((t=>t.startsWith(e+"="))))?void 0:t.split("=")[1])||null}setState(e,t=!1){const n={...this.state,...e};if(JSON.stringify(n)!==JSON.stringify(this.state)&&(this.state=n,this.listeners.forEach((e=>e(this.state))),this.saveState(),t)){const e=localStorage.getItem(this.STORAGE_KEY);e&&e!==this.lastSyncedState&&(this.pp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:e}),this.lastSyncedState=e)}}saveState(){localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.state))}loadState(){const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.state=JSON.parse(e),this.listeners.forEach((e=>e(this.state))))}resetState(e,t=!1){if(e?(delete this.state[e],this.saveState()):(this.state={},localStorage.removeItem(this.STORAGE_KEY)),this.listeners.forEach((e=>e(this.state))),t){const t=e?localStorage.getItem(this.STORAGE_KEY):null;this.pp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:t}),this.lastSyncedState=t}}};d(xe,"instance",null);let at=xe;const Ee=class e{constructor(){d(this,"listeners",[])}static getInstance(){return e.instance||(e.instance=new e),e.instance}get params(){return new URLSearchParams(window.location.search)}get(e){return this.params.get(e)}set(e,t){const n=this.params;n.set(e,t),this.updateURL(n)}delete(e){const t=this.params;t.delete(e),this.updateURL(t)}replace(e){const t=new URLSearchParams;for(const n in e){const s=e[n];null!==s&&t.set(n,s)}this.updateURL(t,!0)}updateURL(e,t=!1){const n=`${window.location.pathname}?${e.toString()}`;t?history.replaceState(null,"",n):history.pushState(null,"",n),this.notifyListeners(e)}listen(e){this.listeners.push(e)}notifyListeners(e){for(const t of this.listeners)t(e)}enablePopStateListener(){window.addEventListener("popstate",(()=>{this.notifyListeners(this.params)}))}};d(Ee,"instance",null);let ot=Ee;function gt(e,t,n=window,s=!0){let i=null;if(Object.defineProperty(n,e,{get(){if(null!==i)return i;if(t&&"object"==typeof t&&!Array.isArray(t)&&"getInstance"in t&&"function"==typeof t.getInstance)return i=t.getInstance(),i;if("function"!=typeof t)return i=t,i;try{return i=t.getInstance(),i}catch{return i=t,i}},set(t){null===t?i=null:console.warn(`Cannot override global ${e}`)},configurable:!0,enumerable:!0}),s)try{n[e]}catch(t){console.error(`Failed to initialize ${e}:`,t)}}gt("pp",He),gt("store",at),gt("searchParams",ot);export{at as PPHPLocalStore,He as PPHPUtilities,ot as SearchParamsManager};
|
|
1
|
+
var ls=Object.defineProperty,us=(e,t,n)=>t in e?ls(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t,n)=>us(e,"symbol"!=typeof t?t+"":t,n),ps=[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],Tt=[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],hs="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",wt="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Ye={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"},Je="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",fs={5:Je,"5module":Je+" export import",6:Je+" const class extends export import super"},ds=/^in(stanceof)?$/,ms=new RegExp("["+wt+"]"),gs=new RegExp("["+wt+hs+"]");function et(e,t){for(var n=65536,s=0;s<t.length;s+=2){if((n+=t[s])>e)return!1;if((n+=t[s+1])>=e)return!0}return!1}function te(e,t){return e<65?36===e:e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&ms.test(String.fromCharCode(e)):!1!==t&&et(e,Tt)))}function pe(e,t){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&gs.test(String.fromCharCode(e)):!1!==t&&(et(e,Tt)||et(e,ps)))))}var N=function(e,t){void 0===t&&(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 z(e,t){return new N(e,{beforeExpr:!0,binop:t})}var X={beforeExpr:!0},j={startsExpr:!0},ct={};function _(e,t){return void 0===t&&(t={}),t.keyword=e,ct[e]=new N(e,t)}var h={num:new N("num",j),regexp:new N("regexp",j),string:new N("string",j),name:new N("name",j),privateId:new N("privateId",j),eof:new N("eof"),bracketL:new N("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new N("]"),braceL:new N("{",{beforeExpr:!0,startsExpr:!0}),braceR:new N("}"),parenL:new N("(",{beforeExpr:!0,startsExpr:!0}),parenR:new N(")"),comma:new N(",",X),semi:new N(";",X),colon:new N(":",X),dot:new N("."),question:new N("?",X),questionDot:new N("?."),arrow:new N("=>",X),template:new N("template"),invalidTemplate:new N("invalidTemplate"),ellipsis:new N("...",X),backQuote:new N("`",j),dollarBraceL:new N("${",{beforeExpr:!0,startsExpr:!0}),eq:new N("=",{beforeExpr:!0,isAssign:!0}),assign:new N("_=",{beforeExpr:!0,isAssign:!0}),incDec:new N("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new N("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:z("||",1),logicalAND:z("&&",2),bitwiseOR:z("|",3),bitwiseXOR:z("^",4),bitwiseAND:z("&",5),equality:z("==/!=/===/!==",6),relational:z("</>/<=/>=",7),bitShift:z("<</>>/>>>",8),plusMin:new N("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:z("%",10),star:z("*",10),slash:z("/",10),starstar:new N("**",{beforeExpr:!0}),coalesce:z("??",1),_break:_("break"),_case:_("case",X),_catch:_("catch"),_continue:_("continue"),_debugger:_("debugger"),_default:_("default",X),_do:_("do",{isLoop:!0,beforeExpr:!0}),_else:_("else",X),_finally:_("finally"),_for:_("for",{isLoop:!0}),_function:_("function",j),_if:_("if"),_return:_("return",X),_switch:_("switch"),_throw:_("throw",X),_try:_("try"),_var:_("var"),_const:_("const"),_while:_("while",{isLoop:!0}),_with:_("with"),_new:_("new",{beforeExpr:!0,startsExpr:!0}),_this:_("this",j),_super:_("super",j),_class:_("class",j),_extends:_("extends",X),_export:_("export"),_import:_("import",j),_null:_("null",j),_true:_("true",j),_false:_("false",j),_in:_("in",{beforeExpr:!0,binop:7}),_instanceof:_("instanceof",{beforeExpr:!0,binop:7}),_typeof:_("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:_("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:_("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},H=/\r\n?|\n|\u2028|\u2029/,xs=new RegExp(H.source,"g");function Te(e){return 10===e||13===e||8232===e||8233===e}function Pt(e,t,n){void 0===n&&(n=e.length);for(var s=t;s<n;s++){var i=e.charCodeAt(s);if(Te(i))return s<n-1&&13===i&&10===e.charCodeAt(s+1)?s+2:s+1}return-1}var At=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,B=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,_t=Object.prototype,Es=_t.hasOwnProperty,Cs=_t.toString,we=Object.hasOwn||function(e,t){return Es.call(e,t)},xt=Array.isArray||function(e){return"[object Array]"===Cs.call(e)},Et=Object.create(null);function ue(e){return Et[e]||(Et[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function re(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}var bs=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,ke=function(e,t){this.line=e,this.column=t};ke.prototype.offset=function(e){return new ke(this.line,this.column+e)};var qe=function(e,t,n){this.start=t,this.end=n,null!==e.sourceFile&&(this.source=e.sourceFile)};function Nt(e,t){for(var n=1,s=0;;){var i=Pt(e,s,t);if(i<0)return new ke(n,t-s);++n,s=i}}var tt={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},Ct=!1;function ys(e){var t={};for(var n in tt)t[n]=e&&we(e,n)?e[n]:tt[n];if("latest"===t.ecmaVersion?t.ecmaVersion=1e8:null==t.ecmaVersion?(!Ct&&"object"==typeof console&&console.warn&&(Ct=!0,console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.")),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),null==t.allowReserved&&(t.allowReserved=t.ecmaVersion<5),(!e||null==e.allowHashBang)&&(t.allowHashBang=t.ecmaVersion>=14),xt(t.onToken)){var s=t.onToken;t.onToken=function(e){return s.push(e)}}return xt(t.onComment)&&(t.onComment=vs(t,t.onComment)),t}function vs(e,t){return function(n,s,i,r,a,o){var c={type:n?"Block":"Line",value:s,start:i,end:r};e.locations&&(c.loc=new qe(this,a,o)),e.ranges&&(c.range=[i,r]),t.push(c)}}var Ie=1,Pe=2,lt=4,kt=8,ut=16,It=32,ze=64,Mt=128,be=256,Me=512,Xe=Ie|Pe|be;function pt(e,t){return Pe|(e?lt:0)|(t?kt:0)}var Ve=0,ht=1,oe=2,Rt=3,Ot=4,Lt=5,F=function(e,t,n){this.options=e=ys(e),this.sourceFile=e.sourceFile,this.keywords=ue(fs[e.ecmaVersion>=6?6:"module"===e.sourceType?"5module":5]);var s="";!0!==e.allowReserved&&(s=Ye[e.ecmaVersion>=6?6:5===e.ecmaVersion?5:3],"module"===e.sourceType&&(s+=" await")),this.reservedWords=ue(s);var i=(s?s+" ":"")+Ye.strict;this.reservedWordsStrict=ue(i),this.reservedWordsStrictBind=ue(i+" "+Ye.strictBind),this.input=String(t),this.containsEsc=!1,n?(this.pos=n,this.lineStart=this.input.lastIndexOf("\n",n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(H).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=h.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="module"===e.sourceType,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),0===this.pos&&e.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(Ie),this.regexpState=null,this.privateNameStack=[]},se={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}};F.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)},se.inFunction.get=function(){return(this.currentVarScope().flags&Pe)>0},se.inGenerator.get=function(){return(this.currentVarScope().flags&kt)>0},se.inAsync.get=function(){return(this.currentVarScope().flags<)>0},se.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(be|Me))return!1;if(t&Pe)return(t<)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},se.allowSuper.get=function(){return(this.currentThisScope().flags&ze)>0||this.options.allowSuperOutsideMethod},se.allowDirectSuper.get=function(){return(this.currentThisScope().flags&Mt)>0},se.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},se.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(be|Me)||t&Pe&&!(t&ut))return!0}return!1},se.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&be)>0},F.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,s=0;s<e.length;s++)n=e[s](n);return n},F.parse=function(e,t){return new this(t,e).parse()},F.parseExpressionAt=function(e,t,n){var s=new this(n,e,t);return s.nextToken(),s.parseExpression()},F.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(F.prototype,se);var W=F.prototype,Ss=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;W.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){B.lastIndex=e,e+=B.exec(this.input)[0].length;var t=Ss.exec(this.input.slice(e));if(!t)return!1;if("use strict"===(t[1]||t[2])){B.lastIndex=e+t[0].length;var n=B.exec(this.input),s=n.index+n[0].length,i=this.input.charAt(s);return";"===i||"}"===i||H.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||"!"===i&&"="===this.input.charAt(s+1))}e+=t[0].length,B.lastIndex=e,e+=B.exec(this.input)[0].length,";"===this.input[e]&&e++}},W.eat=function(e){return this.type===e&&(this.next(),!0)},W.isContextual=function(e){return this.type===h.name&&this.value===e&&!this.containsEsc},W.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},W.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},W.canInsertSemicolon=function(){return this.type===h.eof||this.type===h.braceR||H.test(this.input.slice(this.lastTokEnd,this.start))},W.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},W.semicolon=function(){!this.eat(h.semi)&&!this.insertSemicolon()&&this.unexpected()},W.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},W.expect=function(e){this.eat(e)||this.unexpected()},W.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var Ke=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};W.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?"Assigning to rvalue":"Parenthesized pattern")}},W.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,s=e.doubleProto;if(!t)return n>=0||s>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),s>=0&&this.raiseRecoverable(s,"Redefinition of __proto__ property")},W.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")},W.isSimpleAssignTarget=function(e){return"ParenthesizedExpression"===e.type?this.isSimpleAssignTarget(e.expression):"Identifier"===e.type||"MemberExpression"===e.type};var T=F.prototype;T.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==h.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var s=0,i=Object.keys(this.undefinedExports);s<i.length;s+=1){var r=i[s];this.raiseRecoverable(this.undefinedExports[r].start,"Export '"+r+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var ft={kind:"loop"},Ts={kind:"switch"};T.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;B.lastIndex=this.pos;var t=B.exec(this.input),n=this.pos+t[0].length,s=this.input.charCodeAt(n);if(91===s||92===s)return!0;if(e)return!1;if(123===s||s>55295&&s<56320)return!0;if(te(s,!0)){for(var i=n+1;pe(s=this.input.charCodeAt(i),!0);)++i;if(92===s||s>55295&&s<56320)return!0;var r=this.input.slice(n,i);if(!ds.test(r))return!0}return!1},T.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;B.lastIndex=this.pos;var e,t=B.exec(this.input),n=this.pos+t[0].length;return!(H.test(this.input.slice(this.pos,n))||"function"!==this.input.slice(n,n+8)||n+8!==this.input.length&&(pe(e=this.input.charCodeAt(n+8))||e>55295&&e<56320))},T.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;B.lastIndex=this.pos;var n=B.exec(this.input),s=this.pos+n[0].length;if(H.test(this.input.slice(this.pos,s)))return!1;if(e){var i,r=s+5;if("using"!==this.input.slice(s,r)||r===this.input.length||pe(i=this.input.charCodeAt(r))||i>55295&&i<56320)return!1;B.lastIndex=r;var a=B.exec(this.input);if(a&&H.test(this.input.slice(r,r+a[0].length)))return!1}if(t){var o,c=s+2;if(!("of"!==this.input.slice(s,c)||c!==this.input.length&&(pe(o=this.input.charCodeAt(c))||o>55295&&o<56320)))return!1}var h=this.input.charCodeAt(s);return te(h,!0)||92===h},T.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},T.isUsing=function(e){return this.isUsingKeyword(!1,e)},T.parseStatement=function(e,t,n){var s,i=this.type,r=this.startNode();switch(this.isLet(e)&&(i=h._var,s="let"),i){case h._break:case h._continue:return this.parseBreakContinueStatement(r,i.keyword);case h._debugger:return this.parseDebuggerStatement(r);case h._do:return this.parseDoStatement(r);case h._for:return this.parseForStatement(r);case h._function:return e&&(this.strict||"if"!==e&&"label"!==e)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(r,!1,!e);case h._class:return e&&this.unexpected(),this.parseClass(r,!0);case h._if:return this.parseIfStatement(r);case h._return:return this.parseReturnStatement(r);case h._switch:return this.parseSwitchStatement(r);case h._throw:return this.parseThrowStatement(r);case h._try:return this.parseTryStatement(r);case h._const:case h._var:return s=s||this.value,e&&"var"!==s&&this.unexpected(),this.parseVarStatement(r,s);case h._while:return this.parseWhileStatement(r);case h._with:return this.parseWithStatement(r);case h.braceL:return this.parseBlock(!0,r);case h.semi:return this.parseEmptyStatement(r);case h._export:case h._import:if(this.options.ecmaVersion>10&&i===h._import){B.lastIndex=this.pos;var a=B.exec(this.input),o=this.pos+a[0].length,c=this.input.charCodeAt(o);if(40===c||46===c)return this.parseExpressionStatement(r,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),i===h._import?this.parseImport(r):this.parseExport(r,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(r,!0,!e);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return t&&"script"===this.options.sourceType&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),"await using"===l&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(r,!1,l),this.semicolon(),this.finishNode(r,"VariableDeclaration");var p=this.value,u=this.parseExpression();return i===h.name&&"Identifier"===u.type&&this.eat(h.colon)?this.parseLabeledStatement(r,p,u,e):this.parseExpressionStatement(r,u)}},T.parseBreakContinueStatement=function(e,t){var n="break"===t;this.next(),this.eat(h.semi)||this.insertSemicolon()?e.label=null:this.type!==h.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var s=0;s<this.labels.length;++s){var i=this.labels[s];if((null==e.label||i.name===e.label.name)&&(null!=i.kind&&(n||"loop"===i.kind)||e.label&&n))break}return s===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,n?"BreakStatement":"ContinueStatement")},T.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")},T.parseDoStatement=function(e){return this.next(),this.labels.push(ft),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(h._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(h.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},T.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(ft),this.enterScope(0),this.expect(h.parenL),this.type===h.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===h._var||this.type===h._const||n){var s=this.startNode(),i=n?"let":this.value;return this.next(),this.parseVar(s,!0,i),this.finishNode(s,"VariableDeclaration"),this.parseForAfterInit(e,s,t)}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(),"await using"===o&&this.next(),this.parseVar(c,!0,o),this.finishNode(c,"VariableDeclaration"),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,p=new Ke,u=this.start,d=t>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===h._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===h._in&&this.unexpected(t),e.await=!0):a&&this.options.ecmaVersion>=8&&(d.start!==u||l||"Identifier"!==d.type||"async"!==d.name?this.options.ecmaVersion>=9&&(e.await=!1):this.unexpected()),r&&a&&this.raise(d.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(d,!1,p),this.checkLValPattern(d),this.parseForIn(e,d)):(this.checkExpressionErrors(p,!0),t>-1&&this.unexpected(t),this.parseFor(e,d))},T.parseForAfterInit=function(e,t,n){return(this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&1===t.declarations.length?(this.options.ecmaVersion>=9&&(this.type===h._in?n>-1&&this.unexpected(n):e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},T.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,_e|(n?0:st),!1,t)},T.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(h._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")},T.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(h.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},T.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(h.braceL),this.labels.push(Ts),this.enterScope(0);for(var t,n=!1;this.type!==h.braceR;)if(this.type===h._case||this.type===h._default){var s=this.type===h._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),s?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,t.test=null),this.expect(h.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")},T.parseThrowStatement=function(e){return this.next(),H.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var ws=[];T.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t="Identifier"===e.type;return this.enterScope(t?It:0),this.checkLValPattern(e,t?Ot:oe),this.expect(h.parenR),e},T.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===h._catch){var t=this.startNode();this.next(),this.eat(h.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(h._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},T.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")},T.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(ft),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")},T.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")},T.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},T.parseLabeledStatement=function(e,t,n,s){for(var i=0,r=this.labels;i<r.length;i+=1){r[i].name===t&&this.raise(n.start,"Label '"+t+"' is already declared")}for(var a=this.type.isLoop?"loop":this.type===h._switch?"switch":null,o=this.labels.length-1;o>=0;o--){var c=this.labels[o];if(c.statementStart!==e.start)break;c.statementStart=this.start,c.kind=a}return this.labels.push({name:t,kind:a,statementStart:this.start}),e.body=this.parseStatement(s?-1===s.indexOf("label")?s+"label":s:"label"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")},T.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},T.parseBlock=function(e,t,n){for(void 0===e&&(e=!0),void 0===t&&(t=this.startNode()),t.body=[],this.expect(h.braceL),e&&this.enterScope(0);this.type!==h.braceR;){var s=this.parseStatement(null);t.body.push(s)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")},T.parseFor=function(e,t){return e.init=t,this.expect(h.semi),e.test=this.type===h.semi?null:this.parseExpression(),this.expect(h.semi),e.update=this.type===h.parenR?null:this.parseExpression(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")},T.parseForIn=function(e,t){var n=this.type===h._in;return this.next(),"VariableDeclaration"===t.type&&null!=t.declarations[0].init&&(!n||this.options.ecmaVersion<8||this.strict||"var"!==t.kind||"Identifier"!==t.declarations[0].id.type)&&this.raise(t.start,(n?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(h.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,n?"ForInStatement":"ForOfStatement")},T.parseVar=function(e,t,n,s){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(h.eq)?i.init=this.parseMaybeAssign(t):s||"const"!==n||this.type===h._in||this.options.ecmaVersion>=6&&this.isContextual("of")?s||"using"!==n&&"await using"!==n||!(this.options.ecmaVersion>=17)||this.type===h._in||this.isContextual("of")?s||"Identifier"===i.id.type||t&&(this.type===h._in||this.isContextual("of"))?i.init=null:this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):this.raise(this.lastTokEnd,"Missing initializer in "+n+" declaration"):this.unexpected(),e.declarations.push(this.finishNode(i,"VariableDeclarator")),!this.eat(h.comma))break}return e},T.parseVarId=function(e,t){e.id="using"===t||"await using"===t?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,"var"===t?ht:oe,!1)};var _e=1,st=2,Ft=4;function Ps(e,t){var n=t.key.name,s=e[n],i="true";return"MethodDefinition"===t.type&&("get"===t.kind||"set"===t.kind)&&(i=(t.static?"s":"i")+t.kind),"iget"===s&&"iset"===i||"iset"===s&&"iget"===i||"sget"===s&&"sset"===i||"sset"===s&&"sget"===i?(e[n]="true",!1):!!s||(e[n]=i,!1)}function De(e,t){var n=e.computed,s=e.key;return!n&&("Identifier"===s.type&&s.name===t||"Literal"===s.type&&s.value===t)}T.parseFunction=function(e,t,n,s,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!s)&&(this.type===h.star&&t&st&&this.unexpected(),e.generator=this.eat(h.star)),this.options.ecmaVersion>=8&&(e.async=!!s),t&_e&&(e.id=t&Ft&&this.type!==h.name?null:this.parseIdent(),e.id&&!(t&st)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?ht:oe:Rt));var r=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(pt(e.async,e.generator)),t&_e||(e.id=this.type===h.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=r,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,t&_e?"FunctionDeclaration":"FunctionExpression")},T.parseFunctionParams=function(e){this.expect(h.parenL),e.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},T.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var s=this.enterClassBody(),i=this.startNode(),r=!1;for(i.body=[],this.expect(h.braceL);this.type!==h.braceR;){var a=this.parseClassElement(null!==e.superClass);a&&(i.body.push(a),"MethodDefinition"===a.type&&"constructor"===a.kind?(r&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),r=!0):a.key&&"PrivateIdentifier"===a.key.type&&Ps(s,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=n,this.next(),e.body=this.finishNode(i,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},T.parseClassElement=function(e){if(this.eat(h.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),s="",i=!1,r=!1,a="method",o=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(h.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===h.star?o=!0:s="static"}if(n.static=o,!s&&t>=8&&this.eatContextual("async")&&(!this.isClassElementNameStart()&&this.type!==h.star||this.canInsertSemicolon()?s="async":r=!0),!s&&(t>=9||!r)&&this.eat(h.star)&&(i=!0),!s&&!r&&!i){var c=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=c:s=c)}if(s?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=s,this.finishNode(n.key,"Identifier")):this.parseClassElementName(n),t<13||this.type===h.parenL||"method"!==a||i||r){var l=!n.static&&De(n,"constructor"),p=l&&e;l&&"method"!==a&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=l?"constructor":a,this.parseClassMethod(n,i,r,p)}else this.parseClassField(n);return n},T.isClassElementNameStart=function(){return this.type===h.name||this.type===h.privateId||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword},T.parseClassElementName=function(e){this.type===h.privateId?("constructor"===this.value&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},T.parseClassMethod=function(e,t,n,s){var i=e.key;"constructor"===e.kind?(t&&this.raise(i.start,"Constructor can't be a generator"),n&&this.raise(i.start,"Constructor can't be an async method")):e.static&&De(e,"prototype")&&this.raise(i.start,"Classes may not have a static property named prototype");var r=e.value=this.parseMethod(t,n,s);return"get"===e.kind&&0!==r.params.length&&this.raiseRecoverable(r.start,"getter should have no params"),"set"===e.kind&&1!==r.params.length&&this.raiseRecoverable(r.start,"setter should have exactly one param"),"set"===e.kind&&"RestElement"===r.params[0].type&&this.raiseRecoverable(r.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")},T.parseClassField=function(e){return De(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&De(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(h.eq)?(this.enterScope(Me|ze),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")},T.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(be|ze);this.type!==h.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")},T.parseClassId=function(e,t){this.type===h.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,oe,!1)):(!0===t&&this.unexpected(),e.id=null)},T.parseClassSuper=function(e){e.superClass=this.eat(h._extends)?this.parseExprSubscripts(null,!1):null},T.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},T.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var s=this.privateNameStack.length,i=0===s?null:this.privateNameStack[s-1],r=0;r<n.length;++r){var a=n[r];we(t,a.name)||(i?i.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}},T.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")},T.parseExport=function(e,t){if(this.next(),this.eat(h.star))return this.parseExportAllDeclaration(e,t);if(this.eat(h._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),"VariableDeclaration"===e.declaration.type?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==h.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,s=e.specifiers;n<s.length;n+=1){var i=s[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),"Literal"===i.local.type&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")},T.parseExportDeclaration=function(e){return this.parseStatement(null)},T.parseExportDefaultDeclaration=function(){var e;if(this.type===h._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,_e|Ft,!1,e)}if(this.type===h._class){var n=this.startNode();return this.parseClass(n,"nullableID")}var s=this.parseMaybeAssign();return this.semicolon(),s},T.checkExport=function(e,t,n){e&&("string"!=typeof t&&(t="Identifier"===t.type?t.name:t.value),we(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)},T.checkPatternExport=function(e,t){var n=t.type;if("Identifier"===n)this.checkExport(e,t,t.start);else if("ObjectPattern"===n)for(var s=0,i=t.properties;s<i.length;s+=1){var r=i[s];this.checkPatternExport(e,r)}else if("ArrayPattern"===n)for(var a=0,o=t.elements;a<o.length;a+=1){var c=o[a];c&&this.checkPatternExport(e,c)}else"Property"===n?this.checkPatternExport(e,t.value):"AssignmentPattern"===n?this.checkPatternExport(e,t.left):"RestElement"===n&&this.checkPatternExport(e,t.argument)},T.checkVariableExport=function(e,t){if(e)for(var n=0,s=t;n<s.length;n+=1){var i=s[n];this.checkPatternExport(e,i.id)}},T.shouldParseExportStatement=function(){return"var"===this.type.keyword||"const"===this.type.keyword||"class"===this.type.keyword||"function"===this.type.keyword||this.isLet()||this.isAsyncFunction()},T.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")},T.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(h.braceL);!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;t.push(this.parseExportSpecifier(e))}return t},T.parseImport=function(e){return this.next(),this.type===h.string?(e.specifiers=ws,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===h.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")},T.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,oe),this.finishNode(e,"ImportSpecifier")},T.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,oe),this.finishNode(e,"ImportDefaultSpecifier")},T.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,oe),this.finishNode(e,"ImportNamespaceSpecifier")},T.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===h.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(h.comma)))return e;if(this.type===h.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(h.braceL);!this.eat(h.braceR);){if(t)t=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;e.push(this.parseImportSpecifier())}return e},T.parseWithClause=function(){var e=[];if(!this.eat(h._with))return e;this.expect(h.braceL);for(var t={},n=!0;!this.eat(h.braceR);){if(n)n=!1;else if(this.expect(h.comma),this.afterTrailingComma(h.braceR))break;var s=this.parseImportAttribute(),i="Identifier"===s.key.type?s.key.name:s.key.value;we(t,i)&&this.raiseRecoverable(s.key.start,"Duplicate attribute key '"+i+"'"),t[i]=!0,e.push(s)}return e},T.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===h.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved),this.expect(h.colon),this.type!==h.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")},T.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===h.string){var e=this.parseLiteral(this.value);return bs.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)},T.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},T.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&"ExpressionStatement"===e.type&&"Literal"===e.expression.type&&"string"==typeof e.expression.value&&('"'===this.input[e.start]||"'"===this.input[e.start])};var Q=F.prototype;Q.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&"await"===e.name&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var s=0,i=e.properties;s<i.length;s+=1){var r=i[s];this.toAssignable(r,t),"RestElement"===r.type&&("ArrayPattern"===r.argument.type||"ObjectPattern"===r.argument.type)&&this.raise(r.argument.start,"Unexpected token")}break;case"Property":"init"!==e.kind&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),"AssignmentPattern"===e.argument.type&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":"="!==e.operator&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,n);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else n&&this.checkPatternErrors(n,!0);return e},Q.toAssignableList=function(e,t){for(var n=e.length,s=0;s<n;s++){var i=e[s];i&&this.toAssignable(i,t)}if(n){var r=e[n-1];6===this.options.ecmaVersion&&t&&r&&"RestElement"===r.type&&"Identifier"!==r.argument.type&&this.unexpected(r.argument.start)}return e},Q.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")},Q.parseRestBinding=function(){var e=this.startNode();return this.next(),6===this.options.ecmaVersion&&this.type!==h.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")},Q.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case h.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(h.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case h.braceL:return this.parseObj(!0)}return this.parseIdent()},Q.parseBindingList=function(e,t,n,s){for(var i=[],r=!0;!this.eat(e);)if(r?r=!1:this.expect(h.comma),t&&this.type===h.comma)i.push(null);else{if(n&&this.afterTrailingComma(e))break;if(this.type===h.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),i.push(a),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}i.push(this.parseAssignableListItem(s))}return i},Q.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},Q.parseBindingListItem=function(e){return e},Q.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(h.eq))return n;var s=this.startNodeAt(e,t);return s.left=n,s.right=this.parseMaybeAssign(),this.finishNode(s,"AssignmentPattern")},Q.checkLValSimple=function(e,t,n){void 0===t&&(t=Ve);var s=t!==Ve;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(s?"Binding ":"Assigning to ")+e.name+" in strict mode"),s&&(t===oe&&"let"===e.name&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),n&&(we(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==Lt&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":s&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return s&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(s?"Binding":"Assigning to")+" rvalue")}},Q.checkLValPattern=function(e,t,n){switch(void 0===t&&(t=Ve),e.type){case"ObjectPattern":for(var s=0,i=e.properties;s<i.length;s+=1){var r=i[s];this.checkLValInnerPattern(r,t,n)}break;case"ArrayPattern":for(var a=0,o=e.elements;a<o.length;a+=1){var c=o[a];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},Q.checkLValInnerPattern=function(e,t,n){switch(void 0===t&&(t=Ve),e.type){case"Property":this.checkLValInnerPattern(e.value,t,n);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,n);break;case"RestElement":this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var J=function(e,t,n,s,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=s,this.generator=!!i},O={b_stat:new J("{",!1),b_expr:new J("{",!0),b_tmpl:new J("${",!1),p_stat:new J("(",!1),p_expr:new J("(",!0),q_tmpl:new J("`",!0,!0,(function(e){return e.tryReadTemplateToken()})),f_stat:new J("function",!1),f_expr:new J("function",!0),f_expr_gen:new J("function",!0,!1,null,!0),f_gen:new J("function",!1,!1,null,!0)},Ae=F.prototype;Ae.initialContext=function(){return[O.b_stat]},Ae.curContext=function(){return this.context[this.context.length-1]},Ae.braceIsBlock=function(e){var t=this.curContext();return t===O.f_expr||t===O.f_stat||(e!==h.colon||t!==O.b_stat&&t!==O.b_expr?e===h._return||e===h.name&&this.exprAllowed?H.test(this.input.slice(this.lastTokEnd,this.start)):e===h._else||e===h.semi||e===h.eof||e===h.parenR||e===h.arrow||(e===h.braceL?t===O.b_stat:e!==h._var&&e!==h._const&&e!==h.name&&!this.exprAllowed):!t.isExpr)},Ae.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if("function"===t.token)return t.generator}return!1},Ae.updateContext=function(e){var t,n=this.type;n.keyword&&e===h.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Ae.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},h.parenR.updateContext=h.braceR.updateContext=function(){if(1!==this.context.length){var e=this.context.pop();e===O.b_stat&&"function"===this.curContext().token&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}else this.exprAllowed=!0},h.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?O.b_stat:O.b_expr),this.exprAllowed=!0},h.dollarBraceL.updateContext=function(){this.context.push(O.b_tmpl),this.exprAllowed=!0},h.parenL.updateContext=function(e){var t=e===h._if||e===h._for||e===h._with||e===h._while;this.context.push(t?O.p_stat:O.p_expr),this.exprAllowed=!0},h.incDec.updateContext=function(){},h._function.updateContext=h._class.updateContext=function(e){!e.beforeExpr||e===h._else||e===h.semi&&this.curContext()!==O.p_stat||e===h._return&&H.test(this.input.slice(this.lastTokEnd,this.start))||(e===h.colon||e===h.braceL)&&this.curContext()===O.b_stat?this.context.push(O.f_stat):this.context.push(O.f_expr),this.exprAllowed=!1},h.colon.updateContext=function(){"function"===this.curContext().token&&this.context.pop(),this.exprAllowed=!0},h.backQuote.updateContext=function(){this.curContext()===O.q_tmpl?this.context.pop():this.context.push(O.q_tmpl),this.exprAllowed=!1},h.star.updateContext=function(e){if(e===h._function){var t=this.context.length-1;this.context[t]===O.f_expr?this.context[t]=O.f_expr_gen:this.context[t]=O.f_gen}this.exprAllowed=!0},h.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==h.dot&&("of"===this.value&&!this.exprAllowed||"yield"===this.value&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var w=F.prototype;function Vt(e){return"Identifier"===e.type||"ParenthesizedExpression"===e.type&&Vt(e.expression)}function nt(e){return"MemberExpression"===e.type&&"PrivateIdentifier"===e.property.type||"ChainExpression"===e.type&&nt(e.expression)||"ParenthesizedExpression"===e.type&&nt(e.expression)}w.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&"SpreadElement"===e.type||this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var s,i=e.key;switch(i.type){case"Identifier":s=i.name;break;case"Literal":s=String(i.value);break;default:return}var r=e.kind;if(this.options.ecmaVersion>=6)return void("__proto__"===s&&"init"===r&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=i.start):this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),t.proto=!0));var a=t[s="$"+s];if(a)("init"===r?this.strict&&a.init||a.get||a.set:a.init||a[r])&&this.raiseRecoverable(i.start,"Redefinition of property");else a=t[s]={init:!1,get:!1,set:!1};a[r]=!0}},w.parseExpression=function(e,t){var n=this.start,s=this.startLoc,i=this.parseMaybeAssign(e,t);if(this.type===h.comma){var r=this.startNodeAt(n,s);for(r.expressions=[i];this.eat(h.comma);)r.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(r,"SequenceExpression")}return i},w.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var s=!1,i=-1,r=-1,a=-1;t?(i=t.parenthesizedAssign,r=t.trailingComma,a=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Ke,s=!0);var o=this.start,c=this.startLoc;(this.type===h.parenL||this.type===h.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait="await"===e);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,o,c)),this.type.isAssign){var p=this.startNodeAt(o,c);return p.operator=this.value,this.type===h.eq&&(l=this.toAssignable(l,!1,t)),s||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===h.eq?this.checkLValPattern(l):this.checkLValSimple(l),p.left=l,this.next(),p.right=this.parseMaybeAssign(e),a>-1&&(t.doubleProto=a),this.finishNode(p,"AssignmentExpression")}return s&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),r>-1&&(t.trailingComma=r),l},w.parseMaybeConditional=function(e,t){var n=this.start,s=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(this.eat(h.question)){var r=this.startNodeAt(n,s);return r.test=i,r.consequent=this.parseMaybeAssign(),this.expect(h.colon),r.alternate=this.parseMaybeAssign(e),this.finishNode(r,"ConditionalExpression")}return i},w.parseExprOps=function(e,t){var n=this.start,s=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&"ArrowFunctionExpression"===i.type?i:this.parseExprOp(i,n,s,-1,e)},w.parseExprOp=function(e,t,n,s,i){var r=this.type.binop;if(null!=r&&(!i||this.type!==h._in)&&r>s){var a=this.type===h.logicalOR||this.type===h.logicalAND,o=this.type===h.coalesce;o&&(r=h.logicalAND.binop);var c=this.value;this.next();var l=this.start,p=this.startLoc,u=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,p,r,i),d=this.buildBinary(t,n,e,u,c,a||o);return(a&&this.type===h.coalesce||o&&(this.type===h.logicalOR||this.type===h.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(d,t,n,s,i)}return e},w.buildBinary=function(e,t,n,s,i,r){"PrivateIdentifier"===s.type&&this.raise(s.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(e,t);return a.left=n,a.operator=i,a.right=s,this.finishNode(a,r?"LogicalExpression":"BinaryExpression")},w.parseMaybeUnary=function(e,t,n,s){var i,r=this.start,a=this.startLoc;if(this.isContextual("await")&&this.canAwait)i=this.parseAwait(s),t=!0;else if(this.type.prefix){var o=this.startNode(),c=this.type===h.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,c,s),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(o.argument):this.strict&&"delete"===o.operator&&Vt(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):"delete"===o.operator&&nt(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):t=!0,i=this.finishNode(o,c?"UpdateExpression":"UnaryExpression")}else if(t||this.type!==h.privateId){if(i=this.parseExprSubscripts(e,s),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(r,a);l.operator=this.value,l.prefix=!1,l.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(l,"UpdateExpression")}}else(s||0===this.privateNameStack.length)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==h._in&&this.unexpected();return n||!this.eat(h.starstar)?i:t?void this.unexpected(this.lastTokStart):this.buildBinary(r,a,i,this.parseMaybeUnary(null,!1,!1,s),"**",!1)},w.parseExprSubscripts=function(e,t){var n=this.start,s=this.startLoc,i=this.parseExprAtom(e,t);if("ArrowFunctionExpression"===i.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd))return i;var r=this.parseSubscripts(i,n,s,!1,t);return e&&"MemberExpression"===r.type&&(e.parenthesizedAssign>=r.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=r.start&&(e.parenthesizedBind=-1),e.trailingComma>=r.start&&(e.trailingComma=-1)),r},w.parseSubscripts=function(e,t,n,s,i){for(var r=this.options.ecmaVersion>=8&&"Identifier"===e.type&&"async"===e.name&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start==5&&this.potentialArrowAt===e.start,a=!1;;){var o=this.parseSubscript(e,t,n,s,r,a,i);if(o.optional&&(a=!0),o===e||"ArrowFunctionExpression"===o.type){if(a){var c=this.startNodeAt(t,n);c.expression=o,o=this.finishNode(c,"ChainExpression")}return o}e=o}},w.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(h.arrow)},w.parseSubscriptAsyncArrow=function(e,t,n,s){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,s)},w.parseSubscript=function(e,t,n,s,i,r,a){var o=this.options.ecmaVersion>=11,c=o&&this.eat(h.questionDot);s&&c&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(h.bracketL);if(l||c&&this.type!==h.parenL&&this.type!==h.backQuote||this.eat(h.dot)){var p=this.startNodeAt(t,n);p.object=e,l?(p.property=this.parseExpression(),this.expect(h.bracketR)):this.type===h.privateId&&"Super"!==e.type?p.property=this.parsePrivateIdent():p.property=this.parseIdent("never"!==this.options.allowReserved),p.computed=!!l,o&&(p.optional=c),e=this.finishNode(p,"MemberExpression")}else if(!s&&this.eat(h.parenL)){var u=new Ke,d=this.yieldPos,m=this.awaitPos,f=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var g=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1,u);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(u,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=d,this.awaitPos=m,this.awaitIdentPos=f,this.parseSubscriptAsyncArrow(t,n,g,a);this.checkExpressionErrors(u,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=f||this.awaitIdentPos;var E=this.startNodeAt(t,n);E.callee=e,E.arguments=g,o&&(E.optional=c),e=this.finishNode(E,"CallExpression")}else if(this.type===h.backQuote){(c||r)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var x=this.startNodeAt(t,n);x.tag=e,x.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(x,"TaggedTemplateExpression")}return e},w.parseExprAtom=function(e,t,n){this.type===h.slash&&this.readRegexp();var s,i=this.potentialArrowAt===this.start;switch(this.type){case h._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),s=this.startNode(),this.next(),this.type===h.parenL&&!this.allowDirectSuper&&this.raise(s.start,"super() call outside constructor of a subclass"),this.type!==h.dot&&this.type!==h.bracketL&&this.type!==h.parenL&&this.unexpected(),this.finishNode(s,"Super");case h._this:return s=this.startNode(),this.next(),this.finishNode(s,"ThisExpression");case h.name:var r=this.start,a=this.startLoc,o=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&"async"===c.name&&!this.canInsertSemicolon()&&this.eat(h._function))return this.overrideContext(O.f_expr),this.parseFunction(this.startNodeAt(r,a),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(h.arrow))return this.parseArrowExpression(this.startNodeAt(r,a),[c],!1,t);if(this.options.ecmaVersion>=8&&"async"===c.name&&this.type===h.name&&!o&&(!this.potentialArrowInForAwait||"of"!==this.value||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(h.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,a),[c],!0,t)}return c;case h.regexp:var l=this.value;return(s=this.parseLiteral(l.value)).regex={pattern:l.pattern,flags:l.flags},s;case h.num:case h.string:return this.parseLiteral(this.value);case h._null:case h._true:case h._false:return(s=this.startNode()).value=this.type===h._null?null:this.type===h._true,s.raw=this.type.keyword,this.next(),this.finishNode(s,"Literal");case h.parenL:var p=this.start,u=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(u)&&(e.parenthesizedAssign=p),e.parenthesizedBind<0&&(e.parenthesizedBind=p)),u;case h.bracketL:return s=this.startNode(),this.next(),s.elements=this.parseExprList(h.bracketR,!0,!0,e),this.finishNode(s,"ArrayExpression");case h.braceL:return this.overrideContext(O.b_expr),this.parseObj(!1,e);case h._function:return s=this.startNode(),this.next(),this.parseFunction(s,0);case h._class:return this.parseClass(this.startNode(),!1);case h._new:return this.parseNew();case h.backQuote:return this.parseTemplate();case h._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},w.parseExprAtomDefault=function(){this.unexpected()},w.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===h.parenL&&!e)return this.parseDynamicImport(t);if(this.type===h.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name="import",t.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(t)}this.unexpected()},w.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(h.parenR)?e.options=null:(this.expect(h.comma),this.afterTrailingComma(h.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(h.parenR)||(this.expect(h.comma),this.afterTrailingComma(h.parenR)||this.unexpected())));else if(!this.eat(h.parenR)){var t=this.start;this.eat(h.comma)&&this.eat(h.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")},w.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),"meta"!==e.property.name&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),"module"!==this.options.sourceType&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")},w.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),110===t.raw.charCodeAt(t.raw.length-1)&&(t.bigint=null!=t.value?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")},w.parseParenExpression=function(){this.expect(h.parenL);var e=this.parseExpression();return this.expect(h.parenR),e},w.shouldParseArrow=function(e){return!this.canInsertSemicolon()},w.parseParenAndDistinguishExpression=function(e,t){var n,s=this.start,i=this.startLoc,r=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a,o=this.start,c=this.startLoc,l=[],p=!0,u=!1,d=new Ke,m=this.yieldPos,f=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==h.parenR;){if(p?p=!1:this.expect(h.comma),r&&this.afterTrailingComma(h.parenR,!0)){u=!0;break}if(this.type===h.ellipsis){a=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}l.push(this.parseMaybeAssign(!1,d,this.parseParenItem))}var g=this.lastTokEnd,E=this.lastTokEndLoc;if(this.expect(h.parenR),e&&this.shouldParseArrow(l)&&this.eat(h.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=m,this.awaitPos=f,this.parseParenArrowList(s,i,l,t);(!l.length||u)&&this.unexpected(this.lastTokStart),a&&this.unexpected(a),this.checkExpressionErrors(d,!0),this.yieldPos=m||this.yieldPos,this.awaitPos=f||this.awaitPos,l.length>1?((n=this.startNodeAt(o,c)).expressions=l,this.finishNodeAt(n,"SequenceExpression",g,E)):n=l[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var x=this.startNodeAt(s,i);return x.expression=n,this.finishNode(x,"ParenthesizedExpression")}return n},w.parseParenItem=function(e){return e},w.parseParenArrowList=function(e,t,n,s){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,s)};var As=[];w.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===h.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),"target"!==e.property.name&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var s=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),s,i,!0,!1),this.eat(h.parenL)?e.arguments=this.parseExprList(h.parenR,this.options.ecmaVersion>=8,!1):e.arguments=As,this.finishNode(e,"NewExpression")},w.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===h.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value.replace(/\r\n?/g,"\n"),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),n.tail=this.type===h.backQuote,this.finishNode(n,"TemplateElement")},w.parseTemplate=function(e){void 0===e&&(e={});var t=e.isTagged;void 0===t&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var s=this.parseTemplateElement({isTagged:t});for(n.quasis=[s];!s.tail;)this.type===h.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(h.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(h.braceR),n.quasis.push(s=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,"TemplateLiteral")},w.isAsyncProp=function(e){return!e.computed&&"Identifier"===e.key.type&&"async"===e.key.name&&(this.type===h.name||this.type===h.num||this.type===h.string||this.type===h.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===h.star)&&!H.test(this.input.slice(this.lastTokEnd,this.start))},w.parseObj=function(e,t){var n=this.startNode(),s=!0,i={};for(n.properties=[],this.next();!this.eat(h.braceR);){if(s)s=!1;else if(this.expect(h.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(h.braceR))break;var r=this.parseProperty(e,t);e||this.checkPropClash(r,i,t),n.properties.push(r)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")},w.parseProperty=function(e,t){var n,s,i,r,a=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(h.ellipsis))return e?(a.argument=this.parseIdent(!1),this.type===h.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(a,"RestElement")):(a.argument=this.parseMaybeAssign(!1,t),this.type===h.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(a,"SpreadElement"));this.options.ecmaVersion>=6&&(a.method=!1,a.shorthand=!1,(e||t)&&(i=this.start,r=this.startLoc),e||(n=this.eat(h.star)));var o=this.containsEsc;return this.parsePropertyName(a),!e&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(a)?(s=!0,n=this.options.ecmaVersion>=9&&this.eat(h.star),this.parsePropertyName(a)):s=!1,this.parsePropertyValue(a,e,n,s,i,r,t,o),this.finishNode(a,"Property")},w.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n="get"===e.kind?0:1;if(e.value.params.length!==n){var s=e.value.start;"get"===e.kind?this.raiseRecoverable(s,"getter should have no params"):this.raiseRecoverable(s,"setter should have exactly one param")}else"set"===e.kind&&"RestElement"===e.value.params[0].type&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")},w.parsePropertyValue=function(e,t,n,s,i,r,a,o){(n||s)&&this.type===h.colon&&this.unexpected(),this.eat(h.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),e.kind="init"):this.options.ecmaVersion>=6&&this.type===h.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,s),e.kind="init"):t||o||!(this.options.ecmaVersion>=5)||e.computed||"Identifier"!==e.key.type||"get"!==e.key.name&&"set"!==e.key.name||this.type===h.comma||this.type===h.braceR||this.type===h.eq?this.options.ecmaVersion>=6&&!e.computed&&"Identifier"===e.key.type?((n||s)&&this.unexpected(),this.checkUnreserved(e.key),"await"===e.key.name&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,r,this.copyNode(e.key)):this.type===h.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,r,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected():((n||s)&&this.unexpected(),this.parseGetterSetter(e))},w.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(h.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(h.bracketR),e.key;e.computed=!1}return e.key=this.type===h.num||this.type===h.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved)},w.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},w.parseMethod=function(e,t,n){var s=this.startNode(),i=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(s),this.options.ecmaVersion>=6&&(s.generator=e),this.options.ecmaVersion>=8&&(s.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(pt(t,s.generator)|ze|(n?Mt:0)),this.expect(h.parenL),s.params=this.parseBindingList(h.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(s,!1,!0,!1),this.yieldPos=i,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(s,"FunctionExpression")},w.parseArrowExpression=function(e,t,n,s){var i=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(pt(n,!1)|ut),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,s),this.yieldPos=i,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(e,"ArrowFunctionExpression")},w.parseFunctionBody=function(e,t,n,s){var i=t&&this.type!==h.braceL,r=this.strict,a=!1;if(i)e.body=this.parseMaybeAssign(s),e.expression=!0,this.checkParams(e,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!r||o)&&((a=this.strictDirective(this.end))&&o&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var c=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(e,!r&&!a&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Lt),e.body=this.parseBlock(!1,void 0,a&&!r),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},w.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1){if("Identifier"!==n[t].type)return!1}return!0},w.checkParams=function(e,t){for(var n=Object.create(null),s=0,i=e.params;s<i.length;s+=1){var r=i[s];this.checkLValInnerPattern(r,ht,t?null:n)}},w.parseExprList=function(e,t,n,s){for(var i=[],r=!0;!this.eat(e);){if(r)r=!1;else if(this.expect(h.comma),t&&this.afterTrailingComma(e))break;var a=void 0;n&&this.type===h.comma?a=null:this.type===h.ellipsis?(a=this.parseSpread(s),s&&this.type===h.comma&&s.trailingComma<0&&(s.trailingComma=this.start)):a=this.parseMaybeAssign(!1,s),i.push(a)}return i},w.checkUnreserved=function(e){var t=e.start,n=e.end,s=e.name;(this.inGenerator&&"yield"===s&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&"await"===s&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&Xe)&&"arguments"===s&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&("arguments"===s||"await"===s)&&this.raise(t,"Cannot use "+s+" in class static initialization block"),this.keywords.test(s)&&this.raise(t,"Unexpected keyword '"+s+"'"),this.options.ecmaVersion<6&&-1!==this.input.slice(t,n).indexOf("\\"))||(this.strict?this.reservedWordsStrict:this.reservedWords).test(s)&&(!this.inAsync&&"await"===s&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+s+"' is reserved"))},w.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),"await"===t.name&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},w.parseIdentNode=function(){var e=this.startNode();return this.type===h.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,("class"===e.name||"function"===e.name)&&(this.lastTokEnd!==this.lastTokStart+1||46!==this.input.charCodeAt(this.lastTokStart))&&this.context.pop(),this.type=h.name):this.unexpected(),e},w.parsePrivateIdent=function(){var e=this.startNode();return this.type===h.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(0===this.privateNameStack.length?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},w.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===h.semi||this.canInsertSemicolon()||this.type!==h.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(h.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")},w.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var Be=F.prototype;Be.raise=function(e,t){var n=Nt(this.input,e);t+=" ("+n.line+":"+n.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var s=new SyntaxError(t);throw s.pos=e,s.loc=n,s.raisedAt=this.pos,s},Be.raiseRecoverable=Be.raise,Be.curPosition=function(){if(this.options.locations)return new ke(this.curLine,this.pos-this.lineStart)};var he=F.prototype,_s=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};he.enterScope=function(e){this.scopeStack.push(new _s(e))},he.exitScope=function(){this.scopeStack.pop()},he.treatFunctionsAsVarInScope=function(e){return e.flags&Pe||!this.inModule&&e.flags&Ie},he.declareName=function(e,t,n){var s=!1;if(t===oe){var i=this.currentScope();s=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&Ie&&delete this.undefinedExports[e]}else if(t===Ot){this.currentScope().lexical.push(e)}else if(t===Rt){var r=this.currentScope();s=this.treatFunctionsAsVar?r.lexical.indexOf(e)>-1:r.lexical.indexOf(e)>-1||r.var.indexOf(e)>-1,r.functions.push(e)}else for(var a=this.scopeStack.length-1;a>=0;--a){var o=this.scopeStack[a];if(o.lexical.indexOf(e)>-1&&!(o.flags&It&&o.lexical[0]===e)||!this.treatFunctionsAsVarInScope(o)&&o.functions.indexOf(e)>-1){s=!0;break}if(o.var.push(e),this.inModule&&o.flags&Ie&&delete this.undefinedExports[e],o.flags&Xe)break}s&&this.raiseRecoverable(n,"Identifier '"+e+"' has already been declared")},he.checkLocalExport=function(e){-1===this.scopeStack[0].lexical.indexOf(e.name)&&-1===this.scopeStack[0].var.indexOf(e.name)&&(this.undefinedExports[e.name]=e)},he.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},he.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Xe|Me|be))return t}},he.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(Xe|Me|be)&&!(t.flags&ut))return t}};var Ge=function(e,t,n){this.type="",this.start=t,this.end=0,e.options.locations&&(this.loc=new qe(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Re=F.prototype;function Dt(e,t,n,s){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=s),this.options.ranges&&(e.range[1]=n),e}Re.startNode=function(){return new Ge(this,this.start,this.startLoc)},Re.startNodeAt=function(e,t){return new Ge(this,e,t)},Re.finishNode=function(e,t){return Dt.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},Re.finishNodeAt=function(e,t,n,s){return Dt.call(this,e,t,n,s)},Re.copyNode=function(e){var t=new Ge(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};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",Bt="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",$t=Bt+" Extended_Pictographic",Wt=$t,jt=$t+" EBase EComp EMod EPres ExtPict",Ht=jt,ks=jt,Is={9:Bt,10:$t,11:$t,12:jt,13:jt,14:ks},Ms="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Rs={9:"",10:"",11:"",12:"",13:"",14:Ms},bt="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",Ut="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",qt=Ut+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",zt=qt+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Xt=zt+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Kt=Xt+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Os=Kt+" "+Ns,Ls={9:Ut,10:qt,11:zt,12:Xt,13:Kt,14:Os},Gt={};function Fs(e){var t=Gt[e]={binary:ue(Is[e]+" "+bt),binaryOfStrings:ue(Rs[e]),nonBinary:{General_Category:ue(bt),Script:ue(Ls[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var Ze=0,yt=[9,10,11,12,13,14];Ze<yt.length;Ze+=1){var Vs=yt[Ze];Fs(Vs)}var S=F.prototype,$e=function(e,t){this.parent=e,this.base=t||this};$e.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1},$e.prototype.sibling=function(){return new $e(this.parent,this.base)};var ne=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=Gt[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};function Ds(e){for(var t in e)return!0;return!1}function Bs(e){return 105===e||109===e||115===e}function Qt(e){return 36===e||e>=40&&e<=43||46===e||63===e||e>=91&&e<=94||e>=123&&e<=125}function $s(e){return te(e,!0)||36===e||95===e}function Ws(e){return pe(e,!0)||36===e||95===e||8204===e||8205===e}function Yt(e){return e>=65&&e<=90||e>=97&&e<=122}function js(e){return e>=0&&e<=1114111}ne.prototype.reset=function(e,t,n){var s=-1!==n.indexOf("v"),i=-1!==n.indexOf("u");this.start=0|e,this.source=t+"",this.flags=n,s&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},ne.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)},ne.prototype.at=function(e,t){void 0===t&&(t=!1);var n=this.source,s=n.length;if(e>=s)return-1;var i=n.charCodeAt(e);if(!t&&!this.switchU||i<=55295||i>=57344||e+1>=s)return i;var r=n.charCodeAt(e+1);return r>=56320&&r<=57343?(i<<10)+r-56613888:i},ne.prototype.nextIndex=function(e,t){void 0===t&&(t=!1);var n=this.source,s=n.length;if(e>=s)return s;var i,r=n.charCodeAt(e);return!t&&!this.switchU||r<=55295||r>=57344||e+1>=s||(i=n.charCodeAt(e+1))<56320||i>57343?e+1:e+2},ne.prototype.current=function(e){return void 0===e&&(e=!1),this.at(this.pos,e)},ne.prototype.lookahead=function(e){return void 0===e&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},ne.prototype.advance=function(e){void 0===e&&(e=!1),this.pos=this.nextIndex(this.pos,e)},ne.prototype.eat=function(e,t){return void 0===t&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},ne.prototype.eatChars=function(e,t){void 0===t&&(t=!1);for(var n=this.pos,s=0,i=e;s<i.length;s+=1){var r=i[s],a=this.at(n,t);if(-1===a||a!==r)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},S.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,s=!1,i=!1,r=0;r<n.length;r++){var a=n.charAt(r);-1===t.indexOf(a)&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(a,r+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),"u"===a&&(s=!0),"v"===a&&(i=!0)}this.options.ecmaVersion>=15&&s&&i&&this.raise(e.start,"Invalid regular expression flag")},S.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Ds(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},S.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var s=n[t];e.groupNames[s]||e.raise("Invalid named capture referenced")}},S.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new $e(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")},S.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},S.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):!!(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))&&(this.regexp_eatQuantifier(e),!0)},S.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},S.regexp_eatQuantifier=function(e,t){return void 0===t&&(t=!1),!!this.regexp_eatQuantifierPrefix(e,t)&&(e.eat(63),!0)},S.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},S.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var s=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(s=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return-1!==i&&i<s&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=n}return!1},S.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},S.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},S.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),s=e.eat(45);if(n||s){for(var i=0;i<n.length;i++){var r=n.charAt(i);n.indexOf(r,i+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(s){var a=this.regexp_eatModifiers(e);!n&&!a&&58===e.current()&&e.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var c=a.charAt(o);(a.indexOf(c,o+1)>-1||n.indexOf(c)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1},S.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):63===e.current()&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1},S.regexp_eatModifiers=function(e){for(var t="",n=0;-1!==(n=e.current())&&Bs(n);)t+=re(n),e.advance();return t},S.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},S.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},S.regexp_eatSyntaxCharacter=function(e){var t=e.current();return!!Qt(t)&&(e.lastIntValue=t,e.advance(),!0)},S.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;-1!==(n=e.current())&&!Qt(n);)e.advance();return e.pos!==t},S.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return!(-1===t||36===t||t>=40&&t<=43||46===t||63===t||91===t||94===t||124===t)&&(e.advance(),!0)},S.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var s=0,i=n;s<i.length;s+=1){i[s].separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},S.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1},S.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=re(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=re(e.lastIntValue);return!0}return!1},S.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,s=e.current(n);return e.advance(n),92===s&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(s=e.lastIntValue),$s(s)?(e.lastIntValue=s,!0):(e.pos=t,!1)},S.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,s=e.current(n);return e.advance(n),92===s&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(s=e.lastIntValue),Ws(s)?(e.lastIntValue=s,!0):(e.pos=t,!1)},S.regexp_eatAtomEscape=function(e){return!!(this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e))||(e.switchU&&(99===e.current()&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)},S.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},S.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1},S.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},S.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},S.regexp_eatZero=function(e){return 48===e.current()&&!Qe(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},S.regexp_eatControlEscape=function(e){var t=e.current();return 116===t?(e.lastIntValue=9,e.advance(),!0):110===t?(e.lastIntValue=10,e.advance(),!0):118===t?(e.lastIntValue=11,e.advance(),!0):102===t?(e.lastIntValue=12,e.advance(),!0):114===t&&(e.lastIntValue=13,e.advance(),!0)},S.regexp_eatControlLetter=function(e){var t=e.current();return!!Yt(t)&&(e.lastIntValue=t%32,e.advance(),!0)},S.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){void 0===t&&(t=!1);var n=e.pos,s=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(s&&i>=55296&&i<=56319){var r=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var a=e.lastIntValue;if(a>=56320&&a<=57343)return e.lastIntValue=1024*(i-55296)+(a-56320)+65536,!0}e.pos=r,e.lastIntValue=i}return!0}if(s&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&js(e.lastIntValue))return!0;s&&e.raise("Invalid unicode escape"),e.pos=n}return!1},S.regexp_eatIdentityEscape=function(e){if(e.switchU)return!!this.regexp_eatSyntaxCharacter(e)||!!e.eat(47)&&(e.lastIntValue=47,!0);var t=e.current();return!(99===t||e.switchN&&107===t)&&(e.lastIntValue=t,e.advance(),!0)},S.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do{e.lastIntValue=10*e.lastIntValue+(t-48),e.advance()}while((t=e.current())>=48&&t<=57);return!0}return!1};var Jt=0,ae=1,K=2;function Hs(e){return 100===e||68===e||115===e||83===e||119===e||87===e}function Zt(e){return Yt(e)||95===e}function Us(e){return Zt(e)||Qe(e)}function qs(e){return 33===e||e>=35&&e<=38||e>=42&&e<=44||46===e||e>=58&&e<=64||94===e||96===e||126===e}function zs(e){return 40===e||41===e||45===e||47===e||e>=91&&e<=93||e>=123&&e<=125}function Xs(e){return 33===e||35===e||37===e||38===e||44===e||45===e||e>=58&&e<=62||64===e||96===e||126===e}function Qe(e){return e>=48&&e<=57}function es(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function ts(e){return e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e-48}function ss(e){return e>=48&&e<=55}S.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(Hs(t))return e.lastIntValue=-1,e.advance(),ae;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=80===t)||112===t)){var s;if(e.lastIntValue=-1,e.advance(),e.eat(123)&&(s=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&s===K&&e.raise("Invalid property name"),s;e.raise("Invalid property name")}return Jt},S.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var s=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,s),ae}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return Jt},S.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){we(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")},S.regexp_validateUnicodePropertyNameOrValue=function(e,t){return e.unicodeProperties.binary.test(t)?ae:e.switchV&&e.unicodeProperties.binaryOfStrings.test(t)?K:void e.raise("Invalid property name")},S.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";Zt(t=e.current());)e.lastStringValue+=re(t),e.advance();return""!==e.lastStringValue},S.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";Us(t=e.current());)e.lastStringValue+=re(t),e.advance();return""!==e.lastStringValue},S.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},S.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&n===K&&e.raise("Negated character class may contain strings"),!0}return!1},S.regexp_classContents=function(e){return 93===e.current()?ae:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),ae)},S.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(-1===t||-1===n)&&e.raise("Invalid character class"),-1!==t&&-1!==n&&t>n&&e.raise("Range out of order in character class")}}},S.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(99===n||ss(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var s=e.current();return 93!==s&&(e.lastIntValue=s,e.advance(),!0)},S.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},S.regexp_classSetExpression=function(e){var t,n=ae;if(!this.regexp_eatClassSetRange(e))if(t=this.regexp_eatClassSetOperand(e)){t===K&&(n=K);for(var s=e.pos;e.eatChars([38,38]);)38!==e.current()&&(t=this.regexp_eatClassSetOperand(e))?t!==K&&(n=ae):e.raise("Invalid character in character class");if(s!==e.pos)return n;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(s!==e.pos)return n}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(!(t=this.regexp_eatClassSetOperand(e)))return n;t===K&&(n=K)}},S.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var s=e.lastIntValue;return-1!==n&&-1!==s&&n>s&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1},S.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?ae:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},S.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),s=this.regexp_classContents(e);if(e.eat(93))return n&&s===K&&e.raise("Negated character class may contain strings"),s;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},S.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise("Invalid escape");e.pos=t}return null},S.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===K&&(t=K);return t},S.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return 1===t?ae:K},S.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return!(!this.regexp_eatCharacterEscape(e)&&!this.regexp_eatClassSetReservedPunctuator(e))||(e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1));var n=e.current();return!(n<0||n===e.lookahead()&&qs(n)||zs(n))&&(e.advance(),e.lastIntValue=n,!0)},S.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return!!Xs(t)&&(e.lastIntValue=t,e.advance(),!0)},S.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!Qe(t)&&95!==t)&&(e.lastIntValue=t%32,e.advance(),!0)},S.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1},S.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Qe(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t},S.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;es(n=e.current());)e.lastIntValue=16*e.lastIntValue+ts(n),e.advance();return e.pos!==t},S.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=64*t+8*n+e.lastIntValue:e.lastIntValue=8*t+n}else e.lastIntValue=t;return!0}return!1},S.regexp_eatOctalDigit=function(e){var t=e.current();return ss(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)},S.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var s=0;s<t;++s){var i=e.current();if(!es(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+ts(i),e.advance()}return!0};var dt=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new qe(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},A=F.prototype;function Ks(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function ns(e){return"function"!=typeof BigInt?null:BigInt(e.replace(/_/g,""))}A.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new dt(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 dt(this)},typeof Symbol<"u"&&(A[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===h.eof,value:t}}}}),A.nextToken=function(){var e=this.curContext();return(!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length?this.finishToken(h.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},A.readToken=function(e){return te(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},A.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888},A.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(-1===n&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var s=void 0,i=t;(s=Pt(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=s;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},A.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),s=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!Te(s);)s=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},A.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:10===this.input.charCodeAt(this.pos+1)&&++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(!(e>8&&e<14||e>=5760&&At.test(String.fromCharCode(e))))break e;++this.pos}}},A.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},A.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===e&&46===t?(this.pos+=3,this.finishToken(h.ellipsis)):(++this.pos,this.finishToken(h.dot))},A.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===e?this.finishOp(h.assign,2):this.finishOp(h.slash,1)},A.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,s=42===e?h.star:h.modulo;return this.options.ecmaVersion>=7&&42===e&&42===t&&(++n,s=h.starstar,t=this.input.charCodeAt(this.pos+2)),61===t?this.finishOp(h.assign,n+1):this.finishOp(s,n)},A.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12)if(61===this.input.charCodeAt(this.pos+2))return this.finishOp(h.assign,3);return this.finishOp(124===e?h.logicalOR:h.logicalAND,2)}return 61===t?this.finishOp(h.assign,2):this.finishOp(124===e?h.bitwiseOR:h.bitwiseAND,1)},A.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(h.assign,2):this.finishOp(h.bitwiseXOR,1)},A.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?45!==t||this.inModule||62!==this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!H.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(h.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===t?this.finishOp(h.assign,2):this.finishOp(h.plusMin,1)},A.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=62===e&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+n)?this.finishOp(h.assign,n+1):this.finishOp(h.bitShift,n)):33!==t||60!==e||this.inModule||45!==this.input.charCodeAt(this.pos+2)||45!==this.input.charCodeAt(this.pos+3)?(61===t&&(n=2),this.finishOp(h.relational,n)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},A.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(h.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===e&&62===t&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(h.arrow)):this.finishOp(61===e?h.eq:h.prefix,1)},A.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(46===t){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(h.questionDot,2)}if(63===t){if(e>=12)if(61===this.input.charCodeAt(this.pos+2))return this.finishOp(h.assign,3);return this.finishOp(h.coalesce,2)}}return this.finishOp(h.question,1)},A.readToken_numberSign=function(){var e=35;if(this.options.ecmaVersion>=13&&(++this.pos,te(e=this.fullCharCodeAtPos(),!0)||92===e))return this.finishToken(h.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+re(e)+"'")},A.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(h.parenL);case 41:return++this.pos,this.finishToken(h.parenR);case 59:return++this.pos,this.finishToken(h.semi);case 44:return++this.pos,this.finishToken(h.comma);case 91:return++this.pos,this.finishToken(h.bracketL);case 93:return++this.pos,this.finishToken(h.bracketR);case 123:return++this.pos,this.finishToken(h.braceL);case 125:return++this.pos,this.finishToken(h.braceR);case 58:return++this.pos,this.finishToken(h.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(h.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(120===t||88===t)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===t||79===t)return this.readRadixNumber(8);if(98===t||66===t)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(h.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+re(e)+"'")},A.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},A.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var s=this.input.charAt(this.pos);if(H.test(s)&&this.raise(n,"Unterminated regular expression"),e)e=!1;else{if("["===s)t=!0;else if("]"===s&&t)t=!1;else if("/"===s&&!t)break;e="\\"===s}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var r=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(r);var o=this.regexpState||(this.regexpState=new ne(this));o.reset(n,i,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var c=null;try{c=new RegExp(i,a)}catch{}return this.finishToken(h.regexp,{pattern:i,flags:a,value:c})},A.readInt=function(e,t,n){for(var s=this.options.ecmaVersion>=12&&void 0===t,i=n&&48===this.input.charCodeAt(this.pos),r=this.pos,a=0,o=0,c=0,h=t??1/0;c<h;++c,++this.pos){var l=this.input.charCodeAt(this.pos),p=void 0;if(s&&95===l)i&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),95===o&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),0===c&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=l;else{if((p=l>=97?l-97+10:l>=65?l-65+10:l>=48&&l<=57?l-48:1/0)>=e)break;o=l,a=a*e+p}}return s&&95===o&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===r||null!=t&&this.pos-r!==t?null:a},A.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return null==n&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&110===this.input.charCodeAt(this.pos)?(n=ns(this.input.slice(t,this.pos)),++this.pos):te(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,n)},A.readNumber=function(e){var t=this.pos;!e&&null===this.readInt(10,void 0,!0)&&this.raise(t,"Invalid number");var n=this.pos-t>=2&&48===this.input.charCodeAt(t);n&&this.strict&&this.raise(t,"Invalid number");var s=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&110===s){var i=ns(this.input.slice(t,this.pos));return++this.pos,te(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),46===s&&!n&&(++this.pos,this.readInt(10),s=this.input.charCodeAt(this.pos)),(69===s||101===s)&&!n&&((43===(s=this.input.charCodeAt(++this.pos))||45===s)&&++this.pos,null===this.readInt(10)&&this.raise(t,"Invalid number")),te(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var r=Ks(this.input.slice(t,this.pos),n);return this.finishToken(h.num,r)},A.readCodePoint=function(){var e;if(123===this.input.charCodeAt(this.pos)){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(e){for(var t="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var s=this.input.charCodeAt(this.pos);if(s===e)break;92===s?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):8232===s||8233===s?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Te(s)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(h.string,t)};var is={};A.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==is)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},A.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw is;this.raise(e,t)},A.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(96===n||36===n&&123===this.input.charCodeAt(this.pos+1))return this.pos!==this.start||this.type!==h.template&&this.type!==h.invalidTemplate?(e+=this.input.slice(t,this.pos),this.finishToken(h.template,e)):36===n?(this.pos+=2,this.finishToken(h.dollarBraceL)):(++this.pos,this.finishToken(h.backQuote));if(92===n)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Te(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(n)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=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(h.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":"\n"===this.input[this.pos+1]&&++this.pos;case"\n":case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1}this.raise(this.start,"Unterminated template")},A.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return"\n";case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return re(this.readCodePoint());case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var s=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(s,8);return i>255&&(s=s.slice(0,-1),i=parseInt(s,8)),this.pos+=s.length-1,t=this.input.charCodeAt(this.pos),("0"!==s||56===t||57===t)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-s.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(i)}return Te(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},A.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return null===n&&this.invalidStringToken(t,"Bad character escape sequence"),n},A.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,s=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(pe(i,s))this.pos+=i<=65535?1:2;else{if(92!==i)break;this.containsEsc=!0,e+=this.input.slice(n,this.pos);var r=this.pos;117!==this.input.charCodeAt(++this.pos)&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(t?te:pe)(a,s)||this.invalidStringToken(r,"Invalid Unicode escape"),e+=re(a),n=this.pos}t=!1}return e+this.input.slice(n,this.pos)},A.readWord=function(){var e=this.readWord1(),t=h.name;return this.keywords.test(e)&&(t=ct[e]),this.finishToken(t,e)};var Gs="8.15.0";function D(e,t){return F.parse(e,t)}function U(e,t,n,s,i){n||(n=b),function e(s,i,r){var a=r||s.type;n[a](s,i,e),t[a]&&t[a](s,i)}(e,s,i)}function vt(e,t,n,s,i){var r=[];n||(n=b),function e(s,i,a){var o=a||s.type,c=s!==r[r.length-1];c&&r.push(s),n[o](s,i,e),t[o]&&t[o](s,i||r,r),c&&r.pop()}(e,s,i)}function mt(e,t,n){n(e,t)}function ye(e,t,n){}F.acorn={Parser:F,version:Gs,defaultOptions:tt,Position:ke,SourceLocation:qe,getLineInfo:Nt,Node:Ge,TokenType:N,tokTypes:h,keywordTypes:ct,TokContext:J,tokContexts:O,isIdentifierChar:pe,isIdentifierStart:te,Token:dt,isNewLine:Te,lineBreak:H,lineBreakG:xs,nonASCIIwhitespace:At};var b={};b.Program=b.BlockStatement=b.StaticBlock=function(e,t,n){for(var s=0,i=e.body;s<i.length;s+=1){n(i[s],t,"Statement")}},b.Statement=mt,b.EmptyStatement=ye,b.ExpressionStatement=b.ParenthesizedExpression=b.ChainExpression=function(e,t,n){return n(e.expression,t,"Expression")},b.IfStatement=function(e,t,n){n(e.test,t,"Expression"),n(e.consequent,t,"Statement"),e.alternate&&n(e.alternate,t,"Statement")},b.LabeledStatement=function(e,t,n){return n(e.body,t,"Statement")},b.BreakStatement=b.ContinueStatement=ye,b.WithStatement=function(e,t,n){n(e.object,t,"Expression"),n(e.body,t,"Statement")},b.SwitchStatement=function(e,t,n){n(e.discriminant,t,"Expression");for(var s=0,i=e.cases;s<i.length;s+=1){n(i[s],t)}},b.SwitchCase=function(e,t,n){e.test&&n(e.test,t,"Expression");for(var s=0,i=e.consequent;s<i.length;s+=1){n(i[s],t,"Statement")}},b.ReturnStatement=b.YieldExpression=b.AwaitExpression=function(e,t,n){e.argument&&n(e.argument,t,"Expression")},b.ThrowStatement=b.SpreadElement=function(e,t,n){return n(e.argument,t,"Expression")},b.TryStatement=function(e,t,n){n(e.block,t,"Statement"),e.handler&&n(e.handler,t),e.finalizer&&n(e.finalizer,t,"Statement")},b.CatchClause=function(e,t,n){e.param&&n(e.param,t,"Pattern"),n(e.body,t,"Statement")},b.WhileStatement=b.DoWhileStatement=function(e,t,n){n(e.test,t,"Expression"),n(e.body,t,"Statement")},b.ForStatement=function(e,t,n){e.init&&n(e.init,t,"ForInit"),e.test&&n(e.test,t,"Expression"),e.update&&n(e.update,t,"Expression"),n(e.body,t,"Statement")},b.ForInStatement=b.ForOfStatement=function(e,t,n){n(e.left,t,"ForInit"),n(e.right,t,"Expression"),n(e.body,t,"Statement")},b.ForInit=function(e,t,n){"VariableDeclaration"===e.type?n(e,t):n(e,t,"Expression")},b.DebuggerStatement=ye,b.FunctionDeclaration=function(e,t,n){return n(e,t,"Function")},b.VariableDeclaration=function(e,t,n){for(var s=0,i=e.declarations;s<i.length;s+=1){n(i[s],t)}},b.VariableDeclarator=function(e,t,n){n(e.id,t,"Pattern"),e.init&&n(e.init,t,"Expression")},b.Function=function(e,t,n){e.id&&n(e.id,t,"Pattern");for(var s=0,i=e.params;s<i.length;s+=1){n(i[s],t,"Pattern")}n(e.body,t,e.expression?"Expression":"Statement")},b.Pattern=function(e,t,n){"Identifier"===e.type?n(e,t,"VariablePattern"):"MemberExpression"===e.type?n(e,t,"MemberPattern"):n(e,t)},b.VariablePattern=ye,b.MemberPattern=mt,b.RestElement=function(e,t,n){return n(e.argument,t,"Pattern")},b.ArrayPattern=function(e,t,n){for(var s=0,i=e.elements;s<i.length;s+=1){var r=i[s];r&&n(r,t,"Pattern")}},b.ObjectPattern=function(e,t,n){for(var s=0,i=e.properties;s<i.length;s+=1){var r=i[s];"Property"===r.type?(r.computed&&n(r.key,t,"Expression"),n(r.value,t,"Pattern")):"RestElement"===r.type&&n(r.argument,t,"Pattern")}},b.Expression=mt,b.ThisExpression=b.Super=b.MetaProperty=ye,b.ArrayExpression=function(e,t,n){for(var s=0,i=e.elements;s<i.length;s+=1){var r=i[s];r&&n(r,t,"Expression")}},b.ObjectExpression=function(e,t,n){for(var s=0,i=e.properties;s<i.length;s+=1){n(i[s],t)}},b.FunctionExpression=b.ArrowFunctionExpression=b.FunctionDeclaration,b.SequenceExpression=function(e,t,n){for(var s=0,i=e.expressions;s<i.length;s+=1){n(i[s],t,"Expression")}},b.TemplateLiteral=function(e,t,n){for(var s=0,i=e.quasis;s<i.length;s+=1){n(i[s],t)}for(var r=0,a=e.expressions;r<a.length;r+=1){n(a[r],t,"Expression")}},b.TemplateElement=ye,b.UnaryExpression=b.UpdateExpression=function(e,t,n){n(e.argument,t,"Expression")},b.BinaryExpression=b.LogicalExpression=function(e,t,n){n(e.left,t,"Expression"),n(e.right,t,"Expression")},b.AssignmentExpression=b.AssignmentPattern=function(e,t,n){n(e.left,t,"Pattern"),n(e.right,t,"Expression")},b.ConditionalExpression=function(e,t,n){n(e.test,t,"Expression"),n(e.consequent,t,"Expression"),n(e.alternate,t,"Expression")},b.NewExpression=b.CallExpression=function(e,t,n){if(n(e.callee,t,"Expression"),e.arguments)for(var s=0,i=e.arguments;s<i.length;s+=1){n(i[s],t,"Expression")}},b.MemberExpression=function(e,t,n){n(e.object,t,"Expression"),e.computed&&n(e.property,t,"Expression")},b.ExportNamedDeclaration=b.ExportDefaultDeclaration=function(e,t,n){e.declaration&&n(e.declaration,t,"ExportNamedDeclaration"===e.type||e.declaration.id?"Statement":"Expression"),e.source&&n(e.source,t,"Expression")},b.ExportAllDeclaration=function(e,t,n){e.exported&&n(e.exported,t),n(e.source,t,"Expression")},b.ImportDeclaration=function(e,t,n){for(var s=0,i=e.specifiers;s<i.length;s+=1){n(i[s],t)}n(e.source,t,"Expression")},b.ImportExpression=function(e,t,n){n(e.source,t,"Expression")},b.ImportSpecifier=b.ImportDefaultSpecifier=b.ImportNamespaceSpecifier=b.Identifier=b.PrivateIdentifier=b.Literal=ye,b.TaggedTemplateExpression=function(e,t,n){n(e.tag,t,"Expression"),n(e.quasi,t,"Expression")},b.ClassDeclaration=b.ClassExpression=function(e,t,n){return n(e,t,"Class")},b.Class=function(e,t,n){e.id&&n(e.id,t,"Pattern"),e.superClass&&n(e.superClass,t,"Expression"),n(e.body,t)},b.ClassBody=function(e,t,n){for(var s=0,i=e.body;s<i.length;s+=1){n(i[s],t)}},b.MethodDefinition=b.PropertyDefinition=b.Property=function(e,t,n){e.computed&&n(e.key,t,"Expression"),e.value&&n(e.value,t,"Expression")};class Qs{constructor(){d(this,"portals",new Map),d(this,"portalCounter",0),d(this,"componentManager"),d(this,"domBindingManager"),d(this,"cleanupObserver"),d(this,"stateManager"),d(this,"pphpInstance"),this.cleanupObserver=new MutationObserver((e=>{this.handleMutations(e)})),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}setDependencies(e,t,n,s){this.componentManager=e,this.domBindingManager=t,this.stateManager=n,this.pphpInstance=s}createPortal(e,t,n){var s;const i="string"==typeof t?document.querySelector(t):t;if(!i)throw new Error(`Portal container not found: ${t}`);const r=(null==(s=this.componentManager)?void 0:s.getCurrentComponent())||"app",a=(null==n?void 0:n.key)||`portal_${++this.portalCounter}_${Date.now()}`;this.portals.has(a)&&this.removePortal(a);const o={id:a,content:e,container:i,component:r};return this.portals.set(a,o),this.renderPortalWithHydration(o,n,a),a}async renderPortalWithHydration(e,t,n){if(this.componentManager&&this.domBindingManager)try{await this.renderPortal(e,t),await new Promise((e=>requestAnimationFrame(e))),this.domBindingManager.processPendingBindings(),await new Promise((e=>{var t;null==(t=this.stateManager)||t.onDOMUpdateComplete((()=>{e(void 0)}))})),this.pphpInstance&&this.pphpInstance.markPortalHydrated&&this.pphpInstance.markPortalHydrated(n),null!=t&&t.onMount&&t.onMount(e.container)}catch(e){console.error("Portal hydration error:",e),this.pphpInstance&&this.pphpInstance.markPortalHydrated&&this.pphpInstance.markPortalHydrated(n)}else console.warn("PortalManager dependencies not set")}renderPortal(e,t){return new Promise(((t,n)=>{if(!this.componentManager||!this.domBindingManager)return console.warn("PortalManager dependencies not set"),void n(new Error("Dependencies not set"));try{let n;if(e.renderedContent&&e.renderedContent.parentElement&&e.renderedContent.parentElement.removeChild(e.renderedContent),"string"==typeof e.content){const t=document.createElement("template");if(t.innerHTML=e.content.trim(),n=t.content.firstElementChild,!n)throw new Error("Invalid HTML string for portal content")}else if(e.content instanceof DocumentFragment){const t=document.createElement("div");if(t.appendChild(e.content.cloneNode(!0)),n=t.firstElementChild,!n)throw new Error("DocumentFragment must contain at least one element")}else n=e.content;n.setAttribute("data-portal-id",e.id),n.setAttribute("data-portal-component",e.component),e.container.appendChild(n),e.renderedContent=n;const s=[...this.componentManager.componentStack];try{this.componentManager.executePhpScripts(n),this.domBindingManager.processElement(n,!0);const s=n.querySelectorAll("template[pp-for]"),i=this.domBindingManager.loopManager;i&&(s.forEach((t=>{var n,s;const r=t;if(null!=(n=i.loopBindings)&&n.has(r))if("function"==typeof i.updateTemplateParent)i.updateTemplateParent(r);else{const t=i.loopBindings.get(r);t&&(null==(s=t.subscriptionIds)||s.forEach((e=>{var t;null==(t=this.stateManager)||t.removeSubscription(e)})),i.loopBindings.delete(r)),i.processTemplate(r,e.component)}else i.queueTemplate(r,e.component)})),i.processPendingTemplates()),this.domBindingManager.processPendingBindings(),t()}finally{this.componentManager.componentStack=s}}catch(t){console.error("Portal rendering error:",t),this.portals.delete(e.id),n(t)}}))}removePortal(e){const t=this.portals.get(e);if(!t)return!1;try{return t.cleanup&&t.cleanup(),t.renderedContent&&this.cleanupPortalElement(t.renderedContent),t.renderedContent&&t.renderedContent.parentElement&&t.renderedContent.parentElement.removeChild(t.renderedContent),this.portals.delete(e),!0}catch(e){return console.error("Portal cleanup error:",e),!1}}cleanupPortalElement(e){var t;if(this.stateManager){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let s=e;do{s.nodeType===Node.ELEMENT_NODE&&(null==(t=this.stateManager.subscriptionManager)||t.cleanupElement(s))}while(s=n.nextNode())}}updatePortal(e,t,n){const s=this.portals.get(e);return!!s&&(s.content=t,this.renderPortal(s,n),!0)}getPortal(e){return this.portals.get(e)}hasPortal(e){return this.portals.has(e)}getAllPortals(){return Array.from(this.portals.values())}handleMutations(e){for(const t of e)"childList"===t.type&&t.removedNodes.forEach((e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;for(const[e,n]of this.portals)(n.container===t||t.contains(n.container))&&this.removePortal(e)}}))}destroy(){for(const e of Array.from(this.portals.keys()))this.removePortal(e);this.cleanupObserver.disconnect(),this.portals.clear()}}const Z=class e{constructor(){d(this,"stateVariables",new Set)}transformRefDeclarations(e){try{const t=D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{VariableDeclarator:t=>{if(this.isRefDeclaration(t)){const n=t.id.name,i=this.findStatementEnd(e,t.end);s.push({start:i,end:i,replacement:`; this.${n} = ${n}`})}}}),s.sort(((e,t)=>t.start-e.start)).forEach((e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)})),n}catch(t){return console.error("Ref transformation error:",t),e}}isRefDeclaration(e){var t,n,s,i,r;return"Identifier"===(null==(t=e.id)?void 0:t.type)&&"CallExpression"===(null==(n=e.init)?void 0:n.type)&&"MemberExpression"===(null==(s=e.init.callee)?void 0:s.type)&&"Identifier"===(null==(i=e.init.callee.object)?void 0:i.type)&&"pp"===e.init.callee.object.name&&"Identifier"===(null==(r=e.init.callee.property)?void 0:r.type)&&"ref"===e.init.callee.property.name}findStatementEnd(e,t){let n=t;for(;n<e.length&&";"!==e[n]&&"\n"!==e[n];)n++;return n}static getInstance(){return e.instance||(e.instance=new e),e.instance}extractFunctionNames(e){const t=[];try{U(D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),{FunctionDeclaration:e=>{var n;"Identifier"===(null==(n=e.id)?void 0:n.type)&&t.push(e.id.name)},VariableDeclarator:e=>{var n,s,i;"Identifier"===(null==(n=e.id)?void 0:n.type)&&("ArrowFunctionExpression"===(null==(s=e.init)?void 0:s.type)||"FunctionExpression"===(null==(i=e.init)?void 0:i.type))&&t.push(e.id.name)},AssignmentExpression:e=>{var n,s,i;"Identifier"===(null==(n=e.left)?void 0:n.type)&&("ArrowFunctionExpression"===(null==(s=e.right)?void 0:s.type)||"FunctionExpression"===(null==(i=e.right)?void 0:i.type))&&t.push(e.left.name)}})}catch(e){console.error("AST function extraction error:",e)}return Array.from(new Set(t))}transformEffectDeclarations(e){try{const t=D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{CallExpression:t=>{const n=this.transformEffectCall(t,e);n&&s.push(n)}}),s.sort(((e,t)=>t.start-e.start)).forEach((e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)})),n}catch(t){return console.error("Effect transformation error:",t),e}}transformEffectCall(e,t){if(!this.isPPEffectCall(e))return null;const n=e.arguments;if(n.length<2)return null;const s=n[1];if("ArrayExpression"!==s.type||!s.elements.some((e=>!!e&&("Identifier"===e.type||"MemberExpression"===e.type))))return null;const i=s.elements.map((e=>e?"Identifier"===e.type?`"${e.name}"`:"MemberExpression"===e.type?`"${this.extractMemberExpression(e,t)}"`:t.slice(e.start,e.end):"null")),r=t.slice(n[0].start,n[0].end),a=n.slice(2).map((e=>t.slice(e.start,e.end))).join(", "),o=`[${i.join(", ")}]`,c=a?`pp.effect(${r}, ${o}, ${a})`:`pp.effect(${r}, ${o})`;return{start:e.start,end:e.end,replacement:c}}extractMemberExpression(e,t){if("MemberExpression"!==e.type)return"Identifier"===e.type?e.name:t.slice(e.start,e.end);const n=this.extractMemberExpression(e.object,t);if(e.computed){return`${n}[${t.slice(e.property.start,e.property.end)}]`}return`${n}.${e.property.name||t.slice(e.property.start,e.property.end)}`}isPPEffectCall(e){var t,n,s;return"MemberExpression"===(null==(t=e.callee)?void 0:t.type)&&"Identifier"===(null==(n=e.callee.object)?void 0:n.type)&&"pp"===e.callee.object.name&&"Identifier"===(null==(s=e.callee.property)?void 0:s.type)&&"effect"===e.callee.property.name}transformStateDeclarations(e,t){this.stateVariables.clear(),t&&t.forEach((e=>this.stateVariables.add(e)));let n=this.transformStateDeclarationsOnly(e);return n=this.transformEffectDeclarations(n),n=this.transformRefDeclarations(n),n=this.transformUnsupportedStateUsages(n),n}transformStateDeclarationsOnlyOriginal(e){try{const t=D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{VariableDeclarator:t=>{const n=this.transformStateDeclarator(t,e);n&&s.push(n)}}),s.sort(((e,t)=>t.start-e.start)).forEach((e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)})),n}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=D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});this.collectStateVariables(t);let n=this.transformShorthandProperties(e);const s=D(n,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),i=[],r=new Set,a=new Map;vt(s,{VariableDeclarator:(e,t)=>{var n;if(this.isStateDeclaration(e))return;let s=null;for(let e=t.length-1;e>=0;e--){const n=t[e];if("FunctionExpression"===n.type||"ArrowFunctionExpression"===n.type||"FunctionDeclaration"===n.type||"BlockStatement"===n.type){s=n;break}}s&&"Identifier"===(null==(n=e.id)?void 0:n.type)&&(a.has(s)||a.set(s,new Set),a.get(s).add(e.id.name),r.add(e.id.name))}});const o=(e,t)=>{for(let n=t.length-1;n>=0;n--){const s=t[n],i=a.get(s);if(i&&i.has(e))return!0}return!1},c=(e,t)=>!(e&&"Identifier"===e.type&&this.stateVariables.has(e.name)&&!r.has(e.name)&&!this.alreadyHasValue(e,t));return U(s,{MemberExpression:e=>{var t;"Identifier"===(null==(t=e.object)?void 0:t.type)&&this.stateVariables.has(e.object.name)&&!r.has(e.object.name)&&!this.alreadyHasValue(e.object,n)&&i.push({start:e.object.start,end:e.object.end,replacement:`${e.object.name}.value`})},SpreadElement:e=>{if(!c(e.argument,n)){const t=this.transformSpreadElement(e,n);t&&i.push(t)}},UnaryExpression:e=>{if(!c(e.argument,n)){const t=this.transformUnaryExpression(e,n);t&&i.push(t)}},BinaryExpression:e=>{const t=c(e.left,n),s=c(e.right,n);if(!t||!s){const t=this.transformBinaryExpression(e,n);t&&i.push(t)}},LogicalExpression:e=>{const t=c(e.left,n),s=c(e.right,n);if(!t||!s){const t=this.transformLogicalExpression(e,n);t&&i.push(t)}},ConditionalExpression:e=>{const t=this.transformConditionalExpression(e,n);t&&i.push(t)},IfStatement:e=>{if(!c(e.test,n)){const t=this.transformIfStatement(e,n);t&&i.push(t)}},WhileStatement:e=>{if(!c(e.test,n)){const t=this.transformWhileStatement(e,n);t&&i.push(t)}},ForStatement:e=>{const t=this.transformForStatement(e,n);t&&i.push(t)},ReturnStatement:e=>{const t=this.transformReturnStatement(e,n);t&&i.push(t)},VariableDeclarator:e=>{const t=this.transformVariableDeclarator(e,n);t&&i.push(t)},AssignmentExpression:e=>{const t=this.transformAssignmentExpression(e,n);t&&i.push(t)},CallExpression:e=>{const t=this.transformGeneralCallExpression(e,n);t&&t.length>0&&i.push(...t)}}),vt(s,{Identifier:(e,t)=>{!this.stateVariables.has(e.name)||i.some((t=>e.start>=t.start&&e.end<=t.end))||o(e.name,t)||this.alreadyHasValue(e,n)||this.isPartOfStateDeclaration(e,t)||this.isPropertyName(e,t)||this.isMethodCallObject(e,t)||this.isPartOfPPCall(e,t)||this.isPartOfDestructuring(e,t)||i.push({start:e.start,end:e.end,replacement:`${e.name}.value`})}}),i.sort(((e,t)=>t.start-e.start)).forEach((e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)})),n=this.transformMultipleCallArguments(n,r),n}catch(t){return console.error("State usage transformation error:",t),e}}transformShorthandProperties(e){try{const t=D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{Property:e=>{var t;if(e.shorthand&&"Identifier"===(null==(t=e.key)?void 0:t.type)&&this.stateVariables.has(e.key.name)){const t=e.key.name,n=`${t}: ${t}.value`;s.push({start:e.start,end:e.end,replacement:n})}}}),s.sort(((e,t)=>t.start-e.start)).forEach((e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)})),n}catch(t){return console.error("Shorthand property transformation error:",t),e}}transformLogicalExpression(e,t){var n,s;return"Identifier"===(null==(n=e.left)?void 0:n.type)&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,t)?{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`}:"Identifier"===(null==(s=e.right)?void 0:s.type)&&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){var n,s,i;return"Identifier"===(null==(n=e.test)?void 0:n.type)&&this.stateVariables.has(e.test.name)&&!this.alreadyHasValue(e.test,t)?{start:e.test.start,end:e.test.end,replacement:`${e.test.name}.value`}:"Identifier"===(null==(s=e.consequent)?void 0:s.type)&&this.stateVariables.has(e.consequent.name)&&!this.alreadyHasValue(e.consequent,t)?{start:e.consequent.start,end:e.consequent.end,replacement:`${e.consequent.name}.value`}:"Identifier"===(null==(i=e.alternate)?void 0:i.type)&&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){var n,s,i;return this.isStateDeclaration(e)||"ArrayPattern"===(null==(n=e.id)?void 0:n.type)||"ObjectPattern"===(null==(s=e.id)?void 0:s.type)?null:"Identifier"===(null==(i=e.init)?void 0:i.type)&&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){var n,s,i;return"ArrayPattern"===(null==(n=e.left)?void 0:n.type)||"ObjectPattern"===(null==(s=e.left)?void 0:s.type)?null:"Identifier"===(null==(i=e.right)?void 0:i.type)&&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(t,n){var s,i;const r=n.slice(t.callee.start,t.callee.end);if("MemberExpression"===(null==(s=t.callee)?void 0:s.type)&&"Identifier"===(null==(i=t.callee.object)?void 0:i.type)&&this.stateVariables.has(t.callee.object.name))return[];if(this.isPPCall(t))return[];if(!e.isFunctionNeedingValueTransform(r)&&t.arguments.length>0){const e=[];for(const s of t.arguments)"Identifier"===s.type&&this.stateVariables.has(s.name)&&(this.alreadyHasValue(s,n)||e.push({start:s.start,end:s.end,replacement:`${s.name}.value`}));return e}return[]}static isFunctionNeedingValueTransform(e){if(this.FUNCTIONS_NEEDING_VALUE_TRANSFORM.has(e))return!0;const t=e.lastIndexOf(".");if(t>-1){const n=e.slice(t+1);if(this.FUNCTIONS_NEEDING_VALUE_TRANSFORM.has(n))return!0}return!1}transformExpressionNode(e,t){return"Identifier"===(null==e?void 0:e.type)&&this.stateVariables.has(e.name)&&!this.alreadyHasValue(e,t)?{start:e.start,end:e.end,replacement:`${e.name}.value`}:null}isPPCall(e){var t,n,s;return"MemberExpression"===(null==(t=e.callee)?void 0:t.type)&&"Identifier"===(null==(n=e.callee.object)?void 0:n.type)&&"pp"===e.callee.object.name&&"Identifier"===(null==(s=e.callee.property)?void 0:s.type)&&("state"===e.callee.property.name||"effect"===e.callee.property.name)}isPartOfStateDeclaration(e,t){var n,s;if(!t||!Array.isArray(t))return!1;for(const e of t)if("VariableDeclarator"===e.type&&"ArrayPattern"===(null==(n=e.id)?void 0:n.type)&&"CallExpression"===(null==(s=e.init)?void 0:s.type)&&this.isPPStateCall(e.init))return!0;return!1}isPropertyName(e,t){if(!t||0===t.length)return!1;const n=t[t.length-1];return!!("Property"===(null==n?void 0:n.type)&&n.key===e||"Property"===(null==n?void 0:n.type)&&n.shorthand&&n.value===e||"MemberExpression"===(null==n?void 0:n.type)&&n.property===e&&!n.computed)}isMethodCallObject(e,t){if(!t||0===t.length)return!1;const n=t[t.length-1];if("MemberExpression"===(null==n?void 0:n.type)&&n.object===e&&t.length>=2){const e=t[t.length-2];if("CallExpression"===(null==e?void 0:e.type)&&e.callee===n)return!0}return!1}isPartOfPPCall(e,t){var n,s,i;if(!t||!Array.isArray(t))return!1;for(const e of t)if("CallExpression"===e.type&&"MemberExpression"===(null==(n=e.callee)?void 0:n.type)&&"Identifier"===(null==(s=e.callee.object)?void 0:s.type)&&"pp"===e.callee.object.name&&"Identifier"===(null==(i=e.callee.property)?void 0:i.type)&&("state"===e.callee.property.name||"effect"===e.callee.property.name))return!0;return!1}isPartOfDestructuring(e,t){if(!t||!Array.isArray(t))return!1;for(let n=0;n<t.length;n++){const s=t[n];if("ArrayPattern"===s.type||"ObjectPattern"===s.type){if(n+1<t.length){const i=t[n+1];if("VariableDeclarator"===(null==i?void 0:i.type)&&i.id===s&&i.init===e)return!1}return!0}}return!1}collectStateVariables(e){U(e,{VariableDeclarator:e=>{if(this.isStateDeclaration(e)){const t=e.id.elements[0];"Identifier"===(null==t?void 0:t.type)&&this.stateVariables.add(t.name)}}})}isStateDeclaration(e){var t,n;return"ArrayPattern"===(null==(t=e.id)?void 0:t.type)&&"CallExpression"===(null==(n=e.init)?void 0:n.type)&&this.isPPStateCall(e.init)}transformSpreadElement(e,t){var n;return"Identifier"===(null==(n=e.argument)?void 0:n.type)&&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){var n;return"Identifier"===(null==(n=e.argument)?void 0:n.type)&&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){var n,s;if(["===","!==","==","!=",">","<",">=","<=","+","-","*","/","%","**","&","|","^","<<",">>",">>>","in","instanceof"].includes(e.operator)){if("Identifier"===(null==(n=e.left)?void 0:n.type)&&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("Identifier"===(null==(s=e.right)?void 0:s.type)&&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(t,n){try{const s=D(t,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=t;const r=[];return U(s,{CallExpression:t=>{const s=i.slice(t.callee.start,t.callee.end);if(e.isFunctionNeedingValueTransform(s)&&t.arguments.length>0)for(const e of t.arguments)if("Identifier"===e.type&&this.stateVariables.has(e.name)){if(n&&n.has(e.name))continue;this.alreadyHasValue(e,i)||r.push({start:e.start,end:e.end,replacement:`${e.name}.value`})}}}),r.sort(((e,t)=>t.start-e.start)).forEach((e=>{i=i.slice(0,e.start)+e.replacement+i.slice(e.end)})),i}catch(e){return console.error("Multiple call arguments transformation error:",e),t}}transformDestructuringAssignments(e){try{const t=D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return U(t,{VariableDeclarator:t=>{var n,i,r;this.isStateDeclaration(t)||("ArrayPattern"===(null==(n=t.id)?void 0:n.type)||"ObjectPattern"===(null==(i=t.id)?void 0:i.type))&&"Identifier"===(null==(r=t.init)?void 0:r.type)&&this.stateVariables.has(t.init.name)&&(this.alreadyHasValue(t.init,e)||s.push({start:t.init.start,end:t.init.end,replacement:`${t.init.name}.value`}))},AssignmentExpression:t=>{var n,i,r;("ArrayPattern"===(null==(n=t.left)?void 0:n.type)||"ObjectPattern"===(null==(i=t.left)?void 0:i.type))&&"Identifier"===(null==(r=t.right)?void 0:r.type)&&this.stateVariables.has(t.right.name)&&(this.alreadyHasValue(t.right,e)||s.push({start:t.right.start,end:t.right.end,replacement:`${t.right.name}.value`}))}}),s.sort(((e,t)=>t.start-e.start)).forEach((e=>{n=n.slice(0,e.start)+e.replacement+n.slice(e.end)})),n}catch(t){return console.error("Destructuring transformation error:",t),e}}alreadyHasValue(e,t){const n=e.end;return t.slice(n,n+6).startsWith(".value")}transformStateDeclarator(e,t){var n,s;if("ArrayPattern"!==(null==(n=e.id)?void 0:n.type)||"CallExpression"!==(null==(s=e.init)?void 0:s.type))return null;const i=e.init;if(!this.isPPStateCall(i))return null;const r=e.id.elements[0];if(!r||"Identifier"!==r.type)return null;const a=r.name,o=`set${this.capitalize(a)}`,c=e.id.elements[1];return"Identifier"===(null==c?void 0:c.type)&&c.name!==o&&console.warn(`Setter name mismatch: expected ${o}, got ${c.name}`),this.createTransformation(i,a,t)}isPPStateCall(e){var t,n,s;return"MemberExpression"===(null==(t=e.callee)?void 0:t.type)&&"Identifier"===(null==(n=e.callee.object)?void 0:n.type)&&"pp"===e.callee.object.name&&"Identifier"===(null==(s=e.callee.property)?void 0:s.type)&&"state"===e.callee.property.name}createTransformation(e,t,n){const s=e.arguments;if(0===s.length){const n=`pp.state("${t}")`;return{start:e.start,end:e.end,replacement:n}}const i=s[0];if("Literal"===i.type&&"string"==typeof i.value&&i.value===t)return null;if(1===s.length){const s=`pp.state("${t}", ${n.slice(i.start,i.end)})`;return{start:e.start,end:e.end,replacement:s}}const r=`pp.state("${t}", ${n.slice(e.arguments[0].start,e.arguments[e.arguments.length-1].end)})`;return{start:e.start,end:e.end,replacement:r}}looksLikeVariableName(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&e.length<=50&&!e.includes(" ")}extractStateDeclarations(e){const t=[];try{U(D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0}),{VariableDeclarator:n=>{const s=this.extractStateFromDeclarator(n,e);s&&t.push(s)}})}catch(e){console.error("State extraction error:",e)}return t}extractStateFromDeclarator(e,t){var n,s,i,r;if("ArrayPattern"!==(null==(n=e.id)?void 0:n.type)||"CallExpression"!==(null==(s=e.init)?void 0:s.type)||!this.isPPStateCall(e.init))return null;const a=e.id.elements[0],o=e.id.elements[1];if("Identifier"!==(null==a?void 0:a.type)||"Identifier"!==(null==o?void 0:o.type))return null;const c=e.init.arguments;let h,l=a.name;return c.length>=1&&("Literal"===c[0].type&&"string"==typeof c[0].value?this.looksLikeVariableName(c[0].value)?(l=c[0].value,c.length>=2&&(h=this.extractLiteralValue(c[1]))):(l=a.name,h=this.extractLiteralValue(c[0])):h=this.extractLiteralValue(c[0])),{variableName:a.name,setterName:o.name,stateKey:l,initialValue:h,line:(null==(i=e.loc)?void 0:i.start.line)||0,column:(null==(r=e.loc)?void 0:r.start.column)||0}}extractFunctionDeclarations(e){const t=[];try{U(D(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0}),{FunctionDeclaration:e=>{var n,s;"Identifier"===(null==(n=e.id)?void 0:n.type)&&t.push({name:e.id.name,type:"function",params:e.params.map((e=>"Identifier"===e.type?e.name:"")),line:(null==(s=e.loc)?void 0:s.start.line)||0})},VariableDeclarator:e=>{var n,s,i,r;if("Identifier"===(null==(n=e.id)?void 0:n.type)&&("ArrowFunctionExpression"===(null==(s=e.init)?void 0:s.type)||"FunctionExpression"===(null==(i=e.init)?void 0:i.type))){const n=e.init;t.push({name:e.id.name,type:"ArrowFunctionExpression"===n.type?"arrow":"function",params:n.params.map((e=>"Identifier"===e.type?e.name:"")),line:(null==(r=e.loc)?void 0:r.start.line)||0})}}})}catch(e){console.error("Function extraction error:",e)}return t}extractLiteralValue(e){if("Literal"===e.type)return e.value;"Identifier"===e.type&&e.name}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}};d(Z,"instance"),d(Z,"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"]));let Ne=Z;class Ys{constructor(e,t){d(this,"textNodeBindings",new Map),d(this,"expressionEvaluator"),d(this,"stateManager"),d(this,"componentManager"),d(this,"cleanupObserver"),d(this,"bindingCount",0),this.expressionEvaluator=e,this.stateManager=t,this.cleanupObserver=new MutationObserver((e=>{this.cleanupDetachedNodes(e)})),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}cleanupDetachedNodes(e){const t=[];for(const n of e)"childList"===n.type&&n.removedNodes.forEach((e=>{if(e.nodeType===Node.TEXT_NODE)t.push(e);else if(e.nodeType===Node.ELEMENT_NODE){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let s;for(;s=n.nextNode();)t.push(s)}}));Promise.resolve().then((()=>{t.forEach((e=>{document.contains(e)||this.cleanupTextNode(e)}))}))}processTextNode(e,t){if(this.shouldSkipTextNode(e))return;const n=k.findScope(e);let s;if(n)s="app"===n?"app":n;else{const n=e.parentElement;s=n?P.getContextComponent(n):t}const i=e.textContent||"",r=L.parse(i);if(!this.hasValidExpressions(r))return;const a=this.resolveComponentRootForElement(e,s),o=this.createTextNodeBinding(i,r,s,a);this.setupExpressionSubscriptions(e,r,s,a,o),this.textNodeBindings.set(e,o),this.bindingCount++,this.updateTextNode(e)}shouldSkipTextNode(e){return this.textNodeBindings.has(e)||P.isTextNodeInsideScript(e)||this.isInsideLoopItem(e)}hasValidExpressions(e){return e.some((e=>"expression"===e.type))}createTextNodeBinding(e,t,n,s){return{originalContent:e,expressions:t,subscriptionIds:[],component:n,componentElement:s}}setupExpressionSubscriptions(e,t,n,s,i){t.filter((e=>"expression"===e.type)).forEach((t=>{if(!t.expression)return;const r=`text_${Date.now()}_${Math.random()}`,a=this.expressionEvaluator.extractDependencies(t.expression,n,this.stateManager);if(s&&this.componentManager){const e=this.componentManager.getComponentPropDependencies(s,n);a.push(...e)}const o={id:r,selector:"",dependencies:new Set(a),callback:()=>{this.updateTextNode(e)},element:e.parentElement??void 0,component:n};this.stateManager.addSubscription(o),i.subscriptionIds.push(r)}))}updateTextNode(e){const t=this.textNodeBindings.get(e);if(!t||!e.parentElement)return;const n=this.resolveBindingComponentElement(e,t),s=this.buildEvaluationContext(e,t,n),i=this.evaluateExpressionsToText(t.expressions,s,t.component);this.applyTextUpdate(e,i)}resolveBindingComponentElement(e,t){let{componentElement:n}=t;return(!n||!document.contains(n))&&(n=this.resolveComponentRootForElement(e,t.component),t.componentElement=n),n}buildEvaluationContext(e,t,n){let s=this.componentManager.buildComponentContext(t.component);const i=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t.component}"]`);let r=!1;for(const e of i)if(this.componentManager.hasStoredProps(e)){const t=this.componentManager.evaluateProps(e);s={...s,...t},r=!0;break}if(!r){let t=e.parentElement;for(;t&&t!==document.body;){if(t.hasAttribute(g.ATTR_PREFIXES.COMPONENT)&&this.componentManager.hasStoredProps(t)){const e=this.componentManager.evaluateProps(t);s={...s,...e};break}t=t.parentElement}}return os(s)}evaluateExpressionsToText(e,t,n){let s="";for(const i of e)if("static"===i.type)s+=i.content;else if(i.expression)try{s+=Ce(this.expressionEvaluator.evaluateExpression(i.expression,t,n))}catch(e){console.error(`❌ Text binding evaluation error for "${i.expression}":`,e),console.error(`Component: ${n}`),console.error(`Available variables: [${Object.keys(t).join(", ")}]`),s+=""}return s}applyTextUpdate(e,t){e.textContent!==t&&(e.textContent=t)}isInsideLoopItem(e){var t,n,s;let i=e.parentElement;for(;i&&i!==document.body;){const e=i.previousSibling;if(e&&e.nodeType===Node.COMMENT_NODE&&null!=(t=e.textContent)&&t.startsWith("pp-for:"))return!0;let r=(null==(n=i.parentElement)?void 0:n.firstChild)||null;for(;r;){if(r.nodeType===Node.COMMENT_NODE&&null!=(s=r.textContent)&&s.startsWith("pp-for:")&&r!==i)return!0;r=r.nextSibling}i=i.parentElement}return!1}resolveComponentRootForElement(e,t){const n=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`);if(this.componentManager)for(const e of n)if(this.componentManager.hasStoredProps(e))return e;return n[0]||void 0}cleanupTextNode(e){const t=this.textNodeBindings.get(e);t&&(t.subscriptionIds.forEach((e=>{this.stateManager.removeSubscription(e)})),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()}}const le=class e{constructor(){d(this,"delegatedEvents",new Map),d(this,"elementHandlers",new WeakMap),d(this,"handlerCache",new G(200)),d(this,"componentManager"),d(this,"expressionEvaluator"),d(this,"loopManager"),d(this,"setupEvents",new Set)}static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}static getAllAvailableEvents(){if(e.eventCache)return e.eventCache;const t=new Set,n=["click","input","change","submit","focus","blur","keydown","keyup","mousedown","mouseup","mouseover","mouseout"];try{Object.getOwnPropertyNames(HTMLElement.prototype).filter((e=>e.startsWith("on")&&e.length>2)).map((e=>e.substring(2).toLowerCase())).forEach((e=>t.add(e)))}catch(e){console.warn("Could not get HTMLElement events:",e),n.forEach((e=>t.add(e)))}try{Object.getOwnPropertyNames(Document.prototype).filter((e=>e.startsWith("on")&&e.length>2)).map((e=>e.substring(2).toLowerCase())).forEach((e=>t.add(e)))}catch(e){console.warn("Could not get Document events:",e)}try{Object.getOwnPropertyNames(Window.prototype).filter((e=>e.startsWith("on")&&e.length>2)).map((e=>e.substring(2).toLowerCase())).forEach((e=>t.add(e)))}catch(e){console.warn("Could not get Window events:",e)}try{Object.getOwnPropertyNames(Element.prototype).filter((e=>e.startsWith("on")&&e.length>2)).map((e=>e.substring(2).toLowerCase())).forEach((e=>t.add(e)))}catch(e){console.warn("Could not get Element events:",e)}return new Set(["beforeunload","unload","pagehide","pageshow","popstate","hashchange","storage","message","messageerror","offline","online","languagechange","rejectionhandled","unhandledrejection","afterprint","beforeprint","devicemotion","deviceorientation","deviceorientationabsolute"]).forEach((e=>t.delete(e))),e.eventCache=t,t}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),("focusin"===e||"focusout"===e)&&(t.capture=!1),t}isEventSupported(t){return e.getAllAvailableEvents().has(t.toLowerCase())}getAllSupportedEvents(){return Array.from(e.getAllAvailableEvents()).sort()}getDelegatedEvents(){return Array.from(this.delegatedEvents.keys()).sort()}setDependencies(e,t,n,s){this.componentManager=e,this.expressionEvaluator=t,this.loopManager=s}createDelegatedListener(e){return t=>{const n=t.target;if(!n)return;const s=this.findHandler(n,e);s&&this.executeHandler(s.handler,s.element,t)}}registerEventHandler(e,t,n,s){const i=t.toLowerCase();if(this.ensureEventSetup(i),!this.isEventSupported(i))return;const r=s;this.elementHandlers.has(e)||this.elementHandlers.set(e,new Map);const a={code:n,component:r};this.elementHandlers.get(e).set(i,a);const o=this.delegatedEvents.get(i);o?o.elements.add(e):(console.warn(`⚠️ No delegated listener for ${i}, attaching directly`),this.attachDirectListener(e,i,a))}ensureEventSetup(e){if(!this.setupEvents.has(e)){if(!this.isEventSupported(e))return void console.warn(`⚠️ Attempting to setup unsupported event: ${e}`);try{const t=this.createDelegatedListener(e),n=this.getEventOptions(e);document.addEventListener(e,t,n),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 n=e;for(;n;){const e=this.elementHandlers.get(n);if(null!=e&&e.has(t))return{handler:e.get(t),element:n};n=n.parentElement}return null}compileHandler(e,t){const n=`${t}:${e}`;if(this.handlerCache.has(n))return this.handlerCache.get(n);let s=e;e.includes("this")&&(s=s.replace(/\bthis\b/g,"thisElement")),e.includes("event")&&(s=s.replace(/\bevent\b/g,"eventObject"));const i=new Function("eventObject","thisElement","context",`\n try {\n with(context) {\n ${s}\n }\n } catch(error) {\n console.error('Event handler execution error:', error);\n console.error('Handler code:', ${JSON.stringify(e)});\n console.error('Component:', '${t}');\n console.error('Available context keys:', Object.keys(context));\n }\n `);return this.handlerCache.set(n,i),i}executeHandler(e,t,n){var s;if(this.componentManager&&this.expressionEvaluator)try{const{effectiveComponent:i,useStrictScope:r,scopedComponent:a,actualElementComponent:o}=this.resolveEffectiveComponent(t,e),c=this.locateComponentElement(t,i,o),h=this.findNearestComponentWithProps(t);let l=r?this.buildContextStrict(a,i,c,t):this.buildContextNonStrict(i,c,h);l=os(l),l=this.mergeLoopContext(t,l),this.ensureCompiled(e),null==(s=e.compiledFn)||s.call(e,n,t,l)}catch(t){console.error("💥 Event handler execution failed:",t),console.error("Handler code:",e.code),console.error("Handler component:",e.component)}else console.warn("EventDelegationManager dependencies not set")}resolveEffectiveComponent(e,t){const n=k.findScope(e),s=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);return n?{effectiveComponent:"app"===n?"app":n,useStrictScope:!0,scopedComponent:n,actualElementComponent:s}:t.component?{effectiveComponent:t.component,useStrictScope:!1,scopedComponent:null,actualElementComponent:s}:s?{effectiveComponent:s,useStrictScope:!1,scopedComponent:null,actualElementComponent:s}:{effectiveComponent:"app",useStrictScope:!1,scopedComponent:null,actualElementComponent:null}}locateComponentElement(e,t,n){if(n&&n===t)return e;let s=e.parentElement;for(;s&&s!==document.body;){if(s.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return s;s=s.parentElement}for(s=e.parentElement;s&&s!==document.body;){if(s.getAttribute(g.ATTR_PREFIXES.COMPONENT))return s;s=s.parentElement}const i=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const e of i)if(this.componentManager.hasStoredProps(e))return e;return i.length>0?i[0]:null}findNearestComponentWithProps(e){let t=e.parentElement;for(;t&&t!==document.body;){if(t.hasAttribute(g.ATTR_PREFIXES.COMPONENT)&&this.componentManager.hasStoredProps(t))return t;t=t.parentElement}return null}buildContextStrict(e,t,n,s){if(t&&t!==e){let s=this.componentManager.buildComponentContext(t);if(n&&this.componentManager.hasStoredProps(n)){const e=this.componentManager.evaluateProps(n);s={...s,...e}}if(e&&e!==t)if("app"===e){const e=this.componentManager.buildComponentContext("app");for(const[t,n]of Object.entries(e))t in s||(s[t]=n)}else{const t=this.componentManager.buildComponentContext(e);for(const[e,n]of Object.entries(t))e in s||(s[e]=n)}return s}if("app"===e){let e=this.componentManager.buildComponentContext("app");if(n&&n!==document.body&&this.componentManager.hasStoredProps(n)){const t=this.componentManager.evaluateProps(n);e={...e,...t}}return e}let i=this.componentManager.buildComponentContext(t);if(n&&this.componentManager.hasStoredProps(n)){const e=this.componentManager.evaluateProps(n);i={...i,...e}}return i}buildContextNonStrict(e,t,n){if(n){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===e)return this.componentManager.buildComponentContextWithProps(e,n);if("app"===k.findScope(n)){let e={};e.getContext=()=>this.componentManager.buildComponentContext("app"),e.withContext=e=>{const t=this.componentManager.buildComponentContext("app");return e.call(t,t)},e.__getProp=e=>this.componentManager.evaluateProps(n)[e];const t=this.componentManager.evaluateProps(n);e={...e,...t};const s=n.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(s){const t=this.componentManager.getComponentFunctions(s);if(t)for(const[n,s]of t)e[n]=s}return e}const t=this.componentManager.buildRestrictedComponentContext(e,!1),s=this.componentManager.evaluateProps(n);return Object.assign(t,s),t}if(t&&t.getAttribute(g.ATTR_PREFIXES.COMPONENT)===e)return this.componentManager.buildComponentContextWithProps(e,t);const s=this.componentManager.buildRestrictedComponentContext(e,!1),i=t||n;if(i&&this.componentManager.hasStoredProps(i)){const e=this.componentManager.evaluateProps(i);Object.assign(s,e)}return s}mergeLoopContext(e,t){var n;const s=null==(n=this.loopManager)?void 0:n.getLoopContextForElement(e);if(!s)return t;const i={};for(const[e,t]of Object.entries(s))i[e]="function"==typeof t&&"__pphp_key"in t?t.value:t;return{...t,...i}}ensureCompiled(e){e.compiledFn||(e.compiledFn=this.compileHandler(e.code,e.component))}attachDirectListener(e,t,n){const s=t=>{this.executeHandler(n,e,t)};e.addEventListener(t,s),e[`__${t}_listener`]=s}removeEventHandler(e,t){var n,s;const i=this.elementHandlers.get(e);i&&(i.delete(t),0===i.size&&this.elementHandlers.delete(e));const r=this.delegatedEvents.get(t);r&&(null==(s=(n=r.elements).delete)||s.call(n,e));const a=e[`__${t}_listener`];a&&(e.removeEventListener(t,a),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()}};d(le,"eventCache",null);let ie=le;class Js{constructor(e,t,n){d(this,"stateManager"),d(this,"componentManager"),d(this,"expressionEvaluator"),d(this,"textNodeManager"),d(this,"observer"),d(this,"listeners",new WeakMap),d(this,"pendingBindings",[]),d(this,"pendingTextNodes",[]),d(this,"applyingUpdates",!1),d(this,"elementCache",new WeakMap),d(this,"batchedUpdates",new Set),d(this,"processingRAF",null),d(this,"updateQueue",new Map),d(this,"eventDelegation",new ie),d(this,"processedElements",new WeakSet),d(this,"loopManager"),d(this,"templateRenderer"),d(this,"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"}),d(this,"lastValueCache",new WeakMap),d(this,"stringValueCache",new G(500)),d(this,"refBindings",new WeakMap),d(this,"isRelevantMutation",(e=>{if(this.applyingUpdates&&"attributes"===e.type)return!1;if("childList"===e.type||"characterData"===e.type)return!0;if("attributes"===e.type){const t=e.attributeName;return t===g.ATTR_PREFIXES.COMPONENT||null!==t&&ie.isEventAttribute(t)}return!1})),this.stateManager=e,this.componentManager=t,this.expressionEvaluator=n,this.textNodeManager=new Ys(n,e),this.textNodeManager.componentManager=this.componentManager,this.componentManager.setDOMBindingManager(this),this.setupMutationObserver(),this.eventDelegation.setupEventDelegation(),this.loopManager=new Zs(e,n),this.loopManager.setDependencies(t,this),this.loopManager.eventDelegation=this.eventDelegation,this.eventDelegation.setDependencies(this.componentManager,this.expressionEvaluator,this.stateManager,this.loopManager),this.templateRenderer=new ve(n)}refreshComponentElement(e,t){this.elementCache.delete(e),this.processedElements.delete(e);const n=[...this.componentManager.componentStack];this.componentManager.componentStack=["app"],"app"!==t&&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=n}}refreshComponentTextNodes(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>{const n=e;return!n.textContent||!g.MUSTACHE_PATTERN.test(n.textContent)||P.isTextNodeInsideScript(n)||this.isTextNodeInsideLoopItem(n)||P.getComponentForNode(n)!==t?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let s;const i=[];for(;s=n.nextNode();)i.push(s);i.forEach((e=>{this.textNodeManager.cleanupTextNode(e),this.textNodeManager.cleanupTextNode(e),this.textNodeManager.processTextNode(e,t)}))}walkComponentChildren(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const s=n;return P.getElementComponent(s)!==t?NodeFilter.FILTER_REJECT:s===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}});let s;const i=[];for(;s=n.nextNode();){const e=s;i.push(e)}i.forEach((n=>{this.elementCache.delete(n),this.processedElements.delete(n);const s=this.componentManager.buildComponentContextWithProps(t,e);this.processElementInContext(n,s,t,!0)}))}createSpreadDirectiveBinding(e,t,n){const s=`spread_${Date.now()}_${Math.random()}`,i=L.parseSpreadDirective(t);if(0===i.spreads.length&&0===i.objects.length)return void console.warn(`Invalid pp-spread directive: ${t}`);const r=new Set,a=()=>{if(document.contains(e))try{const t=this.componentManager.buildComponentContextWithProps(n,e);this.clearSpreadAttributes(e,r);for(const s of i.spreads){const i=this.expressionEvaluator.evaluateExpression(s,t,n);i&&"object"==typeof i&&this.applySpreadObject(e,i,r)}for(const s of i.objects)this.applyObjectProperties(e,s,t,n,r)}catch(e){console.error(`Spread directive evaluation error for "${t}":`,e)}else this.stateManager.removeSubscription(s)},o=new Set;for(const e of i.spreads)this.templateRenderer.dependencies(e,n,this.stateManager).forEach((e=>o.add(e)));for(const e of i.objects)for(const t of e)this.templateRenderer.dependencies(t.value,n,this.stateManager).forEach((e=>o.add(e)));const c={id:s,selector:"",dependencies:o,callback:a,element:e,component:n};this.stateManager.addSubscription(c),this.storeSpreadSubscription(e,s),a()}applyObjectProperties(e,t,n,s,i){for(const r of t)try{const t=this.expressionEvaluator.evaluateExpression(r.value,n,s);if(this.isEventProperty(r.key)){this.handleSpreadEventProperty(e,r.key,t);continue}const a=this.normalizeAttributeName(r.key);this.updateElementProperty(e,a,t),i.add(a)}catch(e){console.error(`Error evaluating object property "${r.key}: ${r.value}":`,e)}}applySpreadObject(e,t,n){for(const[s,i]of Object.entries(t))if(null!=i){if(this.isEventProperty(s)){this.handleSpreadEventProperty(e,s,i);continue}const t=this.normalizeAttributeName(s);(!e.hasAttribute(t)||n.has(t))&&(this.updateElementProperty(e,t,i),n.add(t))}}isEventProperty(e){return e.startsWith("on")&&e.length>2}handleSpreadEventProperty(e,t,n){const s=t.substring(2).toLowerCase();if("function"==typeof n){const t=t=>{var s;try{const i=P.getContextComponent(e),r=(null==(s=this.componentManager)?void 0:s.buildComponentContextWithProps(i,e))||{};n.call(r,t)}catch(e){console.error("Spread event handler error:",e)}};return e.addEventListener(s,t),void this.storeDirectEventListener(e,s,t)}if("string"==typeof n){const t=P.getContextComponent(e);this.eventDelegation.registerEventHandler(e,s,n,t)}}storeDirectEventListener(e,t,n){e.__directEventListeners||(e.__directEventListeners=[]),e.__directEventListeners.push({eventType:t,listener:n})}clearSpreadAttributes(e,t){for(const n of t)e.hasAttribute(n)&&e.removeAttribute(n);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(0===t.length)return;const n=je.getInstance(),s=new Set;for(const e of t)if("childList"===e.type&&(e.removedNodes.forEach((t=>{if(t.nodeType===Node.ELEMENT_NODE){const e=t;this.cleanupRefBinding(e),e.querySelectorAll(`[${g.ATTR_PREFIXES.REF}]`).forEach((e=>{this.cleanupRefBinding(e)})),n.invalidateElement(e),k.invalidateTree(e);const s=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);s&&n.invalidateByComponent(s)}else if(t.nodeType===Node.COMMENT_NODE){const t=e.target;t&&s.add(t)}})),e.addedNodes.forEach((t=>{if(t.nodeType===Node.ELEMENT_NODE){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);e&&n.invalidateByComponent(e)}else if(t.nodeType===Node.COMMENT_NODE){const t=e.target;t&&s.add(t)}}))),"attributes"===e.type&&e.target){const t=e.target;n.invalidateElement(t);const s=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);s&&n.invalidateByComponent(s)}s.forEach((e=>{k.invalidateTree(e)})),this.processMutationsBatch(t)})),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0,characterDataOldValue:!1,attributeFilter:[g.ATTR_PREFIXES.COMPONENT]})}processElement(e,t=!0){if(e===document.body){const n=Array.from(document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}]`)).sort(((e,t)=>P.getElementDepth(e)-P.getElementDepth(t)));this.processElementsBatch([e],t),n.forEach((e=>{this.processElementsBatch([e],t)})),t&&this.loopManager.processPendingTemplates()}else this.processElementsBatch([e],t)}processElementsBatch(e,t=!0){for(const n of e)this.processSingleElement(n,t);t&&(e.forEach((e=>{this.componentManager.executePhpScripts(e)})),this.processPendingBindings())}processSingleElement(e,t){const n=P.getElementComponent(e),s=k.findScope(e);let i;i=s?"app"===s?"app":s:P.getParentComponentForElement(e);const r=this.componentManager.componentStack.length;"app"!==n&&this.componentManager.pushComponent(n),this.componentManager.setupProps(e,i),t&&this.componentManager.executePhpScripts(e),this.processLoopTemplates(e,n);const a=t?this.componentManager.buildComponentContextWithProps(n,e):{};for(this.processElementInContext(e,a,n,t),this.walkDOM(e,a,n,t);this.componentManager.componentStack.length>r;)this.componentManager.popComponent()}processLoopTemplates(e,t){this.getDirectComponentTemplates(e,t).forEach((e=>{this.loopManager.queueTemplate(e,t)}))}getDirectComponentTemplates(e,t){const n=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:t=>{const n=t;return n!==e&&n.hasAttribute(g.ATTR_PREFIXES.COMPONENT)?NodeFilter.FILTER_REJECT:"TEMPLATE"===n.tagName&&n.hasAttribute("pp-for")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let i;for(;i=s.nextNode();)n.push(i);return n}walkDOM(e,t,n,s){const i=it.getInstance(),r=`walkDOM_${n}_${s}`,a=i.getCachedTraversal(e,r,(()=>{const t=i.traverseElementsAndText(e,(t=>{if(t===e||"script"===t.tagName.toLowerCase()||this.loopManager.isLoopItem(t))return!1;let s=t.parentElement;for(;s&&s!==e;){if(this.loopManager.isLoopItem(s))return!1;s=s.parentElement}return!(P.getElementComponent(t)!==n||this.processedElements.has(t))}),(e=>{if(!e.textContent||!g.MUSTACHE_PATTERN.test(e.textContent)||P.isTextNodeInsideScript(e)||this.isTextNodeInsideLoopItem(e))return!1;const t=e.parentElement;if(t){const s=P.getContextComponent(t),i=P.getComponentForNode(e);if(s!==n&&i!==n)return!1}else if(P.getComponentForNode(e)!==n)return!1;return!0}));return[...t.textNodes,...t.elements]})),o=[],c=[];a.forEach((e=>{if(e.nodeType===Node.TEXT_NODE)o.push(e);else if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.hasAttribute(`${g.ATTR_PREFIXES.REF}`)&&s){const e=t.getAttribute(`${g.ATTR_PREFIXES.REF}`);this.createRefBinding(t,e,n),t.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}c.push(t),this.processedElements.add(t)}})),o.forEach((e=>{const t=e.parentElement,i=t?P.getContextComponent(t):n;s?this.textNodeManager.processTextNode(e,i):this.pendingTextNodes.push({textNode:e,component:i})})),c.forEach((e=>{this.processElementInContext(e,t,n,s)}))}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,n,s){if(e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)){const t=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);s&&this.createRefBinding(e,t,n),e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}if(e.hasAttribute(`${g.ATTR_PREFIXES.SPREAD}`)){const t=e.getAttribute(`${g.ATTR_PREFIXES.SPREAD}`);s&&this.createSpreadDirectiveBinding(e,t,n),e.removeAttribute(g.ATTR_PREFIXES.SPREAD)}if(this.loopManager.isLoopItem(e)||this.isElementInLoopItem(e))return;const i=this.extractDomMustacheBindings(e),r=this.elementCache.get(e),a=this.getElementHash(e);if(r&&r.hash===a&&this.isCacheValid(r)&&s)return void this.applyBindingsFromCache(e,r,t);const o={bindings:i,component:n,listeners:[],lastProcessed:Date.now(),hash:a};s?this.applyBindings(e,i,t,n):i.forEach(((t,s)=>{this.pendingBindings.push({element:e,property:s,expression:t,component:n})})),this.setupEventBindings(e,n),this.elementCache.set(e,o)}createRefBinding(e,t,n){try{const n=L.decodeEntities(t),s=L.isSingleExpression(n)||n,i=P.getContextComponent(e),r=this.componentManager.buildComponentContextWithProps(i,e);try{const t=this.expressionEvaluator.evaluateExpression(s,r,i);if("function"==typeof t){const n=t;this.refBindings.set(e,{element:e,callback:n,component:i}),n(e)}else if(t&&"object"==typeof t&&"current"in t){const n=t;this.refBindings.set(e,{element:e,refObject:n,component:i}),n.current=e}else console.warn(`⚠️ ${g.ATTR_PREFIXES.REF} expression did not return a ref object or callback: ${s}`,t)}catch(e){console.error(`❌ Failed to evaluate ref "${s}":`,e)}}catch(e){console.error(`❌ Failed to create ref binding for "${t}":`,e)}}isElementInLoopItem(e){let t=e;for(;t;){if(this.loopManager.isLoopItem(t))return!0;t=t.parentElement}return!1}extractDomMustacheBindings(e){var t;const n=new Map,s=e.attributes,i=this.elementCache.get(e),r=k.findScope(e),a=e.getAttribute(g.ATTR_PREFIXES.COMPONENT),o=a&&(null==(t=this.componentManager)?void 0:t.hasStoredProps(e)),c=r&&a&&r!==a;for(let t=0;t<s.length;t++){const r=s[t];if(r.name!==g.ATTR_PREFIXES.COMPONENT&&"key"!==r.name&&!ie.isEventAttribute(r.name)&&(!i||!i.bindings.has(r.name))&&r.value){const t=g.MUSTACHE_PATTERN.test(r.value),s=L.decodeEntities(r.value),i=g.MUSTACHE_PATTERN.test(s);if(t||i){if(this.looksLikeSerializedObject(s))continue;const a=L.extractExpressions(s),h=P.getContextComponent(e);if(0===a.length&&(t||i)){console.error(`\n❌ Malformed mustache expression in attribute "${r.name}":`),console.error(` Value: ${s}`),console.error(" Element:",e),console.error(` Component: ${h}`),console.error(" 💡 The expression has mustache syntax {} but couldn't be parsed"),console.error(" 💡 Common causes: unmatched quotes, unclosed braces, invalid syntax\n"),o||c&&P.shouldBeDirectBinding(e,r.name)?n.set(r.name,s):c||n.set(r.name,s);continue}for(const t of a){const n=nn.validate(t,h);n.valid||(console.error(`\n❌ Invalid expression in attribute "${r.name}":`),console.error(` Expression: ${t}`),console.error(` Original HTML: ${r.value}`),console.error(` Decoded: ${s}`),console.error(" Element:",e),console.error(` Component: ${h}`),n.errors.forEach((e=>{console.error(` ⚠️ ${e}`)})),console.error(" 💡 Hint: Check your quotes and syntax in conditional expressions"),console.error(" 💡 Example: class=\"{isActive ? 'text-blue-500' : 'text-gray-500'}\"\n")),n.warnings.length>0&&(console.warn(`\n⚠️ Expression warnings in attribute "${r.name}":`),console.warn(` Expression: ${t}`),console.warn(" Element:",e),n.warnings.forEach((e=>{console.warn(` • ${e}`)})))}o||c&&P.shouldBeDirectBinding(e,r.name)?n.set(r.name,s):c||n.set(r.name,s)}}}return n}applyBindings(e,t,n,s){t.forEach(((t,n)=>{this.createMustacheBinding(e,n,t)})),this.setupEventBindings(e,s)}applyBindingsFromCache(e,t,n){t.bindings.forEach(((n,s)=>{try{const i=this.componentManager.buildComponentContextWithProps(t.component,e),r=this.templateRenderer.render(n,i,t.component);this.updateElementProperty(e,s,r)}catch(e){console.error(`Cached binding evaluation error for "${n}":`,e)}}))}createMustacheBinding(e,t,n){const s=`mustache_${Date.now()}_${Math.random()}`,i=k.findScope(e),r=null!==e.getAttribute(g.ATTR_PREFIXES.COMPONENT);let a,o=!1,c=!1;i?(a="app"===i?"app":i,c=!0,o=!1):r?(a=P.getParentComponentForElement(e),o=!0,c=!1):(a=P.getContextComponent(e),o=!1,c=!1),e.removeAttribute(t);let h=null,l=e.parentElement;for(;l&&l!==document.body;){if(l.hasAttribute(g.ATTR_PREFIXES.COMPONENT)){h=l;break}l=l.parentElement}const p=this.templateRenderer.dependencies(n,a,this.stateManager),u=new Set(p),d=this.findComponentElementForMustacheBinding(e,a);if(d&&this.componentManager){const e=this.componentManager.elementProps.get(d);if(e)for(const t of p){const n=t.split("."),s=n[n.length-1];if(e.has(s)){const t=e.get(s);this.templateRenderer.dependencies(t.expression,t.component,this.stateManager).forEach((e=>u.add(e)))}}}if(h&&h!==d&&this.componentManager&&this.componentManager.hasStoredProps(h)){const e=this.componentManager.elementProps.get(h);if(e)for(const t of p){const n=t.split("."),s=n[n.length-1];if(e.has(s)){const t=e.get(s);this.templateRenderer.dependencies(t.expression,t.component,this.stateManager).forEach((e=>u.add(e)))}}}const m=()=>{if(document.contains(e))try{let s;if(c){if(s=this.componentManager.buildComponentContextWithProps(a,d||void 0),e!==d&&r&&this.componentManager.elementProps.get(e)){const t=this.componentManager.evaluateProps(e);s={...s,...t}}}else if(o){let t=null,n=e.parentElement;for(;n&&n!==document.body;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===a){t=n;break}n=n.parentElement}if(s=this.componentManager.buildComponentContextWithProps(a,t||void 0),e!==t&&this.componentManager.hasStoredProps(e)){const t=this.componentManager.evaluatePropsWithContext(e,a,e);s={...s,...t}}}else{const t=this.findComponentElementForMustacheBinding(e,a);if(t){if(s=this.componentManager.buildRestrictedComponentContextWithProps(a,t),e!==t&&this.componentManager.hasStoredProps(e)){const t=this.componentManager.evaluatePropsWithContext(e,a,e);s={...s,...t}}}else{if(s=this.componentManager.buildRestrictedComponentContext(a,!1),t&&this.componentManager.hasStoredProps(t)){const e=this.componentManager.evaluateProps(t);Object.assign(s,e)}if(e!==t&&this.componentManager.hasStoredProps(e)){const t=this.componentManager.evaluatePropsWithContext(e,a,e);Object.assign(s,t)}}}if(h&&this.componentManager&&this.componentManager.hasStoredProps(h)){const e=this.componentManager.evaluateProps(h);s={...s,...e}}const i=this.templateRenderer.render(n,s,a);this.scheduleElementUpdate(e,t,i)}catch(e){console.error(`Mustache binding evaluation error for "${n}":`,e),console.error(`Context component: ${a}`),console.error(`Use strict scope: ${c}`)}else this.stateManager.removeSubscription(s)},f={id:s,selector:"",dependencies:u,callback:m,element:e,component:a};this.stateManager.addSubscription(f),m()}findComponentElementForMustacheBinding(e,t){if(e.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return n;n=n.parentElement}const s=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const e of s)if(this.componentManager&&this.componentManager.hasStoredProps(e))return e;return s[0]||null}setupEventBindings(e,t){const n=k.findScope(e),s=n?"app"===n?"app":n:t;for(let t=0;t<e.attributes.length;t++){const n=e.attributes[t];if(ie.isEventAttribute(n.name)){const t=n.name.substring(2);this.eventDelegation.registerEventHandler(e,t,n.value,s),e.removeAttribute(n.name)}}}scheduleElementUpdate(e,t,n){this.isCriticalProperty(t)?this.updateElementProperty(e,t,n):(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}`]=n)}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 n of t){const t=e[`__pending_${n}`];this.updateElementProperty(e,n,t),delete e[`__pending_${n}`]}}}finally{this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF=null,this.applyingUpdates=!1}}updateElementProperty(e,t,n){const s=We(n),i=this.lastValueCache.get(e);if(i&&this.isSameValue(i.get(t),s))return;const r=this.applyingUpdates;this.applyingUpdates=!0;try{switch(t){case"textContent":const n=this.cachedValueToString(s);e.textContent!==n&&(e.textContent=n);break;case"innerHTML":const i=this.cachedValueToString(s);e.innerHTML!==i&&(e.innerHTML=i);break;case"value":const r=this.cachedValueToString(s);e instanceof HTMLOptionElement?e.value!==r&&(e.value=r,e.setAttribute("value",r)):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.value!==r&&(e.value=r);break;case"selectedIndex":if(e instanceof HTMLSelectElement){const t=Number(s);e.selectedIndex!==t&&(e.selectedIndex=t)}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,s);break;case"indeterminate":if(e instanceof HTMLInputElement&&"checkbox"===e.type){const t=!!s;e.indeterminate!==t&&(e.indeterminate=t)}break;case"class":case"className":const a=this.cachedValueToString(s);e instanceof SVGElement?e.getAttribute("class")!==a&&e.setAttribute("class",a):e.className!==a&&(e.className=a);break;case"htmlFor":case"for":if(e instanceof HTMLLabelElement){const t=this.cachedValueToString(s);e.htmlFor!==t&&(e.htmlFor=t)}break;case"style":if(e instanceof HTMLElement)if("object"==typeof s&&s&&!Array.isArray(s))this.updateStyleObject(e,s);else{const t=this.cachedValueToString(s);e.style.cssText!==t&&(e.style.cssText=t)}break;case"tabIndex":if(e instanceof HTMLElement){const t=null==s?-1:Number(s);e.tabIndex!==t&&(e.tabIndex=t)}break;case"contentEditable":if(e instanceof HTMLElement){const t=!0===s?"true":!1===s?"false":String(s);e.contentEditable!==t&&(e.contentEditable=t)}break;case"draggable":if(e instanceof HTMLElement){const t=!0===s,n=t?"true":"false";e.draggable!==t&&(e.draggable=t,e.setAttribute("draggable",n))}break;case"spellcheck":if(e instanceof HTMLElement){const t=!!s,n=t?"true":"false";e.spellcheck!==t&&(e.spellcheck=t,e.setAttribute("spellcheck",n))}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,s);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,s);break;default:t.startsWith("aria-")?this.setAriaAttribute(e,t,s):t.startsWith("data-")?this.setDataAttribute(e,t,s):this.setGenericAttribute(e,t,s)}this.updateValueCache(e,t,s)}catch(n){console.error(`Failed to update property "${t}" on element:`,e,n)}finally{this.applyingUpdates=r}}looksLikeSerializedObject(e){const t=e.startsWith("{")&&e.endsWith("}"),n=e.startsWith("[")&&e.endsWith("]");if(!t&&!n)return!1;try{const t=JSON.parse(e);return"object"==typeof t&&null!==t&&(Array.isArray(t)||Object.keys(t).length>0)}catch{return!1}}cachedValueToString(e){if("string"==typeof e)return e;if("number"==typeof e)return String(e);if(null==e)return"";if("boolean"==typeof e)return e?"true":"false";if(this.stringValueCache.has(e))return this.stringValueCache.get(e);const t=Ce(e);return this.stringValueCache.set(e,t),t}isSameValue(e,t){if(e===t)return!0;if("object"==typeof e&&"object"==typeof t){if(null===e||null===t)return e===t;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((e,n)=>e===t[n]));if(this.isStyleObject(e)&&this.isStyleObject(t)){const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every((n=>e[n]===t[n]))}}return!1}isStyleObject(e){return e&&"object"==typeof e&&!Array.isArray(e)}setBooleanProperty(e,t,n){const s=!!n;this.setBooleanProp(e,t,n)||(s&&!e.hasAttribute(t)?e.setAttribute(t,""):!s&&e.hasAttribute(t)&&e.removeAttribute(t))}updateStyleObject(e,t){var n;const s=null==(n=this.lastValueCache.get(e))?void 0:n.get("style"),i=s&&"object"==typeof s?s:{};for(const[n,s]of Object.entries(t))i[n]!==s&&(e.style[n]=s)}setStringAttribute(e,t,n){const s=this.cachedValueToString(n);e.getAttribute(t)!==s&&(null==n?e.removeAttribute(t):e.setAttribute(t,s))}setNumericAttribute(e,t,n){const s=String(n);e.getAttribute(t)!==s&&(null==n?e.removeAttribute(t):e.setAttribute(t,s))}setAriaAttribute(e,t,n){const s=this.cachedValueToString(n);e.getAttribute(t)!==s&&(null==n||!1===n?e.removeAttribute(t):e.setAttribute(t,s))}setDataAttribute(e,t,n){const s=this.cachedValueToString(n);e.getAttribute(t)!==s&&(null==n?e.removeAttribute(t):e.setAttribute(t,s))}setGenericAttribute(e,t,n){const s=this.cachedValueToString(n);e.getAttribute(t)!==s&&(null==n||!1===n?e.removeAttribute(t):e.setAttribute(t,s))}updateValueCache(e,t,n){this.lastValueCache.has(e)||this.lastValueCache.set(e,new Map),this.lastValueCache.get(e).set(t,n)}setBooleanProp(e,t,n){const s=this.BOOL_REFLECTED[t];if(!s)return!1;const i=!!n;return e instanceof HTMLElement&&s in e?(e[s]!==i&&(e[s]=i),!0):(i?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 n of e)t.has(n.component)||t.set(n.component,[]),t.get(n.component).push(n);for(const[e,n]of t){const t=[...this.componentManager.componentStack];this.componentManager.componentStack="app"!==e?["app",e]:["app"];for(const t of n)try{if(!document.contains(t.element))continue;this.createMustacheBinding(t.element,t.property,t.expression)}catch(t){console.error(`❌ Failed to create binding for ${e}:`,t)}this.componentManager.componentStack=t}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,n]of e){const e=[...this.componentManager.componentStack];this.componentManager.componentStack="app"!==t?["app",t]:["app"];for(const{textNode:e,component:t}of n)if(document.contains(e))try{this.textNodeManager.processTextNode(e,t)}catch(e){console.error(`❌ Failed to process text node for ${t}:`,e)}this.componentManager.componentStack=e}}processMutationsBatch(e){const t=new Set,n=new Set,s=new Set,i=new Set,r=new Set;for(const s of e)if("childList"===s.type&&(s.addedNodes.forEach((e=>{if(e.nodeType===Node.ELEMENT_NODE)t.add(e);else if(e.nodeType===Node.TEXT_NODE){const t=e;t.textContent&&g.MUSTACHE_PATTERN.test(t.textContent)&&r.add(t)}})),s.removedNodes.forEach((e=>{if(e.nodeType===Node.ELEMENT_NODE)n.add(e);else if(e.nodeType===Node.TEXT_NODE){const t=e;t.textContent&&g.MUSTACHE_PATTERN.test(t.textContent)&&(document.contains(t)||this.textNodeManager.cleanupTextNode(t))}}))),"attributes"===s.type&&s.target&&i.add(s.target),"characterData"===s.type&&s.target){const e=s.target;e.textContent&&g.MUSTACHE_PATTERN.test(e.textContent)&&r.add(e)}for(const e of n)(t.has(e)||document.contains(e))&&(s.add(e),n.delete(e),t.has(e)&&t.delete(e));n.size>0&&this.cleanupElementsBatch(Array.from(n)),t.size>0&&this.processElementsBatch(Array.from(t)),r.size>0&&this.processTextNodesBatch(Array.from(r)),i.size>0&&this.rebindChangedElements(Array.from(i))}processTextNodesBatch(e){const t=new Map;for(const n of e){const e=P.getComponentForNode(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}for(const[e,n]of t)n.forEach((t=>{this.textNodeManager.processTextNode(t,e)}))}rebindChangedElements(e){e.forEach((e=>{this.processElementBindings(e,!0)}))}processElementBindings(e,t=!0){const n=this.extractDomMustacheBindings(e),s=P.getElementComponent(e);n.forEach(((n,i)=>{t?this.createMustacheBinding(e,i,n):this.pendingBindings.push({element:e,property:i,expression:n,component:s})})),t&&this.setupEventBindings(e,s)}cleanupElementsBatch(e){e.forEach((e=>this.cleanupElement(e)))}cleanupElement(e){var t;this.cleanupRefBinding(e),null==(t=this.stateManager.subscriptionManager)||t.cleanupElement(e);const n=this.listeners.get(e)||[];for(const{type:t,fn:s}of n)e.removeEventListener(t,s);this.listeners.delete(e),this.elementCache.delete(e),this.processedElements.delete(e),this.componentManager.cleanupProps(e);const s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let i;for(;i=s.nextNode();)this.textNodeManager.cleanupTextNode(i);"TEMPLATE"===e.tagName&&e.hasAttribute("pp-for")&&this.loopManager.cleanupTemplate(e),e.querySelectorAll("template[pp-for]").forEach((e=>{this.loopManager.cleanupTemplate(e)}));const r=e.__directEventListeners;r&&(r.forEach((({eventType:t,listener:n})=>{e.removeEventListener(t,n)})),delete e.__directEventListeners);const a=e.__spreadEventHandlers;a&&(a.forEach((e=>{window.__spreadHandlers&&window.__spreadHandlers.delete(e)})),delete e.__spreadEventHandlers);const o=e.__spreadSubscriptions;o&&(o.forEach((e=>{this.stateManager.removeSubscription(e)})),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(e){console.error("Failed to cleanup ref:",e)}this.refBindings.delete(e)}}getElementHash(e){const t=[];for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n];(s.name===g.ATTR_PREFIXES.COMPONENT||ie.isEventAttribute(s.name)||s.value&&g.MUSTACHE_PATTERN.test(s.value))&&t.push(`${s.name}=${s.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(`[${g.ATTR_PREFIXES.REF}]`).forEach((e=>{this.cleanupRefBinding(e)})),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()}}const de=class e{constructor(){d(this,"walkerPool",[]),d(this,"traversalCache",new WeakMap),d(this,"lastCacheTime",new WeakMap),d(this,"CACHE_TTL",250),d(this,"trackedElements",new Set)}static getInstance(){return e.instance||(e.instance=new e),e.instance}acquireWalker(e,t,n){return document.createTreeWalker(e,t,n)}releaseWalker(e){this.walkerPool.length<3&&this.walkerPool.push(e)}getCachedTraversal(e,t,n){const s=Date.now(),i=this.traversalCache.get(e),r=this.lastCacheTime.get(e);if(i&&r&&s-r<this.CACHE_TTL){const e=i.get(t);if(e)return e}const a=n();return this.traversalCache.has(e)||(this.traversalCache.set(e,new Map),this.trackedElements.add(e)),this.traversalCache.get(e).set(t,a),this.lastCacheTime.set(e,s),a}traverseElementsAndText(e,t,n){const s=this.acquireWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),i=[],r=[];let a;for(;a=s.nextNode();)if(a.nodeType===Node.ELEMENT_NODE){const e=a;(!t||t(e))&&i.push(e)}else if(a.nodeType===Node.TEXT_NODE){const e=a;(!n||n(e))&&r.push(e)}return this.releaseWalker(s),{elements:i,textNodes:r}}cleanupCache(){const e=[];for(const t of this.trackedElements)document.contains(t)||e.push(t);e.forEach((e=>{this.traversalCache.delete(e),this.lastCacheTime.delete(e),this.trackedElements.delete(e)}))}};d(de,"instance");let it=de;const me=class e{static getDOMCache(){return this.domCache||(this.domCache=je.getInstance()),this.domCache}static isFrameworkAttribute(t){return e.FRAMEWORK_ATTRIBUTES.has(t)}static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}static shouldBeDirectBinding(t,n){const s=k.findScope(t),i=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);return!(!s||!i||s===i)&&e.isDOMProperty(t,n)}static isDOMProperty(t,n){const s=t.tagName.toLowerCase(),i=document.createElement(s);return e.attributeToPropertyName(n)in i}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,((e,t)=>t.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 e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}static isTextNodeInsideScript(e){let t=e.parentElement;for(;t&&t!==document.body;){const e=t.tagName.toLowerCase();if("script"===e||"style"===e)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)}};d(me,"FRAMEWORK_ATTRIBUTES",new Set(["pp-component","pp-for","pp-spread","pp-ref","key"])),d(me,"domCache");let P=me;class Zs{constructor(e,t){d(this,"eventDelegation"),d(this,"loopBindings",new Map),d(this,"stateManager"),d(this,"expressionEvaluator"),d(this,"componentManager"),d(this,"domBindingManager"),d(this,"cleanupObserver"),d(this,"loopCounter",0),d(this,"pendingTemplates",[]),d(this,"loopItemElements",new WeakSet),d(this,"loopItemContexts",new WeakMap),d(this,"templateRenderer"),d(this,"templateMoveObserver"),this.stateManager=e,this.expressionEvaluator=t,this.cleanupObserver=new MutationObserver((e=>{this.cleanupDetachedTemplates(e)})),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateMoveObserver=new MutationObserver((e=>{this.handleTemplateMoves(e)})),this.templateMoveObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateRenderer=new ve(t)}handleTemplateMoves(e){const t=new Set;for(const n of e)"childList"===n.type&&n.addedNodes.forEach((e=>{if(e.nodeType!==Node.ELEMENT_NODE)return;const n=e;if(n.querySelectorAll("template[pp-for]").forEach((e=>{const n=e;this.loopBindings.has(n)&&t.add(n)})),"TEMPLATE"===n.tagName&&n.hasAttribute("pp-for")){const e=n;this.loopBindings.has(e)&&t.add(e)}}));t.size>0&&setTimeout((()=>{t.forEach((e=>{document.contains(e)&&this.updateMovedTemplate(e)}))}),0)}updateMovedTemplate(e){const t=this.loopBindings.get(e);if(!t)return;const n=e.parentElement;if(!n||n===t.parentElement&&t.placeholder.parentElement===n&&t.placeholder.nextSibling===e)return;const s=[...t.renderedItems];t.placeholder.parentElement&&t.placeholder.parentElement!==n&&t.placeholder.parentElement.removeChild(t.placeholder);const i=document.createComment(`pp-for: ${t.expression}`);n.insertBefore(i,e),t.parentElement=n,t.placeholder=i,s.length>0&&(s.forEach((t=>{t.element.parentElement!==n&&n.insertBefore(t.element,e)})),this.updateDOMOrder(t,s)),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 n=e.parentElement;for(;n;){if(t.isLoopItem&&t.isLoopItem(n))return t.getLoopItemContext(n);n=n.parentElement}const s=t.getAllLoops();for(const[t,n]of s)for(const t of n.renderedItems)if(t.element.contains(e))return t.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:n}of e)document.contains(t)&&this.processTemplate(t,n)}processTemplate(e,t){const n=e.getAttribute("pp-for");if(!n||this.loopBindings.has(e))return;if(!e.parentElement)return console.warn("⚠️ Template has no parent, queueing for later:",n),void this.queueTemplate(e,t);const s=this.parseLoopExpression(n);if(!s)return void console.error(`Invalid pp-for syntax: "${n}"`);const i=e.getAttribute("pp-ssr")??void 0,r=void 0!==i;let a;r&&(a=this.findListContainer(e,i),a||console.warn(`⚠️ No pp-list="${i}" container found for SSR template`));const o=k.findScope(e);let c=t;if(o)if(o.includes(":children")){const e=o.replace(/:children$/,"");c="app"===e?"app":e}else c="app"===o?"app":o;const h=e.parentElement,l=document.createComment(`pp-for: ${n}`);h.insertBefore(l,e);const p={template:e,expression:n,itemVar:s.itemVar,indexVar:s.indexVar,component:c,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:h,placeholder:l,iterableExpr:s.iterableExpr,isSSR:r,ssrIdentifier:i,listContainer:a};this.loopBindings.set(e,p),r&&a&&this.hydrateSSRItems(p),this.setupLoopReactivity(p,s.iterableExpr),this.renderLoop(p,s.iterableExpr)}findListContainer(e,t){var n;let s=e.parentElement;for(;s&&s!==document.body;){if(s.getAttribute("pp-list")===t)return s;s=s.parentElement}const i=null==(n=e.parentElement)?void 0:n.children;if(i)for(const e of Array.from(i))if(e.getAttribute("pp-list")===t)return e}hydrateSSRItems(e){if(!e.listContainer)return;const t=[];if(Array.from(e.listContainer.children).forEach((n=>{if(n===e.template||n.nodeType!==Node.ELEMENT_NODE)return;const s=n;s.hasAttribute("key")&&t.push(s)})),0===t.length)return console.warn("⚠️ [Hydrate] No SSR items found, falling back to client render"),void(e.isSSR=!1);t.forEach(((t,n)=>{const s={key:t.getAttribute("key"),element:t,context:{},subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map,parentTemplate:e.template};this.loopItemElements.add(t),e.renderedItems.push(s),t.removeAttribute("key")}))}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 n=e.match(/^\s*\(\s*([a-zA-Z_$][\w$]*)\s*,\s*([a-zA-Z_$][\w$]*)\s*\)\s+in\s+(.+)$/);return n?{itemVar:n[1],indexVar:n[2],iterableExpr:n[3].trim()}:null}setupLoopReactivity(e,t){const n=`loop_${Date.now()}_${++this.loopCounter}`,s=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager),i=this.findComponentElementForLoop(e);if(i&&this.componentManager){const t=this.componentManager.getComponentPropDependencies(i,e.component);s.push(...t)}const r={id:n,selector:"",dependencies:new Set(s),callback:()=>{this.renderLoop(e,e.iterableExpr)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(r),e.subscriptionIds.push(n)}renderLoop(e,t){if(this.componentManager&&this.domBindingManager)try{const n=e.template,s=k.findScope(n);let i,r;if((null==s?void 0:s.includes(":children"))||!1){const e=s.replace(/:children$/,"");if(r=this.findComponentElementForScope(e),i=this.componentManager.buildComponentContext(e),r&&this.componentManager.hasStoredProps(r)){const e=this.componentManager.evaluateProps(r);i={...i,...e}}}else{r=this.findComponentElementForLoop(e);const t=this.findParentLoopContext(e.template);if(null!==s){const n=this.componentManager.buildComponentContext(e.component);if(r){const e=this.componentManager.evaluateProps(r);i={...n,...e}}else i=n;t&&(i={...i,...t})}else{if(i=this.componentManager.buildRestrictedComponentContext(e.component,!1),r&&this.componentManager.hasStoredProps(r)){const e=this.componentManager.evaluateProps(r);Object.assign(i,e)}t&&(i={...i,...t})}}const a=We(this.expressionEvaluator.evaluateExpression(t,i,e.component));if(!Array.isArray(a))return console.warn(`Loop expression "${t}" did not return an array:`,a,`Available context keys: [${Object.keys(i).join(", ")}]`,"Parent loop context:"),void this.clearRenderedItems(e);e.isSSR&&e.renderedItems.length>0?this.reconcileSSRItems(e,a):this.updateRenderedItems(e,a)}catch(n){console.error(`❌ Error evaluating loop expression "${t}":`,n),this.clearRenderedItems(e)}}reconcileSSRItems(e,t){const n=e.renderedItems,s=[],i=new Set,r=new Map,a=[];n.forEach((e=>{r.set(e.key,e),a.push(e)})),t.forEach(((t,n)=>{const o=this.generateItemKey(e,t,n),c=r.get(o);if(c&&!i.has(c.element))i.add(c.element),this.updateItemContext(e,c,t,n),this.processElementWithContext(c.element,c.context,e.component,c),this.refreshLoopItemContent(c),c.element.querySelectorAll("template[pp-for]").forEach((e=>{const t=e,n=this.loopBindings.get(t);n&&this.renderLoop(n,n.iterableExpr)})),s.push(c);else{const r=a.find((e=>!i.has(e.element)));if(r)i.add(r.element),r.key=o,this.updateItemContext(e,r,t,n),this.refreshLoopItemContent(r),s.push(r);else{const i=this.createLoopItem(e,t,n,o);i&&(s.push(i),this.processNestedLoopsInItem(i,e.component))}}})),n.forEach((e=>{i.has(e.element)||this.cleanupLoopItem(e)})),this.updateDOMOrder(e,s),e.renderedItems=s,e.isSSR=!1}refreshLoopItemContent(e){if(e.textNodeTemplates)for(const[t,n]of e.textNodeTemplates)document.contains(t)&&this.updateTextNodeWithContext(t,n,e.context,this.getTextNodeComponent(t));if(e.attributeTemplates)for(const[t,n]of e.attributeTemplates)document.contains(t)&&n.forEach(((n,s)=>{var i;try{const r=P.getElementComponent(t),a=this.templateRenderer.render(n,e.context,r);null==(i=this.domBindingManager)||i.updateElementProperty(t,s,a)}catch(e){console.error(`Error refreshing attribute "${s}":`,e)}}))}findComponentElementForScope(e){const t=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${e}"]`);for(const e of t)if(this.componentManager.hasStoredProps(e))return e;return t[0]||void 0}findParentLoopContext(e){const t=[];let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const e=this.loopItemContexts.get(n);e&&t.unshift(e)}for(const[s,i]of this.loopBindings)if(i.template!==e)for(const s of i.renderedItems)if(s.element===n||s.element.contains(e)){t.unshift(s.context);break}n=n.parentElement}return t.length>0?t.reduce(((e,t)=>({...e,...t})),{}):null}findComponentElementForLoop(e){var t;let n=e.parentElement;for(;n;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===e.component)return n;n=n.parentElement}if("app"===e.component)for(n=e.parentElement;n&&n!==document.body;){if(n.hasAttribute(g.ATTR_PREFIXES.COMPONENT)&&null!=(t=this.componentManager)&&t.hasStoredProps(n))return n;n=n.parentElement}return document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${e.component}"]`)[0]||void 0}updateRenderedItems(e,t){const n=e.renderedItems,s=[],i=new Set,r=new Map,a=[];n.forEach((e=>{r.set(e.key,e),a.push(e)})),t.forEach(((t,n)=>{const o=this.generateItemKey(e,t,n),c=r.get(o);if(c&&!i.has(c.element))i.add(c.element),this.updateItemContext(e,c,t,n),this.refreshLoopItemContent(c),c.element.querySelectorAll("template[pp-for]").forEach((e=>{const t=e,n=this.loopBindings.get(t);n&&this.renderLoop(n,n.iterableExpr)})),s.push(c);else{const r=a.find((e=>!i.has(e.element)));if(r)i.add(r.element),r.key=o,this.updateItemContext(e,r,t,n),this.refreshLoopItemContent(r),s.push(r);else{const i=this.createLoopItem(e,t,n,o);i&&(s.push(i),this.processNestedLoopsInItem(i,e.component))}}})),n.forEach((e=>{i.has(e.element)||this.cleanupLoopItem(e)})),this.updateDOMOrder(e,s),e.renderedItems=s}processNestedLoopsInItem(e,t){e.element.querySelectorAll("template[pp-for]").forEach((n=>{const s=n;this.loopBindings.has(s)||this.processNestedTemplate(s,t,e.context)}))}generateItemKey(e,t,n){const s=e.template.content.firstElementChild;if(s&&s.hasAttribute("key")){const i=s.getAttribute("key");try{const s=this.createItemContextWithParentContext(e,t,n),r=L.isSingleExpression(i);if(r){const t=this.expressionEvaluator.evaluateExpression(r,s,e.component);return String(t)}{const t=L.parse(i);let n="";for(const i of t)if("static"===i.type)n+=i.content;else if(i.expression){n+=Ce(this.expressionEvaluator.evaluateExpression(i.expression,s,e.component))}return n}}catch(s){console.warn(`Error evaluating key expression "${i}":`,s,"Available context keys:",Object.keys(this.createItemContextWithParentContext(e,t,n)))}}return t&&"object"==typeof t&&"id"in t?String(t.id):`${e.expression}_${n}`}createItemContextWithParentContext(e,t,n){if(!this.componentManager)return{};const s=e.template,i=k.findScope(s);let r;if((null==i?void 0:i.includes(":children"))||!1){const e=i.replace(/:children$/,"");r=this.componentManager.buildComponentContext(e);const t=this.findComponentElementForScope(e);if(t&&this.componentManager.hasStoredProps(t)){const e=this.componentManager.evaluateProps(t);r={...r,...e}}}else{const t=null!==i,n=this.findComponentElementForLoop(e),s=n&&this.componentManager.hasStoredProps(n);if(t&&"app"===i&&s&&n){r={},r.getContext=()=>this.componentManager.buildComponentContext("app"),r.withContext=e=>{const t=this.componentManager.buildComponentContext("app");return e.call(t,t)},r.__getProp=e=>{if(n)return this.componentManager.evaluateProps(n)[e]};const e=this.componentManager.evaluateProps(n);r={...r,...e}}else r=this.componentManager.buildComponentContext(e.component)}const a=this.getAllParentLoopContexts(e.template),o=t&&"object"==typeof t?Object.keys(t):[],c={};for(const[e,t]of Object.entries(r))o.includes(e)&&!e.startsWith("set")&&!e.endsWith("Getter")||(c[e]=t);const h={...c,...a,[e.itemVar]:t};return e.indexVar&&(h[e.indexVar]=n),h}getAllParentLoopContexts(e){const t=[];let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const e=this.loopItemContexts.get(n);e&&t.unshift(e)}for(const[s,i]of this.loopBindings)for(const s of i.renderedItems)if(s.element.contains(e)||s.element===n){t.unshift(s.context);break}n=n.parentElement}const s={};for(const e of t)for(const[t,n]of Object.entries(e))if(!(t in s)){if("function"==typeof n&&!("__pphp_key"in n)){["getContext","withContext","__getProp"].includes(t)&&(s[t]=n);continue}s[t]=n}return s}createItemContext(e,t,n){if(!this.componentManager)return{};const s=e.template,i=k.findScope(s),r=null!==i,a=this.findComponentElementForLoop(e),o=a&&this.componentManager.hasStoredProps(a);let c,h=!1,l=s.parentElement;for(;l&&l!==document.body;){if(this.loopItemElements.has(l)){const e=this.loopItemContexts.get(l);if(e&&!Object.keys(e).some((t=>{const n=e[t];return"function"==typeof n&&!("__pphp_key"in n)&&!["getContext","withContext","__getProp"].includes(t)}))){h=!0;break}}l=l.parentElement}if(r&&"app"===i&&o&&a||h&&o&&a){c={},c.getContext=()=>this.componentManager.buildComponentContext("app"),c.withContext=e=>{const t=this.componentManager.buildComponentContext("app");return e.call(t,t)},c.__getProp=e=>{if(a)return this.componentManager.evaluateProps(a)[e]};const e=this.componentManager.evaluateProps(a);c={...c,...e}}else c=r||o?this.componentManager.buildComponentContext(e.component):this.componentManager.buildRestrictedComponentContext(e.component,!1);const p={},u=t&&"object"==typeof t?Object.keys(t):[];for(const[e,t]of Object.entries(c))"function"!=typeof t||t.__pphp_key?e.startsWith("set")||e.endsWith("Getter")||["getContext","withContext","__getProp"].includes(e)?p[e]=t:u.includes(e)||(p[e]=t):p[e]=t;const d=this.findAllParentLoopContexts(e.template),m={...p,...d,[e.itemVar]:t};return e.indexVar&&(m[e.indexVar]=n),m}findAllParentLoopContexts(e){const t={};let n=e.parentElement,s=0;for(;n&&n!==document.body&&s<10;){if(s++,this.loopItemElements.has(n)){const e=this.loopItemContexts.get(n);if(e)for(const[n,s]of Object.entries(e))if(!(n in t)){const e="function"==typeof s,i=e&&"__pphp_key"in s,r=["getContext","withContext","__getProp"].includes(n);if(e&&!i){r&&(t[n]=s);continue}t[n]=s}}for(const[s,i]of this.loopBindings)if(s!==e)for(const e of i.renderedItems)if(e.element===n){for(const[n,s]of Object.entries(e.context))if(!(n in t)){const e="function"==typeof s,i=e&&"__pphp_key"in s,r=["getContext","withContext","__getProp"].includes(n);if(e&&!i){r&&(t[n]=s);continue}t[n]=s}break}n=n.parentElement}return t}createLoopItem(e,t,n,s){if(!this.domBindingManager)return null;try{const i=this.createItemContextWithParentContext(e,t,n);this.preCloneSanitizeTemplate(e.template);const r=document.importNode(e.template.content,!0),a=document.createElement("div");a.appendChild(r);const o=a.firstElementChild;if(!o)return console.error("❌ [LoopItem] No element found in template"),null;a.removeChild(o),this.loopItemElements.add(o),this.loopItemContexts.set(o,i),o.getAttribute("key")&&o.removeAttribute("key");const c={key:s,element:o,context:i,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map,parentTemplate:e.template};return o instanceof HTMLElement&&(o.classList.add("pp-entering"),requestAnimationFrame((()=>{requestAnimationFrame((()=>{o.classList.remove("pp-entering")}))}))),this.executeComponentScriptsInLoopItem(o),this.processRefsInLoopItem(o,i,e.component,c),this.processElementWithContext(o,i,e.component,c),this.cleanupRawMustacheAttributes(o),c}catch(e){return console.error("❌ [LoopItem] Error creating loop item:",e),console.error(" Stack:",e.stack),null}}preCloneSanitizeTemplate(e){const t=e.content.querySelectorAll("input");for(const e of Array.from(t)){const t=(e.getAttribute("type")||"text").toLowerCase();if(!["number","date","time","datetime-local","month","week","email","url","tel","range"].includes(t))continue;const n=["value","min","max","step","pattern"];for(const t of n){const n=e.getAttribute(t);if(n&&g.MUSTACHE_PATTERN.test(n)){const s=`data-pp-${t}`;e.setAttribute(s,n),e.removeAttribute(t)}}"number"===t&&!e.hasAttribute("value")&&e.setAttribute("value","0")}}processRefsInLoopItem(e,t,n,s){if(e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)){const i=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);s&&(s.refTemplates||(s.refTemplates=new Map),s.refTemplates.set(e,i)),this.processRefAttribute(e,i,t,n),ve.containsMustacheExpression(i)||e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let r;const a=[];for(;r=i.nextNode();)a.push(r);a.forEach((e=>{const i=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);s&&(s.refTemplates||(s.refTemplates=new Map),s.refTemplates.set(e,i)),this.processRefAttribute(e,i,t,n),ve.containsMustacheExpression(i)||e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}))}processRefAttribute(e,t,n,s){try{const i=L.decodeEntities(t),r=L.isSingleExpression(i)||i,a=this.expressionEvaluator.evaluateExpression(r,n,s);"function"==typeof a?a(e):a&&"object"==typeof a&&"current"in a?a.current=e:console.warn("⚠️ Invalid ref result:",a),e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}catch(e){console.error("❌ Failed to process ref:",e)}}executeComponentScriptsInLoopItem(e){if(!this.componentManager)return;const t=[e],n=e.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}]`);t.push(...Array.from(n)),t.forEach((e=>{if(e.hasAttribute(g.ATTR_PREFIXES.COMPONENT)){const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(t){const n=this.getLoopItemContextForElement(e),s=`${t}_${this.generateInstanceId(n)}`;e.setAttribute(g.ATTR_PREFIXES.COMPONENT,s),e.__originalComponentName=t,e.__uniqueComponentName=s,this.componentManager.pushComponent(s),window[s]||(window[s]={}),window[t]&&Object.assign(window[s],window[t]),this.getComponentScripts(e).forEach((e=>{this.componentManager.executeScript(e)})),this.componentManager.popComponent()}}}))}getLoopItemContextForElement(e){let t=e;for(;t;){if(this.loopItemElements.has(t)){const e=this.loopItemContexts.get(t);if(e)return e}t=t.parentElement}for(const[t,n]of this.loopBindings)for(const t of n.renderedItems)if(t.element===e||t.element.contains(e))return t.context;return console.warn("⚠️ No loop item context found, using empty context"),{}}generateInstanceId(e){const t={};for(const[n,s]of Object.entries(e))"function"==typeof s||n.startsWith("set")||n.endsWith("Getter")||"getContext"===n||"withContext"===n||"__getProp"===n||s&&"function"==typeof s&&"__pphp_key"in s||"boolean"==typeof s||"number"==typeof s||"string"==typeof s||s&&"object"==typeof s&&!Array.isArray(s)&&"id"in s&&(t[n]=s);return 0===Object.keys(t).length?`${Date.now()}_${Math.random().toString(36).substring(2,7)}`:Object.keys(t).sort().map((e=>{const n=t[e];return n&&"object"==typeof n&&"id"in n?`${e}_${n.id}`:`${e}_${JSON.stringify(n)}`})).join("_").replace(/[^a-zA-Z0-9_]/g,"").substring(0,20)||`fallback_${Date.now()}`}getComponentScripts(e){const t=[];return e.querySelectorAll(`script[type="${g.SCRIPT_TYPE}"]`).forEach((n=>{const s=n;let i=s.parentElement,r=!1;for(;i&&i!==e.parentElement;){if(i===e){r=!0;break}if(i.hasAttribute(g.ATTR_PREFIXES.COMPONENT)&&i!==e)break;i=i.parentElement}r&&t.push(s)})),t}cleanupRawMustacheAttributes(e){this.cleanupElementMustacheAttributes(e);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let n;for(;n=t.nextNode();)this.cleanupElementMustacheAttributes(n)}cleanupElementMustacheAttributes(e){const t=Array.from(e.attributes);for(const n of t)n.value&&g.MUSTACHE_PATTERN.test(n.value)&&(P.isBooleanAttribute(n.name),e.removeAttribute(n.name))}processElementWithContext(e,t,n,s){if(!this.domBindingManager||!this.componentManager)return;const i=(e,n)=>{const s=this.componentManager.buildComponentContext(n),i=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(i&&i!==n){const e=this.componentManager.buildComponentContext(i);return{...t,...s,...e}}return{...t,...s}},r=this.componentManager.buildComponentContextWithProps.bind(this.componentManager);this.componentManager.buildComponentContextWithProps=(t,n)=>n&&(n===e||e.contains(n))?i(n,t):r(t,n);try{if(e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)){const s=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);this.processRefInLoopContext(e,s,t,n),e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:t=>t===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}),r=[];let a;for(;a=i.nextNode();){const e=a;if(e.hasAttribute(`${g.ATTR_PREFIXES.REF}`)){const t=e.getAttribute(`${g.ATTR_PREFIXES.REF}`);r.push({element:e,expression:t})}}r.forEach((({element:e,expression:s})=>{this.processRefInLoopContext(e,s,t,n)}));const o=this.bindLoopItemElement(e,t,n,s);this.setupEventBindingsForLoopItem(e,n);for(let t=0;t<e.childNodes.length;t++){const i=e.childNodes[t];if(i.nodeType===Node.TEXT_NODE){const e=i;if(e.textContent&&g.MUSTACHE_PATTERN.test(e.textContent)&&!P.isTextNodeInsideScript(e)){const t=this.getComponentForTextNode(e);this.processTextNodeWithLoopContext(e,o,t,s)}}else if(i.nodeType===Node.ELEMENT_NODE){const e=i;if("script"===e.tagName.toLowerCase())continue;const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT)||n,r=this.bindLoopItemElement(e,o,t,s);this.setupEventBindingsForLoopItem(e,t),this.processChildrenRecursively(e,r,t,s)}}e.querySelectorAll("template[pp-for]").forEach((t=>{(t.parentElement===e||e.contains(t))&&this.processNestedTemplate(t,n,o)}))}finally{this.componentManager.buildComponentContextWithProps=r}}processChildrenRecursively(e,t,n,s){const i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:t=>{if(t===e)return NodeFilter.FILTER_SKIP;if(t.nodeType===Node.TEXT_NODE){const e=t;if(P.isTextNodeInsideScript(e))return NodeFilter.FILTER_REJECT;if(e.textContent&&g.MUSTACHE_PATTERN.test(e.textContent))return NodeFilter.FILTER_ACCEPT}else if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("script"===e.tagName.toLowerCase())return NodeFilter.FILTER_REJECT;const i=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);return i&&i!==n&&!s?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let r;for(;r=i.nextNode();)if(r.nodeType===Node.TEXT_NODE){const e=r,n=this.getComponentForTextNode(e);this.processTextNodeWithLoopContext(e,t,n,s)}else if(r.nodeType===Node.ELEMENT_NODE){const e=r,n=P.getElementComponent(e),i=this.bindLoopItemElement(e,t,n,s);this.setupEventBindingsForLoopItem(e,n),this.processChildrenRecursively(e,i,n,s)}}processChildElementsWithContext(e,t,n,s){const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:t=>{if(t===e)return NodeFilter.FILTER_SKIP;if(t.nodeType===Node.TEXT_NODE){const e=t;if(P.isTextNodeInsideScript(e))return NodeFilter.FILTER_REJECT;if(e.textContent&&g.MUSTACHE_PATTERN.test(e.textContent))return NodeFilter.FILTER_ACCEPT}else if(t.nodeType===Node.ELEMENT_NODE){const e=t;if("script"===e.tagName.toLowerCase())return NodeFilter.FILTER_REJECT;const s=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);return s&&s!==n?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let r;const a=[],o=[];for(;r=i.nextNode();)r.nodeType===Node.ELEMENT_NODE?a.push(r):r.nodeType===Node.TEXT_NODE&&o.push(r);o.forEach((e=>{const n=this.getComponentForTextNode(e);this.processTextNodeWithLoopContext(e,t,n,s)})),a.forEach((e=>{const n=P.getElementComponent(e),i=this.bindLoopItemElement(e,t,n,s);this.setupEventBindingsForLoopItem(e,n),this.processChildElementsWithContext(e,i,n,s)}))}processRefInLoopContext(e,t,n,s){try{const i=L.decodeEntities(t),r=L.isSingleExpression(i)||i,a=this.expressionEvaluator.evaluateExpression(r,n,s);"function"==typeof a?a(e):a&&"object"==typeof a&&"current"in a?a.current=e:console.warn("⚠️ Invalid ref result:",a),e.removeAttribute(`${g.ATTR_PREFIXES.REF}`)}catch(e){console.error("❌ processRefInLoopContext error:",e)}}getComponentForTextNode(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}processNestedTemplate(e,t,n){const s=e.getAttribute("pp-for");if(!s||this.loopBindings.has(e))return;const i=this.parseLoopExpression(s);if(!i)return void console.error(`Invalid pp-for syntax: "${s}"`);const r=e.parentElement,a=document.createComment(`pp-for: ${s}`);r.insertBefore(a,e);const o=this.findComponentElementForTemplate(e);let c={...n};const h=this.findParentLoopContextForNestedTemplate(e);if(h&&(c={...c,...h}),o&&this.componentManager){const e=o.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e){const t=P.getParentComponentForElement(o);this.componentManager.hasStoredProps(o)||this.componentManager.setupProps(o,t);const n=this.evaluateComponentPropsWithContext(o,c);c={...this.componentManager.buildComponentContext(e),...n,...c}}}const l={template:e,expression:s,itemVar:i.itemVar,indexVar:i.indexVar,iterableExpr:i.iterableExpr,component:t,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:r,placeholder:a};this.loopBindings.set(e,l),this.setupNestedLoopReactivity(l,i.iterableExpr,c),this.renderNestedLoop(l,i.iterableExpr,c)}findParentLoopContextForNestedTemplate(e){let t=e.parentElement;const n={};let s=0;for(;t&&t!==document.body&&s<10;){if(s++,this.loopItemElements.has(t)){const e=this.loopItemContexts.get(t);if(e)for(const[t,s]of Object.entries(e))t in n||(n[t]=s)}for(const[s,i]of this.loopBindings)for(const s of i.renderedItems)(s.element.contains(e)||s.element===t)&&(i.itemVar in n||(n[i.itemVar]=s.context[i.itemVar]),i.indexVar&&!(i.indexVar in n)&&(n[i.indexVar]=s.context[i.indexVar]));t=t.parentElement}return Object.keys(n).length>0?n:null}evaluateComponentPropsWithContext(e,t){const n={};if(!this.componentManager||!this.expressionEvaluator)return n;const s=this.componentManager.extractProps(e,"app");for(const[e,i]of s)try{const s=this.templateRenderer.render(i.expression,t,i.component);n[e]=s}catch(t){console.error(`Failed to evaluate prop "${e}":`,t),n[e]=void 0}return n}findComponentElementForTemplate(e){let t=e.parentElement;for(;t;){if(t.hasAttribute(g.ATTR_PREFIXES.COMPONENT))return t;t=t.parentElement}return null}setupNestedLoopReactivity(e,t,n){const s=`nested_loop_${Date.now()}_${++this.loopCounter}`;let i=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager);const r={id:s,selector:"",dependencies:new Set(i),callback:()=>{const s=e.template,i=this.findComponentElementForTemplate(s);let r=n;if(s.parentElement){const e=this.getParentLoopContextForElement(s);e&&(r={...r,...e})}if(i&&this.componentManager){const t=i.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(t){const s=this.extractParentLoopContextFromBinding(e,n),a=this.evaluateComponentPropsWithContext(i,s),o=this.componentManager.buildComponentContext(t);r={...s,...o,...a}}}this.renderNestedLoop(e,t,r)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(r),e.subscriptionIds.push(s)}getParentLoopContextForElement(e){let t=e.parentElement;for(;t;){if(this.loopItemElements.has(t)){const e=this.loopItemContexts.get(t);if(e)return e}t=t.parentElement}return null}extractParentLoopContextFromBinding(e,t){const n=new Set;for(const[t,s]of this.loopBindings)if(s!==e)for(const t of s.renderedItems)if(t.element.contains(e.template)){n.add(s.itemVar),s.indexVar&&n.add(s.indexVar);break}const s={};for(const[e,i]of Object.entries(t))(n.has(e)||e.startsWith("users")||e.startsWith("set")||e.includes("Getter")||"function"==typeof i)&&(s[e]=i);return s}renderNestedLoop(e,t,n){if(this.componentManager&&this.domBindingManager)try{const s=e.template,i=null!==k.findScope(s),r=this.findComponentElementForLoop(e),a=r&&this.componentManager.hasStoredProps(r);let o;if(i||a)o=n;else{const t=this.componentManager.buildRestrictedComponentContext(e.component,!1),s=this.extractLoopVariablesOnly(n);o={...t,...s}}const c=We(this.expressionEvaluator.evaluateExpression(t,o,e.component));if(!Array.isArray(c))return console.warn(`Nested loop expression "${t}" did not return an array:`,c,`Available context keys: [${Object.keys(o).join(", ")}]`),void this.clearRenderedItems(e);this.updateNestedRenderedItems(e,c,o)}catch(s){console.error(`Error evaluating nested loop expression "${t}":`,s,`Available context keys: [${Object.keys(n).join(", ")}]`),this.clearRenderedItems(e)}}extractLoopVariablesOnly(e){const t={};for(const[n,s]of Object.entries(e))"function"==typeof s&&!("__pphp_key"in s)||n.startsWith("set")&&"function"==typeof s||n.endsWith("Getter")||["getContext","withContext","__getProp"].includes(n)||(t[n]=s);return t}updateNestedRenderedItems(e,t,n){const s=e.renderedItems,i=[],r=new Set,a=new Map;s.forEach((e=>{a.set(e.key,e)})),t.forEach(((t,s)=>{const o=this.generateNestedItemKey(e,t,s,n),c=a.get(o);if(c&&!r.has(c.element))r.add(c.element),this.updateNestedItemContext(e,c,t,s,n),i.push(c);else{const r=this.createNestedLoopItem(e,t,s,o,n);r&&i.push(r)}})),s.forEach((e=>{r.has(e.element)||this.cleanupLoopItem(e)})),this.updateDOMOrder(e,i),e.renderedItems=i}generateNestedItemKey(e,t,n,s){return t&&"object"==typeof t&&"id"in t?String(t.id):`${e.expression}_${n}_${JSON.stringify(s[e.itemVar]||{})}`}createNestedLoopItem(e,t,n,s,i){if(!this.domBindingManager)return null;try{const r={...i,[e.itemVar]:t};e.indexVar&&(r[e.indexVar]=n);const 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:s,element:c,context:r,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map};return this.processElementWithContext(c,r,e.component,h),this.cleanupRawMustacheAttributes(c),h}catch(e){return console.error("Error creating nested loop item:",e),null}}updateNestedItemContext(e,t,n,s,i){const r={...i};r[e.itemVar]=n,e.indexVar&&(r[e.indexVar]=s);const a=this.gatherAllComponentContextsInLoopItem(t.element),o={...r,...a};if(t.context=o,this.loopItemContexts.set(t.element,o),t.textNodeTemplates)for(const[e,n]of t.textNodeTemplates)document.contains(e)&&this.updateTextNodeWithContext(e,n,o,this.getTextNodeComponent(e));if(t.attributeTemplates)for(const[e,n]of t.attributeTemplates)document.contains(e)&&n.forEach(((t,n)=>{var s;try{const i=P.getElementComponent(e),r=this.buildElementSpecificContext(e,o),a=this.templateRenderer.render(t,r,i);null==(s=this.domBindingManager)||s.updateElementProperty(e,n,a)}catch(e){console.error(`Nested binding update error for "${t}":`,e)}}))}bindLoopItemElement(e,t,n,s){const i=this.extractMustacheBindings(e),r=this.findOriginalComponentName(n),a=k.findScope(e);let o=r;o=a?"app"===a?"app":a:this.findLoopParentComponent(e,r);let c=this.componentManager.buildComponentContext(o);c={...c,...t};const h=!!e.getAttribute(g.ATTR_PREFIXES.COMPONENT),l=new Map,p=new Map;i.forEach(((e,t)=>{h&&"class"!==t&&"style"!==t?l.set(t,e):p.set(t,e)}));const u={},d=this.sortPropsByDependency(l);for(const[e,t]of d)try{const n=this.templateRenderer.render(t,c,o);u[e]=n,c[e]=n}catch(t){console.error(`❌ Failed to evaluate prop "${e}":`,t),u[e]=void 0,c[e]=void 0}h&&Object.keys(u).length>0&&(window[n]||(window[n]={}),Object.assign(window[n],u));const m=c;return s&&Object.keys(u).length>0&&Object.assign(s.context,u),s&&i.size>0&&(s.attributeTemplates||(s.attributeTemplates=new Map),s.attributeTemplates.set(e,new Map(i))),i.forEach(((t,n)=>{this.createLoopItemBinding(e,n,t,m,o,s)})),m}sortPropsByDependency(e){const t=Array.from(e.keys()),n=Array.from(e.entries()),s=[],i=[];for(const[e,r]of n)t.some((t=>t!==e&&r.includes(t)))?i.push([e,r]):s.push([e,r]);return[...s,...i]}setupEventBindingsForLoopItem(e,t){if(!this.eventDelegation)return void console.warn("No event delegation manager available");const n=Array.from(e.attributes);for(const s of n)if(ie.isEventAttribute(s.name)){const n=s.name.substring(2);this.eventDelegation.registerEventHandler(e,n,s.value,t),e.removeAttribute(s.name)}}processTextNodeWithLoopContext(e,t,n,s){if(P.isTextNodeInsideScript(e))return;const i=e.textContent||"";if(!L.parse(i).some((e=>"expression"===e.type)))return;s&&(s.textNodeTemplates||(s.textNodeTemplates=new Map),s.textNodeTemplates.set(e,i));const r=this.findActualComponentForTextNode(e);let a=t;r!==n&&s&&this.componentManager&&(a={...this.componentManager.buildComponentContext(r),...s.context}),this.updateTextNodeWithContext(e,i,a,r);const o=`loop_text_${Date.now()}_${Math.random()}`,c=this.templateRenderer.dependencies(i,r,this.stateManager),h=new Set(c),l={id:o,selector:"",dependencies:h,callback:()=>{if(!document.contains(e))return void this.stateManager.removeSubscription(o);let t={};if(this.componentManager&&(t=r!==n&&s?{...this.componentManager.buildComponentContext(r),...s.context}:this.componentManager.buildComponentContext(r)),s){const e={};let n=null;for(const[e,t]of this.loopBindings)if(t.renderedItems.includes(s)){n=t;break}if(n){e[n.itemVar]=s.context[n.itemVar],n.indexVar&&(e[n.indexVar]=s.context[n.indexVar]);const t=this.findParentLoopContext(n.template);t&&Object.assign(e,t)}t={...t,...e}}this.updateTextNodeWithContext(e,i,t,r)},component:r};this.stateManager.addSubscription(l),s&&s.subscriptionIds.push(o)}findActualComponentForTextNode(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e){return t.__uniqueComponentName||e}t=t.parentElement}return"app"}updateTextNodeWithContext(e,t,n,s){const i=L.parse(t),r={};for(const[e,t]of Object.entries(n))r[e]="function"==typeof t&&"__pphp_key"in t?t.value:t;let a="";for(const e of i)if("static"===e.type)a+=e.content;else if(e.expression)try{a+=Ce(this.expressionEvaluator.evaluateExpression(e.expression,r,s))}catch(t){console.warn(`Loop text evaluation error for "${e.expression}":`,t,"Available context keys:",Object.keys(r)),a+=""}e.textContent!==a&&(e.textContent=a)}extractMustacheBindings(e){const t=new Map,n=e.attributes;for(let e=0;e<n.length;e++){const s=n[e];if(s.name!==g.ATTR_PREFIXES.COMPONENT&&"key"!==s.name&&!s.name.startsWith("on")&&s.value){const e=g.MUSTACHE_PATTERN.test(s.value),n=L.decodeEntities(s.value),i=g.MUSTACHE_PATTERN.test(n);(e||i)&&t.set(s.name,n)}}return t}createLoopItemBinding(e,t,n,s,i,r){const a=`loop_item_${Date.now()}_${Math.random()}`,o=k.findScope(e);let c;c=o?"app"===o?"app":o:this.findLoopParentComponent(e,i);const h=this.templateRenderer.dependencies(n,c,this.stateManager);let l=null;const p=[];if(null!=r&&r.parentTemplate&&(l=this.findParentComponentWithPropsFromTemplate(r.parentTemplate),l&&this.componentManager)){const e=l.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e){const t=this.componentManager.getComponentPropDependencies(l,e);p.push(...t);const s=this.componentManager.elementProps.get(l);if(s){const e=Array.from(s.keys());for(const t of e)if(n.includes(t)){const e=s.get(t);if(e){const t=this.templateRenderer.dependencies(e.expression,e.component,this.stateManager);p.push(...t)}}}}}const u=new Set([...h,...p,"*"]);let d=!1,m=0;const f=()=>{var i;if(!d)if(document.contains(e)){m=0;try{const a=this.componentManager.buildComponentContext(c);let o;if(r){o={...a};let e=null;for(const[t,n]of this.loopBindings)if(n.renderedItems.includes(r)){e=n;break}e&&(o[e.itemVar]=r.context[e.itemVar],e.indexVar&&(o[e.indexVar]=r.context[e.indexVar]));for(const[e,t]of Object.entries(r.context))e in o||(o[e]=t);if(l&&this.componentManager){const e=this.componentManager.evaluateProps(l);Object.assign(o,e)}}else o=s;const h=this.templateRenderer.render(n,o,c);null==(i=this.domBindingManager)||i.updateElementProperty(e,t,h)}catch(e){console.error(`❌ Loop item binding evaluation error for "${n}":`,e),console.error("Available context keys:",Object.keys(s))}}else if(m++,m<5){const e=10*Math.pow(2,m-1);setTimeout((()=>{d||f()}),e)}else d=!0,this.stateManager.removeSubscription(a)},E={id:a,selector:"",dependencies:u,callback:()=>{d||f()},element:e,component:c};if(this.stateManager.addSubscription(E),r){r.subscriptionIds.push(a);const e=this.cleanupLoopItem.bind(this);this.cleanupLoopItem=t=>{t===r&&(d=!0),e(t)}}(()=>{document.contains(e)?f():Promise.resolve().then((()=>{if(!d&&document.contains(e))f();else if(!d&&m<5){m++;const e=10*Math.pow(2,m-1);setTimeout((()=>{d||f()}),e)}else!d&&m>=5&&(d=!0,this.stateManager.removeSubscription(a))}))})()}findParentComponentWithPropsFromTemplate(e){var t;let n=e.parentElement;for(;n&&n!==document.body;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)&&null!=(t=this.componentManager)&&t.hasStoredProps(n))return n;n=n.parentElement}return null}findLoopParentComponent(e,t){for(const[t,n]of this.loopBindings)for(const t of n.renderedItems)if(t.element===e||t.element.contains(e))return n.component;return this.findOriginalComponentName(t)}findOriginalComponentName(e){return e.includes("_")&&/\d{13}/.test(e)?e.split("_")[0]:e}updateItemContext(e,t,n,s){const i={...this.createItemContext(e,n,s),...this.gatherAllComponentContextsInLoopItem(t.element)};if(t.context=i,this.loopItemContexts.set(t.element,i),t.refTemplates)for(const[n,s]of t.refTemplates)if(document.contains(n))try{this.processRefAttribute(n,s,i,e.component)}catch(e){console.error(`Ref template update error for "${s}":`,e)}if(t.textNodeTemplates)for(const[e,n]of t.textNodeTemplates)document.contains(e)&&this.updateTextNodeWithContext(e,n,i,this.getTextNodeComponent(e));if(t.attributeTemplates)for(const[e,n]of t.attributeTemplates)document.contains(e)&&n.forEach(((t,n)=>{var s;try{const r=P.getElementComponent(e),a=this.buildElementSpecificContext(e,i),o=this.templateRenderer.render(t,a,r);null==(s=this.domBindingManager)||s.updateElementProperty(e,n,o)}catch(e){console.error(`Attribute binding update error for "${t}":`,e)}}))}gatherAllComponentContextsInLoopItem(e){if(!this.componentManager)return{};const t={};if(e.hasAttribute(g.ATTR_PREFIXES.COMPONENT)){const n=e.getAttribute(g.ATTR_PREFIXES.COMPONENT),s=this.componentManager.buildComponentContext(n);Object.assign(t,s)}return e.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}]`).forEach((e=>{var n;const s=e.getAttribute(g.ATTR_PREFIXES.COMPONENT),i=null==(n=this.componentManager)?void 0:n.buildComponentContext(s);Object.assign(t,i)})),t}buildElementSpecificContext(e,t){if(!this.componentManager)return t;const n=P.getElementComponent(e),s=this.componentManager.buildComponentContext(n);return{...t,...s}}getTextNodeComponent(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}updateDOMOrder(e,t){let n=e.isSSR&&e.listContainer?e.template:e.placeholder;t.forEach((t=>{(t.element.parentElement!==e.parentElement||t.element!==n.nextSibling)&&e.parentElement.insertBefore(t.element,n.nextSibling),n=t.element}))}clearRenderedItems(e){e.renderedItems.forEach((e=>{this.cleanupLoopItem(e)})),e.renderedItems=[]}cleanupLoopItem(e){if(e.element instanceof HTMLElement){const t=e.element;if(t.style.transition||"none"!==getComputedStyle(t).transition)return t.style.opacity="0",void requestAnimationFrame((()=>{this.performCleanup(e)}))}this.performCleanup(e)}performCleanup(e){this.loopItemElements.delete(e.element),this.loopItemContexts.delete(e.element),e.element.parentElement&&e.element.parentElement.removeChild(e.element),e.subscriptionIds.forEach((e=>{this.stateManager.removeSubscription(e)}))}isLoopItem(e){return this.loopItemElements.has(e)}getLoopItemContext(e){return this.loopItemContexts.get(e)}cleanupDetachedTemplates(e){for(const t of e)"childList"===t.type&&t.removedNodes.forEach((e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(document.contains(t))return;if("TEMPLATE"===t.tagName&&t.hasAttribute("pp-for")){const e=t;document.contains(e)||this.cleanupTemplate(e)}t.querySelectorAll("template[pp-for]").forEach((e=>{const t=e;document.contains(t)||this.cleanupTemplate(t)}))}}))}cleanupTemplate(e){const t=this.loopBindings.get(e);t&&(this.clearRenderedItems(t),t.subscriptionIds.forEach((e=>{this.stateManager.removeSubscription(e)})),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 ve{constructor(e){this.evaluator=e}static containsMustacheExpression(e){if(g.MUSTACHE_PATTERN.test(e))return!0;const t=L.decodeEntities(e);return g.MUSTACHE_PATTERN.test(t)}render(e,t,n){const s=L.isSingleExpression(e);if(s)return this.evaluator.evaluateExpression(s,t,n);let i="";for(const s of L.parse(e))if("static"===s.type)i+=s.content;else if(s.expression)try{i+=Ce(this.evaluator.evaluateExpression(s.expression,t,n))}catch{}return i}dependencies(e,t,n){const s=L.extractExpressions(e),i=new Set;for(const e of s)for(const s of this.evaluator.extractDependencies(e,t,n))i.add(s);return[...i]}}class en{constructor(e){d(this,"componentStack",["app"]),d(this,"elementProps",new WeakMap),d(this,"contextCache",new G(100)),d(this,"contextIndex",new Map),d(this,"contextInvalidated",new Set),d(this,"stateManager"),d(this,"processedScripts",new WeakSet),d(this,"componentFunctions",new Map),d(this,"expressionEvaluator"),d(this,"domBindingManager"),d(this,"templateRenderer"),d(this,"updateTimeouts"),d(this,"updateBatcher",new St),d(this,"propDependencyCache",new Map),this.stateManager=e,this.updateBatcher=new St,this.stateManager.onStateChange((e=>this.invalidateContextCache(e)))}getPropDependencies(e,t){var n;const s=this.findElementWithProps(t);if(!s)return[];const i=this.elementProps.get(s);if(!i||!i.has(e))return[];const r=i.get(e),a=(null==(n=this.templateRenderer)?void 0:n.dependencies(r.expression,r.component,this.stateManager))||[],o=new Set(a);for(const e of a){const t=e.split("."),n=t[t.length-1];this.getPropDependencies(n,r.component).forEach((e=>o.add(e)))}return Array.from(o)}buildRestrictedComponentContext(e,t=!1){const n={};window[e]&&Object.assign(n,window[e]);const s=this.componentFunctions.get(e);if(s)for(const[e,t]of s)n[e]=t;const i=this.stateManager.getState(),r=Object.keys(i).filter((t=>t.startsWith(e+".")));for(const t of r){const s=t.substring(e.length+1);s in n||(n[s]=i[t])}if(t&&"app"!==e){const e=this.componentFunctions.get("app");if(e)for(const[t,s]of e)t in n||(n[t]=s);if(window.app)for(const[e,t]of Object.entries(window.app))"function"==typeof t&&!("__pphp_key"in t)&&(e in n||(n[e]=t))}return n}getComponentPropDependencies(e,t){if(this.propDependencyCache.has(e))return this.propDependencyCache.get(e);const n=new Set,s=this.elementProps.get(e);s&&this.templateRenderer&&s.forEach((t=>{var s;const i=null==(s=this.templateRenderer)?void 0:s.dependencies(t.expression,t.component,this.stateManager);null==i||i.forEach((e=>n.add(e)));const r=this.findElementWithProps(t.component);r&&r!==e&&this.getComponentPropDependencies(r,t.component).forEach((e=>n.add(e)))}));const i=Array.from(n);return this.propDependencyCache.set(e,i),i}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 ve(e)}extractProps(e,t){const n=new Map,s=e.attributes,i=k.findScope(e),r=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);let a=t;i&&(a="app"===i?"app":i);for(let t=0;t<s.length;t++){const i=s[t];if(i.name!==g.ATTR_PREFIXES.COMPONENT&&i.name!==g.ATTR_PREFIXES.SPREAD&&i.name!==g.ATTR_PREFIXES.LOOP&&!ie.isEventAttribute(i.name)&&i.value&&ve.containsMustacheExpression(i.value)){if(r&&this.mightReferenceSelfProps(i.value,e))continue;const t=this.attributeToPropName(i.name),s={name:t,expression:i.value,component:a,subscriptionIds:[]};n.set(t,s)}}return n}mightReferenceSelfProps(e,t){const n=this.elementProps.get(t);if(!n)return!1;const s=Array.from(n.keys()),i=L.extractExpressions(e);if(0===i.length)return!1;for(const e of i)try{const t=D(e,{ecmaVersion:2022,sourceType:"script"}),n=new Set,i=new Set;U(t,{Identifier:(e,t)=>{const s=null==t?void 0:t[t.length-1];"MemberExpression"===(null==s?void 0:s.type)&&s.property===e&&!s.computed||("FunctionExpression"===(null==s?void 0:s.type)||"ArrowFunctionExpression"===(null==s?void 0:s.type))&&(s.params||[]).includes(e)||("MemberExpression"===(null==s?void 0:s.type)&&s.object===e?i.add(e.name):n.add(e.name))}});for(const e of s){if("dataState"===e)continue;const t=n.has(e),s=i.has(e)&&!n.has(e);if(t&&!s)return!0}}catch(t){console.error(`❌ Failed to parse mustache expression "${e}":`,t);continue}return!1}attributeToPropName(e){return e.replace(/-([a-z])/g,((e,t)=>t.toUpperCase()))}setupProps(e,t){const n=this.extractProps(e,t);0!==n.size&&(this.elementProps.set(e,n),this.expressionEvaluator&&n.forEach(((t,n)=>{this.setupPropBinding(e,t)})))}setupPropBinding(e,t){var n;if(!this.expressionEvaluator)return;const s=`prop_${Date.now()}_${Math.random()}`,i=(null==(n=this.templateRenderer)?void 0:n.dependencies(t.expression,t.component,this.stateManager))||[],r={id:s,selector:"",dependencies:new Set(i),callback:()=>{const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);t&&(this.updateBatcher.scheduleUpdate(t,e),this.refreshComponentBindings(e,t))},element:e,component:t.component};this.stateManager.addSubscription(r),t.subscriptionIds.push(s)}refreshComponentBindings(e,t){this.contextInvalidated.add(t),this.contextCache.delete(t),this.domBindingManager&&this.domBindingManager.refreshComponentElement(e,t)}evaluateProps(e){const t={},n=this.elementProps.get(e);if(!n||!this.expressionEvaluator)return t;const s=n.values().next().value;if(!s)return t;const i=this.buildComponentContextWithProps(s.component);return n.forEach(((e,n)=>{var s;try{const r=null==(s=this.templateRenderer)?void 0:s.render(e.expression,i,e.component);t[n]="function"==typeof r?"__pphp_key"in r?r:(...e)=>r.apply(this,e):r}catch(e){console.error(`❌ Failed to evaluate prop "${n}":`,e),t[n]=void 0}})),t}cleanupProps(e){const t=this.elementProps.get(e);t&&(t.forEach((e=>{e.subscriptionIds.forEach((e=>{this.stateManager.removeSubscription(e)}))})),this.elementProps.delete(e))}buildComponentContextWithProps(e,t){const n=this.buildComponentContext(e);let s=this.findElementWithProps(e);if(t&&this.elementProps.has(t)&&(s=t),s)try{const i=this.evaluatePropsWithContext(s,e,t);Object.keys(i).length>0&&Object.keys(i).forEach((e=>{n[e]=i[e]}))}catch(t){console.error(`❌ Error evaluating props for ${e}:`,t)}return n}buildRestrictedComponentContextWithProps(e,t){const n=this.buildRestrictedComponentContext(e,!1);if(this.elementProps.has(t)){const e=this.evaluateProps(t);Object.assign(n,e)}return n}evaluatePropsWithContext(e,t,n){const s={},i=this.elementProps.get(e);if(!i||!this.expressionEvaluator)return s;const r=i.values().next().value;if(!r)return s;const a=r.component;let o=this.buildComponentContextWithProps(a);const c=new Map,h=new Map,l=Array.from(i.keys());i.forEach(((e,t)=>{l.some((n=>n!==t&&e.expression.includes(n)))?h.set(t,e):c.set(t,e)})),c.forEach(((e,t)=>{var n;try{const i=null==(n=this.templateRenderer)?void 0:n.render(e.expression,o,e.component);s[t]=i}catch(e){console.error(`❌ Failed to evaluate prop "${t}":`,e),s[t]=void 0}}));const p={...o,...s};return h.forEach(((e,t)=>{var n;try{const i=null==(n=this.templateRenderer)?void 0:n.render(e.expression,p,e.component);s[t]=i}catch(e){console.error(`❌ Failed to evaluate prop "${t}":`,e),s[t]=void 0}})),s}findElementWithProps(e){const t=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${e}"]`);for(const e of t){const t=this.elementProps.get(e);if(t&&t.size>0)return e}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 n=e.split("_");n.pop();const s=n.join("_");window[s]&&Object.assign(t,window[s])}"app"!==e&&window[e]&&Object.assign(t,window[e]),"app"===e&&window.app&&Object.assign(t,window.app);const n=this.componentFunctions.get(e);if(n)for(const[e,s]of n)t[e]=s;const s=this.stateManager.getState();for(const n of Object.keys(s))if(n.startsWith(e+".")){const i=n.substring(e.length+1);i in t||(t[i]=s[n])}return t}invalidateContextCache(e){if(e.startsWith("app.")){this.contextCache.clear();for(const e of this.contextInvalidated.keys())this.contextInvalidated.add(e);return}const t=e.indexOf(".");if(-1!==t){const n=e.slice(0,t);this.invalidateComponent(n)}}invalidateComponent(e){this.contextInvalidated.add(e),this.contextIndex.delete(e)}executePhpScripts(e){const t=this.componentStack.length,n=e.getAttribute(g.ATTR_PREFIXES.COMPONENT),s=e===document.body;if(n||s){if(n){this.pushComponent(n);const t=this.getParentComponent(e);this.setupProps(e,t)}this.getRelevantScripts(e,s).forEach((e=>{const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);t&&t!==n?(this.pushComponent(t),this.executeScript(e),this.popComponent()):this.executeScript(e)}))}for(Array.from(e.children).forEach((e=>this.executePhpScripts(e)));this.componentStack.length>t;)this.popComponent()}getParentComponent(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}getRelevantScripts(e,t){return Array.from(e.querySelectorAll(`script[type="${g.SCRIPT_TYPE}"]`)).filter((n=>{if(this.processedScripts.has(n))return!1;if(t)return!!n.hasAttribute(g.ATTR_PREFIXES.COMPONENT)||!n.closest(`[${g.ATTR_PREFIXES.COMPONENT}]`);let s=n.parentElement;for(;s&&s!==e;){if(s.hasAttribute(g.ATTR_PREFIXES.COMPONENT))return!1;s=s.parentElement}return s===e||e.contains(n)}))}executeScript(e){if(this.processedScripts.has(e))return;this.processedScripts.add(e);const t=this.getCurrentComponent(),n=e.textContent||"",s=L.decodeEntities(n);try{const n=this.findComponentElementForScript(e,t);if(n===e){const t=this.getParentComponent(e);this.setupProps(e,t)}let i;if(this.hasExplicitContext(n||e,t))i=this.buildComponentContextWithProps(t,n);else if(i=this.buildRestrictedComponentContext(t,!1),n&&this.hasStoredProps(n)){const e=this.evaluateProps(n);Object.assign(i,e)}window[t]||(window[t]={}),this.executeScriptFunctions(s,t,i)}catch(e){console.error(`Script execution failed in component ${t}:`,e),console.error("Script content:",s)}}hasExplicitContext(e,t){return null!==k.findScope(e)}findComponentElementForScript(e,t){if(e.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(g.ATTR_PREFIXES.COMPONENT)===t)return n;n=n.parentElement}const s=document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const e of s)if(this.elementProps.has(e))return e;return s[0]||void 0}executeScriptFunctions(e,t,n){const s=this.extractFunctionNames(e),i=this.findElementWithProps(t),r=this.extractVariableDeclarations(e);let a={...n};r.forEach((e=>{delete a[e];const t=`set${rs(e)}`,n=`${e}Getter`;delete a[t],delete a[n]}));const o=i&&this.hasStoredProps(i);if(o){a=this.buildRestrictedComponentContext(t,!1);const e=this.evaluateProps(i);a={...a,...e}}else if(i){const e=this.evaluateProps(i);Object.assign(a,e)}a.getContext=()=>{if(o){return{...this.buildRestrictedComponentContext(t,!1),...i?this.evaluateProps(i):{}}}return this.buildComponentContextWithProps(t)},a.withContext=e=>{const t=a.getContext();return e.call(t,t)},a.__getProp=e=>{if(i)return this.evaluateProps(i)[e]};const c=Ne.getInstance(),h=new Set;if(i){const e=this.evaluateProps(i);for(const[t,n]of Object.entries(e))"function"==typeof n&&"__pphp_key"in n&&(h.add(t),/^set[A-Z]/.test(t)&&h.add(t))}let l=c.transformStateDeclarations(e,h);l=this.modifyScriptForReactiveProps(l,t,i||void 0);const p=`\n ${l}\n\n ${s.map((e=>`\n if (typeof ${e} === 'function') {\n this['${e}'] = ${e};\n }\n `)).join("\n")}\n `,u={};for(const[e,t]of Object.entries(a))this.isValidJavaScriptIdentifier(e)&&(u[e]=t);const d=Object.keys(u),m=d.map((e=>u[e]));if(this.checkIfInLoopItem()){const e=this.extractLoopItemContext();this.domBindingManager.stateManager.currentLoopContext=e}try{new Function(...d,p).call(window[t],...m),window[t].getContext=a.getContext,window[t].withContext=a.withContext,window[t].__getProp=a.__getProp;for(const e of s){const n=window[t][e];"function"==typeof n&&this.storeFunctionForComponent(t,e,n)}this.invalidateComponent(t)}catch(n){console.error("Script execution failed:",n),console.error("Component:",t),console.error("Original script:",e),console.error("Available context keys:",Object.keys(u)),console.error("Should isolate:",o)}finally{this.domBindingManager.stateManager.currentLoopContext=null}}isValidJavaScriptIdentifier(e){return!Se.has(e)&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}checkIfInLoopItem(){return!1}extractLoopItemContext(){return{}}extractVariableDeclarations(e){const t=Ne.getInstance().extractStateDeclarations(e).map((e=>e.variableName)),n=[],s=/(?:const|let|var)\s*\[\s*([^,\]]+)(?:\s*,\s*([^,\]]+))?\s*\]/g;let i;for(;null!==(i=s.exec(e));)i[1]&&!t.includes(i[1].trim())&&n.push(i[1].trim()),i[2]&&!t.includes(i[2].trim())&&n.push(i[2].trim());const r=/(?:const|let|var)\s+([a-zA-Z_$][\w$]*)/g;for(;null!==(i=r.exec(e));)t.includes(i[1])||n.push(i[1]);return[...t,...n]}modifyScriptForReactiveProps(e,t,n){if(!n||!this.elementProps.has(n))return e;const s=this.elementProps.get(n),i=Array.from(s.keys());let r=e;return i.forEach((e=>{r=this.replacePropOutsideStrings(r,e)})),r}replacePropOutsideStrings(e,t){let n="",s=0;const i=e.length;for(;s<i;){const r=e[s];if("'"!==r)if('"'!==r)if("`"!==r){if("/"===r&&s+1<i){if("/"===e[s+1]){const t=e.indexOf("\n",s),r=-1===t?i:t;n+=e.slice(s,r),s=r;continue}if("*"===e[s+1]){const t=e.indexOf("*/",s+2),r=-1===t?i:t+2;n+=e.slice(s,r),s=r;continue}}this.matchesPropName(e,s,t)?(n+=`__getProp('${t}')`,s+=t.length):(n+=r,s++)}else{const t=this.findTemplateEnd(e,s);n+=e.slice(s,t+1),s=t+1}else{const t=this.findStringEnd(e,s,'"');n+=e.slice(s,t+1),s=t+1}else{const t=this.findStringEnd(e,s,"'");n+=e.slice(s,t+1),s=t+1}}return n}findStringEnd(e,t,n){let s=t+1;for(;s<e.length;){if(e[s]===n&&"\\"!==e[s-1])return s;"\\"===e[s]&&s++,s++}return e.length-1}findTemplateEnd(e,t){let n=t+1,s=0;for(;n<e.length;){const t=e[n];if("`"===t&&0===s)return n;"$"===t&&n+1<e.length&&"{"===e[n+1]?(s++,n++):"}"===t&&s>0?s--:"\\"===t&&n++,n++}return e.length-1}matchesPropName(e,t,n){if(t+n.length>e.length||e.substr(t,n.length)!==n)return!1;const s=t>0?e[t-1]:"",i=t+n.length<e.length?e[t+n.length]:"",r=0===t||!/[a-zA-Z0-9_$]/.test(s),a=t+n.length===e.length||!/[a-zA-Z0-9_$]/.test(i);if(!r||!a||"."===s||"."===i)return!1;const o=e.slice(t+n.length);if(/^\s*[=:]/.test(o))return!1;const c=e.slice(Math.max(0,t-20),t);return!/[a-zA-Z0-9_$]\s*\.\s*$/.test(c)}extractFunctionNames(e){return Ne.getInstance().extractFunctionNames(e)}storeFunctionForComponent(e,t,n){this.componentFunctions.has(e)||this.componentFunctions.set(e,new Map),this.componentFunctions.get(e).set(t,n),window[e]||(window[e]={}),window[e][t]=n}getComponentFunctions(e){return this.componentFunctions.get(e)}destroy(){if(this.updateTimeouts){for(const e of this.updateTimeouts.values())clearTimeout(e);this.updateTimeouts.clear()}this.componentFunctions.clear(),this.elementProps=new WeakMap,this.contextCache.clear(),this.propDependencyCache.clear()}}class St{constructor(){d(this,"pendingUpdates",new Map),d(this,"batchTimeout",null),d(this,"componentManager"),d(this,"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),null===this.batchTimeout&&(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[e,n]of t)this.processComponentUpdate(e,n)}sortUpdatesByDependency(e){const t=new WeakMap,n=e=>{let n=t.get(e);return null==n&&(n=P.getElementDepth(e),t.set(e,n)),n};return Array.from(e.entries()).sort((([,e],[,t])=>Math.min(...Array.from(e,n))-Math.min(...Array.from(t,n))))}processComponentUpdate(e,t){if(!this.componentManager||!this.domBindingManager)return;this.componentManager.invalidateComponent(e);const n=[],s=[],i=[];for(const r of t){if(!document.contains(r))continue;const t=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,null);let a;for(;a=t.nextNode();)n.push(a);const o=this.domBindingManager.loopManager;if(o){const t=o.getAllLoops();for(const[n,i]of t)i.component===e&&r.contains(n)&&s.push([n,i])}i.push(r)}this.updateTextNodesBatch(n,e),this.updateLoopsBatch(s),this.updateElementsBatch(i,e)}updateTextNodesBatch(e,t){const n=this.domBindingManager.textNodeManager;n&&e.forEach((e=>{document.contains(e)&&P.getComponentForNode(e)===t&&n.updateTextNode(e)}))}updateLoopsBatch(e){const t=this.domBindingManager.loopManager;if(!t)return;const n=new Map;e.forEach((([e,t])=>{const s=P.getElementDepth(e);n.has(s)||n.set(s,[]),n.get(s).push([e,t])}));const s=Array.from(n.keys()).sort(((e,t)=>e-t));for(const e of s)n.get(e).forEach((([e,n])=>{document.contains(e)&&t.renderLoop(n,n.iterableExpr)}))}updateElementsBatch(e,t){e.forEach((e=>{document.contains(e)&&this.domBindingManager.processElementBindings(e,!0)}))}}const g={ATTR_PREFIXES:{COMPONENT:"pp-component",LOOP:"pp-for",SPREAD:"pp-spread",REF:"pp-ref"},SCRIPT_TYPE:"text/pp",MAX_CACHE_SIZE:2e3,DEBOUNCE_MS:16,MUSTACHE_PATTERN:/\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}/},Se=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 tn(e,t){let n;return(...s)=>{clearTimeout(n),n=window.setTimeout((()=>e(...s)),t)}}function rs(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ce(e){if(null==e||"boolean"==typeof e||"function"==typeof e||Array.isArray(e)&&0===e.length||"object"==typeof e&&0===Object.keys(e).length)return"";if("number"==typeof e)return String(e);if("string"==typeof e)return e;if(Array.isArray(e)){if(e.some((e=>null!==e&&("object"==typeof e||Array.isArray(e)))))try{return JSON.stringify(e)}catch{return"[Array]"}return e.map((e=>Ce(e))).filter((e=>""!==e)).join("")}if("object"==typeof e)try{return JSON.stringify(e)}catch{return"[object Object]"}return String(e)}function Oe(e){return"function"==typeof e&&"__pphp_key"in e}function We(e){return Oe(e)?e.value:e}function as(e,t={}){if(!Oe(e))return e;const n=e.value;return t.forComparison||t.forLogical||t.forceExtract||null==n||"boolean"==typeof n||"string"==typeof n||"number"==typeof n?n:e}function os(e,t=!1){const n={};for(const[s,i]of Object.entries(e))Oe(i)?n[s]=t?as(i):i.value:n[s]=i;return n}function sn(e){return e.includes("?")||e.includes("&&")||e.includes("||")||e.includes("===")||e.includes("!==")||e.includes("==")||e.includes("!=")||e.includes(">=")||e.includes("<=")||e.includes(">")||e.includes("<")||/^!/.test(e.trim())}class k{static findScope(e){const t=e instanceof Text?e.parentElement:e;if(!t)return null;if(this.scopeCache.has(t))return this.scopeCache.get(t);const n=this.findScopeUncached(t);return this.scopeCache.set(t,n),this.trackElement(t),n}static findScopeUncached(e){const t=this.findScopeInSiblings(e);if(null!==t)return t;let n=e.parentElement;for(;n&&n!==document.body;){if(n instanceof Element&&n.hasAttribute(g.ATTR_PREFIXES.COMPONENT))return null;const e=this.findScopeInSiblings(n);if(null!==e)return e;n=n.parentElement}return null}static findScopeInSiblings(e){let t=e.previousSibling,n=0;for(;t;){if(t.nodeType===Node.COMMENT_NODE){const e=t,s=this.parseCommentNode(e,n);if(null!==s)if("end"===s.type)n++;else if("start"===s.type){if(0===n)return s.name;n--}}t=t.previousSibling}return null}static parseCommentNode(e,t){if(this.commentCache.has(e)){const t=this.commentCache.get(e);if(""===t)return null;if("/pp-scope"===t)return{type:"end",name:""};if(t.startsWith("pp-scope:"))return{type:"start",name:t.substring(9)}}const n=(e.textContent||"").trim();if("/pp-scope"===n)return this.commentCache.set(e,n),{type:"end",name:""};if(n.startsWith("pp-scope:")){const t=n.substring(9).trim();return this.isValidScopeName(t)?(this.commentCache.set(e,n),{type:"start",name:t}):(console.warn(`⚠️ Invalid scope name in comment: "${t}". Scope names must be valid identifiers or "app".`),this.commentCache.set(e,""),null)}return this.commentCache.set(e,""),null}static isValidScopeName(e){return"app"===e||/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)}static removeScopeComments(){const e=document.createTreeWalker(document.body,NodeFilter.SHOW_COMMENT,{acceptNode:e=>{const t=(e.textContent||"").trim();return"/pp-scope"===t||t.startsWith("pp-scope:")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),t=[];let n;for(;n=e.nextNode();)t.push(n);if(0===t.length)return void console.debug("No scope comments found to remove");console.debug(`Found ${t.length} scope comments to remove`);let s=0;for(const e of t)try{e.parentNode&&(e.parentNode.removeChild(e),s++)}catch(e){console.error("Failed to remove scope comment:",e)}console.debug(`✅ Successfully removed ${s} scope comments from DOM`)}static preCacheAllScopes(){const e=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,null),t=[];let n;for(;n=e.nextNode();)t.push(n);for(const e of t)this.findScope(e);console.debug(`Pre-cached scopes for ${t.length} elements`)}static trackElement(e){this.trackedElements.add(e),this.trackedElements.size>=this.MAX_TRACKED_ELEMENTS&&this.scheduleCleanup(),Date.now()-this.lastCleanup>this.CLEANUP_INTERVAL&&this.scheduleCleanup()}static scheduleCleanup(){this.cleanupScheduled||(this.cleanupScheduled=!0,requestIdleCallback((()=>{this.performCleanup(),this.cleanupScheduled=!1}),{timeout:1e3}))}static performCleanup(){const e=[];let t=0;for(const n of this.trackedElements){if(t++,t%100==0&&!this.cleanupScheduled)break;document.contains(n)||e.push(n)}e.forEach((e=>{this.scopeCache.delete(e),this.trackedElements.delete(e)})),this.lastCleanup=Date.now(),e.length>0&&console.debug(`ScopeResolver cleanup: removed ${e.length} detached elements, ${this.trackedElements.size} elements remaining`)}static clearCache(){this.scopeCache=new WeakMap,this.commentCache=new WeakMap,this.trackedElements.clear(),this.cleanupScheduled=!1,this.lastCleanup=0}static invalidateElement(e){this.scopeCache.delete(e),this.trackedElements.delete(e)}static invalidateTree(e){this.invalidateElement(e);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let n;for(;n=t.nextNode();)this.invalidateElement(n)}static getCacheStats(){return{trackedElements:this.trackedElements.size,lastCleanup:this.lastCleanup,cleanupScheduled:this.cleanupScheduled}}static forceCleanup(){this.cleanupScheduled=!0,this.performCleanup(),this.cleanupScheduled=!1}}d(k,"scopeCache",new WeakMap),d(k,"commentCache",new WeakMap),d(k,"trackedElements",new Set),d(k,"cleanupScheduled",!1),d(k,"CLEANUP_INTERVAL",5e3),d(k,"MAX_TRACKED_ELEMENTS",1e3),d(k,"lastCleanup",0);class nn{static validate(e,t){const n=[],s=[];try{const t=D(e,{ecmaVersion:2022,sourceType:"script"}),i=this.validateAST(t,e);n.push(...i.errors),s.push(...i.warnings);const r=this.validateSyntax(e);n.push(...r.errors),s.push(...r.warnings)}catch(e){n.push(`Invalid JavaScript syntax: ${e instanceof Error?e.message:String(e)}`)}return{valid:0===n.length,errors:n,warnings:s}}static validateAST(e,t){const n=[],s=[];return U(e,{ConditionalExpression:e=>{const i=t.slice(e.consequent.start,e.consequent.end),r=this.validateBranch(i,"truthy");n.push(...r.errors),s.push(...r.warnings);const a=t.slice(e.alternate.start,e.alternate.end),o=this.validateBranch(a,"falsy");n.push(...o.errors),s.push(...o.warnings)}}),{errors:n,warnings:s}}static validateBranch(e,t){const n=[],s=[];try{return D(e,{ecmaVersion:2022,sourceType:"script"}),{errors:n,warnings:s}}catch{const i=this.countQuotes(e);if(i.single%2!=0&&(n.push(`Unmatched single quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,"'"))){const t=this.suggestQuoteFix(e,"'");t&&n.push(` Did you mean: ${t}`)}if(i.double%2!=0&&(n.push(`Unmatched double quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,'"'))){const t=this.suggestQuoteFix(e,'"');t&&n.push(` Did you mean: ${t}`)}i.single%2==0&&i.double%2==0&&this.looksLikeUnquotedLiteral(e)&&s.push(`Value "${e}" in ternary ${t} branch may need quotes. Did you mean '${e}' or "${e}"?`)}return{errors:n,warnings:s}}static hasTrailingOrLeadingQuote(e,t){const n=e.startsWith(t),s=e.endsWith(t);return n&&!s||!n&&s}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();if(!t||this.isAlreadyQuoted(t))return!1;try{return D(t,{ecmaVersion:2022,sourceType:"script"}),!1}catch{}return!(Se.has(t)||"true"===t||"false"===t||"null"===t||"undefined"===t||!isNaN(Number(t))&&""!==t||/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)||t.includes(".")||/\[.*\]/.test(t)||/\(.*\)/.test(t))&&!!(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,n=0,s=!1;for(let i=0;i<e.length;i++)s?s=!1:"\\"!==e[i]?("'"===e[i]&&t++,'"'===e[i]&&n++):s=!0;return{single:t,double:n}}static validateSyntax(e){const t=[],n=this.checkBrackets(e);n.valid||t.push(n.error);const s=this.checkParentheses(e);return s.valid||t.push(s.error),{errors:t,warnings:[]}}static checkBrackets(e){let t=0,n=!1,s="";for(let i=0;i<e.length;i++){const r=e[i],a=i>0?e[i-1]:"";if(n||"'"!==r&&'"'!==r?n&&r===s&&"\\"!==a&&(n=!1,s=""):(n=!0,s=r),!n&&("{"===r&&t++,"}"===r&&t--,t<0))return{valid:!1,error:"Unexpected closing bracket '}'"}}return 0!==t?{valid:!1,error:"Mismatched brackets - missing '}'"}:{valid:!0,error:""}}static checkParentheses(e){let t=0,n=!1,s="";for(let i=0;i<e.length;i++){const r=e[i],a=i>0?e[i-1]:"";if(n||"'"!==r&&'"'!==r?n&&r===s&&"\\"!==a&&(n=!1,s=""):(n=!0,s=r),!n&&("("===r&&t++,")"===r&&t--,t<0))return{valid:!1,error:"Unexpected closing parenthesis ')'"}}return 0!==t?{valid:!1,error:"Mismatched parentheses - missing ')'"}:{valid:!0,error:""}}}const $=class e{constructor(){d(this,"componentElementsCache",new G(100)),d(this,"scriptElementsCache",new G(50)),d(this,"templateElementsCache",new G(50)),d(this,"selectorCache",new G(200)),d(this,"elementComponentCache",new WeakMap),d(this,"parentComponentCache",new WeakMap),d(this,"contextComponentCache",new WeakMap),d(this,"elementDepthCache",new WeakMap),d(this,"elementChildrenCache",new WeakMap),d(this,"cacheHits",0),d(this,"cacheMisses",0)}static getInstance(){return e.instance||(e.instance=new e),e.instance}queryComponentElements(t){const n=e.CACHE_KEYS.COMPONENT_ELEMENTS(t);if(this.componentElementsCache.has(n))return this.cacheHits++,this.componentElementsCache.get(n);this.cacheMisses++;const s=Array.from(document.querySelectorAll(`[${g.ATTR_PREFIXES.COMPONENT}="${t}"]`));return s.forEach((e=>{this.elementComponentCache.set(e,t)})),this.componentElementsCache.set(n,s),s}querySelectorAll(t){const n=e.CACHE_KEYS.SELECTOR(t);if(this.selectorCache.has(n))return this.cacheHits++,this.selectorCache.get(n);this.cacheMisses++;const s=Array.from(document.querySelectorAll(t));return this.selectorCache.set(n,s),s}getElementComponent(e){if(this.elementComponentCache.has(e))return this.cacheHits++,this.elementComponentCache.get(e);this.cacheMisses++;const t=e.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(t)return this.elementComponentCache.set(e,t),t;let n=e.parentElement;for(;n;){const t=n.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(t)return this.elementComponentCache.set(e,t),t;n=n.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=k.findScope(e);let n;return n=t?"app"===t?"app":t:this.getElementComponent(e),this.contextComponentCache.set(e,n),n}getParentOfComponent(e,t){if(this.parentComponentCache.has(t))return this.cacheHits++,this.parentComponentCache.get(t);if(this.cacheMisses++,"app"===e)return this.parentComponentCache.set(t,"app"),"app";let n=t;for(;n&&n.getAttribute(g.ATTR_PREFIXES.COMPONENT)!==e;)n=n.parentElement;if(!n)return this.parentComponentCache.set(t,"app"),"app";let s=n.parentElement;for(;s;){const e=s.getAttribute(g.ATTR_PREFIXES.COMPONENT);if(e)return this.parentComponentCache.set(t,e),e;s=s.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,n=e.parentElement;for(;n&&n!==document.body;)t++,n=n.parentElement;return this.elementDepthCache.set(e,t),t}getFirstComponentElement(e){const t=this.queryComponentElements(e);return t.length>0?t[0]:null}getComponentScripts(t,n){const s=e.CACHE_KEYS.SCRIPTS(t,(null==n?void 0:n.tagName)||"global");if(this.scriptElementsCache.has(s))return this.cacheHits++,this.scriptElementsCache.get(s);this.cacheMisses++;let i=[];if(n){const e=n.querySelectorAll(`script[type="${g.SCRIPT_TYPE}"]`);for(const t of e)t instanceof HTMLScriptElement&&i.push(t)}else{const e=document.querySelectorAll(`script[type="${g.SCRIPT_TYPE}"]`);for(const n of e)if(n instanceof HTMLScriptElement){const e=n.getAttribute(g.ATTR_PREFIXES.COMPONENT);(e===t||!e&&!n.closest(`[${g.ATTR_PREFIXES.COMPONENT}]`))&&i.push(n)}}return this.scriptElementsCache.set(s,i),i}getComponentTemplates(t,n){const s=e.CACHE_KEYS.TEMPLATES(t,(null==n?void 0:n.tagName)||"global");if(this.templateElementsCache.has(s))return this.cacheHits++,this.templateElementsCache.get(s);this.cacheMisses++;let i=[];if(n){const e=n.querySelectorAll("template[pp-for]");for(const n of e)n instanceof HTMLTemplateElement&&this.getElementComponent(n)===t&&i.push(n)}else{const e=document.querySelectorAll("template[pp-for]");for(const n of e)n instanceof HTMLTemplateElement&&this.getElementComponent(n)===t&&i.push(n)}return this.templateElementsCache.set(s,i),i}querySelector(e){const t=this.querySelectorAll(e);return t.length>0?t[0]:null}findElementForComponent(e,t){if("app"===t)return document.body;const n=this.queryComponentElements(t);return n.length>0?n[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(t){const n=e.CACHE_KEYS.COMPONENT_ELEMENTS(t);this.componentElementsCache.delete(n);const s=e.CACHE_KEYS.SCRIPTS(t,"global");this.scriptElementsCache.delete(s);const i=e.CACHE_KEYS.TEMPLATES(t,"global");this.templateElementsCache.delete(i),this.selectorCache.clear(),this.queryComponentElements(t).forEach((e=>k.invalidateElement(e)))}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),k.invalidateElement(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,k.clearCache()}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}};d($,"instance"),d($,"CACHE_KEYS",{COMPONENT_ELEMENTS:e=>`comp:${e}`,SCRIPTS:(e,t)=>`scripts:${e}:${t}`,TEMPLATES:(e,t)=>`templates:${e}:${t}`,SELECTOR:e=>`sel:${e}`});let je=$;class rn{constructor(){d(this,"subscriptions",new Map),d(this,"elementSubscriptions",new WeakMap),d(this,"keyIndex",new Map),d(this,"cleanupQueue",new Set),d(this,"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 n=this.elementSubscriptions.get(t.element);n&&(n.delete(e),0===n.size&&this.elementSubscriptions.delete(t.element))}for(const n of t.dependencies){const t=this.keyIndex.get(n);t&&(t.delete(e),0===t.size&&this.keyIndex.delete(n))}}}cleanupElement(e){const t=this.elementSubscriptions.get(e);t&&(t.forEach((e=>this.cleanupQueue.add(e))),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,n]of this.subscriptions)n.element&&!document.contains(n.element)&&e.push(t);e.forEach((e=>this.removeSubscription(e)))}getStats(){return{totalSubscriptions:this.subscriptions.size,elementSubscriptions:this.elementSubscriptions instanceof WeakMap?-1:0,keyIndexes:this.keyIndex.size}}}class G{constructor(e){d(this,"cache",new Map),d(this,"maxSize"),d(this,"hits",0),d(this,"misses",0),this.maxSize=e}keys(){return Array.from(this.cache.keys())}deleteByPrefix(e){let t=0;const n=[];return this.cache.forEach(((t,s)=>{"string"==typeof s&&s.startsWith(e)&&n.push(s)})),n.forEach((e=>{this.cache.delete(e)&&t++})),t}getKeysByPrefix(e){const t=[];return this.cache.forEach(((n,s)=>{"string"==typeof s&&s.startsWith(e)&&t.push(s)})),t}get(e){const t=this.cache.get(e);if(void 0!==t)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 e=this.cache.keys().next().value;void 0!==e&&this.cache.delete(e)}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}}const ee=class e{static parseSpreadDirective(e){const t=e.replace(/^\s*\{\s*|\s*\}\s*$/g,""),n=this.parseSpreadParts(t),s=[],i=[];for(const e of n){const t=e.trim();if(t.startsWith("..."))s.push(t.substring(3).trim());else if(t.startsWith("{")&&t.endsWith("}")){const e=t.slice(1,-1).trim();if(e){const t=this.parseObjectProperties(e);i.push(t)}}else console.warn(`Invalid spread directive part: "${t}". Expected ...spread or {object}`)}return{spreads:s,objects:i}}static parseSpreadParts(e){const t=[];let n="",s=0,i=!1,r="",a=0;for(;a<e.length;){const o=e[a],c=a>0?e[a-1]:"";if(i||'"'!==o&&"'"!==o?i&&o===r&&"\\"!==c&&(i=!1,r=""):(i=!0,r=o),!i)if("{"===o)s++;else if("}"===o)s--;else if(","===o&&0===s){t.push(n.trim()),n="",a++;continue}n+=o,a++}return n.trim()&&t.push(n.trim()),t}static parseObjectProperties(e){const t=[],n=this.parseObjectParts(e);for(const e of n){const n=e.trim(),s=this.findPropertySeparator(n);if(-1!==s){const e=n.substring(0,s).trim().replace(/['"]/g,""),i=n.substring(s+1).trim();t.push({key:e,value:i})}else console.warn(`Invalid object property: "${n}". Expected key: value format.`)}return t}static parseObjectParts(e){const t=[];let n="",s=0,i=!1,r="";for(let a=0;a<e.length;a++){const o=e[a],c=a>0?e[a-1]:"";if(i||'"'!==o&&"'"!==o?i&&o===r&&"\\"!==c&&(i=!1,r=""):(i=!0,r=o),!i)if("{"===o||"["===o||"("===o)s++;else if("}"===o||"]"===o||")"===o)s--;else if(","===o&&0===s){t.push(n.trim()),n="";continue}n+=o}return n.trim()&&t.push(n.trim()),t}static findPropertySeparator(e){let t=0,n=!1,s="";for(let i=0;i<e.length;i++){const r=e[i],a=i>0?e[i-1]:"";if(n||'"'!==r&&"'"!==r?n&&r===s&&"\\"!==a&&(n=!1,s=""):(n=!0,s=r),!n)if("{"===r||"["===r||"("===r)t++;else if("}"===r||"]"===r||")"===r)t--;else if(":"===r&&0===t)return i}return-1}static parse(t){if(e.EXPRESSION_CACHE.has(t))return e.EXPRESSION_CACHE.get(t);const n=e.parseContentWithNesting(t);return e.EXPRESSION_CACHE.set(t,n),n}static parseContentWithNesting(e){const t=[],n=e.length;let s=0,i=0;for(;s<n;)if("{"===e[s]){s>i&&t.push({type:"static",content:e.substring(i,s),expression:null});const n=this.extractNestedExpression(e,s);-1!==n.endIndex&&n.expression&&this.isValidExpression(n.expression)?(t.push({type:"expression",content:e.substring(s,n.endIndex+1),expression:n.expression.trim()}),s=n.endIndex+1,i=s):s++}else s++;return i<n&&t.push({type:"static",content:e.substring(i),expression:null}),t}static isValidExpression(e){const t=e.trim();if(!t)return!1;try{const e=D(t,{ecmaVersion:2022,sourceType:"script"});if("Program"!==e.type)return!1;const n=e.body;if(!n||0===n.length)return!1;const s=n[0];if("ExpressionStatement"!==s.type)return!1;const i=s.expression;return!("ObjectExpression"===i.type||"SequenceExpression"===i.type)}catch{try{const e=D(`(${t})`,{ecmaVersion:2022,sourceType:"script"}).body;if(e&&e.length>0&&"ExpressionStatement"===e[0].type)return!0}catch{return!1}return!1}}static extractNestedExpression(e,t){let n=1,s=t+1,i=!1,r="",a=!1;for(;s<e.length&&n>0;){const t=e[s],o=s>0?e[s-1]:"";i||'"'!==t&&"'"!==t?i&&t===r&&"\\"!==o&&(i=!1,r=""):(i=!0,r=t),!i&&"`"===t&&"\\"!==o&&(a=!a),!i&&!a&&("{"===t?n++:"}"===t&&n--),s++}if(0===n){const n=e.slice(t+1,s-1);if(n.trim()){const t=this.checkForMismatchedQuotes(n);t.hasIssue&&(console.error("\n❌ Malformed expression detected during parsing:"),console.error(` Expression: ${n}`),console.error(` Issue: ${t.message}`),console.error(` Full content: ${e}`),console.error(" 💡 Hint: Check your quotes - strings must be properly quoted\n"))}return{endIndex:s-1,expression:n}}return console.warn("\n⚠️ Failed to extract mustache expression - unclosed braces"),console.warn(` Content: ${e}`),console.warn(` Starting at position: ${t}\n`),{endIndex:-1,expression:""}}static checkForMismatchedQuotes(e){let t=0,n=0,s=!1;for(let i=0;i<e.length;i++)s?s=!1:"\\"!==e[i]?("'"===e[i]&&t++,'"'===e[i]&&n++):s=!0;return t%2!=0?{hasIssue:!0,message:`Unmatched single quotes (found ${t})`}:n%2!=0?{hasIssue:!0,message:`Unmatched double quotes (found ${n})`}:{hasIssue:!1,message:""}}static isSingleExpression(t){const n=e.parseContentWithNesting(t);return 1===n.length&&"expression"===n[0].type?n[0].expression:null}static extractExpressions(t){const n=e.parseContentWithNesting(t),s=n.filter((e=>"expression"===e.type)).map((e=>e.expression)).filter((e=>e));return n.some((e=>"expression"===e.type))&&0===s.length&&(console.error("\n❌ Failed to extract expressions from content:"),console.error(` Content: ${t}`),console.error(` Parsed ${n.length} parts, but extracted 0 expressions`),console.error(" This usually means malformed mustache syntax\n")),s}};d(ee,"EXPRESSION_CACHE",new G(1e3)),d(ee,"decodeEntities",(e=>{const t=document.createElement("textarea");t.innerHTML=e;let n=t.value;for(;n.includes("&");){t.innerHTML=n;const e=t.value;if(e===n)break;n=e}return n}));let L=ee;class an{constructor(){d(this,"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){var n;null==(n=this.listeners.get(e))||n.delete(t)}emit(e,...t){const n=this.listeners.get(e);n&&n.forEach((n=>{try{n(...t)}catch(t){console.error(`Event listener error for ${e}:`,t)}}))}}class Fe{constructor(){d(this,"subscriptionManager",new rn),d(this,"stateStore",{}),d(this,"updateQueue",new Set),d(this,"isUpdating",!1),d(this,"eventBus",new an),d(this,"contextCache",new Map),d(this,"previousValues",new Map),d(this,"originalStateStore",{}),d(this,"domUpdateCallbacks",[]),d(this,"domUpdateScheduled",!1),d(this,"scheduleFlush",tn((()=>{this.flushUpdates()}),g.DEBOUNCE_MS)),this.setupGlobalStateProxy(),setInterval((()=>{this.subscriptionManager.cleanupStaleSubscriptions()}),3e4)}static findExistingStateKey(e,t,n){return[`${t}.${e}`,`app.${e}`,e].find((e=>e in n))||null}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[n,s]of t)s.component===e&&this.subscriptionManager.removeSubscription(n)}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((t=>t.startsWith(`${e}.`))).forEach((e=>{delete this.stateStore[e],delete this.originalStateStore[e],this.previousValues.delete(e)}))}onDOMUpdateComplete(e){this.domUpdateCallbacks.push(e),this.domUpdateScheduled||(this.domUpdateScheduled=!0,requestAnimationFrame((()=>{requestAnimationFrame((()=>{const e=[...this.domUpdateCallbacks];this.domUpdateCallbacks=[],this.domUpdateScheduled=!1,e.forEach((e=>{try{e()}catch(e){console.error("DOM update callback error:",e)}}))}))})))}setInitialState(e,t){if(this.previousValues.set(e,void 0),this.originalStateStore[e]=t,this.previousValues.size>100){const e=this.previousValues.keys().next().value;"string"==typeof e&&this.previousValues.delete(e)}}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,n,s)=>{const i=e[t],r=Reflect.set(e,t,n,s);return i!==n&&this.notifySubscribers(t),r},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){var t;const n=this.stateStore[e],s=null==(t=this.previousValues)?void 0:t.get(e),i=this.subscriptionManager.getAllSubscriptions();for(const[t,r]of i)for(const t of r.dependencies)if(this.isPathDependency(t)&&t.startsWith(e+".")){const i=t.substring(e.length+1),r=this.getPathValue(s,i),a=this.getPathValue(n,i);this.deepEqual(r,a)||this.updateQueue.add(t)}}isPathDependency(e){return e.includes(".")&&e.split(".").length>1}getPathValue(e,t){if(!e||"object"!=typeof e)return;const n=t.split(".");let s=e;for(const e of n){if(null==s)return;if(Array.isArray(s))return"length"===e?s.length:s.map((t=>null==t?void 0:t[e])).filter((e=>void 0!==e));s=s[e]}return s}deepEqual(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((e,n)=>this.deepEqual(e,t[n])));if("object"==typeof e&&"object"==typeof t){const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every((n=>this.deepEqual(e[n],t[n])))}return!1}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 e of t){const t=this.subscriptionManager.getSubscription(e);if(!t)continue;if(t.element&&!document.contains(t.element)){this.subscriptionManager.removeSubscription(e);continue}const n=t.element??document.body;try{const e=Array.from(this.updateQueue)[0];t.callback(n,{key:e})}catch(e){console.error("Wildcard subscription callback failed:",e)}}for(const t of this.updateQueue){if(e.has(t))continue;e.add(t);const n=this.subscriptionManager.getSubscriptionsForKey(t);if(n)for(const e of n){const n=this.subscriptionManager.getSubscription(e);if(!n)continue;const s=n.element??document.body;try{n.callback(s,{key:t})}catch(e){console.error("Subscription callback failed:",e)}}}}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 e=this.previousValues.keys().next().value;"string"==typeof e&&this.previousValues.delete(e)}}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[n,s]of t)for(const t of s.dependencies)e.has(t)||e.set(t,new Set),e.get(t).add(n);return e}destroy(){this.clearState(),this.clearSubscriptions(),this.contextCache.clear(),this.previousValues.clear(),this.domUpdateCallbacks=[]}}const ge=class e{constructor(){d(this,"expressionCache",new G(g.MAX_CACHE_SIZE)),d(this,"dependencyCache",new G(g.MAX_CACHE_SIZE)),d(this,"commonExpressionsCache",new G(100)),d(this,"dependencyParser",new on),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 n={fn:new Function("return "+t),contextMap:new Map,dependencies:[t],timestamp:Date.now(),hitCount:0},s=e.CACHE_KEYS.COMMON(t);this.commonExpressionsCache.set(s,n)}))}extractDependencies(t,n,s){const i=this.normalizeExpression(t),r=e.CACHE_KEYS.DEPENDENCY(n,i);let a=this.dependencyCache.get(r);return a||(a=this.dependencyParser.extract(i,n,s),this.dependencyCache.set(r,a),a)}evaluateExpression(t,n,s){const i=this.normalizeExpression(t),r=e.CACHE_KEYS.COMMON(i);let a=this.commonExpressionsCache.get(r);if(a){a.hitCount++;try{return a.fn()}catch(e){return void console.error(`Common expression evaluation failed: "${i}"`,e)}}const o=e.CACHE_KEYS.EXPRESSION(s,i);a=this.expressionCache.get(o);const c=this.transformContextForEvaluation(n,i);(!a||this.isStale(a))&&(a=this.compileExpression(i,c,s),this.expressionCache.set(o,a)),a.hitCount++;try{const e=this.buildArguments(a.contextMap,c);return a.fn(...e)}catch(e){return console.error(`Expression evaluation failed: "${i}"`,e),void console.error("Available context:",Object.keys(c))}}transformContextForEvaluation(e,t){const n=!!t&&sn(t),s={};for(const[t,i]of Object.entries(e))Oe(i)?s[t]=as(i,{forComparison:n}):s[t]=i;return s}compileExpression(e,t,n){const s=this.prepareSafeContext(t),i=new Map,r=[];Object.keys(s).forEach(((e,t)=>{i.set(e,t),r.push(e)}));const a=this.dependencyParser.extract(e,n);return{fn:new Function(...r,`return (${e})`),contextMap:i,dependencies:a,timestamp:Date.now(),hitCount:0}}buildArguments(e,t){const n=new Array(e.size);for(const[s,i]of e)n[i]=t[s];return n}isStale(e){return Date.now()-e.timestamp>3e5}prepareSafeContext(e){const t={};for(const[n,s]of Object.entries(e))Se.has(n)||!this.isValidJavaScriptIdentifier(n)||(t[n]=s);return t}isValidJavaScriptIdentifier(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!Se.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((t=>{const n=this.expressionCache.get(t);n&&this.isStale(n)&&(this.expressionCache.delete(t),e++)})),e}};d(ge,"CACHE_KEYS",{EXPRESSION:(e,t)=>`expr:${e}:${t}`,DEPENDENCY:(e,t)=>`deps:${e}:${t}`,COMMON:e=>`common:${e}`});let rt=ge;class on{constructor(){d(this,"parseCache",new G(500))}extract(e,t,n){const s=this.normalizeExpression(e),i=`${t}:${s}`;if(this.parseCache.has(i))return this.parseCache.get(i);const r=this.parseExpression(s,t,n);return this.parseCache.set(i,r),r}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}parseExpression(e,t,n){const s=this.extractIdentifiers(e),i=[],r=(null==n?void 0:n.getState())||{};for(const e of s){if(Se.has(e))continue;const n=e.indexOf("."),s=-1===n?e:e.substring(0,n),a=Fe.findExistingStateKey(s,t,r);if(a)i.push(a);else{const e="app"===t?[`app.${s}`]:[`${t}.${s}`,`app.${s}`];i.push(...e)}if(-1!==n){const e="app"===t?[`app.${s}`]:[`${t}.${s}`,`app.${s}`];i.push(...e)}}return Array.from(new Set(i))}extractIdentifiers(e){const t=[];let n=0;for(;n<e.length;){const s=e[n];if("'"!==s)if('"'!==s)if("`"!==s)if(this.isIdentifierStart(s)){const s=this.extractIdentifier(e,n);t.push(s.value),n=s.endIndex}else n++;else n=this.skipTemplateLiteral(e,n,t);else n=this.skipString(e,n,'"');else n=this.skipString(e,n,"'")}return t}skipString(e,t,n){let s=t+1;for(;s<e.length&&e[s]!==n;)"\\"===e[s]&&s++,s++;return s+1}skipTemplateLiteral(e,t,n){let s=t+1;for(;s<e.length&&"`"!==e[s];)if("$"===e[s]&&s+1<e.length&&"{"===e[s+1]){s+=2;let t=1;for(;s<e.length&&t>0;){const i=e[s];if('"'!==i&&"'"!==i){if("{"===i?t++:"}"===i&&t--,t>0&&this.isIdentifierStart(i)){const t=this.extractIdentifier(e,s);n.push(t.value),s=t.endIndex-1}s++}else s=this.skipString(e,s,i)}}else"\\"===e[s]&&s++,s++;return s+1}extractIdentifier(e,t){let n=t;for(;n<e.length&&(this.isIdentifierPart(e[n])||"."===e[n]);)n++;return{value:e.substring(t,n),endIndex:n}}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 cs{constructor(){d(this,"hydrationStarted",!1),d(this,"hydrationDone",!1),d(this,"initialized",!1),d(this,"stateManager",new Fe),d(this,"expressionEvaluator",new rt),d(this,"componentManager",new en(this.stateManager)),d(this,"domBindingManager",new Js(this.stateManager,this.componentManager,this.expressionEvaluator)),d(this,"hydrationCallbacks",new Set),d(this,"portalManager",new Qs),d(this,"hydrationResolve"),d(this,"hydrationPromise"),d(this,"portalHydrationPromises",new Set),d(this,"portalHydrationResolvers",new Map),d(this,"pendingLoopRenders",0),d(this,"currentLoopContext",null),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>this.initialize())):setTimeout((()=>this.initialize()),0),this.hydrationPromise=new Promise((e=>this.hydrationResolve=e))}async initialize(){this.initialized||(this.initialized=!0,this.markHydrationStart(),this.componentManager.setExpressionEvaluator(this.expressionEvaluator),this.portalManager.setDependencies(this.componentManager,this.domBindingManager,this.stateManager,this),k.preCacheAllScopes(),this.componentManager.executePhpScripts(document.body),this.domBindingManager.processElement(document.body,!0),this.domBindingManager.processPendingBindings(),await this.waitForLoopRenders(),await this.waitForDOMUpdates(),this.markHydrated(),this.scheduleCommentCleanup())}async waitForLoopRenders(){const e=Date.now();for(;this.pendingLoopRenders>0;){const t=Date.now()-e;if(t>5e3){console.warn(`⚠️ [PPHP] Loop render timeout - ${this.pendingLoopRenders} loops may not have completed after ${t}ms`);break}t%500==0&&console.log(` Still waiting: ${this.pendingLoopRenders} loops pending (${t}ms elapsed)`),await new Promise((e=>setTimeout(e,10)))}0===this.pendingLoopRenders&&(console.log("✅ [PPHP] All loops rendered, waiting 50ms for stability..."),await new Promise((e=>setTimeout(e,50))))}waitForDOMUpdates(){return new Promise((e=>{Promise.resolve().then((()=>{requestAnimationFrame((()=>{requestAnimationFrame((()=>{e()}))}))}))}))}scheduleCommentCleanup(){const e=()=>{try{k.removeScopeComments(),console.debug("✅ Scope comments cleaned up")}catch(e){console.error("Failed to remove scope comments:",e)}};"requestIdleCallback"in window?requestIdleCallback(e,{timeout:5e3}):setTimeout(e,100)}createPortal(e,t,n){const s=this.portalManager.createPortal(e,t,n),i=new Promise((e=>{this.portalHydrationResolvers.set(s,e)}));return this.portalHydrationPromises.add(i),i.finally((()=>{this.portalHydrationPromises.delete(i),this.portalHydrationResolvers.delete(s)})),s}removePortal(e){return this.markPortalHydrated(e),this.portalManager.removePortal(e)}markPortalHydrated(e){const t=this.portalHydrationResolvers.get(e);t&&t()}updatePortal(e,t,n){return this.portalManager.updatePortal(e,t,n)}cleanup(){this.portalManager.destroy(),this.domBindingManager.destroy(),this.componentManager.destroy(),this.stateManager.clearState(),this.stateManager.clearSubscriptions(),this.expressionEvaluator.clearAllCaches(),this.hydrationCallbacks.clear(),this.deleteAllComponentObjects(),k.clearCache()}ref(e=null){return{current:e}}async hydrated(){await Promise.all([this.hydrationPromise,...Array.from(this.portalHydrationPromises)])}onHydrated(e){this.hydrationDone?queueMicrotask(e):this.hydrationCallbacks.add(e)}markHydrationStart(){this.hydrationStarted=!0,this.hydrationDone=!1,document.dispatchEvent(new CustomEvent("pp:hydrationstart"))}get isHydrated(){return this.hydrationDone}get isHydrating(){return this.hydrationStarted&&!this.hydrationDone}markHydrated(){if(!this.hydrationDone){this.hydrationStarted=!1,this.hydrationDone=!0,this.hydrationResolve();for(const e of this.hydrationCallbacks)try{e()}catch(e){console.error("❌ [PPHP] Hydration callback error:",e)}this.hydrationCallbacks.clear(),document.dispatchEvent(new CustomEvent("pp:hydrated",{detail:{at:performance.now()}}))}}state(e,t){const n=this.componentManager.getCurrentComponent();let s,i,r;"string"==typeof e&&2===arguments.length?(s=e,i=t):"string"==typeof e&&1===arguments.length?this.looksLikeVariableName(e)?(s=e,i=void 0):(console.warn("pp.state() called with string that doesn't look like variable name:",e),s="unknownState",i=e):(console.warn("pp.state() called without explicit key - this should be handled by AST transformation"),s="unknownState",i=e),Oe(i)&&(i=We(i));const a=this.getLoopExecutionContext();if(a){const e=this.generateLoopInstanceId(a);r=`${n}.${e}.${s}`}else r=`${n}.${s}`;this.stateManager.hasState(r)||this.stateManager.setInitialState(r,i);const o=()=>this.stateManager.getState()[r],c=new Proxy(o,{get(e,t,n){if("__pphp_key"===t||"__pphp_fullKey"===t||"__pphp_component"===t||"value"===t||"valueOf"===t||"toString"===t)return Reflect.get(e,t,n);const s=e();if(null!=s){if(t in Object(s)){const e=s[t];return"function"==typeof e?e.bind(s):e}return Reflect.get(e,t,n)}},has(e,t){if("__pphp_key"===t||"__pphp_fullKey"===t||"__pphp_component"===t||"value"===t||"valueOf"===t||"toString"===t)return Reflect.has(e,t);const n=e();return null!=n&&t in Object(n)||Reflect.has(e,t)},apply:(e,t,n)=>Reflect.apply(e,t,n)});Object.defineProperty(c,"__pphp_key",{value:s,enumerable:!1,writable:!1}),Object.defineProperty(c,"__pphp_fullKey",{value:r,enumerable:!1,writable:!1}),Object.defineProperty(c,"__pphp_component",{value:n,enumerable:!1,writable:!1}),Object.defineProperty(c,"value",{get:()=>this.stateManager.getState()[r],enumerable:!0,configurable:!0}),o.valueOf=()=>this.stateManager.getState()[r],o.toString=()=>Ce(this.stateManager.getState()[r]);const h=e=>{const t=this.stateManager.getState()[r],n="function"==typeof e?e(t):e;this.stateManager.setState(r,n)};return this.createComponentScopedGlobals(n,s,c,h),[c,h]}getLoopExecutionContext(){return this.currentLoopContext}generateLoopInstanceId(e){const t=Object.keys(e).sort().map((t=>{const n=e[t];return n&&"object"==typeof n&&"id"in n?`${t}:${n.id}`:`${t}:${JSON.stringify(n)}`}));return`loop_${btoa(t.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(" ")&&!Se.has(e)}effect(e,t){const n=`effect_${Date.now()}_${Math.random()}`,s=this.componentManager.getCurrentComponent();let i,r,a,o=!1;if(1===arguments.length)r="always",a={immediate:!0,detectDeps:!0};else if(Array.isArray(t)){const e=this.extractDependencyNames(t,s);0===e.length?(r="once",a={deps:e,immediate:!0}):(r="deps",a={deps:e,immediate:!0})}else{const e={immediate:!0,...t||{}};if(e.deps&&0!==e.deps.length){r="deps",a={deps:this.extractDependencyNames(e.deps,s),immediate:e.immediate,detectDeps:e.detectDeps}}else r="always",a={immediate:e.immediate,detectDeps:!0}}const c=()=>{o||this.stateManager.onDOMUpdateComplete((()=>{if(!o){if(i&&"function"==typeof i)try{i()}catch(e){console.error("Effect cleanup error:",e)}try{i=e()}catch(e){console.error("Effect callback error:",e)}}}))};switch(r){case"always":const e={id:n,selector:"",dependencies:new Set(["*"]),callback:c,component:s};this.stateManager.addSubscription(e);break;case"once":break;case"deps":const t=this.resolveDependencies(a.deps,s);if(t.length){const e={id:n,selector:"",dependencies:new Set(t),callback:c,component:s};this.stateManager.addSubscription(e)}}return!1!==a.immediate&&c(),()=>{if(o=!0,i&&"function"==typeof i)try{i()}catch(e){console.error("Effect cleanup error:",e)}this.stateManager.removeSubscription(n)}}extractDependencyNames(e,t){const n=[];for(const t of e)"string"==typeof t?n.push(t):"function"==typeof t&&t.__pphp_key?n.push(t.__pphp_key):console.warn("Invalid dependency in effect:",t);return n.filter(Boolean)}resolveDependencies(e,t){const n=[],s=this.stateManager.getState();for(const i of e)if(i.includes(".")){const e=i.split("."),r=e[0],a=e.slice(1).join("."),o=this.componentManager.getPropDependencies(r,t);if(o.length>0)n.push(...o);else{const e=Fe.findExistingStateKey(r,t,s);e?n.push(`${e}.${a}`):n.push(`${t}.${i}`)}}else{const e=this.componentManager.getPropDependencies(i,t);if(e.length>0)n.push(...e);else{const e=Fe.findExistingStateKey(i,t,s);e?n.push(e):n.push(`${t}.${i}`)}}return Array.from(new Set(n))}createComponentScopedGlobals(e,t,n,s){window[e]||(window[e]={});const i=`set${rs(t)}`;window[e][t]=n,window[e][i]=s,window[e][`${t}Getter`]=n}deleteAllComponentObjects(){const e=Object.keys(window),t=new Set(["window","self","document","location","customElements","history","navigation","locationbar","menubar","personalbar","scrollbars","statusbar","toolbar","frames","top","parent","navigator","external","screen","visualViewport","crypto","performance","localStorage","sessionStorage","indexedDB","fetch","XMLHttpRequest","WebSocket","Worker","SharedWorker","MessageChannel","MessagePort","Notification","Push","BroadcastChannel","Cache","CacheStorage","requestAnimationFrame","cancelAnimationFrame","requestIdleCallback","cancelIdleCallback","setInterval","clearInterval","setTimeout","clearTimeout","queueMicrotask","atob","btoa","alert","confirm","prompt","open","close","focus","blur","print","stop","getComputedStyle","getSelection","matchMedia","scroll","scrollBy","scrollTo","resizeBy","resizeTo","moveBy","moveTo"]);for(const n of e){if(t.has(n))continue;const e=window[n];(/^s[a-z0-9]+$/i.test(n)||"app"===n)&&e&&"object"==typeof e&&delete window[n]}}static resetInstance(){this.instance&&(this.instance.destroy(),this.instance=null)}destroy(){this.cleanup(),this.initialized=!1,this.hydrationDone=!1}}d(cs,"instance",null);const Ue=class e extends cs{constructor(){super(),d(this,"cryptoKey",null),d(this,"activeAbortController",null),d(this,"navigationEnabled",!1),d(this,"boundHandleLinkClick",null),d(this,"boundHandlePopState",null),d(this,"isNavigating",!1),this.hydrated().then((()=>{document.body.hidden=!1,this.enableSPANavigation()})).catch((e=>{console.error("PPHPUtilities hydration error:",e),document.body.hidden=!1}))}static resetInstance(){this.instance&&(this.instance.navigationEnabled&&this.instance.disableSPANavigation(),this.instance.activeAbortController&&(this.instance.activeAbortController.abort(),this.instance.activeAbortController=null),this.instance.destroy(),this.instance=null)}static getInstance(){return this.instance||(this.instance=new e),this.instance}enableSPANavigation(){this.navigationEnabled||"true"!==document.body.getAttribute("pp-spa")||(this.navigationEnabled=!0,this.boundHandleLinkClick=this.handleLinkClick.bind(this),this.boundHandlePopState=this.handlePopState.bind(this),document.addEventListener("click",this.boundHandleLinkClick),window.addEventListener("popstate",this.boundHandlePopState))}disableSPANavigation(){this.navigationEnabled=!1,this.boundHandleLinkClick&&(document.removeEventListener("click",this.boundHandleLinkClick),this.boundHandleLinkClick=null),this.boundHandlePopState&&(window.removeEventListener("popstate",this.boundHandlePopState),this.boundHandlePopState=null)}handleLinkClick(e){if(!this.navigationEnabled)return;const t=e.target.closest("a");if(t&&t.href)try{const n=new URL(t.href),s=n.origin!==window.location.origin,i=n.pathname===window.location.pathname&&n.search===window.location.search,r="false"===t.getAttribute("pp-spa");if(s||"_blank"===t.target||t.hasAttribute("download")||r||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;if(e.preventDefault(),i){const e=n.hash;if(e){const t=document.querySelector(e);t&&t.scrollIntoView({behavior:"smooth"})}else window.scrollTo({top:0,behavior:"smooth"});return}this.navigateTo(n.pathname+n.search+n.hash)}catch(e){console.error("Link click navigation error:",e)}}async handlePopState(){const e=window.location.pathname+window.location.search+window.location.hash;await this.navigateTo(e,!1)}async navigateTo(e,t=!0){this.isNavigating=!0;try{this.dispatchNavigationEvent("start",e),await this.showLoadingTransition();const n=await this.fetchPageContent(e);console.log("🚀 ~ PPHPUtilities ~ navigateTo ~ newDoc:",n),this.updateBrowserHistory(e,t);const s=document.getElementById("loading-file-1B87E"),i="startViewTransition"in document;this.performCleanup(),!s&&i?await this.updatePageContentWithViewTransition(n):this.updatePageContent(n),this.initialized=!1,await this.initialize(),await this.hydrated(),await this.handleNavigationCompletion(e),this.dispatchNavigationEvent("complete",e)}catch(t){this.handleNavigationError(e,t)}finally{this.isNavigating=!1}}async updatePageContentWithViewTransition(e){if(this.isNavigating)return void this.updatePageContent(e);const t=document.startViewTransition((()=>{this.updatePageContent(e)}));try{await t.finished}catch(e){console.warn("View transition failed, continuing anyway:",e)}}dispatchNavigationEvent(e,t,n){const s=`pp:navigation:${e}`,i=n?{url:t,error:n}:{url:t};document.dispatchEvent(new CustomEvent(s,{detail:i}))}async showLoadingTransition(){const e=document.getElementById("loading-file-1B87E");if(e){const t=this.findLoadingElement(e,window.location.pathname);if(t)return void await this.updateContentWithTransition(t)}const t=document.querySelector("[pp-loading-content='true']")||document.body;t&&!("startViewTransition"in document)&&await this.fadeOut(t,250)}async fetchPageContent(e){var t;const n=await fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest","X-PP-Navigation":"true",Accept:"text/html"}});if(!n.ok)throw new Error(`Navigation failed: ${n.status} ${n.statusText}`);let s=await n.text();const i=document.createElement("iframe");i.style.display="none",document.body.appendChild(i);const r=i.contentDocument||(null==(t=i.contentWindow)?void 0:t.document);if(!r)throw document.body.removeChild(i),new Error("Failed to create iframe document");r.documentElement.innerHTML=s;const a=document.implementation.createHTMLDocument();return a.head.innerHTML=r.head.innerHTML,a.body.innerHTML=r.body.innerHTML,Array.from(r.body.attributes).forEach((e=>{a.body.setAttribute(e.name,e.value)})),a.title=r.title,document.body.removeChild(i),a}performCleanup(){this.cleanup()}updateBrowserHistory(e,t){t&&history.pushState(null,"",e)}updatePageContent(e){e.title&&(document.title=e.title),this.reconcileHead(e);const t=e.body;document.body.innerHTML=t.innerHTML}async handleNavigationCompletion(e){const t=new URL(e,window.location.origin).hash;if(t){const e=document.querySelector(t);e&&e.scrollIntoView({behavior:"smooth"})}else window.scrollTo({top:0,behavior:"instant"});const n=document.querySelector("[pp-loading-content='true']")||document.body;n?requestAnimationFrame((()=>{document.body.hidden=!1,this.fadeIn(n,150)})):document.body.hidden=!1}handleNavigationError(e,t){console.error("Navigation error:",t),document.body.hidden=!1,this.dispatchNavigationEvent("error",e,t),window.location.href=e}findLoadingElement(e,t){let n=t;for(;;){const t=e.querySelector(`div[pp-loading-url='${n}']`);if(t)return t;if("/"===n)break;const s=n.lastIndexOf("/");n=s<=0?"/":n.substring(0,s)}return e.querySelector("div[pp-loading-url='/' ]")}async updateContentWithTransition(e){const t=document.querySelector("[pp-loading-content='true']")||document.body;if(!t)return;const{fadeIn:n,fadeOut:s}=this.parseTransition(e);await this.fadeOut(t,s),t.innerHTML=e.innerHTML,this.fadeIn(t,n)}parseTransition(e){let t=250,n=250;const s=e.querySelector("[pp-loading-transition]"),i=null==s?void 0:s.getAttribute("pp-loading-transition");if(i){let e=JSON.parse(i);e&&"object"==typeof e?(t=this.parseTime(e.fadeIn??t),n=this.parseTime(e.fadeOut??n)):console.warn("pp-loading-transition is not valid JSON → default values (250 ms) will be used. String:",i)}return{fadeIn:t,fadeOut:n}}fadeOut(e,t){return new Promise((n=>{e.style.transition=`opacity ${t}ms ease-out`,setTimeout((()=>{e.style.transition="",n()}),t)}))}fadeIn(e,t){e.style.transition=`opacity ${t}ms ease-in`,setTimeout((()=>{e.style.transition=""}),t)}parseTime(e){if("number"==typeof e)return e;const t=e.match(/^(\d+)(ms|s|m)?$/);if(t){const e=parseInt(t[1],10);switch(t[2]||"ms"){case"ms":default:return e;case"s":return 1e3*e;case"m":return 60*e*1e3}}return 0}reconcileHead(e){const t="pp-dynamic-script",n="pp-dynamic-link";document.head.querySelectorAll("[pp-dynamic-meta]").forEach((e=>e.remove())),document.head.querySelectorAll(`[${n}]`).forEach((e=>e.remove())),document.head.querySelectorAll(`[${t}]`).forEach((e=>e.remove())),Array.from(e.head.children).forEach((e=>{var s;switch(e.tagName){case"SCRIPT":if(e.hasAttribute(t)){const t=document.createElement("script");Array.from(e.attributes).forEach((e=>t.setAttribute(e.name,e.value))),t.textContent=e.textContent,document.head.appendChild(t)}break;case"META":{const t=e;if(t.getAttribute("charset")||"viewport"===t.name)break;const n=t.name?`meta[name="${t.name}"]`:`meta[property="${t.getAttribute("property")}"]`,i=t.cloneNode(!0),r=document.head.querySelector(n);r?document.head.replaceChild(i,r):document.head.insertBefore(i,(null==(s=document.head.querySelector("title"))?void 0:s.nextSibling)||null);break}case"TITLE":{const t=e.cloneNode(!0),n=document.head.querySelector("title");n?document.head.replaceChild(t,n):document.head.appendChild(t);break}case"LINK":{const t=e;if("icon"===t.rel){const e=t.cloneNode(!0),n=document.head.querySelector('link[rel="icon"]');n?document.head.replaceChild(e,n):document.head.appendChild(e)}else t.hasAttribute(n)&&document.head.appendChild(t.cloneNode(!0));break}}}))}async redirect(e){if(e)try{const t=new URL(e,window.location.origin);t.origin!==window.location.origin?window.location.href=e:this.navigationEnabled?await this.navigateTo(t.pathname+t.search+t.hash):window.location.href=e}catch(e){console.error("Redirect error:",e)}}async initCryptoKey(){var e;const t=null==(e=document.cookie.split("; ").find((e=>e.startsWith("pp_function_call_jwt="))))?void 0:e.split("=",2)[1];if(!t)throw new Error("Missing function-call token");const[,n]=t.split("."),s=atob(n.replace(/-/g,"+").replace(/_/g,"/")),{k:i,exp:r}=JSON.parse(s);if(Date.now()/1e3>r)throw new Error("Function-call token expired");const a=Uint8Array.from(atob(i),(e=>e.charCodeAt(0)));this.cryptoKey=await crypto.subtle.importKey("raw",a,{name:"AES-CBC"},!1,["encrypt","decrypt"])}async encryptCallbackName(e){await this.initCryptoKey();const t=crypto.getRandomValues(new Uint8Array(16)),n=(new TextEncoder).encode(e),s=await crypto.subtle.encrypt({name:"AES-CBC",iv:t},this.cryptoKey,n);return`${btoa(String.fromCharCode(...t))}:${btoa(String.fromCharCode(...new Uint8Array(s)))}`}createFetchOptions(e){return{method:"POST",headers:{"Content-Type":"application/json",HTTP_PP_WIRE_REQUEST:"true"},body:JSON.stringify(e)}}async fetchFunction(e,t={},n=!1){let s=null;try{n&&this.activeAbortController&&(this.activeAbortController.abort(),this.activeAbortController=null),s=new AbortController,n&&(this.activeAbortController=s);const i={callback:await this.encryptCallbackName(e),...t},r=window.location.href;let a;if(Object.keys(i).some((e=>{const t=i[e];return t instanceof File||t instanceof FileList&&t.length>0}))){const e=new FormData;Object.keys(i).forEach((t=>{const n=i[t];n instanceof File?e.append(t,n):n instanceof FileList?Array.from(n).forEach((n=>e.append(t,n))):e.append(t,n)})),a={method:"POST",headers:{HTTP_PP_WIRE_REQUEST:"true"},body:e,signal:s.signal}}else a={signal:s.signal,...this.createFetchOptions(i)};const o=await fetch(r,a);if(!o.ok)throw new Error(`Fetch failed with status: ${o.status} ${o.statusText}`);const c=await o.text();s&&this.activeAbortController===s&&(this.activeAbortController=null);try{return JSON.parse(c)}catch{return c}}catch(e){if(s&&this.activeAbortController===s&&(this.activeAbortController=null),e instanceof Error&&"AbortError"===e.name)return console.log("Request was cancelled"),{cancelled:!0};throw console.error("Error in fetchFunction:",e),new Error("Failed to fetch data.")}}};d(Ue,"instance",null);let He=Ue;const xe=class e{constructor(e={}){d(this,"state"),d(this,"listeners"),d(this,"pp"),d(this,"STORAGE_KEY"),d(this,"lastSyncedState",null),this.state=e,this.listeners=[],this.pp=He.getInstance(),this.STORAGE_KEY=this.getCookie("pp_local_store_key")||"pp_local_store_59e13",this.lastSyncedState=localStorage.getItem(this.STORAGE_KEY),this.loadState()}static getInstance(t={}){return e.instance||(e.instance=new e(t)),e.instance}getCookie(e){var t;return(null==(t=document.cookie.split("; ").find((t=>t.startsWith(e+"="))))?void 0:t.split("=")[1])||null}setState(e,t=!1){const n={...this.state,...e};if(JSON.stringify(n)!==JSON.stringify(this.state)&&(this.state=n,this.listeners.forEach((e=>e(this.state))),this.saveState(),t)){const e=localStorage.getItem(this.STORAGE_KEY);e&&e!==this.lastSyncedState&&(this.pp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:e}),this.lastSyncedState=e)}}saveState(){localStorage.setItem(this.STORAGE_KEY,JSON.stringify(this.state))}loadState(){const e=localStorage.getItem(this.STORAGE_KEY);e&&(this.state=JSON.parse(e),this.listeners.forEach((e=>e(this.state))))}resetState(e,t=!1){if(e?(delete this.state[e],this.saveState()):(this.state={},localStorage.removeItem(this.STORAGE_KEY)),this.listeners.forEach((e=>e(this.state))),t){const t=e?localStorage.getItem(this.STORAGE_KEY):null;this.pp.fetchFunction(this.STORAGE_KEY,{[this.STORAGE_KEY]:t}),this.lastSyncedState=t}}};d(xe,"instance",null);let at=xe;const Ee=class e{constructor(){d(this,"listeners",[])}static getInstance(){return e.instance||(e.instance=new e),e.instance}get params(){return new URLSearchParams(window.location.search)}get(e){return this.params.get(e)}set(e,t){const n=this.params;n.set(e,t),this.updateURL(n)}delete(e){const t=this.params;t.delete(e),this.updateURL(t)}replace(e){const t=new URLSearchParams;for(const n in e){const s=e[n];null!==s&&t.set(n,s)}this.updateURL(t,!0)}updateURL(e,t=!1){const n=`${window.location.pathname}?${e.toString()}`;t?history.replaceState(null,"",n):history.pushState(null,"",n),this.notifyListeners(e)}listen(e){this.listeners.push(e)}notifyListeners(e){for(const t of this.listeners)t(e)}enablePopStateListener(){window.addEventListener("popstate",(()=>{this.notifyListeners(this.params)}))}};d(Ee,"instance",null);let ot=Ee;function gt(e,t,n=window,s=!0){let i=null;if(Object.defineProperty(n,e,{get(){if(null!==i)return i;if(t&&"object"==typeof t&&!Array.isArray(t)&&"getInstance"in t&&"function"==typeof t.getInstance)return i=t.getInstance(),i;if("function"!=typeof t)return i=t,i;try{return i=t.getInstance(),i}catch{return i=t,i}},set(t){null===t?i=null:console.warn(`Cannot override global ${e}`)},configurable:!0,enumerable:!0}),s)try{n[e]}catch(t){console.error(`Failed to initialize ${e}:`,t)}}gt("pp",He),gt("store",at),gt("searchParams",ot);export{at as PPHPLocalStore,He as PPHPUtilities,ot as SearchParamsManager};
|