create-prisma-php-app 4.1.0-beta.6 → 4.2.0-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,42 +1 @@
1
- import{P as qt}from"./pp-portal.js";var zt=[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],ct=[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],Xt="‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",ut="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟍꟐꟑꟓꟕ-Ƛꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Fe={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"},De="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",Kt={5:De,"5module":De+" export import",6:De+" const class extends export import super"},Gt=/^in(stanceof)?$/,Qt=new RegExp("["+ut+"]"),Zt=new RegExp("["+ut+Xt+"]");function $e(s,e){for(var t=65536,n=0;n<e.length;n+=2){if(t+=e[n],t>s)return!1;if(t+=e[n+1],t>=s)return!0}return!1}function Y(s,e){return s<65?s===36:s<91?!0:s<97?s===95:s<123?!0:s<=65535?s>=170&&Qt.test(String.fromCharCode(s)):e===!1?!1:$e(s,ct)}function ae(s,e){return s<48?s===36:s<58?!0:s<65?!1:s<91?!0:s<97?s===95:s<123?!0:s<=65535?s>=170&&Zt.test(String.fromCharCode(s)):e===!1?!1:$e(s,ct)||$e(s,zt)}var _=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function q(s,e){return new _(s,{beforeExpr:!0,binop:e})}var z={beforeExpr:!0},j={startsExpr:!0},ze={};function w(s,e){return e===void 0&&(e={}),e.keyword=s,ze[s]=new _(s,e)}var l={num:new _("num",j),regexp:new _("regexp",j),string:new _("string",j),name:new _("name",j),privateId:new _("privateId",j),eof:new _("eof"),bracketL:new _("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new _("]"),braceL:new _("{",{beforeExpr:!0,startsExpr:!0}),braceR:new _("}"),parenL:new _("(",{beforeExpr:!0,startsExpr:!0}),parenR:new _(")"),comma:new _(",",z),semi:new _(";",z),colon:new _(":",z),dot:new _("."),question:new _("?",z),questionDot:new _("?."),arrow:new _("=>",z),template:new _("template"),invalidTemplate:new _("invalidTemplate"),ellipsis:new _("...",z),backQuote:new _("`",j),dollarBraceL:new _("${",{beforeExpr:!0,startsExpr:!0}),eq:new _("=",{beforeExpr:!0,isAssign:!0}),assign:new _("_=",{beforeExpr:!0,isAssign:!0}),incDec:new _("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new _("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:q("||",1),logicalAND:q("&&",2),bitwiseOR:q("|",3),bitwiseXOR:q("^",4),bitwiseAND:q("&",5),equality:q("==/!=/===/!==",6),relational:q("</>/<=/>=",7),bitShift:q("<</>>/>>>",8),plusMin:new _("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:q("%",10),star:q("*",10),slash:q("/",10),starstar:new _("**",{beforeExpr:!0}),coalesce:q("??",1),_break:w("break"),_case:w("case",z),_catch:w("catch"),_continue:w("continue"),_debugger:w("debugger"),_default:w("default",z),_do:w("do",{isLoop:!0,beforeExpr:!0}),_else:w("else",z),_finally:w("finally"),_for:w("for",{isLoop:!0}),_function:w("function",j),_if:w("if"),_return:w("return",z),_switch:w("switch"),_throw:w("throw",z),_try:w("try"),_var:w("var"),_const:w("const"),_while:w("while",{isLoop:!0}),_with:w("with"),_new:w("new",{beforeExpr:!0,startsExpr:!0}),_this:w("this",j),_super:w("super",j),_class:w("class",j),_extends:w("extends",z),_export:w("export"),_import:w("import",j),_null:w("null",j),_true:w("true",j),_false:w("false",j),_in:w("in",{beforeExpr:!0,binop:7}),_instanceof:w("instanceof",{beforeExpr:!0,binop:7}),_typeof:w("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:w("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:w("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},H=/\r\n?|\n|\u2028|\u2029/,Yt=new RegExp(H.source,"g");function ge(s){return s===10||s===13||s===8232||s===8233}function lt(s,e,t){t===void 0&&(t=s.length);for(var n=e;n<t;n++){var i=s.charCodeAt(n);if(ge(i))return n<t-1&&i===13&&s.charCodeAt(n+1)===10?n+2:n+1}return-1}var pt=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,D=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ht=Object.prototype,Jt=ht.hasOwnProperty,es=ht.toString,xe=Object.hasOwn||(function(s,e){return Jt.call(s,e)}),tt=Array.isArray||(function(s){return es.call(s)==="[object Array]"}),st=Object.create(null);function re(s){return st[s]||(st[s]=new RegExp("^(?:"+s.replace(/ /g,"|")+")$"))}function se(s){return s<=65535?String.fromCharCode(s):(s-=65536,String.fromCharCode((s>>10)+55296,(s&1023)+56320))}var ts=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,ve=function(e,t){this.line=e,this.column=t};ve.prototype.offset=function(e){return new ve(this.line,this.column+e)};var Me=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function ft(s,e){for(var t=1,n=0;;){var i=lt(s,n,e);if(i<0)return new ve(t,e-n);++t,n=i}}var je={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},nt=!1;function ss(s){var e={};for(var t in je)e[t]=s&&xe(s,t)?s[t]:je[t];if(e.ecmaVersion==="latest"?e.ecmaVersion=1e8:e.ecmaVersion==null?(!nt&&typeof console=="object"&&console.warn&&(nt=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
2
- Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=11):e.ecmaVersion>=2015&&(e.ecmaVersion-=2009),e.allowReserved==null&&(e.allowReserved=e.ecmaVersion<5),(!s||s.allowHashBang==null)&&(e.allowHashBang=e.ecmaVersion>=14),tt(e.onToken)){var n=e.onToken;e.onToken=function(i){return n.push(i)}}return tt(e.onComment)&&(e.onComment=ns(e,e.onComment)),e}function ns(s,e){return function(t,n,i,r,a,o){var c={type:t?"Block":"Line",value:n,start:i,end:r};s.locations&&(c.loc=new Me(this,a,o)),s.ranges&&(c.range=[i,r]),e.push(c)}}var Se=1,Ee=2,Xe=4,dt=8,Ke=16,mt=32,Ie=64,gt=128,le=256,Pe=512,Oe=Se|Ee|le;function Ge(s,e){return Ee|(s?Xe:0)|(e?dt:0)}var we=0,Qe=1,ie=2,xt=3,Et=4,bt=5,L=function(e,t,n){this.options=e=ss(e),this.sourceFile=e.sourceFile,this.keywords=re(Kt[e.ecmaVersion>=6?6:e.sourceType==="module"?"5module":5]);var i="";e.allowReserved!==!0&&(i=Fe[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType==="module"&&(i+=" await")),this.reservedWords=re(i);var r=(i?i+" ":"")+Fe.strict;this.reservedWordsStrict=re(r),this.reservedWordsStrictBind=re(r+" "+Fe.strictBind),this.input=String(t),this.containsEsc=!1,n?(this.pos=n,this.lineStart=this.input.lastIndexOf(`
3
- `,n-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(H).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=l.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(Se),this.regexpState=null,this.privateNameStack=[]},J={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}};L.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};J.inFunction.get=function(){return(this.currentVarScope().flags&Ee)>0};J.inGenerator.get=function(){return(this.currentVarScope().flags&dt)>0};J.inAsync.get=function(){return(this.currentVarScope().flags&Xe)>0};J.canAwait.get=function(){for(var s=this.scopeStack.length-1;s>=0;s--){var e=this.scopeStack[s],t=e.flags;if(t&(le|Pe))return!1;if(t&Ee)return(t&Xe)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};J.allowSuper.get=function(){var s=this.currentThisScope(),e=s.flags;return(e&Ie)>0||this.options.allowSuperOutsideMethod};J.allowDirectSuper.get=function(){return(this.currentThisScope().flags&gt)>0};J.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};J.allowNewDotTarget.get=function(){for(var s=this.scopeStack.length-1;s>=0;s--){var e=this.scopeStack[s],t=e.flags;if(t&(le|Pe)||t&Ee&&!(t&Ke))return!0}return!1};J.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&le)>0};L.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,i=0;i<e.length;i++)n=e[i](n);return n};L.parse=function(e,t){return new this(t,e).parse()};L.parseExpressionAt=function(e,t,n){var i=new this(n,e,t);return i.nextToken(),i.parseExpression()};L.tokenizer=function(e,t){return new this(t,e)};Object.defineProperties(L.prototype,J);var B=L.prototype,is=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;B.strictDirective=function(s){if(this.options.ecmaVersion<5)return!1;for(;;){D.lastIndex=s,s+=D.exec(this.input)[0].length;var e=is.exec(this.input.slice(s));if(!e)return!1;if((e[1]||e[2])==="use strict"){D.lastIndex=s+e[0].length;var t=D.exec(this.input),n=t.index+t[0].length,i=this.input.charAt(n);return i===";"||i==="}"||H.test(t[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i==="!"&&this.input.charAt(n+1)==="=")}s+=e[0].length,D.lastIndex=s,s+=D.exec(this.input)[0].length,this.input[s]===";"&&s++}};B.eat=function(s){return this.type===s?(this.next(),!0):!1};B.isContextual=function(s){return this.type===l.name&&this.value===s&&!this.containsEsc};B.eatContextual=function(s){return this.isContextual(s)?(this.next(),!0):!1};B.expectContextual=function(s){this.eatContextual(s)||this.unexpected()};B.canInsertSemicolon=function(){return this.type===l.eof||this.type===l.braceR||H.test(this.input.slice(this.lastTokEnd,this.start))};B.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};B.semicolon=function(){!this.eat(l.semi)&&!this.insertSemicolon()&&this.unexpected()};B.afterTrailingComma=function(s,e){if(this.type===s)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};B.expect=function(s){this.eat(s)||this.unexpected()};B.unexpected=function(s){this.raise(s??this.start,"Unexpected token")};var Re=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};B.checkPatternErrors=function(s,e){if(s){s.trailingComma>-1&&this.raiseRecoverable(s.trailingComma,"Comma is not permitted after the rest element");var t=e?s.parenthesizedAssign:s.parenthesizedBind;t>-1&&this.raiseRecoverable(t,e?"Assigning to rvalue":"Parenthesized pattern")}};B.checkExpressionErrors=function(s,e){if(!s)return!1;var t=s.shorthandAssign,n=s.doubleProto;if(!e)return t>=0||n>=0;t>=0&&this.raise(t,"Shorthand property assignments are valid only in destructuring patterns"),n>=0&&this.raiseRecoverable(n,"Redefinition of __proto__ property")};B.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")};B.isSimpleAssignTarget=function(s){return s.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(s.expression):s.type==="Identifier"||s.type==="MemberExpression"};var v=L.prototype;v.parseTopLevel=function(s){var e=Object.create(null);for(s.body||(s.body=[]);this.type!==l.eof;){var t=this.parseStatement(null,!0,e);s.body.push(t)}if(this.inModule)for(var n=0,i=Object.keys(this.undefinedExports);n<i.length;n+=1){var r=i[n];this.raiseRecoverable(this.undefinedExports[r].start,"Export '"+r+"' is not defined")}return this.adaptDirectivePrologue(s.body),this.next(),s.sourceType=this.options.sourceType,this.finishNode(s,"Program")};var Ze={kind:"loop"},rs={kind:"switch"};v.isLet=function(s){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;D.lastIndex=this.pos;var e=D.exec(this.input),t=this.pos+e[0].length,n=this.input.charCodeAt(t);if(n===91||n===92)return!0;if(s)return!1;if(n===123||n>55295&&n<56320)return!0;if(Y(n,!0)){for(var i=t+1;ae(n=this.input.charCodeAt(i),!0);)++i;if(n===92||n>55295&&n<56320)return!0;var r=this.input.slice(t,i);if(!Gt.test(r))return!0}return!1};v.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;D.lastIndex=this.pos;var s=D.exec(this.input),e=this.pos+s[0].length,t;return!H.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(ae(t=this.input.charCodeAt(e+8))||t>55295&&t<56320))};v.isUsingKeyword=function(s,e){if(this.options.ecmaVersion<17||!this.isContextual(s?"await":"using"))return!1;D.lastIndex=this.pos;var t=D.exec(this.input),n=this.pos+t[0].length;if(H.test(this.input.slice(this.pos,n)))return!1;if(s){var i=n+5,r;if(this.input.slice(n,i)!=="using"||i===this.input.length||ae(r=this.input.charCodeAt(i))||r>55295&&r<56320)return!1;D.lastIndex=i;var a=D.exec(this.input);if(a&&H.test(this.input.slice(i,i+a[0].length)))return!1}if(e){var o=n+2,c;if(this.input.slice(n,o)==="of"&&(o===this.input.length||!ae(c=this.input.charCodeAt(o))&&!(c>55295&&c<56320)))return!1}var u=this.input.charCodeAt(n);return Y(u,!0)||u===92};v.isAwaitUsing=function(s){return this.isUsingKeyword(!0,s)};v.isUsing=function(s){return this.isUsingKeyword(!1,s)};v.parseStatement=function(s,e,t){var n=this.type,i=this.startNode(),r;switch(this.isLet(s)&&(n=l._var,r="let"),n){case l._break:case l._continue:return this.parseBreakContinueStatement(i,n.keyword);case l._debugger:return this.parseDebuggerStatement(i);case l._do:return this.parseDoStatement(i);case l._for:return this.parseForStatement(i);case l._function:return s&&(this.strict||s!=="if"&&s!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!s);case l._class:return s&&this.unexpected(),this.parseClass(i,!0);case l._if:return this.parseIfStatement(i);case l._return:return this.parseReturnStatement(i);case l._switch:return this.parseSwitchStatement(i);case l._throw:return this.parseThrowStatement(i);case l._try:return this.parseTryStatement(i);case l._const:case l._var:return r=r||this.value,s&&r!=="var"&&this.unexpected(),this.parseVarStatement(i,r);case l._while:return this.parseWhileStatement(i);case l._with:return this.parseWithStatement(i);case l.braceL:return this.parseBlock(!0,i);case l.semi:return this.parseEmptyStatement(i);case l._export:case l._import:if(this.options.ecmaVersion>10&&n===l._import){D.lastIndex=this.pos;var a=D.exec(this.input),o=this.pos+a[0].length,c=this.input.charCodeAt(o);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),n===l._import?this.parseImport(i):this.parseExport(i,t);default:if(this.isAsyncFunction())return s&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!s);var u=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(u)return e&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),u==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(i,!1,u),this.semicolon(),this.finishNode(i,"VariableDeclaration");var p=this.value,h=this.parseExpression();return n===l.name&&h.type==="Identifier"&&this.eat(l.colon)?this.parseLabeledStatement(i,p,h,s):this.parseExpressionStatement(i,h)}};v.parseBreakContinueStatement=function(s,e){var t=e==="break";this.next(),this.eat(l.semi)||this.insertSemicolon()?s.label=null:this.type!==l.name?this.unexpected():(s.label=this.parseIdent(),this.semicolon());for(var n=0;n<this.labels.length;++n){var i=this.labels[n];if((s.label==null||i.name===s.label.name)&&(i.kind!=null&&(t||i.kind==="loop")||s.label&&t))break}return n===this.labels.length&&this.raise(s.start,"Unsyntactic "+e),this.finishNode(s,t?"BreakStatement":"ContinueStatement")};v.parseDebuggerStatement=function(s){return this.next(),this.semicolon(),this.finishNode(s,"DebuggerStatement")};v.parseDoStatement=function(s){return this.next(),this.labels.push(Ze),s.body=this.parseStatement("do"),this.labels.pop(),this.expect(l._while),s.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(l.semi):this.semicolon(),this.finishNode(s,"DoWhileStatement")};v.parseForStatement=function(s){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Ze),this.enterScope(0),this.expect(l.parenL),this.type===l.semi)return e>-1&&this.unexpected(e),this.parseFor(s,null);var t=this.isLet();if(this.type===l._var||this.type===l._const||t){var n=this.startNode(),i=t?"let":this.value;return this.next(),this.parseVar(n,!0,i),this.finishNode(n,"VariableDeclaration"),this.parseForAfterInit(s,n,e)}var r=this.isContextual("let"),a=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var c=this.startNode();return this.next(),o==="await using"&&this.next(),this.parseVar(c,!0,o),this.finishNode(c,"VariableDeclaration"),this.parseForAfterInit(s,c,e)}var u=this.containsEsc,p=new Re,h=this.start,f=e>-1?this.parseExprSubscripts(p,"await"):this.parseExpression(!0,p);return this.type===l._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===l._in&&this.unexpected(e),s.await=!0):a&&this.options.ecmaVersion>=8&&(f.start===h&&!u&&f.type==="Identifier"&&f.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(s.await=!1)),r&&a&&this.raise(f.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(f,!1,p),this.checkLValPattern(f),this.parseForIn(s,f)):(this.checkExpressionErrors(p,!0),e>-1&&this.unexpected(e),this.parseFor(s,f))};v.parseForAfterInit=function(s,e,t){return(this.type===l._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&e.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===l._in?t>-1&&this.unexpected(t):s.await=t>-1),this.parseForIn(s,e)):(t>-1&&this.unexpected(t),this.parseFor(s,e))};v.parseFunctionStatement=function(s,e,t){return this.next(),this.parseFunction(s,ye|(t?0:We),!1,e)};v.parseIfStatement=function(s){return this.next(),s.test=this.parseParenExpression(),s.consequent=this.parseStatement("if"),s.alternate=this.eat(l._else)?this.parseStatement("if"):null,this.finishNode(s,"IfStatement")};v.parseReturnStatement=function(s){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(l.semi)||this.insertSemicolon()?s.argument=null:(s.argument=this.parseExpression(),this.semicolon()),this.finishNode(s,"ReturnStatement")};v.parseSwitchStatement=function(s){this.next(),s.discriminant=this.parseParenExpression(),s.cases=[],this.expect(l.braceL),this.labels.push(rs),this.enterScope(0);for(var e,t=!1;this.type!==l.braceR;)if(this.type===l._case||this.type===l._default){var n=this.type===l._case;e&&this.finishNode(e,"SwitchCase"),s.cases.push(e=this.startNode()),e.consequent=[],this.next(),n?e.test=this.parseExpression():(t&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),t=!0,e.test=null),this.expect(l.colon)}else e||this.unexpected(),e.consequent.push(this.parseStatement(null));return this.exitScope(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(s,"SwitchStatement")};v.parseThrowStatement=function(s){return this.next(),H.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),s.argument=this.parseExpression(),this.semicolon(),this.finishNode(s,"ThrowStatement")};var as=[];v.parseCatchClauseParam=function(){var s=this.parseBindingAtom(),e=s.type==="Identifier";return this.enterScope(e?mt:0),this.checkLValPattern(s,e?Et:ie),this.expect(l.parenR),s};v.parseTryStatement=function(s){if(this.next(),s.block=this.parseBlock(),s.handler=null,this.type===l._catch){var e=this.startNode();this.next(),this.eat(l.parenL)?e.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterScope(0)),e.body=this.parseBlock(!1),this.exitScope(),s.handler=this.finishNode(e,"CatchClause")}return s.finalizer=this.eat(l._finally)?this.parseBlock():null,!s.handler&&!s.finalizer&&this.raise(s.start,"Missing catch or finally clause"),this.finishNode(s,"TryStatement")};v.parseVarStatement=function(s,e,t){return this.next(),this.parseVar(s,!1,e,t),this.semicolon(),this.finishNode(s,"VariableDeclaration")};v.parseWhileStatement=function(s){return this.next(),s.test=this.parseParenExpression(),this.labels.push(Ze),s.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(s,"WhileStatement")};v.parseWithStatement=function(s){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),s.object=this.parseParenExpression(),s.body=this.parseStatement("with"),this.finishNode(s,"WithStatement")};v.parseEmptyStatement=function(s){return this.next(),this.finishNode(s,"EmptyStatement")};v.parseLabeledStatement=function(s,e,t,n){for(var i=0,r=this.labels;i<r.length;i+=1){var a=r[i];a.name===e&&this.raise(t.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===l._switch?"switch":null,c=this.labels.length-1;c>=0;c--){var u=this.labels[c];if(u.statementStart===s.start)u.statementStart=this.start,u.kind=o;else break}return this.labels.push({name:e,kind:o,statementStart:this.start}),s.body=this.parseStatement(n?n.indexOf("label")===-1?n+"label":n:"label"),this.labels.pop(),s.label=t,this.finishNode(s,"LabeledStatement")};v.parseExpressionStatement=function(s,e){return s.expression=e,this.semicolon(),this.finishNode(s,"ExpressionStatement")};v.parseBlock=function(s,e,t){for(s===void 0&&(s=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(l.braceL),s&&this.enterScope(0);this.type!==l.braceR;){var n=this.parseStatement(null);e.body.push(n)}return t&&(this.strict=!1),this.next(),s&&this.exitScope(),this.finishNode(e,"BlockStatement")};v.parseFor=function(s,e){return s.init=e,this.expect(l.semi),s.test=this.type===l.semi?null:this.parseExpression(),this.expect(l.semi),s.update=this.type===l.parenR?null:this.parseExpression(),this.expect(l.parenR),s.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(s,"ForStatement")};v.parseForIn=function(s,e){var t=this.type===l._in;return this.next(),e.type==="VariableDeclaration"&&e.declarations[0].init!=null&&(!t||this.options.ecmaVersion<8||this.strict||e.kind!=="var"||e.declarations[0].id.type!=="Identifier")&&this.raise(e.start,(t?"for-in":"for-of")+" loop variable declaration may not have an initializer"),s.left=e,s.right=t?this.parseExpression():this.parseMaybeAssign(),this.expect(l.parenR),s.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(s,t?"ForInStatement":"ForOfStatement")};v.parseVar=function(s,e,t,n){for(s.declarations=[],s.kind=t;;){var i=this.startNode();if(this.parseVarId(i,t),this.eat(l.eq)?i.init=this.parseMaybeAssign(e):!n&&t==="const"&&!(this.type===l._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!n&&(t==="using"||t==="await using")&&this.options.ecmaVersion>=17&&this.type!==l._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+t+" declaration"):!n&&i.id.type!=="Identifier"&&!(e&&(this.type===l._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):i.init=null,s.declarations.push(this.finishNode(i,"VariableDeclarator")),!this.eat(l.comma))break}return s};v.parseVarId=function(s,e){s.id=e==="using"||e==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(s.id,e==="var"?Qe:ie,!1)};var ye=1,We=2,Ct=4;v.parseFunction=function(s,e,t,n,i){this.initFunction(s),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!n)&&(this.type===l.star&&e&We&&this.unexpected(),s.generator=this.eat(l.star)),this.options.ecmaVersion>=8&&(s.async=!!n),e&ye&&(s.id=e&Ct&&this.type!==l.name?null:this.parseIdent(),s.id&&!(e&We)&&this.checkLValSimple(s.id,this.strict||s.generator||s.async?this.treatFunctionsAsVar?Qe:ie:xt));var r=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ge(s.async,s.generator)),e&ye||(s.id=this.type===l.name?this.parseIdent():null),this.parseFunctionParams(s),this.parseFunctionBody(s,t,!1,i),this.yieldPos=r,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(s,e&ye?"FunctionDeclaration":"FunctionExpression")};v.parseFunctionParams=function(s){this.expect(l.parenL),s.params=this.parseBindingList(l.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};v.parseClass=function(s,e){this.next();var t=this.strict;this.strict=!0,this.parseClassId(s,e),this.parseClassSuper(s);var n=this.enterClassBody(),i=this.startNode(),r=!1;for(i.body=[],this.expect(l.braceL);this.type!==l.braceR;){var a=this.parseClassElement(s.superClass!==null);a&&(i.body.push(a),a.type==="MethodDefinition"&&a.kind==="constructor"?(r&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),r=!0):a.key&&a.key.type==="PrivateIdentifier"&&os(n,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=t,this.next(),s.body=this.finishNode(i,"ClassBody"),this.exitClassBody(),this.finishNode(s,e?"ClassDeclaration":"ClassExpression")};v.parseClassElement=function(s){if(this.eat(l.semi))return null;var e=this.options.ecmaVersion,t=this.startNode(),n="",i=!1,r=!1,a="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(l.braceL))return this.parseClassStaticBlock(t),t;this.isClassElementNameStart()||this.type===l.star?o=!0:n="static"}if(t.static=o,!n&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===l.star)&&!this.canInsertSemicolon()?r=!0:n="async"),!n&&(e>=9||!r)&&this.eat(l.star)&&(i=!0),!n&&!r&&!i){var c=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=c:n=c)}if(n?(t.computed=!1,t.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),t.key.name=n,this.finishNode(t.key,"Identifier")):this.parseClassElementName(t),e<13||this.type===l.parenL||a!=="method"||i||r){var u=!t.static&&_e(t,"constructor"),p=u&&s;u&&a!=="method"&&this.raise(t.key.start,"Constructor can't have get/set modifier"),t.kind=u?"constructor":a,this.parseClassMethod(t,i,r,p)}else this.parseClassField(t);return t};v.isClassElementNameStart=function(){return this.type===l.name||this.type===l.privateId||this.type===l.num||this.type===l.string||this.type===l.bracketL||this.type.keyword};v.parseClassElementName=function(s){this.type===l.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),s.computed=!1,s.key=this.parsePrivateIdent()):this.parsePropertyName(s)};v.parseClassMethod=function(s,e,t,n){var i=s.key;s.kind==="constructor"?(e&&this.raise(i.start,"Constructor can't be a generator"),t&&this.raise(i.start,"Constructor can't be an async method")):s.static&&_e(s,"prototype")&&this.raise(i.start,"Classes may not have a static property named prototype");var r=s.value=this.parseMethod(e,t,n);return s.kind==="get"&&r.params.length!==0&&this.raiseRecoverable(r.start,"getter should have no params"),s.kind==="set"&&r.params.length!==1&&this.raiseRecoverable(r.start,"setter should have exactly one param"),s.kind==="set"&&r.params[0].type==="RestElement"&&this.raiseRecoverable(r.params[0].start,"Setter cannot use rest params"),this.finishNode(s,"MethodDefinition")};v.parseClassField=function(s){return _e(s,"constructor")?this.raise(s.key.start,"Classes can't have a field named 'constructor'"):s.static&&_e(s,"prototype")&&this.raise(s.key.start,"Classes can't have a static field named 'prototype'"),this.eat(l.eq)?(this.enterScope(Pe|Ie),s.value=this.parseMaybeAssign(),this.exitScope()):s.value=null,this.semicolon(),this.finishNode(s,"PropertyDefinition")};v.parseClassStaticBlock=function(s){s.body=[];var e=this.labels;for(this.labels=[],this.enterScope(le|Ie);this.type!==l.braceR;){var t=this.parseStatement(null);s.body.push(t)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(s,"StaticBlock")};v.parseClassId=function(s,e){this.type===l.name?(s.id=this.parseIdent(),e&&this.checkLValSimple(s.id,ie,!1)):(e===!0&&this.unexpected(),s.id=null)};v.parseClassSuper=function(s){s.superClass=this.eat(l._extends)?this.parseExprSubscripts(null,!1):null};v.enterClassBody=function(){var s={declared:Object.create(null),used:[]};return this.privateNameStack.push(s),s.declared};v.exitClassBody=function(){var s=this.privateNameStack.pop(),e=s.declared,t=s.used;if(this.options.checkPrivateFields)for(var n=this.privateNameStack.length,i=n===0?null:this.privateNameStack[n-1],r=0;r<t.length;++r){var a=t[r];xe(e,a.name)||(i?i.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}};function os(s,e){var t=e.key.name,n=s[t],i="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(i=(e.static?"s":"i")+e.kind),n==="iget"&&i==="iset"||n==="iset"&&i==="iget"||n==="sget"&&i==="sset"||n==="sset"&&i==="sget"?(s[t]="true",!1):n?!0:(s[t]=i,!1)}function _e(s,e){var t=s.computed,n=s.key;return!t&&(n.type==="Identifier"&&n.name===e||n.type==="Literal"&&n.value===e)}v.parseExportAllDeclaration=function(s,e){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(s.exported=this.parseModuleExportName(),this.checkExport(e,s.exported,this.lastTokStart)):s.exported=null),this.expectContextual("from"),this.type!==l.string&&this.unexpected(),s.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(s,"ExportAllDeclaration")};v.parseExport=function(s,e){if(this.next(),this.eat(l.star))return this.parseExportAllDeclaration(s,e);if(this.eat(l._default))return this.checkExport(e,"default",this.lastTokStart),s.declaration=this.parseExportDefaultDeclaration(),this.finishNode(s,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())s.declaration=this.parseExportDeclaration(s),s.declaration.type==="VariableDeclaration"?this.checkVariableExport(e,s.declaration.declarations):this.checkExport(e,s.declaration.id,s.declaration.id.start),s.specifiers=[],s.source=null,this.options.ecmaVersion>=16&&(s.attributes=[]);else{if(s.declaration=null,s.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==l.string&&this.unexpected(),s.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause());else{for(var t=0,n=s.specifiers;t<n.length;t+=1){var i=n[t];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type==="Literal"&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}s.source=null,this.options.ecmaVersion>=16&&(s.attributes=[])}this.semicolon()}return this.finishNode(s,"ExportNamedDeclaration")};v.parseExportDeclaration=function(s){return this.parseStatement(null)};v.parseExportDefaultDeclaration=function(){var s;if(this.type===l._function||(s=this.isAsyncFunction())){var e=this.startNode();return this.next(),s&&this.next(),this.parseFunction(e,ye|Ct,!1,s)}else if(this.type===l._class){var t=this.startNode();return this.parseClass(t,"nullableID")}else{var n=this.parseMaybeAssign();return this.semicolon(),n}};v.checkExport=function(s,e,t){s&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),xe(s,e)&&this.raiseRecoverable(t,"Duplicate export '"+e+"'"),s[e]=!0)};v.checkPatternExport=function(s,e){var t=e.type;if(t==="Identifier")this.checkExport(s,e,e.start);else if(t==="ObjectPattern")for(var n=0,i=e.properties;n<i.length;n+=1){var r=i[n];this.checkPatternExport(s,r)}else if(t==="ArrayPattern")for(var a=0,o=e.elements;a<o.length;a+=1){var c=o[a];c&&this.checkPatternExport(s,c)}else t==="Property"?this.checkPatternExport(s,e.value):t==="AssignmentPattern"?this.checkPatternExport(s,e.left):t==="RestElement"&&this.checkPatternExport(s,e.argument)};v.checkVariableExport=function(s,e){if(s)for(var t=0,n=e;t<n.length;t+=1){var i=n[t];this.checkPatternExport(s,i.id)}};v.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};v.parseExportSpecifier=function(s){var e=this.startNode();return e.local=this.parseModuleExportName(),e.exported=this.eatContextual("as")?this.parseModuleExportName():e.local,this.checkExport(s,e.exported,e.exported.start),this.finishNode(e,"ExportSpecifier")};v.parseExportSpecifiers=function(s){var e=[],t=!0;for(this.expect(l.braceL);!this.eat(l.braceR);){if(t)t=!1;else if(this.expect(l.comma),this.afterTrailingComma(l.braceR))break;e.push(this.parseExportSpecifier(s))}return e};v.parseImport=function(s){return this.next(),this.type===l.string?(s.specifiers=as,s.source=this.parseExprAtom()):(s.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),s.source=this.type===l.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(s.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(s,"ImportDeclaration")};v.parseImportSpecifier=function(){var s=this.startNode();return s.imported=this.parseModuleExportName(),this.eatContextual("as")?s.local=this.parseIdent():(this.checkUnreserved(s.imported),s.local=s.imported),this.checkLValSimple(s.local,ie),this.finishNode(s,"ImportSpecifier")};v.parseImportDefaultSpecifier=function(){var s=this.startNode();return s.local=this.parseIdent(),this.checkLValSimple(s.local,ie),this.finishNode(s,"ImportDefaultSpecifier")};v.parseImportNamespaceSpecifier=function(){var s=this.startNode();return this.next(),this.expectContextual("as"),s.local=this.parseIdent(),this.checkLValSimple(s.local,ie),this.finishNode(s,"ImportNamespaceSpecifier")};v.parseImportSpecifiers=function(){var s=[],e=!0;if(this.type===l.name&&(s.push(this.parseImportDefaultSpecifier()),!this.eat(l.comma)))return s;if(this.type===l.star)return s.push(this.parseImportNamespaceSpecifier()),s;for(this.expect(l.braceL);!this.eat(l.braceR);){if(e)e=!1;else if(this.expect(l.comma),this.afterTrailingComma(l.braceR))break;s.push(this.parseImportSpecifier())}return s};v.parseWithClause=function(){var s=[];if(!this.eat(l._with))return s;this.expect(l.braceL);for(var e={},t=!0;!this.eat(l.braceR);){if(t)t=!1;else if(this.expect(l.comma),this.afterTrailingComma(l.braceR))break;var n=this.parseImportAttribute(),i=n.key.type==="Identifier"?n.key.name:n.key.value;xe(e,i)&&this.raiseRecoverable(n.key.start,"Duplicate attribute key '"+i+"'"),e[i]=!0,s.push(n)}return s};v.parseImportAttribute=function(){var s=this.startNode();return s.key=this.type===l.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(l.colon),this.type!==l.string&&this.unexpected(),s.value=this.parseExprAtom(),this.finishNode(s,"ImportAttribute")};v.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===l.string){var s=this.parseLiteral(this.value);return ts.test(s.value)&&this.raise(s.start,"An export name cannot include a lone surrogate."),s}return this.parseIdent(!0)};v.adaptDirectivePrologue=function(s){for(var e=0;e<s.length&&this.isDirectiveCandidate(s[e]);++e)s[e].directive=s[e].expression.raw.slice(1,-1)};v.isDirectiveCandidate=function(s){return this.options.ecmaVersion>=5&&s.type==="ExpressionStatement"&&s.expression.type==="Literal"&&typeof s.expression.value=="string"&&(this.input[s.start]==='"'||this.input[s.start]==="'")};var G=L.prototype;G.toAssignable=function(s,e,t){if(this.options.ecmaVersion>=6&&s)switch(s.type){case"Identifier":this.inAsync&&s.name==="await"&&this.raise(s.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":s.type="ObjectPattern",t&&this.checkPatternErrors(t,!0);for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];this.toAssignable(r,e),r.type==="RestElement"&&(r.argument.type==="ArrayPattern"||r.argument.type==="ObjectPattern")&&this.raise(r.argument.start,"Unexpected token")}break;case"Property":s.kind!=="init"&&this.raise(s.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(s.value,e);break;case"ArrayExpression":s.type="ArrayPattern",t&&this.checkPatternErrors(t,!0),this.toAssignableList(s.elements,e);break;case"SpreadElement":s.type="RestElement",this.toAssignable(s.argument,e),s.argument.type==="AssignmentPattern"&&this.raise(s.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":s.operator!=="="&&this.raise(s.left.end,"Only '=' operator can be used for specifying default value."),s.type="AssignmentPattern",delete s.operator,this.toAssignable(s.left,e);break;case"ParenthesizedExpression":this.toAssignable(s.expression,e,t);break;case"ChainExpression":this.raiseRecoverable(s.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!e)break;default:this.raise(s.start,"Assigning to rvalue")}else t&&this.checkPatternErrors(t,!0);return s};G.toAssignableList=function(s,e){for(var t=s.length,n=0;n<t;n++){var i=s[n];i&&this.toAssignable(i,e)}if(t){var r=s[t-1];this.options.ecmaVersion===6&&e&&r&&r.type==="RestElement"&&r.argument.type!=="Identifier"&&this.unexpected(r.argument.start)}return s};G.parseSpread=function(s){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,s),this.finishNode(e,"SpreadElement")};G.parseRestBinding=function(){var s=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==l.name&&this.unexpected(),s.argument=this.parseBindingAtom(),this.finishNode(s,"RestElement")};G.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case l.bracketL:var s=this.startNode();return this.next(),s.elements=this.parseBindingList(l.bracketR,!0,!0),this.finishNode(s,"ArrayPattern");case l.braceL:return this.parseObj(!0)}return this.parseIdent()};G.parseBindingList=function(s,e,t,n){for(var i=[],r=!0;!this.eat(s);)if(r?r=!1:this.expect(l.comma),e&&this.type===l.comma)i.push(null);else{if(t&&this.afterTrailingComma(s))break;if(this.type===l.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),i.push(a),this.type===l.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(s);break}else i.push(this.parseAssignableListItem(n))}return i};G.parseAssignableListItem=function(s){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};G.parseBindingListItem=function(s){return s};G.parseMaybeDefault=function(s,e,t){if(t=t||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(l.eq))return t;var n=this.startNodeAt(s,e);return n.left=t,n.right=this.parseMaybeAssign(),this.finishNode(n,"AssignmentPattern")};G.checkLValSimple=function(s,e,t){e===void 0&&(e=we);var n=e!==we;switch(s.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(s.name)&&this.raiseRecoverable(s.start,(n?"Binding ":"Assigning to ")+s.name+" in strict mode"),n&&(e===ie&&s.name==="let"&&this.raiseRecoverable(s.start,"let is disallowed as a lexically bound name"),t&&(xe(t,s.name)&&this.raiseRecoverable(s.start,"Argument name clash"),t[s.name]=!0),e!==bt&&this.declareName(s.name,e,s.start));break;case"ChainExpression":this.raiseRecoverable(s.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":n&&this.raiseRecoverable(s.start,"Binding member expression");break;case"ParenthesizedExpression":return n&&this.raiseRecoverable(s.start,"Binding parenthesized expression"),this.checkLValSimple(s.expression,e,t);default:this.raise(s.start,(n?"Binding":"Assigning to")+" rvalue")}};G.checkLValPattern=function(s,e,t){switch(e===void 0&&(e=we),s.type){case"ObjectPattern":for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];this.checkLValInnerPattern(r,e,t)}break;case"ArrayPattern":for(var a=0,o=s.elements;a<o.length;a+=1){var c=o[a];c&&this.checkLValInnerPattern(c,e,t)}break;default:this.checkLValSimple(s,e,t)}};G.checkLValInnerPattern=function(s,e,t){switch(e===void 0&&(e=we),s.type){case"Property":this.checkLValInnerPattern(s.value,e,t);break;case"AssignmentPattern":this.checkLValPattern(s.left,e,t);break;case"RestElement":this.checkLValPattern(s.argument,e,t);break;default:this.checkLValPattern(s,e,t)}};var Q=function(e,t,n,i,r){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=i,this.generator=!!r},I={b_stat:new Q("{",!1),b_expr:new Q("{",!0),b_tmpl:new Q("${",!1),p_stat:new Q("(",!1),p_expr:new Q("(",!0),q_tmpl:new Q("`",!0,!0,function(s){return s.tryReadTemplateToken()}),f_stat:new Q("function",!1),f_expr:new Q("function",!0),f_expr_gen:new Q("function",!0,!1,null,!0),f_gen:new Q("function",!1,!1,null,!0)},be=L.prototype;be.initialContext=function(){return[I.b_stat]};be.curContext=function(){return this.context[this.context.length-1]};be.braceIsBlock=function(s){var e=this.curContext();return e===I.f_expr||e===I.f_stat?!0:s===l.colon&&(e===I.b_stat||e===I.b_expr)?!e.isExpr:s===l._return||s===l.name&&this.exprAllowed?H.test(this.input.slice(this.lastTokEnd,this.start)):s===l._else||s===l.semi||s===l.eof||s===l.parenR||s===l.arrow?!0:s===l.braceL?e===I.b_stat:s===l._var||s===l._const||s===l.name?!1:!this.exprAllowed};be.inGeneratorContext=function(){for(var s=this.context.length-1;s>=1;s--){var e=this.context[s];if(e.token==="function")return e.generator}return!1};be.updateContext=function(s){var e,t=this.type;t.keyword&&s===l.dot?this.exprAllowed=!1:(e=t.updateContext)?e.call(this,s):this.exprAllowed=t.beforeExpr};be.overrideContext=function(s){this.curContext()!==s&&(this.context[this.context.length-1]=s)};l.parenR.updateContext=l.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var s=this.context.pop();s===I.b_stat&&this.curContext().token==="function"&&(s=this.context.pop()),this.exprAllowed=!s.isExpr};l.braceL.updateContext=function(s){this.context.push(this.braceIsBlock(s)?I.b_stat:I.b_expr),this.exprAllowed=!0};l.dollarBraceL.updateContext=function(){this.context.push(I.b_tmpl),this.exprAllowed=!0};l.parenL.updateContext=function(s){var e=s===l._if||s===l._for||s===l._with||s===l._while;this.context.push(e?I.p_stat:I.p_expr),this.exprAllowed=!0};l.incDec.updateContext=function(){};l._function.updateContext=l._class.updateContext=function(s){s.beforeExpr&&s!==l._else&&!(s===l.semi&&this.curContext()!==I.p_stat)&&!(s===l._return&&H.test(this.input.slice(this.lastTokEnd,this.start)))&&!((s===l.colon||s===l.braceL)&&this.curContext()===I.b_stat)?this.context.push(I.f_expr):this.context.push(I.f_stat),this.exprAllowed=!1};l.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};l.backQuote.updateContext=function(){this.curContext()===I.q_tmpl?this.context.pop():this.context.push(I.q_tmpl),this.exprAllowed=!1};l.star.updateContext=function(s){if(s===l._function){var e=this.context.length-1;this.context[e]===I.f_expr?this.context[e]=I.f_expr_gen:this.context[e]=I.f_gen}this.exprAllowed=!0};l.name.updateContext=function(s){var e=!1;this.options.ecmaVersion>=6&&s!==l.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var T=L.prototype;T.checkPropClash=function(s,e,t){if(!(this.options.ecmaVersion>=9&&s.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(s.computed||s.method||s.shorthand))){var n=s.key,i;switch(n.type){case"Identifier":i=n.name;break;case"Literal":i=String(n.value);break;default:return}var r=s.kind;if(this.options.ecmaVersion>=6){i==="__proto__"&&r==="init"&&(e.proto&&(t?t.doubleProto<0&&(t.doubleProto=n.start):this.raiseRecoverable(n.start,"Redefinition of __proto__ property")),e.proto=!0);return}i="$"+i;var a=e[i];if(a){var o;r==="init"?o=this.strict&&a.init||a.get||a.set:o=a.init||a[r],o&&this.raiseRecoverable(n.start,"Redefinition of property")}else a=e[i]={init:!1,get:!1,set:!1};a[r]=!0}};T.parseExpression=function(s,e){var t=this.start,n=this.startLoc,i=this.parseMaybeAssign(s,e);if(this.type===l.comma){var r=this.startNodeAt(t,n);for(r.expressions=[i];this.eat(l.comma);)r.expressions.push(this.parseMaybeAssign(s,e));return this.finishNode(r,"SequenceExpression")}return i};T.parseMaybeAssign=function(s,e,t){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(s);this.exprAllowed=!1}var n=!1,i=-1,r=-1,a=-1;e?(i=e.parenthesizedAssign,r=e.trailingComma,a=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new Re,n=!0);var o=this.start,c=this.startLoc;(this.type===l.parenL||this.type===l.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=s==="await");var u=this.parseMaybeConditional(s,e);if(t&&(u=t.call(this,u,o,c)),this.type.isAssign){var p=this.startNodeAt(o,c);return p.operator=this.value,this.type===l.eq&&(u=this.toAssignable(u,!1,e)),n||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=u.start&&(e.shorthandAssign=-1),this.type===l.eq?this.checkLValPattern(u):this.checkLValSimple(u),p.left=u,this.next(),p.right=this.parseMaybeAssign(s),a>-1&&(e.doubleProto=a),this.finishNode(p,"AssignmentExpression")}else n&&this.checkExpressionErrors(e,!0);return i>-1&&(e.parenthesizedAssign=i),r>-1&&(e.trailingComma=r),u};T.parseMaybeConditional=function(s,e){var t=this.start,n=this.startLoc,i=this.parseExprOps(s,e);if(this.checkExpressionErrors(e))return i;if(this.eat(l.question)){var r=this.startNodeAt(t,n);return r.test=i,r.consequent=this.parseMaybeAssign(),this.expect(l.colon),r.alternate=this.parseMaybeAssign(s),this.finishNode(r,"ConditionalExpression")}return i};T.parseExprOps=function(s,e){var t=this.start,n=this.startLoc,i=this.parseMaybeUnary(e,!1,!1,s);return this.checkExpressionErrors(e)||i.start===t&&i.type==="ArrowFunctionExpression"?i:this.parseExprOp(i,t,n,-1,s)};T.parseExprOp=function(s,e,t,n,i){var r=this.type.binop;if(r!=null&&(!i||this.type!==l._in)&&r>n){var a=this.type===l.logicalOR||this.type===l.logicalAND,o=this.type===l.coalesce;o&&(r=l.logicalAND.binop);var c=this.value;this.next();var u=this.start,p=this.startLoc,h=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),u,p,r,i),f=this.buildBinary(e,t,s,h,c,a||o);return(a&&this.type===l.coalesce||o&&(this.type===l.logicalOR||this.type===l.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(f,e,t,n,i)}return s};T.buildBinary=function(s,e,t,n,i,r){n.type==="PrivateIdentifier"&&this.raise(n.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(s,e);return a.left=t,a.operator=i,a.right=n,this.finishNode(a,r?"LogicalExpression":"BinaryExpression")};T.parseMaybeUnary=function(s,e,t,n){var i=this.start,r=this.startLoc,a;if(this.isContextual("await")&&this.canAwait)a=this.parseAwait(n),e=!0;else if(this.type.prefix){var o=this.startNode(),c=this.type===l.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,c,n),this.checkExpressionErrors(s,!0),c?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&yt(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&He(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):e=!0,a=this.finishNode(o,c?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===l.privateId)(n||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),a=this.parsePrivateIdent(),this.type!==l._in&&this.unexpected();else{if(a=this.parseExprSubscripts(s,n),this.checkExpressionErrors(s))return a;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=this.startNodeAt(i,r);u.operator=this.value,u.prefix=!1,u.argument=a,this.checkLValSimple(a),this.next(),a=this.finishNode(u,"UpdateExpression")}}if(!t&&this.eat(l.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(i,r,a,this.parseMaybeUnary(null,!1,!1,n),"**",!1);else return a};function yt(s){return s.type==="Identifier"||s.type==="ParenthesizedExpression"&&yt(s.expression)}function He(s){return s.type==="MemberExpression"&&s.property.type==="PrivateIdentifier"||s.type==="ChainExpression"&&He(s.expression)||s.type==="ParenthesizedExpression"&&He(s.expression)}T.parseExprSubscripts=function(s,e){var t=this.start,n=this.startLoc,i=this.parseExprAtom(s,e);if(i.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return i;var r=this.parseSubscripts(i,t,n,!1,e);return s&&r.type==="MemberExpression"&&(s.parenthesizedAssign>=r.start&&(s.parenthesizedAssign=-1),s.parenthesizedBind>=r.start&&(s.parenthesizedBind=-1),s.trailingComma>=r.start&&(s.trailingComma=-1)),r};T.parseSubscripts=function(s,e,t,n,i){for(var r=this.options.ecmaVersion>=8&&s.type==="Identifier"&&s.name==="async"&&this.lastTokEnd===s.end&&!this.canInsertSemicolon()&&s.end-s.start===5&&this.potentialArrowAt===s.start,a=!1;;){var o=this.parseSubscript(s,e,t,n,r,a,i);if(o.optional&&(a=!0),o===s||o.type==="ArrowFunctionExpression"){if(a){var c=this.startNodeAt(e,t);c.expression=o,o=this.finishNode(c,"ChainExpression")}return o}s=o}};T.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(l.arrow)};T.parseSubscriptAsyncArrow=function(s,e,t,n){return this.parseArrowExpression(this.startNodeAt(s,e),t,!0,n)};T.parseSubscript=function(s,e,t,n,i,r,a){var o=this.options.ecmaVersion>=11,c=o&&this.eat(l.questionDot);n&&c&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var u=this.eat(l.bracketL);if(u||c&&this.type!==l.parenL&&this.type!==l.backQuote||this.eat(l.dot)){var p=this.startNodeAt(e,t);p.object=s,u?(p.property=this.parseExpression(),this.expect(l.bracketR)):this.type===l.privateId&&s.type!=="Super"?p.property=this.parsePrivateIdent():p.property=this.parseIdent(this.options.allowReserved!=="never"),p.computed=!!u,o&&(p.optional=c),s=this.finishNode(p,"MemberExpression")}else if(!n&&this.eat(l.parenL)){var h=new Re,f=this.yieldPos,g=this.awaitPos,d=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var x=this.parseExprList(l.parenR,this.options.ecmaVersion>=8,!1,h);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=f,this.awaitPos=g,this.awaitIdentPos=d,this.parseSubscriptAsyncArrow(e,t,x,a);this.checkExpressionErrors(h,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=g||this.awaitPos,this.awaitIdentPos=d||this.awaitIdentPos;var b=this.startNodeAt(e,t);b.callee=s,b.arguments=x,o&&(b.optional=c),s=this.finishNode(b,"CallExpression")}else if(this.type===l.backQuote){(c||r)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var C=this.startNodeAt(e,t);C.tag=s,C.quasi=this.parseTemplate({isTagged:!0}),s=this.finishNode(C,"TaggedTemplateExpression")}return s};T.parseExprAtom=function(s,e,t){this.type===l.slash&&this.readRegexp();var n,i=this.potentialArrowAt===this.start;switch(this.type){case l._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),n=this.startNode(),this.next(),this.type===l.parenL&&!this.allowDirectSuper&&this.raise(n.start,"super() call outside constructor of a subclass"),this.type!==l.dot&&this.type!==l.bracketL&&this.type!==l.parenL&&this.unexpected(),this.finishNode(n,"Super");case l._this:return n=this.startNode(),this.next(),this.finishNode(n,"ThisExpression");case l.name:var r=this.start,a=this.startLoc,o=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&c.name==="async"&&!this.canInsertSemicolon()&&this.eat(l._function))return this.overrideContext(I.f_expr),this.parseFunction(this.startNodeAt(r,a),0,!1,!0,e);if(i&&!this.canInsertSemicolon()){if(this.eat(l.arrow))return this.parseArrowExpression(this.startNodeAt(r,a),[c],!1,e);if(this.options.ecmaVersion>=8&&c.name==="async"&&this.type===l.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(l.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(r,a),[c],!0,e)}return c;case l.regexp:var u=this.value;return n=this.parseLiteral(u.value),n.regex={pattern:u.pattern,flags:u.flags},n;case l.num:case l.string:return this.parseLiteral(this.value);case l._null:case l._true:case l._false:return n=this.startNode(),n.value=this.type===l._null?null:this.type===l._true,n.raw=this.type.keyword,this.next(),this.finishNode(n,"Literal");case l.parenL:var p=this.start,h=this.parseParenAndDistinguishExpression(i,e);return s&&(s.parenthesizedAssign<0&&!this.isSimpleAssignTarget(h)&&(s.parenthesizedAssign=p),s.parenthesizedBind<0&&(s.parenthesizedBind=p)),h;case l.bracketL:return n=this.startNode(),this.next(),n.elements=this.parseExprList(l.bracketR,!0,!0,s),this.finishNode(n,"ArrayExpression");case l.braceL:return this.overrideContext(I.b_expr),this.parseObj(!1,s);case l._function:return n=this.startNode(),this.next(),this.parseFunction(n,0);case l._class:return this.parseClass(this.startNode(),!1);case l._new:return this.parseNew();case l.backQuote:return this.parseTemplate();case l._import:return this.options.ecmaVersion>=11?this.parseExprImport(t):this.unexpected();default:return this.parseExprAtomDefault()}};T.parseExprAtomDefault=function(){this.unexpected()};T.parseExprImport=function(s){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===l.parenL&&!s)return this.parseDynamicImport(e);if(this.type===l.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);return t.name="import",e.meta=this.finishNode(t,"Identifier"),this.parseImportMeta(e)}else this.unexpected()};T.parseDynamicImport=function(s){if(this.next(),s.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(l.parenR)?s.options=null:(this.expect(l.comma),this.afterTrailingComma(l.parenR)?s.options=null:(s.options=this.parseMaybeAssign(),this.eat(l.parenR)||(this.expect(l.comma),this.afterTrailingComma(l.parenR)||this.unexpected())));else if(!this.eat(l.parenR)){var e=this.start;this.eat(l.comma)&&this.eat(l.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(s,"ImportExpression")};T.parseImportMeta=function(s){this.next();var e=this.containsEsc;return s.property=this.parseIdent(!0),s.property.name!=="meta"&&this.raiseRecoverable(s.property.start,"The only valid meta property for import is 'import.meta'"),e&&this.raiseRecoverable(s.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(s.start,"Cannot use 'import.meta' outside a module"),this.finishNode(s,"MetaProperty")};T.parseLiteral=function(s){var e=this.startNode();return e.value=s,e.raw=this.input.slice(this.start,this.end),e.raw.charCodeAt(e.raw.length-1)===110&&(e.bigint=e.value!=null?e.value.toString():e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};T.parseParenExpression=function(){this.expect(l.parenL);var s=this.parseExpression();return this.expect(l.parenR),s};T.shouldParseArrow=function(s){return!this.canInsertSemicolon()};T.parseParenAndDistinguishExpression=function(s,e){var t=this.start,n=this.startLoc,i,r=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a=this.start,o=this.startLoc,c=[],u=!0,p=!1,h=new Re,f=this.yieldPos,g=this.awaitPos,d;for(this.yieldPos=0,this.awaitPos=0;this.type!==l.parenR;)if(u?u=!1:this.expect(l.comma),r&&this.afterTrailingComma(l.parenR,!0)){p=!0;break}else if(this.type===l.ellipsis){d=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===l.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else c.push(this.parseMaybeAssign(!1,h,this.parseParenItem));var x=this.lastTokEnd,b=this.lastTokEndLoc;if(this.expect(l.parenR),s&&this.shouldParseArrow(c)&&this.eat(l.arrow))return this.checkPatternErrors(h,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=g,this.parseParenArrowList(t,n,c,e);(!c.length||p)&&this.unexpected(this.lastTokStart),d&&this.unexpected(d),this.checkExpressionErrors(h,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=g||this.awaitPos,c.length>1?(i=this.startNodeAt(a,o),i.expressions=c,this.finishNodeAt(i,"SequenceExpression",x,b)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var C=this.startNodeAt(t,n);return C.expression=i,this.finishNode(C,"ParenthesizedExpression")}else return i};T.parseParenItem=function(s){return s};T.parseParenArrowList=function(s,e,t,n){return this.parseArrowExpression(this.startNodeAt(s,e),t,!1,n)};var cs=[];T.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var s=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===l.dot){var e=this.startNodeAt(s.start,s.loc&&s.loc.start);e.name="new",s.meta=this.finishNode(e,"Identifier"),this.next();var t=this.containsEsc;return s.property=this.parseIdent(!0),s.property.name!=="target"&&this.raiseRecoverable(s.property.start,"The only valid meta property for new is 'new.target'"),t&&this.raiseRecoverable(s.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(s.start,"'new.target' can only be used in functions and class static block"),this.finishNode(s,"MetaProperty")}var n=this.start,i=this.startLoc;return s.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),n,i,!0,!1),this.eat(l.parenL)?s.arguments=this.parseExprList(l.parenR,this.options.ecmaVersion>=8,!1):s.arguments=cs,this.finishNode(s,"NewExpression")};T.parseTemplateElement=function(s){var e=s.isTagged,t=this.startNode();return this.type===l.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),t.value={raw:this.value.replace(/\r\n?/g,`
4
- `),cooked:null}):t.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
5
- `),cooked:this.value},this.next(),t.tail=this.type===l.backQuote,this.finishNode(t,"TemplateElement")};T.parseTemplate=function(s){s===void 0&&(s={});var e=s.isTagged;e===void 0&&(e=!1);var t=this.startNode();this.next(),t.expressions=[];var n=this.parseTemplateElement({isTagged:e});for(t.quasis=[n];!n.tail;)this.type===l.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(l.dollarBraceL),t.expressions.push(this.parseExpression()),this.expect(l.braceR),t.quasis.push(n=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(t,"TemplateLiteral")};T.isAsyncProp=function(s){return!s.computed&&s.key.type==="Identifier"&&s.key.name==="async"&&(this.type===l.name||this.type===l.num||this.type===l.string||this.type===l.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===l.star)&&!H.test(this.input.slice(this.lastTokEnd,this.start))};T.parseObj=function(s,e){var t=this.startNode(),n=!0,i={};for(t.properties=[],this.next();!this.eat(l.braceR);){if(n)n=!1;else if(this.expect(l.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(l.braceR))break;var r=this.parseProperty(s,e);s||this.checkPropClash(r,i,e),t.properties.push(r)}return this.finishNode(t,s?"ObjectPattern":"ObjectExpression")};T.parseProperty=function(s,e){var t=this.startNode(),n,i,r,a;if(this.options.ecmaVersion>=9&&this.eat(l.ellipsis))return s?(t.argument=this.parseIdent(!1),this.type===l.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(t,"RestElement")):(t.argument=this.parseMaybeAssign(!1,e),this.type===l.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(t,"SpreadElement"));this.options.ecmaVersion>=6&&(t.method=!1,t.shorthand=!1,(s||e)&&(r=this.start,a=this.startLoc),s||(n=this.eat(l.star)));var o=this.containsEsc;return this.parsePropertyName(t),!s&&!o&&this.options.ecmaVersion>=8&&!n&&this.isAsyncProp(t)?(i=!0,n=this.options.ecmaVersion>=9&&this.eat(l.star),this.parsePropertyName(t)):i=!1,this.parsePropertyValue(t,s,n,i,r,a,e,o),this.finishNode(t,"Property")};T.parseGetterSetter=function(s){var e=s.key.name;this.parsePropertyName(s),s.value=this.parseMethod(!1),s.kind=e;var t=s.kind==="get"?0:1;if(s.value.params.length!==t){var n=s.value.start;s.kind==="get"?this.raiseRecoverable(n,"getter should have no params"):this.raiseRecoverable(n,"setter should have exactly one param")}else s.kind==="set"&&s.value.params[0].type==="RestElement"&&this.raiseRecoverable(s.value.params[0].start,"Setter cannot use rest params")};T.parsePropertyValue=function(s,e,t,n,i,r,a,o){(t||n)&&this.type===l.colon&&this.unexpected(),this.eat(l.colon)?(s.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),s.kind="init"):this.options.ecmaVersion>=6&&this.type===l.parenL?(e&&this.unexpected(),s.method=!0,s.value=this.parseMethod(t,n),s.kind="init"):!e&&!o&&this.options.ecmaVersion>=5&&!s.computed&&s.key.type==="Identifier"&&(s.key.name==="get"||s.key.name==="set")&&this.type!==l.comma&&this.type!==l.braceR&&this.type!==l.eq?((t||n)&&this.unexpected(),this.parseGetterSetter(s)):this.options.ecmaVersion>=6&&!s.computed&&s.key.type==="Identifier"?((t||n)&&this.unexpected(),this.checkUnreserved(s.key),s.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=i),e?s.value=this.parseMaybeDefault(i,r,this.copyNode(s.key)):this.type===l.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),s.value=this.parseMaybeDefault(i,r,this.copyNode(s.key))):s.value=this.copyNode(s.key),s.kind="init",s.shorthand=!0):this.unexpected()};T.parsePropertyName=function(s){if(this.options.ecmaVersion>=6){if(this.eat(l.bracketL))return s.computed=!0,s.key=this.parseMaybeAssign(),this.expect(l.bracketR),s.key;s.computed=!1}return s.key=this.type===l.num||this.type===l.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};T.initFunction=function(s){s.id=null,this.options.ecmaVersion>=6&&(s.generator=s.expression=!1),this.options.ecmaVersion>=8&&(s.async=!1)};T.parseMethod=function(s,e,t){var n=this.startNode(),i=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(n),this.options.ecmaVersion>=6&&(n.generator=s),this.options.ecmaVersion>=8&&(n.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ge(e,n.generator)|Ie|(t?gt:0)),this.expect(l.parenL),n.params=this.parseBindingList(l.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(n,!1,!0,!1),this.yieldPos=i,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(n,"FunctionExpression")};T.parseArrowExpression=function(s,e,t,n){var i=this.yieldPos,r=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(Ge(t,!1)|Ke),this.initFunction(s),this.options.ecmaVersion>=8&&(s.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,s.params=this.toAssignableList(e,!0),this.parseFunctionBody(s,!0,!1,n),this.yieldPos=i,this.awaitPos=r,this.awaitIdentPos=a,this.finishNode(s,"ArrowFunctionExpression")};T.parseFunctionBody=function(s,e,t,n){var i=e&&this.type!==l.braceL,r=this.strict,a=!1;if(i)s.body=this.parseMaybeAssign(n),s.expression=!0,this.checkParams(s,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(s.params);(!r||o)&&(a=this.strictDirective(this.end),a&&o&&this.raiseRecoverable(s.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var c=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(s,!r&&!a&&!e&&!t&&this.isSimpleParamList(s.params)),this.strict&&s.id&&this.checkLValSimple(s.id,bt),s.body=this.parseBlock(!1,void 0,a&&!r),s.expression=!1,this.adaptDirectivePrologue(s.body.body),this.labels=c}this.exitScope()};T.isSimpleParamList=function(s){for(var e=0,t=s;e<t.length;e+=1){var n=t[e];if(n.type!=="Identifier")return!1}return!0};T.checkParams=function(s,e){for(var t=Object.create(null),n=0,i=s.params;n<i.length;n+=1){var r=i[n];this.checkLValInnerPattern(r,Qe,e?null:t)}};T.parseExprList=function(s,e,t,n){for(var i=[],r=!0;!this.eat(s);){if(r)r=!1;else if(this.expect(l.comma),e&&this.afterTrailingComma(s))break;var a=void 0;t&&this.type===l.comma?a=null:this.type===l.ellipsis?(a=this.parseSpread(n),n&&this.type===l.comma&&n.trailingComma<0&&(n.trailingComma=this.start)):a=this.parseMaybeAssign(!1,n),i.push(a)}return i};T.checkUnreserved=function(s){var e=s.start,t=s.end,n=s.name;if(this.inGenerator&&n==="yield"&&this.raiseRecoverable(e,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&n==="await"&&this.raiseRecoverable(e,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&Oe)&&n==="arguments"&&this.raiseRecoverable(e,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(n==="arguments"||n==="await")&&this.raise(e,"Cannot use "+n+" in class static initialization block"),this.keywords.test(n)&&this.raise(e,"Unexpected keyword '"+n+"'"),!(this.options.ecmaVersion<6&&this.input.slice(e,t).indexOf("\\")!==-1)){var i=this.strict?this.reservedWordsStrict:this.reservedWords;i.test(n)&&(!this.inAsync&&n==="await"&&this.raiseRecoverable(e,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(e,"The keyword '"+n+"' is reserved"))}};T.parseIdent=function(s){var e=this.parseIdentNode();return this.next(!!s),this.finishNode(e,"Identifier"),s||(this.checkUnreserved(e),e.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=e.start)),e};T.parseIdentNode=function(){var s=this.startNode();return this.type===l.name?s.name=this.value:this.type.keyword?(s.name=this.type.keyword,(s.name==="class"||s.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=l.name):this.unexpected(),s};T.parsePrivateIdent=function(){var s=this.startNode();return this.type===l.privateId?s.name=this.value:this.unexpected(),this.next(),this.finishNode(s,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(s.start,"Private field '#"+s.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(s)),s};T.parseYield=function(s){this.yieldPos||(this.yieldPos=this.start);var e=this.startNode();return this.next(),this.type===l.semi||this.canInsertSemicolon()||this.type!==l.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(l.star),e.argument=this.parseMaybeAssign(s)),this.finishNode(e,"YieldExpression")};T.parseAwait=function(s){this.awaitPos||(this.awaitPos=this.start);var e=this.startNode();return this.next(),e.argument=this.parseMaybeUnary(null,!0,!1,s),this.finishNode(e,"AwaitExpression")};var ke=L.prototype;ke.raise=function(s,e){var t=ft(this.input,s);e+=" ("+t.line+":"+t.column+")",this.sourceFile&&(e+=" in "+this.sourceFile);var n=new SyntaxError(e);throw n.pos=s,n.loc=t,n.raisedAt=this.pos,n};ke.raiseRecoverable=ke.raise;ke.curPosition=function(){if(this.options.locations)return new ve(this.curLine,this.pos-this.lineStart)};var oe=L.prototype,us=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};oe.enterScope=function(s){this.scopeStack.push(new us(s))};oe.exitScope=function(){this.scopeStack.pop()};oe.treatFunctionsAsVarInScope=function(s){return s.flags&Ee||!this.inModule&&s.flags&Se};oe.declareName=function(s,e,t){var n=!1;if(e===ie){var i=this.currentScope();n=i.lexical.indexOf(s)>-1||i.functions.indexOf(s)>-1||i.var.indexOf(s)>-1,i.lexical.push(s),this.inModule&&i.flags&Se&&delete this.undefinedExports[s]}else if(e===Et){var r=this.currentScope();r.lexical.push(s)}else if(e===xt){var a=this.currentScope();this.treatFunctionsAsVar?n=a.lexical.indexOf(s)>-1:n=a.lexical.indexOf(s)>-1||a.var.indexOf(s)>-1,a.functions.push(s)}else for(var o=this.scopeStack.length-1;o>=0;--o){var c=this.scopeStack[o];if(c.lexical.indexOf(s)>-1&&!(c.flags&mt&&c.lexical[0]===s)||!this.treatFunctionsAsVarInScope(c)&&c.functions.indexOf(s)>-1){n=!0;break}if(c.var.push(s),this.inModule&&c.flags&Se&&delete this.undefinedExports[s],c.flags&Oe)break}n&&this.raiseRecoverable(t,"Identifier '"+s+"' has already been declared")};oe.checkLocalExport=function(s){this.scopeStack[0].lexical.indexOf(s.name)===-1&&this.scopeStack[0].var.indexOf(s.name)===-1&&(this.undefinedExports[s.name]=s)};oe.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};oe.currentVarScope=function(){for(var s=this.scopeStack.length-1;;s--){var e=this.scopeStack[s];if(e.flags&(Oe|Pe|le))return e}};oe.currentThisScope=function(){for(var s=this.scopeStack.length-1;;s--){var e=this.scopeStack[s];if(e.flags&(Oe|Pe|le)&&!(e.flags&Ke))return e}};var Le=function(e,t,n){this.type="",this.start=t,this.end=0,e.options.locations&&(this.loc=new Me(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Ae=L.prototype;Ae.startNode=function(){return new Le(this,this.start,this.startLoc)};Ae.startNodeAt=function(s,e){return new Le(this,s,e)};function vt(s,e,t,n){return s.type=e,s.end=t,this.options.locations&&(s.loc.end=n),this.options.ranges&&(s.range[1]=t),s}Ae.finishNode=function(s,e){return vt.call(this,s,e,this.lastTokEnd,this.lastTokEndLoc)};Ae.finishNodeAt=function(s,e,t,n){return vt.call(this,s,e,t,n)};Ae.copyNode=function(s){var e=new Le(this,s.start,this.startLoc);for(var t in s)e[t]=s[t];return e};var ls="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",St="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",Tt=St+" Extended_Pictographic",Pt=Tt,At=Pt+" EBase EComp EMod EPres ExtPict",wt=At,ps=wt,hs={9:St,10:Tt,11:Pt,12:At,13:wt,14:ps},fs="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",ds={9:"",10:"",11:"",12:"",13:"",14:fs},it="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",_t="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",kt=_t+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Nt=kt+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Mt=Nt+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",It=Mt+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",ms=It+" "+ls,gs={9:_t,10:kt,11:Nt,12:Mt,13:It,14:ms},Ot={};function xs(s){var e=Ot[s]={binary:re(hs[s]+" "+it),binaryOfStrings:re(ds[s]),nonBinary:{General_Category:re(it),Script:re(gs[s])}};e.nonBinary.Script_Extensions=e.nonBinary.Script,e.nonBinary.gc=e.nonBinary.General_Category,e.nonBinary.sc=e.nonBinary.Script,e.nonBinary.scx=e.nonBinary.Script_Extensions}for(var Be=0,rt=[9,10,11,12,13,14];Be<rt.length;Be+=1){var Es=rt[Be];xs(Es)}var y=L.prototype,Ne=function(e,t){this.parent=e,this.base=t||this};Ne.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};Ne.prototype.sibling=function(){return new Ne(this.parent,this.base)};var ee=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=Ot[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};ee.prototype.reset=function(e,t,n){var i=n.indexOf("v")!==-1,r=n.indexOf("u")!==-1;this.start=e|0,this.source=t+"",this.flags=n,i&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=r&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=r&&this.parser.options.ecmaVersion>=9)};ee.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)};ee.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,i=n.length;if(e>=i)return-1;var r=n.charCodeAt(e);if(!(t||this.switchU)||r<=55295||r>=57344||e+1>=i)return r;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(r<<10)+a-56613888:r};ee.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,i=n.length;if(e>=i)return i;var r=n.charCodeAt(e),a;return!(t||this.switchU)||r<=55295||r>=57344||e+1>=i||(a=n.charCodeAt(e+1))<56320||a>57343?e+1:e+2};ee.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)};ee.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)};ee.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)};ee.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e?(this.advance(t),!0):!1};ee.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,i=0,r=e;i<r.length;i+=1){var a=r[i],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0};y.validateRegExpFlags=function(s){for(var e=s.validFlags,t=s.flags,n=!1,i=!1,r=0;r<t.length;r++){var a=t.charAt(r);e.indexOf(a)===-1&&this.raise(s.start,"Invalid regular expression flag"),t.indexOf(a,r+1)>-1&&this.raise(s.start,"Duplicate regular expression flag"),a==="u"&&(n=!0),a==="v"&&(i=!0)}this.options.ecmaVersion>=15&&n&&i&&this.raise(s.start,"Invalid regular expression flag")};function bs(s){for(var e in s)return!0;return!1}y.validateRegExpPattern=function(s){this.regexp_pattern(s),!s.switchN&&this.options.ecmaVersion>=9&&bs(s.groupNames)&&(s.switchN=!0,this.regexp_pattern(s))};y.regexp_pattern=function(s){s.pos=0,s.lastIntValue=0,s.lastStringValue="",s.lastAssertionIsQuantifiable=!1,s.numCapturingParens=0,s.maxBackReference=0,s.groupNames=Object.create(null),s.backReferenceNames.length=0,s.branchID=null,this.regexp_disjunction(s),s.pos!==s.source.length&&(s.eat(41)&&s.raise("Unmatched ')'"),(s.eat(93)||s.eat(125))&&s.raise("Lone quantifier brackets")),s.maxBackReference>s.numCapturingParens&&s.raise("Invalid escape");for(var e=0,t=s.backReferenceNames;e<t.length;e+=1){var n=t[e];s.groupNames[n]||s.raise("Invalid named capture referenced")}};y.regexp_disjunction=function(s){var e=this.options.ecmaVersion>=16;for(e&&(s.branchID=new Ne(s.branchID,null)),this.regexp_alternative(s);s.eat(124);)e&&(s.branchID=s.branchID.sibling()),this.regexp_alternative(s);e&&(s.branchID=s.branchID.parent),this.regexp_eatQuantifier(s,!0)&&s.raise("Nothing to repeat"),s.eat(123)&&s.raise("Lone quantifier brackets")};y.regexp_alternative=function(s){for(;s.pos<s.source.length&&this.regexp_eatTerm(s););};y.regexp_eatTerm=function(s){return this.regexp_eatAssertion(s)?(s.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(s)&&s.switchU&&s.raise("Invalid quantifier"),!0):(s.switchU?this.regexp_eatAtom(s):this.regexp_eatExtendedAtom(s))?(this.regexp_eatQuantifier(s),!0):!1};y.regexp_eatAssertion=function(s){var e=s.pos;if(s.lastAssertionIsQuantifiable=!1,s.eat(94)||s.eat(36))return!0;if(s.eat(92)){if(s.eat(66)||s.eat(98))return!0;s.pos=e}if(s.eat(40)&&s.eat(63)){var t=!1;if(this.options.ecmaVersion>=9&&(t=s.eat(60)),s.eat(61)||s.eat(33))return this.regexp_disjunction(s),s.eat(41)||s.raise("Unterminated group"),s.lastAssertionIsQuantifiable=!t,!0}return s.pos=e,!1};y.regexp_eatQuantifier=function(s,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(s,e)?(s.eat(63),!0):!1};y.regexp_eatQuantifierPrefix=function(s,e){return s.eat(42)||s.eat(43)||s.eat(63)||this.regexp_eatBracedQuantifier(s,e)};y.regexp_eatBracedQuantifier=function(s,e){var t=s.pos;if(s.eat(123)){var n=0,i=-1;if(this.regexp_eatDecimalDigits(s)&&(n=s.lastIntValue,s.eat(44)&&this.regexp_eatDecimalDigits(s)&&(i=s.lastIntValue),s.eat(125)))return i!==-1&&i<n&&!e&&s.raise("numbers out of order in {} quantifier"),!0;s.switchU&&!e&&s.raise("Incomplete quantifier"),s.pos=t}return!1};y.regexp_eatAtom=function(s){return this.regexp_eatPatternCharacters(s)||s.eat(46)||this.regexp_eatReverseSolidusAtomEscape(s)||this.regexp_eatCharacterClass(s)||this.regexp_eatUncapturingGroup(s)||this.regexp_eatCapturingGroup(s)};y.regexp_eatReverseSolidusAtomEscape=function(s){var e=s.pos;if(s.eat(92)){if(this.regexp_eatAtomEscape(s))return!0;s.pos=e}return!1};y.regexp_eatUncapturingGroup=function(s){var e=s.pos;if(s.eat(40)){if(s.eat(63)){if(this.options.ecmaVersion>=16){var t=this.regexp_eatModifiers(s),n=s.eat(45);if(t||n){for(var i=0;i<t.length;i++){var r=t.charAt(i);t.indexOf(r,i+1)>-1&&s.raise("Duplicate regular expression modifiers")}if(n){var a=this.regexp_eatModifiers(s);!t&&!a&&s.current()===58&&s.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var c=a.charAt(o);(a.indexOf(c,o+1)>-1||t.indexOf(c)>-1)&&s.raise("Duplicate regular expression modifiers")}}}}if(s.eat(58)){if(this.regexp_disjunction(s),s.eat(41))return!0;s.raise("Unterminated group")}}s.pos=e}return!1};y.regexp_eatCapturingGroup=function(s){if(s.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(s):s.current()===63&&s.raise("Invalid group"),this.regexp_disjunction(s),s.eat(41))return s.numCapturingParens+=1,!0;s.raise("Unterminated group")}return!1};y.regexp_eatModifiers=function(s){for(var e="",t=0;(t=s.current())!==-1&&Cs(t);)e+=se(t),s.advance();return e};function Cs(s){return s===105||s===109||s===115}y.regexp_eatExtendedAtom=function(s){return s.eat(46)||this.regexp_eatReverseSolidusAtomEscape(s)||this.regexp_eatCharacterClass(s)||this.regexp_eatUncapturingGroup(s)||this.regexp_eatCapturingGroup(s)||this.regexp_eatInvalidBracedQuantifier(s)||this.regexp_eatExtendedPatternCharacter(s)};y.regexp_eatInvalidBracedQuantifier=function(s){return this.regexp_eatBracedQuantifier(s,!0)&&s.raise("Nothing to repeat"),!1};y.regexp_eatSyntaxCharacter=function(s){var e=s.current();return Rt(e)?(s.lastIntValue=e,s.advance(),!0):!1};function Rt(s){return s===36||s>=40&&s<=43||s===46||s===63||s>=91&&s<=94||s>=123&&s<=125}y.regexp_eatPatternCharacters=function(s){for(var e=s.pos,t=0;(t=s.current())!==-1&&!Rt(t);)s.advance();return s.pos!==e};y.regexp_eatExtendedPatternCharacter=function(s){var e=s.current();return e!==-1&&e!==36&&!(e>=40&&e<=43)&&e!==46&&e!==63&&e!==91&&e!==94&&e!==124?(s.advance(),!0):!1};y.regexp_groupSpecifier=function(s){if(s.eat(63)){this.regexp_eatGroupName(s)||s.raise("Invalid group");var e=this.options.ecmaVersion>=16,t=s.groupNames[s.lastStringValue];if(t)if(e)for(var n=0,i=t;n<i.length;n+=1){var r=i[n];r.separatedFrom(s.branchID)||s.raise("Duplicate capture group name")}else s.raise("Duplicate capture group name");e?(t||(s.groupNames[s.lastStringValue]=[])).push(s.branchID):s.groupNames[s.lastStringValue]=!0}};y.regexp_eatGroupName=function(s){if(s.lastStringValue="",s.eat(60)){if(this.regexp_eatRegExpIdentifierName(s)&&s.eat(62))return!0;s.raise("Invalid capture group name")}return!1};y.regexp_eatRegExpIdentifierName=function(s){if(s.lastStringValue="",this.regexp_eatRegExpIdentifierStart(s)){for(s.lastStringValue+=se(s.lastIntValue);this.regexp_eatRegExpIdentifierPart(s);)s.lastStringValue+=se(s.lastIntValue);return!0}return!1};y.regexp_eatRegExpIdentifierStart=function(s){var e=s.pos,t=this.options.ecmaVersion>=11,n=s.current(t);return s.advance(t),n===92&&this.regexp_eatRegExpUnicodeEscapeSequence(s,t)&&(n=s.lastIntValue),ys(n)?(s.lastIntValue=n,!0):(s.pos=e,!1)};function ys(s){return Y(s,!0)||s===36||s===95}y.regexp_eatRegExpIdentifierPart=function(s){var e=s.pos,t=this.options.ecmaVersion>=11,n=s.current(t);return s.advance(t),n===92&&this.regexp_eatRegExpUnicodeEscapeSequence(s,t)&&(n=s.lastIntValue),vs(n)?(s.lastIntValue=n,!0):(s.pos=e,!1)};function vs(s){return ae(s,!0)||s===36||s===95||s===8204||s===8205}y.regexp_eatAtomEscape=function(s){return this.regexp_eatBackReference(s)||this.regexp_eatCharacterClassEscape(s)||this.regexp_eatCharacterEscape(s)||s.switchN&&this.regexp_eatKGroupName(s)?!0:(s.switchU&&(s.current()===99&&s.raise("Invalid unicode escape"),s.raise("Invalid escape")),!1)};y.regexp_eatBackReference=function(s){var e=s.pos;if(this.regexp_eatDecimalEscape(s)){var t=s.lastIntValue;if(s.switchU)return t>s.maxBackReference&&(s.maxBackReference=t),!0;if(t<=s.numCapturingParens)return!0;s.pos=e}return!1};y.regexp_eatKGroupName=function(s){if(s.eat(107)){if(this.regexp_eatGroupName(s))return s.backReferenceNames.push(s.lastStringValue),!0;s.raise("Invalid named reference")}return!1};y.regexp_eatCharacterEscape=function(s){return this.regexp_eatControlEscape(s)||this.regexp_eatCControlLetter(s)||this.regexp_eatZero(s)||this.regexp_eatHexEscapeSequence(s)||this.regexp_eatRegExpUnicodeEscapeSequence(s,!1)||!s.switchU&&this.regexp_eatLegacyOctalEscapeSequence(s)||this.regexp_eatIdentityEscape(s)};y.regexp_eatCControlLetter=function(s){var e=s.pos;if(s.eat(99)){if(this.regexp_eatControlLetter(s))return!0;s.pos=e}return!1};y.regexp_eatZero=function(s){return s.current()===48&&!Ve(s.lookahead())?(s.lastIntValue=0,s.advance(),!0):!1};y.regexp_eatControlEscape=function(s){var e=s.current();return e===116?(s.lastIntValue=9,s.advance(),!0):e===110?(s.lastIntValue=10,s.advance(),!0):e===118?(s.lastIntValue=11,s.advance(),!0):e===102?(s.lastIntValue=12,s.advance(),!0):e===114?(s.lastIntValue=13,s.advance(),!0):!1};y.regexp_eatControlLetter=function(s){var e=s.current();return Lt(e)?(s.lastIntValue=e%32,s.advance(),!0):!1};function Lt(s){return s>=65&&s<=90||s>=97&&s<=122}y.regexp_eatRegExpUnicodeEscapeSequence=function(s,e){e===void 0&&(e=!1);var t=s.pos,n=e||s.switchU;if(s.eat(117)){if(this.regexp_eatFixedHexDigits(s,4)){var i=s.lastIntValue;if(n&&i>=55296&&i<=56319){var r=s.pos;if(s.eat(92)&&s.eat(117)&&this.regexp_eatFixedHexDigits(s,4)){var a=s.lastIntValue;if(a>=56320&&a<=57343)return s.lastIntValue=(i-55296)*1024+(a-56320)+65536,!0}s.pos=r,s.lastIntValue=i}return!0}if(n&&s.eat(123)&&this.regexp_eatHexDigits(s)&&s.eat(125)&&Ss(s.lastIntValue))return!0;n&&s.raise("Invalid unicode escape"),s.pos=t}return!1};function Ss(s){return s>=0&&s<=1114111}y.regexp_eatIdentityEscape=function(s){if(s.switchU)return this.regexp_eatSyntaxCharacter(s)?!0:s.eat(47)?(s.lastIntValue=47,!0):!1;var e=s.current();return e!==99&&(!s.switchN||e!==107)?(s.lastIntValue=e,s.advance(),!0):!1};y.regexp_eatDecimalEscape=function(s){s.lastIntValue=0;var e=s.current();if(e>=49&&e<=57){do s.lastIntValue=10*s.lastIntValue+(e-48),s.advance();while((e=s.current())>=48&&e<=57);return!0}return!1};var Vt=0,ne=1,X=2;y.regexp_eatCharacterClassEscape=function(s){var e=s.current();if(Ts(e))return s.lastIntValue=-1,s.advance(),ne;var t=!1;if(s.switchU&&this.options.ecmaVersion>=9&&((t=e===80)||e===112)){s.lastIntValue=-1,s.advance();var n;if(s.eat(123)&&(n=this.regexp_eatUnicodePropertyValueExpression(s))&&s.eat(125))return t&&n===X&&s.raise("Invalid property name"),n;s.raise("Invalid property name")}return Vt};function Ts(s){return s===100||s===68||s===115||s===83||s===119||s===87}y.regexp_eatUnicodePropertyValueExpression=function(s){var e=s.pos;if(this.regexp_eatUnicodePropertyName(s)&&s.eat(61)){var t=s.lastStringValue;if(this.regexp_eatUnicodePropertyValue(s)){var n=s.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(s,t,n),ne}}if(s.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(s)){var i=s.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(s,i)}return Vt};y.regexp_validateUnicodePropertyNameAndValue=function(s,e,t){xe(s.unicodeProperties.nonBinary,e)||s.raise("Invalid property name"),s.unicodeProperties.nonBinary[e].test(t)||s.raise("Invalid property value")};y.regexp_validateUnicodePropertyNameOrValue=function(s,e){if(s.unicodeProperties.binary.test(e))return ne;if(s.switchV&&s.unicodeProperties.binaryOfStrings.test(e))return X;s.raise("Invalid property name")};y.regexp_eatUnicodePropertyName=function(s){var e=0;for(s.lastStringValue="";Ft(e=s.current());)s.lastStringValue+=se(e),s.advance();return s.lastStringValue!==""};function Ft(s){return Lt(s)||s===95}y.regexp_eatUnicodePropertyValue=function(s){var e=0;for(s.lastStringValue="";Ps(e=s.current());)s.lastStringValue+=se(e),s.advance();return s.lastStringValue!==""};function Ps(s){return Ft(s)||Ve(s)}y.regexp_eatLoneUnicodePropertyNameOrValue=function(s){return this.regexp_eatUnicodePropertyValue(s)};y.regexp_eatCharacterClass=function(s){if(s.eat(91)){var e=s.eat(94),t=this.regexp_classContents(s);return s.eat(93)||s.raise("Unterminated character class"),e&&t===X&&s.raise("Negated character class may contain strings"),!0}return!1};y.regexp_classContents=function(s){return s.current()===93?ne:s.switchV?this.regexp_classSetExpression(s):(this.regexp_nonEmptyClassRanges(s),ne)};y.regexp_nonEmptyClassRanges=function(s){for(;this.regexp_eatClassAtom(s);){var e=s.lastIntValue;if(s.eat(45)&&this.regexp_eatClassAtom(s)){var t=s.lastIntValue;s.switchU&&(e===-1||t===-1)&&s.raise("Invalid character class"),e!==-1&&t!==-1&&e>t&&s.raise("Range out of order in character class")}}};y.regexp_eatClassAtom=function(s){var e=s.pos;if(s.eat(92)){if(this.regexp_eatClassEscape(s))return!0;if(s.switchU){var t=s.current();(t===99||$t(t))&&s.raise("Invalid class escape"),s.raise("Invalid escape")}s.pos=e}var n=s.current();return n!==93?(s.lastIntValue=n,s.advance(),!0):!1};y.regexp_eatClassEscape=function(s){var e=s.pos;if(s.eat(98))return s.lastIntValue=8,!0;if(s.switchU&&s.eat(45))return s.lastIntValue=45,!0;if(!s.switchU&&s.eat(99)){if(this.regexp_eatClassControlLetter(s))return!0;s.pos=e}return this.regexp_eatCharacterClassEscape(s)||this.regexp_eatCharacterEscape(s)};y.regexp_classSetExpression=function(s){var e=ne,t;if(!this.regexp_eatClassSetRange(s))if(t=this.regexp_eatClassSetOperand(s)){t===X&&(e=X);for(var n=s.pos;s.eatChars([38,38]);){if(s.current()!==38&&(t=this.regexp_eatClassSetOperand(s))){t!==X&&(e=ne);continue}s.raise("Invalid character in character class")}if(n!==s.pos)return e;for(;s.eatChars([45,45]);)this.regexp_eatClassSetOperand(s)||s.raise("Invalid character in character class");if(n!==s.pos)return e}else s.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(s)){if(t=this.regexp_eatClassSetOperand(s),!t)return e;t===X&&(e=X)}};y.regexp_eatClassSetRange=function(s){var e=s.pos;if(this.regexp_eatClassSetCharacter(s)){var t=s.lastIntValue;if(s.eat(45)&&this.regexp_eatClassSetCharacter(s)){var n=s.lastIntValue;return t!==-1&&n!==-1&&t>n&&s.raise("Range out of order in character class"),!0}s.pos=e}return!1};y.regexp_eatClassSetOperand=function(s){return this.regexp_eatClassSetCharacter(s)?ne:this.regexp_eatClassStringDisjunction(s)||this.regexp_eatNestedClass(s)};y.regexp_eatNestedClass=function(s){var e=s.pos;if(s.eat(91)){var t=s.eat(94),n=this.regexp_classContents(s);if(s.eat(93))return t&&n===X&&s.raise("Negated character class may contain strings"),n;s.pos=e}if(s.eat(92)){var i=this.regexp_eatCharacterClassEscape(s);if(i)return i;s.pos=e}return null};y.regexp_eatClassStringDisjunction=function(s){var e=s.pos;if(s.eatChars([92,113])){if(s.eat(123)){var t=this.regexp_classStringDisjunctionContents(s);if(s.eat(125))return t}else s.raise("Invalid escape");s.pos=e}return null};y.regexp_classStringDisjunctionContents=function(s){for(var e=this.regexp_classString(s);s.eat(124);)this.regexp_classString(s)===X&&(e=X);return e};y.regexp_classString=function(s){for(var e=0;this.regexp_eatClassSetCharacter(s);)e++;return e===1?ne:X};y.regexp_eatClassSetCharacter=function(s){var e=s.pos;if(s.eat(92))return this.regexp_eatCharacterEscape(s)||this.regexp_eatClassSetReservedPunctuator(s)?!0:s.eat(98)?(s.lastIntValue=8,!0):(s.pos=e,!1);var t=s.current();return t<0||t===s.lookahead()&&As(t)||ws(t)?!1:(s.advance(),s.lastIntValue=t,!0)};function As(s){return s===33||s>=35&&s<=38||s>=42&&s<=44||s===46||s>=58&&s<=64||s===94||s===96||s===126}function ws(s){return s===40||s===41||s===45||s===47||s>=91&&s<=93||s>=123&&s<=125}y.regexp_eatClassSetReservedPunctuator=function(s){var e=s.current();return _s(e)?(s.lastIntValue=e,s.advance(),!0):!1};function _s(s){return s===33||s===35||s===37||s===38||s===44||s===45||s>=58&&s<=62||s===64||s===96||s===126}y.regexp_eatClassControlLetter=function(s){var e=s.current();return Ve(e)||e===95?(s.lastIntValue=e%32,s.advance(),!0):!1};y.regexp_eatHexEscapeSequence=function(s){var e=s.pos;if(s.eat(120)){if(this.regexp_eatFixedHexDigits(s,2))return!0;s.switchU&&s.raise("Invalid escape"),s.pos=e}return!1};y.regexp_eatDecimalDigits=function(s){var e=s.pos,t=0;for(s.lastIntValue=0;Ve(t=s.current());)s.lastIntValue=10*s.lastIntValue+(t-48),s.advance();return s.pos!==e};function Ve(s){return s>=48&&s<=57}y.regexp_eatHexDigits=function(s){var e=s.pos,t=0;for(s.lastIntValue=0;Dt(t=s.current());)s.lastIntValue=16*s.lastIntValue+Bt(t),s.advance();return s.pos!==e};function Dt(s){return s>=48&&s<=57||s>=65&&s<=70||s>=97&&s<=102}function Bt(s){return s>=65&&s<=70?10+(s-65):s>=97&&s<=102?10+(s-97):s-48}y.regexp_eatLegacyOctalEscapeSequence=function(s){if(this.regexp_eatOctalDigit(s)){var e=s.lastIntValue;if(this.regexp_eatOctalDigit(s)){var t=s.lastIntValue;e<=3&&this.regexp_eatOctalDigit(s)?s.lastIntValue=e*64+t*8+s.lastIntValue:s.lastIntValue=e*8+t}else s.lastIntValue=e;return!0}return!1};y.regexp_eatOctalDigit=function(s){var e=s.current();return $t(e)?(s.lastIntValue=e-48,s.advance(),!0):(s.lastIntValue=0,!1)};function $t(s){return s>=48&&s<=55}y.regexp_eatFixedHexDigits=function(s,e){var t=s.pos;s.lastIntValue=0;for(var n=0;n<e;++n){var i=s.current();if(!Dt(i))return s.pos=t,!1;s.lastIntValue=16*s.lastIntValue+Bt(i),s.advance()}return!0};var Ye=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new Me(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},A=L.prototype;A.next=function(s){!s&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Ye(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 Ye(this)};typeof Symbol<"u"&&(A[Symbol.iterator]=function(){var s=this;return{next:function(){var e=s.getToken();return{done:e.type===l.eof,value:e}}}});A.nextToken=function(){var s=this.curContext();if((!s||!s.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(l.eof);if(s.override)return s.override(this);this.readToken(this.fullCharCodeAtPos())};A.readToken=function(s){return Y(s,this.options.ecmaVersion>=6)||s===92?this.readWord():this.getTokenFromCode(s)};A.fullCharCodeAtPos=function(){var s=this.input.charCodeAt(this.pos);if(s<=55295||s>=56320)return s;var e=this.input.charCodeAt(this.pos+1);return e<=56319||e>=57344?s:(s<<10)+e-56613888};A.skipBlockComment=function(){var s=this.options.onComment&&this.curPosition(),e=this.pos,t=this.input.indexOf("*/",this.pos+=2);if(t===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=t+2,this.options.locations)for(var n=void 0,i=e;(n=lt(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=n;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,t),e,this.pos,s,this.curPosition())};A.skipLineComment=function(s){for(var e=this.pos,t=this.options.onComment&&this.curPosition(),n=this.input.charCodeAt(this.pos+=s);this.pos<this.input.length&&!ge(n);)n=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(e+s,this.pos),e,this.pos,t,this.curPosition())};A.skipSpace=function(){e:for(;this.pos<this.input.length;){var s=this.input.charCodeAt(this.pos);switch(s){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(s>8&&s<14||s>=5760&&pt.test(String.fromCharCode(s)))++this.pos;else break e}}};A.finishToken=function(s,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var t=this.type;this.type=s,this.value=e,this.updateContext(t)};A.readToken_dot=function(){var s=this.input.charCodeAt(this.pos+1);if(s>=48&&s<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&s===46&&e===46?(this.pos+=3,this.finishToken(l.ellipsis)):(++this.pos,this.finishToken(l.dot))};A.readToken_slash=function(){var s=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):s===61?this.finishOp(l.assign,2):this.finishOp(l.slash,1)};A.readToken_mult_modulo_exp=function(s){var e=this.input.charCodeAt(this.pos+1),t=1,n=s===42?l.star:l.modulo;return this.options.ecmaVersion>=7&&s===42&&e===42&&(++t,n=l.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(l.assign,t+1):this.finishOp(n,t)};A.readToken_pipe_amp=function(s){var e=this.input.charCodeAt(this.pos+1);if(e===s){if(this.options.ecmaVersion>=12){var t=this.input.charCodeAt(this.pos+2);if(t===61)return this.finishOp(l.assign,3)}return this.finishOp(s===124?l.logicalOR:l.logicalAND,2)}return e===61?this.finishOp(l.assign,2):this.finishOp(s===124?l.bitwiseOR:l.bitwiseAND,1)};A.readToken_caret=function(){var s=this.input.charCodeAt(this.pos+1);return s===61?this.finishOp(l.assign,2):this.finishOp(l.bitwiseXOR,1)};A.readToken_plus_min=function(s){var e=this.input.charCodeAt(this.pos+1);return e===s?e===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||H.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(l.incDec,2):e===61?this.finishOp(l.assign,2):this.finishOp(l.plusMin,1)};A.readToken_lt_gt=function(s){var e=this.input.charCodeAt(this.pos+1),t=1;return e===s?(t=s===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+t)===61?this.finishOp(l.assign,t+1):this.finishOp(l.bitShift,t)):e===33&&s===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(e===61&&(t=2),this.finishOp(l.relational,t))};A.readToken_eq_excl=function(s){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(l.equality,this.input.charCodeAt(this.pos+2)===61?3:2):s===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(l.arrow)):this.finishOp(s===61?l.eq:l.prefix,1)};A.readToken_question=function(){var s=this.options.ecmaVersion;if(s>=11){var e=this.input.charCodeAt(this.pos+1);if(e===46){var t=this.input.charCodeAt(this.pos+2);if(t<48||t>57)return this.finishOp(l.questionDot,2)}if(e===63){if(s>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(l.assign,3)}return this.finishOp(l.coalesce,2)}}return this.finishOp(l.question,1)};A.readToken_numberSign=function(){var s=this.options.ecmaVersion,e=35;if(s>=13&&(++this.pos,e=this.fullCharCodeAtPos(),Y(e,!0)||e===92))return this.finishToken(l.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+se(e)+"'")};A.getTokenFromCode=function(s){switch(s){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(l.parenL);case 41:return++this.pos,this.finishToken(l.parenR);case 59:return++this.pos,this.finishToken(l.semi);case 44:return++this.pos,this.finishToken(l.comma);case 91:return++this.pos,this.finishToken(l.bracketL);case 93:return++this.pos,this.finishToken(l.bracketR);case 123:return++this.pos,this.finishToken(l.braceL);case 125:return++this.pos,this.finishToken(l.braceR);case 58:return++this.pos,this.finishToken(l.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(l.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(e===120||e===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(e===111||e===79)return this.readRadixNumber(8);if(e===98||e===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(s);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(s);case 124:case 38:return this.readToken_pipe_amp(s);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(s);case 60:case 62:return this.readToken_lt_gt(s);case 61:case 33:return this.readToken_eq_excl(s);case 63:return this.readToken_question();case 126:return this.finishOp(l.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+se(s)+"'")};A.finishOp=function(s,e){var t=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(s,t)};A.readRegexp=function(){for(var s,e,t=this.pos;;){this.pos>=this.input.length&&this.raise(t,"Unterminated regular expression");var n=this.input.charAt(this.pos);if(H.test(n)&&this.raise(t,"Unterminated regular expression"),s)s=!1;else{if(n==="[")e=!0;else if(n==="]"&&e)e=!1;else if(n==="/"&&!e)break;s=n==="\\"}++this.pos}var i=this.input.slice(t,this.pos);++this.pos;var r=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(r);var o=this.regexpState||(this.regexpState=new ee(this));o.reset(t,i,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var c=null;try{c=new RegExp(i,a)}catch{}return this.finishToken(l.regexp,{pattern:i,flags:a,value:c})};A.readInt=function(s,e,t){for(var n=this.options.ecmaVersion>=12&&e===void 0,i=t&&this.input.charCodeAt(this.pos)===48,r=this.pos,a=0,o=0,c=0,u=e??1/0;c<u;++c,++this.pos){var p=this.input.charCodeAt(this.pos),h=void 0;if(n&&p===95){i&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),c===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=p;continue}if(p>=97?h=p-97+10:p>=65?h=p-65+10:p>=48&&p<=57?h=p-48:h=1/0,h>=s)break;o=p,a=a*s+h}return n&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===r||e!=null&&this.pos-r!==e?null:a};function ks(s,e){return e?parseInt(s,8):parseFloat(s.replace(/_/g,""))}function jt(s){return typeof BigInt!="function"?null:BigInt(s.replace(/_/g,""))}A.readRadixNumber=function(s){var e=this.pos;this.pos+=2;var t=this.readInt(s);return t==null&&this.raise(this.start+2,"Expected number in radix "+s),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(t=jt(this.input.slice(e,this.pos)),++this.pos):Y(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(l.num,t)};A.readNumber=function(s){var e=this.pos;!s&&this.readInt(10,void 0,!0)===null&&this.raise(e,"Invalid number");var t=this.pos-e>=2&&this.input.charCodeAt(e)===48;t&&this.strict&&this.raise(e,"Invalid number");var n=this.input.charCodeAt(this.pos);if(!t&&!s&&this.options.ecmaVersion>=11&&n===110){var i=jt(this.input.slice(e,this.pos));return++this.pos,Y(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(l.num,i)}t&&/[89]/.test(this.input.slice(e,this.pos))&&(t=!1),n===46&&!t&&(++this.pos,this.readInt(10),n=this.input.charCodeAt(this.pos)),(n===69||n===101)&&!t&&(n=this.input.charCodeAt(++this.pos),(n===43||n===45)&&++this.pos,this.readInt(10)===null&&this.raise(e,"Invalid number")),Y(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var r=ks(this.input.slice(e,this.pos),t);return this.finishToken(l.num,r)};A.readCodePoint=function(){var s=this.input.charCodeAt(this.pos),e;if(s===123){this.options.ecmaVersion<6&&this.unexpected();var t=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(t,"Code point out of bounds")}else e=this.readHexChar(4);return e};A.readString=function(s){for(var e="",t=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var n=this.input.charCodeAt(this.pos);if(n===s)break;n===92?(e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!1),t=this.pos):n===8232||n===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(ge(n)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(t,this.pos++),this.finishToken(l.string,e)};var Wt={};A.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(s){if(s===Wt)this.readInvalidTemplateToken();else throw s}this.inTemplateElement=!1};A.invalidStringToken=function(s,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Wt;this.raise(s,e)};A.readTmplToken=function(){for(var s="",e=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var t=this.input.charCodeAt(this.pos);if(t===96||t===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===l.template||this.type===l.invalidTemplate)?t===36?(this.pos+=2,this.finishToken(l.dollarBraceL)):(++this.pos,this.finishToken(l.backQuote)):(s+=this.input.slice(e,this.pos),this.finishToken(l.template,s));if(t===92)s+=this.input.slice(e,this.pos),s+=this.readEscapedChar(!0),e=this.pos;else if(ge(t)){switch(s+=this.input.slice(e,this.pos),++this.pos,t){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:s+=`
6
- `;break;default:s+=String.fromCharCode(t);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}};A.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(l.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
7
- `&&++this.pos;case`
8
- `:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};A.readEscapedChar=function(s){var e=this.input.charCodeAt(++this.pos);switch(++this.pos,e){case 110:return`
9
- `;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return se(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),s){var t=this.pos-1;this.invalidStringToken(t,"Invalid escape sequence in template string")}default:if(e>=48&&e<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(n,8);return i>255&&(n=n.slice(0,-1),i=parseInt(n,8)),this.pos+=n.length-1,e=this.input.charCodeAt(this.pos),(n!=="0"||e===56||e===57)&&(this.strict||s)&&this.invalidStringToken(this.pos-1-n.length,s?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(i)}return ge(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}};A.readHexChar=function(s){var e=this.pos,t=this.readInt(16,s);return t===null&&this.invalidStringToken(e,"Bad character escape sequence"),t};A.readWord1=function(){this.containsEsc=!1;for(var s="",e=!0,t=this.pos,n=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(ae(i,n))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,s+=this.input.slice(t,this.pos);var r=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(e?Y:ae)(a,n)||this.invalidStringToken(r,"Invalid Unicode escape"),s+=se(a),t=this.pos}else break;e=!1}return s+this.input.slice(t,this.pos)};A.readWord=function(){var s=this.readWord1(),e=l.name;return this.keywords.test(s)&&(e=ze[s]),this.finishToken(e,s)};var Ns="8.15.0";L.acorn={Parser:L,version:Ns,defaultOptions:je,Position:ve,SourceLocation:Me,getLineInfo:ft,Node:Le,TokenType:_,tokTypes:l,keywordTypes:ze,TokContext:Q,tokContexts:I,isIdentifierChar:ae,isIdentifierStart:Y,Token:Ye,isNewLine:ge,lineBreak:H,lineBreakG:Yt,nonASCIIwhitespace:pt};function F(s,e){return L.parse(s,e)}function U(s,e,t,n,i){t||(t=E),(function r(a,o,c){var u=c||a.type;t[u](a,o,r),e[u]&&e[u](a,o)})(s,n,i)}function at(s,e,t,n,i){var r=[];t||(t=E),(function a(o,c,u){var p=u||o.type,h=o!==r[r.length-1];h&&r.push(o),t[p](o,c,a),e[p]&&e[p](o,c||r,r),h&&r.pop()})(s,n,i)}function Je(s,e,t){t(s,e)}function pe(s,e,t){}var E={};E.Program=E.BlockStatement=E.StaticBlock=function(s,e,t){for(var n=0,i=s.body;n<i.length;n+=1){var r=i[n];t(r,e,"Statement")}};E.Statement=Je;E.EmptyStatement=pe;E.ExpressionStatement=E.ParenthesizedExpression=E.ChainExpression=function(s,e,t){return t(s.expression,e,"Expression")};E.IfStatement=function(s,e,t){t(s.test,e,"Expression"),t(s.consequent,e,"Statement"),s.alternate&&t(s.alternate,e,"Statement")};E.LabeledStatement=function(s,e,t){return t(s.body,e,"Statement")};E.BreakStatement=E.ContinueStatement=pe;E.WithStatement=function(s,e,t){t(s.object,e,"Expression"),t(s.body,e,"Statement")};E.SwitchStatement=function(s,e,t){t(s.discriminant,e,"Expression");for(var n=0,i=s.cases;n<i.length;n+=1){var r=i[n];t(r,e)}};E.SwitchCase=function(s,e,t){s.test&&t(s.test,e,"Expression");for(var n=0,i=s.consequent;n<i.length;n+=1){var r=i[n];t(r,e,"Statement")}};E.ReturnStatement=E.YieldExpression=E.AwaitExpression=function(s,e,t){s.argument&&t(s.argument,e,"Expression")};E.ThrowStatement=E.SpreadElement=function(s,e,t){return t(s.argument,e,"Expression")};E.TryStatement=function(s,e,t){t(s.block,e,"Statement"),s.handler&&t(s.handler,e),s.finalizer&&t(s.finalizer,e,"Statement")};E.CatchClause=function(s,e,t){s.param&&t(s.param,e,"Pattern"),t(s.body,e,"Statement")};E.WhileStatement=E.DoWhileStatement=function(s,e,t){t(s.test,e,"Expression"),t(s.body,e,"Statement")};E.ForStatement=function(s,e,t){s.init&&t(s.init,e,"ForInit"),s.test&&t(s.test,e,"Expression"),s.update&&t(s.update,e,"Expression"),t(s.body,e,"Statement")};E.ForInStatement=E.ForOfStatement=function(s,e,t){t(s.left,e,"ForInit"),t(s.right,e,"Expression"),t(s.body,e,"Statement")};E.ForInit=function(s,e,t){s.type==="VariableDeclaration"?t(s,e):t(s,e,"Expression")};E.DebuggerStatement=pe;E.FunctionDeclaration=function(s,e,t){return t(s,e,"Function")};E.VariableDeclaration=function(s,e,t){for(var n=0,i=s.declarations;n<i.length;n+=1){var r=i[n];t(r,e)}};E.VariableDeclarator=function(s,e,t){t(s.id,e,"Pattern"),s.init&&t(s.init,e,"Expression")};E.Function=function(s,e,t){s.id&&t(s.id,e,"Pattern");for(var n=0,i=s.params;n<i.length;n+=1){var r=i[n];t(r,e,"Pattern")}t(s.body,e,s.expression?"Expression":"Statement")};E.Pattern=function(s,e,t){s.type==="Identifier"?t(s,e,"VariablePattern"):s.type==="MemberExpression"?t(s,e,"MemberPattern"):t(s,e)};E.VariablePattern=pe;E.MemberPattern=Je;E.RestElement=function(s,e,t){return t(s.argument,e,"Pattern")};E.ArrayPattern=function(s,e,t){for(var n=0,i=s.elements;n<i.length;n+=1){var r=i[n];r&&t(r,e,"Pattern")}};E.ObjectPattern=function(s,e,t){for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];r.type==="Property"?(r.computed&&t(r.key,e,"Expression"),t(r.value,e,"Pattern")):r.type==="RestElement"&&t(r.argument,e,"Pattern")}};E.Expression=Je;E.ThisExpression=E.Super=E.MetaProperty=pe;E.ArrayExpression=function(s,e,t){for(var n=0,i=s.elements;n<i.length;n+=1){var r=i[n];r&&t(r,e,"Expression")}};E.ObjectExpression=function(s,e,t){for(var n=0,i=s.properties;n<i.length;n+=1){var r=i[n];t(r,e)}};E.FunctionExpression=E.ArrowFunctionExpression=E.FunctionDeclaration;E.SequenceExpression=function(s,e,t){for(var n=0,i=s.expressions;n<i.length;n+=1){var r=i[n];t(r,e,"Expression")}};E.TemplateLiteral=function(s,e,t){for(var n=0,i=s.quasis;n<i.length;n+=1){var r=i[n];t(r,e)}for(var a=0,o=s.expressions;a<o.length;a+=1){var c=o[a];t(c,e,"Expression")}};E.TemplateElement=pe;E.UnaryExpression=E.UpdateExpression=function(s,e,t){t(s.argument,e,"Expression")};E.BinaryExpression=E.LogicalExpression=function(s,e,t){t(s.left,e,"Expression"),t(s.right,e,"Expression")};E.AssignmentExpression=E.AssignmentPattern=function(s,e,t){t(s.left,e,"Pattern"),t(s.right,e,"Expression")};E.ConditionalExpression=function(s,e,t){t(s.test,e,"Expression"),t(s.consequent,e,"Expression"),t(s.alternate,e,"Expression")};E.NewExpression=E.CallExpression=function(s,e,t){if(t(s.callee,e,"Expression"),s.arguments)for(var n=0,i=s.arguments;n<i.length;n+=1){var r=i[n];t(r,e,"Expression")}};E.MemberExpression=function(s,e,t){t(s.object,e,"Expression"),s.computed&&t(s.property,e,"Expression")};E.ExportNamedDeclaration=E.ExportDefaultDeclaration=function(s,e,t){s.declaration&&t(s.declaration,e,s.type==="ExportNamedDeclaration"||s.declaration.id?"Statement":"Expression"),s.source&&t(s.source,e,"Expression")};E.ExportAllDeclaration=function(s,e,t){s.exported&&t(s.exported,e),t(s.source,e,"Expression")};E.ImportDeclaration=function(s,e,t){for(var n=0,i=s.specifiers;n<i.length;n+=1){var r=i[n];t(r,e)}t(s.source,e,"Expression")};E.ImportExpression=function(s,e,t){t(s.source,e,"Expression")};E.ImportSpecifier=E.ImportDefaultSpecifier=E.ImportNamespaceSpecifier=E.Identifier=E.PrivateIdentifier=E.Literal=pe;E.TaggedTemplateExpression=function(s,e,t){t(s.tag,e,"Expression"),t(s.quasi,e,"Expression")};E.ClassDeclaration=E.ClassExpression=function(s,e,t){return t(s,e,"Class")};E.Class=function(s,e,t){s.id&&t(s.id,e,"Pattern"),s.superClass&&t(s.superClass,e,"Expression"),t(s.body,e)};E.ClassBody=function(s,e,t){for(var n=0,i=s.body;n<i.length;n+=1){var r=i[n];t(r,e)}};E.MethodDefinition=E.PropertyDefinition=E.Property=function(s,e,t){s.computed&&t(s.key,e,"Expression"),s.value&&t(s.value,e,"Expression")};const m={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,POOL_SIZE:10,MUSTACHE_PATTERN:/\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}/,MUSTACHE_SINGLE_PATTERN:/^\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}$/},Te=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 Ms(s,e){let t;return(...n)=>{clearTimeout(t),t=window.setTimeout(()=>s(...n),e)}}function Ht(s){return s.charAt(0).toUpperCase()+s.slice(1)}function ue(s){if(s==null||typeof s=="boolean"||typeof s=="function"||Array.isArray(s)&&s.length===0||typeof s=="object"&&Object.keys(s).length===0)return"";if(typeof s=="number")return String(s);if(typeof s=="string")return s;if(Array.isArray(s)){if(s.some(t=>t!==null&&(typeof t=="object"||Array.isArray(t))))try{return JSON.stringify(s)}catch{return"[Array]"}return s.map(t=>ue(t)).filter(t=>t!=="").join("")}if(typeof s=="object")try{return JSON.stringify(s)}catch{return"[object Object]"}return String(s)}function Ue(s){return typeof s=="function"&&"__pphp_key"in s?s.value:s}class R{static scopeCache=new WeakMap;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),n}static findScopeUncached(e){let t=e.previousSibling,n=0;for(;t;){if(t.nodeType===Node.COMMENT_NODE){const a=(t.textContent||"").trim();if(a==="/pp-scope")n++;else if(a.startsWith("pp-scope:")){if(n===0)return a.substring(9).trim();n--}}t=t.previousSibling}let i=e.parentElement;for(;i&&i!==document.body;){for(t=i.previousSibling;t;){if(t.nodeType===Node.COMMENT_NODE){const a=(t.textContent||"").trim();if(a==="/pp-scope")n++;else if(a.startsWith("pp-scope:")){if(n===0)return a.substring(9).trim();n--}}t=t.previousSibling}i=i.parentElement}return null}static clearCache(){this.scopeCache=new WeakMap}static invalidateElement(e){this.scopeCache.delete(e)}}class Is{static validate(e,t){const n=[],i=[];try{const r=F(e,{ecmaVersion:2022,sourceType:"script"}),a=this.validateAST(r,e);n.push(...a.errors),i.push(...a.warnings);const o=this.validateSyntax(e);n.push(...o.errors),i.push(...o.warnings)}catch(r){n.push(`Invalid JavaScript syntax: ${r instanceof Error?r.message:String(r)}`)}return{valid:n.length===0,errors:n,warnings:i}}static validateAST(e,t){const n=[],i=[];return U(e,{ConditionalExpression:r=>{const a=t.slice(r.consequent.start,r.consequent.end),o=this.validateBranch(a,"truthy");n.push(...o.errors),i.push(...o.warnings);const c=t.slice(r.alternate.start,r.alternate.end),u=this.validateBranch(c,"falsy");n.push(...u.errors),i.push(...u.warnings)}}),{errors:n,warnings:i}}static validateBranch(e,t){const n=[],i=[];try{return F(e,{ecmaVersion:2022,sourceType:"script"}),{errors:n,warnings:i}}catch{const a=this.countQuotes(e);if(a.single%2!==0&&(n.push(`Unmatched single quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,"'"))){const o=this.suggestQuoteFix(e,"'");o&&n.push(` Did you mean: ${o}`)}if(a.double%2!==0&&(n.push(`Unmatched double quotes in ternary ${t} branch: "${e}"`),this.hasTrailingOrLeadingQuote(e,'"'))){const o=this.suggestQuoteFix(e,'"');o&&n.push(` Did you mean: ${o}`)}a.single%2===0&&a.double%2===0&&this.looksLikeUnquotedLiteral(e)&&i.push(`Value "${e}" in ternary ${t} branch may need quotes. Did you mean '${e}' or "${e}"?`)}return{errors:n,warnings:i}}static hasTrailingOrLeadingQuote(e,t){const n=e.startsWith(t),i=e.endsWith(t);return n&&!i||!n&&i}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 F(t,{ecmaVersion:2022,sourceType:"script"}),!1}catch{}return Te.has(t)||t==="true"||t==="false"||t==="null"||t==="undefined"||!isNaN(Number(t))&&t!==""||/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)||t.includes(".")||/\[.*\]/.test(t)||/\(.*\)/.test(t)?!1:!!(t.includes("-")||/\s/.test(t)||/[^a-zA-Z0-9_$.]/.test(t))}static isAlreadyQuoted(e){return e.startsWith("'")&&e.endsWith("'")&&e.length>=2||e.startsWith('"')&&e.endsWith('"')&&e.length>=2}static countQuotes(e){let t=0,n=0,i=!1;for(let r=0;r<e.length;r++){if(i){i=!1;continue}if(e[r]==="\\"){i=!0;continue}e[r]==="'"&&t++,e[r]==='"'&&n++}return{single:t,double:n}}static validateSyntax(e){const t=[],n=[],i=this.checkBrackets(e);i.valid||t.push(i.error);const r=this.checkParentheses(e);return r.valid||t.push(r.error),{errors:t,warnings:n}}static checkBrackets(e){let t=0,n=!1,i="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!n&&(a==="'"||a==='"')?(n=!0,i=a):n&&a===i&&o!=="\\"&&(n=!1,i=""),!n&&(a==="{"&&t++,a==="}"&&t--,t<0))return{valid:!1,error:"Unexpected closing bracket '}'"}}return t!==0?{valid:!1,error:"Mismatched brackets - missing '}'"}:{valid:!0,error:""}}static checkParentheses(e){let t=0,n=!1,i="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!n&&(a==="'"||a==='"')?(n=!0,i=a):n&&a===i&&o!=="\\"&&(n=!1,i=""),!n&&(a==="("&&t++,a===")"&&t--,t<0))return{valid:!1,error:"Unexpected closing parenthesis ')'"}}return t!==0?{valid:!1,error:"Mismatched parentheses - missing ')'"}:{valid:!0,error:""}}}class fe{static instance;walkerPool=[];traversalCache=new WeakMap;lastCacheTime=new WeakMap;CACHE_TTL=250;trackedElements=new Set;static getInstance(){return fe.instance||(fe.instance=new fe),fe.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 i=Date.now(),r=this.traversalCache.get(e),a=this.lastCacheTime.get(e);if(r&&a&&i-a<this.CACHE_TTL){const c=r.get(t);if(c)return c}const o=n();return this.traversalCache.has(e)||(this.traversalCache.set(e,new Map),this.trackedElements.add(e)),this.traversalCache.get(e).set(t,o),this.lastCacheTime.set(e,i),o}traverseElementsAndText(e,t,n){const i=this.acquireWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),r=[],a=[];let o;for(;o=i.nextNode();)if(o.nodeType===Node.ELEMENT_NODE){const c=o;(!t||t(c))&&r.push(c)}else if(o.nodeType===Node.TEXT_NODE){const c=o;(!n||n(c))&&a.push(c)}return this.releaseWalker(i),{elements:r,textNodes:a}}cleanupCache(){const e=[];for(const t of this.trackedElements)document.contains(t)||e.push(t);e.forEach(t=>{this.traversalCache.delete(t),this.lastCacheTime.delete(t),this.trackedElements.delete(t)})}}class W{static instance;componentElementsCache=new K(100);scriptElementsCache=new K(50);templateElementsCache=new K(50);selectorCache=new K(200);elementComponentCache=new WeakMap;parentComponentCache=new WeakMap;contextComponentCache=new WeakMap;elementDepthCache=new WeakMap;elementChildrenCache=new WeakMap;cacheHits=0;cacheMisses=0;static CACHE_KEYS={COMPONENT_ELEMENTS:e=>`comp:${e}`,SCRIPTS:(e,t)=>`scripts:${e}:${t}`,TEMPLATES:(e,t)=>`templates:${e}:${t}`,SELECTOR:e=>`sel:${e}`};static getInstance(){return W.instance||(W.instance=new W),W.instance}queryComponentElements(e){const t=W.CACHE_KEYS.COMPONENT_ELEMENTS(e);if(this.componentElementsCache.has(t))return this.cacheHits++,this.componentElementsCache.get(t);this.cacheMisses++;const n=Array.from(document.querySelectorAll(`[${m.ATTR_PREFIXES.COMPONENT}="${e}"]`));return n.forEach(i=>{this.elementComponentCache.set(i,e)}),this.componentElementsCache.set(t,n),n}querySelectorAll(e){const t=W.CACHE_KEYS.SELECTOR(e);if(this.selectorCache.has(t))return this.cacheHits++,this.selectorCache.get(t);this.cacheMisses++;const n=Array.from(document.querySelectorAll(e));return this.selectorCache.set(t,n),n}getElementComponent(e){if(this.elementComponentCache.has(e))return this.cacheHits++,this.elementComponentCache.get(e);this.cacheMisses++;const t=e.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(t)return this.elementComponentCache.set(e,t),t;let n=e.parentElement;for(;n;){const i=n.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(i)return this.elementComponentCache.set(e,i),i;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=R.findScope(e);let n;return t?t==="app"?n="app":n=t:n=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++,e==="app")return this.parentComponentCache.set(t,"app"),"app";let n=t;for(;n&&n.getAttribute(m.ATTR_PREFIXES.COMPONENT)!==e;)n=n.parentElement;if(!n)return this.parentComponentCache.set(t,"app"),"app";let i=n.parentElement;for(;i;){const r=i.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(r)return this.parentComponentCache.set(t,r),r;i=i.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(e,t){const n=W.CACHE_KEYS.SCRIPTS(e,t?.tagName||"global");if(this.scriptElementsCache.has(n))return this.cacheHits++,this.scriptElementsCache.get(n);this.cacheMisses++;let i=[];if(t){const r=t.querySelectorAll(`script[type="${m.SCRIPT_TYPE}"]`);for(const a of r)a instanceof HTMLScriptElement&&i.push(a)}else{const r=document.querySelectorAll(`script[type="${m.SCRIPT_TYPE}"]`);for(const a of r)if(a instanceof HTMLScriptElement){const o=a.getAttribute(m.ATTR_PREFIXES.COMPONENT);(o===e||!o&&!a.closest(`[${m.ATTR_PREFIXES.COMPONENT}]`))&&i.push(a)}}return this.scriptElementsCache.set(n,i),i}getComponentTemplates(e,t){const n=W.CACHE_KEYS.TEMPLATES(e,t?.tagName||"global");if(this.templateElementsCache.has(n))return this.cacheHits++,this.templateElementsCache.get(n);this.cacheMisses++;let i=[];if(t){const r=t.querySelectorAll("template[pp-for]");for(const a of r)a instanceof HTMLTemplateElement&&this.getElementComponent(a)===e&&i.push(a)}else{const r=document.querySelectorAll("template[pp-for]");for(const a of r)a instanceof HTMLTemplateElement&&this.getElementComponent(a)===e&&i.push(a)}return this.templateElementsCache.set(n,i),i}querySelector(e){const t=this.querySelectorAll(e);return t.length>0?t[0]:null}findElementForComponent(e,t){if(t==="app")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(e){const t=W.CACHE_KEYS.COMPONENT_ELEMENTS(e);this.componentElementsCache.delete(t);const n=W.CACHE_KEYS.SCRIPTS(e,"global");this.scriptElementsCache.delete(n);const i=W.CACHE_KEYS.TEMPLATES(e,"global");this.templateElementsCache.delete(i),this.selectorCache.clear()}invalidateByPrefix(e){this.invalidateByComponent(e)}invalidateElement(e){this.elementComponentCache.delete(e),this.contextComponentCache.delete(e),this.parentComponentCache.delete(e),this.elementDepthCache.delete(e),this.elementChildrenCache.delete(e)}clearAllCaches(){this.componentElementsCache.clear(),this.scriptElementsCache.clear(),this.templateElementsCache.clear(),this.selectorCache.clear(),this.elementComponentCache=new WeakMap,this.parentComponentCache=new WeakMap,this.contextComponentCache=new WeakMap,this.elementDepthCache=new WeakMap,this.elementChildrenCache=new WeakMap}getCacheStats(){const e=this.cacheHits+this.cacheMisses;return{componentElements:this.componentElementsCache.getStats(),scriptElements:this.scriptElementsCache.getStats(),templateElements:this.templateElementsCache.getStats(),selectors:this.selectorCache.getStats(),global:{size:0,maxSize:-1,hitRate:e>0?this.cacheHits/e*100:0,hits:this.cacheHits,misses:this.cacheMisses}}}resetStats(){this.cacheHits=0,this.cacheMisses=0}}class Os{subscriptions=new Map;elementSubscriptions=new WeakMap;keyIndex=new Map;cleanupQueue=new Set;cleanupScheduled=!1;addSubscription(e){this.subscriptions.set(e.id,e),e.element&&(this.elementSubscriptions.has(e.element)||this.elementSubscriptions.set(e.element,new Set),this.elementSubscriptions.get(e.element).add(e.id));for(const t of e.dependencies)this.keyIndex.has(t)||this.keyIndex.set(t,new Set),this.keyIndex.get(t).add(e.id)}removeSubscription(e){const t=this.subscriptions.get(e);if(t){if(this.subscriptions.delete(e),t.element){const n=this.elementSubscriptions.get(t.element);n&&(n.delete(e),n.size===0&&this.elementSubscriptions.delete(t.element))}for(const n of t.dependencies){const i=this.keyIndex.get(n);i&&(i.delete(e),i.size===0&&this.keyIndex.delete(n))}}}cleanupElement(e){const t=this.elementSubscriptions.get(e);t&&(t.forEach(n=>this.cleanupQueue.add(n)),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(t=>this.removeSubscription(t))}getStats(){return{totalSubscriptions:this.subscriptions.size,elementSubscriptions:this.elementSubscriptions instanceof WeakMap?-1:0,keyIndexes:this.keyIndex.size}}}class Z{static instance;stateVariables=new Set;static FUNCTIONS_NEEDING_VALUE_TRANSFORM=new Set(["console.log","console.warn","console.error","console.info","console.debug","console.dir","console.table","console.trace","console.assert","JSON.stringify","JSON.parse","Object.keys","Object.values","Object.entries","Array.from","Array.isArray","Math.max","Math.min","Math.abs","Math.floor","Math.ceil","Math.round","alert","confirm","prompt","parseInt","parseFloat","Number","String","Boolean"]);transformRefDeclarations(e){try{const t=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return U(t,{VariableDeclarator:r=>{if(this.isRefDeclaration(r)){const a=r.id.name,o=this.findStatementEnd(e,r.end);i.push({start:o,end:o,replacement:`; this.${a} = ${a}`})}}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("Ref transformation error:",t),e}}isRefDeclaration(e){return e.id?.type==="Identifier"&&e.init?.type==="CallExpression"&&e.init.callee?.type==="MemberExpression"&&e.init.callee.object?.type==="Identifier"&&e.init.callee.object.name==="pp"&&e.init.callee.property?.type==="Identifier"&&e.init.callee.property.name==="ref"}findStatementEnd(e,t){let n=t;for(;n<e.length&&e[n]!==";"&&e[n]!==`
10
- `;)n++;return n}static getInstance(){return Z.instance||(Z.instance=new Z),Z.instance}extractFunctionNames(e){const t=[];try{const n=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});U(n,{FunctionDeclaration:i=>{i.id?.type==="Identifier"&&t.push(i.id.name)},VariableDeclarator:i=>{i.id?.type==="Identifier"&&(i.init?.type==="ArrowFunctionExpression"||i.init?.type==="FunctionExpression")&&t.push(i.id.name)},AssignmentExpression:i=>{i.left?.type==="Identifier"&&(i.right?.type==="ArrowFunctionExpression"||i.right?.type==="FunctionExpression")&&t.push(i.left.name)}})}catch(n){console.error("AST function extraction error:",n)}return Array.from(new Set(t))}transformEffectDeclarations(e){try{const t=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return U(t,{CallExpression:r=>{const a=this.transformEffectCall(r,e);a&&i.push(a)}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.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 i=n[1];if(i.type!=="ArrayExpression"||!i.elements.some(h=>h?h.type==="Identifier"||h.type==="MemberExpression":!1))return null;const a=i.elements.map(h=>h?h.type==="Identifier"?`"${h.name}"`:h.type==="MemberExpression"?`"${this.extractMemberExpression(h,t)}"`:t.slice(h.start,h.end):"null"),o=t.slice(n[0].start,n[0].end),c=n.slice(2).map(h=>t.slice(h.start,h.end)).join(", "),u=`[${a.join(", ")}]`,p=c?`pp.effect(${o}, ${u}, ${c})`:`pp.effect(${o}, ${u})`;return{start:e.start,end:e.end,replacement:p}}extractMemberExpression(e,t){if(e.type!=="MemberExpression")return e.type==="Identifier"?e.name:t.slice(e.start,e.end);const n=this.extractMemberExpression(e.object,t);if(e.computed){const i=t.slice(e.property.start,e.property.end);return`${n}[${i}]`}else{const i=e.property.name||t.slice(e.property.start,e.property.end);return`${n}.${i}`}}isPPEffectCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&e.callee.property.name==="effect"}transformStateDeclarations(e,t){this.stateVariables.clear(),t&&t.forEach(i=>this.stateVariables.add(i));let n=this.transformStateDeclarationsOnly(e);return n=this.transformEffectDeclarations(n),n=this.transformRefDeclarations(n),n=this.transformUnsupportedStateUsages(n),n}transformStateDeclarationsOnlyOriginal(e){try{const t=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return U(t,{VariableDeclarator:r=>{const a=this.transformStateDeclarator(r,e);a&&i.push(a)}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.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=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});this.collectStateVariables(t);let n=this.transformShorthandProperties(e);const i=F(n,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),r=[],a=new Set,o=new Map;at(i,{VariableDeclarator:(p,h)=>{if(this.isStateDeclaration(p))return;let f=null;for(let g=h.length-1;g>=0;g--){const d=h[g];if(d.type==="FunctionExpression"||d.type==="ArrowFunctionExpression"||d.type==="FunctionDeclaration"||d.type==="BlockStatement"){f=d;break}}f&&p.id?.type==="Identifier"&&(o.has(f)||o.set(f,new Set),o.get(f).add(p.id.name),a.add(p.id.name))}});const c=(p,h)=>{for(let f=h.length-1;f>=0;f--){const g=h[f],d=o.get(g);if(d&&d.has(p))return!0}return!1},u=(p,h)=>!!(!p||p.type!=="Identifier"||!this.stateVariables.has(p.name)||a.has(p.name)||this.alreadyHasValue(p,h));return U(i,{MemberExpression:p=>{p.object?.type==="Identifier"&&this.stateVariables.has(p.object.name)&&!a.has(p.object.name)&&!this.alreadyHasValue(p.object,n)&&r.push({start:p.object.start,end:p.object.end,replacement:`${p.object.name}.value`})},SpreadElement:p=>{if(!u(p.argument,n)){const h=this.transformSpreadElement(p,n);h&&r.push(h)}},UnaryExpression:p=>{if(!u(p.argument,n)){const h=this.transformUnaryExpression(p,n);h&&r.push(h)}},BinaryExpression:p=>{const h=u(p.left,n),f=u(p.right,n);if(!h||!f){const g=this.transformBinaryExpression(p,n);g&&r.push(g)}},LogicalExpression:p=>{const h=u(p.left,n),f=u(p.right,n);if(!h||!f){const g=this.transformLogicalExpression(p,n);g&&r.push(g)}},ConditionalExpression:p=>{const h=this.transformConditionalExpression(p,n);h&&r.push(h)},IfStatement:p=>{if(!u(p.test,n)){const h=this.transformIfStatement(p,n);h&&r.push(h)}},WhileStatement:p=>{if(!u(p.test,n)){const h=this.transformWhileStatement(p,n);h&&r.push(h)}},ForStatement:p=>{const h=this.transformForStatement(p,n);h&&r.push(h)},ReturnStatement:p=>{const h=this.transformReturnStatement(p,n);h&&r.push(h)},VariableDeclarator:p=>{const h=this.transformVariableDeclarator(p,n);h&&r.push(h)},AssignmentExpression:p=>{const h=this.transformAssignmentExpression(p,n);h&&r.push(h)},CallExpression:p=>{const h=this.transformGeneralCallExpression(p,n);h&&h.length>0&&r.push(...h)}}),at(i,{Identifier:(p,h)=>{!this.stateVariables.has(p.name)||r.some(g=>p.start>=g.start&&p.end<=g.end)||c(p.name,h)||this.alreadyHasValue(p,n)||this.isPartOfStateDeclaration(p,h)||this.isPropertyName(p,h)||this.isMethodCallObject(p,h)||this.isPartOfPPCall(p,h)||this.isPartOfDestructuring(p,h)||r.push({start:p.start,end:p.end,replacement:`${p.name}.value`})}}),r.sort((p,h)=>h.start-p.start).forEach(p=>{n=n.slice(0,p.start)+p.replacement+n.slice(p.end)}),n=this.transformMultipleCallArguments(n,a),n}catch(t){return console.error("State usage transformation error:",t),e}}transformShorthandProperties(e){try{const t=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return U(t,{Property:r=>{if(r.shorthand&&r.key?.type==="Identifier"&&this.stateVariables.has(r.key.name)){const a=r.key.name,o=`${a}: ${a}.value`;i.push({start:r.start,end:r.end,replacement:o})}}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.end)}),n}catch(t){return console.error("Shorthand property transformation error:",t),e}}transformLogicalExpression(e,t){return e.left?.type==="Identifier"&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,t)?{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`}:e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,t)?{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}:null}transformConditionalExpression(e,t){return e.test?.type==="Identifier"&&this.stateVariables.has(e.test.name)&&!this.alreadyHasValue(e.test,t)?{start:e.test.start,end:e.test.end,replacement:`${e.test.name}.value`}:e.consequent?.type==="Identifier"&&this.stateVariables.has(e.consequent.name)&&!this.alreadyHasValue(e.consequent,t)?{start:e.consequent.start,end:e.consequent.end,replacement:`${e.consequent.name}.value`}:e.alternate?.type==="Identifier"&&this.stateVariables.has(e.alternate.name)&&!this.alreadyHasValue(e.alternate,t)?{start:e.alternate.start,end:e.alternate.end,replacement:`${e.alternate.name}.value`}:null}transformIfStatement(e,t){return this.transformExpressionNode(e.test,t)}transformWhileStatement(e,t){return this.transformExpressionNode(e.test,t)}transformForStatement(e,t){return e.test?this.transformExpressionNode(e.test,t):null}transformReturnStatement(e,t){return e.argument?this.transformExpressionNode(e.argument,t):null}transformVariableDeclarator(e,t){return this.isStateDeclaration(e)||e.id?.type==="ArrayPattern"||e.id?.type==="ObjectPattern"?null:e.init?.type==="Identifier"&&this.stateVariables.has(e.init.name)&&!this.alreadyHasValue(e.init,t)?{start:e.init.start,end:e.init.end,replacement:`${e.init.name}.value`}:null}transformAssignmentExpression(e,t){return e.left?.type==="ArrayPattern"||e.left?.type==="ObjectPattern"?null:e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,t)?{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}:null}transformGeneralCallExpression(e,t){const n=t.slice(e.callee.start,e.callee.end);if(e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&this.stateVariables.has(e.callee.object.name))return[];if(this.isPPCall(e))return[];if(!Z.isFunctionNeedingValueTransform(n)&&e.arguments.length>0){const r=[];for(const a of e.arguments)a.type==="Identifier"&&this.stateVariables.has(a.name)&&(this.alreadyHasValue(a,t)||r.push({start:a.start,end:a.end,replacement:`${a.name}.value`}));return r}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 e?.type==="Identifier"&&this.stateVariables.has(e.name)&&!this.alreadyHasValue(e,t)?{start:e.start,end:e.end,replacement:`${e.name}.value`}:null}isPPCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&(e.callee.property.name==="state"||e.callee.property.name==="effect")}isPartOfStateDeclaration(e,t){if(!t||!Array.isArray(t))return!1;for(const n of t)if(n.type==="VariableDeclarator"&&n.id?.type==="ArrayPattern"&&n.init?.type==="CallExpression"&&this.isPPStateCall(n.init))return!0;return!1}isPropertyName(e,t){if(!t||t.length===0)return!1;const n=t[t.length-1];return!!(n?.type==="Property"&&n.key===e||n?.type==="Property"&&n.shorthand&&n.value===e||n?.type==="MemberExpression"&&n.property===e&&!n.computed)}isMethodCallObject(e,t){if(!t||t.length===0)return!1;const n=t[t.length-1];if(n?.type==="MemberExpression"&&n.object===e&&t.length>=2){const i=t[t.length-2];if(i?.type==="CallExpression"&&i.callee===n)return!0}return!1}isPartOfPPCall(e,t){if(!t||!Array.isArray(t))return!1;for(const n of t)if(n.type==="CallExpression"&&n.callee?.type==="MemberExpression"&&n.callee.object?.type==="Identifier"&&n.callee.object.name==="pp"&&n.callee.property?.type==="Identifier"&&(n.callee.property.name==="state"||n.callee.property.name==="effect"))return!0;return!1}isPartOfDestructuring(e,t){if(!t||!Array.isArray(t))return!1;for(let n=0;n<t.length;n++){const i=t[n];if(i.type==="ArrayPattern"||i.type==="ObjectPattern"){if(n+1<t.length){const r=t[n+1];if(r?.type==="VariableDeclarator"&&r.id===i&&r.init===e)return!1}return!0}}return!1}collectStateVariables(e){U(e,{VariableDeclarator:t=>{if(this.isStateDeclaration(t)){const n=t.id.elements[0];n?.type==="Identifier"&&this.stateVariables.add(n.name)}}})}isStateDeclaration(e){return e.id?.type==="ArrayPattern"&&e.init?.type==="CallExpression"&&this.isPPStateCall(e.init)}transformSpreadElement(e,t){return e.argument?.type==="Identifier"&&this.stateVariables.has(e.argument.name)?this.alreadyHasValue(e.argument,t)?null:{start:e.argument.start,end:e.argument.end,replacement:`${e.argument.name}.value`}:null}transformUnaryExpression(e,t){return e.argument?.type==="Identifier"&&this.stateVariables.has(e.argument.name)&&["typeof","!","+","-","~","void","delete"].includes(e.operator)&&!this.alreadyHasValue(e.argument,t)?{start:e.argument.start,end:e.argument.end,replacement:`${e.argument.name}.value`}:null}transformBinaryExpression(e,t){if(["===","!==","==","!=",">","<",">=","<=","+","-","*","/","%","**","&","|","^","<<",">>",">>>","in","instanceof"].includes(e.operator)){if(e.left?.type==="Identifier"&&this.stateVariables.has(e.left.name)&&!this.alreadyHasValue(e.left,t))return{start:e.left.start,end:e.left.end,replacement:`${e.left.name}.value`};if(e.right?.type==="Identifier"&&this.stateVariables.has(e.right.name)&&!this.alreadyHasValue(e.right,t))return{start:e.right.start,end:e.right.end,replacement:`${e.right.name}.value`}}return null}transformMultipleCallArguments(e,t){try{const n=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=e;const r=[];return U(n,{CallExpression:a=>{const o=i.slice(a.callee.start,a.callee.end);if(Z.isFunctionNeedingValueTransform(o)&&a.arguments.length>0){for(const u of a.arguments)if(u.type==="Identifier"&&this.stateVariables.has(u.name)){if(t&&t.has(u.name))continue;this.alreadyHasValue(u,i)||r.push({start:u.start,end:u.end,replacement:`${u.name}.value`})}}}}),r.sort((a,o)=>o.start-a.start).forEach(a=>{i=i.slice(0,a.start)+a.replacement+i.slice(a.end)}),i}catch(n){return console.error("Multiple call arguments transformation error:",n),e}}transformDestructuringAssignments(e){try{const t=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const i=[];return U(t,{VariableDeclarator:r=>{this.isStateDeclaration(r)||(r.id?.type==="ArrayPattern"||r.id?.type==="ObjectPattern")&&r.init?.type==="Identifier"&&this.stateVariables.has(r.init.name)&&(this.alreadyHasValue(r.init,e)||i.push({start:r.init.start,end:r.init.end,replacement:`${r.init.name}.value`}))},AssignmentExpression:r=>{(r.left?.type==="ArrayPattern"||r.left?.type==="ObjectPattern")&&r.right?.type==="Identifier"&&this.stateVariables.has(r.right.name)&&(this.alreadyHasValue(r.right,e)||i.push({start:r.right.start,end:r.right.end,replacement:`${r.right.name}.value`}))}}),i.sort((r,a)=>a.start-r.start).forEach(r=>{n=n.slice(0,r.start)+r.replacement+n.slice(r.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){if(e.id?.type!=="ArrayPattern"||e.init?.type!=="CallExpression")return null;const n=e.init;if(!this.isPPStateCall(n))return null;const i=e.id.elements[0];if(!i||i.type!=="Identifier")return null;const r=i.name,a=`set${this.capitalize(r)}`,o=e.id.elements[1];return o?.type==="Identifier"&&o.name!==a&&console.warn(`Setter name mismatch: expected ${a}, got ${o.name}`),this.createTransformation(n,r,t)}isPPStateCall(e){return e.callee?.type==="MemberExpression"&&e.callee.object?.type==="Identifier"&&e.callee.object.name==="pp"&&e.callee.property?.type==="Identifier"&&e.callee.property.name==="state"}createTransformation(e,t,n){const i=e.arguments;if(i.length===0){const c=`pp.state("${t}")`;return{start:e.start,end:e.end,replacement:c}}const r=i[0];if(r.type==="Literal"&&typeof r.value=="string"&&r.value===t)return null;if(i.length===1){const c=n.slice(r.start,r.end),u=`pp.state("${t}", ${c})`;return{start:e.start,end:e.end,replacement:u}}const a=n.slice(e.arguments[0].start,e.arguments[e.arguments.length-1].end),o=`pp.state("${t}", ${a})`;return{start:e.start,end:e.end,replacement:o}}looksLikeVariableName(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&e.length<=50&&!e.includes(" ")}extractStateDeclarations(e){const t=[];try{const n=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0});U(n,{VariableDeclarator:i=>{const r=this.extractStateFromDeclarator(i,e);r&&t.push(r)}})}catch(n){console.error("State extraction error:",n)}return t}extractStateFromDeclarator(e,t){if(e.id?.type!=="ArrayPattern"||e.init?.type!=="CallExpression"||!this.isPPStateCall(e.init))return null;const n=e.id.elements[0],i=e.id.elements[1];if(n?.type!=="Identifier"||i?.type!=="Identifier")return null;const r=e.init.arguments;let a=n.name,o;return r.length>=1&&(r[0].type==="Literal"&&typeof r[0].value=="string"?this.looksLikeVariableName(r[0].value)?(a=r[0].value,r.length>=2&&(o=this.extractLiteralValue(r[1]))):(a=n.name,o=this.extractLiteralValue(r[0])):o=this.extractLiteralValue(r[0])),{variableName:n.name,setterName:i.name,stateKey:a,initialValue:o,line:e.loc?.start.line||0,column:e.loc?.start.column||0}}extractFunctionDeclarations(e){const t=[];try{const n=F(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0,locations:!0});U(n,{FunctionDeclaration:i=>{i.id?.type==="Identifier"&&t.push({name:i.id.name,type:"function",params:i.params.map(r=>r.type==="Identifier"?r.name:""),line:i.loc?.start.line||0})},VariableDeclarator:i=>{if(i.id?.type==="Identifier"&&(i.init?.type==="ArrowFunctionExpression"||i.init?.type==="FunctionExpression")){const r=i.init;t.push({name:i.id.name,type:r.type==="ArrowFunctionExpression"?"arrow":"function",params:r.params.map(a=>a.type==="Identifier"?a.name:""),line:i.loc?.start.line||0})}}})}catch(n){console.error("Function extraction error:",n)}return t}extractLiteralValue(e){if(e.type==="Literal")return e.value;e.type==="Identifier"&&e.name}capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}}class P{static FRAMEWORK_ATTRIBUTES=new Set(["pp-component","pp-for","pp-spread","pp-ref","key"]);static domCache;static getDOMCache(){return this.domCache||(this.domCache=W.getInstance()),this.domCache}static isFrameworkAttribute(e){return P.FRAMEWORK_ATTRIBUTES.has(e)}static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}static shouldBeDirectBinding(e,t){const n=R.findScope(e),i=e.getAttribute(m.ATTR_PREFIXES.COMPONENT);return!n||!i||n===i?!1:P.isDOMProperty(e,t)}static isDOMProperty(e,t){const n=e.tagName.toLowerCase(),i=document.createElement(n);return P.attributeToPropertyName(t)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,(n,i)=>i.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 n=t.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(n)return n;t=t.parentElement}return"app"}static isTextNodeInsideScript(e){let t=e.parentElement;for(;t&&t!==document.body;){const n=t.tagName.toLowerCase();if(n==="script"||n==="style")return!0;t=t.parentElement}return!1}static getComponentForNode(e){let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return t?this.getDOMCache().getElementComponent(t):"app"}static getElementComponent(e){return this.getDOMCache().getElementComponent(e)}}class de{static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}}class qe{static findExistingStateKey(e,t,n){return[`${t}.${e}`,`app.${e}`,e].find(r=>r in n)||null}}class ot{pendingUpdates=new Map;batchTimeout=null;componentManager;domBindingManager;setManagers(e,t){this.componentManager=e,this.domBindingManager=t}scheduleUpdate(e,t){this.pendingUpdates.has(e)||this.pendingUpdates.set(e,new Set),this.pendingUpdates.get(e).add(t),this.batchTimeout===null&&(this.batchTimeout=requestAnimationFrame(()=>{this.processBatchedUpdates(),this.batchTimeout=null}))}processBatchedUpdates(){const e=new Map(this.pendingUpdates);this.pendingUpdates.clear(),this.batchTimeout=null;const t=this.sortUpdatesByDependency(e);for(const[n,i]of t)this.processComponentUpdate(n,i)}sortUpdatesByDependency(e){const t=new WeakMap,n=i=>{let r=t.get(i);return r==null&&(r=P.getElementDepth(i),t.set(i,r)),r};return Array.from(e.entries()).sort(([,i],[,r])=>{const a=Math.min(...Array.from(i,n)),o=Math.min(...Array.from(r,n));return a-o})}processComponentUpdate(e,t){if(!this.componentManager||!this.domBindingManager)return;this.componentManager.invalidateComponent(e);const n=[],i=[],r=[];for(const a of t){if(!document.contains(a))continue;const o=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null);let c;for(;c=o.nextNode();)n.push(c);const u=this.domBindingManager.loopManager;if(u){const p=u.getAllLoops();for(const[h,f]of p)f.component===e&&a.contains(h)&&i.push([h,f])}r.push(a)}this.updateTextNodesBatch(n,e),this.updateLoopsBatch(i),this.updateElementsBatch(r,e)}updateTextNodesBatch(e,t){const n=this.domBindingManager.textNodeManager;n&&e.forEach(i=>{document.contains(i)&&P.getComponentForNode(i)===t&&n.updateTextNode(i)})}updateLoopsBatch(e){const t=this.domBindingManager.loopManager;if(!t)return;const n=new Map;e.forEach(([r,a])=>{const o=P.getElementDepth(r);n.has(o)||n.set(o,[]),n.get(o).push([r,a])});const i=Array.from(n.keys()).sort((r,a)=>r-a);for(const r of i)n.get(r).forEach(([o,c])=>{document.contains(o)&&t.renderLoop(c,c.iterableExpr)})}updateElementsBatch(e,t){e.forEach(n=>{document.contains(n)&&this.domBindingManager.processElementBindings(n,!0)})}}class K{cache=new Map;maxSize;hits=0;misses=0;constructor(e){this.maxSize=e}keys(){return Array.from(this.cache.keys())}deleteByPrefix(e){let t=0;const n=[];return this.cache.forEach((i,r)=>{typeof r=="string"&&r.startsWith(e)&&n.push(r)}),n.forEach(i=>{this.cache.delete(i)&&t++}),t}getKeysByPrefix(e){const t=[];return this.cache.forEach((n,i)=>{typeof i=="string"&&i.startsWith(e)&&t.push(i)}),t}get(e){const t=this.cache.get(e);if(t!==void 0)return this.hits++,this.cache.delete(e),this.cache.set(e,t),t;this.misses++}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){const n=this.cache.keys().next().value;n!==void 0&&this.cache.delete(n)}this.cache.set(e,t)}size(){return this.cache.size}has(e){return this.cache.has(e)}delete(e){return this.cache.delete(e)}clear(){this.cache.clear(),this.hits=0,this.misses=0}getStats(){const e=this.hits+this.misses;return{size:this.cache.size,maxSize:this.maxSize,hitRate:e>0?this.hits/e*100:0,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}}class M{static EXPRESSION_CACHE=new K(1e3);static parseSpreadDirective(e){const t=e.replace(/^\s*\{\s*|\s*\}\s*$/g,""),n=this.parseSpreadParts(t),i=[],r=[];for(const a of n){const o=a.trim();if(o.startsWith("..."))i.push(o.substring(3).trim());else if(o.startsWith("{")&&o.endsWith("}")){const c=o.slice(1,-1).trim();if(c){const u=this.parseObjectProperties(c);r.push(u)}}else console.warn(`Invalid spread directive part: "${o}". Expected ...spread or {object}`)}return{spreads:i,objects:r}}static parseSpreadParts(e){const t=[];let n="",i=0,r=!1,a="",o=0;for(;o<e.length;){const c=e[o],u=o>0?e[o-1]:"";if(!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&u!=="\\"&&(r=!1,a=""),!r){if(c==="{")i++;else if(c==="}")i--;else if(c===","&&i===0){t.push(n.trim()),n="",o++;continue}}n+=c,o++}return n.trim()&&t.push(n.trim()),t}static parseObjectProperties(e){const t=[],n=this.parseObjectParts(e);for(const i of n){const r=i.trim(),a=this.findPropertySeparator(r);if(a!==-1){const o=r.substring(0,a).trim().replace(/['"]/g,""),c=r.substring(a+1).trim();t.push({key:o,value:c})}else console.warn(`Invalid object property: "${r}". Expected key: value format.`)}return t}static parseObjectParts(e){const t=[];let n="",i=0,r=!1,a="";for(let o=0;o<e.length;o++){const c=e[o],u=o>0?e[o-1]:"";if(!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&u!=="\\"&&(r=!1,a=""),!r){if(c==="{"||c==="["||c==="(")i++;else if(c==="}"||c==="]"||c===")")i--;else if(c===","&&i===0){t.push(n.trim()),n="";continue}}n+=c}return n.trim()&&t.push(n.trim()),t}static findPropertySeparator(e){let t=0,n=!1,i="";for(let r=0;r<e.length;r++){const a=e[r],o=r>0?e[r-1]:"";if(!n&&(a==='"'||a==="'")?(n=!0,i=a):n&&a===i&&o!=="\\"&&(n=!1,i=""),!n){if(a==="{"||a==="["||a==="(")t++;else if(a==="}"||a==="]"||a===")")t--;else if(a===":"&&t===0)return r}}return-1}static decodeEntities=e=>{const t=document.createElement("textarea");t.innerHTML=e;let n=t.value;for(;n.includes("&");){t.innerHTML=n;const i=t.value;if(i===n)break;n=i}return n};static parse(e){if(M.EXPRESSION_CACHE.has(e))return M.EXPRESSION_CACHE.get(e);const t=M.parseContentWithNesting(e);return M.EXPRESSION_CACHE.set(e,t),t}static parseContentWithNesting(e){const t=[],n=e.length;let i=0,r=0;for(;i<n;)if(e[i]==="{"){i>r&&t.push({type:"static",content:e.substring(r,i),expression:null});const o=this.extractNestedExpression(e,i);o.endIndex!==-1&&o.expression&&this.isValidExpression(o.expression)?(t.push({type:"expression",content:e.substring(i,o.endIndex+1),expression:o.expression.trim()}),i=o.endIndex+1,r=i):i++}else i++;return r<n&&t.push({type:"static",content:e.substring(r),expression:null}),t}static isValidExpression(e){const t=e.trim();if(!t)return!1;try{const n=F(t,{ecmaVersion:2022,sourceType:"script"});if(n.type!=="Program")return!1;const i=n.body;if(!i||i.length===0)return!1;const r=i[0];if(r.type!=="ExpressionStatement")return!1;const a=r.expression;return!(a.type==="ObjectExpression"||a.type==="SequenceExpression")}catch{try{const r=F(`(${t})`,{ecmaVersion:2022,sourceType:"script"}).body;if(r&&r.length>0&&r[0].type==="ExpressionStatement")return!0}catch{return!1}return!1}}static extractNestedExpression(e,t){let n=1,i=t+1,r=!1,a="",o=!1;for(;i<e.length&&n>0;){const c=e[i],u=i>0?e[i-1]:"";!r&&(c==='"'||c==="'")?(r=!0,a=c):r&&c===a&&u!=="\\"&&(r=!1,a=""),!r&&c==="`"&&u!=="\\"&&(o=!o),!r&&!o&&(c==="{"?n++:c==="}"&&n--),i++}if(n===0){const c=e.slice(t+1,i-1);if(c.trim()){const u=this.checkForMismatchedQuotes(c);u.hasIssue&&(console.error(`
11
- ❌ Malformed expression detected during parsing:`),console.error(` Expression: ${c}`),console.error(` Issue: ${u.message}`),console.error(` Full content: ${e}`),console.error(` 💡 Hint: Check your quotes - strings must be properly quoted
12
- `))}return{endIndex:i-1,expression:c}}return console.warn(`
13
- ⚠️ Failed to extract mustache expression - unclosed braces`),console.warn(` Content: ${e}`),console.warn(` Starting at position: ${t}
14
- `),{endIndex:-1,expression:""}}static checkForMismatchedQuotes(e){let t=0,n=0,i=!1;for(let r=0;r<e.length;r++){if(i){i=!1;continue}if(e[r]==="\\"){i=!0;continue}e[r]==="'"&&t++,e[r]==='"'&&n++}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(e){const t=M.parseContentWithNesting(e);return t.length===1&&t[0].type==="expression"?t[0].expression:null}static extractExpressions(e){const t=M.parseContentWithNesting(e),n=t.filter(i=>i.type==="expression").map(i=>i.expression).filter(i=>i);return t.some(i=>i.type==="expression")&&n.length===0&&(console.error(`
15
- ❌ Failed to extract expressions from content:`),console.error(` Content: ${e}`),console.error(` Parsed ${t.length} parts, but extracted 0 expressions`),console.error(` This usually means malformed mustache syntax
16
- `)),n}}class Rs{textNodeBindings=new Map;expressionEvaluator;stateManager;componentManager;cleanupObserver;bindingCount=0;constructor(e,t){this.expressionEvaluator=e,this.stateManager=t,this.cleanupObserver=new MutationObserver(n=>{this.cleanupDetachedNodes(n)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0})}cleanupDetachedNodes(e){const t=[];for(const n of e)n.type==="childList"&&n.removedNodes.forEach(i=>{if(i.nodeType===Node.TEXT_NODE)t.push(i);else if(i.nodeType===Node.ELEMENT_NODE){const r=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,null);let a;for(;a=r.nextNode();)t.push(a)}});Promise.resolve().then(()=>{t.forEach(n=>{document.contains(n)||this.cleanupTextNode(n)})})}processTextNode(e,t){if(this.shouldSkipTextNode(e))return;const n=this.determineContextComponent(e,t),i=e.textContent||"",r=M.parse(i);if(!this.hasValidExpressions(r))return;const a=this.resolveFinalContextComponent(e,n,r),o=this.resolveComponentRootForElement(e,a),c=this.createTextNodeBinding(i,r,a,o);this.setupExpressionSubscriptions(e,r,a,o,c),this.textNodeBindings.set(e,c),this.bindingCount++,this.updateTextNode(e)}shouldSkipTextNode(e){return this.textNodeBindings.has(e)||P.isTextNodeInsideScript(e)||this.isInsideLoopItem(e)}determineContextComponent(e,t){const n=R.findScope(e),i=e.parentElement;return n?n==="app"?"app":n:i?P.getContextComponent(i):t}hasValidExpressions(e){return e.some(t=>t.type==="expression")}resolveFinalContextComponent(e,t,n){const i=R.findScope(e),r=this.getTextNodeActualComponent(e);if(r&&r!==i){const a=this.extractVariableNames(n);if(this.checkComponentVariables(a,r))return r}if(i&&i!=="app"){if(r&&r!==i){const a=this.extractVariableNames(n);if(this.checkComponentVariables(a,r))return r}return i}if(i==="app"&&r&&r!=="app"){const a=this.extractVariableNames(n);return this.checkComponentVariables(a,r)?r:"app"}return t}extractVariableNames(e){return e.filter(t=>t.type==="expression"&&t.expression).map(t=>{const n=t.expression.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);return n?n[1]:null}).filter(Boolean)}checkComponentVariables(e,t){const n=this.stateManager.getState();return e.some(i=>`${t}.${i}`in n)}createTextNodeBinding(e,t,n,i){return{originalContent:e,expressions:t,subscriptionIds:[],component:n,componentElement:i}}setupExpressionSubscriptions(e,t,n,i,r){t.filter(a=>a.type==="expression").forEach(a=>{if(!a.expression)return;const o=`text_${Date.now()}_${Math.random()}`,c=this.expressionEvaluator.extractDependencies(a.expression,n,this.stateManager);if(i&&this.componentManager){const p=this.componentManager.getComponentPropDependencies(i,n);c.push(...p)}const u={id:o,selector:"",dependencies:new Set(c),callback:()=>this.updateTextNode(e),element:e.parentElement??void 0,component:n};this.stateManager.addSubscription(u),r.subscriptionIds.push(o)})}updateTextNode(e){const t=this.textNodeBindings.get(e);if(!t||!e.parentElement)return;const n=this.resolveBindingComponentElement(e,t),i=this.buildEvaluationContext(e,t,n),r=this.evaluateExpressionsToText(t.expressions,i,t.component);this.applyTextUpdate(e,r)}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){const i=R.findScope(e),r=i!==null,a=this.getTextNodeActualComponent(e);let o;return r?o=this.buildExplicitContext(i,e,a,n):o=this.buildImplicitContext(t.component,n),this.transformContextForEvaluation(o)}buildExplicitContext(e,t,n,i){if(e==="app"){let c=this.componentManager.buildComponentContext("app");if(n&&n!=="app"){const p=this.componentManager.buildComponentContext(n);c={...c,...p}}let u=i;if((!u||!this.componentManager.hasStoredProps(u))&&(u=this.findActualComponentElement(t)),u&&this.componentManager.hasStoredProps(u)){const p=this.componentManager.evaluateProps(u);c={...c,...p}}return c}let r={};if(n&&n!==e){const c=this.componentManager.buildRestrictedComponentContext(n,!1);r={...r,...c}}const a=this.componentManager.buildRestrictedComponentContext(e,!1);for(const[c,u]of Object.entries(a))c in r||(r[c]=u);let o=i;if((!o||!this.componentManager.hasStoredProps(o))&&(o=this.findActualComponentElement(t)),o&&this.componentManager.hasStoredProps(o)){const c=this.componentManager.evaluateProps(o);r={...r,...c}}if(!o||!this.componentManager.hasStoredProps(o)){const c=this.findPortalComponentElement(t);if(c&&c!==o&&this.componentManager.hasStoredProps(c)){const u=this.componentManager.evaluateProps(c);r={...r,...u}}}return r}findPortalComponentElement(e){let t=e.parentElement;for(;t&&t!==document.body;){if(t.hasAttribute("data-portal-component")){const n=t.getAttribute("data-portal-component"),i=document.querySelectorAll(`[${m.ATTR_PREFIXES.COMPONENT}="${n}"]`);for(const r of i)if(this.componentManager.hasStoredProps(r))return r;return i[0]||null}t=t.parentElement}return null}buildImplicitContext(e,t){const n=this.componentManager.buildRestrictedComponentContext(e,!1);if(t&&this.componentManager.hasStoredProps(t)){const i=this.componentManager.evaluateProps(t);Object.assign(n,i)}return n}findActualComponentElement(e){let t=e.parentElement;for(;t&&t!==document.body;){if(t.hasAttribute("pp-component"))return t;t=t.parentElement}return null}transformContextForEvaluation(e){const t={};for(const[n,i]of Object.entries(e))typeof i=="function"&&"__pphp_key"in i?t[n]=i.value:t[n]=i;return t}evaluateExpressionsToText(e,t,n){let i="";for(const r of e)if(r.type==="static")i+=r.content;else if(r.expression)try{const a=this.expressionEvaluator.evaluateExpression(r.expression,t,n);i+=ue(a)}catch(a){console.error(`❌ Text binding evaluation error for "${r.expression}":`,a),console.error(`Component: ${n}`),console.error(`Available variables: [${Object.keys(t).join(", ")}]`),i+=""}return i}applyTextUpdate(e,t){e.textContent!==t&&(e.textContent=t)}isInsideLoopItem(e){let t=e.parentElement;for(;t&&t!==document.body;){const n=t.previousSibling;if(n&&n.nodeType===Node.COMMENT_NODE&&n.textContent?.startsWith("pp-for:"))return!0;let i=t.parentElement?.firstChild||null;for(;i;){if(i.nodeType===Node.COMMENT_NODE&&i.textContent?.startsWith("pp-for:")&&i!==t)return!0;i=i.nextSibling}t=t.parentElement}return!1}getTextNodeActualComponent(e){let t=e.parentElement;for(;t&&t!==document.body;){const n=t.getAttribute("pp-component");if(n)return n;t=t.parentElement}return null}resolveComponentRootForElement(e,t){const n=document.querySelectorAll(`[${m.ATTR_PREFIXES.COMPONENT}="${t}"]`);if(this.componentManager){for(const i of n)if(this.componentManager.hasStoredProps(i))return i}return n[0]||void 0}cleanupTextNode(e){const t=this.textNodeBindings.get(e);t&&(t.subscriptionIds.forEach(n=>{this.stateManager.removeSubscription(n)}),this.textNodeBindings.delete(e),this.bindingCount=Math.max(0,this.bindingCount-1))}getBindingCount(){return this.textNodeBindings.size}getAllBindings(){return new Map(this.textNodeBindings)}clearAllBindings(){for(const[e]of this.textNodeBindings)this.cleanupTextNode(e)}destroy(){this.cleanupObserver.disconnect(),this.clearAllBindings()}}class Ls{listeners=new Map;on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>this.off(e,t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,...t){const n=this.listeners.get(e);n&&n.forEach(i=>{try{i(...t)}catch(r){console.error(`Event listener error for ${e}:`,r)}})}}class Vs{subscriptionManager=new Os;stateStore={};updateQueue=new Set;isUpdating=!1;eventBus=new Ls;contextCache=new Map;previousValues=new Map;originalStateStore={};domUpdateCallbacks=[];domUpdateScheduled=!1;constructor(){this.setupGlobalStateProxy(),setInterval(()=>{this.subscriptionManager.cleanupStaleSubscriptions()},3e4)}clearSubscriptions(){const e=this.subscriptionManager.getAllSubscriptions();for(const[t]of e)this.subscriptionManager.removeSubscription(t);this.updateQueue.clear()}clearComponentSubscriptions(e){const t=this.subscriptionManager.getAllSubscriptions();for(const[n,i]of t)i.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(n=>n.startsWith(`${e}.`)).forEach(n=>{delete this.stateStore[n],delete this.originalStateStore[n],this.previousValues.delete(n)})}onDOMUpdateComplete(e){this.domUpdateCallbacks.push(e),this.domUpdateScheduled||(this.domUpdateScheduled=!0,requestAnimationFrame(()=>{requestAnimationFrame(()=>{const t=[...this.domUpdateCallbacks];this.domUpdateCallbacks=[],this.domUpdateScheduled=!1,t.forEach(n=>{try{n()}catch(i){console.error("DOM update callback error:",i)}})})}))}setInitialState(e,t){if(this.previousValues.set(e,void 0),this.originalStateStore[e]=t,this.previousValues.size>100){const n=this.previousValues.keys().next().value;typeof n=="string"&&this.previousValues.delete(n)}}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,i)=>{const r=e[t],a=Reflect.set(e,t,n,i);return r!==n&&this.notifySubscribers(t),a},get:(e,t)=>Reflect.get(e,t)})}notifySubscribers(e){if(this.eventBus.emit("stateChanged",e),this.updateQueue.add(e),e.includes(".")){const t=e.split(".")[0];this.updateQueue.add(t)}this.notifyPathBasedSubscribers(e),this.isUpdating||this.scheduleFlush()}notifyPathBasedSubscribers(e){const t=this.stateStore[e],n=this.previousValues?.get(e),i=this.subscriptionManager.getAllSubscriptions();for(const[r,a]of i)for(const o of a.dependencies)if(this.isPathDependency(o)&&o.startsWith(e+".")){const c=o.substring(e.length+1),u=this.getPathValue(n,c),p=this.getPathValue(t,c);this.deepEqual(u,p)||this.updateQueue.add(o)}}isPathDependency(e){return e.includes(".")&&e.split(".").length>1}getPathValue(e,t){if(!e||typeof e!="object")return;const n=t.split(".");let i=e;for(const r of n){if(i==null)return;if(Array.isArray(i))return r==="length"?i.length:i.map(a=>a?.[r]).filter(a=>a!==void 0);i=i[r]}return i}deepEqual(e,t){if(e===t)return!0;if(e==null||t==null)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((n,i)=>this.deepEqual(n,t[i]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),i=Object.keys(t);return n.length!==i.length?!1:n.every(r=>this.deepEqual(e[r],t[r]))}return!1}scheduleFlush=Ms(()=>{this.flushUpdates()},m.DEBOUNCE_MS);flushUpdates(){if(!this.isUpdating){this.isUpdating=!0;try{const e=new Set,t=this.subscriptionManager.getSubscriptionsForKey("*");if(t&&t.size>0&&this.updateQueue.size>0)for(const n of t){const i=this.subscriptionManager.getSubscription(n);if(!i)continue;if(i.element&&!document.contains(i.element)){this.subscriptionManager.removeSubscription(n);continue}const r=i.element??document.body;try{const a=Array.from(this.updateQueue)[0];i.callback(r,{key:a})}catch(a){console.error("Wildcard subscription callback failed:",a)}}for(const n of this.updateQueue){if(e.has(n))continue;e.add(n);const i=this.subscriptionManager.getSubscriptionsForKey(n);if(i)for(const r of i){const a=this.subscriptionManager.getSubscription(r);if(!a)continue;const o=a.element??document.body;try{a.callback(o,{key:n})}catch(c){console.error("Subscription callback failed:",c)}}}}finally{this.updateQueue.clear(),this.isUpdating=!1}}}getState(){return this.stateStore}setState(e,t){if(this.previousValues.set(e,this.stateStore[e]),this.stateStore[e]=t,this.previousValues.size>100){const n=this.previousValues.keys().next().value;typeof n=="string"&&this.previousValues.delete(n)}}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,i]of t)for(const r of i.dependencies)e.has(r)||e.set(r,new Set),e.get(r).add(n);return e}destroy(){this.clearState(),this.clearSubscriptions(),this.contextCache.clear(),this.previousValues.clear(),this.domUpdateCallbacks=[]}}class me{expressionCache=new K(m.MAX_CACHE_SIZE);dependencyCache=new K(m.MAX_CACHE_SIZE);commonExpressionsCache=new K(100);dependencyParser=new Fs;static CACHE_KEYS={EXPRESSION:(e,t)=>`expr:${e}:${t}`,DEPENDENCY:(e,t)=>`deps:${e}:${t}`,COMMON:e=>`common:${e}`};constructor(){this.precompileCommonExpressions()}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}precompileCommonExpressions(){["true","false","null","undefined"].forEach(t=>{const n={fn:new Function("return "+t),contextMap:new Map,dependencies:[t],timestamp:Date.now(),hitCount:0},i=me.CACHE_KEYS.COMMON(t);this.commonExpressionsCache.set(i,n)})}extractDependencies(e,t,n){const i=this.normalizeExpression(e),r=me.CACHE_KEYS.DEPENDENCY(t,i);let a=this.dependencyCache.get(r);return a||(a=this.dependencyParser.extract(i,t,n),this.dependencyCache.set(r,a),a)}evaluateExpression(e,t,n){const i=this.normalizeExpression(e),r=me.CACHE_KEYS.COMMON(i);let a=this.commonExpressionsCache.get(r);if(a){a.hitCount++;try{return a.fn()}catch(u){console.error(`Common expression evaluation failed: "${i}"`,u);return}}const o=me.CACHE_KEYS.EXPRESSION(n,i);a=this.expressionCache.get(o);const c=this.transformContextForEvaluation(t,i);(!a||this.isStale(a))&&(a=this.compileExpression(i,c,n),this.expressionCache.set(o,a)),a.hitCount++;try{const u=this.buildArguments(a.contextMap,c);return a.fn(...u)}catch(u){console.error(`Expression evaluation failed: "${i}"`,u),console.error("Available context:",Object.keys(c));return}}transformContextForEvaluation(e,t){const n={},i=t&&(t.includes("?")||t.includes("&&")||t.includes("||")||t.includes("===")||t.includes("!==")||t.includes("==")||t.includes("!=")||t.includes(">=")||t.includes("<=")||t.includes(">")||t.includes("<")||/^!/.test(t.trim()));for(const[r,a]of Object.entries(e))if(typeof a=="function"&&"__pphp_key"in a){const o=a.value;i||o===null||o===void 0||typeof o=="boolean"||typeof o=="string"||typeof o=="number"?n[r]=o:n[r]=a}else n[r]=a;return n}compileExpression(e,t,n){const i=this.prepareSafeContext(t),r=new Map,a=[];Object.keys(i).forEach((c,u)=>{r.set(c,u),a.push(c)});const o=this.dependencyParser.extract(e,n);return{fn:new Function(...a,`return (${e})`),contextMap:r,dependencies:o,timestamp:Date.now(),hitCount:0}}buildArguments(e,t){const n=new Array(e.size);for(const[i,r]of e)n[r]=t[i];return n}isStale(e){return Date.now()-e.timestamp>3e5}prepareSafeContext(e){const t={};for(const[n,i]of Object.entries(e))Te.has(n)||!this.isValidJavaScriptIdentifier(n)||(t[n]=i);return t}isValidJavaScriptIdentifier(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!Te.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(n=>{const i=this.expressionCache.get(n);i&&this.isStale(i)&&(this.expressionCache.delete(n),e++)}),e}}class Fs{parseCache=new K(500);extract(e,t,n){const i=this.normalizeExpression(e),r=`${t}:${i}`;if(this.parseCache.has(r))return this.parseCache.get(r);const a=this.parseExpression(i,t,n);return this.parseCache.set(r,a),a}normalizeExpression(e){return e.replace(/\r\n/g," ").replace(/\r/g," ").replace(/\n/g," ").replace(/\s+/g," ").trim()}parseExpression(e,t,n){const i=this.extractIdentifiers(e),r=[],a=n?.getState()||{};for(const c of i){if(Te.has(c))continue;const u=c.indexOf("."),p=u===-1?c:c.substring(0,u),h=qe.findExistingStateKey(p,t,a);if(h)r.push(h);else{const f=t==="app"?[`app.${p}`]:[`${t}.${p}`,`app.${p}`];r.push(...f)}if(u!==-1){const f=t==="app"?[`app.${p}`]:[`${t}.${p}`,`app.${p}`];r.push(...f)}}return Array.from(new Set(r))}extractIdentifiers(e){const t=[];let n=0;for(;n<e.length;){const i=e[n];if(i==="'"){n=this.skipString(e,n,"'");continue}if(i==='"'){n=this.skipString(e,n,'"');continue}if(i==="`"){n=this.skipTemplateLiteral(e,n,t);continue}if(this.isIdentifierStart(i)){const r=this.extractIdentifier(e,n);t.push(r.value),n=r.endIndex;continue}n++}return t}skipString(e,t,n){let i=t+1;for(;i<e.length&&e[i]!==n;)e[i]==="\\"&&i++,i++;return i+1}skipTemplateLiteral(e,t,n){let i=t+1;for(;i<e.length&&e[i]!=="`";){if(e[i]==="$"&&i+1<e.length&&e[i+1]==="{"){i+=2;let r=1;for(;i<e.length&&r>0;){const a=e[i];if(a==='"'||a==="'"){i=this.skipString(e,i,a);continue}if(a==="{"?r++:a==="}"&&r--,r>0&&this.isIdentifierStart(a)){const o=this.extractIdentifier(e,i);n.push(o.value),i=o.endIndex-1}i++}continue}e[i]==="\\"&&i++,i++}return i+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 Ds{componentStack=["app"];elementProps=new WeakMap;contextCache=new K(100);contextIndex=new Map;contextInvalidated=new Set;stateManager;processedScripts=new WeakSet;componentFunctions=new Map;expressionEvaluator;domBindingManager;loopManager;templateRenderer;updateTimeouts;updateBatcher=new ot;propDependencyCache=new Map;constructor(e){this.stateManager=e,this.updateBatcher=new ot,this.stateManager.onStateChange(t=>this.invalidateContextCache(t))}getPropDependencies(e,t){const n=this.findElementWithProps(t);if(!n)return[];const i=this.elementProps.get(n);if(!i||!i.has(e))return[];const r=i.get(e);return this.templateRenderer?.dependencies(r.expression,r.component,this.stateManager)||[]}buildRestrictedComponentContext(e,t=!1){const n={};window[e]&&Object.assign(n,window[e]);const i=this.componentFunctions.get(e);if(i)for(const[o,c]of i)n[o]=c;const r=this.stateManager.getState(),a=Object.keys(r).filter(o=>o.startsWith(e+"."));for(const o of a){const c=o.substring(e.length+1);c in n||(n[c]=r[o])}if(t){if(window.app)for(const[u,p]of Object.entries(window.app))u in n||(n[u]=p);const o=this.componentFunctions.get("app");if(o)for(const[u,p]of o)u in n||(n[u]=p);const c=Object.keys(r).filter(u=>u.startsWith("app."));for(const u of c){const p=u.substring(4);p in n||(n[p]=r[u])}}return n}getComponentPropDependencies(e,t){if(this.propDependencyCache.has(e))return this.propDependencyCache.get(e);const n=[],i=this.elementProps.get(e);i&&this.templateRenderer&&i.forEach(a=>{const o=this.templateRenderer?.dependencies(a.expression,a.component,this.stateManager);n.push(...o??[])});const r=Array.from(new Set(n));return this.propDependencyCache.set(e,r),r}setDOMBindingManager(e){this.domBindingManager=e,this.updateBatcher.setManagers(this,e)}hasStoredProps(e){return this.elementProps.has(e)&&this.elementProps.get(e).size>0}setExpressionEvaluator(e){this.expressionEvaluator=e,this.templateRenderer=new et(e),this.loopManager=new Ut(this.stateManager,e)}extractProps(e,t){const n=new Map,i=e.attributes,r=R.findScope(e),a=e.getAttribute(m.ATTR_PREFIXES.COMPONENT);let o=t;r&&(o=r==="app"?"app":r);for(let c=0;c<i.length;c++){const u=i[c];if(!(u.name===m.ATTR_PREFIXES.COMPONENT||u.name===m.ATTR_PREFIXES.SPREAD||u.name===m.ATTR_PREFIXES.LOOP)&&!de.isEventAttribute(u.name)&&u.value&&$s.containsMustacheExpression(u.value)){if(a&&this.mightReferenceSelfProps(u.value,e))continue;const p=this.attributeToPropName(u.name),h={name:p,expression:u.value,component:o,subscriptionIds:[]};n.set(p,h)}}return n}mightReferenceSelfProps(e,t){const n=this.elementProps.get(t);if(!n)return!1;const i=Array.from(n.keys()),r=M.extractExpressions(e);if(r.length===0)return!1;for(const a of r)try{const o=F(a,{ecmaVersion:2022,sourceType:"script"}),c=new Set,u=new Set;U(o,{Identifier:(p,h)=>{const f=h?.[h.length-1];f?.type==="MemberExpression"&&f.property===p&&!f.computed||(f?.type==="FunctionExpression"||f?.type==="ArrowFunctionExpression")&&(f.params||[]).includes(p)||(f?.type==="MemberExpression"&&f.object===p?u.add(p.name):c.add(p.name))}});for(const p of i){if(p==="dataState")continue;const h=c.has(p),f=u.has(p)&&!c.has(p);if(h&&!f)return!0}}catch(o){console.error(`❌ Failed to parse mustache expression "${a}":`,o);continue}return!1}attributeToPropName(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}setupProps(e,t){const n=this.extractProps(e,t);n.size!==0&&(this.elementProps.set(e,n),this.expressionEvaluator&&n.forEach((i,r)=>{this.setupPropBinding(e,i)}))}setupPropBinding(e,t){if(!this.expressionEvaluator)return;const n=`prop_${Date.now()}_${Math.random()}`,i=this.templateRenderer?.dependencies(t.expression,t.component,this.stateManager)||[],r={id:n,selector:"",dependencies:new Set(i),callback:()=>{const a=e.getAttribute(m.ATTR_PREFIXES.COMPONENT);a&&(this.updateBatcher.scheduleUpdate(a,e),this.refreshComponentBindings(e,a))},element:e,component:t.component};this.stateManager.addSubscription(r),t.subscriptionIds.push(n)}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 i=n.values().next().value;if(!i)return t;const r=this.buildComponentContext(i.component);return n.forEach((a,o)=>{try{const c=this.templateRenderer?.render(a.expression,r,a.component);typeof c=="function"?"__pphp_key"in c?t[o]=c:t[o]=(...u)=>c.apply(this,u):t[o]=c}catch(c){console.error(`❌ Failed to evaluate prop "${o}":`,c),t[o]=void 0}}),t}cleanupProps(e){const t=this.elementProps.get(e);t&&(t.forEach(n=>{n.subscriptionIds.forEach(i=>{this.stateManager.removeSubscription(i)})}),this.elementProps.delete(e))}buildComponentContextWithProps(e,t){const n=this.buildComponentContext(e);let i=this.findElementWithProps(e);if(t&&this.elementProps.has(t)&&(i=t),i)try{const r=this.evaluatePropsWithContext(i,e,t);Object.keys(r).length>0&&Object.keys(r).forEach(a=>{n[a]=r[a]})}catch(r){console.error(`❌ Error evaluating props for ${e}:`,r)}return n}buildRestrictedComponentContextWithProps(e,t){const n=this.buildRestrictedComponentContext(e,!1);if(this.elementProps.has(t)){const i=this.evaluateProps(t);Object.assign(n,i)}return n}evaluatePropsWithContext(e,t,n){const i={},r=this.elementProps.get(e);if(!r||!this.expressionEvaluator)return i;const a=r.values().next().value;if(!a)return i;const o=R.findScope(e);let c;if(o)if(o==="app")c=this.buildComponentContext("app");else{const d=this.findElementWithProps(o);d&&this.hasStoredProps(d)?c=this.buildComponentContext(o):c=this.buildRestrictedComponentContext(o,!1)}else{const d=this.findElementWithProps(a.component);d&&this.hasStoredProps(d)?c=this.buildComponentContext(a.component):c=this.buildRestrictedComponentContext(a.component,!1)}const u=this.loopManager?.getLoopContextForElement(e);u&&(c={...c,...u});const p=new Map,h=new Map,f=Array.from(r.keys());r.forEach((d,x)=>{f.some(C=>C!==x&&d.expression.includes(C))?h.set(x,d):p.set(x,d)}),p.forEach((d,x)=>{try{const b=this.templateRenderer?.render(d.expression,c,o||d.component);i[x]=b}catch(b){console.error(`❌ Failed to evaluate prop "${x}":`,b),i[x]=void 0}});const g={...c,...i};return h.forEach((d,x)=>{try{const b=this.templateRenderer?.render(d.expression,g,o||d.component);i[x]=b}catch(b){console.error(`❌ Failed to evaluate prop "${x}":`,b),i[x]=void 0}}),i}findElementWithProps(e){const t=document.querySelectorAll(`[${m.ATTR_PREFIXES.COMPONENT}="${e}"]`);for(const n of t){const i=this.elementProps.get(n);if(i&&i.size>0)return n}return null}pushComponent(e){this.componentStack.push(e)}popComponent(){return this.componentStack.pop()}getCurrentComponent(){return this.componentStack[this.componentStack.length-1]}buildComponentContext(e){if(!this.contextInvalidated.has(e)&&this.contextCache.has(e))return this.contextCache.get(e);const t=this.computeComponentContext(e);return this.contextCache.set(e,t),this.contextInvalidated.delete(e),t}computeComponentContext(e){const t={};if(e.includes("_loop_")||e.match(/_[a-zA-Z0-9]{8}$/)){const r=e.split("_");r.pop();const a=r.join("_");window[a]&&Object.assign(t,window[a])}e!=="app"&&window[e]&&Object.assign(t,window[e]),e==="app"&&window.app&&Object.assign(t,window.app);const n=this.componentFunctions.get(e);if(n)for(const[r,a]of n)t[r]=a;if(e!=="app"){const r=this.componentFunctions.get("app");if(r)for(const[a,o]of r)a in t||(t[a]=o);if(window.app)for(const[a,o]of Object.entries(window.app))a in t||(t[a]=o)}const i=this.stateManager.getState();for(const r of Object.keys(i))if(r.startsWith(e+".")){const a=r.substring(e.length+1);a in t||(t[a]=i[r])}if(e!=="app"){for(const r of Object.keys(i))if(r.startsWith("app.")){const a=r.substring(4);a in t||(t[a]=i[r])}}return t}invalidateContextCache(e){if(e.startsWith("app.")){this.contextCache.clear();for(const n of this.contextInvalidated.keys())this.contextInvalidated.add(n);return}const t=e.indexOf(".");if(t!==-1){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(m.ATTR_PREFIXES.COMPONENT),i=e===document.body;if(n||i){if(n){this.pushComponent(n);const a=this.getParentComponent(e);this.setupProps(e,a)}this.getRelevantScripts(e,i).forEach(a=>{const o=a.getAttribute(m.ATTR_PREFIXES.COMPONENT);o&&o!==n?(this.pushComponent(o),this.executeScript(a),this.popComponent()):this.executeScript(a)})}for(Array.from(e.children).forEach(r=>this.executePhpScripts(r));this.componentStack.length>t;)this.popComponent()}getParentComponent(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(n)return n;t=t.parentElement}return"app"}getRelevantScripts(e,t){return Array.from(e.querySelectorAll(`script[type="${m.SCRIPT_TYPE}"]`)).filter(n=>{if(this.processedScripts.has(n))return!1;if(t)return n.hasAttribute(m.ATTR_PREFIXES.COMPONENT)?!0:!n.closest(`[${m.ATTR_PREFIXES.COMPONENT}]`);let i=n.parentElement;for(;i&&i!==e;){if(i.hasAttribute(m.ATTR_PREFIXES.COMPONENT))return!1;i=i.parentElement}return i===e||e.contains(n)})}executeScript(e){if(this.processedScripts.has(e))return;this.processedScripts.add(e);const t=this.getCurrentComponent(),n=e.textContent||"",i=M.decodeEntities(n);try{const r=this.findComponentElementForScript(e,t);if(r===e){const c=this.getParentComponent(e);this.setupProps(e,c)}const a=this.hasExplicitContext(r||e,t);let o;if(a)o=this.buildComponentContextWithProps(t,r);else if(o=this.buildRestrictedComponentContext(t,!1),r&&this.hasStoredProps(r)){const c=this.evaluateProps(r);Object.assign(o,c)}window[t]||(window[t]={}),this.executeScriptFunctions(i,t,o)}catch(r){console.error(`Script execution failed in component ${t}:`,r),console.error("Script content:",i)}}hasExplicitContext(e,t){return R.findScope(e)!==null}findComponentElementForScript(e,t){if(e.getAttribute(m.ATTR_PREFIXES.COMPONENT)===t)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(m.ATTR_PREFIXES.COMPONENT)===t)return n;n=n.parentElement}const i=document.querySelectorAll(`[${m.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const r of i)if(this.elementProps.has(r))return r;return i[0]||void 0}executeScriptFunctions(e,t,n){const i=this.extractFunctionNames(e),r=this.findElementWithProps(t),a=this.extractVariableDeclarations(e);let o={...n};if(a.forEach(x=>{delete o[x];const b=`set${Ht(x)}`,C=`${x}Getter`;delete o[b],delete o[C]}),r){const x=this.evaluateProps(r);Object.assign(o,x)}o.getContext=()=>this.buildComponentContextWithProps(t),o.withContext=x=>{const b=this.buildComponentContextWithProps(t);return x.call(b,b)},o.__getProp=x=>{if(r)return this.evaluateProps(r)[x]};const c=Z.getInstance(),u=new Set;if(r){const x=this.evaluateProps(r);for(const[b,C]of Object.entries(x))typeof C=="function"&&"__pphp_key"in C&&(u.add(b),/^set[A-Z]/.test(b)&&u.add(b))}let p=c.transformStateDeclarations(e,u);p=this.modifyScriptForReactiveProps(p,t,r||void 0);const h=`
17
- ${p}
18
-
19
- ${i.map(x=>`
20
- if (typeof ${x} === 'function') {
21
- this['${x}'] = ${x};
22
- }
23
- `).join(`
24
- `)}
25
- `,f=Object.keys(o),g=f.map(x=>o[x]);if(this.checkIfInLoopItem()){const x=this.extractLoopItemContext();this.domBindingManager.stateManager.currentLoopContext=x}try{new Function(...f,h).call(window[t],...g),window[t].getContext=o.getContext,window[t].withContext=o.withContext,window[t].__getProp=o.__getProp;for(const b of i){const C=window[t][b];typeof C=="function"&&this.storeFunctionForComponent(t,b,C)}this.invalidateComponent(t)}catch(x){console.error("Script execution failed:",x),console.error("Component:",t),console.error("Original script:",e),console.error("Processed script:",p),console.error("Execution context keys:",Object.keys(o))}finally{this.domBindingManager.stateManager.currentLoopContext=null}}checkIfInLoopItem(){return!1}extractLoopItemContext(){return{}}extractVariableDeclarations(e){const i=Z.getInstance().extractStateDeclarations(e).map(u=>u.variableName),r=[],a=/(?:const|let|var)\s*\[\s*([^,\]]+)(?:\s*,\s*([^,\]]+))?\s*\]/g;let o;for(;(o=a.exec(e))!==null;)o[1]&&!i.includes(o[1].trim())&&r.push(o[1].trim()),o[2]&&!i.includes(o[2].trim())&&r.push(o[2].trim());const c=/(?:const|let|var)\s+([a-zA-Z_$][\w$]*)/g;for(;(o=c.exec(e))!==null;)i.includes(o[1])||r.push(o[1]);return[...i,...r]}modifyScriptForReactiveProps(e,t,n){if(!n||!this.elementProps.has(n))return e;const i=this.elementProps.get(n),r=Array.from(i.keys());let a=e;return r.forEach(o=>{a=this.replacePropOutsideStrings(a,o)}),a}replacePropOutsideStrings(e,t){let n="",i=0;const r=e.length;for(;i<r;){const a=e[i];if(a==="'"){const o=this.findStringEnd(e,i,"'");n+=e.slice(i,o+1),i=o+1;continue}if(a==='"'){const o=this.findStringEnd(e,i,'"');n+=e.slice(i,o+1),i=o+1;continue}if(a==="`"){const o=this.findTemplateEnd(e,i);n+=e.slice(i,o+1),i=o+1;continue}if(a==="/"&&i+1<r){if(e[i+1]==="/"){const o=e.indexOf(`
26
- `,i),c=o===-1?r:o;n+=e.slice(i,c),i=c;continue}else if(e[i+1]==="*"){const o=e.indexOf("*/",i+2),c=o===-1?r:o+2;n+=e.slice(i,c),i=c;continue}}this.matchesPropName(e,i,t)?(n+=`__getProp('${t}')`,i+=t.length):(n+=a,i++)}return n}findStringEnd(e,t,n){let i=t+1;for(;i<e.length;){if(e[i]===n&&e[i-1]!=="\\")return i;e[i]==="\\"&&i++,i++}return e.length-1}findTemplateEnd(e,t){let n=t+1,i=0;for(;n<e.length;){const r=e[n];if(r==="`"&&i===0)return n;r==="$"&&n+1<e.length&&e[n+1]==="{"?(i++,n++):r==="}"&&i>0?i--:r==="\\"&&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 r=t>0?e[t-1]:"",a=t+n.length<e.length?e[t+n.length]:"",o=t===0||!/[a-zA-Z0-9_$]/.test(r),c=t+n.length===e.length||!/[a-zA-Z0-9_$]/.test(a);if(!o||!c||r==="."||a===".")return!1;const u=e.slice(t+n.length);if(/^\s*[=:]/.test(u))return!1;const p=e.slice(Math.max(0,t-20),t);return!/[a-zA-Z0-9_$]\s*\.\s*$/.test(p)}extractFunctionNames(e){return Z.getInstance().extractFunctionNames(e)}storeFunctionForComponent(e,t,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 Bs{stateManager;componentManager;expressionEvaluator;textNodeManager;observer;listeners=new WeakMap;pendingBindings=[];pendingTextNodes=[];applyingUpdates=!1;elementCache=new WeakMap;batchedUpdates=new Set;processingRAF=null;updateQueue=new Map;eventDelegation=new ce;processedElements=new WeakSet;loopManager;templateRenderer;BOOL_REFLECTED={checked:"checked",disabled:"disabled",hidden:"hidden",readonly:"readOnly",required:"required",multiple:"multiple",selected:"selected",autofocus:"autofocus",autoplay:"autoplay",controls:"controls",defer:"defer",loop:"loop",muted:"muted",open:"open",reversed:"reversed",async:"async",default:"default",formnovalidate:"formNoValidate",novalidate:"noValidate",allowfullscreen:"allowFullscreen",capture:"capture",itemscope:"itemScope"};lastValueCache=new WeakMap;stringValueCache=new K(500);refBindings=new WeakMap;constructor(e,t,n){this.stateManager=e,this.componentManager=t,this.expressionEvaluator=n,this.textNodeManager=new Rs(n,e),this.textNodeManager.componentManager=this.componentManager,this.componentManager.setDOMBindingManager(this),this.setupMutationObserver(),this.eventDelegation.setupEventDelegation(),this.loopManager=new Ut(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 et(n)}refreshComponentElement(e,t){this.elementCache.delete(e),this.processedElements.delete(e);const n=[...this.componentManager.componentStack];this.componentManager.componentStack=["app"],t!=="app"&&this.componentManager.componentStack.push(t);try{const i=this.componentManager.buildComponentContextWithProps(t,e);this.processElementInContext(e,i,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:a=>{const o=a;return!o.textContent||!m.MUSTACHE_PATTERN.test(o.textContent)||P.isTextNodeInsideScript(o)||this.isTextNodeInsideLoopItem(o)||P.getComponentForNode(o)!==t?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let i;const r=[];for(;i=n.nextNode();)r.push(i);r.forEach(a=>{this.textNodeManager.cleanupTextNode(a),this.textNodeManager.cleanupTextNode(a),this.textNodeManager.processTextNode(a,t)})}walkComponentChildren(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const o=a;return P.getElementComponent(o)!==t?NodeFilter.FILTER_REJECT:o===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}});let i;const r=[];for(;i=n.nextNode();){const a=i;r.push(a)}r.forEach(a=>{this.elementCache.delete(a),this.processedElements.delete(a);const o=this.componentManager.buildComponentContextWithProps(t,e);this.processElementInContext(a,o,t,!0)})}createSpreadDirectiveBinding(e,t,n){const i=`spread_${Date.now()}_${Math.random()}`,r=M.parseSpreadDirective(t);if(r.spreads.length===0&&r.objects.length===0){console.warn(`Invalid pp-spread directive: ${t}`);return}const a=new Set,o=()=>{if(!document.contains(e)){this.stateManager.removeSubscription(i);return}try{const p=this.componentManager.buildComponentContextWithProps(n,e);this.clearSpreadAttributes(e,a);for(const h of r.spreads){const f=this.expressionEvaluator.evaluateExpression(h,p,n);f&&typeof f=="object"&&this.applySpreadObject(e,f,a)}for(const h of r.objects)this.applyObjectProperties(e,h,p,n,a)}catch(p){console.error(`Spread directive evaluation error for "${t}":`,p)}},c=new Set;for(const p of r.spreads)this.templateRenderer.dependencies(p,n,this.stateManager).forEach(f=>c.add(f));for(const p of r.objects)for(const h of p)this.templateRenderer.dependencies(h.value,n,this.stateManager).forEach(g=>c.add(g));const u={id:i,selector:"",dependencies:c,callback:o,element:e,component:n};this.stateManager.addSubscription(u),this.storeSpreadSubscription(e,i),o()}applyObjectProperties(e,t,n,i,r){for(const a of t)try{const o=this.expressionEvaluator.evaluateExpression(a.value,n,i);if(this.isEventProperty(a.key)){this.handleSpreadEventProperty(e,a.key,o);continue}const c=this.normalizeAttributeName(a.key);this.updateElementProperty(e,c,o),r.add(c)}catch(o){console.error(`Error evaluating object property "${a.key}: ${a.value}":`,o)}}applySpreadObject(e,t,n){for(const[i,r]of Object.entries(t))if(r!=null){if(this.isEventProperty(i)){this.handleSpreadEventProperty(e,i,r);continue}const a=this.normalizeAttributeName(i);(!e.hasAttribute(a)||n.has(a))&&(this.updateElementProperty(e,a,r),n.add(a))}}isEventProperty(e){return e.startsWith("on")&&e.length>2}handleSpreadEventProperty(e,t,n){const i=t.substring(2).toLowerCase();if(typeof n=="function"){const r=a=>{try{const o=P.getContextComponent(e),c=this.componentManager?.buildComponentContextWithProps(o,e)||{};n.call(c,a)}catch(o){console.error("Spread event handler error:",o)}};e.addEventListener(i,r),this.storeDirectEventListener(e,i,r);return}if(typeof n=="string"){const r=P.getContextComponent(e);this.eventDelegation.registerEventHandler(e,i,n,r)}}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(t.length===0)return;const n=W.getInstance();for(const i of t)if(i.type==="childList"&&(i.removedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const a=r;this.cleanupRefBinding(a),a.querySelectorAll("[pp-ref]").forEach(u=>{this.cleanupRefBinding(u)}),n.invalidateElement(a);const c=a.getAttribute(m.ATTR_PREFIXES.COMPONENT);c&&n.invalidateByComponent(c)}}),i.addedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const o=r.getAttribute(m.ATTR_PREFIXES.COMPONENT);o&&n.invalidateByComponent(o)}})),i.type==="attributes"&&i.target){const r=i.target;n.invalidateElement(r);const a=r.getAttribute(m.ATTR_PREFIXES.COMPONENT);a&&n.invalidateByComponent(a)}this.processMutationsBatch(t)}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0,attributeFilter:[m.ATTR_PREFIXES.COMPONENT]})}isRelevantMutation=e=>{if(this.applyingUpdates&&e.type==="attributes")return!1;if(e.type==="childList"||e.type==="characterData")return!0;if(e.type==="attributes"){const t=e.attributeName;return t===m.ATTR_PREFIXES.COMPONENT||t!==null&&de.isEventAttribute(t)}return!1};processElement(e,t=!0){if(e===document.body){const i=Array.from(document.querySelectorAll(`[${m.ATTR_PREFIXES.COMPONENT}]`)).sort((r,a)=>{const o=P.getElementDepth(r),c=P.getElementDepth(a);return o-c});this.processElementsBatch([e],t),i.forEach(r=>{this.processElementsBatch([r],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(n=>{this.componentManager.executePhpScripts(n)}),this.processPendingBindings())}processSingleElement(e,t){const n=P.getElementComponent(e),i=R.findScope(e);let r;i?i==="app"?r="app":r=i:r=P.getParentComponentForElement(e);const a=this.componentManager.componentStack.length;n!=="app"&&this.componentManager.pushComponent(n),this.componentManager.setupProps(e,r),t&&this.componentManager.executePhpScripts(e),this.processLoopTemplates(e,n);const o=t?this.componentManager.buildComponentContextWithProps(n,e):{};for(this.processElementInContext(e,o,n,t),this.walkDOM(e,o,n,t);this.componentManager.componentStack.length>a;)this.componentManager.popComponent()}processLoopTemplates(e,t){this.getDirectComponentTemplates(e,t).forEach(i=>{this.loopManager.queueTemplate(i,t)})}getDirectComponentTemplates(e,t){const n=[],i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:a=>{const o=a;return o!==e&&o.hasAttribute(m.ATTR_PREFIXES.COMPONENT)?NodeFilter.FILTER_REJECT:o.tagName==="TEMPLATE"&&o.hasAttribute("pp-for")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let r;for(;r=i.nextNode();)n.push(r);return n}walkDOM(e,t,n,i){const r=fe.getInstance(),a=`walkDOM_${n}_${i}`,o=r.getCachedTraversal(e,a,()=>{const p=r.traverseElementsAndText(e,h=>{if(h===e||h.tagName.toLowerCase()==="script"||this.loopManager.isLoopItem(h))return!1;let f=h.parentElement;for(;f&&f!==e;){if(this.loopManager.isLoopItem(f))return!1;f=f.parentElement}return!(P.getElementComponent(h)!==n||this.processedElements.has(h))},h=>{if(!h.textContent||!m.MUSTACHE_PATTERN.test(h.textContent)||P.isTextNodeInsideScript(h)||this.isTextNodeInsideLoopItem(h))return!1;const f=h.parentElement;if(f){const g=P.getContextComponent(f),d=P.getComponentForNode(h);if(g!==n&&d!==n)return!1}else if(P.getComponentForNode(h)!==n)return!1;return!0});return[...p.textNodes,...p.elements]}),c=[],u=[];o.forEach(p=>{if(p.nodeType===Node.TEXT_NODE)c.push(p);else if(p.nodeType===Node.ELEMENT_NODE){const h=p;if(h.hasAttribute("pp-ref")&&i){const f=h.getAttribute("pp-ref");this.createRefBinding(h,f,n),h.removeAttribute("pp-ref")}u.push(h),this.processedElements.add(h)}}),c.forEach(p=>{const h=p.parentElement,f=h?P.getContextComponent(h):n;i?this.textNodeManager.processTextNode(p,f):this.pendingTextNodes.push({textNode:p,component:f})}),u.forEach(p=>{this.processElementInContext(p,t,n,i)})}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,i){if(e.hasAttribute("pp-ref")){const u=e.getAttribute("pp-ref");i&&this.createRefBinding(e,u,n),e.removeAttribute("pp-ref")}if(e.hasAttribute(m.ATTR_PREFIXES.SPREAD)){const u=e.getAttribute(m.ATTR_PREFIXES.SPREAD);i&&this.createSpreadDirectiveBinding(e,u,n),e.removeAttribute(m.ATTR_PREFIXES.SPREAD)}if(this.loopManager.isLoopItem(e)||this.isElementInLoopItem(e))return;const r=this.extractDomMustacheBindings(e),a=this.elementCache.get(e),o=this.getElementHash(e);if(a&&a.hash===o&&this.isCacheValid(a)&&i){this.applyBindingsFromCache(e,a,t);return}const c={bindings:r,component:n,listeners:[],lastProcessed:Date.now(),hash:o};i?this.applyBindings(e,r,t,n):r.forEach((u,p)=>{this.pendingBindings.push({element:e,property:p,expression:u,component:n})}),this.setupEventBindings(e,n),this.elementCache.set(e,c)}createRefBinding(e,t,n){try{const i=M.decodeEntities(t),r=M.isSingleExpression(i)||i,a=P.getContextComponent(e),o=this.componentManager.buildComponentContextWithProps(a,e);try{const c=this.expressionEvaluator.evaluateExpression(r,o,a);if(typeof c=="function"){const u=c;this.refBindings.set(e,{element:e,callback:u,component:a}),u(e)}else if(c&&typeof c=="object"&&"current"in c){const u=c;this.refBindings.set(e,{element:e,refObject:u,component:a}),u.current=e}else console.warn(`⚠️ pp-ref expression did not return a ref object or callback: ${r}`,c)}catch(c){console.error(`❌ Failed to evaluate ref "${r}":`,c)}}catch(i){console.error(`❌ Failed to create ref binding for "${t}":`,i)}}isElementInLoopItem(e){let t=e;for(;t;){if(this.loopManager.isLoopItem(t))return!0;t=t.parentElement}return!1}extractDomMustacheBindings(e){const t=new Map,n=e.attributes,i=this.elementCache.get(e),r=R.findScope(e),a=e.getAttribute(m.ATTR_PREFIXES.COMPONENT),o=a&&this.componentManager?.hasStoredProps(e),c=r&&a&&r!==a;for(let u=0;u<n.length;u++){const p=n[u];if(!(p.name===m.ATTR_PREFIXES.COMPONENT||p.name==="key"||de.isEventAttribute(p.name))&&!(i&&i.bindings.has(p.name))&&p.value){const h=m.MUSTACHE_PATTERN.test(p.value),f=M.decodeEntities(p.value),g=m.MUSTACHE_PATTERN.test(f);if(h||g){if(this.looksLikeSerializedObject(f))continue;const d=M.extractExpressions(f),x=P.getContextComponent(e);if(d.length===0&&(h||g)){console.error(`
27
- ❌ Malformed mustache expression in attribute "${p.name}":`),console.error(` Value: ${f}`),console.error(" Element:",e),console.error(` Component: ${x}`),console.error(" 💡 The expression has mustache syntax {} but couldn't be parsed"),console.error(` 💡 Common causes: unmatched quotes, unclosed braces, invalid syntax
28
- `),o||c&&P.shouldBeDirectBinding(e,p.name)?t.set(p.name,f):c||t.set(p.name,f);continue}for(const b of d){const C=Is.validate(b,x);C.valid||(console.error(`
29
- ❌ Invalid expression in attribute "${p.name}":`),console.error(` Expression: ${b}`),console.error(` Original HTML: ${p.value}`),console.error(` Decoded: ${f}`),console.error(" Element:",e),console.error(` Component: ${x}`),C.errors.forEach(S=>{console.error(` ⚠️ ${S}`)}),console.error(" 💡 Hint: Check your quotes and syntax in conditional expressions"),console.error(` 💡 Example: class="{isActive ? 'text-blue-500' : 'text-gray-500'}"
30
- `)),C.warnings.length>0&&(console.warn(`
31
- ⚠️ Expression warnings in attribute "${p.name}":`),console.warn(` Expression: ${b}`),console.warn(" Element:",e),C.warnings.forEach(S=>{console.warn(` • ${S}`)}))}o||c&&P.shouldBeDirectBinding(e,p.name)?t.set(p.name,f):c||t.set(p.name,f)}}}return t}applyBindings(e,t,n,i){t.forEach((r,a)=>{this.createMustacheBinding(e,a,r)}),this.setupEventBindings(e,i)}applyBindingsFromCache(e,t,n){t.bindings.forEach((i,r)=>{try{const a=this.componentManager.buildComponentContextWithProps(t.component,e),o=this.templateRenderer.render(i,a,t.component);this.updateElementProperty(e,r,o)}catch(a){console.error(`Cached binding evaluation error for "${i}":`,a)}})}createMustacheBinding(e,t,n){const i=`mustache_${Date.now()}_${Math.random()}`,r=R.findScope(e),o=e.getAttribute(m.ATTR_PREFIXES.COMPONENT)!==null;let c,u=!1,p=!1;r?(c=r==="app"?"app":r,p=!0,u=!1):o?(c=P.getParentComponentForElement(e),u=!0,p=!1):(c=P.getContextComponent(e),u=!1,p=!1),e.removeAttribute(t);let h=null,f=e.parentElement;for(;f&&f!==document.body;){if(f.hasAttribute(m.ATTR_PREFIXES.COMPONENT)){h=f;break}f=f.parentElement}const g=this.templateRenderer.dependencies(n,c,this.stateManager),d=new Set(g),x=this.findComponentElementForMustacheBinding(e,c);if(x&&this.componentManager){const S=this.componentManager.elementProps.get(x);if(S)for(const V of g){const N=V.split("."),k=N[N.length-1];if(S.has(k)){const O=S.get(k);this.templateRenderer.dependencies(O.expression,O.component,this.stateManager).forEach($=>d.add($))}}}if(h&&h!==x&&this.componentManager&&this.componentManager.hasStoredProps(h)){const S=this.componentManager.elementProps.get(h);if(S)for(const V of g){const N=V.split("."),k=N[N.length-1];if(S.has(k)){const O=S.get(k);this.templateRenderer.dependencies(O.expression,O.component,this.stateManager).forEach($=>d.add($))}}}const b=()=>{if(!document.contains(e)){this.stateManager.removeSubscription(i);return}try{let S;if(p){if(S=this.componentManager.buildComponentContextWithProps(c,x||void 0),e!==x&&o&&this.componentManager.elementProps.get(e)){const k=this.componentManager.evaluateProps(e);S={...S,...k}}}else if(u){let N=null,k=e.parentElement;for(;k&&k!==document.body;){if(k.getAttribute(m.ATTR_PREFIXES.COMPONENT)===c){N=k;break}k=k.parentElement}if(S=this.componentManager.buildComponentContextWithProps(c,N||void 0),e!==N&&this.componentManager.hasStoredProps(e)){const O=this.componentManager.evaluatePropsWithContext(e,c,e);S={...S,...O}}}else{const N=this.findComponentElementForMustacheBinding(e,c);if(N){if(S=this.componentManager.buildRestrictedComponentContextWithProps(c,N),e!==N&&this.componentManager.hasStoredProps(e)){const k=this.componentManager.evaluatePropsWithContext(e,c,e);S={...S,...k}}}else{if(S=this.componentManager.buildRestrictedComponentContext(c,!1),N&&this.componentManager.hasStoredProps(N)){const k=this.componentManager.evaluateProps(N);Object.assign(S,k)}if(e!==N&&this.componentManager.hasStoredProps(e)){const k=this.componentManager.evaluatePropsWithContext(e,c,e);Object.assign(S,k)}}}if(h&&this.componentManager&&this.componentManager.hasStoredProps(h)){const N=this.componentManager.evaluateProps(h);S={...S,...N}}const V=this.templateRenderer.render(n,S,c);this.scheduleElementUpdate(e,t,V)}catch(S){console.error(`Mustache binding evaluation error for "${n}":`,S),console.error(`Context component: ${c}`),console.error(`Use strict scope: ${p}`)}},C={id:i,selector:"",dependencies:d,callback:b,element:e,component:c};this.stateManager.addSubscription(C),b()}findComponentElementForMustacheBinding(e,t){if(e.getAttribute(m.ATTR_PREFIXES.COMPONENT)===t)return e;let i=e.parentElement;for(;i;){if(i.getAttribute(m.ATTR_PREFIXES.COMPONENT)===t)return i;i=i.parentElement}const r=document.querySelectorAll(`[${m.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const a of r)if(this.componentManager&&this.componentManager.hasStoredProps(a))return a;return r[0]||null}setupEventBindings(e,t){for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n];if(de.isEventAttribute(i.name)){const r=i.name.substring(2),a=t;this.eventDelegation.registerEventHandler(e,r,i.value,a),e.removeAttribute(i.name)}}}scheduleElementUpdate(e,t,n){if(this.isCriticalProperty(t)){this.updateElementProperty(e,t,n);return}this.updateQueue.has(e)||(this.updateQueue.set(e,new Set),this.batchedUpdates.add(e)),this.updateQueue.get(e).add(t),this.processingRAF||(this.processingRAF=requestAnimationFrame(()=>{this.processBatchedElementUpdates()})),e[`__pending_${t}`]=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 i=e[`__pending_${n}`];this.updateElementProperty(e,n,i),delete e[`__pending_${n}`]}}}finally{this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF=null,this.applyingUpdates=!1}}updateElementProperty(e,t,n){const i=Ue(n),r=this.lastValueCache.get(e);if(r&&this.isSameValue(r.get(t),i))return;const a=this.applyingUpdates;this.applyingUpdates=!0;try{switch(t){case"textContent":const o=this.cachedValueToString(i);e.textContent!==o&&(e.textContent=o);break;case"innerHTML":const c=this.cachedValueToString(i);e.innerHTML!==c&&(e.innerHTML=c);break;case"value":const u=this.cachedValueToString(i);e instanceof HTMLOptionElement?e.value!==u&&(e.value=u,e.setAttribute("value",u)):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.value!==u&&(e.value=u);break;case"selectedIndex":if(e instanceof HTMLSelectElement){const h=Number(i);e.selectedIndex!==h&&(e.selectedIndex=h)}break;case"checked":case"disabled":case"hidden":case"readonly":case"required":case"multiple":case"selected":case"autofocus":case"autoplay":case"controls":case"defer":case"loop":case"muted":case"open":case"reversed":case"async":case"default":case"formnovalidate":case"novalidate":case"allowfullscreen":case"capture":case"itemscope":this.setBooleanProperty(e,t,i);break;case"indeterminate":if(e instanceof HTMLInputElement&&e.type==="checkbox"){const h=!!i;e.indeterminate!==h&&(e.indeterminate=h)}break;case"class":case"className":const p=this.cachedValueToString(i);e instanceof SVGElement?e.getAttribute("class")!==p&&e.setAttribute("class",p):e.className!==p&&(e.className=p);break;case"htmlFor":case"for":if(e instanceof HTMLLabelElement){const h=this.cachedValueToString(i);e.htmlFor!==h&&(e.htmlFor=h)}break;case"style":if(e instanceof HTMLElement)if(typeof i=="object"&&i&&!Array.isArray(i))this.updateStyleObject(e,i);else{const h=this.cachedValueToString(i);e.style.cssText!==h&&(e.style.cssText=h)}break;case"tabIndex":if(e instanceof HTMLElement){const h=i==null?-1:Number(i);e.tabIndex!==h&&(e.tabIndex=h)}break;case"contentEditable":if(e instanceof HTMLElement){const h=i===!0?"true":i===!1?"false":String(i);e.contentEditable!==h&&(e.contentEditable=h)}break;case"draggable":if(e instanceof HTMLElement){const h=i===!0,f=h?"true":"false";e.draggable!==h&&(e.draggable=h,e.setAttribute("draggable",f))}break;case"spellcheck":if(e instanceof HTMLElement){const h=!!i,f=h?"true":"false";e.spellcheck!==h&&(e.spellcheck=h,e.setAttribute("spellcheck",f))}break;case"src":case"href":case"action":case"alt":case"title":case"placeholder":case"id":case"name":case"type":case"method":case"target":case"rel":case"pattern":case"accept":case"autocomplete":case"enctype":case"wrap":case"download":case"ping":case"referrerpolicy":case"crossorigin":case"integrity":case"loading":case"decoding":case"srcset":case"sizes":case"dir":case"lang":case"translate":case"role":this.setStringAttribute(e,t,i);break;case"min":case"max":case"step":case"maxLength":case"minLength":case"size":case"rows":case"cols":case"rowSpan":case"colSpan":this.setNumericAttribute(e,t,i);break;default:t.startsWith("aria-")?this.setAriaAttribute(e,t,i):t.startsWith("data-")?this.setDataAttribute(e,t,i):this.setGenericAttribute(e,t,i);break}this.updateValueCache(e,t,i)}catch(o){console.error(`Failed to update property "${t}" on element:`,e,o)}finally{this.applyingUpdates=a}}looksLikeSerializedObject(e){const t=e.startsWith("{")&&e.endsWith("}"),n=e.startsWith("[")&&e.endsWith("]");if(!t&&!n)return!1;try{const i=JSON.parse(e);return typeof i=="object"&&i!==null&&(Array.isArray(i)||Object.keys(i).length>0)}catch{return!1}}cachedValueToString(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(e==null)return"";if(typeof e=="boolean")return e?"true":"false";if(this.stringValueCache.has(e))return this.stringValueCache.get(e);const t=ue(e);return this.stringValueCache.set(e,t),t}isSameValue(e,t){if(e===t)return!0;if(typeof e=="object"&&typeof t=="object"){if(e===null||t===null)return e===t;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,i)=>n===t[i]);if(this.isStyleObject(e)&&this.isStyleObject(t)){const n=Object.keys(e),i=Object.keys(t);return n.length===i.length&&n.every(r=>e[r]===t[r])}}return!1}isStyleObject(e){return e&&typeof e=="object"&&!Array.isArray(e)}setBooleanProperty(e,t,n){const i=!!n;this.setBooleanProp(e,t,n)||(i&&!e.hasAttribute(t)?e.setAttribute(t,""):!i&&e.hasAttribute(t)&&e.removeAttribute(t))}updateStyleObject(e,t){const n=this.lastValueCache.get(e)?.get("style"),i=n&&typeof n=="object"?n:{};for(const[r,a]of Object.entries(t))i[r]!==a&&(e.style[r]=a)}setStringAttribute(e,t,n){const i=this.cachedValueToString(n);e.getAttribute(t)!==i&&(n==null?e.removeAttribute(t):e.setAttribute(t,i))}setNumericAttribute(e,t,n){const i=String(n);e.getAttribute(t)!==i&&(n==null?e.removeAttribute(t):e.setAttribute(t,i))}setAriaAttribute(e,t,n){const i=this.cachedValueToString(n);e.getAttribute(t)!==i&&(n==null||n===!1?e.removeAttribute(t):e.setAttribute(t,i))}setDataAttribute(e,t,n){const i=this.cachedValueToString(n);e.getAttribute(t)!==i&&(n==null?e.removeAttribute(t):e.setAttribute(t,i))}setGenericAttribute(e,t,n){const i=this.cachedValueToString(n);e.getAttribute(t)!==i&&(n==null||n===!1?e.removeAttribute(t):e.setAttribute(t,i))}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 i=this.BOOL_REFLECTED[t];if(!i)return!1;const r=!!n;return e instanceof HTMLElement&&i in e?(e[i]!==r&&(e[i]=r),!0):(r?e.hasAttribute(t)||e.setAttribute(t,""):e.hasAttribute(t)&&e.removeAttribute(t),!0)}processPendingBindings(){const e=[...this.pendingBindings];this.pendingBindings=[];const t=new Map;for(const n of e)t.has(n.component)||t.set(n.component,[]),t.get(n.component).push(n);for(const[n,i]of t){const r=[...this.componentManager.componentStack];n!=="app"?this.componentManager.componentStack=["app",n]:this.componentManager.componentStack=["app"];for(const a of i)try{if(!document.contains(a.element))continue;this.createMustacheBinding(a.element,a.property,a.expression)}catch(o){console.error(`❌ Failed to create binding for ${n}:`,o)}this.componentManager.componentStack=r}this.processTextNodesPending()}processTextNodesPending(){const e=new Map;for(const t of this.pendingTextNodes)e.has(t.component)||e.set(t.component,[]),e.get(t.component).push(t);this.pendingTextNodes=[];for(const[t,n]of e){const i=[...this.componentManager.componentStack];t!=="app"?this.componentManager.componentStack=["app",t]:this.componentManager.componentStack=["app"];for(const{textNode:r,component:a}of n)if(document.contains(r))try{this.textNodeManager.processTextNode(r,a)}catch(o){console.error(`❌ Failed to process text node for ${a}:`,o)}this.componentManager.componentStack=i}}processMutationsBatch(e){const t=new Set,n=new Set,i=new Set,r=new Set,a=new Set;for(const o of e)if(o.type==="childList"&&(o.addedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE)t.add(c);else if(c.nodeType===Node.TEXT_NODE){const u=c;u.textContent&&m.MUSTACHE_PATTERN.test(u.textContent)&&a.add(u)}}),o.removedNodes.forEach(c=>{if(c.nodeType===Node.ELEMENT_NODE)n.add(c);else if(c.nodeType===Node.TEXT_NODE){const u=c;u.textContent&&m.MUSTACHE_PATTERN.test(u.textContent)&&(document.contains(u)||this.textNodeManager.cleanupTextNode(u))}})),o.type==="attributes"&&o.target&&r.add(o.target),o.type==="characterData"&&o.target){const c=o.target;c.textContent&&m.MUSTACHE_PATTERN.test(c.textContent)&&a.add(c)}for(const o of n)(t.has(o)||document.contains(o))&&(i.add(o),n.delete(o),t.has(o)&&t.delete(o));n.size>0&&this.cleanupElementsBatch(Array.from(n)),t.size>0&&this.processElementsBatch(Array.from(t)),a.size>0&&this.processTextNodesBatch(Array.from(a)),r.size>0&&this.rebindChangedElements(Array.from(r))}processTextNodesBatch(e){const t=new Map;for(const n of e){const i=P.getComponentForNode(n);t.has(i)||t.set(i,[]),t.get(i).push(n)}for(const[n,i]of t)i.forEach(r=>{this.textNodeManager.processTextNode(r,n)})}rebindChangedElements(e){e.forEach(t=>{this.processElementBindings(t,!0)})}processElementBindings(e,t=!0){const n=this.extractDomMustacheBindings(e),i=P.getElementComponent(e);n.forEach((r,a)=>{t?this.createMustacheBinding(e,a,r):this.pendingBindings.push({element:e,property:a,expression:r,component:i})}),t&&this.setupEventBindings(e,i)}cleanupElementsBatch(e){e.forEach(t=>this.cleanupElement(t))}cleanupElement(e){this.cleanupRefBinding(e),this.stateManager.subscriptionManager?.cleanupElement(e);const t=this.listeners.get(e)||[];for(const{type:u,fn:p}of t)e.removeEventListener(u,p);this.listeners.delete(e),this.elementCache.delete(e),this.processedElements.delete(e),this.componentManager.cleanupProps(e);const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);let i;for(;i=n.nextNode();)this.textNodeManager.cleanupTextNode(i);e.tagName==="TEMPLATE"&&e.hasAttribute("pp-for")&&this.loopManager.cleanupTemplate(e),e.querySelectorAll("template[pp-for]").forEach(u=>{this.loopManager.cleanupTemplate(u)});const a=e.__directEventListeners;a&&(a.forEach(({eventType:u,listener:p})=>{e.removeEventListener(u,p)}),delete e.__directEventListeners);const o=e.__spreadEventHandlers;o&&(o.forEach(u=>{window.__spreadHandlers&&window.__spreadHandlers.delete(u)}),delete e.__spreadEventHandlers);const c=e.__spreadSubscriptions;c&&(c.forEach(u=>{this.stateManager.removeSubscription(u)}),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(n){console.error("Failed to cleanup ref:",n)}this.refBindings.delete(e)}}getElementHash(e){const t=[];for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n];(i.name===m.ATTR_PREFIXES.COMPONENT||de.isEventAttribute(i.name)||i.value&&m.MUSTACHE_PATTERN.test(i.value))&&t.push(`${i.name}=${i.value}`)}return t.sort().join("|")}isCacheValid(e){return Date.now()-e.lastProcessed<3e4}refreshAllBindings(){this.elementCache=new WeakMap,this.processedElements=new WeakSet,this.processElement(document.body,!0)}destroy(){this.observer&&this.observer.disconnect(),document.querySelectorAll("[pp-ref]").forEach(t=>{this.cleanupRefBinding(t)}),this.eventDelegation.cleanup(),this.batchedUpdates.clear(),this.updateQueue.clear(),this.processingRAF&&cancelAnimationFrame(this.processingRAF),this.elementCache=new WeakMap,this.listeners=new WeakMap,this.processedElements=new WeakSet,this.loopManager.destroy()}}class ce{static eventCache=null;delegatedEvents=new Map;elementHandlers=new WeakMap;handlerCache=new K(200);componentManager;expressionEvaluator;loopManager;setupEvents=new Set;static getAllAvailableEvents(){if(ce.eventCache)return ce.eventCache;const e=new Set,t=["click","input","change","submit","focus","blur","keydown","keyup","mousedown","mouseup","mouseover","mouseout"];try{Object.getOwnPropertyNames(HTMLElement.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(i){console.warn("Could not get HTMLElement events:",i),t.forEach(r=>e.add(r))}try{Object.getOwnPropertyNames(Document.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(i){console.warn("Could not get Document events:",i)}try{Object.getOwnPropertyNames(Window.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(i){console.warn("Could not get Window events:",i)}try{Object.getOwnPropertyNames(Element.prototype).filter(r=>r.startsWith("on")&&r.length>2).map(r=>r.substring(2).toLowerCase()).forEach(r=>e.add(r))}catch(i){console.warn("Could not get Element events:",i)}return new Set(["beforeunload","unload","pagehide","pageshow","popstate","hashchange","storage","message","messageerror","offline","online","languagechange","rejectionhandled","unhandledrejection","afterprint","beforeprint","devicemotion","deviceorientation","deviceorientationabsolute"]).forEach(i=>e.delete(i)),ce.eventCache=e,e}setupEventDelegation(){const e=["click","input","change","submit","focus","blur"];for(const t of e)this.ensureEventSetup(t)}getEventOptions(e){const t={capture:!0,passive:!1};return["wheel","touchstart","touchmove","touchend","scroll","mousewheel"].includes(e)&&(t.passive=!0),(e==="focusin"||e==="focusout")&&(t.capture=!1),t}isEventSupported(e){return ce.getAllAvailableEvents().has(e.toLowerCase())}getAllSupportedEvents(){return Array.from(ce.getAllAvailableEvents()).sort()}getDelegatedEvents(){return Array.from(this.delegatedEvents.keys()).sort()}setDependencies(e,t,n,i){this.componentManager=e,this.expressionEvaluator=t,this.loopManager=i}createDelegatedListener(e){return t=>{const n=t.target;if(!n)return;const i=this.findHandler(n,e);i&&this.executeHandler(i.handler,i.element,t)}}registerEventHandler(e,t,n,i){const r=t.toLowerCase();if(this.ensureEventSetup(r),!this.isEventSupported(r))return;const a=i;this.elementHandlers.has(e)||this.elementHandlers.set(e,new Map);const o=this.elementHandlers.get(e),c={code:n,component:a};o.set(r,c);const u=this.delegatedEvents.get(r);u?u.elements.add(e):(console.warn(`⚠️ No delegated listener for ${r}, attaching directly`),this.attachDirectListener(e,r,c))}ensureEventSetup(e){if(!this.setupEvents.has(e)){if(!this.isEventSupported(e)){console.warn(`⚠️ Attempting to setup unsupported event: ${e}`);return}try{const 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 i=this.elementHandlers.get(n);if(i?.has(t))return{handler:i.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 i=e;e.includes("this")&&(i=i.replace(/\bthis\b/g,"thisElement")),e.includes("event")&&(i=i.replace(/\bevent\b/g,"eventObject"));const r=new Function("eventObject","thisElement","context",`
32
- try {
33
- with(context) {
34
- ${i}
35
- }
36
- } catch(error) {
37
- console.error('Event handler execution error:', error);
38
- console.error('Handler code:', ${JSON.stringify(e)});
39
- console.error('Component:', '${t}');
40
- console.error('Available context keys:', Object.keys(context));
41
- }
42
- `);return this.handlerCache.set(n,r),r}executeHandler(e,t,n){if(!this.componentManager||!this.expressionEvaluator){console.warn("EventDelegationManager dependencies not set");return}try{const{effectiveComponent:i,useStrictScope:r,scopedComponent:a,actualElementComponent:o}=this.resolveEffectiveComponent(t,e),c=this.locateComponentElement(t,i,o),u=this.findNearestComponentWithProps(t);let p=r?this.buildContextStrict(a,i,c,t):this.buildContextNonStrict(i,c,u);p=this.makeStateAware(p),p=this.mergeLoopContext(t,p),this.ensureCompiled(e),e.compiledFn?.(n,t,p)}catch(i){console.error("💥 Event handler execution failed:",i),console.error("Handler code:",e.code),console.error("Handler component:",e.component)}}resolveEffectiveComponent(e,t){const n=R.findScope(e),i=e.getAttribute(m.ATTR_PREFIXES.COMPONENT);return t.component?{effectiveComponent:t.component,useStrictScope:!!n,scopedComponent:n,actualElementComponent:i}:i?{effectiveComponent:i,useStrictScope:!!n,scopedComponent:n,actualElementComponent:i}:n?{effectiveComponent:n==="app"?"app":n,useStrictScope:!0,scopedComponent:n,actualElementComponent:i}:{effectiveComponent:"app",useStrictScope:!1,scopedComponent:null,actualElementComponent:i}}locateComponentElement(e,t,n){if(n&&n===t)return e;let i=e.parentElement;for(;i&&i!==document.body;){if(i.getAttribute(m.ATTR_PREFIXES.COMPONENT)===t)return i;i=i.parentElement}for(i=e.parentElement;i&&i!==document.body;){if(i.getAttribute(m.ATTR_PREFIXES.COMPONENT))return i;i=i.parentElement}const r=document.querySelectorAll(`[${m.ATTR_PREFIXES.COMPONENT}="${t}"]`);for(const a of r)if(this.componentManager.hasStoredProps(a))return a;return r.length>0?r[0]:null}findNearestComponentWithProps(e){let t=e.parentElement;for(;t&&t!==document.body;){if(t.hasAttribute(m.ATTR_PREFIXES.COMPONENT)&&this.componentManager.hasStoredProps(t))return t;t=t.parentElement}return null}buildContextStrict(e,t,n,i){if(t&&t!==e){let a=this.componentManager.buildComponentContext(t);if(n&&this.componentManager.hasStoredProps(n)){const o=this.componentManager.evaluateProps(n);a={...a,...o}}if(e&&e!==t)if(e==="app"){const o=this.componentManager.buildComponentContext("app");for(const[c,u]of Object.entries(o))c in a||(a[c]=u)}else{const o=this.componentManager.buildComponentContext(e);for(const[c,u]of Object.entries(o))c in a||(a[c]=u)}return a}if(e==="app"){let a=this.componentManager.buildComponentContext("app");if(n&&n!==document.body&&this.componentManager.hasStoredProps(n)){const o=this.componentManager.evaluateProps(n);a={...a,...o}}return a}let r=this.componentManager.buildComponentContext(t);if(n&&this.componentManager.hasStoredProps(n)){const a=this.componentManager.evaluateProps(n);r={...r,...a}}return r}buildContextNonStrict(e,t,n){if(n){if(R.findScope(n)==="app"){let u={};u.getContext=()=>this.componentManager.buildComponentContext("app"),u.withContext=f=>{const g=this.componentManager.buildComponentContext("app");return f.call(g,g)},u.__getProp=f=>this.componentManager.evaluateProps(n)[f];const p=this.componentManager.evaluateProps(n);u={...u,...p};const h=n.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(h){const f=this.componentManager.getComponentFunctions(h);if(f)for(const[g,d]of f)u[g]=d}return u}const o=this.componentManager.buildRestrictedComponentContext(e,!1),c=this.componentManager.evaluateProps(n);return Object.assign(o,c),o}const i=this.componentManager.buildRestrictedComponentContext(e,!1),r=t||n;if(r&&this.componentManager.hasStoredProps(r)){const a=this.componentManager.evaluateProps(r);Object.assign(i,a)}return i}makeStateAware(e){const t={...e};for(const[n,i]of Object.entries(e))typeof i=="function"&&"__pphp_key"in i&&(t[n]=i.value);return t}mergeLoopContext(e,t){const n=this.loopManager?.getLoopContextForElement(e);if(!n)return t;const i={};for(const[r,a]of Object.entries(n))typeof a=="function"&&"__pphp_key"in a?i[r]=a.value:i[r]=a;return{...t,...i}}ensureCompiled(e){e.compiledFn||(e.compiledFn=this.compileHandler(e.code,e.component))}attachDirectListener(e,t,n){const i=r=>{this.executeHandler(n,e,r)};e.addEventListener(t,i),e[`__${t}_listener`]=i}removeEventHandler(e,t){const n=this.elementHandlers.get(e);n&&(n.delete(t),n.size===0&&this.elementHandlers.delete(e));const i=this.delegatedEvents.get(t);i&&i.elements.delete?.(e);const r=e[`__${t}_listener`];r&&(e.removeEventListener(t,r),delete e[`__${t}_listener`])}cleanup(){for(const[e,t]of this.delegatedEvents)document.removeEventListener(e,t.listener,!0);this.delegatedEvents.clear(),this.handlerCache.clear(),this.setupEvents.clear()}}class Ws{static instance=null;stateManager=new Vs;expressionEvaluator=new me;componentManager=new Ds(this.stateManager);domBindingManager=new Bs(this.stateManager,this.componentManager,this.expressionEvaluator);hydrationCallbacks=new Set;portalManager=new qt;initialized=!1;hydrationDone=!1;hydrationResolve;hydrationPromise;portalHydrationPromises=new Set;portalHydrationResolvers=new Map;constructor(){document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.initialize()):setTimeout(()=>this.initialize(),0),this.hydrationPromise=new Promise(e=>this.hydrationResolve=e)}initialize(){this.initialized||(this.initialized=!0,this.markHydrationStart(),this.componentManager.setExpressionEvaluator(this.expressionEvaluator),this.portalManager.setDependencies(this.componentManager,this.domBindingManager,this.stateManager,this),this.componentManager.executePhpScripts(document.body),this.domBindingManager.processElement(document.body,!0),this.domBindingManager.processPendingBindings(),Promise.resolve().then(()=>{requestAnimationFrame(()=>{this.markHydrated()})}))}createPortal(e,t,n){const i=this.portalManager.createPortal(e,t,n),r=new Promise(a=>{this.portalHydrationResolvers.set(i,a)});return this.portalHydrationPromises.add(r),r.finally(()=>{this.portalHydrationPromises.delete(r),this.portalHydrationResolvers.delete(i)}),i}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()}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)}get isHydrated(){return this.hydrationDone}markHydrationStart(){document.dispatchEvent(new CustomEvent("pp:hydrationstart"))}markHydrated(){if(!this.hydrationDone){this.hydrationDone=!0,this.hydrationResolve();for(const e of this.hydrationCallbacks)try{e()}catch{}this.hydrationCallbacks.clear(),document.dispatchEvent(new CustomEvent("pp:hydrated",{detail:{at:performance.now()}}))}}state(e,t){const n=this.componentManager.getCurrentComponent();let i,r;typeof e=="string"&&arguments.length===2?(i=e,r=t):typeof e=="string"&&arguments.length===1?this.looksLikeVariableName(e)?(i=e,r=void 0):(console.warn("pp.state() called with string that doesn't look like variable name:",e),i="unknownState",r=e):(console.warn("pp.state() called without explicit key - this should be handled by AST transformation"),i="unknownState",r=e),r&&typeof r=="function"&&"__pphp_key"in r&&(r=r.value);let a;const o=this.getLoopExecutionContext();if(o){const h=this.generateLoopInstanceId(o);a=`${n}.${h}.${i}`}else a=`${n}.${i}`;this.stateManager.hasState(a)||this.stateManager.setInitialState(a,r);const c=(()=>this.stateManager.getState()[a]),u=new Proxy(c,{get(h,f,g){if(f==="__pphp_key"||f==="__pphp_fullKey"||f==="__pphp_component"||f==="value"||f==="valueOf"||f==="toString")return Reflect.get(h,f,g);const d=h();if(d!=null){if(f in Object(d)){const x=d[f];return typeof x=="function"?x.bind(d):x}return Reflect.get(h,f,g)}},has(h,f){if(f==="__pphp_key"||f==="__pphp_fullKey"||f==="__pphp_component"||f==="value"||f==="valueOf"||f==="toString")return Reflect.has(h,f);const g=h();return g!=null&&f in Object(g)?!0:Reflect.has(h,f)},apply(h,f,g){return Reflect.apply(h,f,g)}});Object.defineProperty(u,"__pphp_key",{value:i,enumerable:!1,writable:!1}),Object.defineProperty(u,"__pphp_fullKey",{value:a,enumerable:!1,writable:!1}),Object.defineProperty(u,"__pphp_component",{value:n,enumerable:!1,writable:!1}),Object.defineProperty(u,"value",{get:()=>this.stateManager.getState()[a],enumerable:!0,configurable:!0}),c.valueOf=()=>this.stateManager.getState()[a],c.toString=()=>ue(this.stateManager.getState()[a]);const p=h=>{const f=this.stateManager.getState()[a],g=typeof h=="function"?h(f):h;this.stateManager.setState(a,g)};return this.createComponentScopedGlobals(n,i,u,p),[u,p]}currentLoopContext=null;getLoopExecutionContext(){return this.currentLoopContext}generateLoopInstanceId(e){const n=Object.keys(e).sort().map(r=>{const a=e[r];return a&&typeof a=="object"&&"id"in a?`${r}:${a.id}`:`${r}:${JSON.stringify(a)}`});return`loop_${btoa(n.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(" ")&&!Te.has(e)}effect(e,t){const n=`effect_${Date.now()}_${Math.random()}`,i=this.componentManager.getCurrentComponent();let r,a=!1,o,c;if(arguments.length===1)o="always",c={immediate:!0,detectDeps:!0};else if(Array.isArray(t)){const p=this.extractDependencyNames(t,i);p.length===0?(o="once",c={deps:p,immediate:!0}):(o="deps",c={deps:p,immediate:!0})}else{const p={immediate:!0,...t||{}};if(!p.deps||p.deps.length===0)o="always",c={immediate:p.immediate,detectDeps:!0};else{const h=this.extractDependencyNames(p.deps,i);o="deps",c={deps:h,immediate:p.immediate,detectDeps:p.detectDeps}}}const u=()=>{a||this.stateManager.onDOMUpdateComplete(()=>{if(!a){if(r&&typeof r=="function")try{r()}catch(p){console.error("Effect cleanup error:",p)}try{r=e()}catch(p){console.error("Effect callback error:",p)}}})};switch(o){case"always":const p=["*"],h={id:n,selector:"",dependencies:new Set(p),callback:u,component:i};this.stateManager.addSubscription(h);break;case"once":break;case"deps":const f=this.resolveDependencies(c.deps,i);if(f.length){const g={id:n,selector:"",dependencies:new Set(f),callback:u,component:i};this.stateManager.addSubscription(g)}break}return c.immediate!==!1&&u(),()=>{if(a=!0,r&&typeof r=="function")try{r()}catch(p){console.error("Effect cleanup error:",p)}this.stateManager.removeSubscription(n)}}extractDependencyNames(e,t){const n=[];for(const i of e)typeof i=="string"?n.push(i):typeof i=="function"&&i.__pphp_key?n.push(i.__pphp_key):console.warn("Invalid dependency in effect:",i);return n.filter(Boolean)}resolveDependencies(e,t){const n=[],i=this.stateManager.getState();for(const r of e)if(r.includes(".")){const a=r.split("."),o=a[0],c=a.slice(1).join("."),u=this.componentManager.getPropDependencies(o,t);if(u.length>0)n.push(...u);else{const p=qe.findExistingStateKey(o,t,i);p?n.push(`${p}.${c}`):n.push(`${t}.${r}`)}}else{const a=this.componentManager.getPropDependencies(r,t);if(a.length>0)n.push(...a);else{const o=qe.findExistingStateKey(r,t,i);o?n.push(o):n.push(`${t}.${r}`)}}return Array.from(new Set(n))}createComponentScopedGlobals(e,t,n,i){window[e]||(window[e]={});const r=`set${Ht(t)}`;window[e][t]=n,window[e][r]=i,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 i=window[n];(/^s[a-z0-9]+$/i.test(n)||n==="app")&&i&&typeof i=="object"&&delete window[n]}}static resetInstance(){this.instance&&(this.instance.destroy(),this.instance=null)}destroy(){this.cleanup(),this.initialized=!1,this.hydrationDone=!1}}class Ut{loopBindings=new Map;stateManager;expressionEvaluator;componentManager;domBindingManager;cleanupObserver;loopCounter=0;pendingTemplates=[];loopItemElements=new WeakSet;loopItemContexts=new WeakMap;templateRenderer;templateMoveObserver;constructor(e,t){this.stateManager=e,this.expressionEvaluator=t,this.cleanupObserver=new MutationObserver(n=>{this.cleanupDetachedTemplates(n)}),this.cleanupObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateMoveObserver=new MutationObserver(n=>{this.handleTemplateMoves(n)}),this.templateMoveObserver.observe(document.body,{childList:!0,subtree:!0}),this.templateRenderer=new et(t)}handleTemplateMoves(e){const t=new Set;for(const n of e)n.type==="childList"&&n.addedNodes.forEach(i=>{if(i.nodeType!==Node.ELEMENT_NODE)return;const r=i;if(r.querySelectorAll("template[pp-for]").forEach(o=>{const c=o;this.loopBindings.has(c)&&t.add(c)}),r.tagName==="TEMPLATE"&&r.hasAttribute("pp-for")){const o=r;this.loopBindings.has(o)&&t.add(o)}});t.size>0&&setTimeout(()=>{t.forEach(n=>{document.contains(n)&&this.updateMovedTemplate(n)})},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 i=[...t.renderedItems];t.placeholder.parentElement&&t.placeholder.parentElement!==n&&t.placeholder.parentElement.removeChild(t.placeholder);const r=document.createComment(`pp-for: ${t.expression}`);n.insertBefore(r,e),t.parentElement=n,t.placeholder=r,i.length>0&&(i.forEach(a=>{a.element.parentElement!==n&&n.insertBefore(a.element,e)}),this.updateDOMOrder(t,i)),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 i=t.getAllLoops();for(const[r,a]of i)for(const o of a.renderedItems)if(o.element.contains(e))return o.context;return null}setDependencies(e,t){this.componentManager=e,this.domBindingManager=t}queueTemplate(e,t){this.loopBindings.has(e)||this.pendingTemplates.push({template:e,component:t})}processPendingTemplates(){const e=[...this.pendingTemplates];this.pendingTemplates=[];for(const{template:t,component: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){console.warn("⚠️ Template has no parent, queueing for later:",n),this.queueTemplate(e,t);return}const i=this.parseLoopExpression(n);if(!i){console.error(`Invalid pp-for syntax: "${n}"`);return}const r=R.findScope(e);let a=t;r&&(r==="app"?a="app":a=r);const o=e.parentElement,c=document.createComment(`pp-for: ${n}`);o.insertBefore(c,e);const u={template:e,expression:n,itemVar:i.itemVar,indexVar:i.indexVar,component:a,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:o,placeholder:c,iterableExpr:i.iterableExpr};this.loopBindings.set(e,u),this.setupLoopReactivity(u,i.iterableExpr),this.renderLoop(u,i.iterableExpr)}parseLoopExpression(e){const t=e.match(/^\s*([a-zA-Z_$][\w$]*)\s+in\s+(.+)$/);if(t)return{itemVar:t[1],iterableExpr:t[2].trim()};const 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}`,i=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager),r=this.findComponentElementForLoop(e);if(r&&this.componentManager){const o=this.componentManager.getComponentPropDependencies(r,e.component);i.push(...o)}const a={id:n,selector:"",dependencies:new Set(i),callback:()=>{this.renderLoop(e,e.iterableExpr)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(a),e.subscriptionIds.push(n)}renderLoop(e,t){if(!(!this.componentManager||!this.domBindingManager))try{const n=this.findComponentElementForLoop(e);let i;const r=this.findParentLoopContext(e.template),a=e.template;if(R.findScope(a)!==null){const h=this.componentManager.buildComponentContext(e.component);if(n){const f=this.componentManager.evaluateProps(n);i={...h,...f}}else i=h;r&&(i={...i,...r})}else{if(i=this.componentManager.buildRestrictedComponentContext(e.component,!1),n&&this.componentManager.hasStoredProps(n)){const h=this.componentManager.evaluateProps(n);Object.assign(i,h)}r&&(i={...i,...r})}const u=this.expressionEvaluator.evaluateExpression(t,i,e.component),p=Ue(u);if(!Array.isArray(p)){console.warn(`Loop expression "${t}" did not return an array:`,p,`Available context keys: [${Object.keys(i).join(", ")}]`,"Parent loop context:",r),this.clearRenderedItems(e);return}this.updateRenderedItems(e,p)}catch(n){console.error(`Error evaluating loop expression "${t}":`,n),this.clearRenderedItems(e)}}findParentLoopContext(e){const t=[];let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const i=this.loopItemContexts.get(n);i&&t.unshift(i)}for(const[i,r]of this.loopBindings)if(r.template!==e){for(const a of r.renderedItems)if(a.element===n||a.element.contains(e)){t.unshift(a.context);break}}n=n.parentElement}return t.length>0?t.reduce((i,r)=>({...i,...r}),{}):null}findComponentElementForLoop(e){let t=e.parentElement;for(;t;){if(t.getAttribute(m.ATTR_PREFIXES.COMPONENT)===e.component)return t;t=t.parentElement}if(e.component==="app")for(t=e.parentElement;t&&t!==document.body;){if(t.hasAttribute(m.ATTR_PREFIXES.COMPONENT)&&this.componentManager?.hasStoredProps(t))return t;t=t.parentElement}return document.querySelectorAll(`[${m.ATTR_PREFIXES.COMPONENT}="${e.component}"]`)[0]||void 0}updateRenderedItems(e,t){const n=e.renderedItems,i=[],r=new Set,a=new Map;n.forEach(o=>{a.set(o.key,o)}),t.forEach((o,c)=>{const u=this.generateItemKey(e,o,c),p=a.get(u);if(p&&!r.has(p.element))r.add(p.element),this.updateItemContext(e,p,o,c),p.element.querySelectorAll("template[pp-for]").forEach(f=>{const g=f,d=this.loopBindings.get(g);d&&this.renderLoop(d,d.iterableExpr)}),i.push(p);else{const h=this.createLoopItem(e,o,c,u);h&&(i.push(h),this.processNestedLoopsInItem(h,e.component))}}),n.forEach(o=>{r.has(o.element)||this.cleanupLoopItem(o)}),this.updateDOMOrder(e,i),e.renderedItems=i}processNestedLoopsInItem(e,t){e.element.querySelectorAll("template[pp-for]").forEach(i=>{const r=i;this.loopBindings.has(r)||this.processNestedTemplate(r,t,e.context)})}generateItemKey(e,t,n){const r=e.template.content.firstElementChild;if(r&&r.hasAttribute("key")){const a=r.getAttribute("key");try{const o=this.createItemContextWithParentContext(e,t,n),c=M.isSingleExpression(a);if(c){const u=this.expressionEvaluator.evaluateExpression(c,o,e.component);return String(u)}else{const u=M.parse(a);let p="";for(const h of u)if(h.type==="static")p+=h.content;else if(h.expression){const f=this.expressionEvaluator.evaluateExpression(h.expression,o,e.component);p+=ue(f)}return p}}catch(o){console.warn(`Error evaluating key expression "${a}":`,o,"Available context keys:",Object.keys(this.createItemContextWithParentContext(e,t,n)))}}return t&&typeof t=="object"&&"id"in t?String(t.id):`${e.expression}_${n}`}createItemContextWithParentContext(e,t,n){if(!this.componentManager)return{};const i=e.template,r=R.findScope(i),a=r!==null,o=this.findComponentElementForLoop(e),c=o&&this.componentManager.hasStoredProps(o);let u;if(a&&r==="app"&&c&&o){u={},u.getContext=()=>this.componentManager.buildComponentContext("app"),u.withContext=x=>{const b=this.componentManager.buildComponentContext("app");return x.call(b,b)},u.__getProp=x=>{if(o)return this.componentManager.evaluateProps(o)[x]};const d=this.componentManager.evaluateProps(o);u={...u,...d}}else u=this.componentManager.buildComponentContext(e.component);const p=this.getAllParentLoopContexts(e.template),h=t&&typeof t=="object"?Object.keys(t):[],f={};for(const[d,x]of Object.entries(u))h.includes(d)&&!d.startsWith("set")&&!d.endsWith("Getter")||(f[d]=x);const g={...f,...p,[e.itemVar]:t};return e.indexVar&&(g[e.indexVar]=n),g}getAllParentLoopContexts(e){const t=[];let n=e.parentElement;for(;n&&n!==document.body;){if(this.loopItemElements.has(n)){const r=this.loopItemContexts.get(n);r&&t.unshift(r)}for(const[r,a]of this.loopBindings)for(const o of a.renderedItems)if(o.element.contains(e)||o.element===n){t.unshift(o.context);break}n=n.parentElement}const i={};for(const r of t)for(const[a,o]of Object.entries(r))if(!(a in i)){if(typeof o=="function"&&!("__pphp_key"in o)){["getContext","withContext","__getProp"].includes(a)&&(i[a]=o);continue}i[a]=o}return i}createItemContext(e,t,n){if(!this.componentManager)return{};const i=e.template,r=R.findScope(i),a=r!==null,o=this.findComponentElementForLoop(e),c=o&&this.componentManager.hasStoredProps(o);let u=!1,p=i.parentElement;for(;p&&p!==document.body;){if(this.loopItemElements.has(p)){const b=this.loopItemContexts.get(p);if(b&&!Object.keys(b).some(S=>{const V=b[S];return typeof V=="function"&&!("__pphp_key"in V)&&!["getContext","withContext","__getProp"].includes(S)})){u=!0;break}}p=p.parentElement}let h;if(a&&r==="app"&&c&&o||u&&c&&o){h={},h.getContext=()=>this.componentManager.buildComponentContext("app"),h.withContext=C=>{const S=this.componentManager.buildComponentContext("app");return C.call(S,S)},h.__getProp=C=>{if(o)return this.componentManager.evaluateProps(o)[C]};const b=this.componentManager.evaluateProps(o);h={...h,...b}}else a||c?h=this.componentManager.buildComponentContext(e.component):h=this.componentManager.buildRestrictedComponentContext(e.component,!1);const f={},g=t&&typeof t=="object"?Object.keys(t):[];for(const[b,C]of Object.entries(h)){if(typeof C=="function"&&!C.__pphp_key){f[b]=C;continue}if(b.startsWith("set")||b.endsWith("Getter")){f[b]=C;continue}if(["getContext","withContext","__getProp"].includes(b)){f[b]=C;continue}g.includes(b)||(f[b]=C)}const d=this.findAllParentLoopContexts(e.template),x={...f,...d,[e.itemVar]:t};return e.indexVar&&(x[e.indexVar]=n),x}findAllParentLoopContexts(e){const t={};let n=e.parentElement,i=0;for(;n&&n!==document.body&&i<10;){if(i++,this.loopItemElements.has(n)){const r=this.loopItemContexts.get(n);if(r){for(const[a,o]of Object.entries(r))if(!(a in t)){const c=typeof o=="function",u=c&&"__pphp_key"in o,p=["getContext","withContext","__getProp"].includes(a);if(c&&!u){p&&(t[a]=o);continue}t[a]=o}}}for(const[r,a]of this.loopBindings)if(r!==e){for(const o of a.renderedItems)if(o.element===n){for(const[c,u]of Object.entries(o.context))if(!(c in t)){const p=typeof u=="function",h=p&&"__pphp_key"in u,f=["getContext","withContext","__getProp"].includes(c);if(p&&!h){f&&(t[c]=u);continue}t[c]=u}break}}n=n.parentElement}return t}createLoopItem(e,t,n,i){if(!this.domBindingManager)return null;try{const r=this.createItemContextWithParentContext(e,t,n);this.preCloneSanitizeTemplate(e.template);const a=document.importNode(e.template.content,!0),o=document.createElement("div");o.appendChild(a);const c=o.firstElementChild;if(!c)return console.error("❌ [LoopItem] No element found in template"),null;o.removeChild(c),this.sanitizeInputValidationAttributes(c),this.loopItemElements.add(c),this.loopItemContexts.set(c,r),c.getAttribute("key")&&c.removeAttribute("key");const p={key:i,element:c,context:r,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map,parentTemplate:e.template};return this.executeComponentScriptsInLoopItem(c),this.processRefsInLoopItem(c,r,e.component),this.processElementWithContext(c,r,e.component,p),this.cleanupRawMustacheAttributes(c),p}catch(r){return console.error("❌ [LoopItem] Error creating loop item:",r),console.error(" Stack:",r.stack),null}}preCloneSanitizeTemplate(e){const n=e.content.querySelectorAll("input");for(const i of Array.from(n)){const r=(i.getAttribute("type")||"text").toLowerCase();if(!["number","date","time","datetime-local","month","week","email","url","tel","range"].includes(r))continue;const o=["value","min","max","step","pattern"];for(const c of o){const u=i.getAttribute(c);if(u&&m.MUSTACHE_PATTERN.test(u)){const p=`data-pp-${c}`;i.setAttribute(p,u),i.removeAttribute(c)}}r==="number"&&!i.hasAttribute("value")&&i.setAttribute("value","0")}}sanitizeInputValidationAttributes(e){const t=[];e.tagName.toLowerCase()==="input"&&t.push(e),t.push(...Array.from(e.querySelectorAll("input")));for(const n of t){const i=(n.getAttribute("type")||"text").toLowerCase();if(!["number","date","time","datetime-local","month","week","email","url","tel","range"].includes(i))continue;const a=["value","min","max","step","pattern"];for(const o of a){const c=`data-pp-${o}`,u=n.getAttribute(c);u&&(n.setAttribute(o,u),n.removeAttribute(c))}n.getAttribute("value")==="0"&&!n.hasAttribute("data-pp-value")&&i==="number"&&n.removeAttribute("value")}}processRefsInLoopItem(e,t,n){if(e.hasAttribute("pp-ref")){const o=e.getAttribute("pp-ref");this.processRefAttribute(e,o,t,n)}const i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>o.hasAttribute("pp-ref")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let r;const a=[];for(;r=i.nextNode();)a.push(r);a.forEach(o=>{const c=o.getAttribute("pp-ref");this.processRefAttribute(o,c,t,n)})}processRefAttribute(e,t,n,i){try{const r=M.decodeEntities(t),a=M.isSingleExpression(r)||r,o=this.expressionEvaluator.evaluateExpression(a,n,i);typeof o=="function"?o(e):o&&typeof o=="object"&&"current"in o?o.current=e:console.warn("⚠️ Invalid ref result:",o),e.removeAttribute("pp-ref")}catch(r){console.error("❌ Failed to process ref:",r)}}executeComponentScriptsInLoopItem(e){if(!this.componentManager)return;const t=[e],n=e.querySelectorAll(`[${m.ATTR_PREFIXES.COMPONENT}]`);t.push(...Array.from(n)),t.forEach(i=>{if(i.hasAttribute(m.ATTR_PREFIXES.COMPONENT)){const r=i.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(r){const a=this.getLoopItemContextForElement(i),o=this.generateInstanceId(a),c=`${r}_${o}`;i.setAttribute(m.ATTR_PREFIXES.COMPONENT,c),i.__originalComponentName=r,i.__uniqueComponentName=c,this.componentManager.pushComponent(c),window[c]||(window[c]={}),window[r]&&Object.assign(window[c],window[r]),this.getComponentScripts(i).forEach(p=>{this.componentManager.executeScript(p)}),this.componentManager.popComponent()}}})}getLoopItemContextForElement(e){let t=e;for(;t;){if(this.loopItemElements.has(t)){const n=this.loopItemContexts.get(t);if(n)return n}t=t.parentElement}for(const[n,i]of this.loopBindings)for(const r of i.renderedItems)if(r.element===e||r.element.contains(e))return r.context;return console.warn("⚠️ No loop item context found, using empty context"),{}}generateInstanceId(e){const t={};for(const[a,o]of Object.entries(e))typeof o=="function"||a.startsWith("set")||a.endsWith("Getter")||a==="getContext"||a==="withContext"||a==="__getProp"||o&&typeof o=="function"&&"__pphp_key"in o||typeof o=="boolean"||typeof o=="number"||typeof o=="string"||o&&typeof o=="object"&&!Array.isArray(o)&&"id"in o&&(t[a]=o);return Object.keys(t).length===0?`${Date.now()}_${Math.random().toString(36).substring(2,7)}`:Object.keys(t).sort().map(a=>{const o=t[a];return o&&typeof o=="object"&&"id"in o?`${a}_${o.id}`:`${a}_${JSON.stringify(o)}`}).join("_").replace(/[^a-zA-Z0-9_]/g,"").substring(0,20)||`fallback_${Date.now()}`}getComponentScripts(e){const t=[];return e.querySelectorAll(`script[type="${m.SCRIPT_TYPE}"]`).forEach(i=>{const r=i;let a=r.parentElement,o=!1;for(;a&&a!==e.parentElement;){if(a===e){o=!0;break}if(a.hasAttribute(m.ATTR_PREFIXES.COMPONENT)&&a!==e)break;a=a.parentElement}o&&t.push(r)}),t}cleanupRawMustacheAttributes(e){this.cleanupElementMustacheAttributes(e);const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,null);let n;for(;n=t.nextNode();)this.cleanupElementMustacheAttributes(n)}cleanupElementMustacheAttributes(e){const t=Array.from(e.attributes);for(const n of t)n.value&&m.MUSTACHE_PATTERN.test(n.value)&&(P.isBooleanAttribute(n.name),e.removeAttribute(n.name))}processElementWithContext(e,t,n,i){if(!this.domBindingManager||!this.componentManager)return;const r=(o,c)=>{const u=this.componentManager.buildComponentContext(c),p=o.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(p&&p!==c){const f=this.componentManager.buildComponentContext(p);return{...t,...u,...f}}return{...t,...u}},a=this.componentManager.buildComponentContextWithProps.bind(this.componentManager);this.componentManager.buildComponentContextWithProps=(o,c)=>c&&(c===e||e.contains(c))?r(c,o):a(o,c);try{if(e.hasAttribute("pp-ref")){const f=e.getAttribute("pp-ref");this.processRefInLoopContext(e,f,t,n),e.removeAttribute("pp-ref")}const o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:f=>f===e?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT}),c=[];let u;for(;u=o.nextNode();){const f=u;if(f.hasAttribute("pp-ref")){const g=f.getAttribute("pp-ref");c.push({element:f,expression:g})}}c.forEach(({element:f,expression:g})=>{this.processRefInLoopContext(f,g,t,n)});const p=this.bindLoopItemElement(e,t,n,i);this.setupEventBindingsForLoopItem(e,n);for(let f=0;f<e.childNodes.length;f++){const g=e.childNodes[f];if(g.nodeType===Node.TEXT_NODE){const d=g;if(d.textContent&&m.MUSTACHE_PATTERN.test(d.textContent)&&!P.isTextNodeInsideScript(d)){const x=this.getComponentForTextNode(d);this.processTextNodeWithLoopContext(d,p,x,i)}}else if(g.nodeType===Node.ELEMENT_NODE){const d=g;if(d.tagName.toLowerCase()==="script")continue;const b=d.getAttribute(m.ATTR_PREFIXES.COMPONENT)||n,C=this.bindLoopItemElement(d,p,b,i);this.setupEventBindingsForLoopItem(d,b),this.processChildrenRecursively(d,C,b,i)}}e.querySelectorAll("template[pp-for]").forEach(f=>{(f.parentElement===e||e.contains(f))&&this.processNestedTemplate(f,n,p)})}finally{this.componentManager.buildComponentContextWithProps=a}}processChildrenRecursively(e,t,n,i){const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{if(o===e)return NodeFilter.FILTER_SKIP;if(o.nodeType===Node.TEXT_NODE){const c=o;if(P.isTextNodeInsideScript(c))return NodeFilter.FILTER_REJECT;if(c.textContent&&m.MUSTACHE_PATTERN.test(c.textContent))return NodeFilter.FILTER_ACCEPT}else if(o.nodeType===Node.ELEMENT_NODE){const c=o;if(c.tagName.toLowerCase()==="script")return NodeFilter.FILTER_REJECT;const u=c.getAttribute(m.ATTR_PREFIXES.COMPONENT);return u&&u!==n&&!i?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let a;for(;a=r.nextNode();)if(a.nodeType===Node.TEXT_NODE){const o=a,c=this.getComponentForTextNode(o);this.processTextNodeWithLoopContext(o,t,c,i)}else if(a.nodeType===Node.ELEMENT_NODE){const o=a,c=P.getElementComponent(o),u=this.bindLoopItemElement(o,t,c,i);this.setupEventBindingsForLoopItem(o,c),this.processChildrenRecursively(o,u,c,i)}}processChildElementsWithContext(e,t,n,i){const r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:u=>{if(u===e)return NodeFilter.FILTER_SKIP;if(u.nodeType===Node.TEXT_NODE){const p=u;if(P.isTextNodeInsideScript(p))return NodeFilter.FILTER_REJECT;if(p.textContent&&m.MUSTACHE_PATTERN.test(p.textContent))return NodeFilter.FILTER_ACCEPT}else if(u.nodeType===Node.ELEMENT_NODE){const p=u;if(p.tagName.toLowerCase()==="script")return NodeFilter.FILTER_REJECT;const h=p.getAttribute(m.ATTR_PREFIXES.COMPONENT);return h&&h!==n?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_SKIP}});let a;const o=[],c=[];for(;a=r.nextNode();)a.nodeType===Node.ELEMENT_NODE?o.push(a):a.nodeType===Node.TEXT_NODE&&c.push(a);c.forEach(u=>{const p=this.getComponentForTextNode(u);this.processTextNodeWithLoopContext(u,t,p,i)}),o.forEach(u=>{const p=P.getElementComponent(u),h=this.bindLoopItemElement(u,t,p,i);this.setupEventBindingsForLoopItem(u,p),this.processChildElementsWithContext(u,h,p,i)})}processRefInLoopContext(e,t,n,i){try{const r=M.decodeEntities(t),a=M.isSingleExpression(r)||r,o=this.expressionEvaluator.evaluateExpression(a,n,i);typeof o=="function"?o(e):o&&typeof o=="object"&&"current"in o?o.current=e:console.warn("⚠️ Invalid ref result:",o),e.removeAttribute("pp-ref")}catch(r){console.error("❌ processRefInLoopContext error:",r)}}getComponentForTextNode(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(n)return n;t=t.parentElement}return"app"}processNestedTemplate(e,t,n){const i=e.getAttribute("pp-for");if(!i||this.loopBindings.has(e))return;const r=this.parseLoopExpression(i);if(!r){console.error(`Invalid pp-for syntax: "${i}"`);return}const a=e.parentElement,o=document.createComment(`pp-for: ${i}`);a.insertBefore(o,e);const c=this.findComponentElementForTemplate(e);let u={...n};const p=this.findParentLoopContextForNestedTemplate(e);if(p&&(u={...u,...p}),c&&this.componentManager){const f=c.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(f){const g=P.getParentComponentForElement(c);this.componentManager.hasStoredProps(c)||this.componentManager.setupProps(c,g);const d=this.evaluateComponentPropsWithContext(c,u);u={...this.componentManager.buildComponentContext(f),...d,...u}}}const h={template:e,expression:i,itemVar:r.itemVar,indexVar:r.indexVar,iterableExpr:r.iterableExpr,component:t,subscriptionIds:[],renderedItems:[],keyExpression:void 0,parentElement:a,placeholder:o};this.loopBindings.set(e,h),this.setupNestedLoopReactivity(h,r.iterableExpr,u),this.renderNestedLoop(h,r.iterableExpr,u)}findParentLoopContextForNestedTemplate(e){let t=e.parentElement;const n={};let i=0;for(;t&&t!==document.body&&i<10;){if(i++,this.loopItemElements.has(t)){const r=this.loopItemContexts.get(t);if(r)for(const[a,o]of Object.entries(r))a in n||(n[a]=o)}for(const[r,a]of this.loopBindings)for(const o of a.renderedItems)(o.element.contains(e)||o.element===t)&&(a.itemVar in n||(n[a.itemVar]=o.context[a.itemVar]),a.indexVar&&!(a.indexVar in n)&&(n[a.indexVar]=o.context[a.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 i=this.componentManager.extractProps(e,"app");for(const[r,a]of i)try{const o=this.templateRenderer.render(a.expression,t,a.component);n[r]=o}catch(o){console.error(`Failed to evaluate prop "${r}":`,o),n[r]=void 0}return n}findComponentElementForTemplate(e){let t=e.parentElement;for(;t;){if(t.hasAttribute(m.ATTR_PREFIXES.COMPONENT))return t;t=t.parentElement}return null}setupNestedLoopReactivity(e,t,n){const i=`nested_loop_${Date.now()}_${++this.loopCounter}`;let r=this.expressionEvaluator.extractDependencies(t,e.component,this.stateManager);const a={id:i,selector:"",dependencies:new Set(r),callback:()=>{const o=e.template,c=this.findComponentElementForTemplate(o);let u=n;if(o.parentElement){const h=this.getParentLoopContextForElement(o);h&&(u={...u,...h})}if(c&&this.componentManager){const h=c.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(h){const f=this.extractParentLoopContextFromBinding(e,n),g=this.evaluateComponentPropsWithContext(c,f),d=this.componentManager.buildComponentContext(h);u={...f,...d,...g}}}this.renderNestedLoop(e,t,u)},element:e.parentElement,component:e.component};this.stateManager.addSubscription(a),e.subscriptionIds.push(i)}getParentLoopContextForElement(e){let t=e.parentElement;for(;t;){if(this.loopItemElements.has(t)){const n=this.loopItemContexts.get(t);if(n)return n}t=t.parentElement}return null}extractParentLoopContextFromBinding(e,t){const n=new Set;for(const[r,a]of this.loopBindings)if(a!==e){for(const o of a.renderedItems)if(o.element.contains(e.template)){n.add(a.itemVar),a.indexVar&&n.add(a.indexVar);break}}const i={};for(const[r,a]of Object.entries(t))(n.has(r)||r.startsWith("users")||r.startsWith("set")||r.includes("Getter")||typeof a=="function")&&(i[r]=a);return i}renderNestedLoop(e,t,n){if(!(!this.componentManager||!this.domBindingManager))try{const i=e.template,a=R.findScope(i)!==null,o=this.findComponentElementForLoop(e),c=o&&this.componentManager.hasStoredProps(o);let u;if(a||c)u=n;else{const f=this.componentManager.buildRestrictedComponentContext(e.component,!1),g=this.extractLoopVariablesOnly(n);u={...f,...g}}const p=this.expressionEvaluator.evaluateExpression(t,u,e.component),h=Ue(p);if(!Array.isArray(h)){console.warn(`Nested loop expression "${t}" did not return an array:`,h,`Available context keys: [${Object.keys(u).join(", ")}]`),this.clearRenderedItems(e);return}this.updateNestedRenderedItems(e,h,u)}catch(i){console.error(`Error evaluating nested loop expression "${t}":`,i,`Available context keys: [${Object.keys(n).join(", ")}]`),this.clearRenderedItems(e)}}extractLoopVariablesOnly(e){const t={};for(const[n,i]of Object.entries(e))typeof i=="function"&&!("__pphp_key"in i)||n.startsWith("set")&&typeof i=="function"||n.endsWith("Getter")||["getContext","withContext","__getProp"].includes(n)||(t[n]=i);return t}updateNestedRenderedItems(e,t,n){const i=e.renderedItems,r=[],a=new Set,o=new Map;i.forEach(c=>{o.set(c.key,c)}),t.forEach((c,u)=>{const p=this.generateNestedItemKey(e,c,u,n),h=o.get(p);if(h&&!a.has(h.element))a.add(h.element),this.updateNestedItemContext(e,h,c,u,n),r.push(h);else{const f=this.createNestedLoopItem(e,c,u,p,n);f&&r.push(f)}}),i.forEach(c=>{a.has(c.element)||this.cleanupLoopItem(c)}),this.updateDOMOrder(e,r),e.renderedItems=r}generateNestedItemKey(e,t,n,i){return t&&typeof t=="object"&&"id"in t?String(t.id):`${e.expression}_${n}_${JSON.stringify(i[e.itemVar]||{})}`}createNestedLoopItem(e,t,n,i,r){if(!this.domBindingManager)return null;try{const a={...r,[e.itemVar]:t};e.indexVar&&(a[e.indexVar]=n);const o=document.importNode(e.template.content,!0),c=document.createElement("div");c.appendChild(o);const u=c.firstElementChild;if(!u)return console.warn("Template content must contain exactly one root element"),null;c.removeChild(u),this.loopItemElements.add(u),this.loopItemContexts.set(u,a),u.getAttribute("key")&&u.removeAttribute("key");const h={key:i,element:u,context:a,subscriptionIds:[],textNodeTemplates:new Map,attributeTemplates:new Map};return this.processElementWithContext(u,a,e.component,h),this.cleanupRawMustacheAttributes(u),h}catch(a){return console.error("Error creating nested loop item:",a),null}}updateNestedItemContext(e,t,n,i,r){const a={...r};a[e.itemVar]=n,e.indexVar&&(a[e.indexVar]=i);const o=this.gatherAllComponentContextsInLoopItem(t.element),c={...a,...o};if(t.context=c,this.loopItemContexts.set(t.element,c),t.textNodeTemplates)for(const[u,p]of t.textNodeTemplates)document.contains(u)&&this.updateTextNodeWithContext(u,p,c,this.getTextNodeComponent(u));if(t.attributeTemplates)for(const[u,p]of t.attributeTemplates)document.contains(u)&&p.forEach((h,f)=>{try{const g=P.getElementComponent(u),d=this.buildElementSpecificContext(u,c),x=this.templateRenderer.render(h,d,g);this.domBindingManager?.updateElementProperty(u,f,x)}catch(g){console.error(`Nested binding update error for "${h}":`,g)}})}bindLoopItemElement(e,t,n,i){const r=this.extractMustacheBindings(e),a=this.findOriginalComponentName(n),o=R.findScope(e);let c=a;o?o==="app"?c="app":c=o:c=this.findLoopParentComponent(e,a);let u=this.componentManager.buildComponentContext(c);u={...u,...t};const h=!!e.getAttribute(m.ATTR_PREFIXES.COMPONENT),f=new Map,g=new Map;r.forEach((C,S)=>{h&&S!=="class"&&S!=="style"?f.set(S,C):g.set(S,C)});const d={},x=this.sortPropsByDependency(f);for(const[C,S]of x)try{const V=this.templateRenderer.render(S,u,c);d[C]=V,u[C]=V}catch(V){console.error(`❌ Failed to evaluate prop "${C}":`,V),d[C]=void 0,u[C]=void 0}h&&Object.keys(d).length>0&&(window[n]||(window[n]={}),Object.assign(window[n],d));const b=u;return i&&Object.keys(d).length>0&&Object.assign(i.context,d),i&&r.size>0&&(i.attributeTemplates||(i.attributeTemplates=new Map),i.attributeTemplates.set(e,new Map(r))),r.forEach((C,S)=>{this.createLoopItemBinding(e,S,C,b,c,i)}),b}sortPropsByDependency(e){const t=Array.from(e.keys()),n=Array.from(e.entries()),i=[],r=[];for(const[a,o]of n)t.some(u=>u!==a&&o.includes(u))?r.push([a,o]):i.push([a,o]);return[...i,...r]}setupEventBindingsForLoopItem(e,t){const n=this.domBindingManager.eventDelegation;if(!n){console.warn("No event delegation manager available");return}const i=Array.from(e.attributes);for(const r of i)if(de.isEventAttribute(r.name)){const a=r.name.substring(2);n.registerEventHandler(e,a,r.value,t),e.removeAttribute(r.name)}}processTextNodeWithLoopContext(e,t,n,i){if(P.isTextNodeInsideScript(e))return;const r=e.textContent||"";if(!M.parse(r).some(x=>x.type==="expression"))return;i&&(i.textNodeTemplates||(i.textNodeTemplates=new Map),i.textNodeTemplates.set(e,r));const c=this.findActualComponentForTextNode(e);let u=t;c!==n&&i&&this.componentManager&&(u={...this.componentManager.buildComponentContext(c),...i.context}),this.updateTextNodeWithContext(e,r,u,c);const p=`loop_text_${Date.now()}_${Math.random()}`,h=this.templateRenderer.dependencies(r,c,this.stateManager),f=new Set(h),d={id:p,selector:"",dependencies:f,callback:()=>{if(!document.contains(e)){this.stateManager.removeSubscription(p);return}let x={};if(this.componentManager&&(c!==n&&i?x={...this.componentManager.buildComponentContext(c),...i.context}:x=this.componentManager.buildComponentContext(c)),i){const b={};let C=null;for(const[S,V]of this.loopBindings)if(V.renderedItems.includes(i)){C=V;break}if(C){b[C.itemVar]=i.context[C.itemVar],C.indexVar&&(b[C.indexVar]=i.context[C.indexVar]);const S=this.findParentLoopContext(C.template);S&&Object.assign(b,S)}x={...x,...b}}this.updateTextNodeWithContext(e,r,x,c)},component:c};this.stateManager.addSubscription(d),i&&i.subscriptionIds.push(p)}findActualComponentForTextNode(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(n){const i=t.__uniqueComponentName;return i||n}t=t.parentElement}return"app"}updateTextNodeWithContext(e,t,n,i){const r=M.parse(t),a={};for(const[c,u]of Object.entries(n))typeof u=="function"&&"__pphp_key"in u?a[c]=u.value:a[c]=u;let o="";for(const c of r)if(c.type==="static")o+=c.content;else if(c.expression)try{const u=this.expressionEvaluator.evaluateExpression(c.expression,a,i);o+=ue(u)}catch(u){console.warn(`Loop text evaluation error for "${c.expression}":`,u,"Available context keys:",Object.keys(a)),o+=""}e.textContent!==o&&(e.textContent=o)}extractMustacheBindings(e){const t=new Map,n=e.attributes;for(let i=0;i<n.length;i++){const r=n[i];if(!(r.name===m.ATTR_PREFIXES.COMPONENT||r.name==="key"||r.name.startsWith("on"))&&r.value){const a=m.MUSTACHE_PATTERN.test(r.value),o=M.decodeEntities(r.value),c=m.MUSTACHE_PATTERN.test(o);(a||c)&&t.set(r.name,o)}}return t}createLoopItemBinding(e,t,n,i,r,a){const o=`loop_item_${Date.now()}_${Math.random()}`,c=R.findScope(e);let u;c?c==="app"?u="app":u=c:u=this.findLoopParentComponent(e,r);const p=this.templateRenderer.dependencies(n,u,this.stateManager);let h=null;const f=[];if(a?.parentTemplate&&(h=this.findParentComponentWithPropsFromTemplate(a.parentTemplate),h&&this.componentManager)){const N=h.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(N){const k=this.componentManager.getComponentPropDependencies(h,N);f.push(...k);const O=this.componentManager.elementProps.get(h);if(O){const Ce=Array.from(O.keys());for(const $ of Ce)if(n.includes($)){const te=O.get($);if(te){const he=this.templateRenderer.dependencies(te.expression,te.component,this.stateManager);f.push(...he)}}}}}const g=new Set([...p,...f,"*"]);let d=!1,x=0;const b=5,C=()=>{if(d)return;if(!document.contains(e)){if(x++,x<b){const k=10*Math.pow(2,x-1);setTimeout(()=>{d||C()},k)}else d=!0,this.stateManager.removeSubscription(o);return}x=0;try{const k=this.componentManager.buildComponentContext(u);let O;if(a){O={...k};let $=null;for(const[te,he]of this.loopBindings)if(he.renderedItems.includes(a)){$=he;break}$&&(O[$.itemVar]=a.context[$.itemVar],$.indexVar&&(O[$.indexVar]=a.context[$.indexVar]));for(const[te,he]of Object.entries(a.context))te in O||(O[te]=he);if(h&&this.componentManager){const te=this.componentManager.evaluateProps(h);Object.assign(O,te)}}else O=i;const Ce=this.templateRenderer.render(n,O,u);this.domBindingManager?.updateElementProperty(e,t,Ce)}catch(k){console.error(`❌ Loop item binding evaluation error for "${n}":`,k),console.error("Available context keys:",Object.keys(i))}},S={id:o,selector:"",dependencies:g,callback:()=>{d||C()},element:e,component:u};if(this.stateManager.addSubscription(S),a){a.subscriptionIds.push(o);const N=this.cleanupLoopItem.bind(this);this.cleanupLoopItem=k=>{k===a&&(d=!0),N(k)}}(()=>{document.contains(e)?C():Promise.resolve().then(()=>{if(!d&&document.contains(e))C();else if(!d&&x<b){x++;const N=10*Math.pow(2,x-1);setTimeout(()=>{d||C()},N)}else!d&&x>=b&&(d=!0,this.stateManager.removeSubscription(o))})})()}findParentComponentWithPropsFromTemplate(e){let t=e.parentElement;for(;t&&t!==document.body;){if(t.getAttribute(m.ATTR_PREFIXES.COMPONENT)&&this.componentManager?.hasStoredProps(t))return t;t=t.parentElement}return null}findLoopParentComponent(e,t){for(const[n,i]of this.loopBindings)for(const r of i.renderedItems)if(r.element===e||r.element.contains(e))return i.component;return this.findOriginalComponentName(t)}findOriginalComponentName(e){return e.includes("_")&&/\d{13}/.test(e)?e.split("_")[0]:e}updateItemContext(e,t,n,i){const r=this.createItemContext(e,n,i),a=this.gatherAllComponentContextsInLoopItem(t.element),o={...r,...a};if(t.context=o,this.loopItemContexts.set(t.element,o),t.textNodeTemplates)for(const[c,u]of t.textNodeTemplates)document.contains(c)&&this.updateTextNodeWithContext(c,u,o,this.getTextNodeComponent(c));if(t.attributeTemplates)for(const[c,u]of t.attributeTemplates)document.contains(c)&&u.forEach((p,h)=>{try{const f=P.getElementComponent(c),g=this.buildElementSpecificContext(c,o),d=this.templateRenderer.render(p,g,f);this.domBindingManager?.updateElementProperty(c,h,d)}catch(f){console.error(`Attribute binding update error for "${p}":`,f)}})}gatherAllComponentContextsInLoopItem(e){if(!this.componentManager)return{};const t={};if(e.hasAttribute(m.ATTR_PREFIXES.COMPONENT)){const i=e.getAttribute(m.ATTR_PREFIXES.COMPONENT),r=this.componentManager.buildComponentContext(i);Object.assign(t,r)}return e.querySelectorAll(`[${m.ATTR_PREFIXES.COMPONENT}]`).forEach(i=>{const r=i.getAttribute(m.ATTR_PREFIXES.COMPONENT),a=this.componentManager?.buildComponentContext(r);Object.assign(t,a)}),t}buildElementSpecificContext(e,t){if(!this.componentManager)return t;const n=P.getElementComponent(e),i=this.componentManager.buildComponentContext(n);return{...t,...i}}getTextNodeComponent(e){let t=e.parentElement;for(;t;){const n=t.getAttribute(m.ATTR_PREFIXES.COMPONENT);if(n)return n;t=t.parentElement}return"app"}updateDOMOrder(e,t){let n=e.placeholder;t.forEach(i=>{(i.element.parentElement!==e.parentElement||i.element!==n.nextSibling)&&e.parentElement.insertBefore(i.element,n.nextSibling),n=i.element})}clearRenderedItems(e){e.renderedItems.forEach(t=>{this.cleanupLoopItem(t)}),e.renderedItems=[]}cleanupLoopItem(e){this.loopItemElements.delete(e.element),this.loopItemContexts.delete(e.element),e.element.parentElement&&e.element.parentElement.removeChild(e.element),e.subscriptionIds.forEach(t=>{this.stateManager.removeSubscription(t)})}isLoopItem(e){return this.loopItemElements.has(e)}getLoopItemContext(e){return this.loopItemContexts.get(e)}cleanupDetachedTemplates(e){for(const t of e)t.type==="childList"&&t.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const i=n;if(document.contains(i))return;if(i.tagName==="TEMPLATE"&&i.hasAttribute("pp-for")){const a=i;document.contains(a)||this.cleanupTemplate(a)}i.querySelectorAll("template[pp-for]").forEach(a=>{const o=a;document.contains(o)||this.cleanupTemplate(o)})}})}cleanupTemplate(e){const t=this.loopBindings.get(e);t&&(this.clearRenderedItems(t),t.subscriptionIds.forEach(n=>{this.stateManager.removeSubscription(n)}),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 et{constructor(e){this.evaluator=e}render(e,t,n){const i=M.isSingleExpression(e);if(i)return this.evaluator.evaluateExpression(i,t,n);let r="";for(const a of M.parse(e))if(a.type==="static")r+=a.content;else if(a.expression)try{const o=this.evaluator.evaluateExpression(a.expression,t,n);r+=ue(o)}catch{}return r}dependencies(e,t,n){const i=M.extractExpressions(e),r=new Set;for(const a of i)for(const o of this.evaluator.extractDependencies(a,t,n))r.add(o);return[...r]}}class $s{static containsMustacheExpression(e){if(m.MUSTACHE_PATTERN.test(e))return!0;const n=M.decodeEntities(e);return m.MUSTACHE_PATTERN.test(n)}}export{Ut as L,Ws as P,et as T,$s as a};
1
+ var $s=Object.defineProperty,js=(e,t,n)=>t in e?$s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,d=(e,t,n)=>js(e,"symbol"!=typeof t?t+"":t,n),Ws=[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],ts=[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_・",ss="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟍꟐꟑꟓꟕ-Ƛꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",xt={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"},Et="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",Us={5:Et,"5module":Et+" export import",6:Et+" const class extends export import super"},qs=/^in(stanceof)?$/,zs=new RegExp("["+ss+"]"),Ks=new RegExp("["+ss+Hs+"]");function yt(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 le(e,t){return e<65?36===e:e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&zs.test(String.fromCharCode(e)):!1!==t&&yt(e,ts)))}function ve(e,t){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&Ks.test(String.fromCharCode(e)):!1!==t&&(yt(e,ts)||yt(e,Ws)))))}var R=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 ee(e,t){return new R(e,{beforeExpr:!0,binop:t})}var te={beforeExpr:!0},Q={startsExpr:!0},Mt={};function _(e,t){return void 0===t&&(t={}),t.keyword=e,Mt[e]=new R(e,t)}var h={num:new R("num",Q),regexp:new R("regexp",Q),string:new R("string",Q),name:new R("name",Q),privateId:new R("privateId",Q),eof:new R("eof"),bracketL:new R("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new R("]"),braceL:new R("{",{beforeExpr:!0,startsExpr:!0}),braceR:new R("}"),parenL:new R("(",{beforeExpr:!0,startsExpr:!0}),parenR:new R(")"),comma:new R(",",te),semi:new R(";",te),colon:new R(":",te),dot:new R("."),question:new R("?",te),questionDot:new R("?."),arrow:new R("=>",te),template:new R("template"),invalidTemplate:new R("invalidTemplate"),ellipsis:new R("...",te),backQuote:new R("`",Q),dollarBraceL:new R("${",{beforeExpr:!0,startsExpr:!0}),eq:new R("=",{beforeExpr:!0,isAssign:!0}),assign:new R("_=",{beforeExpr:!0,isAssign:!0}),incDec:new R("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new R("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:ee("||",1),logicalAND:ee("&&",2),bitwiseOR:ee("|",3),bitwiseXOR:ee("^",4),bitwiseAND:ee("&",5),equality:ee("==/!=/===/!==",6),relational:ee("</>/<=/>=",7),bitShift:ee("<</>>/>>>",8),plusMin:new R("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:ee("%",10),star:ee("*",10),slash:ee("/",10),starstar:new R("**",{beforeExpr:!0}),coalesce:ee("??",1),_break:_("break"),_case:_("case",te),_catch:_("catch"),_continue:_("continue"),_debugger:_("debugger"),_default:_("default",te),_do:_("do",{isLoop:!0,beforeExpr:!0}),_else:_("else",te),_finally:_("finally"),_for:_("for",{isLoop:!0}),_function:_("function",Q),_if:_("if"),_return:_("return",te),_switch:_("switch"),_throw:_("throw",te),_try:_("try"),_var:_("var"),_const:_("const"),_while:_("while",{isLoop:!0}),_with:_("with"),_new:_("new",{beforeExpr:!0,startsExpr:!0}),_this:_("this",Q),_super:_("super",Q),_class:_("class",Q),_extends:_("extends",te),_export:_("export"),_import:_("import",Q),_null:_("null",Q),_true:_("true",Q),_false:_("false",Q),_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})},J=/\r\n?|\n|\u2028|\u2029/,Xs=new RegExp(J.source,"g");function Le(e){return 10===e||13===e||8232===e||8233===e}function ns(e,t,n){void 0===n&&(n=e.length);for(var s=t;s<n;s++){var i=e.charCodeAt(s);if(Le(i))return s<n-1&&13===i&&10===e.charCodeAt(s+1)?s+2:s+1}return-1}var is=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,K=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,rs=Object.prototype,Gs=rs.hasOwnProperty,Qs=rs.toString,Ve=Object.hasOwn||function(e,t){return Gs.call(e,t)},Ht=Array.isArray||function(e){return"[object Array]"===Qs.call(e)},Ut=Object.create(null);function ye(e){return Ut[e]||(Ut[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function de(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}var Ys=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,He=function(e,t){this.line=e,this.column=t};He.prototype.offset=function(e){return new He(this.line,this.column+e)};var ct=function(e,t,n){this.start=t,this.end=n,null!==e.sourceFile&&(this.source=e.sourceFile)};function as(e,t){for(var n=1,s=0;;){var i=ns(e,s,t);if(i<0)return new He(n,t-s);++n,s=i}}var vt={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},qt=!1;function Js(e){var t={};for(var n in vt)t[n]=e&&Ve(e,n)?e[n]:vt[n];if("latest"===t.ecmaVersion?t.ecmaVersion=1e8:null==t.ecmaVersion?(!qt&&"object"==typeof console&&console.warn&&(qt=!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),Ht(t.onToken)){var s=t.onToken;t.onToken=function(e){return s.push(e)}}return Ht(t.onComment)&&(t.onComment=Zs(t,t.onComment)),t}function Zs(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 ct(this,a,o)),e.ranges&&(c.range=[i,r]),t.push(c)}}var Ue=1,Fe=2,It=4,os=8,Ot=16,cs=32,lt=64,ls=128,_e=256,ze=512,ut=Ue|Fe|_e;function Rt(e,t){return Fe|(e?It:0)|(t?os:0)}var et=0,Lt=1,ge=2,us=3,ps=4,hs=5,H=function(e,t,n){this.options=e=Js(e),this.sourceFile=e.sourceFile,this.keywords=ye(Us[e.ecmaVersion>=6?6:"module"===e.sourceType?"5module":5]);var s="";!0!==e.allowReserved&&(s=xt[e.ecmaVersion>=6?6:5===e.ecmaVersion?5:3],"module"===e.sourceType&&(s+=" await")),this.reservedWords=ye(s);var i=(s?s+" ":"")+xt.strict;this.reservedWordsStrict=ye(i),this.reservedWordsStrictBind=ye(i+" "+xt.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(J).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(Ue),this.regexpState=null,this.privateNameStack=[]},ue={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}};H.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)},ue.inFunction.get=function(){return(this.currentVarScope().flags&Fe)>0},ue.inGenerator.get=function(){return(this.currentVarScope().flags&os)>0},ue.inAsync.get=function(){return(this.currentVarScope().flags&It)>0},ue.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(_e|ze))return!1;if(t&Fe)return(t&It)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},ue.allowSuper.get=function(){return(this.currentThisScope().flags&lt)>0||this.options.allowSuperOutsideMethod},ue.allowDirectSuper.get=function(){return(this.currentThisScope().flags&ls)>0},ue.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},ue.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(_e|ze)||t&Fe&&!(t&Ot))return!0}return!1},ue.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&_e)>0},H.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},H.parse=function(e,t){return new this(t,e).parse()},H.parseExpressionAt=function(e,t,n){var s=new this(n,e,t);return s.nextToken(),s.parseExpression()},H.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(H.prototype,ue);var G=H.prototype,en=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;G.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){K.lastIndex=e,e+=K.exec(this.input)[0].length;var t=en.exec(this.input.slice(e));if(!t)return!1;if("use strict"===(t[1]||t[2])){K.lastIndex=e+t[0].length;var n=K.exec(this.input),s=n.index+n[0].length,i=this.input.charAt(s);return";"===i||"}"===i||J.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||"!"===i&&"="===this.input.charAt(s+1))}e+=t[0].length,K.lastIndex=e,e+=K.exec(this.input)[0].length,";"===this.input[e]&&e++}},G.eat=function(e){return this.type===e&&(this.next(),!0)},G.isContextual=function(e){return this.type===h.name&&this.value===e&&!this.containsEsc},G.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},G.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},G.canInsertSemicolon=function(){return this.type===h.eof||this.type===h.braceR||J.test(this.input.slice(this.lastTokEnd,this.start))},G.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},G.semicolon=function(){!this.eat(h.semi)&&!this.insertSemicolon()&&this.unexpected()},G.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},G.expect=function(e){this.eat(e)||this.unexpected()},G.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var pt=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};G.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")}},G.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")},G.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")},G.isSimpleAssignTarget=function(e){return"ParenthesizedExpression"===e.type?this.isSimpleAssignTarget(e.expression):"Identifier"===e.type||"MemberExpression"===e.type};var T=H.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 Vt={kind:"loop"},tn={kind:"switch"};T.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;K.lastIndex=this.pos;var t=K.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(le(s,!0)){for(var i=n+1;ve(s=this.input.charCodeAt(i),!0);)++i;if(92===s||s>55295&&s<56320)return!0;var r=this.input.slice(n,i);if(!qs.test(r))return!0}return!1},T.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;K.lastIndex=this.pos;var e,t=K.exec(this.input),n=this.pos+t[0].length;return!(J.test(this.input.slice(this.pos,n))||"function"!==this.input.slice(n,n+8)||n+8!==this.input.length&&(ve(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;K.lastIndex=this.pos;var n=K.exec(this.input),s=this.pos+n[0].length;if(J.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||ve(i=this.input.charCodeAt(r))||i>55295&&i<56320)return!1;K.lastIndex=r;var a=K.exec(this.input);if(a&&J.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&&(ve(o=this.input.charCodeAt(c))||o>55295&&o<56320)))return!1}var h=this.input.charCodeAt(s);return le(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){K.lastIndex=this.pos;var a=K.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(Vt),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(Vt),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 pt,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(tn),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(),J.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 sn=[];T.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t="Identifier"===e.type;return this.enterScope(t?cs:0),this.checkLValPattern(e,t?ps:ge),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(Vt),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?Lt:ge,!1)};var $e=1,St=2,fs=4;function nn(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 tt(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&fs&&this.type!==h.name?null:this.parseIdent(),e.id&&!(t&St)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Lt:ge:us));var r=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Rt(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&&nn(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&&tt(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&&tt(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 tt(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&tt(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(h.eq)?(this.enterScope(ze|lt),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(_e|lt);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,ge,!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];Ve(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|fs,!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),Ve(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=sn,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,ge),this.finishNode(e,"ImportSpecifier")},T.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,ge),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,ge),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;Ve(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 Ys.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 ie=H.prototype;ie.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},ie.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},ie.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")},ie.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")},ie.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()},ie.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},ie.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},ie.parseBindingListItem=function(e){return e},ie.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")},ie.checkLValSimple=function(e,t,n){void 0===t&&(t=et);var s=t!==et;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===ge&&"let"===e.name&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),n&&(Ve(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==hs&&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")}},ie.checkLValPattern=function(e,t,n){switch(void 0===t&&(t=et),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)}},ie.checkLValInnerPattern=function(e,t,n){switch(void 0===t&&(t=et),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 re=function(e,t,n,s,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=s,this.generator=!!i},D={b_stat:new re("{",!1),b_expr:new re("{",!0),b_tmpl:new re("${",!1),p_stat:new re("(",!1),p_expr:new re("(",!0),q_tmpl:new re("`",!0,!0,(function(e){return e.tryReadTemplateToken()})),f_stat:new re("function",!1),f_expr:new re("function",!0),f_expr_gen:new re("function",!0,!1,null,!0),f_gen:new re("function",!1,!1,null,!0)},De=H.prototype;De.initialContext=function(){return[D.b_stat]},De.curContext=function(){return this.context[this.context.length-1]},De.braceIsBlock=function(e){var t=this.curContext();return t===D.f_expr||t===D.f_stat||(e!==h.colon||t!==D.b_stat&&t!==D.b_expr?e===h._return||e===h.name&&this.exprAllowed?J.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===D.b_stat:e!==h._var&&e!==h._const&&e!==h.name&&!this.exprAllowed):!t.isExpr)},De.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},De.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},De.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===D.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)?D.b_stat:D.b_expr),this.exprAllowed=!0},h.dollarBraceL.updateContext=function(){this.context.push(D.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?D.p_stat:D.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()!==D.p_stat||e===h._return&&J.test(this.input.slice(this.lastTokEnd,this.start))||(e===h.colon||e===h.braceL)&&this.curContext()===D.b_stat?this.context.push(D.f_stat):this.context.push(D.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()===D.q_tmpl?this.context.pop():this.context.push(D.q_tmpl),this.exprAllowed=!1},h.star.updateContext=function(e){if(e===h._function){var t=this.context.length-1;this.context[t]===D.f_expr?this.context[t]=D.f_expr_gen:this.context[t]=D.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=H.prototype;function ds(e){return"Identifier"===e.type||"ParenthesizedExpression"===e.type&&ds(e.expression)}function Tt(e){return"MemberExpression"===e.type&&"PrivateIdentifier"===e.property.type||"ChainExpression"===e.type&&Tt(e.expression)||"ParenthesizedExpression"===e.type&&Tt(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 pt,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&&ds(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):"delete"===o.operator&&Tt(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 pt,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 x=this.startNodeAt(t,n);x.callee=e,x.arguments=g,o&&(x.optional=c),e=this.finishNode(x,"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 E=this.startNodeAt(t,n);E.tag=e,E.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(E,"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(D.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(D.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 pt,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,x=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,x)):n=l[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var E=this.startNodeAt(s,i);return E.expression=n,this.finishNode(E,"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 rn=[];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=rn,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)&&!J.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(Rt(t,s.generator)|lt|(n?ls: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(Rt(n,!1)|Ot),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,hs),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,Lt,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&ut)&&"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 st=H.prototype;st.raise=function(e,t){var n=as(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},st.raiseRecoverable=st.raise,st.curPosition=function(){if(this.options.locations)return new He(this.curLine,this.pos-this.lineStart)};var Se=H.prototype,an=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};Se.enterScope=function(e){this.scopeStack.push(new an(e))},Se.exitScope=function(){this.scopeStack.pop()},Se.treatFunctionsAsVarInScope=function(e){return e.flags&Fe||!this.inModule&&e.flags&Ue},Se.declareName=function(e,t,n){var s=!1;if(t===ge){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&Ue&&delete this.undefinedExports[e]}else if(t===ps){this.currentScope().lexical.push(e)}else if(t===us){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&cs&&o.lexical[0]===e)||!this.treatFunctionsAsVarInScope(o)&&o.functions.indexOf(e)>-1){s=!0;break}if(o.var.push(e),this.inModule&&o.flags&Ue&&delete this.undefinedExports[e],o.flags&ut)break}s&&this.raiseRecoverable(n,"Identifier '"+e+"' has already been declared")},Se.checkLocalExport=function(e){-1===this.scopeStack[0].lexical.indexOf(e.name)&&-1===this.scopeStack[0].var.indexOf(e.name)&&(this.undefinedExports[e.name]=e)},Se.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Se.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(ut|ze|_e))return t}},Se.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(ut|ze|_e)&&!(t.flags&Ot))return t}};var ht=function(e,t,n){this.type="",this.start=t,this.end=0,e.options.locations&&(this.loc=new ct(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},Ke=H.prototype;function ms(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}Ke.startNode=function(){return new ht(this,this.start,this.startLoc)},Ke.startNodeAt=function(e,t){return new ht(this,e,t)},Ke.finishNode=function(e,t){return ms.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},Ke.finishNodeAt=function(e,t,n,s){return ms.call(this,e,t,n,s)},Ke.copyNode=function(e){var t=new ht(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var on="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",gs="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",xs=gs+" Extended_Pictographic",Es=xs,Cs=xs+" EBase EComp EMod EPres ExtPict",bs=Cs,cn=Cs,ln={9:gs,10:xs,11:xs,12:Cs,13:Cs,14:cn},un="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",pn={9:"",10:"",11:"",12:"",13:"",14:un},zt="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",ys="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",vs=ys+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Ss=vs+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Ts=Ss+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",ws=Ts+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",hn=ws+" "+on,fn={9:ys,10:vs,11:Ss,12:Ts,13:ws,14:hn},As={};function dn(e){var t=As[e]={binary:ye(ln[e]+" "+zt),binaryOfStrings:ye(pn[e]),nonBinary:{General_Category:ye(zt),Script:ye(fn[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 Ct=0,Kt=[9,10,11,12,13,14];Ct<Kt.length;Ct+=1){var mn=Kt[Ct];dn(mn)}var S=H.prototype,nt=function(e,t){this.parent=e,this.base=t||this};nt.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},nt.prototype.sibling=function(){return new nt(this.parent,this.base)};var pe=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=As[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 gn(e){for(var t in e)return!0;return!1}function xn(e){return 105===e||109===e||115===e}function Ps(e){return 36===e||e>=40&&e<=43||46===e||63===e||e>=91&&e<=94||e>=123&&e<=125}function En(e){return le(e,!0)||36===e||95===e}function Cn(e){return ve(e,!0)||36===e||95===e||8204===e||8205===e}function Ns(e){return e>=65&&e<=90||e>=97&&e<=122}function bn(e){return e>=0&&e<=1114111}pe.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)},pe.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)},pe.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},pe.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},pe.prototype.current=function(e){return void 0===e&&(e=!1),this.at(this.pos,e)},pe.prototype.lookahead=function(e){return void 0===e&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},pe.prototype.advance=function(e){void 0===e&&(e=!1),this.pos=this.nextIndex(this.pos,e)},pe.prototype.eat=function(e,t){return void 0===t&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},pe.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&&gn(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 nt(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())&&xn(n);)t+=de(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!!Ps(t)&&(e.lastIntValue=t,e.advance(),!0)},S.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;-1!==(n=e.current())&&!Ps(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+=de(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=de(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),En(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),Cn(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()&&!ft(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!!Ns(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)&&bn(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 ks=0,me=1,se=2;function yn(e){return 100===e||68===e||115===e||83===e||119===e||87===e}function _s(e){return Ns(e)||95===e}function vn(e){return _s(e)||ft(e)}function Sn(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 Tn(e){return 40===e||41===e||45===e||47===e||e>=91&&e<=93||e>=123&&e<=125}function wn(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 ft(e){return e>=48&&e<=57}function Ms(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Is(e){return e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e-48}function Os(e){return e>=48&&e<=55}S.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(yn(t))return e.lastIntValue=-1,e.advance(),me;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===se&&e.raise("Invalid property name"),s;e.raise("Invalid property name")}return ks},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),me}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return ks},S.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){Ve(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)?me:e.switchV&&e.unicodeProperties.binaryOfStrings.test(t)?se:void e.raise("Invalid property name")},S.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";_s(t=e.current());)e.lastStringValue+=de(t),e.advance();return""!==e.lastStringValue},S.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";vn(t=e.current());)e.lastStringValue+=de(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===se&&e.raise("Negated character class may contain strings"),!0}return!1},S.regexp_classContents=function(e){return 93===e.current()?me:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),me)},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||Os(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=me;if(!this.regexp_eatClassSetRange(e))if(t=this.regexp_eatClassSetOperand(e)){t===se&&(n=se);for(var s=e.pos;e.eatChars([38,38]);)38!==e.current()&&(t=this.regexp_eatClassSetOperand(e))?t!==se&&(n=me):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===se&&(n=se)}},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)?me: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===se&&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)===se&&(t=se);return t},S.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return 1===t?me:se},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()&&Sn(n)||Tn(n))&&(e.advance(),e.lastIntValue=n,!0)},S.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return!!wn(t)&&(e.lastIntValue=t,e.advance(),!0)},S.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!ft(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;ft(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;Ms(n=e.current());)e.lastIntValue=16*e.lastIntValue+Is(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 Os(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(!Ms(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Is(i),e.advance()}return!0};var Ft=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new ct(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},k=H.prototype;function An(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function Rs(e){return"function"!=typeof BigInt?null:BigInt(e.replace(/_/g,""))}k.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 Ft(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},k.getToken=function(){return this.next(),new Ft(this)},typeof Symbol<"u"&&(k[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===h.eof,value:t}}}}),k.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())},k.readToken=function(e){return le(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},k.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},k.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=ns(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())},k.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&&!Le(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())},k.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&&is.test(String.fromCharCode(e))))break e;++this.pos}}},k.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)},k.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))},k.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)},k.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)},k.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)},k.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(h.assign,2):this.finishOp(h.bitwiseXOR,1)},k.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&&!J.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)},k.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())},k.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)},k.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)},k.readToken_numberSign=function(){var e=35;if(this.options.ecmaVersion>=13&&(++this.pos,le(e=this.fullCharCodeAtPos(),!0)||92===e))return this.finishToken(h.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+de(e)+"'")},k.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 '"+de(e)+"'")},k.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},k.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(J.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 pe(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})},k.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},k.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=Rs(this.input.slice(t,this.pos)),++this.pos):le(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(h.num,n)},k.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=Rs(this.input.slice(t,this.pos));return++this.pos,le(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")),le(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var r=An(this.input.slice(t,this.pos),n);return this.finishToken(h.num,r)},k.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},k.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)):(Le(s)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(h.string,t)};var Ls={};k.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==Ls)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},k.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Ls;this.raise(e,t)},k.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(Le(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}},k.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")},k.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 de(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 Le(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},k.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return null===n&&this.invalidStringToken(t,"Bad character escape sequence"),n},k.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(ve(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?le:ve)(a,s)||this.invalidStringToken(r,"Invalid Unicode escape"),e+=de(a),n=this.pos}t=!1}return e+this.input.slice(n,this.pos)},k.readWord=function(){var e=this.readWord1(),t=h.name;return this.keywords.test(e)&&(t=Mt[e]),this.finishToken(t,e)};var Pn="8.15.0";function U(e,t){return H.parse(e,t)}function Z(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 Xt(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 Dt(e,t,n){n(e,t)}function Me(e,t,n){}H.acorn={Parser:H,version:Pn,defaultOptions:vt,Position:He,SourceLocation:ct,getLineInfo:as,Node:ht,TokenType:R,tokTypes:h,keywordTypes:Mt,TokContext:re,tokContexts:D,isIdentifierChar:ve,isIdentifierStart:le,Token:Ft,isNewLine:Le,lineBreak:J,lineBreakG:Xs,nonASCIIwhitespace:is};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=Dt,b.EmptyStatement=Me,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=Me,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=Me,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=Me,b.MemberPattern=Dt,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=Dt,b.ThisExpression=b.Super=b.MetaProperty=Me,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=Me,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=Me,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 Nn{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 oe=class e{constructor(){d(this,"stateVariables",new Set)}transformRefDeclarations(e){try{const t=U(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return Z(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{Z(U(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=U(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return Z(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=U(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return Z(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=U(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});this.collectStateVariables(t);let n=this.transformShorthandProperties(e);const s=U(n,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0}),i=[],r=new Set,a=new Map;Xt(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 Z(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)}}),Xt(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=U(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return Z(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){Z(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=U(t,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let i=t;const r=[];return Z(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=U(e,{ecmaVersion:2022,sourceType:"script",allowReturnOutsideFunction:!0});let n=e;const s=[];return Z(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{Z(U(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{Z(U(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(oe,"instance"),d(oe,"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 je=oe;class kn{constructor(e,t){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 it(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=M.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=[];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)})),console.log(`🔄 Hydrating ${t.length} SSR items for "${e.ssrIdentifier}"`),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=M.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=rt(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)})),console.log(`🔄 Reconciling ${n.length} SSR items with ${t.length} state items`),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)console.log(`♻️ Reusing SSR element (was key: ${r.key}, now: ${o})`),i.add(r.element),r.key=o,this.updateItemContext(e,r,t,n),this.refreshLoopItemContent(r),s.push(r);else{console.log(`➕ Creating new item with key: ${o}`);const i=this.createLoopItem(e,t,n,o);i&&(s.push(i),this.processNestedLoopsInItem(i,e.component))}}})),n.forEach((e=>{i.has(e.element)||(console.log(`🗑️ Removing unused SSR item with key: ${e.key}`),this.cleanupLoopItem(e))})),this.updateDOMOrder(e,s),e.renderedItems=s,e.isSSR=!1,console.log(`✅ SSR hydration complete for "${e.ssrIdentifier}"`)}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=N.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(`[${x.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(x.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(x.ATTR_PREFIXES.COMPONENT)&&null!=(t=this.componentManager)&&t.hasStoredProps(n))return n;n=n.parentElement}return document.querySelectorAll(`[${x.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=B.isSingleExpression(i);if(r){const t=this.expressionEvaluator.evaluateExpression(r,s,e.component);return String(t)}{const t=B.parse(i);let n="";for(const i of t)if("static"===i.type)n+=i.content;else if(i.expression){n+=ke(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=M.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=M.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),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&&x.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){if(e.hasAttribute("pp-ref")){const s=e.getAttribute("pp-ref");this.processRefAttribute(e,s,t,n)}const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.hasAttribute("pp-ref")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let i;const r=[];for(;i=s.nextNode();)r.push(i);r.forEach((e=>{const s=e.getAttribute("pp-ref");this.processRefAttribute(e,s,t,n)}))}processRefAttribute(e,t,n,s){try{const i=B.decodeEntities(t),r=B.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("pp-ref")}catch(e){console.error("❌ Failed to process ref:",e)}}executeComponentScriptsInLoopItem(e){if(!this.componentManager)return;const t=[e],n=e.querySelectorAll(`[${x.ATTR_PREFIXES.COMPONENT}]`);t.push(...Array.from(n)),t.forEach((e=>{if(e.hasAttribute(x.ATTR_PREFIXES.COMPONENT)){const t=e.getAttribute(x.ATTR_PREFIXES.COMPONENT);if(t){const n=this.getLoopItemContextForElement(e),s=`${t}_${this.generateInstanceId(n)}`;e.setAttribute(x.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="${x.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(x.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&&x.MUSTACHE_PATTERN.test(n.value)&&(N.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(x.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("pp-ref")){const s=e.getAttribute("pp-ref");this.processRefInLoopContext(e,s,t,n),e.removeAttribute("pp-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("pp-ref")){const t=e.getAttribute("pp-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&&x.MUSTACHE_PATTERN.test(e.textContent)&&!N.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(x.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(N.isTextNodeInsideScript(e))return NodeFilter.FILTER_REJECT;if(e.textContent&&x.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(x.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=N.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(N.isTextNodeInsideScript(e))return NodeFilter.FILTER_REJECT;if(e.textContent&&x.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(x.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=N.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=B.decodeEntities(t),r=B.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("pp-ref")}catch(e){console.error("❌ processRefInLoopContext error:",e)}}getComponentForTextNode(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(x.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(x.ATTR_PREFIXES.COMPONENT);if(e){const t=N.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(x.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(x.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!==M.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=rt(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=N.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=M.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(x.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){const n=this.domBindingManager.eventDelegation;if(!n)return void console.warn("No event delegation manager available");const s=Array.from(e.attributes);for(const i of s)if(Re.isEventAttribute(i.name)){const s=i.name.substring(2);n.registerEventHandler(e,s,i.value,t),e.removeAttribute(i.name)}}processTextNodeWithLoopContext(e,t,n,s){if(N.isTextNodeInsideScript(e))return;const i=e.textContent||"";if(!B.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(x.ATTR_PREFIXES.COMPONENT);if(e){return t.__uniqueComponentName||e}t=t.parentElement}return"app"}updateTextNodeWithContext(e,t,n,s){const i=B.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+=ke(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!==x.ATTR_PREFIXES.COMPONENT&&"key"!==s.name&&!s.name.startsWith("on")&&s.value){const e=x.MUSTACHE_PATTERN.test(s.value),n=B.decodeEntities(s.value),i=x.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=M.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(x.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)},g={id:a,selector:"",dependencies:u,callback:()=>{d||f()},element:e,component:c};if(this.stateManager.addSubscription(g),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(x.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.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=N.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(x.ATTR_PREFIXES.COMPONENT)){const n=e.getAttribute(x.ATTR_PREFIXES.COMPONENT),s=this.componentManager.buildComponentContext(n);Object.assign(t,s)}return e.querySelectorAll(`[${x.ATTR_PREFIXES.COMPONENT}]`).forEach((e=>{var n;const s=e.getAttribute(x.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=N.getElementComponent(e),s=this.componentManager.buildComponentContext(n);return{...t,...s}}getTextNodeComponent(e){let t=e.parentElement;for(;t;){const e=t.getAttribute(x.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 it{constructor(e){this.evaluator=e}static containsMustacheExpression(e){if(x.MUSTACHE_PATTERN.test(e))return!0;const t=B.decodeEntities(e);return x.MUSTACHE_PATTERN.test(t)}render(e,t,n){const s=B.isSingleExpression(e);if(s)return this.evaluator.evaluateExpression(s,t,n);let i="";for(const s of B.parse(e))if("static"===s.type)i+=s.content;else if(s.expression)try{i+=ke(this.evaluator.evaluateExpression(s.expression,t,n))}catch{}return i}dependencies(e,t,n){const s=B.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 _n{constructor(e){d(this,"componentStack",["app"]),d(this,"elementProps",new WeakMap),d(this,"contextCache",new ne(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 Gt),d(this,"propDependencyCache",new Map),this.stateManager=e,this.updateBatcher=new Gt,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);return(null==(n=this.templateRenderer)?void 0:n.dependencies(r.expression,r.component,this.stateManager))||[]}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){if(window.app)for(const[e,t]of Object.entries(window.app))e in n||(n[e]=t);const e=this.componentFunctions.get("app");if(e)for(const[t,s]of e)t in n||(n[t]=s);const t=Object.keys(i).filter((e=>e.startsWith("app.")));for(const e of t){const t=e.substring(4);t in n||(n[t]=i[e])}}return n}getComponentPropDependencies(e,t){if(this.propDependencyCache.has(e))return this.propDependencyCache.get(e);const n=[],s=this.elementProps.get(e);s&&this.templateRenderer&&s.forEach((e=>{var t;const s=null==(t=this.templateRenderer)?void 0:t.dependencies(e.expression,e.component,this.stateManager);n.push(...s??[])}));const i=Array.from(new Set(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 it(e)}extractProps(e,t){const n=new Map,s=e.attributes,i=M.findScope(e),r=e.getAttribute(x.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!==x.ATTR_PREFIXES.COMPONENT&&i.name!==x.ATTR_PREFIXES.SPREAD&&i.name!==x.ATTR_PREFIXES.LOOP&&!Re.isEventAttribute(i.name)&&i.value&&it.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=B.extractExpressions(e);if(0===i.length)return!1;for(const e of i)try{const t=U(e,{ecmaVersion:2022,sourceType:"script"}),n=new Set,i=new Set;Z(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(x.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.buildComponentContext(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.buildComponentContext(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(`[${x.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;if("app"!==e){const e=this.componentFunctions.get("app");if(e)for(const[n,s]of e)n in t||(t[n]=s);if(window.app)for(const[e,n]of Object.entries(window.app))e in t||(t[e]=n)}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])}if("app"!==e)for(const e of Object.keys(s))if(e.startsWith("app.")){const n=e.substring(4);n in t||(t[n]=s[e])}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(x.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(x.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(x.ATTR_PREFIXES.COMPONENT);if(e)return e;t=t.parentElement}return"app"}getRelevantScripts(e,t){return Array.from(e.querySelectorAll(`script[type="${x.SCRIPT_TYPE}"]`)).filter((n=>{if(this.processedScripts.has(n))return!1;if(t)return!!n.hasAttribute(x.ATTR_PREFIXES.COMPONENT)||!n.closest(`[${x.ATTR_PREFIXES.COMPONENT}]`);let s=n.parentElement;for(;s&&s!==e;){if(s.hasAttribute(x.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=B.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!==M.findScope(e)}findComponentElementForScript(e,t){if(e.getAttribute(x.ATTR_PREFIXES.COMPONENT)===t)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(x.ATTR_PREFIXES.COMPONENT)===t)return n;n=n.parentElement}const s=document.querySelectorAll(`[${x.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${Vs(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=je.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=Object.keys(a),d=u.map((e=>a[e]));if(this.checkIfInLoopItem()){const e=this.extractLoopItemContext();this.domBindingManager.stateManager.currentLoopContext=e}try{new Function(...u,p).call(window[t],...d),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(a)),console.error("Should isolate:",o)}finally{this.domBindingManager.stateManager.currentLoopContext=null}}checkIfInLoopItem(){return!1}extractLoopItemContext(){return{}}extractVariableDeclarations(e){const t=je.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 je.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 Gt{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=N.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)&&N.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=N.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)}))}}class Mn{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=M.findScope(e);let s;if(n)s="app"===n?"app":n;else{const n=e.parentElement;s=n?N.getContextComponent(n):t}const i=e.textContent||"",r=B.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)||N.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(`[${x.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(x.ATTR_PREFIXES.COMPONENT)&&this.componentManager.hasStoredProps(t)){const e=this.componentManager.evaluateProps(t);s={...s,...e};break}t=t.parentElement}}return Bt(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+=ke(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(`[${x.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()}}class In{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 wt),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 ne(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===x.ATTR_PREFIXES.COMPONENT||null!==t&&Re.isEventAttribute(t)}return!1})),this.stateManager=e,this.componentManager=t,this.expressionEvaluator=n,this.textNodeManager=new Mn(n,e),this.textNodeManager.componentManager=this.componentManager,this.componentManager.setDOMBindingManager(this),this.setupMutationObserver(),this.eventDelegation.setupEventDelegation(),this.loopManager=new kn(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 it(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||!x.MUSTACHE_PATTERN.test(n.textContent)||N.isTextNodeInsideScript(n)||this.isTextNodeInsideLoopItem(n)||N.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 N.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=B.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=N.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=N.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=at.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("[pp-ref]").forEach((e=>{this.cleanupRefBinding(e)})),n.invalidateElement(e),M.invalidateTree(e);const s=e.getAttribute(x.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(x.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(x.ATTR_PREFIXES.COMPONENT);s&&n.invalidateByComponent(s)}s.forEach((e=>{M.invalidateTree(e)})),this.processMutationsBatch(t)})),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0,characterDataOldValue:!1,attributeFilter:[x.ATTR_PREFIXES.COMPONENT]})}processElement(e,t=!0){if(e===document.body){const n=Array.from(document.querySelectorAll(`[${x.ATTR_PREFIXES.COMPONENT}]`)).sort(((e,t)=>N.getElementDepth(e)-N.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=N.getElementComponent(e),s=M.findScope(e);let i;i=s?"app"===s?"app":s:N.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(x.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=At.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!(N.getElementComponent(t)!==n||this.processedElements.has(t))}),(e=>{if(!e.textContent||!x.MUSTACHE_PATTERN.test(e.textContent)||N.isTextNodeInsideScript(e)||this.isTextNodeInsideLoopItem(e))return!1;const t=e.parentElement;if(t){const s=N.getContextComponent(t),i=N.getComponentForNode(e);if(s!==n&&i!==n)return!1}else if(N.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("pp-ref")&&s){const e=t.getAttribute("pp-ref");this.createRefBinding(t,e,n),t.removeAttribute("pp-ref")}c.push(t),this.processedElements.add(t)}})),o.forEach((e=>{const t=e.parentElement,i=t?N.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("pp-ref")){const t=e.getAttribute("pp-ref");s&&this.createRefBinding(e,t,n),e.removeAttribute("pp-ref")}if(e.hasAttribute(x.ATTR_PREFIXES.SPREAD)){const t=e.getAttribute(x.ATTR_PREFIXES.SPREAD);s&&this.createSpreadDirectiveBinding(e,t,n),e.removeAttribute(x.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=B.decodeEntities(t),s=B.isSingleExpression(n)||n,i=N.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(`⚠️ pp-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=M.findScope(e),a=e.getAttribute(x.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!==x.ATTR_PREFIXES.COMPONENT&&"key"!==r.name&&!Re.isEventAttribute(r.name)&&(!i||!i.bindings.has(r.name))&&r.value){const t=x.MUSTACHE_PATTERN.test(r.value),s=B.decodeEntities(r.value),i=x.MUSTACHE_PATTERN.test(s);if(t||i){if(this.looksLikeSerializedObject(s))continue;const a=B.extractExpressions(s),h=N.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&&N.shouldBeDirectBinding(e,r.name)?n.set(r.name,s):c||n.set(r.name,s);continue}for(const t of a){const n=Ln.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&&N.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=M.findScope(e),r=null!==e.getAttribute(x.ATTR_PREFIXES.COMPONENT);let a,o=!1,c=!1;i?(a="app"===i?"app":i,c=!0,o=!1):r?(a=N.getParentComponentForElement(e),o=!0,c=!1):(a=N.getContextComponent(e),o=!1,c=!1),e.removeAttribute(t);let h=null,l=e.parentElement;for(;l&&l!==document.body;){if(l.hasAttribute(x.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(x.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(x.ATTR_PREFIXES.COMPONENT)===t)return e;let n=e.parentElement;for(;n;){if(n.getAttribute(x.ATTR_PREFIXES.COMPONENT)===t)return n;n=n.parentElement}const s=document.querySelectorAll(`[${x.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=M.findScope(e),s=n?"app"===n?"app":n:t;for(let t=0;t<e.attributes.length;t++){const n=e.attributes[t];if(Re.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=rt(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=ke(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&&x.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&&x.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&&x.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=N.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=N.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===x.ATTR_PREFIXES.COMPONENT||Re.isEventAttribute(s.name)||s.value&&x.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("[pp-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 be=class e{constructor(){d(this,"delegatedEvents",new Map),d(this,"elementHandlers",new WeakMap),d(this,"handlerCache",new ne(200)),d(this,"componentManager"),d(this,"expressionEvaluator"),d(this,"loopManager"),d(this,"setupEvents",new Set)}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=Bt(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=M.findScope(e),s=e.getAttribute(x.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(x.ATTR_PREFIXES.COMPONENT)===t)return s;s=s.parentElement}for(s=e.parentElement;s&&s!==document.body;){if(s.getAttribute(x.ATTR_PREFIXES.COMPONENT))return s;s=s.parentElement}const i=document.querySelectorAll(`[${x.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(x.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(x.ATTR_PREFIXES.COMPONENT)===e)return this.componentManager.buildComponentContextWithProps(e,n);if("app"===M.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(x.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(x.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(be,"eventCache",null);let wt=be;const Te=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(Te,"instance");let At=Te;const x={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:/\{((?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*)\}/},qe=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 On(e,t){let n;return(...s)=>{clearTimeout(n),n=window.setTimeout((()=>e(...s)),t)}}function Vs(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ke(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=>ke(e))).filter((e=>""!==e)).join("")}if("object"==typeof e)try{return JSON.stringify(e)}catch{return"[object Object]"}return String(e)}function Xe(e){return"function"==typeof e&&"__pphp_key"in e}function rt(e){return Xe(e)?e.value:e}function Fs(e,t={}){if(!Xe(e))return e;const n=e.value;return t.forComparison||t.forLogical||null==n||"boolean"==typeof n||"string"==typeof n||"number"==typeof n?n:!1===t.forPrimitive?e:n}function Bt(e,t=!1){const n={};for(const[s,i]of Object.entries(e))Xe(i)?n[s]=t?Fs(i):i.value:n[s]=i;return n}function Rn(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 M{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(x.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(this.scopeComments.add(e),"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(){if(this.commentsRemoved)return;console.debug(`Removing ${this.scopeComments.size} scope comments from DOM`);let e=0;for(const t of this.scopeComments)try{t.parentNode&&document.contains(t)&&(t.parentNode.removeChild(t),e++)}catch(e){console.error("Failed to remove scope comment:",e)}this.scopeComments.clear(),this.commentsRemoved=!0,console.debug(`Successfully removed ${e} scope comments`)}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.scopeComments.clear(),this.commentsRemoved=!1,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,scopeComments:this.scopeComments.size,commentsRemoved:this.commentsRemoved,lastCleanup:this.lastCleanup,cleanupScheduled:this.cleanupScheduled}}static forceCleanup(){this.cleanupScheduled=!0,this.performCleanup(),this.cleanupScheduled=!1}}d(M,"scopeCache",new WeakMap),d(M,"commentCache",new WeakMap),d(M,"trackedElements",new Set),d(M,"scopeComments",new Set),d(M,"commentsRemoved",!1),d(M,"cleanupScheduled",!1),d(M,"CLEANUP_INTERVAL",5e3),d(M,"MAX_TRACKED_ELEMENTS",1e3),d(M,"lastCleanup",0);class Ln{static validate(e,t){const n=[],s=[];try{const t=U(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 Z(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 U(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 U(t,{ecmaVersion:2022,sourceType:"script"}),!1}catch{}return!(qe.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 X=class e{constructor(){d(this,"componentElementsCache",new ne(100)),d(this,"scriptElementsCache",new ne(50)),d(this,"templateElementsCache",new ne(50)),d(this,"selectorCache",new ne(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(`[${x.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(x.ATTR_PREFIXES.COMPONENT);if(t)return this.elementComponentCache.set(e,t),t;let n=e.parentElement;for(;n;){const t=n.getAttribute(x.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=M.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(x.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(x.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="${x.SCRIPT_TYPE}"]`);for(const t of e)t instanceof HTMLScriptElement&&i.push(t)}else{const e=document.querySelectorAll(`script[type="${x.SCRIPT_TYPE}"]`);for(const n of e)if(n instanceof HTMLScriptElement){const e=n.getAttribute(x.ATTR_PREFIXES.COMPONENT);(e===t||!e&&!n.closest(`[${x.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=>M.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),M.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,M.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(X,"instance"),d(X,"CACHE_KEYS",{COMPONENT_ELEMENTS:e=>`comp:${e}`,SCRIPTS:(e,t)=>`scripts:${e}:${t}`,TEMPLATES:(e,t)=>`templates:${e}:${t}`,SELECTOR:e=>`sel:${e}`});let at=X;class Vn{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}}}const we=class e{static getDOMCache(){return this.domCache||(this.domCache=at.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=M.findScope(t),i=t.getAttribute(x.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(x.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(we,"FRAMEWORK_ATTRIBUTES",new Set(["pp-component","pp-for","pp-spread","pp-ref","key"])),d(we,"domCache");let N=we;class Re{static isEventAttribute(e){return e.startsWith("on")&&e.length>2&&!e.includes("-")}}class Pt{static findExistingStateKey(e,t,n){return[`${t}.${e}`,`app.${e}`,e].find((e=>e in n))||null}}class ne{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 ce=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=U(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=U(`(${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(ce,"EXPRESSION_CACHE",new ne(1e3)),d(ce,"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 B=ce;class Fn{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 Dn{constructor(){d(this,"subscriptionManager",new Vn),d(this,"stateStore",{}),d(this,"updateQueue",new Set),d(this,"isUpdating",!1),d(this,"eventBus",new Fn),d(this,"contextCache",new Map),d(this,"previousValues",new Map),d(this,"originalStateStore",{}),d(this,"domUpdateCallbacks",[]),d(this,"domUpdateScheduled",!1),d(this,"scheduleFlush",On((()=>{this.flushUpdates()}),x.DEBOUNCE_MS)),this.setupGlobalStateProxy(),setInterval((()=>{this.subscriptionManager.cleanupStaleSubscriptions()}),3e4)}clearSubscriptions(){const e=this.subscriptionManager.getAllSubscriptions();for(const[t]of e)this.subscriptionManager.removeSubscription(t);this.updateQueue.clear()}clearComponentSubscriptions(e){const t=this.subscriptionManager.getAllSubscriptions();for(const[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 Ae=class e{constructor(){d(this,"expressionCache",new ne(x.MAX_CACHE_SIZE)),d(this,"dependencyCache",new ne(x.MAX_CACHE_SIZE)),d(this,"commonExpressionsCache",new ne(100)),d(this,"dependencyParser",new Bn),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&&Rn(t);if(n)return Bt(e,!0);const s={};for(const[t,i]of Object.entries(e))Xe(i)?s[t]=Fs(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))qe.has(n)||!this.isValidJavaScriptIdentifier(n)||(t[n]=s);return t}isValidJavaScriptIdentifier(e){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)&&!qe.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(Ae,"CACHE_KEYS",{EXPRESSION:(e,t)=>`expr:${e}:${t}`,DEPENDENCY:(e,t)=>`deps:${e}:${t}`,COMMON:e=>`common:${e}`});let Nt=Ae;class Bn{constructor(){d(this,"parseCache",new ne(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(qe.has(e))continue;const n=e.indexOf("."),s=-1===n?e:e.substring(0,n),a=Pt.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 Ds{constructor(){d(this,"stateManager",new Dn),d(this,"expressionEvaluator",new Nt),d(this,"componentManager",new _n(this.stateManager)),d(this,"domBindingManager",new In(this.stateManager,this.componentManager,this.expressionEvaluator)),d(this,"hydrationCallbacks",new Set),d(this,"portalManager",new Nn),d(this,"initialized",!1),d(this,"hydrationDone",!1),d(this,"hydrationResolve"),d(this,"hydrationPromise"),d(this,"portalHydrationPromises",new Set),d(this,"portalHydrationResolvers",new Map),d(this,"currentLoopContext",null),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>this.initialize())):setTimeout((()=>this.initialize()),0),this.hydrationPromise=new Promise((e=>this.hydrationResolve=e))}initialize(){this.initialized||(this.initialized=!0,this.markHydrationStart(),this.componentManager.setExpressionEvaluator(this.expressionEvaluator),this.portalManager.setDependencies(this.componentManager,this.domBindingManager,this.stateManager,this),M.preCacheAllScopes(),this.componentManager.executePhpScripts(document.body),this.domBindingManager.processElement(document.body,!0),this.domBindingManager.processPendingBindings(),Promise.resolve().then((()=>{requestAnimationFrame((()=>{M.removeScopeComments(),this.markHydrated()}))})))}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(),M.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)}get isHydrated(){return this.hydrationDone}markHydrationStart(){document.dispatchEvent(new CustomEvent("pp:hydrationstart"))}markHydrated(){if(!this.hydrationDone){this.hydrationDone=!0,this.hydrationResolve();for(const e of this.hydrationCallbacks)try{e()}catch{}this.hydrationCallbacks.clear(),document.dispatchEvent(new CustomEvent("pp:hydrated",{detail:{at:performance.now()}}))}}state(e,t){const 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),Xe(i)&&(i=rt(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=()=>ke(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(" ")&&!qe.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=Pt.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=Pt.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${Vs(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(Ds,"instance",null);var Qt=11;function $n(e,t){var n,s,i,r,a=t.attributes;if(t.nodeType!==Qt&&e.nodeType!==Qt){for(var o=a.length-1;o>=0;o--)s=(n=a[o]).name,i=n.namespaceURI,r=n.value,i?(s=n.localName||s,e.getAttributeNS(i,s)!==r&&("xmlns"===n.prefix&&(s=n.name),e.setAttributeNS(i,s,r))):e.getAttribute(s)!==r&&e.setAttribute(s,r);for(var c=e.attributes,h=c.length-1;h>=0;h--)s=(n=c[h]).name,(i=n.namespaceURI)?(s=n.localName||s,t.hasAttributeNS(i,s)||e.removeAttributeNS(i,s)):t.hasAttribute(s)||e.removeAttribute(s)}}var Je,jn="http://www.w3.org/1999/xhtml",Y=typeof document>"u"?void 0:document,Wn=!!Y&&"content"in Y.createElement("template"),Hn=!!Y&&Y.createRange&&"createContextualFragment"in Y.createRange();function Un(e){var t=Y.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function qn(e){return Je||(Je=Y.createRange()).selectNode(Y.body),Je.createContextualFragment(e).childNodes[0]}function zn(e){var t=Y.createElement("body");return t.innerHTML=e,t.childNodes[0]}function Kn(e){return e=e.trim(),Wn?Un(e):Hn?qn(e):zn(e)}function Ze(e,t){var n,s,i=e.nodeName,r=t.nodeName;return i===r||(n=i.charCodeAt(0),s=r.charCodeAt(0),n<=90&&s>=97?i===r.toUpperCase():s<=90&&n>=97&&r===i.toUpperCase())}function Xn(e,t){return t&&t!==jn?Y.createElementNS(t,e):Y.createElement(e)}function Gn(e,t){for(var n=e.firstChild;n;){var s=n.nextSibling;t.appendChild(n),n=s}return t}function bt(e,t,n){e[n]!==t[n]&&(e[n]=t[n],e[n]?e.setAttribute(n,""):e.removeAttribute(n))}var Yt={OPTION:function(e,t){var n=e.parentNode;if(n){var s=n.nodeName.toUpperCase();"OPTGROUP"===s&&(s=(n=n.parentNode)&&n.nodeName.toUpperCase()),"SELECT"===s&&!n.hasAttribute("multiple")&&(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),n.selectedIndex=-1)}bt(e,t,"selected")},INPUT:function(e,t){bt(e,t,"checked"),bt(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var n=t.value;e.value!==n&&(e.value=n);var s=e.firstChild;if(s){var i=s.nodeValue;if(i==n||!n&&i==e.placeholder)return;s.nodeValue=n}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var n,s,i=-1,r=0,a=e.firstChild;a;)if("OPTGROUP"===(s=a.nodeName&&a.nodeName.toUpperCase()))a=(n=a).firstChild;else{if("OPTION"===s){if(a.hasAttribute("selected")){i=r;break}r++}!(a=a.nextSibling)&&n&&(a=n.nextSibling,n=null)}e.selectedIndex=i}}},Be=1,Jt=11,Zt=3,es=8;function Ce(){}function Qn(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function Yn(e){return function(t,n,s){if(s||(s={}),"string"==typeof n)if("#document"===t.nodeName||"HTML"===t.nodeName||"BODY"===t.nodeName){var i=n;(n=Y.createElement("html")).innerHTML=i}else n=Kn(n);else n.nodeType===Jt&&(n=n.firstElementChild);var r=s.getNodeKey||Qn,a=s.onBeforeNodeAdded||Ce,o=s.onNodeAdded||Ce,c=s.onBeforeElUpdated||Ce,h=s.onElUpdated||Ce,l=s.onBeforeNodeDiscarded||Ce,p=s.onNodeDiscarded||Ce,u=s.onBeforeElChildrenUpdated||Ce,d=s.skipFromChildren||Ce,m=s.addChild||function(e,t){return e.appendChild(t)},f=!0===s.childrenOnly,g=Object.create(null),x=[];function E(e){x.push(e)}function y(e,t){if(e.nodeType===Be)for(var n=e.firstChild;n;){var s=void 0;t&&(s=r(n))?E(s):(p(n),n.firstChild&&y(n,t)),n=n.nextSibling}}function b(e,t,n){!1!==l(e)&&(t&&t.removeChild(e),p(e),y(e,n))}function v(e){if(e.nodeType===Be||e.nodeType===Jt)for(var t=e.firstChild;t;){var n=r(t);n&&(g[n]=t),v(t),t=t.nextSibling}}function C(e){o(e);for(var t=e.firstChild;t;){var n=t.nextSibling,s=r(t);if(s){var i=g[s];i&&Ze(t,i)?(t.parentNode.replaceChild(i,t),S(i,t)):C(t)}else C(t);t=n}}function S(t,n,s){var i=r(n);if(i&&delete g[i],!s){var o=c(t,n);if(!1===o||(o instanceof HTMLElement&&v(t=o),e(t,n),h(t),!1===u(t,n)))return}"TEXTAREA"!==t.nodeName?function(e,t){var n,s,i,o,c,h=d(e,t),l=t.firstChild,p=e.firstChild;e:for(;l;){for(o=l.nextSibling,n=r(l);!h&&p;){if(i=p.nextSibling,l.isSameNode&&l.isSameNode(p)){l=o,p=i;continue e}s=r(p);var u=p.nodeType,f=void 0;if(u===l.nodeType&&(u===Be?(n?n!==s&&((c=g[n])?i===c?f=!1:(e.insertBefore(c,p),s?E(s):b(p,e,!0),s=r(p=c)):f=!1):s&&(f=!1),(f=!1!==f&&Ze(p,l))&&S(p,l)):(u===Zt||u==es)&&(f=!0,p.nodeValue!==l.nodeValue&&(p.nodeValue=l.nodeValue))),f){l=o,p=i;continue e}s?E(s):b(p,e,!0),p=i}if(n&&(c=g[n])&&Ze(c,l))h||m(e,c),S(c,l);else{var x=a(l);!1!==x&&(x&&(l=x),l.actualize&&(l=l.actualize(e.ownerDocument||Y)),m(e,l),C(l))}l=o,p=i}!function(e,t,n){for(;t;){var s=t.nextSibling;(n=r(t))?E(n):b(t,e,!0),t=s}}(e,p,s);var y=Yt[e.nodeName];y&&y(e,t)}(t,n):Yt.TEXTAREA(t,n)}v(t);var T=t,w=T.nodeType,A=n.nodeType;if(!f)if(w===Be)A===Be?Ze(t,n)||(p(t),T=Gn(t,Xn(n.nodeName,n.namespaceURI))):T=n;else if(w===Zt||w===es){if(A===w)return T.nodeValue!==n.nodeValue&&(T.nodeValue=n.nodeValue),T;T=n}if(T===n)p(t);else{if(n.isSameNode&&n.isSameNode(T))return;if(S(T,n,f),x)for(var N=0,_=x.length;N<_;N++){var P=g[x[N]];P&&b(P,P.parentNode,!1)}}return!f&&T!==t&&t.parentNode&&(T.actualize&&(T=T.actualize(t.ownerDocument||Y)),t.parentNode.replaceChild(T,t)),T}}var Jn=Yn($n);const We=class e extends Ds{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((()=>{this.isNavigating||(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||(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;if(s||"_blank"===t.target||t.hasAttribute("download")||"true"===t.getAttribute("pp-no-spa")||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.performCleanup(),this.updateBrowserHistory(e,t);const s=document.getElementById("loading-file-1B87E"),i="startViewTransition"in document;!s&&i?await this.updatePageContentWithViewTransition(n):this.updatePageContent(n),await this.reinitializeApp(),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){const t=await fetch(e,{headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/html"}});if(!t.ok)throw new Error(`Navigation failed: ${t.status} ${t.statusText}`);const n=await t.text();return(new DOMParser).parseFromString(n,"text/html")}performCleanup(){this.cleanup(),this.disableSPANavigation()}updateBrowserHistory(e,t){t&&history.pushState(null,"",e)}updatePageContent(e){e.title&&(document.title=e.title),this.reconcileHead(e);const t=e.body;Jn(document.body,t,{childrenOnly:!0,onBeforeElUpdated:(e,t)=>!e.isEqualNode(t)})}async reinitializeApp(){window.pp=null,e.instance=null;const t=window.pp;return await t.hydrated(),t}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(We,"instance",null);let ot=We;const Pe=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=ot.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(Pe,"instance",null);let kt=Pe;const Ne=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(Ne,"instance",null);let _t=Ne;function $t(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)}}$t("pp",ot),$t("store",kt),$t("searchParams",_t);export{kt as PPHPLocalStore,ot as PPHPUtilities,_t as SearchParamsManager};